summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-07-20 08:51:12 -0700
committerBharat Mediratta <bharat@menalto.com>2009-07-20 08:51:12 -0700
commit60d605888094f34b4f5185adcdfd01c0338eb8cc (patch)
tree4b83288399c196edf23b8e91934be274402c498d /modules/gallery
parent709d6c5faf7ece54046c0e2bc431a559a6b9d735 (diff)
Make some API changes simplify the tag editing code. We now have a
good pattern for allowing modules to add their own hooks to item forms! 1) Album, photo and movie forms now all use edit_item as the group and we publish item_edit_form and item_edit_form_completed events which makes it much easier in the module to handle all events. They can still differentiate based on $item->type if they want to. 2) Added tag::clear_all() and tag::compact() functions which takes the place of hiwilson's tag::update() function and is now used in tag_event::item_delete(). This provides a simple API that allows us to have a lot less event handling code. It's less efficient than what hiwilson was doing before in that it will delete and re-add tags, but if that ever turns out to be a performance issue we can do something about it then.
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/controllers/albums.php17
-rw-r--r--modules/gallery/controllers/movies.php13
-rw-r--r--modules/gallery/controllers/photos.php15
-rw-r--r--modules/gallery/helpers/album.php4
-rw-r--r--modules/gallery/helpers/photo.php4
5 files changed, 25 insertions, 28 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 0e1c27e5..56b74cb1 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -174,24 +174,23 @@ class Albums_Controller extends Items_Controller {
->from("items")
->where("parent_id", $album->parent_id)
->where("id <>", $album->id)
- ->where("name", $form->edit_album->dirname->value)
+ ->where("name", $form->edit_item->dirname->value)
->count_records()) {
- $form->edit_album->dirname->add_error("conflict", 1);
+ $form->edit_item->dirname->add_error("conflict", 1);
$valid = false;
}
}
if ($valid) {
- $album->title = $form->edit_album->title->value;
- $album->description = $form->edit_album->description->value;
- $album->sort_column = $form->edit_album->sort_order->column->value;
- $album->sort_order = $form->edit_album->sort_order->direction->value;
+ $album->title = $form->edit_item->title->value;
+ $album->description = $form->edit_item->description->value;
+ $album->sort_column = $form->edit_item->sort_order->column->value;
+ $album->sort_order = $form->edit_item->sort_order->direction->value;
if ($album->id != 1) {
- $album->rename($form->edit_album->dirname->value);
+ $album->rename($form->edit_item->dirname->value);
}
$album->save();
-
- module::event("album_edit_form_completed", $album, $form);
+ module::event("item_edit_form_completed", $album, $form);
log::success("content", "Updated album", "<a href=\"albums/$album->id\">view</a>");
message::success(
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 110ea620..c8227d74 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -77,20 +77,19 @@ class Movies_Controller extends Items_Controller {
->from("items")
->where("parent_id", $photo->parent_id)
->where("id <>", $photo->id)
- ->where("name", $form->edit_photo->filename->value)
+ ->where("name", $form->edit_item->filename->value)
->count_records()) {
- $form->edit_photo->filename->add_error("conflict", 1);
+ $form->edit_item->filename->add_error("conflict", 1);
$valid = false;
}
}
if ($valid) {
- $photo->title = $form->edit_photo->title->value;
- $photo->description = $form->edit_photo->description->value;
- $photo->rename($form->edit_photo->filename->value);
+ $photo->title = $form->edit_item->title->value;
+ $photo->description = $form->edit_item->description->value;
+ $photo->rename($form->edit_item->filename->value);
$photo->save();
-
- module::event("photo_edit_form_completed", $photo, $form);
+ module::event("item_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"photos/$photo->id\">view</a>");
message::success(
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 5d37636d..8ee24da8 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -63,27 +63,26 @@ class Photos_Controller extends Items_Controller {
$form = photo::get_edit_form($photo);
if ($valid = $form->validate()) {
- if ($form->edit_photo->filename->value != $photo->name) {
+ if ($form->edit_item->filename->value != $photo->name) {
// Make sure that there's not a conflict
if (Database::instance()
->from("items")
->where("parent_id", $photo->parent_id)
->where("id <>", $photo->id)
- ->where("name", $form->edit_photo->filename->value)
+ ->where("name", $form->edit_item->filename->value)
->count_records()) {
- $form->edit_photo->filename->add_error("conflict", 1);
+ $form->edit_item->filename->add_error("conflict", 1);
$valid = false;
}
}
}
if ($valid) {
- $photo->title = $form->edit_photo->title->value;
- $photo->description = $form->edit_photo->description->value;
- $photo->rename($form->edit_photo->filename->value);
+ $photo->title = $form->edit_item->title->value;
+ $photo->description = $form->edit_item->description->value;
+ $photo->rename($form->edit_item->filename->value);
$photo->save();
-
- module::event("photo_edit_form_completed", $photo, $form);
+ module::event("item_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"photos/$photo->id\">view</a>");
message::success(
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index 63182c36..5f10bd02 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -96,7 +96,7 @@ class album_Core {
static function get_edit_form($parent) {
$form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gEditAlbumForm"));
$form->hidden("_method")->value("put");
- $group = $form->group("edit_album")->label(t("Edit Album"));
+ $group = $form->group("edit_item")->label(t("Edit Album"));
$group->input("title")->label(t("Title"))->value($parent->title);
$group->textarea("description")->label(t("Description"))->value($parent->description);
@@ -127,7 +127,7 @@ class album_Core {
"DESC" => t("Descending")))
->selected($parent->sort_order);
- module::event("album_edit_form", $parent, $form);
+ module::event("item_edit_form", $parent, $form);
$group->hidden("type")->value("album");
$group->submit("")->value(t("Modify"));
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index bf38e1ee..5cf37de1 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -137,7 +137,7 @@ class photo_Core {
static function get_edit_form($photo) {
$form = new Forge("photos/$photo->id", "", "post", array("id" => "gEditPhotoForm"));
$form->hidden("_method")->value("put");
- $group = $form->group("edit_photo")->label(t("Edit Photo"));
+ $group = $form->group("edit_item")->label(t("Edit Photo"));
$group->input("title")->label(t("Title"))->value($photo->title);
$group->textarea("description")->label(t("Description"))->value($photo->description);
$group->input("filename")->label(t("Filename"))->value($photo->name)
@@ -147,7 +147,7 @@ class photo_Core {
->callback("item::validate_no_trailing_period")
->error_messages("no_trailing_period", t("The photo name can't end in \".\""));
- module::event("photo_edit_form", $photo, $form);
+ module::event("item_edit_form", $photo, $form);
$group->submit("")->value(t("Modify"));
$form->add_rules_from(ORM::factory("item"));