diff options
Diffstat (limited to 'modules/gallery/helpers')
-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_installer.php | 16 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_theme.php | 2 | ||||
-rw-r--r-- | modules/gallery/helpers/item.php | 12 | ||||
-rw-r--r-- | modules/gallery/helpers/theme.php | 23 |
8 files changed, 98 insertions, 10 deletions
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_installer.php b/modules/gallery/helpers/gallery_installer.php index 01c59eaa..83c5ed71 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -304,14 +304,16 @@ class gallery_installer { module::set_var("gallery", "maintenance_mode", 0); module::set_var("gallery", "visible_title_length", 15); module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); + module::set_var("gallery", "apple_touch_icon_url", "lib/images/apple-touch-icon.png"); module::set_var("gallery", "email_from", ""); module::set_var("gallery", "email_reply_to", ""); module::set_var("gallery", "email_line_length", 70); module::set_var("gallery", "email_header_separator", serialize("\n")); module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); + module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); - module::set_version("gallery", 46); + module::set_version("gallery", 48); } static function upgrade($version) { @@ -677,6 +679,18 @@ class gallery_installer { module::set_var("gallery", "upgrade_checker_auto_enabled", true); module::set_version("gallery", $version = 46); } + + if ($version == 46) { + module::set_var("gallery", "apple_touch_icon_url", "lib/images/apple-touch-icon.png"); + module::set_version("gallery", $version = 47); + } + + if ($version == 47) { + // Add configuration variable to set timezone. Defaults to the currently + // used timezone (from PHP configuration). + module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); + module::set_version("gallery", $version = 48); + } } static function uninstall() { diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index c4a82390..e07839d9 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -64,7 +64,7 @@ class gallery_theme_Core { if ($session->get("l10n_mode", false)) { $buf .= $theme->css("l10n_client.css"); $buf .= $theme->script("jquery.cookie.js"); - $buf .=$theme->script("l10n_client.js"); + $buf .= $theme->script("l10n_client.js"); } return $buf; } diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 1a5c631e..7e779544 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -152,8 +152,18 @@ class item_Core { * @param string $filename */ static function convert_filename_to_slug($filename) { - $result = pathinfo($filename, PATHINFO_FILENAME); + $result = str_replace("&", "-and-", $filename); + $result = str_replace(" ", "-", $result); + + // It's not easy to extend the text helper since it's called by the Input class which is + // referenced in hooks/init_gallery, so it's + if (class_exists("transliterate")) { + $result = transliterate::utf8_to_ascii($result); + } else { + $result = text::transliterate_to_ascii($result); + } $result = preg_replace("/[^A-Za-z0-9-_]+/", "-", $result); + $result = preg_replace("/-+/", "-", $result); return trim($result, "-"); } 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 |