diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-16 00:51:31 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-16 00:51:31 -0800 |
commit | bf085a1a176f32546f86988049e0c3f809842ce7 (patch) | |
tree | 61e758059ddf0f53e008e43cb6c2956b02e12906 /modules/gallery/helpers/gallery_event.php | |
parent | d7eb102312a02907fbd26064714dc98f3e016103 (diff) |
Convert photo uploading over to the new model based validation
approach.
- Rearrange Simple_Uploader_Controller::add_photo() to validate
the form early in the process, and switch to using model based
validation.
- Move thumbnail generation into gallery_event::item_created() so
that it's decoupled from the model.
- Delete photo::create() and move all of its logic into
Item_Model::save().
- Add Item_Model::$data_file to track the data file associated
with new movies and photos.
- Do some cleanup on the validation callbacks -- it turns out the
2nd argument is the field name not the value.
Diffstat (limited to 'modules/gallery/helpers/gallery_event.php')
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 679d65c2..9452e855 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -73,6 +73,22 @@ class gallery_event_Core { static function item_created($item) { access::add_item($item); + + if ($item->is_photo() || $item->is_movie()) { + // Build our thumbnail/resizes. + try { + graphics::generate($item); + } catch (Exception $e) { + log::failure("Unable to create a thumbnail for item id {$item->id}"); + Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); + } + + // If the parent has no cover item, make this it. + $parent = $item->parent(); + if (access::can("edit", $parent) && $parent->album_cover_item_id == null) { + item::make_album_cover($item); + } + } } static function item_deleted($item) { |