From 878ba14230dfc291b26bdf1b26628c0112781698 Mon Sep 17 00:00:00 2001 From: undagiga Date: Sat, 8 Jan 2011 22:32:08 +1100 Subject: [PATCH] This is my second attempt to update about_this_photo to V3 and to add the new module about_this_album. Hopefully I have pulled all upstream changes this time. --- .../helpers/about_this_album_block.php | 76 +++++++++++++++++++ 3.0/modules/about_this_album/module.info | 3 + .../views/about_this_album.html.php | 68 +++++++++++++++++ .../helpers/about_this_photo_block.php | 2 +- 3.0/modules/about_this_photo/module.info | 2 +- .../views/about_this_photo.html.php | 8 +- .../helpers/about_this_album_block.php | 76 +++++++++++++++++++ 3.1/modules/about_this_album/module.info | 3 + .../views/about_this_album.html.php | 68 +++++++++++++++++ .../helpers/about_this_photo_block.php | 2 +- 3.1/modules/about_this_photo/module.info | 2 +- .../views/about_this_photo.html.php | 8 +- 12 files changed, 306 insertions(+), 12 deletions(-) create mode 100644 3.0/modules/about_this_album/helpers/about_this_album_block.php create mode 100644 3.0/modules/about_this_album/module.info create mode 100644 3.0/modules/about_this_album/views/about_this_album.html.php create mode 100644 3.1/modules/about_this_album/helpers/about_this_album_block.php create mode 100644 3.1/modules/about_this_album/module.info create mode 100644 3.1/modules/about_this_album/views/about_this_album.html.php diff --git a/3.0/modules/about_this_album/helpers/about_this_album_block.php b/3.0/modules/about_this_album/helpers/about_this_album_block.php new file mode 100644 index 00000000..a2a849e5 --- /dev/null +++ b/3.0/modules/about_this_album/helpers/about_this_album_block.php @@ -0,0 +1,76 @@ + t("About This Album")); + } + + static function get($block_id, $theme) { + switch ($block_id) { + case "aboutthisalbum": + $item = $theme->item; + if ((!$item) or (!$theme->item->is_album())) { + return ""; + } + if ($theme->item->is_album()) { + $block = new Block(); + $block->css_id = "g-about-this-album"; + $block->content = new View("about_this_album.html"); + + if ($theme->item()->id == item::root()->id) { + $block->title = t("About this Site"); + $block->content->album_count = ORM::factory("item")->where("type", "=", "album")->where("id", "<>", 1)->count_all(); + $block->content->photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all(); + $block->content->vcount = Database::instance()->query("SELECT SUM({items}.view_count) as c FROM {items} WHERE type=\"photo\"")->current()->c; + } Else { + $block->title = t("About this Album"); + $block->content->album_count = $item->descendants_count(array(array("type", "=", "album"))); + $block->content->photo_count = $item->descendants_count(array(array("type", "=", "photo"))); + // $block->content->vcount= $theme->item()->view_count; + $descds = $item->descendants(); + $descds_view = 0; + foreach ($descds as $descd) { + if ($descd->is_photo()) { + $descds_view += $descd->view_count; + } + } + $block->content->vcount = $descds_view; + if ($item->description) { + $block->content->description = html::clean($item->description); + } + } + + + $all_tags = ORM::factory("tag") + ->join("items_tags", "items_tags.tag_id", "tags.id") + ->join("items", "items.id", "items_tags.item_id", "LEFT") + ->where("items.parent_id", "=", $item->id) + ->order_by("tags.id", "ASC") + ->find_all(); + if (count($all_tags) > 0) { + $block->content->all_tags = $all_tags; + } + } + break; + } + return $block; + } +} diff --git a/3.0/modules/about_this_album/module.info b/3.0/modules/about_this_album/module.info new file mode 100644 index 00000000..8080a24d --- /dev/null +++ b/3.0/modules/about_this_album/module.info @@ -0,0 +1,3 @@ +name = "About this Album" +description = "Show some simple, specific and useful info about a given album" +version = 1 diff --git a/3.0/modules/about_this_album/views/about_this_album.html.php b/3.0/modules/about_this_album/views/about_this_album.html.php new file mode 100644 index 00000000..01dee4f7 --- /dev/null +++ b/3.0/modules/about_this_album/views/about_this_album.html.php @@ -0,0 +1,68 @@ + + +
+ + + 0): ?> + + + + + + + + + + + + + +
+ + + + 0): ?> +
+ + + ""): ?> + + +
+ + + 0): ?> +
+ + + + id) { + $tag = ORM::factory("tag", $one_tag->id); + $display_tags[] = array(html::clean($tag->name), $tag->url()); + $last_tagid = $one_tag->id; + } + } + + // Sort the array. + asort($display_tags); + + // Print out the list of tags as clickable links. + $not_first = 0; + foreach ($display_tags as $one_tag) { + if ($not_first++ > 0) { + print ", "; + } + print "" . $one_tag[0] . ""; + } +?> + +
+
diff --git a/3.0/modules/about_this_photo/helpers/about_this_photo_block.php b/3.0/modules/about_this_photo/helpers/about_this_photo_block.php index 86869844..808d19bd 100644 --- a/3.0/modules/about_this_photo/helpers/about_this_photo_block.php +++ b/3.0/modules/about_this_photo/helpers/about_this_photo_block.php @@ -54,7 +54,7 @@ class about_this_photo_block_Core { $record = ORM::factory("iptc_record")->where("item_id", "=", $theme->item()->id)->find(); if ($record->loaded()) { $record = unserialize($record->data); - $block->content->source = $record["Source"]; + $block->content->name = $record["ObjectName"]; $block->content->caption = $record["Caption"]; } diff --git a/3.0/modules/about_this_photo/module.info b/3.0/modules/about_this_photo/module.info index 632c0f05..e324ae3b 100644 --- a/3.0/modules/about_this_photo/module.info +++ b/3.0/modules/about_this_photo/module.info @@ -1,3 +1,3 @@ name = "About this Photo" description = "Show some simple, specific and useful info about a given photo" -version = 2 +version = 3 diff --git a/3.0/modules/about_this_photo/views/about_this_photo.html.php b/3.0/modules/about_this_photo/views/about_this_photo.html.php index 45db0274..f0ef130a 100644 --- a/3.0/modules/about_this_photo/views/about_this_photo.html.php +++ b/3.0/modules/about_this_photo/views/about_this_photo.html.php @@ -16,14 +16,14 @@ - - + + - +
-
+
diff --git a/3.1/modules/about_this_album/helpers/about_this_album_block.php b/3.1/modules/about_this_album/helpers/about_this_album_block.php new file mode 100644 index 00000000..a2a849e5 --- /dev/null +++ b/3.1/modules/about_this_album/helpers/about_this_album_block.php @@ -0,0 +1,76 @@ + t("About This Album")); + } + + static function get($block_id, $theme) { + switch ($block_id) { + case "aboutthisalbum": + $item = $theme->item; + if ((!$item) or (!$theme->item->is_album())) { + return ""; + } + if ($theme->item->is_album()) { + $block = new Block(); + $block->css_id = "g-about-this-album"; + $block->content = new View("about_this_album.html"); + + if ($theme->item()->id == item::root()->id) { + $block->title = t("About this Site"); + $block->content->album_count = ORM::factory("item")->where("type", "=", "album")->where("id", "<>", 1)->count_all(); + $block->content->photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all(); + $block->content->vcount = Database::instance()->query("SELECT SUM({items}.view_count) as c FROM {items} WHERE type=\"photo\"")->current()->c; + } Else { + $block->title = t("About this Album"); + $block->content->album_count = $item->descendants_count(array(array("type", "=", "album"))); + $block->content->photo_count = $item->descendants_count(array(array("type", "=", "photo"))); + // $block->content->vcount= $theme->item()->view_count; + $descds = $item->descendants(); + $descds_view = 0; + foreach ($descds as $descd) { + if ($descd->is_photo()) { + $descds_view += $descd->view_count; + } + } + $block->content->vcount = $descds_view; + if ($item->description) { + $block->content->description = html::clean($item->description); + } + } + + + $all_tags = ORM::factory("tag") + ->join("items_tags", "items_tags.tag_id", "tags.id") + ->join("items", "items.id", "items_tags.item_id", "LEFT") + ->where("items.parent_id", "=", $item->id) + ->order_by("tags.id", "ASC") + ->find_all(); + if (count($all_tags) > 0) { + $block->content->all_tags = $all_tags; + } + } + break; + } + return $block; + } +} diff --git a/3.1/modules/about_this_album/module.info b/3.1/modules/about_this_album/module.info new file mode 100644 index 00000000..8080a24d --- /dev/null +++ b/3.1/modules/about_this_album/module.info @@ -0,0 +1,3 @@ +name = "About this Album" +description = "Show some simple, specific and useful info about a given album" +version = 1 diff --git a/3.1/modules/about_this_album/views/about_this_album.html.php b/3.1/modules/about_this_album/views/about_this_album.html.php new file mode 100644 index 00000000..01dee4f7 --- /dev/null +++ b/3.1/modules/about_this_album/views/about_this_album.html.php @@ -0,0 +1,68 @@ + + + diff --git a/3.1/modules/about_this_photo/helpers/about_this_photo_block.php b/3.1/modules/about_this_photo/helpers/about_this_photo_block.php index 86869844..808d19bd 100644 --- a/3.1/modules/about_this_photo/helpers/about_this_photo_block.php +++ b/3.1/modules/about_this_photo/helpers/about_this_photo_block.php @@ -54,7 +54,7 @@ class about_this_photo_block_Core { $record = ORM::factory("iptc_record")->where("item_id", "=", $theme->item()->id)->find(); if ($record->loaded()) { $record = unserialize($record->data); - $block->content->source = $record["Source"]; + $block->content->name = $record["ObjectName"]; $block->content->caption = $record["Caption"]; } diff --git a/3.1/modules/about_this_photo/module.info b/3.1/modules/about_this_photo/module.info index 632c0f05..e324ae3b 100644 --- a/3.1/modules/about_this_photo/module.info +++ b/3.1/modules/about_this_photo/module.info @@ -1,3 +1,3 @@ name = "About this Photo" description = "Show some simple, specific and useful info about a given photo" -version = 2 +version = 3 diff --git a/3.1/modules/about_this_photo/views/about_this_photo.html.php b/3.1/modules/about_this_photo/views/about_this_photo.html.php index 45db0274..f0ef130a 100644 --- a/3.1/modules/about_this_photo/views/about_this_photo.html.php +++ b/3.1/modules/about_this_photo/views/about_this_photo.html.php @@ -16,14 +16,14 @@ - - + + - +
-
+