From 7b336e880445a7d4a0461b18fcee032d8dd1c8da Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 19 Dec 2010 17:41:38 -0800 Subject: [PATCH] New "About this photo" module that puts info in the sidebar about when the photo was created and what tags it has. Written for undagiga in http://gallery.menalto.com/node/99716 --- .../helpers/about_this_photo_block.php | 52 +++++++++++++++++++ 3.0/modules/about_this_photo/module.info | 3 ++ .../views/about_this_photo.html.php | 17 ++++++ .../helpers/about_this_photo_block.php | 52 +++++++++++++++++++ 3.1/modules/about_this_photo/module.info | 3 ++ .../views/about_this_photo.html.php | 17 ++++++ 6 files changed, 144 insertions(+) create mode 100644 3.0/modules/about_this_photo/helpers/about_this_photo_block.php create mode 100644 3.0/modules/about_this_photo/module.info create mode 100644 3.0/modules/about_this_photo/views/about_this_photo.html.php create mode 100644 3.1/modules/about_this_photo/helpers/about_this_photo_block.php create mode 100644 3.1/modules/about_this_photo/module.info create mode 100644 3.1/modules/about_this_photo/views/about_this_photo.html.php 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 new file mode 100644 index 00000000..c1adb174 --- /dev/null +++ b/3.0/modules/about_this_photo/helpers/about_this_photo_block.php @@ -0,0 +1,52 @@ + t("About This Photo")); + } + + static function get($block_id, $theme) { + $block = new Block(); + switch ($block_id) { + case "simple": + $block->css_id = "g-about-this-photo"; + $block->title = t("About this photo"); + $block->content = new View("about_this_photo.html"); + + // exif API doesn't give easy access to individual keys, so do this the hard way + if (module::is_active("exif")) { + $exif = ORM::factory("exif_record")->where("item_id", "=", $theme->item()->id)->find(); + if ($exif->loaded()) { + $exif = unserialize($exif->data); + $timestamp = strtotime($exif["DateTime"]); + $block->content->date = gallery::date($timestamp); + $block->content->time = gallery::time($timestamp); + } + } + + if (module::is_active("tag")) { + $block->content->tags = tag::item_tags($theme->item()); + } + break; + } + return $block; + } +} \ No newline at end of file diff --git a/3.0/modules/about_this_photo/module.info b/3.0/modules/about_this_photo/module.info new file mode 100644 index 00000000..6943685e --- /dev/null +++ b/3.0/modules/about_this_photo/module.info @@ -0,0 +1,3 @@ +name = "About this Photo" +description = "Show some simple, specific and useful info about a given photo" +version = 1 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 new file mode 100644 index 00000000..aa91c578 --- /dev/null +++ b/3.0/modules/about_this_photo/views/about_this_photo.html.php @@ -0,0 +1,17 @@ + + 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 new file mode 100644 index 00000000..c1adb174 --- /dev/null +++ b/3.1/modules/about_this_photo/helpers/about_this_photo_block.php @@ -0,0 +1,52 @@ + t("About This Photo")); + } + + static function get($block_id, $theme) { + $block = new Block(); + switch ($block_id) { + case "simple": + $block->css_id = "g-about-this-photo"; + $block->title = t("About this photo"); + $block->content = new View("about_this_photo.html"); + + // exif API doesn't give easy access to individual keys, so do this the hard way + if (module::is_active("exif")) { + $exif = ORM::factory("exif_record")->where("item_id", "=", $theme->item()->id)->find(); + if ($exif->loaded()) { + $exif = unserialize($exif->data); + $timestamp = strtotime($exif["DateTime"]); + $block->content->date = gallery::date($timestamp); + $block->content->time = gallery::time($timestamp); + } + } + + if (module::is_active("tag")) { + $block->content->tags = tag::item_tags($theme->item()); + } + break; + } + return $block; + } +} \ No newline at end of file diff --git a/3.1/modules/about_this_photo/module.info b/3.1/modules/about_this_photo/module.info new file mode 100644 index 00000000..6943685e --- /dev/null +++ b/3.1/modules/about_this_photo/module.info @@ -0,0 +1,3 @@ +name = "About this Photo" +description = "Show some simple, specific and useful info about a given photo" +version = 1 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 new file mode 100644 index 00000000..aa91c578 --- /dev/null +++ b/3.1/modules/about_this_photo/views/about_this_photo.html.php @@ -0,0 +1,17 @@ + +