From 1ab8bf07ad15c1ab53afb335d32e71e01a00d4b2 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 19 Jul 2009 15:36:17 -0700 Subject: Html validation fix, ticket 572 --- modules/slideshow/helpers/slideshow_theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/slideshow/helpers/slideshow_theme.php b/modules/slideshow/helpers/slideshow_theme.php index 125d175c..269a93ce 100644 --- a/modules/slideshow/helpers/slideshow_theme.php +++ b/modules/slideshow/helpers/slideshow_theme.php @@ -20,7 +20,7 @@ class slideshow_theme_Core { static function head($theme) { $proto = (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] === "off") ? "http" : "https"; - return ""; } } -- cgit v1.2.3 From 33d0b82d024df8fd85798cc4f6b9bab377f4f783 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 19 Jul 2009 15:45:16 -0700 Subject: Fix l10n message inconsistency, ticket 546 --- modules/server_add/controllers/server_add.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 6056d7cd..0be0f698 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -251,7 +251,7 @@ class Server_Add_Controller extends Admin_Controller { $task->state = "success"; $task->percent_complete = 100; ORM::factory("server_add_file")->where("task_id", $task->id)->delete_all(); - message::info(t2("Successfully added one photo", + message::info(t2("Successfully added one photo / album", "Successfully added %count photos and albums", $task->get("completed_files"))); } -- cgit v1.2.3 From 709d6c5faf7ece54046c0e2bc431a559a6b9d735 Mon Sep 17 00:00:00 2001 From: hiwilson Date: Sun, 19 Jul 2009 17:02:20 +0800 Subject: (1)Add tag edit field in album/photo edit form. (2)provide edit functionality. (3)support multi-word tagging. --- modules/gallery/controllers/albums.php | 2 + modules/gallery/controllers/movies.php | 2 + modules/gallery/controllers/photos.php | 2 + modules/gallery/helpers/album.php | 3 ++ modules/gallery/helpers/photo.php | 2 + modules/tag/helpers/tag.php | 67 ++++++++++++++++++++++++++++++++++ modules/tag/helpers/tag_event.php | 18 +++++++++ 7 files changed, 96 insertions(+) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 9980b676..0e1c27e5 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -191,6 +191,8 @@ class Albums_Controller extends Items_Controller { } $album->save(); + module::event("album_edit_form_completed", $album, $form); + log::success("content", "Updated album", "id\">view"); message::success( t("Saved album %album_title", array("album_title" => p::clean($album->title)))); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index d954ad8d..110ea620 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -90,6 +90,8 @@ class Movies_Controller extends Items_Controller { $photo->rename($form->edit_photo->filename->value); $photo->save(); + module::event("photo_edit_form_completed", $photo, $form); + log::success("content", "Updated photo", "id\">view"); message::success( t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title)))); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 9ce6ed23..5d37636d 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -83,6 +83,8 @@ class Photos_Controller extends Items_Controller { $photo->rename($form->edit_photo->filename->value); $photo->save(); + module::event("photo_edit_form_completed", $photo, $form); + log::success("content", "Updated photo", "id\">view"); message::success( t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title)))); diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index f1a6c060..63182c36 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -126,6 +126,9 @@ class album_Core { ->options(array("ASC" => t("Ascending"), "DESC" => t("Descending"))) ->selected($parent->sort_order); + + module::event("album_edit_form", $parent, $form); + $group->hidden("type")->value("album"); $group->submit("")->value(t("Modify")); $form->add_rules_from(ORM::factory("item")); diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index ce964c14..bf38e1ee 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -147,6 +147,8 @@ class photo_Core { ->callback("item::validate_no_trailing_period") ->error_messages("no_trailing_period", t("The photo name can't end in \".\"")); + module::event("photo_edit_form", $photo, $form); + $group->submit("")->value(t("Modify")); $form->add_rules_from(ORM::factory("item")); return $form; diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index ab5ee303..ba8a438e 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -50,6 +50,59 @@ class tag_Core { return $tag; } + /** + * Modify the tags associate with an item. + * + * @param Item_Model $item an item + * @param string $new_tags_string a string of new tags name seperated by ; + * @return null + * @throws Exception("@todo {$tag_name} WAS_NOT_ADDED_TO {$item->id}") + * @throws Exception("@todo {$tag_name} WAS_NOT_DELETED_TO {$item->id}") + */ + static function update($item, $new_tags_string) { + $old_tags = self::get_tags($item); + + $new_tags = preg_split("/[,;]/", $new_tags_string); + foreach ($new_tags as $i => $new_tag) { + $new_tags[$i] = trim($new_tag); + } + + $add_tags = array_diff($new_tags, $old_tags); + foreach ($add_tags as $tag_name) { + if (empty($tag_name)) continue; + $tag = ORM::factory("tag")->where("name", $tag_name)->find(); + if (!$tag->loaded) { + $tag->name = $tag_name; + $tag->count = 0; + $tag->save(); + } + if (!$tag->has($item)) { + if (!$tag->add($item, $tag)) { + throw new Exception("@todo {$tag->name} WAS_NOT_ADDED_TO {$item->id}"); + } + $tag->count++; + $tag->save(); + } + } + + $del_tags = array_diff($old_tags, $new_tags); + foreach ($del_tags as $tag_name) { + $tag = ORM::factory("tag")->where("name", $tag_name)->find(); + if ($tag->has($item)) { + if (!$tag->remove($item, $tag)) { + throw new Exception("@todo {$tag->name} WAS_NOT_DELETED_TO {$item->id}"); + } + $tag->save(); + $tag->count--; + if ($tag->count <= 0) { + $tag->delete(); + } else { + $tag->save(); + } + } + } + } + /** * Return the N most popular tags. * @@ -127,4 +180,18 @@ class tag_Core { $group->submit("")->value(t("Delete Tag")); return $form; } + + static function get_tags($item) { + $records = ORM::factory("item") + ->select("tags.name as tag_name") + ->join("items_tags", "items.id", "items_tags.item_id", "left") + ->join("tags", "items_tags.tag_id", "tags.id", "left") + ->where("items.id", $item->id) + ->find_all(); + $tags = array(); + foreach ($records as $record) { + $tags[] = $record->tag_name; + } + return $tags; + } } \ No newline at end of file diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 0164f556..0b9504b3 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -67,4 +67,22 @@ class tag_event_Core { "SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)"); $db->delete("items_tags", array("item_id" => "$item->id")); } + + static function album_edit_form($album, $form) { + $tag_value = implode('; ', tag::get_tags($album)); + $form->edit_album->input("tags")->label(t("Tags ( seperate by , or ; )"))->value($tag_value); + } + + static function album_edit_form_completed($album, $form) { + tag::update($album, $form->edit_album->tags->value); + } + + static function photo_edit_form($photo, $form) { + $tag_value = implode('; ', tag::get_tags($photo)); + $form->edit_photo->input("tags")->label(t("Tags ( seperate by , or ; )"))->value($tag_value); + } + + static function photo_edit_form_completed($photo, $form) { + tag::update($photo, $form->edit_photo->tags->value); + } } -- cgit v1.2.3 From 60d605888094f34b4f5185adcdfd01c0338eb8cc Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 20 Jul 2009 08:51:12 -0700 Subject: Make some API changes simplify the tag editing code. We now have a good pattern for allowing modules to add their own hooks to item forms! 1) Album, photo and movie forms now all use edit_item as the group and we publish item_edit_form and item_edit_form_completed events which makes it much easier in the module to handle all events. They can still differentiate based on $item->type if they want to. 2) Added tag::clear_all() and tag::compact() functions which takes the place of hiwilson's tag::update() function and is now used in tag_event::item_delete(). This provides a simple API that allows us to have a lot less event handling code. It's less efficient than what hiwilson was doing before in that it will delete and re-add tags, but if that ever turns out to be a performance issue we can do something about it then. --- modules/gallery/controllers/albums.php | 17 ++++--- modules/gallery/controllers/movies.php | 13 +++--- modules/gallery/controllers/photos.php | 15 +++--- modules/gallery/helpers/album.php | 4 +- modules/gallery/helpers/photo.php | 4 +- modules/tag/helpers/tag.php | 85 ++++++++-------------------------- modules/tag/helpers/tag_event.php | 38 +++++++-------- 7 files changed, 60 insertions(+), 116 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 0e1c27e5..56b74cb1 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -174,24 +174,23 @@ class Albums_Controller extends Items_Controller { ->from("items") ->where("parent_id", $album->parent_id) ->where("id <>", $album->id) - ->where("name", $form->edit_album->dirname->value) + ->where("name", $form->edit_item->dirname->value) ->count_records()) { - $form->edit_album->dirname->add_error("conflict", 1); + $form->edit_item->dirname->add_error("conflict", 1); $valid = false; } } if ($valid) { - $album->title = $form->edit_album->title->value; - $album->description = $form->edit_album->description->value; - $album->sort_column = $form->edit_album->sort_order->column->value; - $album->sort_order = $form->edit_album->sort_order->direction->value; + $album->title = $form->edit_item->title->value; + $album->description = $form->edit_item->description->value; + $album->sort_column = $form->edit_item->sort_order->column->value; + $album->sort_order = $form->edit_item->sort_order->direction->value; if ($album->id != 1) { - $album->rename($form->edit_album->dirname->value); + $album->rename($form->edit_item->dirname->value); } $album->save(); - - module::event("album_edit_form_completed", $album, $form); + module::event("item_edit_form_completed", $album, $form); log::success("content", "Updated album", "id\">view"); message::success( diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 110ea620..c8227d74 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -77,20 +77,19 @@ class Movies_Controller extends Items_Controller { ->from("items") ->where("parent_id", $photo->parent_id) ->where("id <>", $photo->id) - ->where("name", $form->edit_photo->filename->value) + ->where("name", $form->edit_item->filename->value) ->count_records()) { - $form->edit_photo->filename->add_error("conflict", 1); + $form->edit_item->filename->add_error("conflict", 1); $valid = false; } } if ($valid) { - $photo->title = $form->edit_photo->title->value; - $photo->description = $form->edit_photo->description->value; - $photo->rename($form->edit_photo->filename->value); + $photo->title = $form->edit_item->title->value; + $photo->description = $form->edit_item->description->value; + $photo->rename($form->edit_item->filename->value); $photo->save(); - - module::event("photo_edit_form_completed", $photo, $form); + module::event("item_edit_form_completed", $photo, $form); log::success("content", "Updated photo", "id\">view"); message::success( diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 5d37636d..8ee24da8 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -63,27 +63,26 @@ class Photos_Controller extends Items_Controller { $form = photo::get_edit_form($photo); if ($valid = $form->validate()) { - if ($form->edit_photo->filename->value != $photo->name) { + if ($form->edit_item->filename->value != $photo->name) { // Make sure that there's not a conflict if (Database::instance() ->from("items") ->where("parent_id", $photo->parent_id) ->where("id <>", $photo->id) - ->where("name", $form->edit_photo->filename->value) + ->where("name", $form->edit_item->filename->value) ->count_records()) { - $form->edit_photo->filename->add_error("conflict", 1); + $form->edit_item->filename->add_error("conflict", 1); $valid = false; } } } if ($valid) { - $photo->title = $form->edit_photo->title->value; - $photo->description = $form->edit_photo->description->value; - $photo->rename($form->edit_photo->filename->value); + $photo->title = $form->edit_item->title->value; + $photo->description = $form->edit_item->description->value; + $photo->rename($form->edit_item->filename->value); $photo->save(); - - module::event("photo_edit_form_completed", $photo, $form); + module::event("item_edit_form_completed", $photo, $form); log::success("content", "Updated photo", "id\">view"); message::success( diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 63182c36..5f10bd02 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -96,7 +96,7 @@ class album_Core { static function get_edit_form($parent) { $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gEditAlbumForm")); $form->hidden("_method")->value("put"); - $group = $form->group("edit_album")->label(t("Edit Album")); + $group = $form->group("edit_item")->label(t("Edit Album")); $group->input("title")->label(t("Title"))->value($parent->title); $group->textarea("description")->label(t("Description"))->value($parent->description); @@ -127,7 +127,7 @@ class album_Core { "DESC" => t("Descending"))) ->selected($parent->sort_order); - module::event("album_edit_form", $parent, $form); + module::event("item_edit_form", $parent, $form); $group->hidden("type")->value("album"); $group->submit("")->value(t("Modify")); diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index bf38e1ee..5cf37de1 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -137,7 +137,7 @@ class photo_Core { static function get_edit_form($photo) { $form = new Forge("photos/$photo->id", "", "post", array("id" => "gEditPhotoForm")); $form->hidden("_method")->value("put"); - $group = $form->group("edit_photo")->label(t("Edit Photo")); + $group = $form->group("edit_item")->label(t("Edit Photo")); $group->input("title")->label(t("Title"))->value($photo->title); $group->textarea("description")->label(t("Description"))->value($photo->description); $group->input("filename")->label(t("Filename"))->value($photo->name) @@ -147,7 +147,7 @@ class photo_Core { ->callback("item::validate_no_trailing_period") ->error_messages("no_trailing_period", t("The photo name can't end in \".\"")); - module::event("photo_edit_form", $photo, $form); + module::event("item_edit_form", $photo, $form); $group->submit("")->value(t("Modify")); $form->add_rules_from(ORM::factory("item")); diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index ba8a438e..1fb2e940 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -50,59 +50,6 @@ class tag_Core { return $tag; } - /** - * Modify the tags associate with an item. - * - * @param Item_Model $item an item - * @param string $new_tags_string a string of new tags name seperated by ; - * @return null - * @throws Exception("@todo {$tag_name} WAS_NOT_ADDED_TO {$item->id}") - * @throws Exception("@todo {$tag_name} WAS_NOT_DELETED_TO {$item->id}") - */ - static function update($item, $new_tags_string) { - $old_tags = self::get_tags($item); - - $new_tags = preg_split("/[,;]/", $new_tags_string); - foreach ($new_tags as $i => $new_tag) { - $new_tags[$i] = trim($new_tag); - } - - $add_tags = array_diff($new_tags, $old_tags); - foreach ($add_tags as $tag_name) { - if (empty($tag_name)) continue; - $tag = ORM::factory("tag")->where("name", $tag_name)->find(); - if (!$tag->loaded) { - $tag->name = $tag_name; - $tag->count = 0; - $tag->save(); - } - if (!$tag->has($item)) { - if (!$tag->add($item, $tag)) { - throw new Exception("@todo {$tag->name} WAS_NOT_ADDED_TO {$item->id}"); - } - $tag->count++; - $tag->save(); - } - } - - $del_tags = array_diff($old_tags, $new_tags); - foreach ($del_tags as $tag_name) { - $tag = ORM::factory("tag")->where("name", $tag_name)->find(); - if ($tag->has($item)) { - if (!$tag->remove($item, $tag)) { - throw new Exception("@todo {$tag->name} WAS_NOT_DELETED_TO {$item->id}"); - } - $tag->save(); - $tag->count--; - if ($tag->count <= 0) { - $tag->delete(); - } else { - $tag->save(); - } - } - } - } - /** * Return the N most popular tags. * @@ -180,18 +127,24 @@ class tag_Core { $group->submit("")->value(t("Delete Tag")); return $form; } - - static function get_tags($item) { - $records = ORM::factory("item") - ->select("tags.name as tag_name") - ->join("items_tags", "items.id", "items_tags.item_id", "left") - ->join("tags", "items_tags.tag_id", "tags.id", "left") - ->where("items.id", $item->id) - ->find_all(); - $tags = array(); - foreach ($records as $record) { - $tags[] = $record->tag_name; - } - return $tags; + + /** + * Delete all tags associated with an item + */ + static function clear_all($item) { + $db = Database::instance(); + $db->query("UPDATE {tags} SET `count` = `count` - 1 WHERE `count` > 0 " . + "AND `id` IN (SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)"); + $db->delete("items_tags", array("item_id" => "$item->id")); + } + + /** + * Get rid of any tags that have no associated items. + */ + static function compact() { + // @todo There's a potential race condition here which we can solve by adding a lock around + // this and all the cases where we create/update tags. I'm loathe to do that since it's an + // extremely rare case. + Database::instance() ->delete("tags", array("count" => 0)); } } \ No newline at end of file diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 0b9504b3..d13d1340 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -60,29 +60,23 @@ class tag_event_Core { } static function item_deleted($item) { - $db = Database::instance(); - $db->query("UPDATE {tags} SET `count` = `count` - 1 WHERE `count` > 0 " . - "AND `id` IN (SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)"); - $db->query("DELETE FROM {tags} WHERE `count` = 0 AND `id` IN (" . - "SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)"); - $db->delete("items_tags", array("item_id" => "$item->id")); + tag::clear_all($item); + tag::compact(); } - - static function album_edit_form($album, $form) { - $tag_value = implode('; ', tag::get_tags($album)); - $form->edit_album->input("tags")->label(t("Tags ( seperate by , or ; )"))->value($tag_value); - } - - static function album_edit_form_completed($album, $form) { - tag::update($album, $form->edit_album->tags->value); - } - - static function photo_edit_form($photo, $form) { - $tag_value = implode('; ', tag::get_tags($photo)); - $form->edit_photo->input("tags")->label(t("Tags ( seperate by , or ; )"))->value($tag_value); + + static function item_edit_form($item, $form) { + $tag_value = implode("; ", tag::item_tags($item)); + $form->edit_item->input("tags")->label(t("Tags (separate by , or ;)")) + ->value($tag_value); } - - static function photo_edit_form_completed($photo, $form) { - tag::update($photo, $form->edit_photo->tags->value); + + static function item_edit_form_completed($item, $form) { + tag::clear_all($item); + foreach (preg_split("/[,;]/", $form->edit_item->tags->value) as $tag_name) { + if ($tag_name) { + tag::add($item, $tag_name); + } + } + tag::compact(); } } -- cgit v1.2.3 From fb7d99740d9868938ec21449d57b9b3fe991f513 Mon Sep 17 00:00:00 2001 From: Shai Ben-Naphtali Date: Thu, 16 Jul 2009 13:10:53 +0800 Subject: Changed "Forgot Your Password" text to use capital 'Y' on the word Your Signed-off-by: Bharat Mediratta --- modules/user/views/login_ajax.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/user/views/login_ajax.html.php b/modules/user/views/login_ajax.html.php index 56a6f111..d697c958 100644 --- a/modules/user/views/login_ajax.html.php +++ b/modules/user/views/login_ajax.html.php @@ -38,7 +38,7 @@
  • - +
  • -- cgit v1.2.3