From b79129e3651a92250b61a501b8c6a1d53bf4928c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 23 Sep 2009 12:02:35 -0700 Subject: Clone the photo::get_edit_form to the movies helper and use it to generate the movie edit form. Fixes ticket #726. --- modules/gallery/helpers/album.php | 5 +++-- modules/gallery/helpers/gallery.php | 19 ++++++++++++++++--- modules/gallery/helpers/movie.php | 30 ++++++++++++++++++++++++++++++ modules/gallery/helpers/photo.php | 5 +++-- 4 files changed, 52 insertions(+), 7 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 9cd746d7..3c62e41e 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -123,14 +123,15 @@ class album_Core { 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 amovie, 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", diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 80ae65bd..91dd2073 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -114,19 +114,32 @@ class gallery_Core { } } + 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") diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 59bf5c19..6c8c6c88 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -128,6 +128,36 @@ class movie_Core { return $movie; } + static function get_edit_form($movie) { + $form = new Forge("movies/$movie->id", "", "post", array("id" => "gEditMovieForm")); + $form->hidden("_method")->value("put"); + $group = $form->group("edit_item")->label(t("Edit Movie")); + $group->input("title")->label(t("Title"))->value($movie->title); + $group->textarea("description")->label(t("Description"))->value($movie->description); + $group->input("filename")->label(t("Filename"))->value($movie->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 movie name can't contain a \"/\"")) + ->callback("item::validate_no_trailing_period") + ->error_messages("no_trailing_period", t("The movie name can't end in \".\"")); + $group->input("slug")->label(t("Internet Address"))->value($movie->slug) + ->callback("item::validate_url_safe") + ->error_messages( + "slug_conflict", t("There is already a movie, photo or album with this internet address")) + ->error_messages( + "not_url_safe", + t("The internet address should contain only letters, numbers, hyphens and underscores")); + + module::event("item_edit_form", $movie, $form); + + $group = $form->group("buttons")->label(""); + $group->submit("")->value(t("Modify")); + $form->add_rules_from(ORM::factory("item")); + return $form; + } + + static function getmoviesize($filename) { $ffmpeg = self::find_ffmpeg(); if (empty($ffmpeg)) { diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index 3d9fbe69..065d2d31 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -163,7 +163,8 @@ class photo_Core { $group->input("title")->label(t("Title"))->value($photo->title); $group->textarea("description")->label(t("Description"))->value($photo->description); $group->input("filename")->label(t("Filename"))->value($photo->name) - ->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 photo name can't contain a \"/\"")) ->callback("item::validate_no_trailing_period") @@ -171,7 +172,7 @@ class photo_Core { $group->input("slug")->label(t("Internet Address"))->value($photo->slug) ->callback("item::validate_url_safe") ->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")) ->error_messages( "not_url_safe", t("The internet address should contain only letters, numbers, hyphens and underscores")); -- cgit v1.2.3 From fed41eae6cdaa83ac65a8565526cb76ced9b2783 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 23 Sep 2009 12:04:26 -0700 Subject: Fix a typo --- modules/gallery/helpers/album.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 3c62e41e..65868cf2 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -124,7 +124,7 @@ class album_Core { $group->input("dirname")->label(t("Directory Name"))->value($parent->name) ->rules("required") ->error_messages( - "name_conflict", t("There is already amovie, photo or album with this name")) + "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") -- cgit v1.2.3 From b038e9cbb4d913088a26f8c4e6e4699de9c860d7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 23 Sep 2009 17:03:25 -0700 Subject: set the version number to 13, so we will update the default themes in the gallery vars --- modules/gallery/helpers/gallery_installer.php | 11 +++++++++++ modules/gallery/module.info | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 6500482b..6ea1b227 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -364,6 +364,17 @@ class gallery_installer { $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() { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 70bd91e2..65a0691c 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 12 +version = 13 -- cgit v1.2.3 From 8bab030883647ffaf0e0bd4d172261159d19dd08 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 23 Sep 2009 19:45:23 -0700 Subject: Add a new api method gallery::find_file. This wraps the Kohana::find_file function, but allows the extension to supplied as part of the filename. Changed the Edit permission dialog to use the new api method to locate the icons from the active theme. --- modules/gallery/helpers/gallery.php | 14 +++++++++++ modules/gallery/views/permissions_form.html.php | 33 +++++++++++++------------ 2 files changed, 31 insertions(+), 16 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 91dd2073..d4f733e4 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -79,6 +79,20 @@ class gallery_Core { 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") diff --git a/modules/gallery/views/permissions_form.html.php b/modules/gallery/views/permissions_form.html.php index a0bb35f2..f5639439 100644 --- a/modules/gallery/views/permissions_form.html.php +++ b/modules/gallery/views/permissions_form.html.php @@ -1,7 +1,6 @@
- @@ -12,7 +11,8 @@ - + name, $item) ?> name, $item) ?> @@ -20,33 +20,34 @@ @@ -55,30 +56,30 @@ -- cgit v1.2.3 From 054a8dedac11ffbaa030fdc178031e5f975bbbdf Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 24 Sep 2009 10:28:02 -0700 Subject: Oops, forgot to change the install version number to match the upgrade version number --- modules/gallery/helpers/gallery_installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 6ea1b227..cf13d794 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -268,7 +268,7 @@ class gallery_installer { 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 Gallery %version"); - module::set_version("gallery", 12); + module::set_version("gallery", 13); } static function upgrade($version) { -- cgit v1.2.3 From 8e16cee2c3b7df19354af366f212ce52a2a7b5c8 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 24 Sep 2009 14:24:43 -0700 Subject: Forgot to change the defaults theme names on initial install... Duh --- modules/gallery/helpers/gallery_installer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index cf13d794..ee605b27 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -224,8 +224,8 @@ class gallery_installer { $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); -- cgit v1.2.3 From 970158f4d9904d00319c3da421024c68777a855d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 24 Sep 2009 16:59:33 -0700 Subject: Fix unit tests by updating the xss golden file and declaring gallery_error::error_handler as static --- modules/gallery/helpers/gallery_error.php | 2 +- modules/gallery/tests/xss_data.txt | 176 +++++++++++++++--------------- 2 files changed, 89 insertions(+), 89 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_error.php b/modules/gallery/helpers/gallery_error.php index 91e05407..39568c93 100644 --- a/modules/gallery/helpers/gallery_error.php +++ b/modules/gallery/helpers/gallery_error.php @@ -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; } diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index f3c90e18..7d3cf362 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -148,31 +148,31 @@ modules/gallery/views/permissions_browse.html.php 44 DIRTY_JS $paren modules/gallery/views/permissions_browse.html.php 52 DIRTY_ATTR $item->id modules/gallery/views/permissions_browse.html.php 53 DIRTY_JS $item->id modules/gallery/views/permissions_browse.html.php 60 DIRTY $form -modules/gallery/views/permissions_form.html.php 24 DIRTY_JS $lock->id -modules/gallery/views/permissions_form.html.php 32 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 32 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 32 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 36 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 36 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 36 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 43 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 43 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 43 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 47 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 47 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 47 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 56 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 56 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 56 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 63 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 63 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 63 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 74 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 74 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 74 DIRTY_JS $item->id -modules/gallery/views/permissions_form.html.php 79 DIRTY_JS $group->id -modules/gallery/views/permissions_form.html.php 79 DIRTY_JS $permission->id -modules/gallery/views/permissions_form.html.php 79 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 26 DIRTY_JS $lock->id +modules/gallery/views/permissions_form.html.php 34 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 34 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 34 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 37 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 37 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 37 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 44 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 44 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 44 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 48 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 48 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 48 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 57 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 57 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 57 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 64 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 64 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 64 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 75 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 75 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 75 DIRTY_JS $item->id +modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $group->id +modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $permission->id +modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $item->id modules/gallery/views/upgrader.html.php 44 DIRTY_ATTR $module->version==$module->code_version?"current":"upgradeable" modules/gallery/views/upgrader.html.php 45 DIRTY_ATTR $id modules/gallery/views/upgrader.html.php 49 DIRTY $module->version @@ -251,8 +251,8 @@ modules/search/views/search.html.php 31 DIRTY_JS $item- modules/search/views/search.html.php 32 DIRTY $item->thumb_img() modules/server_add/views/admin_server_add.html.php 15 DIRTY_ATTR $id modules/server_add/views/admin_server_add.html.php 24 DIRTY $form -modules/server_add/views/server_add_tree.html.php 12 DIRTY_JS html::js_string($dir) modules/server_add/views/server_add_tree.html.php 20 DIRTY_ATTR is_dir($file)?"ui-icon-folder-collapsed":"ui-icon-document" +modules/server_add/views/server_add_tree.html.php 21 DIRTY_ATTR is_dir($file)?"gDirectory":"gFile" modules/server_add/views/server_add_tree_dialog.html.php 3 DIRTY_JS url::site("server_add/children?path=__PATH__") modules/server_add/views/server_add_tree_dialog.html.php 4 DIRTY_JS url::site("server_add/start?item_id={$item->id}&csrf=$csrf") modules/server_add/views/server_add_tree_dialog.html.php 23 DIRTY $tree @@ -283,65 +283,65 @@ modules/user/views/user_languages_block.html.php 2 DIRTY form:: modules/watermark/views/admin_watermarks.html.php 19 DIRTY_ATTR $width modules/watermark/views/admin_watermarks.html.php 19 DIRTY_ATTR $height modules/watermark/views/admin_watermarks.html.php 19 DIRTY_ATTR $url -themes/admin_wind/views/admin.html.php 15 DIRTY_JS $theme->url() -themes/admin_wind/views/admin.html.php 32 DIRTY $theme->admin_head() -themes/admin_wind/views/admin.html.php 36 DIRTY $theme->admin_page_top() -themes/admin_wind/views/admin.html.php 44 DIRTY $theme->admin_header_top() -themes/admin_wind/views/admin.html.php 49 DIRTY_JS item::root()->url() -themes/admin_wind/views/admin.html.php 53 DIRTY $theme->admin_menu() -themes/admin_wind/views/admin.html.php 55 DIRTY $theme->admin_header_bottom() -themes/admin_wind/views/admin.html.php 62 DIRTY $content -themes/admin_wind/views/admin.html.php 68 DIRTY $sidebar -themes/admin_wind/views/admin.html.php 73 DIRTY $theme->admin_footer() -themes/admin_wind/views/admin.html.php 75 DIRTY $theme->admin_credits() -themes/admin_wind/views/admin.html.php 79 DIRTY $theme->admin_page_bottom() -themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor -themes/admin_wind/views/block.html.php 5 DIRTY $id -themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id -themes/admin_wind/views/block.html.php 13 DIRTY $title -themes/admin_wind/views/block.html.php 16 DIRTY $content -themes/admin_wind/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) -themes/admin_wind/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) -themes/admin_wind/views/pager.html.php 27 DIRTY $from_to_msg -themes/admin_wind/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) -themes/admin_wind/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) -themes/wind/views/album.html.php 16 DIRTY_ATTR $child->id -themes/wind/views/album.html.php 16 DIRTY_ATTR $item_class -themes/wind/views/album.html.php 18 DIRTY_JS $child->url() -themes/wind/views/album.html.php 19 DIRTY $child->thumb_img(array("class"=>"gThumbnail")) -themes/wind/views/album.html.php 23 DIRTY_JS $child->url() -themes/wind/views/block.html.php 3 DIRTY_ATTR $anchor -themes/wind/views/block.html.php 5 DIRTY_ATTR $css_id -themes/wind/views/block.html.php 6 DIRTY $title -themes/wind/views/block.html.php 8 DIRTY $content -themes/wind/views/dynamic.html.php 11 DIRTY_ATTR $child->is_album()?"gAlbum":"" -themes/wind/views/dynamic.html.php 13 DIRTY_JS $child->url() -themes/wind/views/dynamic.html.php 14 DIRTY_ATTR $child->id -themes/wind/views/dynamic.html.php 15 DIRTY_ATTR $child->thumb_url() -themes/wind/views/dynamic.html.php 16 DIRTY_ATTR $child->thumb_width -themes/wind/views/dynamic.html.php 17 DIRTY_ATTR $child->thumb_height -themes/wind/views/movie.html.php 8 DIRTY_JS $previous_item->url() -themes/wind/views/movie.html.php 18 DIRTY_JS $next_item->url() -themes/wind/views/movie.html.php 28 DIRTY $item->movie_img(array("class"=>"gMovie","id"=>"gMovieId-{$item->id}")) -themes/wind/views/page.html.php 9 DIRTY $page_title -themes/wind/views/page.html.php 32 DIRTY_JS $theme->url() -themes/wind/views/page.html.php 41 DIRTY $new_width -themes/wind/views/page.html.php 42 DIRTY $new_height -themes/wind/views/page.html.php 43 DIRTY $thumb_proportion -themes/wind/views/page.html.php 82 DIRTY $header_text -themes/wind/views/page.html.php 84 DIRTY_JS item::root()->url() -themes/wind/views/page.html.php 102 DIRTY_JS $parent->url($parent==$theme->item()->parent()?"show={$theme->item()->id}":null) -themes/wind/views/page.html.php 117 DIRTY $content -themes/wind/views/page.html.php 123 DIRTY newView("sidebar.html") -themes/wind/views/page.html.php 130 DIRTY $footer_text -themes/wind/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) -themes/wind/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) -themes/wind/views/pager.html.php 27 DIRTY $from_to_msg -themes/wind/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) -themes/wind/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) -themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->width -themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->height -themes/wind/views/photo.html.php 21 DIRTY_JS $previous_item->url() -themes/wind/views/photo.html.php 31 DIRTY_JS $next_item->url() -themes/wind/views/photo.html.php 43 DIRTY_JS $item->file_url() -themes/wind/views/photo.html.php 45 DIRTY $item->resize_img(array("id"=>"gPhotoId-{$item->id}","class"=>"gResize")) +themes/admin_wind/views/admin.html.php 15 DIRTY_JS $theme->url() +themes/admin_wind/views/admin.html.php 32 DIRTY $theme->admin_head() +themes/admin_wind/views/admin.html.php 36 DIRTY $theme->admin_page_top() +themes/admin_wind/views/admin.html.php 44 DIRTY $theme->admin_header_top() +themes/admin_wind/views/admin.html.php 49 DIRTY_JS item::root()->url() +themes/admin_wind/views/admin.html.php 53 DIRTY $theme->admin_menu() +themes/admin_wind/views/admin.html.php 55 DIRTY $theme->admin_header_bottom() +themes/admin_wind/views/admin.html.php 62 DIRTY $content +themes/admin_wind/views/admin.html.php 68 DIRTY $sidebar +themes/admin_wind/views/admin.html.php 73 DIRTY $theme->admin_footer() +themes/admin_wind/views/admin.html.php 75 DIRTY $theme->admin_credits() +themes/admin_wind/views/admin.html.php 79 DIRTY $theme->admin_page_bottom() +themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor +themes/admin_wind/views/block.html.php 5 DIRTY $id +themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id +themes/admin_wind/views/block.html.php 13 DIRTY $title +themes/admin_wind/views/block.html.php 16 DIRTY $content +themes/admin_wind/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) +themes/admin_wind/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) +themes/admin_wind/views/pager.html.php 27 DIRTY $from_to_msg +themes/admin_wind/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) +themes/admin_wind/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) +themes/wind/views/album.html.php 16 DIRTY_ATTR $child->id +themes/wind/views/album.html.php 16 DIRTY_ATTR $item_class +themes/wind/views/album.html.php 18 DIRTY_JS $child->url() +themes/wind/views/album.html.php 19 DIRTY $child->thumb_img(array("class"=>"gThumbnail")) +themes/wind/views/album.html.php 23 DIRTY_JS $child->url() +themes/wind/views/block.html.php 3 DIRTY_ATTR $anchor +themes/wind/views/block.html.php 5 DIRTY_ATTR $css_id +themes/wind/views/block.html.php 6 DIRTY $title +themes/wind/views/block.html.php 8 DIRTY $content +themes/wind/views/dynamic.html.php 11 DIRTY_ATTR $child->is_album()?"gAlbum":"" +themes/wind/views/dynamic.html.php 13 DIRTY_JS $child->url() +themes/wind/views/dynamic.html.php 14 DIRTY_ATTR $child->id +themes/wind/views/dynamic.html.php 15 DIRTY_ATTR $child->thumb_url() +themes/wind/views/dynamic.html.php 16 DIRTY_ATTR $child->thumb_width +themes/wind/views/dynamic.html.php 17 DIRTY_ATTR $child->thumb_height +themes/wind/views/movie.html.php 8 DIRTY_JS $previous_item->url() +themes/wind/views/movie.html.php 18 DIRTY_JS $next_item->url() +themes/wind/views/movie.html.php 28 DIRTY $item->movie_img(array("class"=>"gMovie","id"=>"gMovieId-{$item->id}")) +themes/wind/views/page.html.php 9 DIRTY $page_title +themes/wind/views/page.html.php 32 DIRTY_JS $theme->url() +themes/wind/views/page.html.php 41 DIRTY $new_width +themes/wind/views/page.html.php 42 DIRTY $new_height +themes/wind/views/page.html.php 43 DIRTY $thumb_proportion +themes/wind/views/page.html.php 82 DIRTY $header_text +themes/wind/views/page.html.php 84 DIRTY_JS item::root()->url() +themes/wind/views/page.html.php 102 DIRTY_JS $parent->url($parent==$theme->item()->parent()?"show={$theme->item()->id}":null) +themes/wind/views/page.html.php 117 DIRTY $content +themes/wind/views/page.html.php 123 DIRTY newView("sidebar.html") +themes/wind/views/page.html.php 130 DIRTY $footer_text +themes/wind/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) +themes/wind/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) +themes/wind/views/pager.html.php 27 DIRTY $from_to_msg +themes/wind/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) +themes/wind/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) +themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->width +themes/wind/views/photo.html.php 8 DIRTY_JS $theme->item()->height +themes/wind/views/photo.html.php 21 DIRTY_JS $previous_item->url() +themes/wind/views/photo.html.php 31 DIRTY_JS $next_item->url() +themes/wind/views/photo.html.php 43 DIRTY_JS $item->file_url() +themes/wind/views/photo.html.php 45 DIRTY $item->resize_img(array("id"=>"gPhotoId-{$item->id}","class"=>"gResize")) -- cgit v1.2.3 From cd240ebaada9ddff112a40a5f80201f23449337e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 24 Sep 2009 20:06:14 -0700 Subject: Refactored the rebuild_dirty_images handler to simplify the counting and end processing. It was getting all confused with trying to figure out the completed and remaining. Now on initiation it sets the total images that are dirty and then counts the completed until it equals the total, then exits. Fixes ticket #771 --- modules/gallery/helpers/gallery_task.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 1b56ab97..3d0476a8 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -48,9 +48,13 @@ class gallery_task_Core { $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 @@ class gallery_task_Core { 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 @@ class gallery_task_Core { $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"); -- cgit v1.2.3 From e204e18b3c6a4b4b1aa76b6d4a5392bd238490eb Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 24 Sep 2009 20:28:26 -0700 Subject: Refactor the graphic rules processing to accomplish 2 goals: First separate the grapics library from module supplied rules and secondly, allow for modules to provide new processing rules callbacks. graphics::generate will now look for _graphics:: methods. --- modules/gallery/helpers/gallery_graphics.php | 54 ++++++++++++++ modules/gallery/helpers/graphics.php | 95 +----------------------- modules/watermark/helpers/watermark_graphics.php | 75 +++++++++++++++++++ 3 files changed, 133 insertions(+), 91 deletions(-) create mode 100644 modules/gallery/helpers/gallery_graphics.php create mode 100644 modules/watermark/helpers/watermark_graphics.php (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/gallery_graphics.php b/modules/gallery/helpers/gallery_graphics.php new file mode 100644 index 00000000..f62fbf97 --- /dev/null +++ b/modules/gallery/helpers/gallery_graphics.php @@ -0,0 +1,54 @@ +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); + } +} diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 78812794..6705652f 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -152,7 +152,7 @@ class graphics_Core { ->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; } } @@ -180,42 +180,6 @@ class 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) { - 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 * @@ -238,60 +202,6 @@ class graphics_Core { module::event("graphics_rotate_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) { - 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 @@ class graphics_Core { * 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"); diff --git a/modules/watermark/helpers/watermark_graphics.php b/modules/watermark/helpers/watermark_graphics.php new file mode 100644 index 00000000..aef7586b --- /dev/null +++ b/modules/watermark/helpers/watermark_graphics.php @@ -0,0 +1,75 @@ +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()); + } + } +} -- cgit v1.2.3
display_name) ?> display_name) ?> + - <?= t('denied icon')->for_html_attr() ?> + " + title="for_html_attr() ?>" + alt="for_html_attr() ?>" /> - <?= t('locked icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" /> - - <?= t('passive allowed icon')->for_html_attr() ?> + + " alt="for_html_attr() ?>" /> - <?= t('inactive denied icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" /> - <?= t('inactive allowed icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" /> - <?= t('passive denied icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" /> - <?= t('inactive allowed icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" /> id == 1): ?> - <?= t('denied icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" title="for_html_attr() ?>"/> - <?= t('denied icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" /> id == 1): ?> - for_html_attr() ?>" alt="for_html_attr() ?>" /> + " title="for_html_attr() ?>" alt="for_html_attr() ?>" /> - <?= t('allowed icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" /> - <?= t('inactive denied icon')->for_html_attr() ?> + " alt="for_html_attr() ?>" />