From c2a1ea64eda2bf3e22ecaf4df4714c091bc5d7c4 Mon Sep 17 00:00:00 2001 From: colings Date: Sun, 2 Jan 2011 09:48:23 -0600 Subject: Tweak to include parent_id in resize call, for custom albums. --- modules/gallery/helpers/graphics.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index edba6b76..bfea2f2c 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -169,7 +169,9 @@ class graphics_Core { } foreach (self::_get_rules($target) as $rule) { - $args = array($working_file, $output_file, unserialize($rule->args)); + $options = unserialize($rule->args); + $options["parent_id"] = $item->parent_id; + $args = array($working_file, $output_file, $options); call_user_func_array($rule->operation, $args); $working_file = $output_file; } -- cgit v1.2.3 From 8437a85ac87f8fc6b4ee420bde59eda683140063 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 29 Jan 2011 08:37:12 -0800 Subject: AUTO_CHECK_INTERVAL --> upgrade_checker::AUTO_CHECK_INTERVAL Fixes #1624 --- modules/gallery/helpers/upgrade_checker.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers') 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; } -- cgit v1.2.3 From 68edb2454dcd2044a82d8e8f8a1b96330e6d3b8c Mon Sep 17 00:00:00 2001 From: colings Date: Mon, 21 Feb 2011 15:40:58 -0600 Subject: Added 'item' to parameters passed to graphics rules --- modules/gallery/helpers/gallery_graphics.php | 6 +++--- modules/gallery/helpers/graphics.php | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php index e63b9336..17de4930 100644 --- a/modules/gallery/helpers/gallery_graphics.php +++ b/modules/gallery/helpers/gallery_graphics.php @@ -46,10 +46,10 @@ class gallery_graphics_Core { * @param string $output_file * @param array $options */ - static function resize($input_file, $output_file, $options) { + static function resize($input_file, $output_file, $options, $item) { 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 +69,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); } /** diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 834211bf..04501132 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -169,9 +169,7 @@ class graphics_Core { } foreach (self::_get_rules($target) as $rule) { - $options = unserialize($rule->args); - $options["parent_id"] = $item->parent_id; - $args = array($working_file, $output_file, $options); + $args = array($working_file, $output_file, unserialize($rule->args), $item); call_user_func_array($rule->operation, $args); $working_file = $output_file; } -- cgit v1.2.3 From ca47b887f5bb8ad311c4ab7e4c71aace37ba88e9 Mon Sep 17 00:00:00 2001 From: colings Date: Wed, 23 Feb 2011 20:31:07 -0600 Subject: Added extra arg to gallery_graphics calls and updated users --- modules/g2_import/helpers/g2_import.php | 2 +- modules/gallery/controllers/quick.php | 2 +- modules/gallery/helpers/gallery_graphics.php | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 5fd92972..22fb68c6 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -610,7 +610,7 @@ class g2_import_Core { if ($g2_preferred && $g2_preferred instanceof GalleryDerivative) { if (preg_match("/rotate\|(-?\d+)/", $g2_preferred->getDerivativeOperations(), $matches)) { $tmpfile = tempnam(TMPPATH, "rotate"); - gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $matches[1])); + gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $matches[1]), $item); $item->set_data_file($tmpfile); $item->save(); unlink($tmpfile); 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/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php index 17de4930..1f47a65c 100644 --- a/modules/gallery/helpers/gallery_graphics.php +++ b/modules/gallery/helpers/gallery_graphics.php @@ -25,17 +25,17 @@ class gallery_graphics_Core { * @param string $output_file * @param array $options */ - static function rotate($input_file, $output_file, $options) { + static function rotate($input_file, $output_file, $options, $item) { 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); } /** @@ -87,11 +87,11 @@ class gallery_graphics_Core { * @param string $output_file * @param array $options */ - static function composite($input_file, $output_file, $options) { + static function composite($input_file, $output_file, $options, $item) { 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 +121,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()); } -- cgit v1.2.3 From e90493aab36e42e0a69a24a8b1f27e4736e32d20 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Wed, 2 Mar 2011 21:11:49 -0700 Subject: Translate user Web Site label. Link web site on user profile page. --- modules/gallery/helpers/gallery_event.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'modules/gallery/helpers') 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; } -- cgit v1.2.3 From c38d4695a01c939840357d7f59aa836169571048 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 5 Mar 2011 15:46:04 -0800 Subject: Add missing phpDoc for the extra Item_Model argument to graphics calls and make the param optional. #1646. --- modules/gallery/helpers/gallery_graphics.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php index 1f47a65c..716bad18 100644 --- a/modules/gallery/helpers/gallery_graphics.php +++ b/modules/gallery/helpers/gallery_graphics.php @@ -24,8 +24,9 @@ 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, $item) { + static function rotate($input_file, $output_file, $options, $item=null) { graphics::init_toolkit(); module::event("graphics_rotate", $input_file, $output_file, $options, $item); @@ -45,8 +46,9 @@ 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, $item) { + static function resize($input_file, $output_file, $options, $item=null) { graphics::init_toolkit(); module::event("graphics_resize", $input_file, $output_file, $options, $item); @@ -86,8 +88,9 @@ 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, $item) { + static function composite($input_file, $output_file, $options, $item=null) { try { graphics::init_toolkit(); -- cgit v1.2.3 From fa6f233603267505c216abc4f12663d245cd23e7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 27 Mar 2011 11:31:34 -0700 Subject: Centralize our encoding code into a new helpers and use mb_convert_encoding if possible. Build on the work in c791ae96d5bb28f39b26a0e556e10e636f97436c by momo-i. Fixes #1660. --- modules/exif/helpers/exif.php | 20 ++------------------ modules/gallery/helpers/encoding.php | 32 ++++++++++++++++++++++++++++++++ modules/tag/helpers/tag_event.php | 5 +---- 3 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 modules/gallery/helpers/encoding.php (limited to 'modules/gallery/helpers') diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index f752d336..a35a2141 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -36,15 +36,7 @@ class exif_Core { foreach(self::_keys() as $field => $exifvar) { if (isset($exif_raw[$exifvar[0]][$exifvar[1]])) { $value = $exif_raw[$exifvar[0]][$exifvar[1]]; - 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); - } + $value = encoding::convert_to_utf8($value); $keys[$field] = Input::clean($value); if ($field == "DateTime") { @@ -65,15 +57,7 @@ class exif_Core { foreach (array("Keywords" => "2#025", "Caption" => "2#120") as $keyword => $iptc_key) { if (!empty($iptc[$iptc_key])) { $value = implode(" ", $iptc[$iptc_key]); - 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); - } + $value = encoding::convert_to_utf8($value); $keys[$keyword] = Input::clean($value); if ($keyword == "Caption" && !$item->description) { 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 @@ + Date: Sun, 10 Apr 2011 13:46:28 -0700 Subject: Gracefully degrade in the case where the .build_number file is missing. Fixes #1673. --- modules/gallery/helpers/gallery.php | 16 +++++++++++----- modules/gallery/helpers/gallery_block.php | 1 + modules/gallery/views/upgrade_checker_block.html.php | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'modules/gallery/helpers') 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/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 @@

%code_name.", array("version" => gallery::VERSION, "code_name" => gallery::CODE_NAME)) ?> + + gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => $build_number)) ?> - gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => gallery::build_number())) ?> + gallery::VERSION, "branch" => gallery::RELEASE_BRANCH, "build_number" => $build_number)) ?>

-- cgit v1.2.3 From 08a6df2274ea196056eb7441d4aff050dc3531fa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 21 Apr 2011 15:50:53 -0700 Subject: Normally Router::find_uri() strips off the url suffix for us, but when we make the theme::$is_admin determination we're working off of the PATH_INFO so we need to strip it off manually. Fixes #1631. --- modules/gallery/helpers/theme.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index f285834c..a42fa7ad 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -41,6 +41,13 @@ 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 (self::$is_admin) { -- cgit v1.2.3 From 11703b24ffdf38443ac46afbfa65e6f07ec5648e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Apr 2011 09:28:19 -0700 Subject: Detect if the users theme is missing (or missing a theme.info) and in that case fall back to the wind theme. Fixes #1655. --- modules/gallery/helpers/theme.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index a42fa7ad..37707f28 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -50,9 +50,25 @@ class theme_Core { 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 -- cgit v1.2.3