summaryrefslogtreecommitdiff
path: root/modules/tag/controllers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2011-04-23 20:30:30 -0700
committerTim Almdal <tnalmdal@shaw.ca>2011-04-23 20:30:30 -0700
commitc01a0eac9a09e0fc2ef4ba45a74c23a8a70f51b7 (patch)
tree078980159474ceab4eccc98ebfa2d898274f5c43 /modules/tag/controllers
parent4c7f27a1a6a4fc71873093dd787de05a8ee6c079 (diff)
Allow the tag rename function to split a tag into multiple tags if a comma is used to delinate the seperate tags.
Diffstat (limited to 'modules/tag/controllers')
-rw-r--r--modules/tag/controllers/admin_tags.php26
1 files changed, 22 insertions, 4 deletions
diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php
index fd82bc92..5dc181bd 100644
--- a/modules/tag/controllers/admin_tags.php
+++ b/modules/tag/controllers/admin_tags.php
@@ -85,11 +85,23 @@ class Admin_Tags_Controller extends Admin_Controller {
if ($in_place_edit->validate()) {
$old_name = $tag->name;
- $tag->name = $in_place_edit->value();
+ $tag_name = $in_place_edit->value();
+ Kohana_Log::add("error", $tag_name);
+ $tags = explode(",", $tag_name);
+ $tag_count = count($tags);
+
+ $tag->name = array_shift($tags);
$tag->save();
- $message = t("Renamed tag <b>%old_name</b> to <b>%new_name</b>",
- array("old_name" => $old_name, "new_name" => $tag->name));
+ if (!empty($tags)) {
+ $this->_copy_items_for_tags($tag, $tags);
+ $message = t("Split tag <i>%old_name</i> into <i>%new_tags</i>",
+ array("old_name" => $old_name, "new_tags" => $tag_name));
+ } else {
+ $message = t("Renamed tag <i>%old_name</i> to <i>%new_name</i>",
+ array("old_name" => $old_name, "new_name" => $tag->name));
+ }
+
message::success($message);
log::success("tags", $message);
@@ -99,5 +111,11 @@ class Admin_Tags_Controller extends Admin_Controller {
}
}
+ private function _copy_items_for_tags($tag, $tags) {
+ foreach ($tag->items() as $item) {
+ foreach ($tags as $idx => $new_tag) {
+ tag::add($item, trim($new_tag));
+ }
+ }
+ }
}
-