diff options
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/MY_url.php | 3 | ||||
-rw-r--r-- | modules/gallery/helpers/access.php | 3 | ||||
-rw-r--r-- | modules/gallery/helpers/album.php | 4 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 7 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 15 | ||||
-rw-r--r-- | modules/gallery/helpers/movie.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/photo.php | 21 | ||||
-rw-r--r-- | modules/gallery/helpers/rest.php | 116 | ||||
-rw-r--r-- | modules/gallery/helpers/theme.php | 39 |
9 files changed, 62 insertions, 148 deletions
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); } } diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index c1c1f9d1..88a02ce2 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/album.php b/modules/gallery/helpers/album.php index 72a79a75..e9a0f6ec 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -92,7 +92,7 @@ class album_Core { } static function get_add_form($parent) { - $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "g-add-album-form")); + $form = new Forge("albums/create/{$parent->id}", "", "post", array("id" => "g-add-album-form")); $group = $form->group("add_album") ->label(t("Add an album to %album_title", array("album_title" => $parent->title))); $group->input("title")->label(t("Title")); @@ -114,7 +114,7 @@ class album_Core { } static function get_edit_form($parent) { - $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "g-edit-album-form")); + $form = new Forge("albums/update/{$parent->id}", "", "post", array("id" => "g-edit-album-form")); $form->hidden("_method")->value("put"); $group = $form->group("edit_item")->label(t("Edit Album")); diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 57a5ee9f..39859b36 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -432,6 +432,13 @@ class gallery_installer { module::clear_var("gallery", "blocks_site.sidebar"); module::set_version("gallery", $version = 19); } + + // Set a default for the number of simultaneous uploads + // Version 20 was reverted in 57adefc5baa7a2b0dfcd3e736e80c2fa86d3bfa2, so skip it. + if ($version == 19 || $version == 20) { + module::set_var("gallery", "simultaneous_upload_limit", 5); + module::set_version("gallery", $version = 21); + } } static function uninstall() { diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index e6c196ce..50abdaae 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -335,6 +335,21 @@ class module_Core { call_user_func_array(array($class, $function), $args); } } + + // Give the admin theme a chance to respond, if we're in admin mode. + if (theme::$is_admin) { + $class = theme::$admin_theme_name . "_event"; + if (method_exists($class, $function)) { + call_user_func_array(array($class, $function), $args); + } + } + + // Give the site theme a chance to respond as well. It gets a chance even in admin mode, as + // long as the theme has an admin subdir. + $class = theme::$site_theme_name . "_event"; + if (method_exists($class, $function)) { + call_user_func_array(array($class, $function), $args); + } } /** diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index e84e8ea6..536d5143 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -129,7 +129,7 @@ class movie_Core { } static function get_edit_form($movie) { - $form = new Forge("movies/$movie->id", "", "post", array("id" => "g-edit-movie-form")); + $form = new Forge("movies/update/$movie->id", "", "post", array("id" => "g-edit-movie-form")); $form->hidden("_method")->value("put"); $group = $form->group("edit_item")->label(t("Edit Movie")); $group->input("title")->label(t("Title"))->value($movie->title); diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index 01cf5278..4188e192 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -137,27 +137,8 @@ class photo_Core { return $photo; } - static function get_add_form($parent) { - $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "g-add-photo-form")); - $group = $form->group("add_photo")->label( - t("Add Photo to %album_title", array("album_title" => $parent->title))); - $group->input("title")->label(t("Title")); - $group->textarea("description")->label(t("Description")); - $group->input("name")->label(t("Filename")); - $group->input("slug")->label(t("Internet Address"))->value($photo->slug) - ->callback("item::validate_url_safe") - ->error_messages( - "not_url_safe", - t("The internet address should contain only letters, numbers, hyphens and underscores")); - $group->upload("file")->label(t("File"))->rules("required|allow[jpg,png,gif,flv,mp4]"); - $group->hidden("type")->value("photo"); - $group->submit("")->value(t("Upload")); - $form->add_rules_from(ORM::factory("item")); - return $form; - } - static function get_edit_form($photo) { - $form = new Forge("photos/$photo->id", "", "post", array("id" => "g-edit-photo-form")); + $form = new Forge("photos/update/$photo->id", "", "post", array("id" => "g-edit-photo-form")); $form->hidden("_method")->value("put"); $group = $form->group("edit_item")->label(t("Edit Photo")); $group->input("title")->label(t("Title"))->value($photo->title); diff --git a/modules/gallery/helpers/rest.php b/modules/gallery/helpers/rest.php deleted file mode 100644 index a63b94c8..00000000 --- a/modules/gallery/helpers/rest.php +++ /dev/null @@ -1,116 +0,0 @@ -<?php defined("SYSPATH") or die("No direct script access."); -/** - * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2009 Bharat Mediratta - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ - -class rest_Core { - const OK = "200 OK"; - const CREATED = "201 Created"; - const ACCEPTED = "202 Accepted"; - const NO_CONTENT = "204 No Content"; - const RESET_CONTENT = "205 Reset Content"; - const PARTIAL_CONTENT = "206 Partial Content"; - const MOVED_PERMANENTLY = "301 Moved Permanently"; - const FOUND = "302 Found"; - const SEE_OTHER = "303 See Other"; - const NOT_MODIFIED = "304 Not Modified"; - const TEMPORARY_REDIRECT = "307 Temporary Redirect"; - const BAD_REQUEST = "400 Bad Request"; - const UNAUTHORIZED = "401 Unauthorized"; - const FORBIDDEN = "403 Forbidden"; - const NOT_FOUND = "404 Not Found"; - const METHOD_NOT_ALLOWED = "405 Method Not Allowed"; - const NOT_ACCEPTABLE = "406 Not Acceptable"; - const CONFLICT = "409 Conflict"; - const GONE = "410 Gone"; - const LENGTH_REQUIRED = "411 Length Required"; - const PRECONDITION_FAILED = "412 Precondition Failed"; - const UNSUPPORTED_MEDIA_TYPE = "415 Unsupported Media Type"; - const EXPECTATION_FAILED = "417 Expectation Failed"; - const INTERNAL_SERVER_ERROR = "500 Internal Server Error"; - const SERVICE_UNAVAILABLE = "503 Service Unavailable"; - - const XML = "application/xml"; - const ATOM = "application/atom+xml"; - const RSS = "application/rss+xml"; - const JSON = "application/json"; - const HTML = "text/html"; - - /** - * We're expecting to run in an environment that only supports GET/POST, so expect to tunnel - * PUT and DELETE through POST. - * - * Returns the HTTP request method taking into consideration PUT/DELETE tunneling. - * @return string HTTP request method - */ - static function request_method() { - if (request::method() == "get") { - return "get"; - } else { - $input = Input::instance(); - switch (strtolower($input->post("_method", $input->get("_method", request::method())))) { - case "put": return "put"; - case "delete": return "delete"; - default: return "post"; - } - } - } - - /** - * Choose an output format based on what the client prefers to accept. - * @return string "html", "xml" or "json" - */ - static function output_format() { - // Pick a format, but let it be overridden. - $input = Input::instance(); - $fmt = $input->get( - "_format", $input->post( - "_format", request::preferred_accept( - array("xhtml", "html", "xml", "json")))); - - // Some browsers (Chrome!) prefer xhtml over html, but we'll normalize this to html for now. - if ($fmt == "xhtml") { - $fmt = "html"; - } - return $fmt; - } - - /** - * Set HTTP response code. - * @param string Use one of the status code constants defined in this class. - */ - static function http_status($status_code) { - header("HTTP/1.1 " . $status_code); - } - - /** - * Set HTTP Location header. - * @param string URL - */ - static function http_location($url) { - header("Location: " . $url); - } - - /** - * Set HTTP Content-Type header. - * @param string content type - */ - static function http_content_type($type) { - header("Content-Type: " . $type); - } -} diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 16ed104e..247aa5c4 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -24,6 +24,10 @@ * Note: by design, this class does not do any permission checking. */ class theme_Core { + public static $admin_theme_name; + public static $site_theme_name; + public static $is_admin; + /** * Load the active theme. This is called at bootstrap time. We will only ever have one theme * active for any given request. @@ -35,14 +39,31 @@ class theme_Core { $path = "/" . $input->get("kohana_uri"); } - if (!(identity::active_user()->admin && $theme_name = $input->get("theme"))) { - $theme_name = module::get_var( - "gallery", - $path == "/admin" || !strncmp($path, "/admin/", 7) ? - "active_admin_theme" : "active_site_theme"); - } $modules = Kohana::config("core.modules"); - array_unshift($modules, THEMEPATH . $theme_name); + self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7); + self::$site_theme_name = module::get_var("gallery", "active_site_theme"); + if (self::$is_admin) { + // Load the admin theme + self::$admin_theme_name = module::get_var("gallery", "active_admin_theme"); + array_unshift($modules, THEMEPATH . self::$admin_theme_name); + + // If the site theme has an admin subdir, load that as a module so that + // themes can provide their own code. + if (file_exists(THEMEPATH . self::$site_theme_name . "/admin")) { + array_unshift($modules, THEMEPATH . self::$site_theme_name . "/admin"); + } + } else { + // Admins can override the site theme, temporarily. This lets us preview themes. + if (identity::active_user()->admin && $override = $input->get("theme")) { + if (file_exists(THEMEPATH . $override)) { + self::$site_theme_name = $override; + } else { + Kohana::log("error", "Missing override theme: '$override'"); + } + } + array_unshift($modules, THEMEPATH . self::$site_theme_name); + } + Kohana::config_set("core.modules", $modules); } @@ -64,6 +85,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; } |