diff options
Diffstat (limited to 'modules/gallery')
42 files changed, 1550 insertions, 709 deletions
diff --git a/modules/gallery/config/cache.php b/modules/gallery/config/cache.php new file mode 100644 index 00000000..cc3ac87d --- /dev/null +++ b/modules/gallery/config/cache.php @@ -0,0 +1,49 @@ +<?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. + */ +/* + * @package Cache + * + * Cache settings, defined as arrays, or "groups". If no group name is + * used when loading the cache library, the group named "default" will be used. + * + * Each group can be used independently, and multiple groups can be used at once. + * + * Group Options: + * driver - Cache backend driver. Kohana comes with file, database, and memcache drivers. + * > File cache is fast and reliable, but requires many filesystem lookups. + * > Database cache can be used to cache items remotely, but is slower. + * > Memcache is very high performance, but prevents cache tags from being used. + * + * params - Driver parameters, specific to each driver. + * + * lifetime - Default lifetime of caches in seconds. By default caches are stored for + * thirty minutes. Specific lifetime can also be set when creating a new cache. + * Setting this to 0 will never automatically delete caches. + * + * requests - Average number of cache requests that will processed before all expired + * caches are deleted. This is commonly referred to as "garbage collection". + * Setting this to 0 or a negative number will disable automatic garbage collection. + */ +$config["default"] = array ( + "driver" => "database", + "params" => null, + "lifetime" => 84600, + "requests" => 1000 +); diff --git a/modules/gallery/controllers/admin_modules.php b/modules/gallery/controllers/admin_modules.php index f7dd909d..ed1f7665 100644 --- a/modules/gallery/controllers/admin_modules.php +++ b/modules/gallery/controllers/admin_modules.php @@ -45,7 +45,11 @@ class Admin_Modules_Controller extends Admin_Controller { } else if (!$info->active && $desired && !module::is_active($module_name)) { $changes->activate[] = $module_name; $activated_names[] = $info->name; - module::install($module_name); + if (module::is_installed($module_name)) { + module::upgrade($module_name); + } else { + module::install($module_name); + } module::activate($module_name); } } diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 2716ed93..8970c3c9 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -56,6 +56,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::set_var("gallery", "header_text", $form->edit_theme->header_text->value); module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); + module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); message::success(t("Updated theme details")); url::redirect("admin/theme_options"); diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 856709c2..22f50fb8 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -26,7 +26,7 @@ class Albums_Controller extends Items_Controller { $page_size = module::get_var("gallery", "page_size", 9); if (!access::can("view", $album)) { if ($album->id == 1) { - $view = new Theme_View("page.html", "page"); + $view = new Theme_View("page.html", "login"); $view->page_title = t("Log in to Gallery"); $view->content = user::get_login_form("login/auth_html"); print $view; @@ -167,7 +167,8 @@ class Albums_Controller extends Items_Controller { $form = album::get_edit_form($album); if ($valid = $form->validate()) { // Make sure that there's not a conflict - if (Database::instance() + if ($album->id != 1 && + Database::instance() ->from("items") ->where("parent_id", $album->parent_id) ->where("id <>", $album->id) @@ -188,7 +189,9 @@ class Albums_Controller extends Items_Controller { $album->description = $form->edit_album->description->value; $album->sort_column = $form->edit_album->sort_order->column->value; $album->sort_order = $form->edit_album->sort_order->direction->value; - $album->rename($form->edit_album->dirname->value); + if ($album->id != 1) { + $album->rename($form->edit_album->dirname->value); + } $album->save(); module::event("item_updated", $orig, $album); diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php new file mode 100644 index 00000000..510482db --- /dev/null +++ b/modules/gallery/controllers/combined.php @@ -0,0 +1,62 @@ +<?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 Combined_Controller extends Controller { + public function javascript($key) { + if (preg_match('/[^0-9a-f]/', $key)) { + // The key can't contain non-hex, so just terminate early + Kohana::show_404(); + } + + // We don't need to save the session for this request + Session::abort_save(); + + // Our data is immutable, so if they already have a copy then it needs no updating. + if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { + header('HTTP/1.0 304 Not Modified'); + return; + } + + $cache = Cache::instance(); + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { + $content = $cache->get("{$key}_gz"); + } + + if (empty($content)) { + $content = $cache->get($key); + } + + if (empty($content)) { + Kohana::show_404(); + } + + if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) { + header("Content-Encoding: gzip"); + header("Cache-Control: public"); + } + + header("Content-Type: text/javascript; charset=UTF-8"); + header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); + + Kohana::close_buffers(false); + print $content; + } +} + diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 1f885e53..0d64bcd9 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -112,6 +112,9 @@ class File_Proxy_Controller extends Controller { kohana::show_404(); } + // We don't need to save the session for this request + Session::abort_save(); + // Dump out the image header("Content-Type: $item->mime_type"); Kohana::close_buffers(false); diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php index aa93a758..831c79c1 100644 --- a/modules/gallery/controllers/l10n_client.php +++ b/modules/gallery/controllers/l10n_client.php @@ -106,7 +106,19 @@ class L10n_Client_Controller extends Controller { } public static function l10n_form() { - $calls = I18n::instance()->call_log(); + if (Input::instance()->get("show_all_l10n_messages")) { + $calls = array(); + foreach (Database::instance() + ->select("key", "message") + ->from("incoming_translations") + ->where(array("locale" => 'root')) + ->get() + ->as_array() as $row) { + $calls[$row->key] = array(unserialize($row->message), array()); + } + } else { + $calls = I18n::instance()->call_log(); + } $locale = I18n::instance()->locale(); if ($calls) { diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 86b0f177..d8cca825 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -44,7 +44,7 @@ class Movies_Controller extends Items_Controller { ->where("id <=", $photo->id) ->count_all(); - $template = new Theme_View("page.html", "photo"); + $template = new Theme_View("page.html", "movie"); $template->set_global("item", $photo); $template->set_global("children", array()); $template->set_global("children_count", $photo->children_count()); diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index cff6686b..e89d9701 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -25,8 +25,10 @@ class Quick_Controller extends Controller { } $view = new View("quick_pane.html"); + $page_type = Input::instance()->get("page_type"); + $view->button_list = gallery_quick::get_quick_buttons($item, $page_type); $view->item = $item; - $view->page_type = Input::instance()->get("page_type"); + $view->page_type = $page_type; print $view; } diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index dfbd4f17..e68df2b8 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -39,7 +39,8 @@ class Simple_Uploader_Controller extends Controller { access::verify_csrf(); $file_validation = new Validation($_FILES); - $file_validation->add_rules("Filedata", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]"); + $file_validation->add_rules( + "Filedata", "upload::valid", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); if ($file_validation->validate()) { // SimpleUploader.swf does not yet call /start directly, so simulate it here for now. if (!batch::in_progress()) { diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php index 5eb96fdd..91952fa9 100644 --- a/modules/gallery/controllers/upgrader.php +++ b/modules/gallery/controllers/upgrader.php @@ -50,8 +50,8 @@ class Upgrader_Controller extends Controller { } // Upgrade gallery and user first - module::install("gallery"); - module::install("user"); + module::upgrade("gallery"); + module::upgrade("user"); // Then upgrade the rest foreach (module::available() as $id => $module) { @@ -60,7 +60,7 @@ class Upgrader_Controller extends Controller { } if ($module->active && $module->code_version != $module->version) { - module::install($id); + module::upgrade($id); } } diff --git a/modules/gallery/css/l10n_client.css b/modules/gallery/css/l10n_client.css index bab1d0ed..ecec859d 100644 --- a/modules/gallery/css/l10n_client.css +++ b/modules/gallery/css/l10n_client.css @@ -5,8 +5,8 @@ /* $Id: l10n_client.css,v 1.6 2008/09/09 10:48:20 goba Exp $ */ /* width percentages add to 99% rather than 100% to prevent float -overflows from occurring in an unnamed browser that can't decide -how it wants to round. */ + overflows from occurring in an unnamed browser that can't decide + how it wants to round. */ /* l10n_client container */ #l10n-client { @@ -19,8 +19,8 @@ how it wants to round. */ bottom:0px; left:0px; overflow:hidden;} - * html #l10n-client { - position:static;} +* html #l10n-client { + position:static;} #l10n-client-string-select .string-list, #l10n-client-string-editor .source, @@ -34,38 +34,38 @@ how it wants to round. */ color:#fff; background:#37a;} - #l10n-client .labels .label { - display:none;} +#l10n-client .labels .label { + display:none;} - /* Panel toggle button (span) */ - #l10n-client .labels .toggle { - cursor:pointer; - display:block; - position:absolute; right:0em; - padding: 0em .75em; height:2em; line-height:2em; - text-transform:uppercase; - text-align:center; background:#000;} +/* Panel toggle button (span) */ +#l10n-client .labels .toggle { + cursor:pointer; + display:block; + position:absolute; right:0em; + padding: 0em .75em; height:2em; line-height:2em; + text-transform:uppercase; + text-align:center; background:#000;} - /* Panel labels */ - #l10n-client h2 { - border-left:1px solid #fff; - height:1em; line-height:1em; - padding: .5em; margin:0px; - font-size:1em; - text-transform:uppercase;} +/* Panel labels */ +#l10n-client h2 { + border-left:1px solid #fff; + height:1em; line-height:1em; + padding: .5em; margin:0px; + font-size:1em; + text-transform:uppercase;} - #l10n-client .strings h2 { - border:0px;} +#l10n-client .strings h2 { + border:0px;} - /* 25 + 37 + 37 = 99 */ - #l10n-client .strings { - width:25%; float:left;} +/* 25 + 37 + 37 = 99 */ +#l10n-client .strings { + width:25%; float:left;} - #l10n-client .source { - width:37%; float:left;} +#l10n-client .source { + width:37%; float:left;} - #l10n-client .translation { - width:37%; float:left;} +#l10n-client .translation { + width:37%; float:left;} /* Translatable string list */ #l10n-client-string-select { @@ -75,77 +75,77 @@ how it wants to round. */ direction: ltr; } - #l10n-client .string-list { - height:17em; - overflow:auto; - list-style:none; list-style-image:none; - margin:0em; padding:0em;} +#l10n-client .string-list { + height:17em; + overflow:auto; + list-style:none; list-style-image:none; + margin:0em; padding:0em;} - #l10n-client .string-list li { - font-size:.9em; - line-height:1.5em; - cursor:default; - background:transparent; - list-style:none; list-style-image:none; - border-bottom:1px solid #ddd; - padding:.25em .5em; - margin:0em;} +#l10n-client .string-list li { + font-size:.9em; + line-height:1.5em; + cursor:default; + background:transparent; + list-style:none; list-style-image:none; + border-bottom:1px solid #ddd; + padding:.25em .5em; + margin:0em;} - /* Green for translated */ - #l10n-client .string-list li.translated { - border-bottom-color:#9c3; - background:#cf6; color:#360;} +/* Green for translated */ +#l10n-client .string-list li.translated { + border-bottom-color:#9c3; + background:#cf6; color:#360;} - #l10n-client .string-list li.translated:hover { - background: #df8;} +#l10n-client .string-list li.translated:hover { + background: #df8;} - #l10n-client .string-list li.translated:active { - background: #9c3;} +#l10n-client .string-list li.translated:active { + background: #9c3;} - #l10n-client .string-list li.hidden { - display:none;} +#l10n-client .string-list li.hidden { + display:none;} - /* Gray + Blue hover for untranslated */ - #l10n-client .string-list li.untranslated {} +/* Gray + Blue hover for untranslated */ +#l10n-client .string-list li.untranslated {} - #l10n-client .string-list li.untranslated:hover { - background: #ace;} +#l10n-client .string-list li.untranslated:hover { + background: #ace;} - #l10n-client .string-list li.untranslated:active { - background: #8ac;} +#l10n-client .string-list li.untranslated:active { + background: #8ac;} - /* Selected string is indicated by bold text */ - #l10n-client .string-list li.active { - font-weight:bold;} +/* Selected string is indicated by bold text */ +#l10n-client .string-list li.active { + font-weight:bold;} - #l10n-client #gL10nSearchForm { - background:#eee; - text-align:center; - height:2em; line-height:2em; - margin:0em; padding:.5em .5em; - } +#l10n-client #gL10nSearchForm { + background:#eee; + text-align:center; + height:2em; line-height:2em; + margin:0em; padding:.5em .5em; +} - #l10n-client #gL10nSearchForm .form-item, - #l10n-client #gL10nSearchForm input.form-text, - #l10n-client #gL10nSearchForm #search-filter-go, - #l10n-client #gL10nSearchForm #search-filter-clear { - display:inline; - vertical-align:middle; - } +#l10n-client #gL10nSearchForm .form-item, +#l10n-client #gL10nSearchForm input.form-text, +#l10n-client #gL10nSearchForm #search-filter-go, +#l10n-client #gL10nSearchForm #search-filter-clear { + display:inline; + vertical-align:middle; +} - #l10n-client #gL10nSearchForm .form-item { - margin:0em; - padding:0em; - } +#l10n-client #gL10nSearchForm .form-item { + margin:0em; + padding:0em; +} - #l10n-client #gL10nSearchForm input.form-text { - width:80%; - } +#l10n-client #gL10nSearchForm input.form-text { + width:80%; +} - #l10n-client #gL10nSearchForm #search-filter-clear { - width:10%; - margin:0em; - } +#l10n-client #gL10nSearchForm #search-filter-clear { + width:10%; + margin:0em; +} #l10n-client-string-editor { display:none; @@ -153,22 +153,22 @@ how it wants to round. */ width:74%;} #l10n-client-string-editor .source { - overflow:hidden; - width:50%; float:left;} + overflow:hidden; + width:50%; float:left;} #l10n-client-string-editor .source .source-text { - line-height:1.5em; - background:#eee; - font-family: monospace; - text-align: left; - height:16em; margin:1em; padding:1em; - overflow:auto; - direction: ltr; + line-height:1.5em; + background:#eee; + font-family: monospace; + text-align: left; + height:16em; margin:1em; padding:1em; + overflow:auto; + direction: ltr; } - #l10n-client-string-editor .translation { - overflow:hidden; - width:49%; float:right;} +#l10n-client-string-editor .translation { + overflow:hidden; + width:49%; float:right;} #gL10nClientSaveForm { padding:0em;} diff --git a/modules/gallery/css/upgrader.css b/modules/gallery/css/upgrader.css new file mode 100644 index 00000000..b877df49 --- /dev/null +++ b/modules/gallery/css/upgrader.css @@ -0,0 +1,117 @@ +body { + background: #eee; + font-family: Trebuchet MS; + font-size: 1.1em; +} + +h1 { + font-size: 1.4em; +} + +div#outer { + width: 650px; + background: white; + border: 1px solid #999; + margin: 0 auto; + padding: -10px; +} + +div#inner { + padding: 0 1em 0 1em; + margin: 0px; +} + +div#footer { + border-top: 1px solid #ccc; + margin: 1em; +} + +td.name { + text-align: left; + padding-left: 30px; +} + +td { + text-align: center; + border-bottom: 1px solid #eee; +} + +tr.current td { + color: #999; + font-style: italic; +} + +tr.current td.gallery { + color: #00d; +} + +tr.upgradeable td { + font-weight: bold; +} + +tr.upgradeable td.gallery { + color: #00d; +} + +table { + width: 600px; + margin-bottom: 10px; +} + +p { + font-size: .9em; +} + +ul { + font-size: .9em; + list-style: none; +} + +li { + display: inline; +} + +li:before { + content: "\00BB \0020"; +} + +div.button { + margin: 0 auto; + width: 120px; + text-align: center; + border: 1px solid #999; + background: #eee; +} + +div.button a { + text-decoration: none; +} + +div.button:hover { + background: #ccc; +} + +div#confirmation { + position: absolute; + background: blue; + z-index: 1000; + margin: 10px; + text-align: center; +} + +div#confirmation div { + margin: 2px; + padding: 20px; + border: 2px solid #999; + background: #eee; +} + +.gray_on_done { + opacity: <?= $done ? "0.5" : "1" ?>; +} + +pre { + display: inline; + margin: 0px; + padding: 0px; +} diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index 7bee70ca..c4967c52 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -58,7 +58,7 @@ class url extends url_Core { * Return the item that the uri is referencing */ static function get_item_from_uri($uri) { - $current_uri = html_entity_decode($uri); + $current_uri = html_entity_decode($uri, ENT_QUOTES); $item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find(); if (!$item->loaded) { // It's possible that the relative path cache for the item we're looking for is out of date, diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index c3837f54..a10f2bbf 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -49,8 +49,9 @@ class gallery_block_Core { $block->css_id = "gLogEntries"; $block->title = t("Log Entries"); $block->content = new View("admin_block_log_entries.html"); - $block->content->entries = ORM::factory("log")->orderby("timestamp", "DESC")->find_all(5); - break; + $block->content->entries = ORM::factory("log") + ->orderby(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5); + break; case "stats": $block->css_id = "gStats"; diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index b2be63be..0e5d29b9 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -18,248 +18,289 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class gallery_installer { - static function install($initial_install=false) { + static function install() { $db = Database::instance(); - if ($initial_install) { - $version = 0; - } else { - $version = module::get_version("gallery"); - } + $db->query("CREATE TABLE {access_caches} ( + `id` int(9) NOT NULL auto_increment, + `item_id` int(9), + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - if ($version == 0) { - $db->query("CREATE TABLE {access_caches} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9), - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {access_intents} ( + `id` int(9) NOT NULL auto_increment, + `item_id` int(9), + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {access_intents} ( - `id` int(9) NOT NULL auto_increment, - `item_id` int(9), - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {caches} ( + `id` int(9) NOT NULL auto_increment, + `key` varchar(255) NOT NULL, + `tags` varchar(255), + `expiration` int(9) NOT NULL, + `cache` longblob, + PRIMARY KEY (`id`), + KEY (`tags`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {graphics_rules} ( - `id` int(9) NOT NULL auto_increment, - `active` BOOLEAN default 0, - `args` varchar(255) default NULL, - `module_name` varchar(64) NOT NULL, - `operation` varchar(64) NOT NULL, - `priority` int(9) NOT NULL, - `target` varchar(32) NOT NULL, - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {graphics_rules} ( + `id` int(9) NOT NULL auto_increment, + `active` BOOLEAN default 0, + `args` varchar(255) default NULL, + `module_name` varchar(64) NOT NULL, + `operation` varchar(64) NOT NULL, + `priority` int(9) NOT NULL, + `target` varchar(32) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {items} ( - `id` int(9) NOT NULL auto_increment, - `album_cover_item_id` int(9) default NULL, - `captured` int(9) default NULL, - `created` int(9) default NULL, - `description` varchar(2048) default NULL, - `height` int(9) default NULL, - `left` int(9) NOT NULL, - `level` int(9) NOT NULL, - `mime_type` varchar(64) default NULL, - `name` varchar(255) default NULL, - `owner_id` int(9) default NULL, - `parent_id` int(9) NOT NULL, - `rand_key` float default NULL, - `relative_path_cache` varchar(255) default NULL, - `resize_dirty` boolean default 1, - `resize_height` int(9) default NULL, - `resize_width` int(9) default NULL, - `right` int(9) NOT NULL, - `sort_column` varchar(64) default NULL, - `sort_order` char(4) default 'ASC', - `thumb_dirty` boolean default 1, - `thumb_height` int(9) default NULL, - `thumb_width` int(9) default NULL, - `title` varchar(255) default NULL, - `type` varchar(32) NOT NULL, - `updated` int(9) default NULL, - `view_count` int(9) default 0, - `weight` int(9) NOT NULL default 0, - `width` int(9) default NULL, - PRIMARY KEY (`id`), - KEY `parent_id` (`parent_id`), - KEY `type` (`type`), - KEY `random` (`rand_key`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {incoming_translations} ( + `id` int(9) NOT NULL auto_increment, + `key` char(32) NOT NULL, + `locale` char(10) NOT NULL, + `message` text NOT NULL, + `revision` int(9) DEFAULT NULL, + `translation` text, + PRIMARY KEY (`id`), + UNIQUE KEY(`key`, `locale`), + KEY `locale_key` (`locale`, `key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {logs} ( - `id` int(9) NOT NULL auto_increment, - `category` varchar(64) default NULL, - `html` varchar(255) default NULL, - `message` text default NULL, - `referer` varchar(255) default NULL, - `severity` int(9) default 0, - `timestamp` int(9) default 0, - `url` varchar(255) default NULL, - `user_id` int(9) default 0, - PRIMARY KEY (`id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {items} ( + `id` int(9) NOT NULL auto_increment, + `album_cover_item_id` int(9) default NULL, + `captured` int(9) default NULL, + `created` int(9) default NULL, + `description` varchar(2048) default NULL, + `height` int(9) default NULL, + `left` int(9) NOT NULL, + `level` int(9) NOT NULL, + `mime_type` varchar(64) default NULL, + `name` varchar(255) default NULL, + `owner_id` int(9) default NULL, + `parent_id` int(9) NOT NULL, + `rand_key` float default NULL, + `relative_path_cache` varchar(255) default NULL, + `resize_dirty` boolean default 1, + `resize_height` int(9) default NULL, + `resize_width` int(9) default NULL, + `right` int(9) NOT NULL, + `sort_column` varchar(64) default NULL, + `sort_order` char(4) default 'ASC', + `thumb_dirty` boolean default 1, + `thumb_height` int(9) default NULL, + `thumb_width` int(9) default NULL, + `title` varchar(255) default NULL, + `type` varchar(32) NOT NULL, + `updated` int(9) default NULL, + `view_count` int(9) default 0, + `weight` int(9) NOT NULL default 0, + `width` int(9) default NULL, + PRIMARY KEY (`id`), + KEY `parent_id` (`parent_id`), + KEY `type` (`type`), + KEY `random` (`rand_key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {messages} ( - `id` int(9) NOT NULL auto_increment, - `key` varchar(255) default NULL, - `severity` varchar(32) default NULL, - `value` varchar(255) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`key`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {logs} ( + `id` int(9) NOT NULL auto_increment, + `category` varchar(64) default NULL, + `html` varchar(255) default NULL, + `message` text default NULL, + `referer` varchar(255) default NULL, + `severity` int(9) default 0, + `timestamp` int(9) default 0, + `url` varchar(255) default NULL, + `user_id` int(9) default 0, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {modules} ( - `id` int(9) NOT NULL auto_increment, - `active` BOOLEAN default 0, - `name` varchar(64) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {messages} ( + `id` int(9) NOT NULL auto_increment, + `key` varchar(255) default NULL, + `severity` varchar(32) default NULL, + `value` varchar(255) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {themes} ( - `id` int(9) NOT NULL auto_increment, - `name` varchar(64) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {modules} ( + `id` int(9) NOT NULL auto_increment, + `active` BOOLEAN default 0, + `name` varchar(64) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {permissions} ( - `id` int(9) NOT NULL auto_increment, - `display_name` varchar(64) default NULL, - `name` varchar(64) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {outgoing_translations} ( + `id` int(9) NOT NULL auto_increment, + `base_revision` int(9) DEFAULT NULL, + `key` char(32) NOT NULL, + `locale` char(10) NOT NULL, + `message` text NOT NULL, + `translation` text, + PRIMARY KEY (`id`), + UNIQUE KEY(`key`, `locale`), + KEY `locale_key` (`locale`, `key`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {incoming_translations} ( - `id` int(9) NOT NULL auto_increment, - `key` char(32) NOT NULL, - `locale` char(10) NOT NULL, - `message` text NOT NULL, - `revision` int(9) DEFAULT NULL, - `translation` text, - PRIMARY KEY (`id`), - UNIQUE KEY(`key`, `locale`), - KEY `locale_key` (`locale`, `key`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {permissions} ( + `id` int(9) NOT NULL auto_increment, + `display_name` varchar(64) default NULL, + `name` varchar(64) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {outgoing_translations} ( - `id` int(9) NOT NULL auto_increment, - `base_revision` int(9) DEFAULT NULL, - `key` char(32) NOT NULL, - `locale` char(10) NOT NULL, - `message` text NOT NULL, - `translation` text, - PRIMARY KEY (`id`), - UNIQUE KEY(`key`, `locale`), - KEY `locale_key` (`locale`, `key`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {sessions} ( + `session_id` varchar(127) NOT NULL, + `data` text NOT NULL, + `last_activity` int(10) UNSIGNED NOT NULL, + PRIMARY KEY (`session_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {sessions} ( - `session_id` varchar(127) NOT NULL, - `data` text NOT NULL, - `last_activity` int(10) UNSIGNED NOT NULL, - PRIMARY KEY (`session_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {tasks} ( + `id` int(9) NOT NULL auto_increment, + `callback` varchar(128) default NULL, + `context` text NOT NULL, + `done` boolean default 0, + `name` varchar(128) default NULL, + `owner_id` int(9) default NULL, + `percent_complete` int(9) default 0, + `state` varchar(32) default NULL, + `status` varchar(255) default NULL, + `updated` int(9) default NULL, + PRIMARY KEY (`id`), + KEY (`owner_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {tasks} ( - `id` int(9) NOT NULL auto_increment, - `callback` varchar(128) default NULL, - `context` text NOT NULL, - `done` boolean default 0, - `name` varchar(128) default NULL, - `owner_id` int(9) default NULL, - `percent_complete` int(9) default 0, - `state` varchar(32) default NULL, - `status` varchar(255) default NULL, - `updated` int(9) default NULL, - PRIMARY KEY (`id`), - KEY (`owner_id`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {themes} ( + `id` int(9) NOT NULL auto_increment, + `name` varchar(64) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - $db->query("CREATE TABLE {vars} ( - `id` int(9) NOT NULL auto_increment, - `module_name` varchar(64) NOT NULL, - `name` varchar(64) NOT NULL, - `value` text, - PRIMARY KEY (`id`), - UNIQUE KEY(`module_name`, `name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE {vars} ( + `id` int(9) NOT NULL auto_increment, + `module_name` varchar(64) NOT NULL, + `name` varchar(64) NOT NULL, + `value` text, + PRIMARY KEY (`id`), + UNIQUE KEY(`module_name`, `name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { - @mkdir(VARPATH . $dir); - } + foreach (array("albums", "logs", "modules", "resizes", "thumbs", "tmp", "uploads") as $dir) { + @mkdir(VARPATH . $dir); + } - access::register_permission("view", "View"); - access::register_permission("view_full", "View Full Size"); - access::register_permission("edit", "Edit"); - access::register_permission("add", "Add"); + access::register_permission("view", "View"); + access::register_permission("view_full", "View Full Size"); + access::register_permission("edit", "Edit"); + access::register_permission("add", "Add"); - $root = ORM::factory("item"); - $root->type = "album"; - $root->title = "Gallery"; - $root->description = ""; - $root->left = 1; - $root->right = 2; - $root->parent_id = 0; - $root->level = 1; - $root->thumb_dirty = 1; - $root->resize_dirty = 1; - $root->sort_column = "weight"; - $root->sort_order = "ASC"; - $root->save(); - access::add_item($root); + $root = ORM::factory("item"); + $root->type = "album"; + $root->title = "Gallery"; + $root->description = ""; + $root->left = 1; + $root->right = 2; + $root->parent_id = 0; + $root->level = 1; + $root->thumb_dirty = 1; + $root->resize_dirty = 1; + $root->sort_column = "weight"; + $root->sort_order = "ASC"; + $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", "page_size", 9); - module::set_var("gallery", "thumb_size", 200); - module::set_var("gallery", "resize_size", 640); - module::set_var("gallery", "default_locale", "en_US"); - module::set_var("gallery", "image_quality", 75); + module::set_var("gallery", "active_site_theme", "default"); + module::set_var("gallery", "active_admin_theme", "admin_default"); + module::set_var("gallery", "page_size", 9); + module::set_var("gallery", "thumb_size", 200); + module::set_var("gallery", "resize_size", 640); + module::set_var("gallery", "default_locale", "en_US"); + module::set_var("gallery", "image_quality", 75); - // Add rules for generating our thumbnails and resizes - graphics::add_rule( - "gallery", "thumb", "resize", - array("width" => 200, "height" => 200, "master" => Image::AUTO), - 100); - graphics::add_rule( - "gallery", "resize", "resize", - array("width" => 640, "height" => 480, "master" => Image::AUTO), - 100); + // Add rules for generating our thumbnails and resizes + graphics::add_rule( + "gallery", "thumb", "resize", + array("width" => 200, "height" => 200, "master" => Image::AUTO), + 100); + graphics::add_rule( + "gallery", "resize", "resize", + array("width" => 640, "height" => 480, "master" => Image::AUTO), + 100); - // Instantiate default themes (site and admin) - foreach (array("default", "admin_default") as $theme_name) { - $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), - ArrayObject::ARRAY_AS_PROPS); - $theme = ORM::factory("theme"); - $theme->name = $theme_name; - $theme->version = $theme_info->version; - $theme->save(); - } + // Instantiate default themes (site and admin) + foreach (array("default", "admin_default") as $theme_name) { + $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"), + ArrayObject::ARRAY_AS_PROPS); + $theme = ORM::factory("theme"); + $theme->name = $theme_name; + $theme->version = $theme_info->version; + $theme->save(); + } - block_manager::add("dashboard_sidebar", "gallery", "block_adder"); - block_manager::add("dashboard_sidebar", "gallery", "stats"); - block_manager::add("dashboard_sidebar", "gallery", "platform_info"); - block_manager::add("dashboard_sidebar", "gallery", "project_news"); - block_manager::add("dashboard_center", "gallery", "welcome"); - block_manager::add("dashboard_center", "gallery", "photo_stream"); - block_manager::add("dashboard_center", "gallery", "log_entries"); + block_manager::add("dashboard_sidebar", "gallery", "block_adder"); + block_manager::add("dashboard_sidebar", "gallery", "stats"); + block_manager::add("dashboard_sidebar", "gallery", "platform_info"); + block_manager::add("dashboard_sidebar", "gallery", "project_news"); + block_manager::add("dashboard_center", "gallery", "welcome"); + block_manager::add("dashboard_center", "gallery", "photo_stream"); + block_manager::add("dashboard_center", "gallery", "log_entries"); - module::set_version("gallery", 1); - module::set_var("gallery", "version", "3.0 beta 1"); - module::set_var("gallery", "choose_default_tookit", 1); + module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); + module::set_var("gallery", "choose_default_tookit", 1); + module::set_var("gallery", "date_format", "Y-M-d"); + module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); + module::set_var("gallery", "time_format", "H:i:s"); + 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", 6); + } - // @todo this string needs to be picked up by l10n_scanner - module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>"); - } else if ($version == 1) { + static function upgrade($version) { + $db = Database::instance(); + if ($version == 1) { module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); module::set_var("gallery", "time_format", "H:i:s"); module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); - module::set_version("gallery", 2); + module::set_version("gallery", $version = 2); + } + + if ($version == 2) { + module::set_var("gallery", "show_credits", 1); + module::set_version("gallery", $version = 3); + } + + if ($version == 3) { + $db->query("CREATE TABLE {caches} ( + `id` varchar(255) NOT NULL, + `tags` varchar(255), + `expiration` int(9) NOT NULL, + `cache` text, + PRIMARY KEY (`id`), + KEY (`tags`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + module::set_version("gallery", $version = 4); + } + + if ($version == 4) { + Cache::instance()->delete_all(); + $db->query("ALTER TABLE {caches} MODIFY COLUMN `cache` LONGBLOB"); + module::set_version("gallery", $version = 5); + } + + if ($version == 5) { + Cache::instance()->delete_all(); + $db->query("ALTER TABLE {caches} DROP COLUMN `id`"); + $db->query("ALTER TABLE {caches} ADD COLUMN `key` varchar(255) NOT NULL"); + $db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY"); + module::set_version("gallery", $version = 6); } } @@ -268,17 +309,17 @@ class gallery_installer { $db->query("DROP TABLE IF EXISTS {access_caches}"); $db->query("DROP TABLE IF EXISTS {access_intents}"); $db->query("DROP TABLE IF EXISTS {graphics_rules}"); + $db->query("DROP TABLE IF EXISTS {incoming_translations}"); $db->query("DROP TABLE IF EXISTS {items}"); $db->query("DROP TABLE IF EXISTS {logs}"); - $db->query("DROP TABLE IF EXISTS {messages}"); $db->query("DROP TABLE IF EXISTS {modules}"); - $db->query("DROP TABLE IF EXISTS {themes}"); - $db->query("DROP TABLE IF EXISTS {incoming_translations}"); $db->query("DROP TABLE IF EXISTS {outgoing_translations}"); $db->query("DROP TABLE IF EXISTS {permissions}"); $db->query("DROP TABLE IF EXISTS {sessions}"); $db->query("DROP TABLE IF EXISTS {tasks}"); + $db->query("DROP TABLE IF EXISTS {themes}"); $db->query("DROP TABLE IF EXISTS {vars}"); + $db->query("DROP TABLE IF EXISTS {caches}"); foreach (array("albums", "resizes", "thumbs", "uploads", "modules", "logs", "database.php") as $entry) { system("/bin/rm -rf " . VARPATH . $entry); diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index fb0234b1..1f1e1ce2 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -94,6 +94,9 @@ class gallery_menu_Core { static function tag($menu, $theme) { } + static function thumb($menu, $theme, $item) { + } + static function photo($menu, $theme) { if (access::can("view_full", $theme->item())) { $menu->append(Menu::factory("link") @@ -149,6 +152,9 @@ class gallery_menu_Core { ->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")) diff --git a/modules/gallery/helpers/gallery_quick.php b/modules/gallery/helpers/gallery_quick.php new file mode 100644 index 00000000..d0ffc584 --- /dev/null +++ b/modules/gallery/helpers/gallery_quick.php @@ -0,0 +1,144 @@ +<?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_quick_Core { + static function get_quick_buttons($item, $page_type) { + $buttons = self::buttons($item, $page_type); + foreach (module::active() as $module) { + if ($module->name == "gallery") { + continue; + } + $class_name = "{$module->name}_quick"; + if (method_exists($class_name, "buttons")) { + $module_buttons = call_user_func(array($class_name, "buttons"), $item, $page_type); + foreach (array("left", "center", "right", "additional") as $position) { + if (!empty($module_buttons[$position])) { + $buttons[$position] = array_merge($buttons[$position], $module_buttons[$position]); + } + } + } + } + + $sorted_buttons->main = array(); + foreach (array("left", "center", "right") as $position) { + $sorted_buttons->main = array_merge($sorted_buttons->main, $buttons[$position]); + } + + $sorted_buttons->additional = $buttons["additional"]; + $max_display = empty($sorted_buttons->additional) ? 6 : 5; + if (count($sorted_buttons->main) >= $max_display) { + $to_move = array_slice($sorted_buttons->main, 5); + $sorted_buttons->additional = array_merge($to_move, $sorted_buttons->additional); + for ($i = count($sorted_buttons->main); $i >= 5; $i--) { + unset($sorted_buttons->main[$i]); + } + } + + return $sorted_buttons; + } + + static function buttons($item, $page_type) { + $elements = array("left" => array(), "center" => array(), "right" => array(), + "additional" => array()); + switch ($item->type) { + case "movie": + $edit_title = t("Edit this movie"); + $move_title = t("Move this movie to another album"); + $cover_title = t("Choose this movie as the album cover"); + $delete_title = t("Delete this movie"); + break; + case "album": + $edit_title = t("Edit this album"); + $move_title = t("Move this album to another album"); + $cover_title = t("Choose this album as the album cover"); + $delete_title = t("Delete this album"); + break; + default: + $edit_title = t("Edit this photo"); + $move_title = t("Move this photo to another album"); + $cover_title = t("Choose this photo as the album cover"); + $delete_title = t("Delete this photo"); + break; + } + + $csrf = access::csrf_token(); + $elements["left"][] = (object)array( + "title" => $edit_title, + "class" => "gDialogLink gButtonLink", + "icon" => "ui-icon-pencil", + "href" => url::site("quick/form_edit/$item->id?page_type=$page_type")); + + if ($item->is_photo() && graphics::can("rotate")) { + $elements["left"][] = + (object)array( + "title" => t("Rotate 90 degrees counter clockwise"), + "class" => "gButtonLink", + "icon" => "ui-icon-rotate-ccw", + "href" => url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type")); + $elements["left"][] = + (object)array( + "title" => t("Rotate 90 degrees clockwise"), + "class" => "gButtonLink", + "icon" => "ui-icon-rotate-cw", + "href" => 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") { + $elements["left"][] = (object)array( + "title" => $move_title, + "class" => "gDialogLink gButtonLink", + "icon" => "ui-icon-folder-open", + "href" => url::site("move/browse/$item->id")); + } + + if (access::can("edit", $item->parent())) { + $disabledState = + $item->type == "album" && empty($item->album_cover_item_id) ? " ui-state-disabled" : ""; + $elements["right"][] = (object)array( + "title" => $cover_title, + "class" => "gButtonLink{$disabledState}", + "icon" => "ui-icon-star", + "href" => url::site("quick/make_album_cover/$item->id?csrf=$csrf&page_type=$page_type")); + + $elements["right"][] = (object)array( + "title" => $delete_title, + "class" => "gDialogLink gButtonLink", + "icon" => "ui-icon-trash", + "id" => "gQuickDelete", + "href" => url::site("quick/form_delete/$item->id?csrf=$csrf&page_type=$page_type")); + } + + if ($item->is_album()) { + $elements["additional"][] = (object)array( + "title" => t("Add a photo"), + "class" => "add_item gDialogLink", + "href" => url::site("simple_uploader/app/$item->id")); + $elements["additional"][] = (object)array( + "title" => t("Add an album"), + "class" => "add_album gDialogLink", + "href" => url::site("form/add/albums/$item->id?type=album")); + $elements["additional"][] = (object)array( + "title" => t("Edit permissions"), + "class" => "permissions gDialogLink", + "href" => url::site("permissions/browse/$item->id")); + } + return $elements; + } +} diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 44c1d3f1..cffecb12 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -29,22 +29,22 @@ class gallery_theme_Core { && access::can("edit", $theme->item())) { $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . url::file("modules/gallery/css/quick.css") . "\" />"; - $buf .= html::script("modules/gallery/js/quick.js"); + $theme->script("modules/gallery/js/quick.js"); } if (module::is_active("rss")) { if ($item = $theme->item()) { - $buf = rss::feed_link("gallery/album/{$item->id}"); + $buf .= rss::feed_link("gallery/album/{$item->id}"); } else if ($tag = $theme->tag()) { - $buf = rss::feed_link("tag/tag/{$tag->id}"); + $buf .= rss::feed_link("tag/tag/{$tag->id}"); } } if ($session->get("l10n_mode", false)) { $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . url::file("modules/gallery/css/l10n_client.css") . "\" />"; - $buf .= html::script("lib/jquery.cookie.js"); - $buf .= html::script("modules/gallery/js/l10n_client.js"); + $theme->script("lib/jquery.cookie.js"); + $theme->script("modules/gallery/js/l10n_client.js"); } return $buf; @@ -87,8 +87,8 @@ class gallery_theme_Core { if ($session->get("l10n_mode", false)) { $buf .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . url::file("modules/gallery/css/l10n_client.css") . "\" />"; - $buf .= html::script("lib/jquery.cookie.js"); - $buf .= html::script("modules/gallery/js/l10n_client.js"); + $theme->script("lib/jquery.cookie.js"); + $theme->script("modules/gallery/js/l10n_client.js"); } return $buf; diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index feebfb34..71b8ddd8 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -135,7 +135,12 @@ class graphics_Core { if ($input_item->is_movie()) { // Convert the movie to a JPG first $output_file = preg_replace("/...$/", "jpg", $output_file); - movie::extract_frame($input_file, $output_file); + try { + movie::extract_frame($input_file, $output_file); + } catch (Exception $e) { + // Assuming this is MISSING_FFMPEG for now + copy(MODPATH . "gallery/images/missing_movie.png", $output_file); + } $working_file = $output_file; } else { $working_file = $input_file; @@ -326,7 +331,7 @@ class graphics_Core { if (!isset($gd["GD Version"])) { $gd["GD Version"] = false; } - putenv("PATH=" . getenv("PATH") . ":/usr/local/bin"); + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin"); return array("gd" => $gd, "imagemagick" => $exec ? dirname(exec("which convert")) : false, "graphicsmagick" => $exec ? dirname(exec("which gm")) : false); diff --git a/modules/gallery/helpers/l10n_scanner.php b/modules/gallery/helpers/l10n_scanner.php index 80b6f01c..a68aa28b 100644 --- a/modules/gallery/helpers/l10n_scanner.php +++ b/modules/gallery/helpers/l10n_scanner.php @@ -125,7 +125,7 @@ class l10n_scanner_Core { && is_array($first_param) && $first_param[0] == T_CONSTANT_ENCAPSED_STRING && is_array($second_param) && $second_param[0] == T_CONSTANT_ENCAPSED_STRING) { $singular = self::_escape_quoted_string($first_param[1]); - $plural = self::_escape_quoted_string($first_param[1]); + $plural = self::_escape_quoted_string($second_param[1]); l10n_scanner::process_message(array("one" => $singular, "other" => $plural), $cache); } else { // t2() found, but inside is something which is not a string literal. @@ -149,6 +149,6 @@ class l10n_scanner_Core { } else { $str = strtr($str, array("\\'" => "'", "\\\\" => "\\")); } - return addcslashes($str, "\0..\37\\\""); + return $str; } } diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index dea8e22c..0d483206 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -107,7 +107,7 @@ class module_Core { /** * Install a module. This will call <module>_installer::install(), which is responsible for - * creating database tables, setting module variables and and calling module::set_version(). + * creating database tables, setting module variables and calling module::set_version(). * Note that after installing, the module must be activated before it is available for use. * @param string $module_name */ @@ -131,6 +131,38 @@ class module_Core { } /** + * Upgrade a module. This will call <module>_installer::upgrade(), which is responsible for + * modifying database tables, changing module variables and calling module::set_version(). + * Note that after upgrading, the module must be activated before it is available for use. + * @param string $module_name + */ + static function upgrade($module_name) { + $kohana_modules = Kohana::config("core.modules"); + array_unshift($kohana_modules, MODPATH . $module_name); + Kohana::config_set("core.modules", $kohana_modules); + + $version_before = module::get_version($module_name); + $installer_class = "{$module_name}_installer"; + if (method_exists($installer_class, "upgrade")) { + call_user_func_array(array($installer_class, "upgrade"), array($version_before)); + } + module::load_modules(); + + // Now the module is upgraded but inactive, so don't leave it in the active path + array_shift($kohana_modules); + Kohana::config_set("core.modules", $kohana_modules); + + $version_after = module::get_version($module_name); + if ($version_before != $version_after) { + log::success( + "module", t("Upgraded module %module_name from %version_before to %version_after", + array("module_name" => $module_name, + "version_before" => $version_before, + "version_after" => $version_after))); + } + } + + /** * Activate an installed module. This will call <module>_installer::activate() which should take * any steps to make sure that the module is ready for use. This will also activate any * existing graphics rules for this module. diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 1d1d29d1..fcf1cc54 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -53,7 +53,12 @@ class movie_Core { throw new Exception("@todo NAME_CANNOT_END_IN_PERIOD"); } - $movie_info = movie::getmoviesize($filename); + try { + $movie_info = movie::getmoviesize($filename); + } catch (Exception $e) { + // Assuming this is MISSING_FFMPEG for now + $movie_info = getimagesize(MODPATH . "gallery/images/missing_movie.png"); + } // Force an extension onto the name $pi = pathinfo($filename); @@ -140,7 +145,7 @@ class movie_Core { static function find_ffmpeg() { if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) { - putenv("PATH=" . getenv("PATH") . ":/usr/local/bin"); + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin"); if (function_exists("exec")) { $ffmpeg_path = exec("which ffmpeg"); } diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index 0a43f25c..b46a2c14 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -55,6 +55,8 @@ class theme_Core { ->value(module::get_var("gallery", "header_text")); $group->textarea("footer_text")->label(t("Footer text"))->id("gFooterText") ->value(module::get_var("gallery", "footer_text")); + $group->checkbox("show_credits")->label(t("Show site credits"))->id("gFooterText") + ->checked(module::get_var("gallery", "show_credits")); $group->submit("")->value(t("Save")); return $form; } diff --git a/modules/gallery/images/missing_movie.png b/modules/gallery/images/missing_movie.png Binary files differnew file mode 100755 index 00000000..fdc97779 --- /dev/null +++ b/modules/gallery/images/missing_movie.png diff --git a/modules/gallery/js/l10n_client.js b/modules/gallery/js/l10n_client.js index 89c4a57d..4936d1cc 100644 --- a/modules/gallery/js/l10n_client.js +++ b/modules/gallery/js/l10n_client.js @@ -93,12 +93,13 @@ jQuery.extend(Gallery, { // Display the source message this.showSourceMessage = function(source, is_plural) { if (is_plural) { - var pretty_source = '[one] - ' + source['one'] + "\n"; - pretty_source += '[other] - ' + source['other']; + var pretty_source = $('#source-text-tmp-space').text('[one] - ' + source['one']).html(); + pretty_source += '<br/>'; + pretty_source += $('#source-text-tmp-space').text('[other] - ' + source['other']).html(); } else { - var pretty_source = source; + var pretty_source = $('#source-text-tmp-space').text(source).html(); } - $('#l10n-client-string-editor .source-text').text(pretty_source); + $('#l10n-client-string-editor .source-text').html(pretty_source); } this.isPluralMessage = function(message) { return typeof(message) == 'object'; diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index 1f976871..01496c0d 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -17,9 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class Admin_View_Core extends View { - private $theme_name = null; - +class Admin_View_Core extends Gallery_View { /** * Attempts to load a view and pre-load view data. * @@ -46,15 +44,6 @@ class Admin_View_Core extends View { $this->set_global("user", user::active()); } - public function url($path, $absolute_url=false) { - $arg = "themes/{$this->theme_name}/$path"; - return $absolute_url ? url::abs_file($arg) : url::file($arg); - } - - public function display($page_name, $view_class="View") { - return new $view_class($page_name); - } - public function admin_menu() { $menu = Menu::factory("root"); gallery_menu::admin($menu, $this); @@ -69,6 +58,7 @@ class Admin_View_Core extends View { } } + $menu->compact(); print $menu; } @@ -108,6 +98,10 @@ class Admin_View_Core extends View { } } + if ($function == "admin_head") { + array_unshift($blocks, $this->combine_script()); + } + if (Session::instance()->get("debug")) { if ($function != "admin_head") { array_unshift( diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php new file mode 100644 index 00000000..659b24dc --- /dev/null +++ b/modules/gallery/libraries/Gallery_View.php @@ -0,0 +1,89 @@ +<?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_View_Core extends View { + protected $theme_name = null; + protected $scripts = array(); + + /** + * Add a script to the combined scripts list. + * @param $file the relative path to a script from the gallery3 directory + */ + public function script($file) { + $this->scripts[$file] = 1; + } + + /** + * Add a script to the combined scripts list. + * @param $file the relative path to a script from the base of the active theme + * @param + */ + public function theme_script($file) { + $file = "themes/{$this->theme_name}/$file"; + $this->scripts[$file] = 1; + } + + /** + * Provide a url to a resource within the current theme. This allows us to refer to theme + * resources without naming the theme itself which makes themes easier to copy. + */ + public function theme_url($path, $absolute_url=false) { + $arg = "themes/{$this->theme_name}/$path"; + return $absolute_url ? url::abs_file($arg) : url::file($arg); + } + + /** + * Combine a series of Javascript files into a single one and cache it in the database, then + * return a single <script> element to refer to it. + */ + protected function combine_script() { + $links = array(); + $key = ""; + foreach (array_keys($this->scripts) as $file) { + $path = DOCROOT . $file; + if (file_exists($path)) { + $stats = stat($path); + $links[] = $path; + // 7 == size, 9 == mtime, see http://php.net/stat + $key = "{$key}$file $stats[7] $stats[9],"; + } else { + Kohana::log("alert", "Javascript file missing: " . $file); + } + } + + $key = md5($key); + $cache = Cache::instance(); + $contents = $cache->get($key); + if (empty($contents)) { + $contents = ""; + foreach ($links as $link) { + $contents .= file_get_contents($link); + } + $cache->set($key, $contents, array("javascript"), 30 * 84600); + if (function_exists("gzencode")) { + $cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), + array("javascript", "gzip"), 30 * 84600); + } + } + + // Handcraft the script link because html::script will add a .js extenstion + return "<script type=\"text/javascript\" src=\"" . url::site("combined/javascript/$key") . + "\"></script>"; + } +}
\ No newline at end of file diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 83bd1616..6d0881ce 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -23,6 +23,11 @@ class Menu_Element { public $css_id; public $css_class; public $id; + public $type; + + public function __construct($type) { + $this->type = $type; + } /** * Set the id @@ -125,26 +130,38 @@ class Menu_Core extends Menu_Element { public static function factory($type) { switch($type) { case "link": - return new Menu_Element_Link(); + return new Menu_Element_Link($type); case "dialog": - return new Menu_Element_Dialog(); + return new Menu_Element_Dialog($type); case "root": - $menu = new Menu(); - $menu->is_root = true; - return $menu; + return new Menu("root"); case "submenu": - return new Menu(); + return new Menu("submenu"); default: throw Exception("@todo UNKNOWN_MENU_TYPE"); } } - public function __construct() { + public function compact() { + foreach ($this->elements as $target_id => $element) { + if ($element->type == "submenu") { + if (empty($element->elements)) { + $this->remove($target_id); + } else { + $element->compact(); + } + } + } + } + + public function __construct($type) { + parent::__construct($type); $this->elements = array(); + $this->is_root = $type == "root"; } /** diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 31c2faa7..8e320f44 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -17,9 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class Theme_View_Core extends View { - private $theme_name = null; - +class Theme_View_Core extends Gallery_View { /** * Attempts to load a view and pre-load view data. * @@ -68,11 +66,6 @@ class Theme_View_Core extends View { return module::get_var("gallery", "thumb_size", 200) / 200; } - public function url($path, $absolute_url=false) { - $arg = "themes/{$this->theme_name}/$path"; - return $absolute_url ? url::abs_file($arg) : url::file($arg); - } - public function item() { return $this->item; } @@ -85,10 +78,6 @@ class Theme_View_Core extends View { return $this->page_type; } - public function display($page_name, $view_class="View") { - return new $view_class($page_name); - } - public function site_menu() { $menu = Menu::factory("root"); if ($this->page_type != "login") { @@ -105,6 +94,7 @@ class Theme_View_Core extends View { } } + $menu->compact(); print $menu; } @@ -120,16 +110,20 @@ class Theme_View_Core extends View { $this->_menu("photo"); } - private function _menu($type) { + public function thumb_menu($item) { + $this->_menu("thumb", $item); + } + + private function _menu($type, $item=null) { $menu = Menu::factory("root"); - call_user_func_array(array("gallery_menu", $type), array(&$menu, $this)); + call_user_func_array(array("gallery_menu", $type), array(&$menu, $this, $item)); foreach (module::active() as $module) { if ($module->name == "gallery") { continue; } $class = "{$module->name}_menu"; if (method_exists($class, $type)) { - call_user_func_array(array($class, $type), array(&$menu, $this)); + call_user_func_array(array($class, $type), array(&$menu, $this, $item)); } } @@ -191,7 +185,28 @@ class Theme_View_Core extends View { case "thumb_info": case "thumb_top": $blocks = array(); + if (method_exists("gallery_theme", $function)) { + switch (count($args)) { + case 0: + $blocks[] = gallery_theme::$function($this); + break; + case 1: + $blocks[] = gallery_theme::$function($this, $args[0]); + break; + case 2: + $blocks[] = gallery_theme::$function($this, $args[0], $args[1]); + break; + default: + $blocks[] = call_user_func_array( + array("gallery_theme", $function), + array_merge(array($this), $args)); + } + + } foreach (module::active() as $module) { + if ($module->name == "gallery") { + continue; + } $helper_class = "{$module->name}_theme"; if (method_exists($helper_class, $function)) { $blocks[] = call_user_func_array( @@ -199,6 +214,11 @@ class Theme_View_Core extends View { array_merge(array($this), $args)); } } + + if ($function == "head") { + array_unshift($blocks, $this->combine_script()); + } + if (Session::instance()->get("debug")) { if ($function != "head") { array_unshift( diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php new file mode 100644 index 00000000..f3a1eb02 --- /dev/null +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -0,0 +1,179 @@ +<?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. + */ +/* + * Based on the Cache_Sqlite_Driver developed by the Kohana Team + */ +class Cache_Database_Driver implements Cache_Driver { + // Kohana database instance + protected $db; + + /** + * Tests that the storage location is a directory and is writable. + */ + public function __construct() { + // Open up an instance of the database + $this->db = Database::instance(); + + if (!$this->db->table_exists("caches")) { + throw new Exception("@todo Cache table is not defined"); + } + } + + /** + * Checks if a cache id is already set. + * + * @param string cache id + * @return boolean + */ + public function exists($id) { + $count = $this->db->count_records("caches", array("key" => $id, "expiration >=" => time())); + return $count > 0; + } + + /** + * Sets a cache item to the given data, tags, and lifetime. + * + * @param string cache id to set + * @param string data in the cache + * @param array cache tags + * @param integer lifetime + * @return bool + */ + public function set($id, $data, array $tags = NULL, $lifetime) { + if (!empty($tags)) { + // Escape the tags, adding brackets so the tag can be explicitly matched + $tags = "<" . implode(">,<", $tags) . ">"; + } + + // Cache Database driver expects unix timestamp + if ($lifetime !== 0) { + $lifetime += time(); + } + + if ($this->exists($id)) { + $status = $this->db->update("caches", + array("tags" => $tags, "expiration" => $lifetime, "cache" => $data), array("key" => $id)); + } else { + $status = $this->db->insert("caches", + array("key" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => $data)); + } + + return count($status) > 0; + } + + /** + * Finds an array of ids for a given tag. + * + * @param string tag name + * @return array of ids that match the tag + */ + public function find($tag) { + $db_result = $this->db->from("caches") + ->like("tags", "<$tag>") + ->get() + ->result(true); + + // An array will always be returned + $result = array(); + + if ($db_result->count() > 0) { + // Disable notices for unserializing + $ER = error_reporting(~E_NOTICE); + + foreach ($db_result as $row) { + // Add each cache to the array + $result[$row->id] = $row->cache; + } + + // Turn notices back on + error_reporting($ER); + } + + return $result; + } + + /** + * Fetches a cache item. This will delete the item if it is expired or if + * the hash does not match the stored hash. + * + * @param string cache id + * @return mixed|NULL + */ + public function get($id) { + $data = null; + $result = $this->db->getwhere("caches", array("key" => $id)); + + if (count($result) > 0) { + $cache = $result->current(); + // Make sure the expiration is valid and that the hash matches + if ($cache->expiration != 0 && $cache->expiration <= time()) { + // Cache is not valid, delete it now + $this->delete($cache->id); + } else { + // Disable notices for unserializing + $ER = error_reporting(~E_NOTICE); + + // Return the valid cache data + $data = $cache->cache; + + // Turn notices back on + error_reporting($ER); + } + } + + return $data; + } + + /** + * Deletes a cache item by id or tag + * + * @param string cache id or tag, or true for "all items" + * @param bool delete a tag + * @return bool + */ + public function delete($id, $tag = false) { + $this->db->from("caches"); + if ($id === true) { + $this->db->where(1); + // Delete all caches + } else if ($tag === true) { + $this->db->like("tags", "<$id>"); + } else { + $this->db->where("key", $id); + } + + $status = $this->db->delete(); + + return count($status) > 0; + } + + /** + * Deletes all cache files that are older than the current time. + */ + public function delete_expired() { + // Delete all expired caches + $status = $this->db->from("caches") + ->where(array("expiration !=" => 0, "expiration <=" => time())) + ->delete(); + + return count($status) > 0; + } + +} // End Cache Database Driver
\ No newline at end of file diff --git a/modules/gallery/models/cache.php b/modules/gallery/models/cache.php new file mode 100644 index 00000000..99e19a6e --- /dev/null +++ b/modules/gallery/models/cache.php @@ -0,0 +1,20 @@ +<?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 Cache_Model extends ORM {} diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 7dce9e51..430119b5 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -378,14 +378,41 @@ class Item_Model extends ORM_MPTT { * the first child in the album is at position 1. */ public function get_position($child_id) { - $result = Database::instance()->query(" + if ($this->sort_order == "DESC") { + $comp = ">"; + } else { + $comp = "<"; + } + + $db = Database::instance(); + $position = $db->query(" SELECT COUNT(*) AS position FROM {items} - WHERE parent_id = {$this->id} - AND {$this->sort_column} <= (SELECT {$this->sort_column} - FROM {items} WHERE id = $child_id) - ORDER BY {$this->sort_column} {$this->sort_order}"); + WHERE parent_id = {$this->id} + AND `{$this->sort_column}` $comp (SELECT `{$this->sort_column}` + FROM {items} WHERE id = $child_id) + ORDER BY `{$this->sort_column}` {$this->sort_order}")->current()->position; + + // We stopped short of our target value in the sort (notice that we're using a < comparator + // above) because it's possible that we have duplicate values in the sort column. An + // equality check would just arbitrarily pick one of those multiple possible equivalent + // columns, which would mean that if you choose a sort order that has duplicates, it'd pick + // any one of them as the child's "position". + // + // Fix this by doing a 2nd query where we iterate over the equivalent columns and add them to + // our base value. + $result = $db->query(" + SELECT id FROM {items} + WHERE parent_id = {$this->id} + AND `{$this->sort_column}` = (SELECT `{$this->sort_column}` + FROM {items} WHERE id = $child_id)"); + foreach ($result as $row) { + $position++; + if ($row->id == $child_id) { + break; + } + } - return $result->current()->position; + return $position; } /** diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 3a5dd593..c184aba7 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = Gallery 3 description = Gallery core application -version = 2 +version = 6 diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php new file mode 100644 index 00000000..a5e0e7a0 --- /dev/null +++ b/modules/gallery/tests/Cache_Test.php @@ -0,0 +1,178 @@ +<?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 Cache_Test extends Unit_Test_Case { + private $_driver; + public function setup() { + Database::instance()->from("caches")->where(1)->delete(); + $this->_driver = new Cache_Database_Driver(); + } + + public function cache_exists_test() { + $db = Database::instance(); + + $this->assert_false($this->_driver->exists("test_key"), "test_key should not be defined"); + + $id = md5(rand()); + $db->insert("caches", array("id" => $id, "tags" => "<tag1>, <tag2>", + "expiration" => 84600 + time(), + "cache" => serialize("some test data"))); + + $this->assert_true($this->_driver->exists($id), "test_key should be defined"); + } + + public function cache_get_test() { + $db = Database::instance(); + + $id = md5(rand()); + $db->insert("caches", array("id" => $id, "tags" => "<tag1>, <tag2>", + "expiration" => 84600 + time(), + "cache" => serialize("some test data"))); + + $data = $this->_driver->get($id); + $this->assert_equal("some test data", $data, "cached data should match"); + + $data = $this->_driver->get(""); + $this->assert_equal(null, $data, "cached data should not be found"); + } + + public function cache_set_test() { + $db = Database::instance(); + + $id = md5(rand()); + $original_data = array("field1" => "value1", "field2" => "value2"); + $this->_driver->set($id, $original_data, array("tag1", "tag2"), 84600); + + $data = $this->_driver->get($id); + $this->assert_equal($original_data, $data, "cached data should match"); + } + + public function cache_find_test() { + $db = Database::instance(); + + $id1 = md5(rand()); + $value1 = array("field1" => "value1", "field2" => "value2"); + $this->_driver->set($id1, $value1, array("tag1", "tag2"), 84600); + + $id2 = md5(rand()); + $value2 = array("field3" => "value3", "field4" => "value4"); + $this->_driver->set($id2, $value2, array("tag2", "tag3"), 84600); + + $id3 = md5(rand()); + $value3 = array("field5" => "value5", "field6" => "value6"); + $this->_driver->set($id3, $value3, array("tag3", "tag4"), 84600); + + $data = $this->_driver->find("tag2"); + + $expected = array($id1 => $value1, $id2 => $value2); + ksort($expected); + $this->assert_equal($expected, $data, "Expected id1 & id2"); + + $data = $this->_driver->find("tag4"); + $this->assert_equal(array($id3 => $value3), $data, "Expected id3"); + } + + public function cache_delete_expired_test() { + $db = Database::instance(); + + $id1 = md5(rand()); + $value1 = array("field1" => "value1", "field2" => "value2"); + $this->_driver->set($id1, $value1, array("tag1", "tag2"), -84600); + + $id2 = md5(rand()); + $value2 = array("field3" => "value3", "field4" => "value4"); + $this->_driver->set($id2, $value2, array("tag2", "tag3"), -846000); + + $id3 = md5(rand()); + $value3 = array("field5" => "value5", "field6" => "value6"); + $this->_driver->set($id3, $value3, array("tag3", "tag4"), -84600); + + $data = $this->_driver->delete_expired(); + + $this->assert_false($this->_driver->exists($id1), "$id1 should have been deleted"); + $this->assert_false($this->_driver->exists($id2), "$id2 should have been deleted"); + $this->assert_false($this->_driver->exists($id3), "$id3 should have been deleted"); + } + + public function cache_delete_id_test() { + $db = Database::instance(); + + $id1 = md5(rand()); + $value1 = array("field1" => "value1", "field2" => "value2"); + $this->_driver->set($id1, $value1, array("tag1", "tag2"), 84600); + + $id2 = md5(rand()); + $value2 = array("field3" => "value3", "field4" => "value4"); + $this->_driver->set($id2, $value2, array("tag2", "tag3"), 846000); + + $id3 = md5(rand()); + $value3 = array("field5" => "value5", "field6" => "value6"); + $this->_driver->set($id3, $value3, array("tag3", "tag4"), 84600); + + $this->_driver->delete($id1); + + $this->assert_false($this->_driver->exists($id1), "$id1 should have been deleted"); + $this->assert_true($this->_driver->exists($id2), "$id2 should not have been deleted"); + $this->assert_true($this->_driver->exists($id3), "$id3 should not have been deleted"); + } + + public function cache_delete_tag_test() { + $db = Database::instance(); + + $id1 = md5(rand()); + $value1 = array("field1" => "value1", "field2" => "value2"); + $this->_driver->set($id1, $value1, array("tag1", "tag2"), 84600); + + $id2 = md5(rand()); + $value2 = array("field3" => "value3", "field4" => "value4"); + $this->_driver->set($id2, $value2, array("tag2", "tag3"), 846000); + + $id3 = md5(rand()); + $value3 = array("field5" => "value5", "field6" => "value6"); + $this->_driver->set($id3, $value3, array("tag3", "tag4"), 84600); + + $data = $this->_driver->delete("tag3", true); + + $this->assert_true($this->_driver->exists($id1), "$id1 should not have been deleted"); + $this->assert_false($this->_driver->exists($id2), "$id2 should have been deleted"); + $this->assert_false($this->_driver->exists($id3), "$id3 should have been deleted"); + } + + public function cache_delete_all_test() { + $db = Database::instance(); + + $id1 = md5(rand()); + $value1 = array("field1" => "value1", "field2" => "value2"); + $this->_driver->set($id1, $value1, array("tag1", "tag2"), 84600); + + $id2 = md5(rand()); + $value2 = array("field3" => "value3", "field4" => "value4"); + $this->_driver->set($id2, $value2, array("tag2", "tag3"), 846000); + + $id3 = md5(rand()); + $value3 = array("field5" => "value5", "field6" => "value6"); + $this->_driver->set($id3, $value3, array("tag3", "tag4"), 84600); + + $data = $this->_driver->delete(true); + + $this->assert_false($this->_driver->exists($id1), "$id1 should have been deleted"); + $this->assert_false($this->_driver->exists($id2), "$id2 should have been deleted"); + $this->assert_false($this->_driver->exists($id3), "$id3 should have been deleted"); + } +}
\ No newline at end of file diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php index 24d24b38..27157d6e 100644 --- a/modules/gallery/tests/Gallery_Installer_Test.php +++ b/modules/gallery/tests/Gallery_Installer_Test.php @@ -31,9 +31,6 @@ class Gallery_Installer_Test extends Unit_Test_Case { public function install_registers_gallery_module_test() { $gallery = ORM::factory("module")->where("name", "gallery")->find(); $this->assert_equal("gallery", $gallery->name); - - // This is probably too volatile to keep for long - $this->assert_equal(1, $gallery->version); } public function install_creates_root_item_test() { diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index f47ae0dc..6133b025 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -37,9 +37,26 @@ modules/comment/views/admin_comments.html.php 194 DIRTY $pager modules/comment/views/comment.html.php 2 DIRTY $comment->id modules/comment/views/comment.html.php 5 DIRTY $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) modules/comment/views/comment.html.php 7 $comment->author_name() -modules/comment/views/comment.html.php 11 DIRTY $comment->created -modules/comment/views/comment.html.php 12 $comment->author_name() -modules/comment/views/comment.html.php 15 $comment->text +modules/comment/views/comment.html.php 12 DIRTY $comment->created +modules/comment/views/comment.html.php 13 $comment->author_name() +modules/comment/views/comment.html.php 16 $comment->text +modules/comment/views/comment.mrss.php 9 $feed->title +modules/comment/views/comment.mrss.php 10 DIRTY $feed->uri +modules/comment/views/comment.mrss.php 11 $feed->description +modules/comment/views/comment.mrss.php 13 DIRTY $feed->uri +modules/comment/views/comment.mrss.php 16 DIRTY $feed->previous_page_uri +modules/comment/views/comment.mrss.php 19 DIRTY $feed->next_page_uri +modules/comment/views/comment.mrss.php 21 DIRTY $pub_date +modules/comment/views/comment.mrss.php 22 DIRTY $pub_date +modules/comment/views/comment.mrss.php 25 $child->title +modules/comment/views/comment.mrss.php 26 $child->item_uri +modules/comment/views/comment.mrss.php 27 $child->author +modules/comment/views/comment.mrss.php 28 DIRTY $child->item_uri +modules/comment/views/comment.mrss.php 29 DIRTY $child->pub_date +modules/comment/views/comment.mrss.php 32 $child->text +modules/comment/views/comment.mrss.php 34 DIRTY $child->thumb_url +modules/comment/views/comment.mrss.php 35 DIRTY $child->thumb_height +modules/comment/views/comment.mrss.php 35 DIRTY $child->thumb_width modules/comment/views/comments.html.php 10 DIRTY $comment->id modules/comment/views/comments.html.php 13 DIRTY $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) modules/comment/views/comments.html.php 15 $comment->author_name() @@ -55,18 +72,19 @@ modules/exif/views/exif_dialog.html.php 21 DIRTY $i modules/exif/views/exif_dialog.html.php 24 $details modules/exif/views/exif_dialog.html.php 24 $i modules/exif/views/exif_sidebar.html.php 2 DIRTY $item->id -modules/g2_import/views/admin_g2_import.html.php 8 DIRTY $form -modules/g2_import/views/admin_g2_import.html.php 26 DIRTY $g2_stats -modules/g2_import/views/admin_g2_import.html.php 29 DIRTY $g2_stats -modules/g2_import/views/admin_g2_import.html.php 32 DIRTY $g2_stats -modules/g2_import/views/admin_g2_import.html.php 35 DIRTY $g2_stats -modules/g2_import/views/admin_g2_import.html.php 38 DIRTY $g2_stats -modules/g2_import/views/admin_g2_import.html.php 41 DIRTY $g2_stats -modules/g2_import/views/admin_g2_import.html.php 45 DIRTY $g2_stats -modules/g2_import/views/admin_g2_import.html.php 53 DIRTY $g2_sizes -modules/g2_import/views/admin_g2_import.html.php 54 DIRTY $thumb_size -modules/g2_import/views/admin_g2_import.html.php 62 DIRTY $g2_sizes -modules/g2_import/views/admin_g2_import.html.php 63 DIRTY $resize_size +modules/g2_import/views/admin_g2_import.html.php 28 DIRTY $form +modules/g2_import/views/admin_g2_import.html.php 40 DIRTY $g2_sizes +modules/g2_import/views/admin_g2_import.html.php 41 DIRTY $thumb_size +modules/g2_import/views/admin_g2_import.html.php 49 DIRTY $g2_sizes +modules/g2_import/views/admin_g2_import.html.php 50 DIRTY $resize_size +modules/g2_import/views/admin_g2_import.html.php 62 DIRTY $g2_stats +modules/g2_import/views/admin_g2_import.html.php 65 DIRTY $g2_stats +modules/g2_import/views/admin_g2_import.html.php 68 DIRTY $g2_stats +modules/g2_import/views/admin_g2_import.html.php 71 DIRTY $g2_stats +modules/g2_import/views/admin_g2_import.html.php 74 DIRTY $g2_stats +modules/g2_import/views/admin_g2_import.html.php 77 DIRTY $g2_stats +modules/g2_import/views/admin_g2_import.html.php 81 DIRTY $g2_stats +modules/g2_import/views/admin_g2_import.html.php 88 DIRTY $csrf modules/gallery/views/admin_advanced_settings.html.php 22 DIRTY $var->module_name modules/gallery/views/admin_advanced_settings.html.php 23 $var->name modules/gallery/views/admin_advanced_settings.html.php 25 DIRTY $var->module_name @@ -140,13 +158,14 @@ modules/gallery/views/admin_maintenance.html.php 171 DIRTY $task->id modules/gallery/views/admin_maintenance.html.php 171 DIRTY $csrf modules/gallery/views/admin_maintenance_task.html.php 5 DIRTY $task->id modules/gallery/views/admin_maintenance_task.html.php 5 DIRTY $csrf +modules/gallery/views/admin_maintenance_task.html.php 26 DIRTY $task->name modules/gallery/views/admin_modules.html.php 19 DIRTY $i modules/gallery/views/admin_modules.html.php 22 DIRTY $data modules/gallery/views/admin_modules.html.php 22 DIRTY $module_name modules/gallery/views/admin_modules.html.php 23 DIRTY $module_info->name modules/gallery/views/admin_modules.html.php 24 DIRTY $module_info->version modules/gallery/views/admin_modules.html.php 25 DIRTY $module_info->description -modules/gallery/views/admin_theme_details.html.php 5 DIRTY $form +modules/gallery/views/admin_theme_options.html.php 5 DIRTY $form modules/gallery/views/admin_themes.html.php 5 DIRTY $csrf modules/gallery/views/admin_themes.html.php 18 DIRTY $site modules/gallery/views/admin_themes.html.php 19 DIRTY $themes @@ -187,13 +206,13 @@ modules/gallery/views/kohana_error_page.php 100 DIRTY $line modules/gallery/views/kohana_error_page.php 112 DIRTY $trace modules/gallery/views/kohana_profiler.php 32 DIRTY $profile->render() modules/gallery/views/kohana_profiler.php 34 DIRTY $execution_time -modules/gallery/views/l10n_client.html.php 13 DIRTY $string -modules/gallery/views/l10n_client.html.php 15 DIRTY $string -modules/gallery/views/l10n_client.html.php 16 DIRTY $string -modules/gallery/views/l10n_client.html.php 18 DIRTY $string -modules/gallery/views/l10n_client.html.php 24 DIRTY $l10n_search_form -modules/gallery/views/l10n_client.html.php 65 DIRTY $string_list -modules/gallery/views/l10n_client.html.php 66 DIRTY $plural_forms +modules/gallery/views/l10n_client.html.php 17 DIRTY $string +modules/gallery/views/l10n_client.html.php 19 DIRTY $string +modules/gallery/views/l10n_client.html.php 20 DIRTY $string +modules/gallery/views/l10n_client.html.php 22 DIRTY $string +modules/gallery/views/l10n_client.html.php 28 DIRTY $l10n_search_form +modules/gallery/views/l10n_client.html.php 70 DIRTY $string_list +modules/gallery/views/l10n_client.html.php 71 DIRTY $plural_forms modules/gallery/views/move_browse.html.php 4 DIRTY $source->id modules/gallery/views/move_browse.html.php 39 DIRTY $tree modules/gallery/views/move_browse.html.php 42 DIRTY $source->id @@ -244,48 +263,29 @@ modules/gallery/views/permissions_form.html.php 74 DIRTY $item->id modules/gallery/views/permissions_form.html.php 79 DIRTY $group->id modules/gallery/views/permissions_form.html.php 79 DIRTY $permission->id modules/gallery/views/permissions_form.html.php 79 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 9 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 9 DIRTY $page_type -modules/gallery/views/quick_pane.html.php 10 DIRTY $title -modules/gallery/views/quick_pane.html.php 12 DIRTY $title -modules/gallery/views/quick_pane.html.php 17 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 17 DIRTY $csrf -modules/gallery/views/quick_pane.html.php 17 DIRTY $page_type -modules/gallery/views/quick_pane.html.php 24 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 24 DIRTY $csrf -modules/gallery/views/quick_pane.html.php 24 DIRTY $page_type -modules/gallery/views/quick_pane.html.php 41 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 42 DIRTY $title -modules/gallery/views/quick_pane.html.php 44 DIRTY $title -modules/gallery/views/quick_pane.html.php 61 DIRTY $disabledState -modules/gallery/views/quick_pane.html.php 61 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 61 DIRTY $csrf -modules/gallery/views/quick_pane.html.php 61 DIRTY $page_type -modules/gallery/views/quick_pane.html.php 62 DIRTY $title -modules/gallery/views/quick_pane.html.php 64 DIRTY $title -modules/gallery/views/quick_pane.html.php 78 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 78 DIRTY $csrf -modules/gallery/views/quick_pane.html.php 78 DIRTY $page_type -modules/gallery/views/quick_pane.html.php 78 DIRTY $message -modules/gallery/views/quick_pane.html.php 78 DIRTY $title -modules/gallery/views/quick_pane.html.php 80 DIRTY $title -modules/gallery/views/quick_pane.html.php 93 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 98 DIRTY $item->id -modules/gallery/views/quick_pane.html.php 103 DIRTY $item->id +modules/gallery/views/quick_pane.html.php 3 DIRTY $button->class +modules/gallery/views/quick_pane.html.php 3 DIRTY $button->href +modules/gallery/views/quick_pane.html.php 4 DIRTY $button->title +modules/gallery/views/quick_pane.html.php 5 DIRTY $button->icon +modules/gallery/views/quick_pane.html.php 6 DIRTY $button->title +modules/gallery/views/quick_pane.html.php 20 DIRTY $button->class +modules/gallery/views/quick_pane.html.php 20 DIRTY $button->href +modules/gallery/views/quick_pane.html.php 21 DIRTY $button->title +modules/gallery/views/quick_pane.html.php 22 DIRTY $button->title modules/gallery/views/simple_uploader.html.php 6 DIRTY $csrf modules/gallery/views/simple_uploader.html.php 8 $item->title modules/gallery/views/simple_uploader.html.php 28 $parent->title modules/gallery/views/simple_uploader.html.php 30 $item->title modules/gallery/views/simple_uploader.html.php 77 DIRTY $item->id modules/gallery/views/simple_uploader.html.php 81 DIRTY $csrf -modules/gallery/views/upgrader.html.php 94 DIRTY $done -modules/gallery/views/upgrader.html.php 124 DIRTY $module->version -modules/gallery/views/upgrader.html.php 124 DIRTY $module->code_version -modules/gallery/views/upgrader.html.php 125 DIRTY $id -modules/gallery/views/upgrader.html.php 126 DIRTY $module->name -modules/gallery/views/upgrader.html.php 129 DIRTY $module->version -modules/gallery/views/upgrader.html.php 132 DIRTY $module->code_version -modules/gallery/views/upgrader.html.php 155 DIRTY $module->name +modules/gallery/views/upgrader.html.php 43 DIRTY $module->version +modules/gallery/views/upgrader.html.php 43 DIRTY $module->code_version +modules/gallery/views/upgrader.html.php 44 DIRTY $id +modules/gallery/views/upgrader.html.php 45 DIRTY $module->name +modules/gallery/views/upgrader.html.php 48 DIRTY $module->version +modules/gallery/views/upgrader.html.php 51 DIRTY $module->code_version +modules/gallery/views/upgrader.html.php 74 DIRTY $module->name +modules/gallery/views/upgrader.html.php 83 DIRTY $upgrade_token modules/image_block/views/image_block_block.html.php 3 DIRTY $item->url() modules/image_block/views/image_block_block.html.php 4 DIRTY $item->thumb_img(array("class" => "gThumbnail")) modules/info/views/info_block.html.php 6 $item->title @@ -354,29 +354,12 @@ modules/recaptcha/views/admin_recaptcha.html.php 6 DIRTY $form->ge modules/recaptcha/views/admin_recaptcha.html.php 10 DIRTY $form modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY $public_key modules/recaptcha/views/form_recaptcha.html.php 7 DIRTY $public_key -modules/rss/views/comment.mrss.php 9 $title -modules/rss/views/comment.mrss.php 10 DIRTY $link -modules/rss/views/comment.mrss.php 11 $description -modules/rss/views/comment.mrss.php 13 DIRTY $feed_link -modules/rss/views/comment.mrss.php 16 DIRTY $previous_page_link -modules/rss/views/comment.mrss.php 19 DIRTY $next_page_link -modules/rss/views/comment.mrss.php 21 DIRTY $pub_date -modules/rss/views/comment.mrss.php 22 DIRTY $pub_date -modules/rss/views/comment.mrss.php 25 $child -modules/rss/views/comment.mrss.php 26 $child -modules/rss/views/comment.mrss.php 27 $child -modules/rss/views/comment.mrss.php 28 DIRTY $child -modules/rss/views/comment.mrss.php 29 DIRTY $child -modules/rss/views/comment.mrss.php 32 $child -modules/rss/views/comment.mrss.php 34 DIRTY $child -modules/rss/views/comment.mrss.php 35 DIRTY $child -modules/rss/views/comment.mrss.php 35 DIRTY $child -modules/rss/views/feed.mrss.php 9 $title -modules/rss/views/feed.mrss.php 10 DIRTY $link -modules/rss/views/feed.mrss.php 11 $description -modules/rss/views/feed.mrss.php 13 DIRTY $feed_link -modules/rss/views/feed.mrss.php 16 DIRTY $previous_page_link -modules/rss/views/feed.mrss.php 19 DIRTY $next_page_link +modules/rss/views/feed.mrss.php 9 $feed->title +modules/rss/views/feed.mrss.php 10 DIRTY $feed->uri +modules/rss/views/feed.mrss.php 11 $feed->description +modules/rss/views/feed.mrss.php 13 DIRTY $feed->uri +modules/rss/views/feed.mrss.php 16 DIRTY $feed->previous_page_uri +modules/rss/views/feed.mrss.php 19 DIRTY $feed->next_page_uri modules/rss/views/feed.mrss.php 21 DIRTY $pub_date modules/rss/views/feed.mrss.php 22 DIRTY $pub_date modules/rss/views/feed.mrss.php 25 $child->title @@ -519,14 +502,14 @@ themes/admin_default/views/block.html.php 5 DIRTY $id themes/admin_default/views/block.html.php 5 DIRTY $csrf themes/admin_default/views/block.html.php 10 DIRTY $title themes/admin_default/views/block.html.php 13 DIRTY $content -themes/admin_default/views/pager.html.php 9 DIRTY $from_to_msg themes/admin_default/views/pager.html.php 11 DIRTY $url -themes/admin_default/views/pager.html.php 16 DIRTY $previous_page -themes/admin_default/views/pager.html.php 16 DIRTY $url -themes/admin_default/views/pager.html.php 21 DIRTY $next_page -themes/admin_default/views/pager.html.php 21 DIRTY $url -themes/admin_default/views/pager.html.php 26 DIRTY $last_page -themes/admin_default/views/pager.html.php 26 DIRTY $url +themes/admin_default/views/pager.html.php 18 DIRTY $previous_page +themes/admin_default/views/pager.html.php 18 DIRTY $url +themes/admin_default/views/pager.html.php 25 DIRTY $from_to_msg +themes/admin_default/views/pager.html.php 28 DIRTY $next_page +themes/admin_default/views/pager.html.php 28 DIRTY $url +themes/admin_default/views/pager.html.php 35 DIRTY $last_page +themes/admin_default/views/pager.html.php 35 DIRTY $url themes/default/views/album.html.php 4 DIRTY $theme->album_top() themes/default/views/album.html.php 5 $item->title themes/default/views/album.html.php 6 $item->description @@ -584,29 +567,29 @@ themes/default/views/movie.html.php 18 DIRTY $item->he themes/default/views/movie.html.php 21 DIRTY $item->id themes/default/views/movie.html.php 35 $item->title themes/default/views/movie.html.php 36 $item->description -themes/default/views/movie.html.php 39 DIRTY $theme->photo_bottom() -themes/default/views/page.html.php 11 $item->title -themes/default/views/page.html.php 14 DIRTY $page_title -themes/default/views/page.html.php 16 DIRTY $theme->page_type -themes/default/views/page.html.php 18 DIRTY $theme->url("images/favicon.ico") -themes/default/views/page.html.php 25 DIRTY $theme->url("css/screen.css") -themes/default/views/page.html.php 28 DIRTY $theme->url("css/fix-ie.css") -themes/default/views/page.html.php 37 DIRTY $new_width -themes/default/views/page.html.php 38 DIRTY $new_height -themes/default/views/page.html.php 39 DIRTY $thumb_proportion -themes/default/views/page.html.php 51 DIRTY $theme->url("js/jquery.scrollTo.js") -themes/default/views/page.html.php 52 DIRTY $theme->url("js/jquery.localscroll.js") -themes/default/views/page.html.php 53 DIRTY $theme->url("js/ui.init.js") -themes/default/views/page.html.php 54 DIRTY $theme->head() -themes/default/views/page.html.php 57 DIRTY $theme->body_attributes() -themes/default/views/page.html.php 58 DIRTY $theme->page_top() -themes/default/views/page.html.php 60 DIRTY $theme->site_status() -themes/default/views/page.html.php 62 DIRTY $theme->display("header.html") -themes/default/views/page.html.php 68 DIRTY $theme->messages() -themes/default/views/page.html.php 69 DIRTY $content -themes/default/views/page.html.php 74 DIRTY $theme->display("sidebar.html") -themes/default/views/page.html.php 78 DIRTY $theme->display("footer.html") -themes/default/views/page.html.php 81 DIRTY $theme->page_bottom() +themes/default/views/movie.html.php 42 DIRTY $theme->photo_bottom() +themes/default/views/page.html.php 9 DIRTY $page_title +themes/default/views/page.html.php 13 $theme->item()->title +themes/default/views/page.html.php 15 $theme->item()->title +themes/default/views/page.html.php 17 $theme->item()->title +themes/default/views/page.html.php 20 $theme->tag()->name +themes/default/views/page.html.php 26 DIRTY $theme->url("images/favicon.ico") +themes/default/views/page.html.php 33 DIRTY $theme->url("css/screen.css") +themes/default/views/page.html.php 36 DIRTY $theme->url("css/fix-ie.css") +themes/default/views/page.html.php 45 DIRTY $new_width +themes/default/views/page.html.php 46 DIRTY $new_height +themes/default/views/page.html.php 47 DIRTY $thumb_proportion +themes/default/views/page.html.php 63 DIRTY $theme->url("js/ui.init.js") +themes/default/views/page.html.php 64 DIRTY $theme->head() +themes/default/views/page.html.php 67 DIRTY $theme->body_attributes() +themes/default/views/page.html.php 68 DIRTY $theme->page_top() +themes/default/views/page.html.php 70 DIRTY $theme->site_status() +themes/default/views/page.html.php 72 DIRTY $theme->display("header.html") +themes/default/views/page.html.php 78 DIRTY $theme->messages() +themes/default/views/page.html.php 79 DIRTY $content +themes/default/views/page.html.php 85 DIRTY $theme->display("sidebar.html") +themes/default/views/page.html.php 90 DIRTY $theme->display("footer.html") +themes/default/views/page.html.php 93 DIRTY $theme->page_bottom() themes/default/views/pager.html.php 11 DIRTY $url themes/default/views/pager.html.php 18 DIRTY $previous_page themes/default/views/pager.html.php 18 DIRTY $url @@ -615,19 +598,24 @@ themes/default/views/pager.html.php 28 DIRTY $next_pag themes/default/views/pager.html.php 28 DIRTY $url themes/default/views/pager.html.php 35 DIRTY $last_page themes/default/views/pager.html.php 35 DIRTY $url -themes/default/views/photo.html.php 3 DIRTY $theme->photo_top() -themes/default/views/photo.html.php 8 DIRTY $previous_item->url() -themes/default/views/photo.html.php 15 DIRTY $position -themes/default/views/photo.html.php 15 DIRTY $sibling_count -themes/default/views/photo.html.php 18 DIRTY $next_item->url() -themes/default/views/photo.html.php 28 DIRTY $theme->resize_top($item) -themes/default/views/photo.html.php 32 DIRTY $item->resize_img(array("id" => "gPhotoId-{$item->id}", "class" => "gResize")) -themes/default/views/photo.html.php 36 DIRTY $theme->resize_bottom($item) -themes/default/views/photo.html.php 40 $item->title -themes/default/views/photo.html.php 41 $item->description -themes/default/views/photo.html.php 47 DIRTY $theme->photo_bottom() +themes/default/views/photo.html.php 9 DIRTY $theme->item()->file_url() +themes/default/views/photo.html.php 9 DIRTY $theme->item()->width +themes/default/views/photo.html.php 9 DIRTY $theme->item()->height +themes/default/views/photo.html.php 17 DIRTY $theme->photo_top() +themes/default/views/photo.html.php 22 DIRTY $previous_item->url() +themes/default/views/photo.html.php 29 DIRTY $position +themes/default/views/photo.html.php 29 DIRTY $sibling_count +themes/default/views/photo.html.php 32 DIRTY $next_item->url() +themes/default/views/photo.html.php 42 DIRTY $theme->resize_top($item) +themes/default/views/photo.html.php 44 DIRTY $item->file_url() +themes/default/views/photo.html.php 46 DIRTY $item->resize_img(array("id" => "gPhotoId-{$item->id}", "class" => "gResize")) +themes/default/views/photo.html.php 50 DIRTY $theme->resize_bottom($item) +themes/default/views/photo.html.php 54 $item->title +themes/default/views/photo.html.php 55 $item->description +themes/default/views/photo.html.php 61 DIRTY $theme->photo_bottom() themes/default/views/sidebar.html.php 2 DIRTY $theme->sidebar_top() themes/default/views/sidebar.html.php 6 DIRTY $theme->album_menu() themes/default/views/sidebar.html.php 8 DIRTY $theme->photo_menu() -themes/default/views/sidebar.html.php 13 DIRTY $theme->sidebar_blocks() -themes/default/views/sidebar.html.php 14 DIRTY $theme->sidebar_bottom() +themes/default/views/sidebar.html.php 10 DIRTY $theme->tag_menu() +themes/default/views/sidebar.html.php 15 DIRTY $theme->sidebar_blocks() +themes/default/views/sidebar.html.php 16 DIRTY $theme->sidebar_bottom() diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php index 1ee02311..d9aecc60 100644 --- a/modules/gallery/views/admin_maintenance_task.html.php +++ b/modules/gallery/views/admin_maintenance_task.html.php @@ -23,8 +23,11 @@ } </script> <div id="gProgress"> + <h1> <?= $task->name ?> </h1> <div class="gProgressBar"></div> - <div id="gStatus"></div> + <div id="gStatus"> + <?= t("Starting up...") ?> + </div> <div> <button id="gPauseButton" class="ui-state-default ui-corner-all" onclick="dismiss()"><?= t("Pause") ?></button> <button id="gDoneButton" class="ui-state-default ui-corner-all" style="display: none" onclick="dismiss()"><?= t("Done") ?></button> diff --git a/modules/gallery/views/l10n_client.html.php b/modules/gallery/views/l10n_client.html.php index 2e53f48f..c15f4b0e 100644 --- a/modules/gallery/views/l10n_client.html.php +++ b/modules/gallery/views/l10n_client.html.php @@ -2,7 +2,11 @@ <div id="l10n-client" class="hidden"> <div class="labels"> <span class="toggle"><?= t("Translate Text") ?></span> - <div class="label strings"><h2><?= t("Page Text") ?></h2></div> + <div class="label strings"><h2><?= t("Page Text") ?> + <? if (!Input::instance()->get('show_all_l10n_messages')): ?> + <a style="background-color:#fff" href="<?= url::site("admin/languages?show_all_l10n_messages=1") ?>"><?= t("(Show All)") ?></a> + <? endif; ?> + </h2></div> <div class="label source"><h2><?= t("Source") ?></div> <div class="label translation"><h2><?= t("Translation to %language", array("language" => locale::display_name())) ?></h2></div> @@ -26,6 +30,7 @@ <div id="l10n-client-string-editor"> <div class="source"> <p class="source-text"></p> + <p id="source-text-tmp-space" style="display:none"></p> </div> <div class="translation"> <form method="post" action="<?= url::site("l10n_client/save") ?>" id="gL10nClientSaveForm"> diff --git a/modules/gallery/views/quick_pane.html.php b/modules/gallery/views/quick_pane.html.php index f50e1abe..eabf4a67 100644 --- a/modules/gallery/views/quick_pane.html.php +++ b/modules/gallery/views/quick_pane.html.php @@ -1,85 +1,14 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> -<? if ($item->type == "photo"): ?> -<? $title = t("Edit this photo") ?> -<? elseif ($item->type == "movie"): ?> -<? $title = t("Edit this movie") ?> -<? elseif ($item->type == "album"): ?> -<? $title = t("Edit this album") ?> -<? endif ?> -<a class="gDialogLink gButtonLink ui-corner-all ui-state-default" href="<?= url::site("quick/form_edit/$item->id?page_type=$page_type") ?>" - title="<?= $title ?>"> - <span class="ui-icon ui-icon-pencil"> - <?= $title ?> - </span> -</a> - -<? if ($item->is_photo() && graphics::can("rotate")): ?> -<a class="gButtonLink ui-corner-all ui-state-default" href="<?= url::site("quick/rotate/$item->id/ccw?csrf=$csrf&page_type=$page_type") ?>" - title="<?= t("Rotate 90 degrees counter clockwise") ?>"> - <span class="ui-icon ui-icon-rotate-ccw"> - <?= t("Rotate 90 degrees counter clockwise") ?> - </span> -</a> - -<a class="gButtonLink ui-corner-all ui-state-default" href="<?= url::site("quick/rotate/$item->id/cw?csrf=$csrf&page_type=$page_type") ?>" - title="<?= t("Rotate 90 degrees clockwise") ?>"> - <span class="ui-icon ui-icon-rotate-cw"> - <?= t("Rotate 90 degrees clockwise") ?> +<? foreach ($button_list->main as $button): ?> +<a class="<?= $button->class ?> ui-corner-all ui-state-default" href="<?= $button->href ?>" + title="<?= $button->title ?>"> + <span class="ui-icon <?= $button->icon ?>"> + <?= $button->title ?> </span> </a> -<? endif ?> +<? endforeach ?> -<? // Don't move photos from the photo page; we don't yet have a good way of redirecting after move ?> -<? if ($page_type == "album"): ?> -<? if ($item->type == "photo"): ?> -<? $title = t("Move this photo to another album") ?> -<? elseif ($item->type == "movie"): ?> -<? $title = t("Move this movie to another album") ?> -<? elseif ($item->type == "album"): ?> -<? $title = t("Move this album to another album") ?> -<? endif ?> -<a class="gDialogLink gButtonLink ui-corner-all ui-state-default" href="<?= url::site("move/browse/$item->id") ?>" - title="<?= $title ?>"> - <span class="ui-icon ui-icon-folder-open"> - <?= $title ?> - </span> -</a> -<? endif ?> - -<? $disabledState = "" ?> -<? if (access::can("edit", $item->parent())): ?> -<? if ($item->type == "photo"): ?> -<? $title = t("Choose this photo as the album cover") ?> -<? elseif ($item->type == "movie"): ?> -<? $title = t("Choose this movie as the album cover") ?> -<? elseif ($item->type == "album"): ?> -<? if (empty($item->album_cover_item_id)): ?> -<? $disabledState = empty($item->album_cover_item_id) ? " ui-state-disabled" : "" ?> -<? endif ?> -<? $title = t("Choose this album as the album cover") ?> -<? endif ?> -<a class="gButtonLink ui-corner-all ui-state-default<?= $disabledState ?>" href="<?= url::site("quick/make_album_cover/$item->id?csrf=$csrf&page_type=$page_type") ?>" - title="<?= $title ?>"> - <span class="ui-icon ui-icon-star"> - <?= $title ?> - </span> -</a> - -<? if ($item->type == "photo"): ?> -<? $title = t("Delete this photo") ?> -<? elseif ($item->type == "movie"): ?> -<? $title = t("Delete this movie") ?> -<? elseif ($item->type == "album"): ?> -<? $title = t("Delete this album") ?> -<? endif ?> -<a class="gDialogLink gButtonLink ui-corner-all ui-state-default" href="<?= url::site("quick/form_delete/$item->id?page_type=$page_type") ?>" id="gQuickDelete" title="<?= $title ?>"> - <span class="ui-icon ui-icon-trash"> - <?= $title ?> - </span> -</a> -<? endif ?> - -<? if ($item->is_album()): ?> +<? if (!empty($button_list->additional)): ?> <a class="gButtonLink ui-corner-all ui-state-default options" href="#" title="<?= t("additional options") ?>"> <span class="ui-icon ui-icon-triangle-1-s"> <?= t("Additional options") ?> @@ -87,19 +16,11 @@ </a> <ul id="gQuickPaneOptions" style="display: none"> - <li><a class="add_item gDialogLink" href="<?= url::site("simple_uploader/app/$item->id") ?>" - title="<?= t("Add a photo") ?>"> - <?= t("Add a photo") ?> - </a></li> - - <li><a class="add_album gDialogLink" href="<?= url::site("form/add/albums/$item->id?type=album") ?>" - title="<?= t("Add an album") ?>"> - <?= t("Add an album") ?> - </a></li> - - <li><a class="permissions gDialogLink" href="<?= url::site("permissions/browse/$item->id") ?>" - title="<?= t("Edit permissions") ?>"> - <?= t("Edit permissions") ?> + <? foreach ($button_list->additional as $button): ?> + <li><a class="<?= $button->class ?>" href="<?= $button->href ?>" + title="<?= $button->title ?>"> + <?= $button->title ?> </a></li> + <? endforeach ?> </ul> <? endif ?> diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 55b4f458..eee29679 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -1,6 +1,7 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <script type="text/javascript" src="<?= url::file("lib/swfupload/swfupload.js") ?>"></script> <script type="text/javascript" src="<?= url::file("lib/swfupload/swfupload.queue.js") ?>"></script> +<script type="text/javascript" src="<?= url::file("lib/jquery.scrollTo.js") ?>"></script> <!-- hack to set the title for the dialog --> <form id="gAddPhotosForm" action="<?= url::site("simple_uploader/finish?csrf=$csrf") ?>"> @@ -195,6 +196,7 @@ var fp = new File_Progress(file); fp.title.html(file.name); fp.set_status("uploading", "<?= t("Uploading...") ?>"); + $("#gAddPhotosCanvas").scrollTo(fp.box, 1000); return true; // @todo add cancel button to call this.cancelUpload(file.id) } diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index fa21e196..07792322 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -2,106 +2,10 @@ <html> <head> <title><?= t("Gallery3 Upgrader") ?></title> + <link rel="stylesheet" type="text/css" href="<?= url::file("modules/gallery/css/upgrader.css") ?>" + media="screen,print,projection" /> + <script src="<?= url::file("lib/jquery.js") ?>" type="text/javascript"></script> </head> - <style> - body { - background: #eee; - font-family: Trebuchet MS; - font-size: 1.1em; - } - h1 { - font-size: 1.4em; - } - div#outer { - width: 650px; - background: white; - border: 1px solid #999; - margin: 0 auto; - padding: -10px; - } - div#inner { - padding: 0 1em 0 1em; - margin: 0px; - } - div#footer { - border-top: 1px solid #ccc; - margin: 1em; - } - td.name { - text-align: left; - padding-left: 30px; - } - td { - text-align: center; - border-bottom: 1px solid #eee; - } - tr.current td { - color: #999; - font-style: italic; - } - tr.current td.gallery { - color: #00d; - } - tr.upgradeable td { - font-weight: bold; - } - tr.upgradeable td.gallery { - color: #00d; - } - table { - width: 600px; - margin-bottom: 10px; - } - p { - font-size: .9em; - } - ul { - font-size: .9em; - list-style: none; - } - li { - display: inline; - } - li:before { - content: "\00BB \0020"; - } - div.button { - margin: 0 auto; - width: 120px; - text-align: center; - border: 1px solid #999; - background: #eee; - } - div.button a { - text-decoration: none; - } - div.button:hover { - background: #ccc; - } - div#confirmation { - position: fixed; - top: 400px; - left: 325px; - background: blue; - z-index: 1000; - margin: 10px; - text-align: center; - } - div#confirmation div { - margin: 2px; - padding: 20px; - border: 2px solid #999; - background: white; - } - .gray_on_done { - opacity: <?= $done ? "0.5" : "1" ?>; - } - pre { - display: inline; - margin: 0px; - padding: 0px; - } - </style> <body> <div id="outer"> <img src="<?= url::file("modules/gallery/images/gallery.png") ?>" /> @@ -117,6 +21,12 @@ </p> </div> </div> + <script type="text/javascript"> + $(document).ready(function() { + $("#confirmation").css("left", Math.round(($(window).width() - $("#confirmation").width()) / 2)); + $("#confirmation").css("top", Math.round(($(window).height() - $("#confirmation").height()) / 2)); + }); + </script> <? endif ?> <p class="gray_on_done"> <?= t("Welcome to the Gallery upgrader. One click and you're done!") ?> |
