summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/config/locale.php8
-rw-r--r--modules/gallery/controllers/admin_theme_options.php13
-rw-r--r--modules/gallery/controllers/admin_themes.php3
-rw-r--r--modules/gallery/controllers/login.php5
-rw-r--r--modules/gallery/helpers/encoding.php32
-rw-r--r--modules/gallery/helpers/gallery.php16
-rw-r--r--modules/gallery/helpers/gallery_block.php1
-rw-r--r--modules/gallery/helpers/gallery_event.php6
-rw-r--r--modules/gallery/helpers/gallery_installer.php16
-rw-r--r--modules/gallery/helpers/gallery_theme.php2
-rw-r--r--modules/gallery/helpers/item.php12
-rw-r--r--modules/gallery/helpers/theme.php23
-rw-r--r--modules/gallery/libraries/Gallery_View.php6
-rw-r--r--modules/gallery/models/item.php4
-rw-r--r--modules/gallery/module.info2
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php4
-rw-r--r--modules/gallery/views/admin_languages.html.php2
-rw-r--r--modules/gallery/views/admin_modules.html.php2
-rw-r--r--modules/gallery/views/upgrade_checker_block.html.php4
19 files changed, 136 insertions, 25 deletions
diff --git a/modules/gallery/config/locale.php b/modules/gallery/config/locale.php
index 0509e45f..13de9098 100644
--- a/modules/gallery/config/locale.php
+++ b/modules/gallery/config/locale.php
@@ -29,14 +29,10 @@
$config['language'] = array('en_US', 'English_United States');
/**
- * Locale timezone. Defaults to use the server timezone.
+ * Locale timezone. Set in 'Advanced' settings, falling back to the server's zone.
* @see http://php.net/timezones
*/
-$config['timezone'] = ini_get('date.timezone');
-if (empty($config['timezone'])) {
- // This is a required field. Pick something as a default.
- $config['timezone'] = "America/Los_Angeles";
-}
+$config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get());
// i18n settings
diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php
index 055e063c..a968a56d 100644
--- a/modules/gallery/controllers/admin_theme_options.php
+++ b/modules/gallery/controllers/admin_theme_options.php
@@ -59,6 +59,7 @@ 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::set_var("gallery", "favicon_url", $form->edit_theme->favicon_url->value);
+ module::set_var("gallery", "apple_touch_icon_url", $form->edit_theme->apple_touch_icon_url->value);
module::event("theme_edit_form_completed", $form);
@@ -77,8 +78,10 @@ class Admin_Theme_Options_Controller extends Admin_Controller {
$group = $form->group("edit_theme")->label(t("Theme layout"));
$group->input("page_size")->label(t("Items per page"))->id("g-page-size")
->rules("required|valid_digit")
+ ->callback(array($this, "_valididate_page_size"))
->error_messages("required", t("You must enter a number"))
->error_messages("valid_digit", t("You must enter a number"))
+ ->error_messages("valid_min_value", t("The value must be greater than zero"))
->value(module::get_var("gallery", "page_size"));
$group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("g-thumb-size")
->rules("required|valid_digit")
@@ -93,6 +96,9 @@ class Admin_Theme_Options_Controller extends Admin_Controller {
$group->input("favicon_url")->label(t("URL (or relative path) to your favicon.ico"))
->id("g-favicon")
->value(module::get_var("gallery", "favicon_url"));
+ $group->input("apple_touch_icon_url")->label(t("URL (or relative path) to your Apple Touch icon"))
+ ->id("g-apple-touch")
+ ->value(module::get_var("gallery", "apple_touch_icon_url"));
$group->textarea("header_text")->label(t("Header text"))->id("g-header-text")
->value(module::get_var("gallery", "header_text"));
$group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text")
@@ -106,5 +112,12 @@ class Admin_Theme_Options_Controller extends Admin_Controller {
$group->submit("")->value(t("Save"));
return $form;
}
+
+ function _valididate_page_size($input) {
+ if ($input->value < 1) {
+ $input->add_error("valid_min_value", true);
+ }
+
+ }
}
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/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/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
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/models/item.php b/modules/gallery/models/item.php
index 8f4bc5e4..f46db696 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -336,9 +336,7 @@ class Item_Model_Core extends ORM_MPTT {
// Make an url friendly slug from the name, if necessary
if (empty($this->slug)) {
- $tmp = pathinfo($this->name, PATHINFO_FILENAME);
- $tmp = preg_replace("/[^A-Za-z0-9-_]+/", "-", $tmp);
- $this->slug = trim($tmp, "-");
+ $this->slug = item::convert_filename_to_slug($this->name);
// If the filename is all invalid characters, then the slug may be empty here. Pick a
// random value.
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 4c0c8866..807d08fd 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 46
+version = 48
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index 4d5aed41..2fde7cc0 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -49,6 +49,10 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
public function convert_filename_to_slug_test() {
$this->assert_equal("foo", item::convert_filename_to_slug("{[foo]}"));
$this->assert_equal("foo-bar", item::convert_filename_to_slug("{[foo!@#!$@#^$@($!(@bar]}"));
+ $this->assert_equal("english-text", item::convert_filename_to_slug("english text"));
+ $this->assert_equal("new-line", item::convert_filename_to_slug("new \n line"));
+ $this->assert_equal("foo-and-bar", item::convert_filename_to_slug("foo&bar"));
+ $this->assert_equal("special", item::convert_filename_to_slug("šṗëçîąļ"));
}
public function move_test() {
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_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>