Skip to content
Browse files

Merge branch 'master' into bharat_dev

  • Loading branch information...
2 parents a7c04d0 + 39cd84d commit 15422e449514d3c82eb57724c312488783a2fcda @bharat bharat committed
View
6 installer/install.sql
@@ -88,8 +88,8 @@ CREATE TABLE {graphics_rules} (
PRIMARY KEY (`id`)
) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
-INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','resize',100,'thumb');
-INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:480;s:6:\"master\";i:2;}','gallery','resize',100,'resize');
+INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'thumb');
+INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:480;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'resize');
DROP TABLE IF EXISTS {groups};
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
@@ -228,7 +228,7 @@ CREATE TABLE {modules} (
UNIQUE KEY `name` (`name`)
) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
-INSERT INTO {modules} VALUES (1,1,'gallery',13);
+INSERT INTO {modules} VALUES (1,1,'gallery',14);
INSERT INTO {modules} VALUES (2,1,'user',1);
INSERT INTO {modules} VALUES (3,1,'comment',2);
INSERT INTO {modules} VALUES (4,1,'organize',1);
View
12 lib/gallery.common.js
@@ -6,6 +6,18 @@
});
};
+ // Make the height of all items the same as the tallest item within the set
+ $.fn.equal_heights = function() {
+ var tallest_height = 0;
+ $(this).each(function(){
+ if ($(this).height() > tallest_height) {
+ tallest_height = $(this).height();
+ }
+ });
+ return $(this).height(tallest_height);
+ };
+
+
// Vertically align a block element's content
$.fn.gallery_valign = function(container) {
return this.each(function(i){
View
8 modules/gallery/controllers/admin_theme_options.php
@@ -35,9 +35,9 @@ public function save() {
$thumb_size = $form->edit_theme->thumb_size->value;
$thumb_dirty = false;
if (module::get_var("gallery", "thumb_size") != $thumb_size) {
- graphics::remove_rule("gallery", "thumb", "resize");
+ graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
graphics::add_rule(
- "gallery", "thumb", "resize",
+ "gallery", "thumb", "gallery_graphics::resize",
array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO),
100);
module::set_var("gallery", "thumb_size", $thumb_size);
@@ -46,9 +46,9 @@ public function save() {
$resize_size = $form->edit_theme->resize_size->value;
$resize_dirty = false;
if (module::get_var("gallery", "resize_size") != $resize_size) {
- graphics::remove_rule("gallery", "resize", "resize");
+ graphics::remove_rule("gallery", "resize", "gallery_graphics::resize");
graphics::add_rule(
- "gallery", "resize", "resize",
+ "gallery", "resize", "gallery_graphics::resize",
array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO),
100);
module::set_var("gallery", "resize_size", $resize_size);
View
261 modules/gallery/helpers/gallery.php
@@ -80,264 +80,23 @@ static function time($timestamp) {
}
/**
- * Provide a wrapper function for Kohana::find_file, that first strips the extension and
- * then calls the Kohana::find_file supply that extension
+ * Provide a wrapper function for Kohana::find_file that first strips the extension and
+ * then calls the Kohana::find_file and supplies the extension as the type.
* @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
+ * @param string filename to look for
+ * @param boolean file required (optional: default false)
+ * @return array if the extension is config, i18n or l10n
+ * @return string if the file is found (relative to the DOCROOT)
+ * @return false if the file is not found
*/
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")
- ->id("home")
- ->label(t("Home"))
- ->url(item::root()->url()));
-
- $item = $theme->item();
-
- $can_edit = $item && access::can("edit", $item);
- $can_add = $item && access::can("add", $item);
-
- if ($can_add) {
- $menu->append($add_menu = Menu::factory("submenu")
- ->id("add_menu")
- ->label(t("Add")));
- $is_album_writable =
- is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path());
- if ($is_album_writable) {
- $add_menu->append(Menu::factory("dialog")
- ->id("add_photos_item")
- ->label(t("Add photos"))
- ->url(url::site("simple_uploader/app/$item->id")));
- if ($item->is_album()) {
- $add_menu->append(Menu::factory("dialog")
- ->id("add_album_item")
- ->label(t("Add an album"))
- ->url(url::site("form/add/albums/$item->id?type=album")));
- }
- } else {
- message::warning(t("The album '%album_name' is not writable.",
- array("album_name" => $item->title)));
- }
- }
-
- 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($option_text));
- if ($item && ($can_edit || $can_add)) {
- if ($can_edit) {
- $options_menu->append(Menu::factory("dialog")
- ->id("edit_item")
- ->label($edit_text)
- ->url(url::site("form/edit/{$item->type}s/$item->id")));
- }
-
- if ($item->is_album()) {
- if ($can_edit) {
- $options_menu->append(Menu::factory("dialog")
- ->id("edit_permissions")
- ->label(t("Edit permissions"))
- ->url(url::site("permissions/browse/$item->id")));
- }
- }
- }
-
- if (user::active()->admin) {
- $menu->append($admin_menu = Menu::factory("submenu")
- ->id("admin_menu")
- ->label(t("Admin")));
- gallery::admin_menu($admin_menu, $theme);
- module::event("admin_menu", $admin_menu, $theme);
- }
-
- module::event("site_menu", $menu, $theme);
+ if (!$file_name && file_exists(DOCROOT . "lib/$file")) {
+ return "lib/$file";
}
- }
- static function admin_menu($menu, $theme) {
- $menu
- ->append(Menu::factory("link")
- ->id("dashboard")
- ->label(t("Dashboard"))
- ->url(url::site("admin")))
- ->append(Menu::factory("submenu")
- ->id("settings_menu")
- ->label(t("Settings"))
- ->append(Menu::factory("link")
- ->id("graphics_toolkits")
- ->label(t("Graphics"))
- ->url(url::site("admin/graphics")))
- ->append(Menu::factory("link")
- ->id("languages")
- ->label(t("Languages"))
- ->url(url::site("admin/languages")))
- ->append(Menu::factory("link")
- ->id("advanced")
- ->label(t("Advanced"))
- ->url(url::site("admin/advanced_settings"))))
- ->append(Menu::factory("link")
- ->id("modules")
- ->label(t("Modules"))
- ->url(url::site("admin/modules")))
- ->append(Menu::factory("submenu")
- ->id("content_menu")
- ->label(t("Content")))
- ->append(Menu::factory("submenu")
- ->id("appearance_menu")
- ->label(t("Appearance"))
- ->append(Menu::factory("link")
- ->id("themes")
- ->label(t("Theme Choice"))
- ->url(url::site("admin/themes")))
- ->append(Menu::factory("link")
- ->id("theme_options")
- ->label(t("Theme Options"))
- ->url(url::site("admin/theme_options"))))
- ->append(Menu::factory("submenu")
- ->id("statistics_menu")
- ->label(t("Statistics")))
- ->append(Menu::factory("link")
- ->id("maintenance")
- ->label(t("Maintenance"))
- ->url(url::site("admin/maintenance")));
- return $menu;
+ return is_string($file_name) ? substr($file_name, strlen(DOCROOT)) : $file_name;
}
- static function context_menu($menu, $theme, $item, $thumb_css_selector) {
- $menu->append($options_menu = Menu::factory("submenu")
- ->id("options_menu")
- ->label(t("Options"))
- ->css_class("ui-icon-carat-1-n"));
-
- if (access::can("edit", $item)) {
- $page_type = $theme->page_type();
- switch ($item->type) {
- case "movie":
- $edit_title = t("Edit this movie");
- $delete_title = t("Delete this movie");
- break;
-
- case "album":
- $edit_title = t("Edit this album");
- $delete_title = t("Delete this album");
- break;
-
- default:
- $edit_title = t("Edit this photo");
- $delete_title = t("Delete this photo");
- break;
- }
- $cover_title = t("Choose as the album cover");
- $move_title = t("Move to another album");
-
- $csrf = access::csrf_token();
-
- $options_menu->append(Menu::factory("dialog")
- ->id("edit")
- ->label($edit_title)
- ->css_class("ui-icon-pencil")
- ->url(url::site("quick/form_edit/$item->id?page_type=$page_type")));
-
-
- if ($item->is_photo() && graphics::can("rotate")) {
- $options_menu
- ->append(
- Menu::factory("ajax_link")
- ->id("rotate_ccw")
- ->label(t("Rotate 90° counter clockwise"))
- ->css_class("ui-icon-rotate-ccw")
- ->ajax_handler("function(data) { " .
- "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
- ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type")))
- ->append(
- Menu::factory("ajax_link")
- ->id("rotate_cw")
- ->label(t("Rotate 90° clockwise"))
- ->css_class("ui-icon-rotate-cw")
- ->ajax_handler("function(data) { " .
- "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
- ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type")));
- }
-
- // Don't move photos from the photo page; we don't yet have a good way of redirecting after
- // move
- if ($page_type == "album") {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("move")
- ->label($move_title)
- ->css_class("ui-icon-folder-open")
- ->url(url::site("move/browse/$item->id")));
- }
-
- $parent = $item->parent();
- if (access::can("edit", $parent)) {
- // We can't make this item the highlight if it's an album with no album cover, or if it's
- // already the album cover.
- if (($item->type == "album" && empty($item->album_cover_item_id)) ||
- ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
- $parent->album_cover_item_id == $item->id) {
- $disabledState = " ui-state-disabled";
- } else {
- $disabledState = " ";
- }
- if ($item->parent()->id != 1) {
- $options_menu
- ->append(Menu::factory("ajax_link")
- ->id("make_album_cover")
- ->label($cover_title)
- ->css_class("ui-icon-star")
- ->ajax_handler("function(data) { window.location.reload() }")
- ->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf")));
- }
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("delete")
- ->label($delete_title)
- ->css_class("ui-icon-trash")
- ->css_id("gQuickDelete")
- ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")));
- }
-
- if ($item->is_album()) {
- $options_menu
- ->append(Menu::factory("dialog")
- ->id("add_item")
- ->label(t("Add a photo"))
- ->css_class("ui-icon-plus")
- ->url(url::site("simple_uploader/app/$item->id")))
- ->append(Menu::factory("dialog")
- ->id("add_album")
- ->label(t("Add an album"))
- ->css_class("ui-icon-note")
- ->url(url::site("form/add/albums/$item->id?type=album")))
- ->append(Menu::factory("dialog")
- ->id("edit_permissions")
- ->label(t("Edit permissions"))
- ->css_class("ui-icon-key")
- ->url(url::site("permissions/browse/$item->id")));
- }
- }
- }
}
View
245 modules/gallery/helpers/gallery_event.php
@@ -53,4 +53,249 @@ static function item_index_data($item, $data) {
$data[] = $item->name;
$data[] = $item->title;
}
+
+ static function site_menu($menu, $theme) {
+ if ($theme->page_type != "login") {
+ $menu->append(Menu::factory("link")
+ ->id("home")
+ ->label(t("Home"))
+ ->url(item::root()->url()));
+
+ $item = $theme->item();
+
+ $can_edit = $item && access::can("edit", $item);
+ $can_add = $item && access::can("add", $item);
+
+ if ($can_add) {
+ $menu->append($add_menu = Menu::factory("submenu")
+ ->id("add_menu")
+ ->label(t("Add")));
+ $is_album_writable =
+ is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path());
+ if ($is_album_writable) {
+ $add_menu->append(Menu::factory("dialog")
+ ->id("add_photos_item")
+ ->label(t("Add photos"))
+ ->url(url::site("simple_uploader/app/$item->id")));
+ if ($item->is_album()) {
+ $add_menu->append(Menu::factory("dialog")
+ ->id("add_album_item")
+ ->label(t("Add an album"))
+ ->url(url::site("form/add/albums/$item->id?type=album")));
+ }
+ } else {
+ message::warning(t("The album '%album_name' is not writable.",
+ array("album_name" => $item->title)));
+ }
+ }
+
+ 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($option_text));
+ if ($item && ($can_edit || $can_add)) {
+ if ($can_edit) {
+ $options_menu->append(Menu::factory("dialog")
+ ->id("edit_item")
+ ->label($edit_text)
+ ->url(url::site("form/edit/{$item->type}s/$item->id")));
+ }
+
+ if ($item->is_album()) {
+ if ($can_edit) {
+ $options_menu->append(Menu::factory("dialog")
+ ->id("edit_permissions")
+ ->label(t("Edit permissions"))
+ ->url(url::site("permissions/browse/$item->id")));
+ }
+ }
+ }
+
+ if (user::active()->admin) {
+ $menu->append($admin_menu = Menu::factory("submenu")
+ ->id("admin_menu")
+ ->label(t("Admin")));
+ module::event("admin_menu", $admin_menu, $theme);
+ }
+ }
+ }
+
+ static function admin_menu($menu, $theme) {
+ $menu
+ ->append(Menu::factory("link")
+ ->id("dashboard")
+ ->label(t("Dashboard"))
+ ->url(url::site("admin")))
+ ->append(Menu::factory("submenu")
+ ->id("settings_menu")
+ ->label(t("Settings"))
+ ->append(Menu::factory("link")
+ ->id("graphics_toolkits")
+ ->label(t("Graphics"))
+ ->url(url::site("admin/graphics")))
+ ->append(Menu::factory("link")
+ ->id("languages")
+ ->label(t("Languages"))
+ ->url(url::site("admin/languages")))
+ ->append(Menu::factory("link")
+ ->id("advanced")
+ ->label(t("Advanced"))
+ ->url(url::site("admin/advanced_settings"))))
+ ->append(Menu::factory("link")
+ ->id("modules")
+ ->label(t("Modules"))
+ ->url(url::site("admin/modules")))
+ ->append(Menu::factory("submenu")
+ ->id("content_menu")
+ ->label(t("Content")))
+ ->append(Menu::factory("submenu")
+ ->id("appearance_menu")
+ ->label(t("Appearance"))
+ ->append(Menu::factory("link")
+ ->id("themes")
+ ->label(t("Theme Choice"))
+ ->url(url::site("admin/themes")))
+ ->append(Menu::factory("link")
+ ->id("theme_options")
+ ->label(t("Theme Options"))
+ ->url(url::site("admin/theme_options"))))
+ ->append(Menu::factory("submenu")
+ ->id("statistics_menu")
+ ->label(t("Statistics")))
+ ->append(Menu::factory("link")
+ ->id("maintenance")
+ ->label(t("Maintenance"))
+ ->url(url::site("admin/maintenance")));
+ return $menu;
+ }
+
+ static function context_menu($menu, $theme, $item, $thumb_css_selector) {
+ $menu->append($options_menu = Menu::factory("submenu")
+ ->id("options_menu")
+ ->label(t("Options"))
+ ->css_class("ui-icon-carat-1-n"));
+
+ if (access::can("edit", $item)) {
+ $page_type = $theme->page_type();
+ switch ($item->type) {
+ case "movie":
+ $edit_title = t("Edit this movie");
+ $delete_title = t("Delete this movie");
+ break;
+
+ case "album":
+ $edit_title = t("Edit this album");
+ $delete_title = t("Delete this album");
+ break;
+
+ default:
+ $edit_title = t("Edit this photo");
+ $delete_title = t("Delete this photo");
+ break;
+ }
+ $cover_title = t("Choose as the album cover");
+ $move_title = t("Move to another album");
+
+ $csrf = access::csrf_token();
+
+ $options_menu->append(Menu::factory("dialog")
+ ->id("edit")
+ ->label($edit_title)
+ ->css_class("ui-icon-pencil")
+ ->url(url::site("quick/form_edit/$item->id?page_type=$page_type")));
+
+
+ if ($item->is_photo() && graphics::can("rotate")) {
+ $options_menu
+ ->append(
+ Menu::factory("ajax_link")
+ ->id("rotate_ccw")
+ ->label(t("Rotate 90° counter clockwise"))
+ ->css_class("ui-icon-rotate-ccw")
+ ->ajax_handler("function(data) { " .
+ "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
+ ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type")))
+ ->append(
+ Menu::factory("ajax_link")
+ ->id("rotate_cw")
+ ->label(t("Rotate 90° clockwise"))
+ ->css_class("ui-icon-rotate-cw")
+ ->ajax_handler("function(data) { " .
+ "\$.gallery_replace_image(data, \$('$thumb_css_selector')) }")
+ ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type")));
+ }
+
+ // Don't move photos from the photo page; we don't yet have a good way of redirecting after
+ // move
+ if ($page_type == "album") {
+ $options_menu
+ ->append(Menu::factory("dialog")
+ ->id("move")
+ ->label($move_title)
+ ->css_class("ui-icon-folder-open")
+ ->url(url::site("move/browse/$item->id")));
+ }
+
+ $parent = $item->parent();
+ if (access::can("edit", $parent)) {
+ // We can't make this item the highlight if it's an album with no album cover, or if it's
+ // already the album cover.
+ if (($item->type == "album" && empty($item->album_cover_item_id)) ||
+ ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
+ $parent->album_cover_item_id == $item->id) {
+ $disabledState = " ui-state-disabled";
+ } else {
+ $disabledState = " ";
+ }
+ if ($item->parent()->id != 1) {
+ $options_menu
+ ->append(Menu::factory("ajax_link")
+ ->id("make_album_cover")
+ ->label($cover_title)
+ ->css_class("ui-icon-star")
+ ->ajax_handler("function(data) { window.location.reload() }")
+ ->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf")));
+ }
+ $options_menu
+ ->append(Menu::factory("dialog")
+ ->id("delete")
+ ->label($delete_title)
+ ->css_class("ui-icon-trash")
+ ->css_id("gQuickDelete")
+ ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")));
+ }
+
+ if ($item->is_album()) {
+ $options_menu
+ ->append(Menu::factory("dialog")
+ ->id("add_item")
+ ->label(t("Add a photo"))
+ ->css_class("ui-icon-plus")
+ ->url(url::site("simple_uploader/app/$item->id")))
+ ->append(Menu::factory("dialog")
+ ->id("add_album")
+ ->label(t("Add an album"))
+ ->css_class("ui-icon-note")
+ ->url(url::site("form/add/albums/$item->id?type=album")))
+ ->append(Menu::factory("dialog")
+ ->id("edit_permissions")
+ ->label(t("Edit permissions"))
+ ->css_class("ui-icon-key")
+ ->url(url::site("permissions/browse/$item->id")));
+ }
+ }
+ }
}
View
55 modules/gallery/helpers/gallery_graphics.php
@@ -51,4 +51,59 @@ static function resize($input_file, $output_file, $options) {
module::event("graphics_resize_completed", $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) {
+ try {
+ graphics::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);
+ } catch (ErrorException $e) {
+ Kohana::log("error", $e->get_message());
+ }
+ }
}
View
13 modules/gallery/helpers/gallery_installer.php
@@ -235,11 +235,11 @@ static function install() {
// Add rules for generating our thumbnails and resizes
graphics::add_rule(
- "gallery", "thumb", "resize",
+ "gallery", "thumb", "gallery_graphics::resize",
array("width" => 200, "height" => 200, "master" => Image::AUTO),
100);
graphics::add_rule(
- "gallery", "resize", "resize",
+ "gallery", "resize", "gallery_graphics::resize",
array("width" => 640, "height" => 480, "master" => Image::AUTO),
100);
@@ -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", 13);
+ module::set_version("gallery", 14);
}
static function upgrade($version) {
@@ -375,6 +375,13 @@ static function upgrade($version) {
module::set_version("gallery", $version = 13);
}
+ if ($version == 13) {
+ // Add rules for generating our thumbnails and resizes
+ Database::instance()->query(
+ "UPDATE {graphics_rules} SET `operation` = CONCAT('gallery_graphics::', `operation`);");
+ module::set_version("gallery", $version = 14);
+ }
+
}
static function uninstall() {
View
8 modules/gallery/helpers/gallery_task.php
@@ -48,11 +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();
+ $total_count = $task->get("total_count", $result->count());
+ $mode = $task->get("mode", "init");
+ if ($mode == "init") {
$task->set("total_count", $total_count);
+ $task->get("mode", "process");
}
+
$completed = $task->get("completed", 0);
$ignored = $task->get("ignored", array());
View
30 modules/gallery/helpers/graphics.php
@@ -19,6 +19,7 @@
*/
class graphics_Core {
private static $init;
+ private static $_rules_cache = array();
/**
* Add a new graphics rule.
@@ -26,7 +27,7 @@ class graphics_Core {
* Rules are applied to targets (thumbnails and resizes) in priority order. Rules are functions
* in the graphics class. So for example, the following rule:
*
- * graphics::add_rule("gallery", "thumb", "resize",
+ * graphics::add_rule("gallery", "thumb", "gallery_graphics::resize",
* array("width" => 200, "height" => 200, "master" => Image::AUTO), 100);
*
* Specifies that "gallery" is adding a rule to resize thumbnails down to a max of 200px on
@@ -35,7 +36,7 @@ class graphics_Core {
*
* @param string $module_name the module that added the rule
* @param string $target the target for this operation ("thumb" or "resize")
- * @param string $operation the name of the operation
+ * @param string $operation the name of the operation (<defining class>::method)
* @param array $args arguments to the operation
* @param integer $priority the priority for this rule (lower priorities are run first)
*/
@@ -56,7 +57,7 @@ static function add_rule($module_name, $target, $operation, $args, $priority) {
* Remove any matching graphics rules
* @param string $module_name the module that added the rule
* @param string $target the target for this operation ("thumb" or "resize")
- * @param string $operation the name of the operation
+ * @param string $operation the name of the operation(<defining class>::method)
*/
static function remove_rule($module_name, $target, $operation) {
ORM::factory("graphics_rule")
@@ -146,13 +147,9 @@ static function generate($item) {
$working_file = $input_file;
}
- foreach (ORM::factory("graphics_rule")
- ->where("target", $target)
- ->where("active", true)
- ->orderby("priority", "asc")
- ->find_all() as $rule) {
+ foreach (self::_get_rules($target) as $rule) {
$args = array($working_file, $output_file, unserialize($rule->args));
- call_user_func_array(array("{$rule->module_name}_graphics", $rule->operation), $args);
+ call_user_func_array($rule->operation, $args);
$working_file = $output_file;
}
}
@@ -180,6 +177,21 @@ static function generate($item) {
}
}
+ private static function _get_rules($target) {
+ if (empty(self::$_rules_cache[$target])) {
+ $rules = array();
+ foreach (ORM::factory("graphics_rule")
+ ->where("target", $target)
+ ->where("active", true)
+ ->orderby("priority", "asc")
+ ->find_all() as $rule) {
+ $rules[] = (object)$rule->as_array();
+ }
+ self::$_rules_cache[$target] = $rules;
+ }
+ return self::$_rules_cache[$target];
+ }
+
/**
* Rotate an image. Valid options are degrees
*
View
27 modules/gallery/helpers/module.php
@@ -283,9 +283,32 @@ static function event($name, &$data=null) {
array_shift($args);
$function = str_replace(".", "_", $name);
- // @todo: consider calling gallery_event first, since for things menus we need it to do some
- // setup
+ if (method_exists("gallery_event", $function)) {
+ switch (count($args)) {
+ case 0:
+ gallery_event::$function();
+ break;
+ case 1:
+ gallery_event::$function($args[0]);
+ break;
+ case 2:
+ gallery_event::$function($args[0], $args[1]);
+ break;
+ case 3:
+ gallery_event::$function($args[0], $args[1], $args[2]);
+ break;
+ case 4: // Context menu events have 4 arguments so lets optimize them
+ gallery_event::$function($args[0], $args[1], $args[2], $args[3]);
+ break;
+ default:
+ call_user_func_array(array("gallery_event", $function), $args);
+ }
+ }
+
foreach (self::$active as $module) {
+ if ($module->name == "gallery") {
+ continue;
+ }
$class = "{$module->name}_event";
if (method_exists($class, $function)) {
call_user_func_array(array($class, $function), $args);
View
1 modules/gallery/libraries/Admin_View.php
@@ -46,7 +46,6 @@ public function __construct($name) {
public function admin_menu() {
$menu = Menu::factory("root");
- gallery::admin_menu($menu, $this);
module::event("admin_menu", $menu, $this);
$menu->compact();
return $menu;
View
16 modules/gallery/libraries/Gallery_View.php
@@ -24,12 +24,12 @@ class Gallery_View_Core extends View {
/**
* Add a script to the combined scripts list.
- * @param $file the relative path to a script from the gallery3 directory
+ * @param $file the file name or path of the script to include. If a path is specified then
+ * it needs to be relative to DOCROOT. Just specifying a file name will result
+ * in searching Kohana's cascading file system.
*/
public function script($file) {
- $base_file = str_replace(".js", "", $file);
- if (($path = Kohana::find_file("js", $base_file, false, "js")) ||
- file_exists($path = DOCROOT . "lib/$file")) {
+ if (($path = gallery::find_file("js", $file, false))) {
$this->scripts[$path] = 1;
} else {
Kohana::log("error", "Can't find script file: $file");
@@ -47,12 +47,12 @@ public function url($path, $absolute_url=false) {
/**
* Add a css file to the combined css list.
- * @param $file the relative path to a script from the gallery3 directory
+ * @param $file the file name or path of the script to include. If a path is specified then
+ * it needs to be relative to DOCROOT. Just specifying a file name will result
+ * in searching Kohana's cascading file system.
*/
public function css($file) {
- $base_file = str_replace(".css", "", $file);
- if (($path = Kohana::find_file("css", $base_file, false, "css")) ||
- file_exists($path = DOCROOT . "lib/$file")) {
+ if (($path = gallery::find_file("css", $file, false))) {
$this->css[$path] = 1;
} else {
Kohana::log("error", "Can't find css file: $file");
View
2 modules/gallery/libraries/Theme_View.php
@@ -80,7 +80,6 @@ public function page_type() {
public function site_menu() {
$menu = Menu::factory("root");
- gallery::site_menu($menu, $this);
module::event("site_menu", $menu, $this);
return $menu->compact();
}
@@ -124,7 +123,6 @@ public function context_menu($item, $thumbnail_css_selector) {
->label(t("Options")))
->css_class("gContextMenu");
- gallery::context_menu($menu, $this, $item, $thumbnail_css_selector);
module::event("context_menu", $menu, $this, $item, $thumbnail_css_selector);
return $menu->compact();
}
View
2 modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 13
+version = 14
View
2 modules/watermark/controllers/admin_watermarks.php
@@ -138,7 +138,7 @@ private function _update_graphics_rules() {
if ($name = module::get_var("watermark", "name")) {
foreach (array("thumb", "resize") as $target) {
graphics::add_rule(
- "watermark", $target, "composite",
+ "watermark", $target, "gallery_graphics::composite",
array("file" => VARPATH . "modules/watermark/$name",
"width" => module::get_var("watermark", "width"),
"height" => module::get_var("watermark", "height"),
View
75 modules/watermark/helpers/watermark_graphics.php
@@ -1,75 +0,0 @@
-<?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 watermark_graphics_Core {
- /**
- * 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) {
- try {
- graphics::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);
- } catch (ErrorException $e) {
- Kohana::log("error", $e->get_message());
- }
- }
-}
View
2 modules/watermark/module.info
@@ -1,3 +1,3 @@
name = "Watermarks"
description = "Allows users to watermark their photos"
-version = 1
+version = 2
View
5 themes/admin_wind/css/screen.css
@@ -399,6 +399,11 @@ tr.gWarning {
background-color: #fcf9ce;
}
+#gLogEntries .gInfo,
+#gLogEntries .gSuccess {
+ background-color: #fff;
+}
+
/* Inline layout (forms, lists) ~~~~~~~~~~ */
.gShortForm li {
View
2 themes/wind/css/screen.css
@@ -449,8 +449,6 @@ form .gError,
border: 1px solid #fff;
float: left;
font-size: .7em;
- height: 220px;
- overflow: hidden;
padding: .6em 8px;
position: relative;
text-align: center;
View
4 themes/wind/js/ui.init.js
@@ -59,8 +59,8 @@ $(document).ready(function() {
// Album view only
if ($("#gAlbumGrid").length) {
- // Vertical align thumbnails/metadata in album grid
- $(".gItem").gallery_valign();
+ // Set equal height for album items and vertically align thumbnails/metadata
+ $('.gItem').equal_heights().gallery_valign();
// Initialize thumbnail hover effect
$(".gItem").hover(

0 comments on commit 15422e4

Please sign in to comment.
Something went wrong with that request. Please try again.