diff options
-rw-r--r-- | core/controllers/welcome.php | 32 | ||||
-rw-r--r-- | core/views/welcome.html.php | 11 | ||||
-rw-r--r-- | modules/tag/helpers/tag_installer.php | 4 |
3 files changed, 43 insertions, 4 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index d8c69f97..ce039ead 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -213,6 +213,38 @@ class Welcome_Controller extends Template_Controller { url::redirect("welcome"); } + function add_tags($count) { + $items = ORM::factory("item")->find_all()->as_array(); + + if (empty($items)) { + url::redirect("welcome"); + } + + $tags_list = array("animation", "art", "blind", "blog", "bug-tracker", "bugs20", "canvas", + "classification", "cocktail", "exhibtion", "forum", "geo-tagging", "german", "germany", + "gl?ser", "graffiti", "illustration", "ITP", "javascript", "miami", "miknow", "nyc", "NYU", + "ontology", "open-source", "project", "school-of-information", "screenshot", "shiftspace", + "shop", "tagging", "talkingpoints", "university-of-michigan", "usability", "writing"); + + $tag_count = count($tags_list); + foreach ($items as $key => $item) { + $jump = ($key % 5) + 1; + for ($idx=0; $idx < $tag_count; $idx=$idx + $jump) { + $tag = ORM::factory("tag")->where("name", $tags_list[$idx])->find(); + if (!$tag->loaded) { + $tag->name = $tags_list[$idx]; + $tag->save(); + } + if (!$item->add($tag)) { + throw new Exception("@todo {$tag->name} WAS_NOT_ADDED_TO {$item->id}"); + } + } + $item->save(); + } + + url::redirect("welcome"); + } + public function profiler() { Session::instance()->set("use_profiler", $this->input->get("use_profiler", false)); $this->auto_render = false; diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php index f98ab167..154df8ce 100644 --- a/core/views/welcome.html.php +++ b/core/views/welcome.html.php @@ -182,17 +182,24 @@ <p> add: [ <? foreach (array(1, 10, 50, 100, 500, 1000) as $count): ?> - <?= html::anchor("welcome/add_albums_and_photos/$count", "$count") ?> + <?= html::anchor("welcome/add_albums_and_photos/$count", "$count") ?> <? endforeach ?> ] photos and albums </p> <p> add: [ <? foreach (array(1, 10, 50, 100, 500, 1000) as $count): ?> - <?= html::anchor("welcome/add_comments/$count", "$count") ?> + <?= html::anchor("welcome/add_comments/$count", "$count") ?> <? endforeach ?> ] comments </p> + <p> + add: [ + <? foreach (array(1, 10, 50, 100, 500, 1000) as $count): ?> + <?= html::anchor("welcome/add_tags/$count", "$count") ?> + <? endforeach ?> + ] tags + </p> <fieldset> <legend>Photos</legend> <form method="post" action="<?= url::site("albums/1") ?>" enctype="multipart/form-data"> diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php index de67bf08..6673ffcc 100644 --- a/modules/tag/helpers/tag_installer.php +++ b/modules/tag/helpers/tag_installer.php @@ -36,8 +36,8 @@ class tag_installer { `item_id` int(9) NOT NULL, `tag_id` int(9) NOT NULL, PRIMARY KEY (`id`), - KEY(`tag_id`), - KEY(`item_id`)) + KEY(`tag_id`, `id`), + KEY(`item_id`, `id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("tag", 1); } |