From 0e4a7a5133dab7d834657c67fcf5d07bc1ea3211 Mon Sep 17 00:00:00 2001 From: hiwilson Date: Sun, 19 Jul 2009 18:43:08 +0800 Subject: make tags to be searchable. work with http://github.com/hiwilson/gallery3/commit/a5eef648c00ec3ddee40ebd716380ae0a50e90e7 Signed-off-by: Bharat Mediratta --- modules/tag/helpers/tag_search.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 modules/tag/helpers/tag_search.php (limited to 'modules') diff --git a/modules/tag/helpers/tag_search.php b/modules/tag/helpers/tag_search.php new file mode 100644 index 00000000..e14b9f4d --- /dev/null +++ b/modules/tag/helpers/tag_search.php @@ -0,0 +1,24 @@ + Date: Sun, 19 Jul 2009 13:20:08 -0700 Subject: Don't post the item_updated() event if we're just updating the view count. --- modules/gallery/models/item.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 05c4e656..129bd77f 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -353,11 +353,12 @@ class Item_Model extends ORM_MPTT { $this->created = $this->updated; $r = ORM::factory("item")->select("MAX(weight) as max_weight")->find(); $this->weight = $r->max_weight + 1; - $created = 1; + } else { + $send_event = 1; } } parent::save(); - if (!isset($created)) { + if (isset($send_event)) { module::event("item_updated", $this); } return $this; -- cgit v1.2.3 From 788a458a11f04e47fe1c241463785d0f0b12cf3c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 19 Jul 2009 13:43:06 -0700 Subject: Remove success logging. Only log on errors, otherwise the log is huge. --- modules/search/helpers/search.php | 1 - modules/search/helpers/search_task.php | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 34eaecbd..6317020f 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -79,7 +79,6 @@ class search_Core { $record->data = join(" ", $data); $record->dirty = 0; $record->save(); - return t("Search index updated for '%title'", array("title" => p::purify($item->title))); } static function stats() { diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index df1dfe16..5643573a 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -52,7 +52,7 @@ class search_task_Core { break; } - $message[] = search::update($item); + search::update($item); $completed++; } @@ -69,13 +69,10 @@ class search_task_Core { $task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent)); - $message[] = $task->status; } catch (Exception $e) { $task->done = true; $task->state = "error"; $task->status = $e->getMessage(); - $message[] = $e->__toString(); } - $task->log($message); } } -- cgit v1.2.3 From 5ee2e3e02c5ce927e2ecf553549f443aa4356551 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 19 Jul 2009 13:46:22 -0700 Subject: Create tag::item_tags which returns all the tags for any one item. --- modules/tag/helpers/tag.php | 19 +++++++++++++++++++ modules/tag/helpers/tag_search.php | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 7c4b56ba..ab5ee303 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -79,6 +79,25 @@ class tag_Core { } } + + /** + * Return all the tags for a given item. + * @return array + */ + static function item_tags($item) { + access::required("view", $item); + $tags = array(); + foreach (Database::instance() + ->select("name") + ->from("tags") + ->join("items_tags", "tags.id", "items_tags.tag_id", "left") + ->where("items_tags.item_id", $item->id) + ->get() as $row) { + $tags[] = $row->name; + } + return $tags; + } + static function get_add_form($item) { $form = new Forge("tags", "", "post", array("id" => "gAddTagForm")); $label = $item->is_album() ? diff --git a/modules/tag/helpers/tag_search.php b/modules/tag/helpers/tag_search.php index e14b9f4d..034b7af5 100644 --- a/modules/tag/helpers/tag_search.php +++ b/modules/tag/helpers/tag_search.php @@ -19,6 +19,6 @@ */ class tag_search_Core { static function item_index_data($item) { - return join(" ", tag::get_tags($item)); + return join(" ", tag::item_tags($item)); } } -- cgit v1.2.3 From bad6d215846cb115c88be0dae0039e89318b21b1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 19 Jul 2009 13:48:38 -0700 Subject: Remove success logging from exif_task. --- modules/exif/helpers/exif_task.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'modules') diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php index f3e77975..c269b732 100644 --- a/modules/exif/helpers/exif_task.php +++ b/modules/exif/helpers/exif_task.php @@ -42,7 +42,6 @@ class exif_task_Core { $completed = $task->get("completed", 0); $start = microtime(true); - $message = array(); foreach (ORM::factory("item") ->join("exif_records", "items.id", "exif_records.item_id", "left") ->where("type", "photo") @@ -57,11 +56,8 @@ class exif_task_Core { $completed++; exif::extract($item); - $message[] = t("Updated Exif meta data for '%title'", - array("title" => p::purify($item->title))); } - $task->log($message); list ($remaining, $total, $percent) = exif::stats(); $task->set("completed", $completed); if ($remaining == 0 || !($remaining + $completed)) { -- cgit v1.2.3 From b3f91167c14e98bbb35f62d7003efb0a82f142eb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 19 Jul 2009 13:55:22 -0700 Subject: Remove excess success logging. In the rebuild images case, it can make a huge log file. In the l10n_client case, it's not really necessary to know that level of detail and it makes for a weird API. --- modules/gallery/helpers/gallery_task.php | 34 ++++++++++++++++++-------------- modules/gallery/helpers/l10n_client.php | 5 ----- 2 files changed, 19 insertions(+), 20 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 9ce2c4a0..9edc3acd 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -45,7 +45,7 @@ class gallery_task_Core { * @param Task_Model the task */ static function rebuild_dirty_images($task) { - $message = array(); + $errors = array(); try { $result = graphics::find_dirty_images_query(); $completed = $task->get("completed", 0); @@ -63,11 +63,11 @@ class gallery_task_Core { $success = graphics::generate($item); if (!$success) { $ignored[$item->id] = 1; - $message[] = t("Unable to rebuild images for '%title'", - array("title" => p::purify($item->title))); + $errors[] = t("Unable to rebuild images for '%title'", + array("title" => p::purify($item->title))); } else { - $message[] = t("Successfully rebuilt images for '%title'", - array("title" => p::purify($item->title))); + $errors[] = t("Successfully rebuilt images for '%title'", + array("title" => p::purify($item->title))); } } @@ -101,13 +101,15 @@ class gallery_task_Core { $task->done = true; $task->state = "error"; $task->status = $e->getMessage(); - $message[] = $e->__toString(); + $errors[] = $e->__toString(); + } + if ($errors) { + $task->log($errors); } - $task->log($message); } static function update_l10n(&$task) { - $message = array(); + $errors = array(); try { $start = microtime(true); $dirs = $task->get("dirs"); @@ -139,8 +141,8 @@ class gallery_task_Core { } } - $message[] = $task->status = t2("Finding files: found 1 file", - "Finding files: found %count files", count($files)); + $task->status = t2("Finding files: found 1 file", + "Finding files: found %count files", count($files)); if (!$dirs) { $task->set("mode", "scan_files"); @@ -165,8 +167,8 @@ class gallery_task_Core { } $total_files = $task->get("total_files"); - $message[] = $task->status = t2("Scanning files: scanned 1 file", - "Scanning files: scanned %count files", $total_files - count($files)); + $task->status = t2("Scanning files: scanned 1 file", + "Scanning files: scanned %count files", $total_files - count($files)); $task->percent_complete = 10 + 80 * ($total_files - count($files)) / $total_files; if (empty($files)) { @@ -177,7 +179,7 @@ class gallery_task_Core { break; case "fetch_updates": // 90% - 100% - $message = array_merge($message, l10n_client::fetch_updates()); + l10n_client::fetch_updates(); $task->done = true; $task->state = "success"; $task->status = t("Translations installed/updated"); @@ -191,8 +193,10 @@ class gallery_task_Core { $task->done = true; $task->state = "error"; $task->status = $e->getMessage(); - $message[] = $e->__toString(); + $errors[] = $e->__toString(); + } + if ($errors) { + $task->log($errors); } - $task->log($message); } } \ No newline at end of file diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index b576b4e1..3460cc65 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -113,10 +113,6 @@ class l10n_client_Core { // [{key:, translation: , rev:, locale:}, // {key:, ...} // ] - $count = count($response); - $message[] = t2("Installed 1 new / updated translation message", - "Installed %count new / updated translation messages", $count); - foreach ($response as $message_data) { // @todo Better input validation if (empty($message_data->key) || empty($message_data->translation) || @@ -153,7 +149,6 @@ class l10n_client_Core { $entry->translation = $translation; $entry->save(); } - return $message; } static function submit_translations() { -- cgit v1.2.3 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