summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-12-01 19:44:29 -0800
committerBharat Mediratta <bharat@menalto.com>2009-12-01 19:44:29 -0800
commitc803cb29091d3b069077d7711a2485f75f274835 (patch)
treef0ebcdacf6d749e6e2ebc47be4634a7eb13c2d5d
parent53df0df0a4f9d2d5369016a7e2ea983ffe202346 (diff)
parent6fa880777cb3b61c0e380ebd5e7b83de55a8d6d4 (diff)
Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
-rw-r--r--modules/gallery/config/routes.php2
-rw-r--r--modules/gallery/controllers/admin_theme_options.php2
-rw-r--r--modules/gallery/controllers/albums.php11
-rw-r--r--modules/gallery/controllers/file_proxy.php2
-rw-r--r--modules/gallery/controllers/items.php8
-rw-r--r--modules/gallery/controllers/movies.php7
-rw-r--r--modules/gallery/controllers/photos.php7
-rw-r--r--modules/gallery/helpers/MY_url.php3
-rw-r--r--modules/gallery/helpers/access.php3
-rw-r--r--modules/gallery/helpers/theme.php4
10 files changed, 39 insertions, 10 deletions
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/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 {
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 32db48d4..76032655 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 53afe0e4..8c46de08 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 ($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 86782469..f261e3a9 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()) {
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/<id> 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 e017b8c8..6e25e6ea 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 5431fcfe..f7c5039e 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 a2b2e461..74284951 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);
}
}
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 445f9b86..0d197597 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -609,7 +609,8 @@ class access_Core {
$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 5245b16c..b836292f 100644
--- a/modules/gallery/helpers/theme.php
+++ b/modules/gallery/helpers/theme.php
@@ -86,6 +86,10 @@ class theme_Core {
->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;
}