diff options
Diffstat (limited to 'modules/gallery')
-rw-r--r-- | modules/gallery/controllers/admin_themes.php | 3 | ||||
-rw-r--r-- | modules/gallery/controllers/admin_upgrade_checker.php | 2 | ||||
-rw-r--r-- | modules/gallery/controllers/login.php | 5 | ||||
-rw-r--r-- | modules/gallery/controllers/quick.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/encoding.php | 32 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery.php | 16 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_block.php | 1 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 6 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_graphics.php | 21 | ||||
-rw-r--r-- | modules/gallery/helpers/graphics.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/theme.php | 23 | ||||
-rw-r--r-- | modules/gallery/helpers/upgrade_checker.php | 3 | ||||
-rw-r--r-- | modules/gallery/libraries/Gallery_View.php | 6 | ||||
-rw-r--r-- | modules/gallery/views/admin_languages.html.php | 2 | ||||
-rw-r--r-- | modules/gallery/views/admin_maintenance.html.php | 2 | ||||
-rw-r--r-- | modules/gallery/views/admin_modules.html.php | 2 | ||||
-rw-r--r-- | modules/gallery/views/upgrade_checker_block.html.php | 4 |
17 files changed, 107 insertions, 25 deletions
diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php index cd8a5530..9cdc3db5 100644 --- a/modules/gallery/controllers/admin_themes.php +++ b/modules/gallery/controllers/admin_themes.php @@ -25,6 +25,9 @@ class Admin_Themes_Controller extends Admin_Controller { $view->content->admin = module::get_var("gallery", "active_admin_theme"); $view->content->site = module::get_var("gallery", "active_site_theme"); $view->content->themes = $this->_get_themes(); + + site_status::clear("missing_site_theme"); + site_status::clear("missing_admin_theme"); print $view; } diff --git a/modules/gallery/controllers/admin_upgrade_checker.php b/modules/gallery/controllers/admin_upgrade_checker.php index a5cfcfc8..29d52a31 100644 --- a/modules/gallery/controllers/admin_upgrade_checker.php +++ b/modules/gallery/controllers/admin_upgrade_checker.php @@ -25,7 +25,7 @@ class Admin_Upgrade_Checker_Controller extends Admin_Controller { if ($message) { $message .= t( " <a href=\"%hide-url\"><i>(remind me later)</i></a>", - array("url" => url::site("admin/upgrade_checker/remind_me_later?csrf=__CSRF__"))); + array("hide-url" => url::site("admin/upgrade_checker/remind_me_later?csrf=__CSRF__"))); site_status::info($message, "upgrade_checker"); } else { site_status::clear("upgrade_checker"); diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php index b203b7d3..fdf5d7b7 100644 --- a/modules/gallery/controllers/login.php +++ b/modules/gallery/controllers/login.php @@ -42,8 +42,9 @@ class Login_Controller extends Controller { public function html() { $view = new Theme_View("page.html", "other", "login"); - $view->page_title = t("Login"); - $view->content = auth::get_login_form("login/auth_html"); + $view->page_title = t("Log in to Gallery"); + $view->content = new View("login_ajax.html"); + $view->content->form = auth::get_login_form("login/auth_html"); print $view; } diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 17abc39f..da4768fd 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -38,7 +38,7 @@ class Quick_Controller extends Controller { if ($degrees) { $tmpfile = tempnam(TMPPATH, "rotate") . "." . pathinfo($item->file_path(), PATHINFO_EXTENSION); - gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees)); + gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item); $item->set_data_file($tmpfile); $item->save(); unlink($tmpfile); diff --git a/modules/gallery/helpers/encoding.php b/modules/gallery/helpers/encoding.php new file mode 100644 index 00000000..c5928634 --- /dev/null +++ b/modules/gallery/helpers/encoding.php @@ -0,0 +1,32 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2011 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 encoding_Core { + static function convert_to_utf8($value) { + if (function_exists("mb_detect_encoding") && + function_exists("mb_convert_encoding") && + mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { + $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value)); + } else if (function_exists("mb_detect_encoding") && + mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { + $value = utf8_encode($value); + } + return $value; + } +}
\ No newline at end of file diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 1fafdef7..cbd9b33c 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -193,19 +193,25 @@ class gallery_Core { */ static function version_string() { if (gallery::RELEASE_CHANNEL == "git") { + $build_number = gallery::build_number(); return sprintf( - "%s (branch %s build %s)", gallery::VERSION, gallery::RELEASE_BRANCH, - gallery::build_number()); + "%s (branch %s, %s)", gallery::VERSION, gallery::RELEASE_BRANCH, + $build_number ? " build $build_number" : "unknown build number"); } else { return sprintf("%s (%s)", gallery::VERSION, gallery::CODE_NAME); } } /** - * Return the contents of the .build_number file, which should be a single integer. + * Return the contents of the .build_number file, which should be a single integer + * or return null if the .build_number file is missing. */ static function build_number() { - $result = parse_ini_file(DOCROOT . ".build_number"); - return $result["build_number"]; + $build_file = DOCROOT . ".build_number"; + if (file_exists($build_file)) { + $result = parse_ini_file(DOCROOT . ".build_number"); + return $result["build_number"]; + } + return null; } }
\ No newline at end of file diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index b9ccf25b..0ba7c936 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -112,6 +112,7 @@ class gallery_block_Core { $block->content->version_info = upgrade_checker::version_info(); $block->content->auto_check_enabled = upgrade_checker::auto_check_enabled(); $block->content->new_version = upgrade_checker::get_upgrade_message(); + $block->content->build_number = gallery::build_number(); } return $block; } diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 07817187..fbdb4ad5 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -539,9 +539,9 @@ class gallery_event_Core { $v = new View("user_profile_info.html"); $fields = array("name" => t("Name"), "locale" => t("Language Preference"), - "email" => t("Email"), "full_name" => t("Full name"), "url" => "Web site"); + "email" => t("Email"), "full_name" => t("Full name"), "url" => t("Web site")); if (!$data->user->guest) { - $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => "Web site"); + $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => t("Web site")); } $v->user_profile_data = array(); foreach ($fields as $field => $label) { @@ -549,6 +549,8 @@ class gallery_event_Core { $value = $data->user->$field; if ($field == "locale") { $value = locales::display_name($value); + } elseif ($field == "url") { + $value = html::mark_clean(html::anchor($data->user->$field)); } $v->user_profile_data[(string) $label] = $value; } diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php index e63b9336..716bad18 100644 --- a/modules/gallery/helpers/gallery_graphics.php +++ b/modules/gallery/helpers/gallery_graphics.php @@ -24,18 +24,19 @@ class gallery_graphics_Core { * @param string $input_file * @param string $output_file * @param array $options + * @param Item_Model $item (optional) */ - static function rotate($input_file, $output_file, $options) { + static function rotate($input_file, $output_file, $options, $item=null) { graphics::init_toolkit(); - module::event("graphics_rotate", $input_file, $output_file, $options); + module::event("graphics_rotate", $input_file, $output_file, $options, $item); Image::factory($input_file) ->quality(module::get_var("gallery", "image_quality")) ->rotate($options["degrees"]) ->save($output_file); - module::event("graphics_rotate_completed", $input_file, $output_file, $options); + module::event("graphics_rotate_completed", $input_file, $output_file, $options, $item); } /** @@ -45,11 +46,12 @@ class gallery_graphics_Core { * @param string $input_file * @param string $output_file * @param array $options + * @param Item_Model $item (optional) */ - static function resize($input_file, $output_file, $options) { + static function resize($input_file, $output_file, $options, $item=null) { graphics::init_toolkit(); - module::event("graphics_resize", $input_file, $output_file, $options); + module::event("graphics_resize", $input_file, $output_file, $options, $item); if (@filesize($input_file) == 0) { throw new Exception("@todo EMPTY_INPUT_FILE"); @@ -69,7 +71,7 @@ class gallery_graphics_Core { $image->save($output_file); } - module::event("graphics_resize_completed", $input_file, $output_file, $options); + module::event("graphics_resize_completed", $input_file, $output_file, $options, $item); } /** @@ -86,12 +88,13 @@ class gallery_graphics_Core { * @param string $input_file * @param string $output_file * @param array $options + * @param Item_Model $item (optional) */ - static function composite($input_file, $output_file, $options) { + static function composite($input_file, $output_file, $options, $item=null) { try { graphics::init_toolkit(); - module::event("graphics_composite", $input_file, $output_file, $options); + module::event("graphics_composite", $input_file, $output_file, $options, $item); list ($width, $height) = getimagesize($input_file); list ($w_width, $w_height) = getimagesize($options["file"]); @@ -121,7 +124,7 @@ class gallery_graphics_Core { ->quality(module::get_var("gallery", "image_quality")) ->save($output_file); - module::event("graphics_composite_completed", $input_file, $output_file, $options); + module::event("graphics_composite_completed", $input_file, $output_file, $options, $item); } catch (ErrorException $e) { Kohana_Log::add("error", $e->get_message()); } diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 72c563b7..04501132 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -169,7 +169,7 @@ class graphics_Core { } foreach (self::_get_rules($target) as $rule) { - $args = array($working_file, $output_file, unserialize($rule->args)); + $args = array($working_file, $output_file, unserialize($rule->args), $item); call_user_func_array($rule->operation, $args); $working_file = $output_file; } diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index f285834c..37707f28 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -41,11 +41,34 @@ class theme_Core { $config = Kohana_Config::instance(); $modules = $config->get("core.modules"); + + // Normally Router::find_uri() strips off the url suffix for us, but we're working off of the + // PATH_INFO here so we need to strip it off manually + if ($suffix = Kohana::config("core.url_suffix")) { + $path = preg_replace("#" . preg_quote($suffix) . "$#u", "", $path); + } + self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7); self::$site_theme_name = module::get_var("gallery", "active_site_theme"); + + // If the site theme doesn't exist, fall back to wind. + if (!file_exists(THEMEPATH . self::$site_theme_name . "/theme.info")) { + site_status::error(t("Theme '%name' is missing. Falling back to the Wind theme.", + array("name" => self::$site_theme_name)), "missing_site_theme"); + module::set_var("gallery", "active_site_theme", self::$site_theme_name = "wind"); + } + if (self::$is_admin) { // Load the admin theme self::$admin_theme_name = module::get_var("gallery", "active_admin_theme"); + + // If the admin theme doesn't exist, fall back to admin_wind. + if (!file_exists(THEMEPATH . self::$admin_theme_name . "/theme.info")) { + site_status::error(t("Admin theme '%name' is missing! Falling back to the Wind theme.", + array("name" => self::$admin_theme_name)), "missing_admin_theme"); + module::set_var("gallery", "active_admin_theme", self::$admin_theme_name = "admin_wind"); + } + array_unshift($modules, THEMEPATH . self::$admin_theme_name); // If the site theme has an admin subdir, load that as a module so that diff --git a/modules/gallery/helpers/upgrade_checker.php b/modules/gallery/helpers/upgrade_checker.php index ff65608b..c11a9319 100644 --- a/modules/gallery/helpers/upgrade_checker.php +++ b/modules/gallery/helpers/upgrade_checker.php @@ -42,7 +42,8 @@ class upgrade_checker_Core { static function should_auto_check() { if (upgrade_checker::auto_check_enabled() && random::int(1, 100) == 1) { $version_info = upgrade_checker::version_info(); - return (!$version_info || (time() - $version_info->timestamp) > AUTO_CHECK_INTERVAL); + return (!$version_info || + (time() - $version_info->timestamp) > upgrade_checker::AUTO_CHECK_INTERVAL); } return false; } diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 562f7929..77e3d204 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -111,6 +111,8 @@ class Gallery_View_Core extends View { $contents = $cache->get($key); if (empty($contents)) { + module::event("before_combine", $type, $this->combine_queue[$type][$group]); + $contents = ""; foreach (array_keys($this->combine_queue[$type][$group]) as $path) { if ($type == "css") { @@ -120,6 +122,8 @@ class Gallery_View_Core extends View { } } + module::event("after_combine", $type, $contents); + $cache->set($key, $contents, array($type), 30 * 84600); $use_gzip = function_exists("gzencode") && @@ -128,6 +132,7 @@ class Gallery_View_Core extends View { $cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), array($type, "gzip"), 30 * 84600); } + } unset($this->combine_queue[$type][$group]); @@ -158,6 +163,7 @@ class Gallery_View_Core extends View { $replace[] = "url('" . url::abs_file($relative) . "')"; } else { Kohana_Log::add("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'"); + } } $replace = str_replace(DIRECTORY_SEPARATOR, "/", $replace); diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index 01d1ce3f..eef087e1 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -51,7 +51,7 @@ <? foreach ($available_locales as $code => $display_name): ?> <? if ($i == (int) (count($available_locales)/2)): ?> </table> - <table> + <table class="g-left"> <tr> <th> <?= t("Installed") ?> </th> <th> <?= t("Language") ?> </th> diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index c28def1d..230e9353 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -3,7 +3,9 @@ <h1> <?= t("Maintenance") ?> </h1> <div class="g-block-content"> <div id="g-maintenance-mode"> + <p> <?= t("When you're performing maintenance on your Gallery, you can enable <b>maintenance mode</b> which prevents any non-admin from accessing your Gallery. Some of the tasks below will automatically put your Gallery in maintenance mode for you.") ?> + </p> <ul id="g-action-status" class="g-message-block"> <? if (module::get_var("gallery", "maintenance_mode")): ?> <li class="g-warning"> diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index f4ae965c..2cc81b0d 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -6,7 +6,7 @@ dataType: "json", success: function(data) { if (data.reload) { - window.location.reload(); + window.location = "<? url::site("/admin/modules") ?>"; } else { $("body").append('<div id="g-dialog">' + data.dialog + '</div>'); $("#g-dialog").dialog({ diff --git a/modules/gallery/views/upgrade_checker_block.html.php b/modules/gallery/views/upgrade_checker_block.html.php index b04887b2..c984d99f 100644 --- a/modules/gallery/views/upgrade_checker_block.html.php +++ b/modules/gallery/views/upgrade_checker_block.html.php @@ -6,8 +6,10 @@ <p> <? if (gallery::RELEASE_CHANNEL == "release"): ?> <?= t("You are using the official Gallery %version release, code named <i>%code_name</i>.", array("version" => gallery::VERSION, "code_name" => gallery::CODE_NAME)) ?> + <? elseif (isset($build_number)): ?> + <?= t("You are using an experimental snapshot of Gallery %version (build %build_number on branch %branch).", array("version" => gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => $build_number)) ?> <? else: ?> - <?= t("You are using an experimental snapshot of Gallery %version (build %build_number on branch %branch).", array("version" => gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => gallery::build_number())) ?> + <?= t("You are using an experimental snapshot of Gallery %version (branch %branch) but your gallery3/.build_number file is missing so we don't know what build you have. You should probably upgrade so that you have that file.", array("version" => gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => $build_number)) ?> <? endif ?> </p> |