From b07bc1af082ea097adb77d2e78e69af3e20d8d29 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Apr 2011 16:15:56 -0700 Subject: Allow the administrator to set the number of tags to display in the cloud via the advanced settings. Fixes ticket #1649. --- modules/tag/controllers/tags.php | 3 ++- modules/tag/helpers/tag_block.php | 2 +- modules/tag/helpers/tag_installer.php | 7 ++++++- modules/tag/module.info | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'modules/tag') diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index fe6d747b..bf41c4df 100644 --- a/modules/tag/controllers/tags.php +++ b/modules/tag/controllers/tags.php @@ -22,7 +22,8 @@ class Tags_Controller extends Controller { // Far from perfection, but at least require view permission for the root album $album = ORM::factory("item", 1); access::required("view", $album); - print tag::cloud(30); + + print tag::cloud(module::get_var("tag", "tag_cloud_size", 30)); } public function create($item_id) { diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php index 8df58a6e..69a9a1c4 100644 --- a/modules/tag/helpers/tag_block.php +++ b/modules/tag/helpers/tag_block.php @@ -30,7 +30,7 @@ class tag_block_Core { $block->css_id = "g-tag"; $block->title = t("Popular tags"); $block->content = new View("tag_block.html"); - $block->content->cloud = tag::cloud(30); + $block->content->cloud = tag::cloud(module::get_var("tag", "tag_cloud_size", 30)); if ($theme->item() && $theme->page_subtype() != "tag" && access::can("edit", $theme->item())) { $controller = new Tags_Controller(); diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php index 16ad1239..66a78b91 100644 --- a/modules/tag/helpers/tag_installer.php +++ b/modules/tag/helpers/tag_installer.php @@ -36,7 +36,8 @@ class tag_installer { KEY(`tag_id`, `id`), KEY(`item_id`, `id`)) DEFAULT CHARSET=utf8;"); - module::set_version("tag", 2); + module::set_var("tag", "tag_cloud_size", 30); + module::set_version("tag", 3); } static function upgrade($version) { @@ -45,6 +46,10 @@ class tag_installer { $db->query("ALTER TABLE {tags} MODIFY COLUMN `name` VARCHAR(128)"); module::set_version("tag", $version = 2); } + if ($version == 2) { + module::set_var("tag", "tag_cloud_size", 30); + module::set_version("tag", $version = 3); + } } static function uninstall() { diff --git a/modules/tag/module.info b/modules/tag/module.info index 8851d119..d9d34386 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -1,3 +1,3 @@ name = "Tags" description = "Allows users to tag photos and albums" -version = 2 +version = 3 -- cgit v1.2.3 From 9dd91b55b03923ef3058fb965b0c927d101a396f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 07:42:28 -0700 Subject: Insure that the tag count to display is always greater than 1. Refixes #1649. --- modules/tag/helpers/tag.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/tag') diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 733215b3..742783d1 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -48,6 +48,7 @@ class tag_Core { * @return ORM_Iterator of Tag_Model in descending tag count order */ static function popular_tags($count) { + $count = $count >= 1 ? $count : 30; return ORM::factory("tag") ->order_by("count", "DESC") ->limit($count) -- cgit v1.2.3 From 0ec819d38161ead063c4dbd953b4b55a33a42f80 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 07:46:38 -0700 Subject: Insure that the tag count to display is always greater than 0. Refixes #1649. --- modules/tag/helpers/tag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/tag') diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 742783d1..c21104ee 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -48,7 +48,7 @@ class tag_Core { * @return ORM_Iterator of Tag_Model in descending tag count order */ static function popular_tags($count) { - $count = $count >= 1 ? $count : 30; + $count = max($count, 1); return ORM::factory("tag") ->order_by("count", "DESC") ->limit($count) -- cgit v1.2.3 From c101151616033d53587d1435881dae0fa45aeefa Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sat, 23 Apr 2011 12:04:12 -0400 Subject: Allow tags to be merged by renaming * Fixes #1628 --- modules/gallery/libraries/InPlaceEdit.php | 8 +++-- modules/tag/controllers/admin_tags.php | 11 +------ modules/tag/models/tag.php | 24 ++++++++++----- modules/tag/tests/Tag_Test.php | 50 ++++++++++++++++++++++++++++--- 4 files changed, 70 insertions(+), 23 deletions(-) (limited to 'modules/tag') diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php index 88c30494..739cbb61 100644 --- a/modules/gallery/libraries/InPlaceEdit.php +++ b/modules/gallery/libraries/InPlaceEdit.php @@ -56,8 +56,12 @@ class InPlaceEdit_Core { } public function validate() { - $post = Validation::factory($_POST) - ->add_callbacks("input", $this->callback); + $post = Validation::factory($_POST); + + if (!empty($this->callback)) { + $post->add_callbacks("input", $this->callback); + } + foreach ($this->rules as $rule) { $post->add_rules("input", $rule); } diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php index 73042a55..fd82bc92 100644 --- a/modules/tag/controllers/admin_tags.php +++ b/modules/tag/controllers/admin_tags.php @@ -81,9 +81,7 @@ class Admin_Tags_Controller extends Admin_Controller { $in_place_edit = InPlaceEdit::factory($tag->name) ->action("admin/tags/rename/$tag->id") - ->rules(array("required", "length[1,64]")) - ->messages(array("in_use" => t("There is already a tag with that name"))) - ->callback(array($this, "check_for_duplicate")); + ->rules(array("required", "length[1,64]")); if ($in_place_edit->validate()) { $old_name = $tag->name; @@ -101,12 +99,5 @@ class Admin_Tags_Controller extends Admin_Controller { } } - public function check_for_duplicate(Validation $post_data, $field) { - $tag_exists = ORM::factory("tag")->where("name", "=", $post_data[$field])->count_all(); - if ($tag_exists) { - $post_data->add_error($field, "in_use"); - } - } - } diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index bd665667..bb79e707 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -69,13 +69,23 @@ class Tag_Model_Core extends ORM { * to this tag. */ public function save() { - $related_item_ids = array(); - foreach (db::build() - ->select("item_id") - ->from("items_tags") - ->where("tag_id", "=", $this->id) - ->execute() as $row) { - $related_item_ids[$row->item_id] = 1; + // Check to see if another tag exists with the same name + $duplicate_tag = ORM::factory("tag") + ->where("name", "=", $this->name) + ->where("id", "!=", $this->id) + ->find(); + if ($duplicate_tag->loaded()) { + // If so, tag its items with this tag so as to merge it + $duplicate_tag_items = ORM::factory("item") + ->join("items_tags", "items.id", "items_tags.item_id") + ->where("items_tags.tag_id", "=", $duplicate_tag->id) + ->find_all(); + foreach ($duplicate_tag_items as $item) { + $this->add($item); + } + + // ... and remove the duplicate tag + $duplicate_tag->delete(); } if (isset($this->object_relations["items"])) { diff --git a/modules/tag/tests/Tag_Test.php b/modules/tag/tests/Tag_Test.php index f5ccb3a2..9e10fa4a 100644 --- a/modules/tag/tests/Tag_Test.php +++ b/modules/tag/tests/Tag_Test.php @@ -18,18 +18,60 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Tag_Test extends Gallery_Unit_Test_Case { + public function teardown() { + ORM::factory("tag")->delete_all(); + } + public function create_tag_test() { $album = test::random_album(); tag::add($album, "tag1"); $tag = ORM::factory("tag")->where("name", "=", "tag1")->find(); - $this->assert_true(1, $tag->count); + $this->assert_equal(1, $tag->count); // Make sure adding the tag again doesn't increase the count tag::add($album, "tag1"); - $this->assert_true(1, $tag->reload()->count); + $this->assert_equal(1, $tag->reload()->count); tag::add(test::random_album(), "tag1"); - $this->assert_true(2, $tag->reload()->count); + $this->assert_equal(2, $tag->reload()->count); + } + + public function rename_merge_tag_test() { + $album1 = test::random_album(); + $album2 = test::random_album(); + + tag::add($album1, "tag1"); + tag::add($album2, "tag2"); + + $tag1 = ORM::factory("tag")->where("name", "=", "tag1")->find(); + $tag1->name = "tag2"; + $tag1->save(); + + // Tags should be merged; $tag2 should be deleted + $tag1->reload(); + + $this->assert_equal(2, $tag1->count); + $this->assert_true($tag1->has($album1)); + $this->assert_true($tag1->has($album2)); + $this->assert_equal(1, ORM::factory("tag")->count_all()); + } + + public function rename_merge_tag_with_same_items_test() { + $album = test::random_album(); + + tag::add($album, "tag1"); + tag::add($album, "tag2"); + + $tag1 = ORM::factory("tag")->where("name", "=", "tag1")->find(); + $tag1->name = "tag2"; + $tag1->save(); + + // Tags should be merged + $tag1->reload(); + + $this->assert_equal(1, $tag1->count); + $this->assert_true($tag1->has($album)); + $this->assert_equal(1, ORM::factory("tag")->count_all()); } -} \ No newline at end of file +} -- cgit v1.2.3 From 5ce85636329b14673718836b3631a3e46efdc3bb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 13:20:22 -0700 Subject: Move the calculation for item_related_update ahead of the duplicate tag merge so that we don't trigger an item_related_update on items who semantically have the same tag after the merge. Follow-on for #1628. --- modules/tag/models/tag.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'modules/tag') diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index bb79e707..d4e385a2 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -69,13 +69,24 @@ class Tag_Model_Core extends ORM { * to this tag. */ public function save() { + // Figure out what items have changed in this tag for our item_related_update event below + if (isset($this->object_relations["items"])) { + $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); + $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); + if (isset($this->changed_relations["items"])) { + $changed = array_merge($added, $removed); + } + $this->count = count($this->object_relations["items"]) + count($added) - count($removed); + } + // Check to see if another tag exists with the same name $duplicate_tag = ORM::factory("tag") ->where("name", "=", $this->name) ->where("id", "!=", $this->id) ->find(); if ($duplicate_tag->loaded()) { - // If so, tag its items with this tag so as to merge it + // If so, tag its items with this tag so as to merge it. Do this after we figure out what's + // changed so that we don't notify on this change to keep churn down. $duplicate_tag_items = ORM::factory("item") ->join("items_tags", "items.id", "items_tags.item_id") ->where("items_tags.tag_id", "=", $duplicate_tag->id) @@ -88,15 +99,6 @@ class Tag_Model_Core extends ORM { $duplicate_tag->delete(); } - if (isset($this->object_relations["items"])) { - $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); - $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); - if (isset($this->changed_relations["items"])) { - $changed = array_merge($added, $removed); - } - $this->count = count($this->object_relations["items"]) + count($added) - count($removed); - } - $result = parent::save(); if (!empty($changed)) { -- cgit v1.2.3 From ba20d5a500fbc724376a2fc749ee2c645041a6e1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 14:46:07 -0700 Subject: Oops, this is the rest of the modules and themes for #1696 and #1698. --- modules/akismet/module.info | 4 ++++ modules/comment/module.info | 4 ++++ modules/digibug/module.info | 4 ++++ modules/exif/module.info | 4 ++++ modules/g2_import/module.info | 4 ++++ modules/image_block/module.info | 4 ++++ modules/info/module.info | 4 ++++ modules/notification/module.info | 4 ++++ modules/organize/module.info | 4 ++++ modules/recaptcha/module.info | 4 ++++ modules/rest/module.info | 4 ++++ modules/rss/module.info | 4 ++++ modules/search/module.info | 4 ++++ modules/server_add/module.info | 4 ++++ modules/slideshow/module.info | 4 ++++ modules/tag/module.info | 4 ++++ modules/user/module.info | 4 ++++ modules/watermark/module.info | 4 ++++ themes/admin_wind/theme.info | 4 ++++ themes/wind/theme.info | 4 ++++ 20 files changed, 80 insertions(+) (limited to 'modules/tag') diff --git a/modules/akismet/module.info b/modules/akismet/module.info index b61ed107..afc649d3 100644 --- a/modules/akismet/module.info +++ b/modules/akismet/module.info @@ -1,3 +1,7 @@ name = "Akismet" description = "Filter comments through the Akismet web service to detect and eliminate spam (http://akismet.com). You'll need a WordPress.com API key to use it." version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:akismet" +discuss_url = "http://gallery.menalto.com/forum_module_akismet" diff --git a/modules/comment/module.info b/modules/comment/module.info index e5aa454d..63c6af1c 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,7 @@ name = "Comments" description = "Allows users and guests to leave comments on photos and albums." version = 4 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:comment" +discuss_url = "http://gallery.menalto.com/forum_module_comment" diff --git a/modules/digibug/module.info b/modules/digibug/module.info index be4e880a..ce437611 100644 --- a/modules/digibug/module.info +++ b/modules/digibug/module.info @@ -1,3 +1,7 @@ name = "Digibug" description = "Digibug Photo Printing Module" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:digibug" +discuss_url = "http://gallery.menalto.com/forum_module_digibug" diff --git a/modules/exif/module.info b/modules/exif/module.info index c8ae688e..c2ffbfa7 100644 --- a/modules/exif/module.info +++ b/modules/exif/module.info @@ -1,3 +1,7 @@ name = "Exif Data" description = "Extract Exif data and display it on photo pages." version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:exif" +discuss_url = "http://gallery.menalto.com/forum_module_exif" diff --git a/modules/g2_import/module.info b/modules/g2_import/module.info index 977af251..0e766255 100644 --- a/modules/g2_import/module.info +++ b/modules/g2_import/module.info @@ -1,3 +1,7 @@ name = "Gallery2 Import" description = "Import your Gallery 2 content into Gallery 3" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:g2_import" +discuss_url = "http://gallery.menalto.com/forum_module_g2_import" diff --git a/modules/image_block/module.info b/modules/image_block/module.info index 6836fabc..aa3c5461 100644 --- a/modules/image_block/module.info +++ b/modules/image_block/module.info @@ -1,3 +1,7 @@ name = "Image Block" description = "Display a random image in the sidebar" version = 3 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:image_block" +discuss_url = "http://gallery.menalto.com/forum_module_image_block" diff --git a/modules/info/module.info b/modules/info/module.info index 5f84cbb9..e8f30594 100644 --- a/modules/info/module.info +++ b/modules/info/module.info @@ -1,3 +1,7 @@ name = "Info" description = "Display extra information about photos and albums" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:info" +discuss_url = "http://gallery.menalto.com/forum_module_info" diff --git a/modules/notification/module.info b/modules/notification/module.info index 8c5e1162..dacc00f9 100644 --- a/modules/notification/module.info +++ b/modules/notification/module.info @@ -1,3 +1,7 @@ name = "Notification" description = "Send notifications to users when changes are made to watched albums." version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:notification" +discuss_url = "http://gallery.menalto.com/forum_module_notification" diff --git a/modules/organize/module.info b/modules/organize/module.info index 0d16144d..31d24379 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -1,3 +1,7 @@ name = "Organize" description = "Visually rearrange and move photos in your gallery" version = 4 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:organize" +discuss_url = "http://gallery.menalto.com/forum_module_organize" diff --git a/modules/recaptcha/module.info b/modules/recaptcha/module.info index cfa1bf7a..2a0b419b 100644 --- a/modules/recaptcha/module.info +++ b/modules/recaptcha/module.info @@ -1,3 +1,7 @@ name = "reCAPTCHA" description = "reCAPTCHA displays a graphical verification that protects the input form from abuse from 'bots,' or automated programs usually written to generate spam (http://recaptcha.net)." version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:recaptcha" +discuss_url = "http://gallery.menalto.com/forum_module_recaptcha" diff --git a/modules/rest/module.info b/modules/rest/module.info index 5aaffc28..c71c64f9 100644 --- a/modules/rest/module.info +++ b/modules/rest/module.info @@ -2,3 +2,7 @@ name = "REST API Module" description = "A REST-based API that allows desktop clients and other apps to interact with Gallery 3" version = 3 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:rest" +discuss_url = "http://gallery.menalto.com/forum_module_rest" diff --git a/modules/rss/module.info b/modules/rss/module.info index 48375da1..5ebae9e7 100644 --- a/modules/rss/module.info +++ b/modules/rss/module.info @@ -1,3 +1,7 @@ name = "RSS" description = "Provides RSS feeds" version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:rss" +discuss_url = "http://gallery.menalto.com/forum_module_rss" diff --git a/modules/search/module.info b/modules/search/module.info index f417c4fa..a1c58af5 100644 --- a/modules/search/module.info +++ b/modules/search/module.info @@ -1,3 +1,7 @@ name = "Search" description = "Allows users to search their Gallery" version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:search" +discuss_url = "http://gallery.menalto.com/forum_module_search" diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 87b317b1..754e06c1 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -1,3 +1,7 @@ name = "Server Add" description = "Allows authorized users to load images directly from your web server" version = 4 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:server_add" +discuss_url = "http://gallery.menalto.com/forum_module_server_add" diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info index b56eac81..55cdf9b8 100644 --- a/modules/slideshow/module.info +++ b/modules/slideshow/module.info @@ -1,3 +1,7 @@ name = "Slideshow" description = "Allows users to view a slideshow of photos" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:slideshow" +discuss_url = "http://gallery.menalto.com/forum_module_slideshow" diff --git a/modules/tag/module.info b/modules/tag/module.info index d9d34386..59d8dfbd 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -1,3 +1,7 @@ name = "Tags" description = "Allows users to tag photos and albums" version = 3 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:tag" +discuss_url = "http://gallery.menalto.com/forum_module_tag" diff --git a/modules/user/module.info b/modules/user/module.info index b7594815..f6dd9529 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -2,3 +2,7 @@ name = "Users and Groups" description = "Gallery 3 user and group management" version = 4 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:user" +discuss_url = "http://gallery.menalto.com/forum_module_user" diff --git a/modules/watermark/module.info b/modules/watermark/module.info index 41a871bd..1f440016 100644 --- a/modules/watermark/module.info +++ b/modules/watermark/module.info @@ -1,3 +1,7 @@ name = "Watermarks" description = "Allows users to watermark their photos" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:watermark" +discuss_url = "http://gallery.menalto.com/forum_module_watermark" diff --git a/themes/admin_wind/theme.info b/themes/admin_wind/theme.info index 4034b64a..aca5c6c5 100644 --- a/themes/admin_wind/theme.info +++ b/themes/admin_wind/theme.info @@ -4,3 +4,7 @@ version = 1 author = "Gallery Team" admin = 1 site = 0 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Theme:admin_wind" +discuss_url = "http://gallery.menalto.com/forum_theme_admin_wind" diff --git a/themes/wind/theme.info b/themes/wind/theme.info index 17ea7c20..c2344c48 100644 --- a/themes/wind/theme.info +++ b/themes/wind/theme.info @@ -4,3 +4,7 @@ version = 1 author = "Gallery Team" site = 1 admin = 0 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Theme:wind" +discuss_url = "http://gallery.menalto.com/forum_theme_wind" -- cgit v1.2.3 From c07af35a19905f3241fb77662e8b7c84e41e9a62 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 14:53:34 -0700 Subject: Oops, fix broken codex urls. For #1698. --- modules/akismet/module.info | 2 +- modules/comment/module.info | 2 +- modules/digibug/module.info | 2 +- modules/exif/module.info | 2 +- modules/g2_import/module.info | 2 +- modules/gallery/module.info | 2 +- modules/image_block/module.info | 2 +- modules/info/module.info | 2 +- modules/notification/module.info | 2 +- modules/organize/module.info | 2 +- modules/recaptcha/module.info | 2 +- modules/rest/module.info | 2 +- modules/rss/module.info | 2 +- modules/search/module.info | 2 +- modules/server_add/module.info | 2 +- modules/slideshow/module.info | 2 +- modules/tag/module.info | 2 +- modules/user/module.info | 2 +- modules/watermark/module.info | 2 +- themes/admin_wind/theme.info | 2 +- themes/wind/theme.info | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) (limited to 'modules/tag') diff --git a/modules/akismet/module.info b/modules/akismet/module.info index afc649d3..63473468 100644 --- a/modules/akismet/module.info +++ b/modules/akismet/module.info @@ -3,5 +3,5 @@ description = "Filter comments through the Akismet web service to detect and eli version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:akismet" +info_url = "http://codex.gallery2.org/Gallery3:Modules:akismet" discuss_url = "http://gallery.menalto.com/forum_module_akismet" diff --git a/modules/comment/module.info b/modules/comment/module.info index 63c6af1c..4e7df6f1 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -3,5 +3,5 @@ description = "Allows users and guests to leave comments on photos and albums." version = 4 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:comment" +info_url = "http://codex.gallery2.org/Gallery3:Modules:comment" discuss_url = "http://gallery.menalto.com/forum_module_comment" diff --git a/modules/digibug/module.info b/modules/digibug/module.info index ce437611..781d5f01 100644 --- a/modules/digibug/module.info +++ b/modules/digibug/module.info @@ -3,5 +3,5 @@ description = "Digibug Photo Printing Module" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:digibug" +info_url = "http://codex.gallery2.org/Gallery3:Modules:digibug" discuss_url = "http://gallery.menalto.com/forum_module_digibug" diff --git a/modules/exif/module.info b/modules/exif/module.info index c2ffbfa7..e266e20e 100644 --- a/modules/exif/module.info +++ b/modules/exif/module.info @@ -3,5 +3,5 @@ description = "Extract Exif data and display it on photo pages." version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:exif" +info_url = "http://codex.gallery2.org/Gallery3:Modules:exif" discuss_url = "http://gallery.menalto.com/forum_module_exif" diff --git a/modules/g2_import/module.info b/modules/g2_import/module.info index 0e766255..30fb46d4 100644 --- a/modules/g2_import/module.info +++ b/modules/g2_import/module.info @@ -3,5 +3,5 @@ description = "Import your Gallery 2 content into Gallery 3" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:g2_import" +info_url = "http://codex.gallery2.org/Gallery3:Modules:g2_import" discuss_url = "http://gallery.menalto.com/forum_module_g2_import" diff --git a/modules/gallery/module.info b/modules/gallery/module.info index fc522d78..42345531 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -3,5 +3,5 @@ description = "Gallery core application" version = 49 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:gallery" +info_url = "http://codex.gallery2.org/Gallery3:Modules:gallery" discuss_url = "http://gallery.menalto.com/forum_module_gallery" diff --git a/modules/image_block/module.info b/modules/image_block/module.info index aa3c5461..6722cc8f 100644 --- a/modules/image_block/module.info +++ b/modules/image_block/module.info @@ -3,5 +3,5 @@ description = "Display a random image in the sidebar" version = 3 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:image_block" +info_url = "http://codex.gallery2.org/Gallery3:Modules:image_block" discuss_url = "http://gallery.menalto.com/forum_module_image_block" diff --git a/modules/info/module.info b/modules/info/module.info index e8f30594..f8964a78 100644 --- a/modules/info/module.info +++ b/modules/info/module.info @@ -3,5 +3,5 @@ description = "Display extra information about photos and albums" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:info" +info_url = "http://codex.gallery2.org/Gallery3:Modules:info" discuss_url = "http://gallery.menalto.com/forum_module_info" diff --git a/modules/notification/module.info b/modules/notification/module.info index dacc00f9..84be8f99 100644 --- a/modules/notification/module.info +++ b/modules/notification/module.info @@ -3,5 +3,5 @@ description = "Send notifications to users when changes are made to watched albu version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:notification" +info_url = "http://codex.gallery2.org/Gallery3:Modules:notification" discuss_url = "http://gallery.menalto.com/forum_module_notification" diff --git a/modules/organize/module.info b/modules/organize/module.info index 31d24379..07b9dc38 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -3,5 +3,5 @@ description = "Visually rearrange and move photos in your gallery" version = 4 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:organize" +info_url = "http://codex.gallery2.org/Gallery3:Modules:organize" discuss_url = "http://gallery.menalto.com/forum_module_organize" diff --git a/modules/recaptcha/module.info b/modules/recaptcha/module.info index 2a0b419b..ebaff7de 100644 --- a/modules/recaptcha/module.info +++ b/modules/recaptcha/module.info @@ -3,5 +3,5 @@ description = "reCAPTCHA displays a graphical verification that protects the inp version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:recaptcha" +info_url = "http://codex.gallery2.org/Gallery3:Modules:recaptcha" discuss_url = "http://gallery.menalto.com/forum_module_recaptcha" diff --git a/modules/rest/module.info b/modules/rest/module.info index c71c64f9..33c9f1cf 100644 --- a/modules/rest/module.info +++ b/modules/rest/module.info @@ -4,5 +4,5 @@ description = "A REST-based API that allows desktop clients and other apps to in version = 3 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:rest" +info_url = "http://codex.gallery2.org/Gallery3:Modules:rest" discuss_url = "http://gallery.menalto.com/forum_module_rest" diff --git a/modules/rss/module.info b/modules/rss/module.info index 5ebae9e7..cd13c1b0 100644 --- a/modules/rss/module.info +++ b/modules/rss/module.info @@ -3,5 +3,5 @@ description = "Provides RSS feeds" version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:rss" +info_url = "http://codex.gallery2.org/Gallery3:Modules:rss" discuss_url = "http://gallery.menalto.com/forum_module_rss" diff --git a/modules/search/module.info b/modules/search/module.info index a1c58af5..1389798d 100644 --- a/modules/search/module.info +++ b/modules/search/module.info @@ -3,5 +3,5 @@ description = "Allows users to search their Gallery" version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:search" +info_url = "http://codex.gallery2.org/Gallery3:Modules:search" discuss_url = "http://gallery.menalto.com/forum_module_search" diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 754e06c1..4ce0a97d 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -3,5 +3,5 @@ description = "Allows authorized users to load images directly from your web ser version = 4 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:server_add" +info_url = "http://codex.gallery2.org/Gallery3:Modules:server_add" discuss_url = "http://gallery.menalto.com/forum_module_server_add" diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info index 55cdf9b8..8c9a3176 100644 --- a/modules/slideshow/module.info +++ b/modules/slideshow/module.info @@ -3,5 +3,5 @@ description = "Allows users to view a slideshow of photos" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:slideshow" +info_url = "http://codex.gallery2.org/Gallery3:Modules:slideshow" discuss_url = "http://gallery.menalto.com/forum_module_slideshow" diff --git a/modules/tag/module.info b/modules/tag/module.info index 59d8dfbd..75d16bf0 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -3,5 +3,5 @@ description = "Allows users to tag photos and albums" version = 3 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:tag" +info_url = "http://codex.gallery2.org/Gallery3:Modules:tag" discuss_url = "http://gallery.menalto.com/forum_module_tag" diff --git a/modules/user/module.info b/modules/user/module.info index f6dd9529..503bcd0d 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -4,5 +4,5 @@ version = 4 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:user" +info_url = "http://codex.gallery2.org/Gallery3:Modules:user" discuss_url = "http://gallery.menalto.com/forum_module_user" diff --git a/modules/watermark/module.info b/modules/watermark/module.info index 1f440016..58efa43f 100644 --- a/modules/watermark/module.info +++ b/modules/watermark/module.info @@ -3,5 +3,5 @@ description = "Allows users to watermark their photos" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:watermark" +info_url = "http://codex.gallery2.org/Gallery3:Modules:watermark" discuss_url = "http://gallery.menalto.com/forum_module_watermark" diff --git a/themes/admin_wind/theme.info b/themes/admin_wind/theme.info index aca5c6c5..466d8e43 100644 --- a/themes/admin_wind/theme.info +++ b/themes/admin_wind/theme.info @@ -6,5 +6,5 @@ admin = 1 site = 0 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Theme:admin_wind" +info_url = "http://codex.gallery2.org/Gallery3:Themes:admin_wind" discuss_url = "http://gallery.menalto.com/forum_theme_admin_wind" diff --git a/themes/wind/theme.info b/themes/wind/theme.info index c2344c48..e0be78b9 100644 --- a/themes/wind/theme.info +++ b/themes/wind/theme.info @@ -6,5 +6,5 @@ site = 1 admin = 0 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Theme:wind" +info_url = "http://codex.gallery2.org/Gallery3:Themes:wind" discuss_url = "http://gallery.menalto.com/forum_theme_wind" -- cgit v1.2.3 From 67d2e8081c6e5f0b679881bca3fdc81fe1e78ccc Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 16:12:10 -0700 Subject: Undo the change made in 5ce85636329b14673718836b3631a3e46efdc3bb because it messes up tag counts (and makes the test fail-- I should have run that!). Also, use Tag_Model::items() in save() to avoid code duplication. Follow-on for #1628. --- modules/tag/models/tag.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'modules/tag') diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index d4e385a2..13e253ba 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -69,29 +69,14 @@ class Tag_Model_Core extends ORM { * to this tag. */ public function save() { - // Figure out what items have changed in this tag for our item_related_update event below - if (isset($this->object_relations["items"])) { - $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); - $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); - if (isset($this->changed_relations["items"])) { - $changed = array_merge($added, $removed); - } - $this->count = count($this->object_relations["items"]) + count($added) - count($removed); - } - // Check to see if another tag exists with the same name $duplicate_tag = ORM::factory("tag") ->where("name", "=", $this->name) ->where("id", "!=", $this->id) ->find(); if ($duplicate_tag->loaded()) { - // If so, tag its items with this tag so as to merge it. Do this after we figure out what's - // changed so that we don't notify on this change to keep churn down. - $duplicate_tag_items = ORM::factory("item") - ->join("items_tags", "items.id", "items_tags.item_id") - ->where("items_tags.tag_id", "=", $duplicate_tag->id) - ->find_all(); - foreach ($duplicate_tag_items as $item) { + // If so, tag its items with this tag so as to merge it. + foreach ($duplicate_tag->items() as $item) { $this->add($item); } @@ -99,6 +84,16 @@ class Tag_Model_Core extends ORM { $duplicate_tag->delete(); } + // Figure out what items have changed in this tag for our item_related_update event below + if (isset($this->object_relations["items"])) { + $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); + $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); + if (isset($this->changed_relations["items"])) { + $changed = array_merge($added, $removed); + } + $this->count = count($this->object_relations["items"]) + count($added) - count($removed); + } + $result = parent::save(); if (!empty($changed)) { -- cgit v1.2.3 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(-) (limited to 'modules/tag') 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 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(-) (limited to 'modules/tag') 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