diff options
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r-- | modules/gallery/controllers/albums.php | 12 | ||||
-rw-r--r-- | modules/gallery/controllers/movies.php | 10 | ||||
-rw-r--r-- | modules/gallery/controllers/photos.php | 15 | ||||
-rw-r--r-- | modules/gallery/controllers/quick.php | 14 |
4 files changed, 34 insertions, 17 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 2134a419..2eeefdf1 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -157,8 +157,6 @@ class Albums_Controller extends Items_Controller { } if ($valid) { - $watching_album = $album->url() != ($location = parse_url(request::referrer(), PHP_URL_PATH)); - $album->title = $form->edit_item->title->value; $album->description = $form->edit_item->description->value; $album->sort_column = $form->edit_item->sort_order->column->value; @@ -174,9 +172,13 @@ class Albums_Controller extends Items_Controller { message::success(t("Saved album %album_title", array("album_title" => html::purify($album->title)))); - print json_encode( - array("result" => "success", - "location" => $watching_album ? $location : $album->url())); + if ($form->from_id->value == $album->id) { + // Use the new url; it might have changed. + print json_encode(array("result" => "success", "location" => $album->url())); + } else { + // Stay on the same page + print json_encode(array("result" => "success")); + } } else { print json_encode( array("result" => "error", diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index b5785ecf..7a8e4d2a 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -110,8 +110,13 @@ class Movies_Controller extends Items_Controller { message::success( t("Saved movie %movie_title", array("movie_title" => $movie->title))); - print json_encode( - array("result" => "success")); + if ($form->from_id->value == $movie->id) { + // Use the new url; it might have changed. + print json_encode(array("result" => "success", "location" => $movie->url())); + } else { + // Stay on the same page + print json_encode(array("result" => "success")); + } } else { print json_encode( array("result" => "error", @@ -123,6 +128,7 @@ class Movies_Controller extends Items_Controller { $movie = ORM::factory("item", $movie_id); access::required("view", $movie); access::required("edit", $movie); + print movie::get_edit_form($movie); } } diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index ced9da2f..56b454ce 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -99,8 +99,6 @@ class Photos_Controller extends Items_Controller { } if ($valid) { - $watching_album = $photo->url() != ($location = parse_url(request::referrer(), PHP_URL_PATH)); - $photo->title = $form->edit_item->title->value; $photo->description = $form->edit_item->description->value; $photo->slug = $form->edit_item->slug->value; @@ -110,12 +108,15 @@ class Photos_Controller extends Items_Controller { log::success("content", "Updated photo", "<a href=\"{$photo->url()}\">view</a>"); message::success( - t("Saved photo %photo_title", - array("photo_title" => html::purify($photo->title)))); + t("Saved photo %photo_title", array("photo_title" => html::purify($photo->title)))); - print json_encode( - array("result" => "success", - "location" => $watching_album ? $location : $photo->url())); + if ($form->from_id->value == $photo->id) { + // Use the new url; it might have changed. + print json_encode(array("result" => "success", "location" => $photo->url())); + } else { + // Stay on the same page + print json_encode(array("result" => "success")); + } } else { print json_encode( array("result" => "error", diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 7f1ad43b..7f9a9826 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -133,13 +133,21 @@ class Quick_Controller extends Controller { switch ($item->type) { case "album": - return print album::get_edit_form($item); + $form = album::get_edit_form($item); + break; case "photo": - return print photo::get_edit_form($item); + $form = photo::get_edit_form($item); + break; case "movie": - return print movie::get_edit_form($item); + $form = movie::get_edit_form($item); + break; } + + // Pass on the source item where this form was generated, so we have an idea where to return to. + $form->hidden("from_id")->value((int)Input::instance()->get("from_id", 0)); + + print $form; } } |