From c01a0eac9a09e0fc2ef4ba45a74c23a8a70f51b7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 20:30:30 -0700 Subject: Allow the tag rename function to split a tag into multiple tags if a comma is used to delinate the seperate tags. --- modules/tag/controllers/admin_tags.php | 26 ++++++++++++++++++++++---- 1 file 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 %old_name to %new_name", - array("old_name" => $old_name, "new_name" => $tag->name)); + if (!empty($tags)) { + $this->_copy_items_for_tags($tag, $tags); + $message = t("Split tag %old_name into %new_tags", + array("old_name" => $old_name, "new_tags" => $tag_name)); + } else { + $message = t("Renamed tag %old_name to %new_name", + 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)); + } + } + } } - -- cgit v1.2.3 From aba51feb3d330f30f0e3b68e16c31f6bb250ef02 Mon Sep 17 00:00:00 2001 From: Automatic Build Number Updater Date: Sat, 23 Apr 2011 20:30:32 -0700 Subject: Automated update of .build_number to 127 for branch master Last update: 4c7f27a1a6a4fc71873093dd787de05a8ee6c079 (1 commits ago) --- .build_number | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.build_number b/.build_number index f5cd72a8..20417d2b 100644 --- a/.build_number +++ b/.build_number @@ -3,4 +3,4 @@ ; process. You don't need to edit it. In fact.. ; ; DO NOT EDIT THIS FILE BY HAND! -build_number=126 +build_number=127 -- cgit v1.2.3 From 41f90e669f75e8e93bd31bf649011d5d315ac326 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 24 Apr 2011 07:04:11 -0700 Subject: Clarify the meaning of variable names. --- modules/tag/controllers/admin_tags.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php index 5dc181bd..7a64f7ab 100644 --- a/modules/tag/controllers/admin_tags.php +++ b/modules/tag/controllers/admin_tags.php @@ -85,18 +85,17 @@ class Admin_Tags_Controller extends Admin_Controller { if ($in_place_edit->validate()) { $old_name = $tag->name; - $tag_name = $in_place_edit->value(); - Kohana_Log::add("error", $tag_name); - $tags = explode(",", $tag_name); - $tag_count = count($tags); + $new_name_or_list = $in_place_edit->value(); + $tag_list = explode(",", $new_name_or_list); + $tag_count = count($tag_list); - $tag->name = array_shift($tags); + $tag->name = array_shift($tag_list); $tag->save(); - if (!empty($tags)) { - $this->_copy_items_for_tags($tag, $tags); - $message = t("Split tag %old_name into %new_tags", - array("old_name" => $old_name, "new_tags" => $tag_name)); + if (!empty($tag_list)) { + $this->_copy_items_for_tags($tag, $tag_list); + $message = t("Split tag %old_name into %tag_list", + array("old_name" => $old_name, "tag_list" => $new_name_or_list)); } else { $message = t("Renamed tag %old_name to %new_name", array("old_name" => $old_name, "new_name" => $tag->name)); @@ -111,10 +110,10 @@ class Admin_Tags_Controller extends Admin_Controller { } } - private function _copy_items_for_tags($tag, $tags) { + private function _copy_items_for_tags($tag, $tag_list) { foreach ($tag->items() as $item) { - foreach ($tags as $idx => $new_tag) { - tag::add($item, trim($new_tag)); + foreach ($tag_list as $new_tag_name) { + tag::add($item, trim($new_tag_name)); } } } -- cgit v1.2.3 From b57dd202db3c4b007e83aff3df9da7920691d76d Mon Sep 17 00:00:00 2001 From: Automatic Build Number Updater Date: Sun, 24 Apr 2011 07:06:14 -0700 Subject: Automated update of .build_number to 128 for branch master Last update: aba51feb3d330f30f0e3b68e16c31f6bb250ef02 (1 commits ago) --- .build_number | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.build_number b/.build_number index 20417d2b..68a5d742 100644 --- a/.build_number +++ b/.build_number @@ -3,4 +3,4 @@ ; process. You don't need to edit it. In fact.. ; ; DO NOT EDIT THIS FILE BY HAND! -build_number=127 +build_number=128 -- cgit v1.2.3