summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-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_graphics.php21
-rw-r--r--modules/gallery/helpers/graphics.php2
-rw-r--r--modules/gallery/helpers/theme.php23
-rw-r--r--modules/gallery/helpers/upgrade_checker.php3
8 files changed, 86 insertions, 18 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_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;
}