From 8b6ed6c477771e42d43ea0684e5139cf361b6cee Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 28 Nov 2008 19:37:01 +0000 Subject: Create module::event() which runs Gallery events. It works by convention. To respond to the "photo_created" event in the gmaps module, you create modules/gmaps/helpers/gmaps_event.php containing class gmaps_event which has function photo_created. Renamed all events from gallery.foo.bar to foo_bar Updated tag module to use new convention. --- modules/tag/helpers/tag.php | 30 ----------------------- modules/tag/helpers/tag_event.php | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 modules/tag/helpers/tag_event.php (limited to 'modules/tag/helpers') diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 19e2238e..774e1fa1 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -88,34 +88,4 @@ class tag_Core { $form->add_rules_from(ORM::factory("tag")); return $form; } - - /** - * Handle the creation of a new photo. - * @todo Get tags from the XMP and/or IPTC data in the image - * - * @param Item_Model $photo - */ - public static function on_photo_create() { - $photo = Event::$data; - $path = $photo->file_path(); - $tags = array(); - $size = getimagesize($photo->file_path(), $info); - if (is_array($info) && !empty($info["APP13"])) { - $iptc = iptcparse($info["APP13"]); - if (!empty($iptc["2#025"])) { - foreach($iptc["2#025"] as $tag) { - $tags[$tag]= 1; - } - } - } - - // @todo figure out how to read the keywords from xmp - - foreach(array_keys($tags) as $tag) { - self::add($photo, $tag); - } - - return; - } - } diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php new file mode 100644 index 00000000..25a79c2a --- /dev/null +++ b/modules/tag/helpers/tag_event.php @@ -0,0 +1,50 @@ +file_path(); + $tags = array(); + $size = getimagesize($photo->file_path(), $info); + if (is_array($info) && !empty($info["APP13"])) { + $iptc = iptcparse($info["APP13"]); + if (!empty($iptc["2#025"])) { + foreach($iptc["2#025"] as $tag) { + $tags[$tag]= 1; + } + } + } + + // @todo figure out how to read the keywords from xmp + + foreach(array_keys($tags) as $tag) { + self::add($photo, $tag); + } + + return; + } +} -- cgit v1.2.3