From 01bad461df11e60f6c92ad68980203cb9ef8425d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 29 Nov 2009 12:39:21 -0800 Subject: Publish theme_edit_form and theme_edit_form_completed events so that themes can piggyback on the regular Admin > Appearance > Theme Options page. --- modules/gallery/controllers/admin_theme_options.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 27a67bdb..9de54c78 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -58,6 +58,8 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); + module::event("theme_edit_form_completed", $form); + message::success(t("Updated theme details")); url::redirect("admin/theme_options"); } else { -- cgit v1.2.3 From 852653ef2415dc070c27ce151ed399525ddfa5a0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 30 Nov 2009 11:10:58 -0800 Subject: Clean up item routing a bit. 1) The new default route is "albums", and Albums_Controller::index() does the right thing 2) Items_Controller redirects to the appropriate specific controller 3) All item controllers now have show() instead of _show(), so that the routing code in url::parse_url() can get to it. But that code is protected against receiving bogus requests. --- modules/gallery/config/routes.php | 2 +- modules/gallery/controllers/albums.php | 11 ++++++++++- modules/gallery/controllers/items.php | 8 +++++--- modules/gallery/controllers/movies.php | 7 ++++++- modules/gallery/controllers/photos.php | 7 ++++++- modules/gallery/helpers/MY_url.php | 3 ++- 6 files changed, 30 insertions(+), 8 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/config/routes.php b/modules/gallery/config/routes.php index 503d6f5b..63cc6150 100644 --- a/modules/gallery/config/routes.php +++ b/modules/gallery/config/routes.php @@ -25,4 +25,4 @@ $config["^admin_.*"] = null; $config["^form/(edit|add)/(\w+)/(.*)$"] = "$2/form_$1/$3"; // Default page is the root album -$config["_default"] = "albums/1"; +$config["_default"] = "albums"; diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 43040b67..0cfee7cd 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -18,7 +18,16 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Albums_Controller extends Items_Controller { - public function _show($album) { + public function index() { + $this->_show(ORM::factory("item", 1)); + } + + public function show($album) { + if (!is_object($album)) { + // show() must be public because we route to it in url::parse_url(), so make + // sure that we're actually receiving an object + Kohana::show_404(); + } $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { diff --git a/modules/gallery/controllers/items.php b/modules/gallery/controllers/items.php index ec3681a3..b350c5a2 100644 --- a/modules/gallery/controllers/items.php +++ b/modules/gallery/controllers/items.php @@ -23,10 +23,12 @@ class Items_Controller extends Controller { if (!$item->loaded) { return Kohana::show_404(); } + // Redirect to the more specific resource type, since it will render - // differently. We could also just delegate here, but it feels more appropriate - // to have a single canonical resource mapping. + // differently. We can't delegate here because we may have gotten to this + // page via /items/ which means that we don't have a type-specific controller. Also, we + // want to drive a single canonical resource mapping where possible. access::required("view", $item); - return $this->_show($item); + url::redirect($item->abs_url()); } } diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 3d5eac32..575b2b60 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -18,7 +18,12 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Movies_Controller extends Items_Controller { - public function _show($movie) { + public function show($movie) { + if (!is_object($movie)) { + // show() must be public because we route to it in url::parse_url(), so make + // sure that we're actually receiving an object + Kohana::show_404(); + } access::required("view", $movie); $where = array("type != " => "album"); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index f052eccd..ba4cfb83 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -18,7 +18,12 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Photos_Controller extends Items_Controller { - public function _show($photo) { + public function show($photo) { + if (!is_object($photo)) { + // show() must be public because we route to it in url::parse_url(), so make + // sure that we're actually receiving an object + Kohana::show_404(); + } access::required("view", $photo); $where = array("type != " => "album"); diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index 368c947e..139aec21 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -35,7 +35,8 @@ class url extends url_Core { if ($item && $item->loaded) { Router::$controller = "{$item->type}s"; Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php"; - Router::$method = $item->id; + Router::$method = "show"; + Router::$arguments = array($item); } } -- cgit v1.2.3 From 883fda313d3d7e76ae98cba7735c4c474b6f517c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 1 Dec 2009 00:08:12 -0800 Subject: Fix a typo that was breaking the home page (doh!) $this->_show() -> $this->show() --- modules/gallery/controllers/albums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 0cfee7cd..3c1a0adf 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -19,7 +19,7 @@ */ class Albums_Controller extends Items_Controller { public function index() { - $this->_show(ORM::factory("item", 1)); + $this->show(ORM::factory("item", 1)); } public function show($album) { -- cgit v1.2.3 From f9ebe009c306eecf7480cc7778266b61d53b077e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 1 Dec 2009 13:34:40 -0800 Subject: Use the real mime type for movies when we're requesting the full movie instead of a thumbnail. Fixes ticket #925, thanks to lsowen. --- modules/gallery/controllers/file_proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index acfd6eb9..ef4f302c 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -112,7 +112,7 @@ class File_Proxy_Controller extends Controller { Session::abort_save(); // Dump out the image. If the item is a movie, then its thumbnail will be a JPG. - if (in_array($item->mime_type, array("video/x-flv", "video/mp4"))) { + if ($type != "albums" && in_array($item->mime_type, array("video/x-flv", "video/mp4"))) { header("Content-type: image/jpeg"); } else { header("Content-Type: $item->mime_type"); -- cgit v1.2.3 From 6fa880777cb3b61c0e380ebd5e7b83de55a8d6d4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 1 Dec 2009 13:37:07 -0800 Subject: Beter fix for #925. --- modules/gallery/controllers/file_proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index ef4f302c..8fde1132 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -112,7 +112,7 @@ class File_Proxy_Controller extends Controller { Session::abort_save(); // Dump out the image. If the item is a movie, then its thumbnail will be a JPG. - if ($type != "albums" && in_array($item->mime_type, array("video/x-flv", "video/mp4"))) { + if ($item->is_movie() && $type != "albums") { header("Content-type: image/jpeg"); } else { header("Content-Type: $item->mime_type"); -- cgit v1.2.3