From 3ad9b6174a0adcc3d9b6e4ae007bd3ffd8ef2d26 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 28 Nov 2008 00:19:08 +0000 Subject: Add event plumbing to allow the tag module to be notified when a photo is created. Eventually this will be used to parse the image meta data and extract tags; --- core/helpers/album.php | 3 +++ core/helpers/photo.php | 6 +++++- modules/tag/helpers/tag.php | 13 +++++++++++++ modules/tag/hooks/photo_created.php | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 modules/tag/hooks/photo_created.php diff --git a/core/helpers/album.php b/core/helpers/album.php index bae682fa..e2163b4c 100644 --- a/core/helpers/album.php +++ b/core/helpers/album.php @@ -53,6 +53,9 @@ class album_Core { if (!file_exists($thumbnail_dir)) { mkdir($thumbnail_dir); } + + Event::run("gallery.album_created", $photo); + return $album; } } diff --git a/core/helpers/photo.php b/core/helpers/photo.php index 46a33b56..900322d2 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -74,8 +74,12 @@ class photo_Core { // @todo: parameterize these dimensions // This saves the photo a second time, which is unfortunate but difficult to avoid. - return $photo->set_thumbnail($filename, 200, 140) + $result = $photo->set_thumbnail($filename, 200, 140) ->set_resize($filename, 640, 480) ->save(); + + Event::run("gallery.photo_created", $photo); + + return $result; } } diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 38595b1c..4b65016d 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -88,4 +88,17 @@ 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; + Kohana::log("debug", "tag::on_photo_create($photo->name)"); + return; + } + } diff --git a/modules/tag/hooks/photo_created.php b/modules/tag/hooks/photo_created.php new file mode 100644 index 00000000..8f6cbab6 --- /dev/null +++ b/modules/tag/hooks/photo_created.php @@ -0,0 +1,2 @@ +