From f7f6cbf04ff2b19535b0d3b9dbd5f4ab41395bfc Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Tue, 4 Jan 2011 00:28:44 -0700 Subject: First info module refactor step: Load item metadata into an array. Loop through this array in the info block view to display loaded data. --- modules/info/helpers/info_block.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'modules/info/helpers') diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php index 3cbbb12b..97820d84 100644 --- a/modules/info/helpers/info_block.php +++ b/modules/info/helpers/info_block.php @@ -31,6 +31,43 @@ class info_block_Core { $block->css_id = "g-metadata"; $block->title = $theme->item()->is_album() ? t("Album info") : t("Photo info"); $block->content = new View("info_block.html"); + + $info[] = array( + 'label' => t("Title:"), + 'value' => html::purify($theme->item->title) + ); + if ($theme->item->description) { + $info[] = array( + 'label' => t("Description:"), + 'value' => nl2br(html::purify($theme->item->description)) + ); + } + if (!$theme->item->is_album()) { + $info[] = array( + 'label' => t("File name:"), + 'value' => html::clean($theme->item->name)); + } + if ($theme->item->captured) { + $info[] = array( + 'label' => t("Captured:"), + 'value' => gallery::date_time($theme->item->captured) + ); + } + if ($theme->item->owner) { + $display_name = $theme->item->owner->display_name(); + if ($theme->item->owner->url) { + $info[] = array( + 'label' => t("Owner:"), + 'value' => "item->owner->url}\">" . html::clean($display_name) . "" + ); + } else { + $info[] = array( + 'label' => t("Owner:"), + 'value' => html::clean($display_name) + ); + } + } + $block->content->metadata = $info; } break; } -- cgit v1.2.3 From 798c876ba1cb5b83f6cd6616b90321e9e527b864 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Tue, 4 Jan 2011 00:40:12 -0700 Subject: Convert the metadata array to be associative. Replaced single with double-quotes. Indenting fixes. --- modules/info/helpers/info_block.php | 48 +++++++++++++++++----------------- modules/info/views/info_block.html.php | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'modules/info/helpers') diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php index 97820d84..f061f7eb 100644 --- a/modules/info/helpers/info_block.php +++ b/modules/info/helpers/info_block.php @@ -31,40 +31,40 @@ class info_block_Core { $block->css_id = "g-metadata"; $block->title = $theme->item()->is_album() ? t("Album info") : t("Photo info"); $block->content = new View("info_block.html"); - - $info[] = array( - 'label' => t("Title:"), - 'value' => html::purify($theme->item->title) - ); + $info["title"] = array( + "label" => t("Title:"), + "value" => html::purify($theme->item->title) + ); if ($theme->item->description) { - $info[] = array( - 'label' => t("Description:"), - 'value' => nl2br(html::purify($theme->item->description)) - ); + $info["description"] = array( + "label" => t("Description:"), + "value" => nl2br(html::purify($theme->item->description)) + ); } if (!$theme->item->is_album()) { - $info[] = array( - 'label' => t("File name:"), - 'value' => html::clean($theme->item->name)); + $info["file_name"] = array( + "label" => t("File name:"), + "value" => html::clean($theme->item->name) + ); } if ($theme->item->captured) { - $info[] = array( - 'label' => t("Captured:"), - 'value' => gallery::date_time($theme->item->captured) - ); + $info["captured"] = array( + "label" => t("Captured:"), + "value" => gallery::date_time($theme->item->captured) + ); } if ($theme->item->owner) { $display_name = $theme->item->owner->display_name(); if ($theme->item->owner->url) { - $info[] = array( - 'label' => t("Owner:"), - 'value' => "item->owner->url}\">" . html::clean($display_name) . "" - ); + $info["owner"] = array( + "label" => t("Owner:"), + "value" => "item->owner->url}\">" . html::clean($display_name) . "" + ); } else { - $info[] = array( - 'label' => t("Owner:"), - 'value' => html::clean($display_name) - ); + $info["owner"] = array( + "label" => t("Owner:"), + "value" => html::clean($display_name) + ); } } $block->content->metadata = $info; diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index 88f29a88..7c162767 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -2,7 +2,7 @@ -- cgit v1.2.3 From dbff45cc91ac44f18ef02b8abdd220a2864f050f Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Tue, 4 Jan 2011 15:56:16 -0700 Subject: Add an info_block_metadata event to allow other modules to add to the item info block. --- modules/info/helpers/info_block.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/info/helpers') diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php index f061f7eb..e3ae1d71 100644 --- a/modules/info/helpers/info_block.php +++ b/modules/info/helpers/info_block.php @@ -68,6 +68,8 @@ class info_block_Core { } } $block->content->metadata = $info; + + module::event("info_block_metadata", $block, $theme->item->id); } break; } -- cgit v1.2.3 From 1d2e583c3177aa498abd70dde442d767efc4e99e Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Tue, 4 Jan 2011 19:25:02 -0700 Subject: Pass the whole item, not just it's ID, to the info_block_metadata event. --- modules/info/helpers/info_block.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/info/helpers') diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php index e3ae1d71..064c73b2 100644 --- a/modules/info/helpers/info_block.php +++ b/modules/info/helpers/info_block.php @@ -69,7 +69,7 @@ class info_block_Core { } $block->content->metadata = $info; - module::event("info_block_metadata", $block, $theme->item->id); + module::event("info_block_metadata", $block, $theme->item); } break; } -- cgit v1.2.3 From a1e3b1ed17177cf7e0ef6b443afdea6a676f65b2 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Wed, 5 Jan 2011 16:00:35 -0700 Subject: Added info module show metadata options and set all to true. Admins may turn off display of items from the Advanced Settings list. --- modules/info/helpers/info_installer.php | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 modules/info/helpers/info_installer.php (limited to 'modules/info/helpers') diff --git a/modules/info/helpers/info_installer.php b/modules/info/helpers/info_installer.php new file mode 100644 index 00000000..51962173 --- /dev/null +++ b/modules/info/helpers/info_installer.php @@ -0,0 +1,41 @@ + Date: Thu, 6 Jan 2011 21:00:28 -0700 Subject: Also missed commiting this in a1e3b1ed17177cf7e0ef. --- modules/info/helpers/info_block.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'modules/info/helpers') diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php index 064c73b2..5841ec6f 100644 --- a/modules/info/helpers/info_block.php +++ b/modules/info/helpers/info_block.php @@ -31,29 +31,31 @@ class info_block_Core { $block->css_id = "g-metadata"; $block->title = $theme->item()->is_album() ? t("Album info") : t("Photo info"); $block->content = new View("info_block.html"); - $info["title"] = array( - "label" => t("Title:"), - "value" => html::purify($theme->item->title) - ); - if ($theme->item->description) { + if ($theme->item->title && module::get_var("info", "show_title")) { + $info["title"] = array( + "label" => t("Title:"), + "value" => html::purify($theme->item->title) + ); + } + if ($theme->item->description && module::get_var("info", "show_description")) { $info["description"] = array( "label" => t("Description:"), "value" => nl2br(html::purify($theme->item->description)) ); } - if (!$theme->item->is_album()) { + if (!$theme->item->is_album() && module::get_var("info", "show_name")) { $info["file_name"] = array( "label" => t("File name:"), "value" => html::clean($theme->item->name) ); } - if ($theme->item->captured) { + if ($theme->item->captured && module::get_var("info", "show_captured")) { $info["captured"] = array( "label" => t("Captured:"), "value" => gallery::date_time($theme->item->captured) ); } - if ($theme->item->owner) { + if ($theme->item->owner && module::get_var("info", "show_owner")) { $display_name = $theme->item->owner->display_name(); if ($theme->item->owner->url) { $info["owner"] = array( -- cgit v1.2.3 From 06d94065ce0919f34151da05b32642a95397044f Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Thu, 6 Jan 2011 21:03:19 -0700 Subject: Updates per Bharat's pull request review. Renamed info_block_metadata event to info_block_get_metadata. --- modules/info/helpers/info_block.php | 2 +- modules/info/views/info_block.html.php | 4 ++-- modules/tag/helpers/tag_event.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'modules/info/helpers') diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php index 5841ec6f..9596bc41 100644 --- a/modules/info/helpers/info_block.php +++ b/modules/info/helpers/info_block.php @@ -71,7 +71,7 @@ class info_block_Core { } $block->content->metadata = $info; - module::event("info_block_metadata", $block, $theme->item); + module::event("info_block_get_metadata", $block, $theme->item); } break; } diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index 7c162767..b296fa1d 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -1,8 +1,8 @@ diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 78fe7058..6b8de723 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -148,12 +148,12 @@ class tag_event_Core { } } - static function info_block_metadata($block, $item) { + static function info_block_get_metadata($block, $item) { $tags = array(); foreach (tag::item_tags($item) as $tag) { - $tags[] = "name}") . "\">$tag->name"; + $tags[] = "name}") . "\">{$tag->name}"; } - if (count($tags)) { + if ($tags) { $info = $block->content->metadata; $info["tags"] = array( "label" => t("Tags:"), -- cgit v1.2.3