diff --git a/modules/gallery/config/routes.php b/modules/gallery/config/routes.php index 503d6f5b6e..63cc6150ba 100644 --- a/modules/gallery/config/routes.php +++ b/modules/gallery/config/routes.php @@ -25,4 +25,4 @@ $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/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 27a67bdb2c..9de54c780f 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -58,6 +58,8 @@ public function save() { 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 { diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 32db48d4a3..760326553c 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/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 53afe0e480..8c46de0873 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -112,7 +112,7 @@ public function __call($function, $args) { 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 ($item->is_movie() && $type != "albums") { header("Content-type: image/jpeg"); } else { header("Content-Type: $item->mime_type"); diff --git a/modules/gallery/controllers/items.php b/modules/gallery/controllers/items.php index 86782469f5..f261e3a93f 100644 --- a/modules/gallery/controllers/items.php +++ b/modules/gallery/controllers/items.php @@ -23,10 +23,12 @@ public function __call($function, $args) { if (!$item->loaded()) { throw new Kohana_404_Exception(); } + // 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 e017b8c8dd..6e25e6eab9 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(array("type", "!=", "album")); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 5431fcfe32..f7c5039ef9 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(array("type", "!=", "album")); diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index a2b2e461d1..742849516b 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -35,7 +35,8 @@ static function parse_url() { 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); } } diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index 445f9b86fd..0d19759789 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -609,7 +609,8 @@ private static function _update_htaccess_files($album, $group, $perm_name, $valu $dirs[] = dirname($album->thumb_path()); } - $base_url = url::site("file_proxy"); + $base_url = url::site("?kohana_uri=/file_proxy"); + $base_url = str_replace("/?", "?", $base_url); foreach ($dirs as $dir) { if ($value === self::DENY) { $fp = fopen("$dir/.htaccess", "w+"); diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 5245b16c1e..b836292f30 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -86,6 +86,10 @@ static function get_edit_form_admin() { ->value(module::get_var("gallery", "footer_text")); $group->checkbox("show_credits")->label(t("Show site credits"))->id("g-footer-text") ->checked(module::get_var("gallery", "show_credits")); + + module::event("theme_edit_form", $form); + + $group = $form->group("buttons"); $group->submit("")->value(t("Save")); return $form; }