Permalink
Browse files

Merge branch 'master' of github.com:gallery/gallery3

  • Loading branch information...
2 parents 16c97eb + e204e18 commit 639c9c2d55164eab8ef1f8c21a7f9b69b54686ff @ckieffer ckieffer committed Sep 25, 2009
Showing with 347 additions and 232 deletions.
  1. +0 −1 modules/gallery/controllers/albums.php
  2. +2 −2 modules/gallery/controllers/movies.php
  3. +3 −2 modules/gallery/helpers/album.php
  4. +30 −3 modules/gallery/helpers/gallery.php
  5. +1 −1 modules/gallery/helpers/gallery_error.php
  6. +54 −0 modules/gallery/helpers/gallery_graphics.php
  7. +14 −3 modules/gallery/helpers/gallery_installer.php
  8. +12 −9 modules/gallery/helpers/gallery_task.php
  9. +4 −91 modules/gallery/helpers/graphics.php
  10. +30 −0 modules/gallery/helpers/movie.php
  11. +3 −2 modules/gallery/helpers/photo.php
  12. +3 −3 modules/gallery/libraries/Admin_View.php
  13. +2 −2 modules/gallery/libraries/Theme_View.php
  14. +1 −1 modules/gallery/module.info
  15. +2 −2 modules/gallery/tests/Xss_Security_Test.php
  16. +88 −88 modules/gallery/tests/xss_data.txt
  17. +2 −2 modules/gallery/views/admin_maintenance_show_log.html.php
  18. +17 −16 modules/gallery/views/permissions_form.html.php
  19. +1 −1 modules/gallery/views/simple_uploader.html.php
  20. +75 −0 modules/watermark/helpers/watermark_graphics.php
  21. 0 themes/{admin_default → admin_wind}/css/fix-ie.css
  22. 0 themes/{admin_default → admin_wind}/css/screen.css
  23. BIN themes/{admin_default → admin_wind}/images/avatar.jpg
  24. BIN themes/{default → admin_wind}/images/ico-album.png
  25. BIN themes/{default → admin_wind}/images/ico-error.png
  26. BIN themes/{default → admin_wind}/images/ico-info.png
  27. BIN themes/{default → admin_wind}/images/ico-print.png
  28. BIN themes/{default → admin_wind}/images/ico-separator.gif
  29. BIN themes/{default → admin_wind}/images/ico-success.png
  30. BIN themes/{default → admin_wind}/images/ico-view-comments.png
  31. BIN themes/{default → admin_wind}/images/ico-view-fullsize.png
  32. BIN themes/{default → admin_wind}/images/ico-view-hybrid.png
  33. BIN themes/{default → admin_wind}/images/ico-view-slideshow.png
  34. BIN themes/{default → admin_wind}/images/ico-warning.png
  35. +1 −1 themes/{admin_default → admin_wind}/js/ui.init.js
  36. +1 −1 themes/{admin_default → admin_wind}/theme.info
  37. BIN themes/{admin_default → admin_wind}/thumbnail.png
  38. 0 themes/{admin_default → admin_wind}/views/admin.html.php
  39. 0 themes/{admin_default → admin_wind}/views/block.html.php
  40. 0 themes/{admin_default → admin_wind}/views/pager.html.php
  41. 0 themes/{default → wind}/css/fix-ie.css
  42. 0 themes/{default → wind}/css/screen.css
  43. BIN themes/{default → wind}/images/avatar.jpg
  44. BIN themes/{admin_default → wind}/images/ico-album.png
  45. BIN themes/{default → wind}/images/ico-denied-gray.png
  46. BIN themes/{default → wind}/images/ico-denied-pale.png
  47. BIN themes/{default → wind}/images/ico-denied.png
  48. BIN themes/{admin_default → wind}/images/ico-error.png
  49. BIN themes/{default → wind}/images/ico-help.png
  50. BIN themes/{admin_default → wind}/images/ico-info.png
  51. BIN themes/{default → wind}/images/ico-lock.png
  52. BIN themes/{admin_default → wind}/images/ico-print.png
  53. BIN themes/{admin_default → wind}/images/ico-separator.gif
  54. BIN themes/{default → wind}/images/ico-success-gray.png
  55. BIN themes/{default → wind}/images/ico-success-pale.png
  56. BIN themes/{admin_default → wind}/images/ico-success.png
  57. BIN themes/{admin_default → wind}/images/ico-view-comments.png
  58. BIN themes/{admin_default → wind}/images/ico-view-fullsize.png
  59. BIN themes/{admin_default → wind}/images/ico-view-hybrid.png
  60. BIN themes/{admin_default → wind}/images/ico-view-slideshow.png
  61. BIN themes/{admin_default → wind}/images/ico-warning.png
  62. BIN themes/{default → wind}/images/select-photos-backg.png
  63. 0 themes/{default → wind}/js/ui.init.js
  64. +1 −1 themes/{default → wind}/theme.info
  65. BIN themes/{default → wind}/thumbnail.png
  66. 0 themes/{default → wind}/views/album.html.php
  67. 0 themes/{default → wind}/views/block.html.php
  68. 0 themes/{default → wind}/views/dynamic.html.php
  69. 0 themes/{default → wind}/views/movie.html.php
  70. 0 themes/{default → wind}/views/page.html.php
  71. 0 themes/{default → wind}/views/pager.html.php
  72. 0 themes/{default → wind}/views/photo.html.php
  73. 0 themes/{default → wind}/views/sidebar.html.php
@@ -28,7 +28,6 @@ public function _show($album) {
if ($album->id == 1) {
$view = new Theme_View("page.html", "login");
$view->page_title = t("Log in to Gallery");
- //$view->content = user::get_login_form("login/auth_html");
$view->content = new View("login_ajax.html");
$view->content->form = user::get_login_form("login/auth_html");
print $view;
@@ -60,7 +60,7 @@ public function _update($movie) {
access::required("view", $movie);
access::required("edit", $movie);
- $form = photo::get_edit_form($movie);
+ $form = movie::get_edit_form($movie);
if ($valid = $form->validate()) {
if ($form->edit_item->filename->value != $movie->name ||
$form->edit_item->slug->value != $movie->slug) {
@@ -114,6 +114,6 @@ public function _update($movie) {
public function _form_edit($movie) {
access::required("view", $movie);
access::required("edit", $movie);
- print photo::get_edit_form($movie);
+ print movie::get_edit_form($movie);
}
}
@@ -123,14 +123,15 @@ static function get_edit_form($parent) {
if ($parent->id != 1) {
$group->input("dirname")->label(t("Directory Name"))->value($parent->name)
->rules("required")
- ->error_messages("name_conflict", t("There is already a photo or album with this name"))
+ ->error_messages(
+ "name_conflict", t("There is already a movie, photo or album with this name"))
->callback("item::validate_no_slashes")
->error_messages("no_slashes", t("The directory name can't contain a \"/\""))
->callback("item::validate_no_trailing_period")
->error_messages("no_trailing_period", t("The directory name can't end in \".\""));
$group->input("slug")->label(t("Internet Address"))->value($parent->slug)
->error_messages(
- "slug_conflict", t("There is already a photo or album with this internet address"))
+ "slug_conflict", t("There is already a movie, photo or album with this internet address"))
->callback("item::validate_url_safe")
->error_messages(
"not_url_safe",
@@ -79,6 +79,20 @@ static function time($timestamp) {
return date(module::get_var("gallery", "time_format", "H:i:s"), $timestamp);
}
+ /**
+ * Provide a wrapper function for Kohana::find_file, that first strips the extension and
+ * then calls the Kohana::find_file supply that extension
+ * @param string directory to search in
+ * @param string filename to look for (without extension)
+ * @param boolean file required
+ * @return the file relative to the DOCROOT
+ */
+ static function find_file($directory, $file, $required=false) {
+ $file_name = substr($file, 0, -strlen($ext = strrchr($file, '.')));
+ $file_name = Kohana::find_file($directory, $file_name, $required, substr($ext, 1));
+ return substr($file_name, strlen(DOCROOT));
+ }
+
static function site_menu($menu, $theme) {
if ($theme->page_type != "login") {
$menu->append(Menu::factory("link")
@@ -114,19 +128,32 @@ static function site_menu($menu, $theme) {
}
}
+ switch ($item->type) {
+ case "album":
+ $option_text = t("Album options");
+ $edit_text = t("Edit album");
+ break;
+ case "movie":
+ $option_text = t("Movie options");
+ $edit_text = t("Edit movie");
+ break;
+ default:
+ $option_text = t("Photo options");
+ $edit_text = t("Edit photo");
+ }
+
$menu->append($options_menu = Menu::factory("submenu")
->id("options_menu")
- ->label(t("Photo options")));
+ ->label($option_text));
if ($item && ($can_edit || $can_add)) {
if ($can_edit) {
$options_menu->append(Menu::factory("dialog")
->id("edit_item")
- ->label($item->is_album() ? t("Edit album") : t("Edit photo"))
+ ->label($edit_text)
->url(url::site("form/edit/{$item->type}s/$item->id")));
}
if ($item->is_album()) {
- $options_menu->label(t("Album options"));
if ($can_edit) {
$options_menu->append(Menu::factory("dialog")
->id("edit_permissions")
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class gallery_error_Core {
- function error_handler($severity, $message, $filename, $lineno) {
+ static function error_handler($severity, $message, $filename, $lineno) {
if (error_reporting() == 0) {
return;
}
@@ -0,0 +1,54 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 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 gallery_graphics_Core {
+ /**
+ * Resize an image. Valid options are width, height and master. Master is one of the Image
+ * master dimension constants.
+ *
+ * @param string $input_file
+ * @param string $output_file
+ * @param array $options
+ */
+ static function resize($input_file, $output_file, $options) {
+ graphics::init_toolkit();
+
+ module::event("graphics_resize", $input_file, $output_file, $options);
+
+ if (@filesize($input_file) == 0) {
+ throw new Exception("@todo EMPTY_INPUT_FILE");
+ }
+
+ $dims = getimagesize($input_file);
+ if (max($dims[0], $dims[1]) < min($options["width"], $options["height"])) {
+ // Image would get upscaled; do nothing
+ copy($input_file, $output_file);
+ } else {
+ $image = Image::factory($input_file)
+ ->resize($options["width"], $options["height"], $options["master"])
+ ->quality(module::get_var("gallery", "image_quality"));
+ if (graphics::can("sharpen")) {
+ $image->sharpen(module::get_var("gallery", "image_sharpen"));
+ }
+ $image->save($output_file);
+ }
+
+ module::event("graphics_resize_completed", $input_file, $output_file, $options);
+ }
+}
@@ -224,8 +224,8 @@ static function install() {
$root->save();
access::add_item($root);
- module::set_var("gallery", "active_site_theme", "default");
- module::set_var("gallery", "active_admin_theme", "admin_default");
+ module::set_var("gallery", "active_site_theme", "wind");
+ module::set_var("gallery", "active_admin_theme", "admin_wind");
module::set_var("gallery", "page_size", 9);
module::set_var("gallery", "thumb_size", 200);
module::set_var("gallery", "resize_size", 640);
@@ -268,7 +268,7 @@ static function install() {
module::set_var("gallery", "show_credits", 1);
// @todo this string needs to be picked up by l10n_scanner
module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>");
- module::set_version("gallery", 12);
+ module::set_version("gallery", 13);
}
static function upgrade($version) {
@@ -364,6 +364,17 @@ static function upgrade($version) {
$db->query("UPDATE {items} SET `relative_url_cache` = NULL, `relative_path_cache` = NULL");
module::set_version("gallery", $version = 12);
}
+
+ if ($version == 12) {
+ if (module::get_var("gallery", "active_site_theme") == "default") {
+ module::set_var("gallery", "active_site_theme", "wind");
+ }
+ if (module::get_var("gallery", "active_admin_theme") == "admin_default") {
+ module::set_var("gallery", "active_admin_theme", "admin_wind");
+ }
+ module::set_version("gallery", $version = 13);
+ }
+
}
static function uninstall() {
@@ -48,9 +48,13 @@ static function rebuild_dirty_images($task) {
$errors = array();
try {
$result = graphics::find_dirty_images_query();
+ $total_count = $task->get("total_count", -1);
+ if ($total_count < 0) {
+ $total_count = $result->count();
+ $task->set("total_count", $total_count);
+ }
$completed = $task->get("completed", 0);
$ignored = $task->get("ignored", array());
- $remaining = $result->count() - count($ignored);
$i = 0;
foreach ($result as $row) {
@@ -62,19 +66,18 @@ static function rebuild_dirty_images($task) {
if ($item->loaded) {
try {
graphics::generate($item);
- $ignored[$item->id] = 1;
+ $completed++;
+
$errors[] = t("Successfully rebuilt images for '%title'",
array("title" => html::purify($item->title)));
} catch (Exception $e) {
$errors[] = t("Unable to rebuild images for '%title'",
array("title" => html::purify($item->title)));
$errors[] = $e->__toString();
+ $ignored[$item->id] = 1;
}
}
- $completed++;
- $remaining--;
-
if (++$i == 2) {
break;
}
@@ -83,17 +86,17 @@ static function rebuild_dirty_images($task) {
$task->status = t2("Updated: 1 image. Total: %total_count.",
"Updated: %count images. Total: %total_count.",
$completed,
- array("total_count" => ($remaining + $completed)));
+ array("total_count" => $total_count));
- if ($completed + $remaining > 0) {
- $task->percent_complete = (int)(100 * $completed / ($completed + $remaining));
+ if ($completed < $total_count) {
+ $task->percent_complete = (int)(100 * ($completed + count($ignored)) / $total_count);
} else {
$task->percent_complete = 100;
}
$task->set("completed", $completed);
$task->set("ignored", $ignored);
- if ($remaining == 0) {
+ if ($task->percent_complete == 100) {
$task->done = true;
$task->state = "success";
site_status::clear("graphics_dirty");
@@ -152,7 +152,7 @@ static function generate($item) {
->orderby("priority", "asc")
->find_all() as $rule) {
$args = array($working_file, $output_file, unserialize($rule->args));
- call_user_func_array(array("graphics", $rule->operation), $args);
+ call_user_func_array(array("{$rule->module_name}_graphics", $rule->operation), $args);
$working_file = $output_file;
}
}
@@ -181,42 +181,6 @@ static function generate($item) {
}
/**
- * Resize an image. Valid options are width, height and master. Master is one of the Image
- * master dimension constants.
- *
- * @param string $input_file
- * @param string $output_file
- * @param array $options
- */
- static function resize($input_file, $output_file, $options) {
- if (!self::$init) {
- self::init_toolkit();
- }
-
- module::event("graphics_resize", $input_file, $output_file, $options);
-
- if (@filesize($input_file) == 0) {
- throw new Exception("@todo EMPTY_INPUT_FILE");
- }
-
- $dims = getimagesize($input_file);
- if (max($dims[0], $dims[1]) < min($options["width"], $options["height"])) {
- // Image would get upscaled; do nothing
- copy($input_file, $output_file);
- } else {
- $image = Image::factory($input_file)
- ->resize($options["width"], $options["height"], $options["master"])
- ->quality(module::get_var("gallery", "image_quality"));
- if (graphics::can("sharpen")) {
- $image->sharpen(module::get_var("gallery", "image_sharpen"));
- }
- $image->save($output_file);
- }
-
- module::event("graphics_resize_completed", $input_file, $output_file, $options);
- }
-
- /**
* Rotate an image. Valid options are degrees
*
* @param string $input_file
@@ -239,60 +203,6 @@ static function rotate($input_file, $output_file, $options) {
}
/**
- * Overlay an image on top of the input file.
- *
- * Valid options are: file, mime_type, position, transparency_percent, padding
- *
- * Valid positions: northwest, north, northeast,
- * west, center, east,
- * southwest, south, southeast
- *
- * padding is in pixels
- *
- * @param string $input_file
- * @param string $output_file
- * @param array $options
- */
- static function composite($input_file, $output_file, $options) {
- if (!self::$init) {
- self::init_toolkit();
- }
-
- module::event("graphics_composite", $input_file, $output_file, $options);
-
- list ($width, $height) = getimagesize($input_file);
- list ($w_width, $w_height) = getimagesize($options["file"]);
-
- $pad = isset($options["padding"]) ? $options["padding"] : 10;
- $top = $pad;
- $left = $pad;
- $y_center = max($height / 2 - $w_height / 2, $pad);
- $x_center = max($width / 2 - $w_width / 2, $pad);
- $bottom = max($height - $w_height - $pad, $pad);
- $right = max($width - $w_width - $pad, $pad);
-
- switch ($options["position"]) {
- case "northwest": $x = $left; $y = $top; break;
- case "north": $x = $x_center; $y = $top; break;
- case "northeast": $x = $right; $y = $top; break;
- case "west": $x = $left; $y = $y_center; break;
- case "center": $x = $x_center; $y = $y_center; break;
- case "east": $x = $right; $y = $y_center; break;
- case "southwest": $x = $left; $y = $bottom; break;
- case "south": $x = $x_center; $y = $bottom; break;
- case "southeast": $x = $right; $y = $bottom; break;
- }
-
- Image::factory($input_file)
- ->composite($options["file"], $x, $y, $options["transparency"])
- ->quality(module::get_var("gallery", "image_quality"))
- ->save($output_file);
-
-
- module::event("graphics_composite_completed", $input_file, $output_file, $options);
- }
-
- /**
* Return a query result that locates all items with dirty images.
* @return Database_Result Query result
*/
@@ -463,6 +373,9 @@ static function choose_default_toolkit() {
* Choose which driver the Kohana Image library uses.
*/
static function init_toolkit() {
+ if (self::$init) {
+ return;
+ }
switch(module::get_var("gallery", "graphics_toolkit")) {
case "gd":
Kohana::config_set("image.driver", "GD");
Oops, something went wrong.

0 comments on commit 639c9c2

Please sign in to comment.