From c791ae96d5bb28f39b26a0e556e10e636f97436c Mon Sep 17 00:00:00 2001 From: momo-i Date: Tue, 1 Feb 2011 07:32:44 +0900 Subject: fixed tag broken --- modules/exif/helpers/exif.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'modules') diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index 1cdf7d34..f752d336 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -37,6 +37,11 @@ class exif_Core { if (isset($exif_raw[$exifvar[0]][$exifvar[1]])) { $value = $exif_raw[$exifvar[0]][$exifvar[1]]; if (function_exists("mb_detect_encoding") && + function_exists("mb_convert_encoding") && + mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { + $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value)); + } + else if (function_exists("mb_detect_encoding") && mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { $value = utf8_encode($value); } @@ -61,6 +66,11 @@ class exif_Core { if (!empty($iptc[$iptc_key])) { $value = implode(" ", $iptc[$iptc_key]); if (function_exists("mb_detect_encoding") && + function_exists("mb_convert_encoding") && + mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { + $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value)); + } + else if (function_exists("mb_detect_encoding") && mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { $value = utf8_encode($value); } -- cgit v1.2.3 From e90493aab36e42e0a69a24a8b1f27e4736e32d20 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Wed, 2 Mar 2011 21:11:49 -0700 Subject: Translate user Web Site label. Link web site on user profile page. --- modules/gallery/helpers/gallery_event.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 07817187..fbdb4ad5 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -539,9 +539,9 @@ class gallery_event_Core { $v = new View("user_profile_info.html"); $fields = array("name" => t("Name"), "locale" => t("Language Preference"), - "email" => t("Email"), "full_name" => t("Full name"), "url" => "Web site"); + "email" => t("Email"), "full_name" => t("Full name"), "url" => t("Web site")); if (!$data->user->guest) { - $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => "Web site"); + $fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => t("Web site")); } $v->user_profile_data = array(); foreach ($fields as $field => $label) { @@ -549,6 +549,8 @@ class gallery_event_Core { $value = $data->user->$field; if ($field == "locale") { $value = locales::display_name($value); + } elseif ($field == "url") { + $value = html::mark_clean(html::anchor($data->user->$field)); } $v->user_profile_data[(string) $label] = $value; } -- cgit v1.2.3 From fa6f233603267505c216abc4f12663d245cd23e7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 27 Mar 2011 11:31:34 -0700 Subject: Centralize our encoding code into a new helpers and use mb_convert_encoding if possible. Build on the work in c791ae96d5bb28f39b26a0e556e10e636f97436c by momo-i. Fixes #1660. --- modules/exif/helpers/exif.php | 20 ++------------------ modules/gallery/helpers/encoding.php | 32 ++++++++++++++++++++++++++++++++ modules/tag/helpers/tag_event.php | 5 +---- 3 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 modules/gallery/helpers/encoding.php (limited to 'modules') diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index f752d336..a35a2141 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -36,15 +36,7 @@ class exif_Core { foreach(self::_keys() as $field => $exifvar) { if (isset($exif_raw[$exifvar[0]][$exifvar[1]])) { $value = $exif_raw[$exifvar[0]][$exifvar[1]]; - if (function_exists("mb_detect_encoding") && - function_exists("mb_convert_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value)); - } - else if (function_exists("mb_detect_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = utf8_encode($value); - } + $value = encoding::convert_to_utf8($value); $keys[$field] = Input::clean($value); if ($field == "DateTime") { @@ -65,15 +57,7 @@ class exif_Core { foreach (array("Keywords" => "2#025", "Caption" => "2#120") as $keyword => $iptc_key) { if (!empty($iptc[$iptc_key])) { $value = implode(" ", $iptc[$iptc_key]); - if (function_exists("mb_detect_encoding") && - function_exists("mb_convert_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value)); - } - else if (function_exists("mb_detect_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = utf8_encode($value); - } + $value = encoding::convert_to_utf8($value); $keys[$keyword] = Input::clean($value); if ($keyword == "Caption" && !$item->description) { diff --git a/modules/gallery/helpers/encoding.php b/modules/gallery/helpers/encoding.php new file mode 100644 index 00000000..c5928634 --- /dev/null +++ b/modules/gallery/helpers/encoding.php @@ -0,0 +1,32 @@ + Date: Thu, 27 Jan 2011 03:05:40 +0100 Subject: Extend comment module field lenghts to fit IPv6 remote host addresses and long (but legally so) hostnames. --- modules/comment/helpers/comment_installer.php | 19 ++++++++++++++++--- modules/comment/models/comment.php | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 48b6ee21..cd20ef72 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -37,8 +37,8 @@ class comment_installer { `server_http_referer` varchar(255) default NULL, `server_http_user_agent` varchar(128) default NULL, `server_query_string` varchar(64) default NULL, - `server_remote_addr` varchar(32) default NULL, - `server_remote_host` varchar(64) default NULL, + `server_remote_addr` varchar(40) default NULL, + `server_remote_host` varchar(255) default NULL, `server_remote_port` varchar(16) default NULL, `state` varchar(15) default 'unpublished', `text` text, @@ -48,7 +48,7 @@ class comment_installer { module::set_var("comment", "spam_caught", 0); module::set_var("comment", "access_permissions", "everybody"); - module::set_version("comment", 3); + module::set_version("comment", 4); } static function upgrade($version) { @@ -62,6 +62,19 @@ class comment_installer { module::set_var("comment", "access_permissions", "everybody"); module::set_version("comment", $version = 3); } + + if ($version == 3) { + /* + 40 bytes for server_remote_addr is enough to swallow the longest + representation of an IPv6 addy. + + 255 bytes for server_remote_host is enough to swallow the longest + legit DNS entry, with a few bytes to spare. + */ + $db->query("ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); + $db->query("ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); + module::set_version("comment", $version = 4); + } } static function uninstall() { diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index d5e952eb..7c189a0e 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -98,8 +98,8 @@ class Comment_Model_Core extends ORM { $this->server_http_referer = substr($input->server("HTTP_REFERER"), 0, 255); $this->server_http_user_agent = substr($input->server("HTTP_USER_AGENT"), 0, 128); $this->server_query_string = substr($input->server("QUERY_STRING"), 0, 64); - $this->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 32); - $this->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 64); + $this->server_remote_addr = substr($input->server("REMOTE_ADDR"), 0, 40); + $this->server_remote_host = substr($input->server("REMOTE_HOST"), 0, 255); $this->server_remote_port = substr($input->server("REMOTE_PORT"), 0, 16); } -- cgit v1.2.3 From c12c43a415cbbe172687f888c1ae388b7f4e4451 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 27 Mar 2011 11:38:37 -0700 Subject: A little more work on kandsten's fix for IPv6 support in 10785b1e820c5e10d982c6b49125903886f7b889: - some style cleanup - bump the module version in module.info - rebuild the installer.sql --- installer/install.sql | 6 +++--- modules/comment/helpers/comment_installer.php | 18 +++++++++--------- modules/comment/module.info | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 865cb2a4..77cda72b 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -67,8 +67,8 @@ CREATE TABLE {comments} ( `server_http_referer` varchar(255) DEFAULT NULL, `server_http_user_agent` varchar(128) DEFAULT NULL, `server_query_string` varchar(64) DEFAULT NULL, - `server_remote_addr` varchar(32) DEFAULT NULL, - `server_remote_host` varchar(64) DEFAULT NULL, + `server_remote_addr` varchar(40) DEFAULT NULL, + `server_remote_host` varchar(255) DEFAULT NULL, `server_remote_port` varchar(16) DEFAULT NULL, `state` varchar(15) DEFAULT 'unpublished', `text` text, @@ -246,7 +246,7 @@ CREATE TABLE {modules} ( /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {modules} VALUES (1,1,'gallery',46,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); -INSERT INTO {modules} VALUES (3,1,'comment',3,3); +INSERT INTO {modules} VALUES (3,1,'comment',4,3); INSERT INTO {modules} VALUES (4,1,'organize',4,4); INSERT INTO {modules} VALUES (5,1,'info',2,5); INSERT INTO {modules} VALUES (6,1,'rss',1,6); diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index cd20ef72..5c6bd586 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -64,15 +64,15 @@ class comment_installer { } if ($version == 3) { - /* - 40 bytes for server_remote_addr is enough to swallow the longest - representation of an IPv6 addy. - - 255 bytes for server_remote_host is enough to swallow the longest - legit DNS entry, with a few bytes to spare. - */ - $db->query("ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); - $db->query("ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); + // 40 bytes for server_remote_addr is enough to swallow the longest + // representation of an IPv6 addy. + // + // 255 bytes for server_remote_host is enough to swallow the longest + // legit DNS entry, with a few bytes to spare. + $db->query( + "ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); + $db->query( + "ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); module::set_version("comment", $version = 4); } } diff --git a/modules/comment/module.info b/modules/comment/module.info index cd34f140..e5aa454d 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,3 @@ name = "Comments" description = "Allows users and guests to leave comments on photos and albums." -version = 3 +version = 4 -- cgit v1.2.3 From 87ce71eb90588a443c05a6b7e378aca8d0e7b3b3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 27 Mar 2011 11:49:36 -0700 Subject: Sort users in group box by name. Thanks edisonnews! Fixes #1662. --- modules/user/views/admin_users_group.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/user/views/admin_users_group.html.php b/modules/user/views/admin_users_group.html.php index 2362e42b..31b91351 100644 --- a/modules/user/views/admin_users_group.html.php +++ b/modules/user/views/admin_users_group.html.php @@ -17,7 +17,7 @@ users->count_all() > 0): ?>
    - users->find_all() as $i => $user): ?> + users->order_by("name", "ASC")->find_all() as $i => $user): ?>
  • name) ?> special): ?> -- cgit v1.2.3 From 7f62f09cf377b92b615e456ec4539300b331fd4b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 27 Mar 2011 13:16:41 -0700 Subject: Improve search to use wildcard matching, thanks to some code from tempg. Fixes #1663. --- modules/search/controllers/search.php | 3 ++- modules/search/helpers/search.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index eef009a0..75cbaa29 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -29,7 +29,8 @@ class Search_Controller extends Controller { $page = 1; } - list ($count, $result) = search::search($q, $page_size, $offset); + $q_with_more_terms = search::add_query_terms($q); + list ($count, $result) = search::search($q_with_more_terms, $page_size, $offset); $max_pages = max(ceil($count / $page_size), 1); diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 09e5e83f..bbde8feb 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -18,6 +18,22 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class search_Core { + /** + * Add more terms to the query by wildcarding the stem value of the first + * few terms in the query. + */ + static function add_query_terms($q) { + $MAX_TERMS = 5; + $terms = explode(" ", $q, $MAX_TERMS); + for ($i = 0; $i < min(count($terms), $MAX_TERMS - 1); $i++) { + // Don't wildcard quoted or already wildcarded terms + if ((substr($terms[$i], 0, 1) != '"') && (substr($terms[$i], -1, 1) != "*")) { + $terms[] = rtrim($terms[$i], "s") . "*"; + } + } + return implode(" ", $terms); + } + static function search($q, $limit, $offset) { $db = Database::instance(); $q = $db->escape($q); -- cgit v1.2.3 From 074f801acdd7d7b1a0a0a5e4ac8c5badfc253cad Mon Sep 17 00:00:00 2001 From: Joe7 Date: Sat, 2 Apr 2011 18:52:54 +0200 Subject: Fix against Ticket #1666 --- modules/tag/helpers/tag_event.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index efef916f..df81ae65 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -110,11 +110,11 @@ class tag_event_Core { } static function add_photos_form($album, $form) { - if (!isset($group->uploadify)) { + $group = $form->add_photos; + if (!is_object($group->uploadify)) { return; } - $group = $form->add_photos; $group->input("tags") ->label(t("Add tags to all uploaded files")) ->value(""); @@ -133,7 +133,8 @@ class tag_event_Core { } static function add_photos_form_completed($album, $form) { - if (!isset($group->uploadify)) { + $group = $form->add_photos; + if (!is_object($group->uploadify)) { return; } -- cgit v1.2.3 From f10648fe0af7c2ae682290812cc78568aea23829 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Sat, 2 Apr 2011 20:56:11 +0200 Subject: Sanitize page value before setting offset based on it --- modules/search/controllers/search.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index 75cbaa29..261d67ee 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -22,13 +22,14 @@ class Search_Controller extends Controller { $page_size = module::get_var("gallery", "page_size", 9); $q = Input::instance()->get("q"); $page = Input::instance()->get("page", 1); - $offset = ($page - 1) * $page_size; // Make sure that the page references a valid offset if ($page < 1) { $page = 1; } + $offset = ($page - 1) * $page_size; + $q_with_more_terms = search::add_query_terms($q); list ($count, $result) = search::search($q_with_more_terms, $page_size, $offset); -- cgit v1.2.3 From 9d8eef143d781c36870532b48599b3da1ad9dd44 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 2 Apr 2011 15:36:50 -0700 Subject: Fix an outdated reference to $entry->file which went away in v4 of the module. Fixes #1669. --- modules/server_add/controllers/server_add.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 2afa93a7..ea8907f4 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -286,7 +286,7 @@ class Server_Add_Controller extends Admin_Controller { } catch (Exception $e) { // This can happen if a photo file is invalid, like a BMP masquerading as a .jpg $entry->item_id = 0; - $task->log("Skipping invalid file: {$entry->file}"); + $task->log("Skipping invalid file: {$entry->path}"); } } -- cgit v1.2.3 From 5931cc872d9ed33467712cb4a970bdbaac798ef9 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Wed, 30 Mar 2011 22:18:06 +0200 Subject: proposed fix for ticket #1664 --- modules/gallery/views/admin_maintenance.html.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index c28def1d..230e9353 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -3,7 +3,9 @@

    +

    maintenance mode which prevents any non-admin from accessing your Gallery. Some of the tasks below will automatically put your Gallery in maintenance mode for you.") ?> +

    • -- cgit v1.2.3 From 1d0f4b7a430e6c7d8d715a42fb391b8e1afbdf19 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sun, 3 Apr 2011 15:44:28 -0500 Subject: [Fixes #1574] Render the login form in the same way in every action This makes sure the "Forgot Your Password?" link appears when the HTML form is initially rendered. --- modules/gallery/controllers/login.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php index b203b7d3..fdf5d7b7 100644 --- a/modules/gallery/controllers/login.php +++ b/modules/gallery/controllers/login.php @@ -42,8 +42,9 @@ class Login_Controller extends Controller { public function html() { $view = new Theme_View("page.html", "other", "login"); - $view->page_title = t("Login"); - $view->content = auth::get_login_form("login/auth_html"); + $view->page_title = t("Log in to Gallery"); + $view->content = new View("login_ajax.html"); + $view->content->form = auth::get_login_form("login/auth_html"); print $view; } -- cgit v1.2.3 From 5b927a7083c8886a42519f9199666431bac0b650 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 4 Apr 2011 17:45:09 -0700 Subject: Guard against registered users removing tags from items they don't own. Fixes #1671. --- modules/tag/helpers/tag_item_rest.php | 1 + modules/tag/helpers/tag_items_rest.php | 1 + 2 files changed, 2 insertions(+) (limited to 'modules') diff --git a/modules/tag/helpers/tag_item_rest.php b/modules/tag/helpers/tag_item_rest.php index a8d3d0bc..be1fa653 100644 --- a/modules/tag/helpers/tag_item_rest.php +++ b/modules/tag/helpers/tag_item_rest.php @@ -29,6 +29,7 @@ class tag_item_rest_Core { static function delete($request) { list ($tag, $item) = rest::resolve($request->url); + access::required("edit", $item); $tag->remove($item); $tag->save(); } diff --git a/modules/tag/helpers/tag_items_rest.php b/modules/tag/helpers/tag_items_rest.php index 535ab513..8ed07276 100644 --- a/modules/tag/helpers/tag_items_rest.php +++ b/modules/tag/helpers/tag_items_rest.php @@ -51,6 +51,7 @@ class tag_items_rest_Core { static function delete($request) { list ($tag, $item) = rest::resolve($request->url); + access::required("edit", $item); $tag->remove($item); $tag->save(); } -- cgit v1.2.3 From 916b7543d13bf33ca704dab18ba3d1eca13d9624 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 10 Apr 2011 13:46:28 -0700 Subject: Gracefully degrade in the case where the .build_number file is missing. Fixes #1673. --- modules/gallery/helpers/gallery.php | 16 +++++++++++----- modules/gallery/helpers/gallery_block.php | 1 + modules/gallery/views/upgrade_checker_block.html.php | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index 1fafdef7..cbd9b33c 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -193,19 +193,25 @@ class gallery_Core { */ static function version_string() { if (gallery::RELEASE_CHANNEL == "git") { + $build_number = gallery::build_number(); return sprintf( - "%s (branch %s build %s)", gallery::VERSION, gallery::RELEASE_BRANCH, - gallery::build_number()); + "%s (branch %s, %s)", gallery::VERSION, gallery::RELEASE_BRANCH, + $build_number ? " build $build_number" : "unknown build number"); } else { return sprintf("%s (%s)", gallery::VERSION, gallery::CODE_NAME); } } /** - * Return the contents of the .build_number file, which should be a single integer. + * Return the contents of the .build_number file, which should be a single integer + * or return null if the .build_number file is missing. */ static function build_number() { - $result = parse_ini_file(DOCROOT . ".build_number"); - return $result["build_number"]; + $build_file = DOCROOT . ".build_number"; + if (file_exists($build_file)) { + $result = parse_ini_file(DOCROOT . ".build_number"); + return $result["build_number"]; + } + return null; } } \ No newline at end of file diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index b9ccf25b..0ba7c936 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -112,6 +112,7 @@ class gallery_block_Core { $block->content->version_info = upgrade_checker::version_info(); $block->content->auto_check_enabled = upgrade_checker::auto_check_enabled(); $block->content->new_version = upgrade_checker::get_upgrade_message(); + $block->content->build_number = gallery::build_number(); } return $block; } diff --git a/modules/gallery/views/upgrade_checker_block.html.php b/modules/gallery/views/upgrade_checker_block.html.php index b04887b2..c984d99f 100644 --- a/modules/gallery/views/upgrade_checker_block.html.php +++ b/modules/gallery/views/upgrade_checker_block.html.php @@ -6,8 +6,10 @@

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

      -- cgit v1.2.3 From 9fe20561068fec04c57f7769aaf9ca5025bdc6ac Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 21 Apr 2011 13:59:03 -0700 Subject: Use window.location = "url" instead of window.location.reload() so that we pop back up to the top of the page so that you see the status message. Fixes #1676. --- modules/gallery/views/admin_modules.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index f4ae965c..2cc81b0d 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -6,7 +6,7 @@ dataType: "json", success: function(data) { if (data.reload) { - window.location.reload(); + window.location = ""; } else { $("body").append('
      ' + data.dialog + '
      '); $("#g-dialog").dialog({ -- cgit v1.2.3 From 1af4f99108ffe1ffc2a3ff723c68c5a12dde0223 Mon Sep 17 00:00:00 2001 From: Chris Kelly Date: Thu, 21 Apr 2011 15:57:18 -0400 Subject: Add missing CSS tag so tables get aligned. Fixes #1678. --- modules/gallery/views/admin_languages.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_languages.html.php b/modules/gallery/views/admin_languages.html.php index 01d1ce3f..eef087e1 100644 --- a/modules/gallery/views/admin_languages.html.php +++ b/modules/gallery/views/admin_languages.html.php @@ -51,7 +51,7 @@ $display_name): ?> - +
      -- cgit v1.2.3 From 5bc0da365221eea08b1525d4cf71371853aa4d15 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 21 Apr 2011 14:33:08 -0700 Subject: Create before_combine and after_combine events to allow modules and themes to interact with the combine list ahead of time, and to be able to do things like minification after it's combined. Fixes #1653. --- modules/gallery/libraries/Gallery_View.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 562f7929..77e3d204 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -111,6 +111,8 @@ class Gallery_View_Core extends View { $contents = $cache->get($key); if (empty($contents)) { + module::event("before_combine", $type, $this->combine_queue[$type][$group]); + $contents = ""; foreach (array_keys($this->combine_queue[$type][$group]) as $path) { if ($type == "css") { @@ -120,6 +122,8 @@ class Gallery_View_Core extends View { } } + module::event("after_combine", $type, $contents); + $cache->set($key, $contents, array($type), 30 * 84600); $use_gzip = function_exists("gzencode") && @@ -128,6 +132,7 @@ class Gallery_View_Core extends View { $cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), array($type, "gzip"), 30 * 84600); } + } unset($this->combine_queue[$type][$group]); @@ -158,6 +163,7 @@ class Gallery_View_Core extends View { $replace[] = "url('" . url::abs_file($relative) . "')"; } else { Kohana_Log::add("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'"); + } } $replace = str_replace(DIRECTORY_SEPARATOR, "/", $replace); -- cgit v1.2.3 From 8cf066b838a98ace3cfa81e02ccc7a8570d1ba7f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 21 Apr 2011 15:43:48 -0700 Subject: Use Tag_Model::url() instead of hand creating tag urls, since the API changed and that broke. Fixe #1680. --- modules/tag/helpers/tag_event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index df81ae65..b415b42d 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -149,7 +149,7 @@ class tag_event_Core { static function info_block_get_metadata($block, $item) { $tags = array(); foreach (tag::item_tags($item) as $tag) { - $tags[] = "name}") . "\">{$tag->name}"; + $tags[] = "url()}\">{$tag->name}"; } if ($tags) { $info = $block->content->metadata; -- cgit v1.2.3 From 08a6df2274ea196056eb7441d4aff050dc3531fa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 21 Apr 2011 15:50:53 -0700 Subject: Normally Router::find_uri() strips off the url suffix for us, but when we make the theme::$is_admin determination we're working off of the PATH_INFO so we need to strip it off manually. Fixes #1631. --- modules/gallery/helpers/theme.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules') diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index f285834c..a42fa7ad 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -41,6 +41,13 @@ class theme_Core { $config = Kohana_Config::instance(); $modules = $config->get("core.modules"); + + // Normally Router::find_uri() strips off the url suffix for us, but we're working off of the + // PATH_INFO here so we need to strip it off manually + if ($suffix = Kohana::config("core.url_suffix")) { + $path = preg_replace("#" . preg_quote($suffix) . "$#u", "", $path); + } + self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7); self::$site_theme_name = module::get_var("gallery", "active_site_theme"); if (self::$is_admin) { -- cgit v1.2.3 From 99fd65ff02d17cbb3ec936b4bdbf2a8c6b0b73e3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Apr 2011 07:55:34 -0700 Subject: Catch the item_updated_data_file() event and rescan. Fixes #1679. --- modules/exif/helpers/exif_event.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules') diff --git a/modules/exif/helpers/exif_event.php b/modules/exif/helpers/exif_event.php index e594c765..72e88041 100644 --- a/modules/exif/helpers/exif_event.php +++ b/modules/exif/helpers/exif_event.php @@ -24,6 +24,12 @@ class exif_event_Core { } } + static function item_updated_data_file($item) { + if (!$item->is_album()) { + exif::extract($item); + } + } + static function item_deleted($item) { db::build() ->delete("exif_records") -- cgit v1.2.3 From 72149b8c68a488e4f935603e6bbf91d2536c2dee Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Apr 2011 08:11:56 -0700 Subject: Urlencode the tag name so that our html is compliant. Fixes #1672. --- modules/tag/models/tag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index 479a7da0..bd665667 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -132,7 +132,7 @@ class Tag_Model_Core extends ORM { * @param string $query the query string (eg "page=3") */ public function url($query=null) { - $url = url::site("tag/{$this->id}/{$this->name}"); + $url = url::site("tag/{$this->id}/" . urlencode($this->name)); if ($query) { $url .= "?$query"; } -- cgit v1.2.3 From 11703b24ffdf38443ac46afbfa65e6f07ec5648e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Apr 2011 09:28:19 -0700 Subject: Detect if the users theme is missing (or missing a theme.info) and in that case fall back to the wind theme. Fixes #1655. --- modules/gallery/helpers/theme.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'modules') diff --git a/modules/gallery/helpers/theme.php b/modules/gallery/helpers/theme.php index a42fa7ad..37707f28 100644 --- a/modules/gallery/helpers/theme.php +++ b/modules/gallery/helpers/theme.php @@ -50,9 +50,25 @@ class theme_Core { self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7); self::$site_theme_name = module::get_var("gallery", "active_site_theme"); + + // If the site theme doesn't exist, fall back to wind. + if (!file_exists(THEMEPATH . self::$site_theme_name . "/theme.info")) { + site_status::error(t("Theme '%name' is missing. Falling back to the Wind theme.", + array("name" => self::$site_theme_name)), "missing_site_theme"); + module::set_var("gallery", "active_site_theme", self::$site_theme_name = "wind"); + } + if (self::$is_admin) { // Load the admin theme self::$admin_theme_name = module::get_var("gallery", "active_admin_theme"); + + // If the admin theme doesn't exist, fall back to admin_wind. + if (!file_exists(THEMEPATH . self::$admin_theme_name . "/theme.info")) { + site_status::error(t("Admin theme '%name' is missing! Falling back to the Wind theme.", + array("name" => self::$admin_theme_name)), "missing_admin_theme"); + module::set_var("gallery", "active_admin_theme", self::$admin_theme_name = "admin_wind"); + } + array_unshift($modules, THEMEPATH . self::$admin_theme_name); // If the site theme has an admin subdir, load that as a module so that -- cgit v1.2.3 From deb7db6486988ce3e41b2fffd010487fbb67a91f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Apr 2011 09:29:25 -0700 Subject: Clear the site status for missing themes when we view this page -- if something goes wrong we'll just add it back again anyway. Follow-on for #1655. --- modules/gallery/controllers/admin_themes.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_themes.php b/modules/gallery/controllers/admin_themes.php index cd8a5530..9cdc3db5 100644 --- a/modules/gallery/controllers/admin_themes.php +++ b/modules/gallery/controllers/admin_themes.php @@ -25,6 +25,9 @@ class Admin_Themes_Controller extends Admin_Controller { $view->content->admin = module::get_var("gallery", "active_admin_theme"); $view->content->site = module::get_var("gallery", "active_site_theme"); $view->content->themes = $this->_get_themes(); + + site_status::clear("missing_site_theme"); + site_status::clear("missing_admin_theme"); print $view; } -- cgit v1.2.3 From 4a9b45c9c3bbd574103e01debcd84cab1a18352a Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Fri, 22 Apr 2011 12:37:28 -0400 Subject: Created apple-touch-icon and added to wind and admin_wind themes. --- installer/install.sql | 1 + lib/images/apple-touch-icon.png | Bin 0 -> 4441 bytes modules/gallery/controllers/admin_theme_options.php | 4 ++++ modules/gallery/helpers/gallery_installer.php | 8 +++++++- modules/gallery/helpers/gallery_theme.php | 5 ++++- modules/gallery/module.info | 2 +- themes/admin_wind/views/admin.html.php | 2 ++ themes/wind/views/page.html.php | 3 ++- 8 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 lib/images/apple-touch-icon.png (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 77cda72b..06d2fcde 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -406,6 +406,7 @@ INSERT INTO {vars} VALUES (NULL,'gallery','admin_area_timeout','5400'); INSERT INTO {vars} VALUES (NULL,'gallery','maintenance_mode','0'); INSERT INTO {vars} VALUES (NULL,'gallery','visible_title_length','15'); INSERT INTO {vars} VALUES (NULL,'gallery','favicon_url','lib/images/favicon.ico'); +INSERT INTO {vars} VALUES (NULL,'gallery','apple_touch_url','lib/images/apple-touch-icon.png'); INSERT INTO {vars} VALUES (NULL,'gallery','email_from','unknown@unknown.com'); INSERT INTO {vars} VALUES (NULL,'gallery','email_reply_to','unknown@unknown.com'); INSERT INTO {vars} VALUES (NULL,'gallery','email_line_length','70'); diff --git a/lib/images/apple-touch-icon.png b/lib/images/apple-touch-icon.png new file mode 100644 index 00000000..d15ce1a6 Binary files /dev/null and b/lib/images/apple-touch-icon.png differ diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 055e063c..840b3b3d 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -59,6 +59,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); module::set_var("gallery", "favicon_url", $form->edit_theme->favicon_url->value); + module::set_var("gallery", "apple_touch_url", $form->edit_theme->apple_touch_url->value); module::event("theme_edit_form_completed", $form); @@ -93,6 +94,9 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $group->input("favicon_url")->label(t("URL (or relative path) to your favicon.ico")) ->id("g-favicon") ->value(module::get_var("gallery", "favicon_url")); + $group->input("apple_touch_url")->label(t("URL (or relative path) to your Apple Touch icon")) + ->id("g-apple-touch") + ->value(module::get_var("gallery", "apple_touch_url")); $group->textarea("header_text")->label(t("Header text"))->id("g-header-text") ->value(module::get_var("gallery", "header_text")); $group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text") diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 01c59eaa..cd9526b1 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -304,6 +304,7 @@ class gallery_installer { module::set_var("gallery", "maintenance_mode", 0); module::set_var("gallery", "visible_title_length", 15); module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); + module::set_var("gallery", "apple_touch_url", "lib/images/apple-touch-icon.png"); module::set_var("gallery", "email_from", ""); module::set_var("gallery", "email_reply_to", ""); module::set_var("gallery", "email_line_length", 70); @@ -311,7 +312,7 @@ class gallery_installer { module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); - module::set_version("gallery", 46); + module::set_version("gallery", 47); } static function upgrade($version) { @@ -677,6 +678,11 @@ class gallery_installer { module::set_var("gallery", "upgrade_checker_auto_enabled", true); module::set_version("gallery", $version = 46); } + + if ($version == 46) { + module::set_var("gallery", "apple_touch_url", "lib/images/apple-touch-icon.png"); + module::set_version("gallery", $version = 47); + } } static function uninstall() { diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index c4a82390..aa3fb7bb 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -60,11 +60,14 @@ class gallery_theme_Core { if ($session->get("debug")) { $buf .= $theme->css("debug.css"); } + if (in_array(URI::instance()->segment(1), array("admin", "admin/dashboard"))) { + $buf .= $theme->script("jquery.jcarousel.min.js"); + } if ($session->get("l10n_mode", false)) { $buf .= $theme->css("l10n_client.css"); $buf .= $theme->script("jquery.cookie.js"); - $buf .=$theme->script("l10n_client.js"); + $buf .= $theme->script("l10n_client.js"); } return $buf; } diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 4c0c8866..aa1dc341 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 46 +version = 47 diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index a56b6f41..0d35ac97 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -15,6 +15,8 @@ " type="image/x-icon" /> + " /> script("jquery.js") ?> script("jquery.form.js") ?> diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 2b86556d..8b9ddf8a 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -21,7 +21,8 @@ " type="image/x-icon" /> - + " /> page_type == "collection"): ?> -- cgit v1.2.3 From 3bce5d00eef5cd6c255ab63bd7391de4557a1784 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Fri, 22 Apr 2011 12:50:21 -0400 Subject: Renamed apple_touch_url to apple_touch_icon_url. --- installer/install.sql | 2 +- modules/gallery/controllers/admin_theme_options.php | 6 +++--- modules/gallery/helpers/gallery_installer.php | 4 ++-- themes/admin_wind/views/admin.html.php | 2 +- themes/wind/views/page.html.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 06d2fcde..c45b421b 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -406,7 +406,7 @@ INSERT INTO {vars} VALUES (NULL,'gallery','admin_area_timeout','5400'); INSERT INTO {vars} VALUES (NULL,'gallery','maintenance_mode','0'); INSERT INTO {vars} VALUES (NULL,'gallery','visible_title_length','15'); INSERT INTO {vars} VALUES (NULL,'gallery','favicon_url','lib/images/favicon.ico'); -INSERT INTO {vars} VALUES (NULL,'gallery','apple_touch_url','lib/images/apple-touch-icon.png'); +INSERT INTO {vars} VALUES (NULL,'gallery','apple_touch_icon_url','lib/images/apple-touch-icon.png'); INSERT INTO {vars} VALUES (NULL,'gallery','email_from','unknown@unknown.com'); INSERT INTO {vars} VALUES (NULL,'gallery','email_reply_to','unknown@unknown.com'); INSERT INTO {vars} VALUES (NULL,'gallery','email_line_length','70'); diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index 840b3b3d..cb46da90 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -59,7 +59,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value); module::set_var("gallery", "favicon_url", $form->edit_theme->favicon_url->value); - module::set_var("gallery", "apple_touch_url", $form->edit_theme->apple_touch_url->value); + module::set_var("gallery", "apple_touch_icon_url", $form->edit_theme->apple_touch_icon_url->value); module::event("theme_edit_form_completed", $form); @@ -94,9 +94,9 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $group->input("favicon_url")->label(t("URL (or relative path) to your favicon.ico")) ->id("g-favicon") ->value(module::get_var("gallery", "favicon_url")); - $group->input("apple_touch_url")->label(t("URL (or relative path) to your Apple Touch icon")) + $group->input("apple_touch_icon_url")->label(t("URL (or relative path) to your Apple Touch icon")) ->id("g-apple-touch") - ->value(module::get_var("gallery", "apple_touch_url")); + ->value(module::get_var("gallery", "apple_touch_icon_url")); $group->textarea("header_text")->label(t("Header text"))->id("g-header-text") ->value(module::get_var("gallery", "header_text")); $group->textarea("footer_text")->label(t("Footer text"))->id("g-footer-text") diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index cd9526b1..20de1fea 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -304,7 +304,7 @@ class gallery_installer { module::set_var("gallery", "maintenance_mode", 0); module::set_var("gallery", "visible_title_length", 15); module::set_var("gallery", "favicon_url", "lib/images/favicon.ico"); - module::set_var("gallery", "apple_touch_url", "lib/images/apple-touch-icon.png"); + module::set_var("gallery", "apple_touch_icon_url", "lib/images/apple-touch-icon.png"); module::set_var("gallery", "email_from", ""); module::set_var("gallery", "email_reply_to", ""); module::set_var("gallery", "email_line_length", 70); @@ -680,7 +680,7 @@ class gallery_installer { } if ($version == 46) { - module::set_var("gallery", "apple_touch_url", "lib/images/apple-touch-icon.png"); + module::set_var("gallery", "apple_touch_icon_url", "lib/images/apple-touch-icon.png"); module::set_version("gallery", $version = 47); } } diff --git a/themes/admin_wind/views/admin.html.php b/themes/admin_wind/views/admin.html.php index 0d35ac97..12301e02 100644 --- a/themes/admin_wind/views/admin.html.php +++ b/themes/admin_wind/views/admin.html.php @@ -16,7 +16,7 @@ href="" type="image/x-icon" /> " /> + href="" /> script("jquery.js") ?> script("jquery.form.js") ?> diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 8b9ddf8a..1c67ff9d 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -22,7 +22,7 @@ href="" type="image/x-icon" /> " /> + href="" /> page_type == "collection"): ?> -- cgit v1.2.3 From 7deed8654549690ec7d5c7d9dd5ad479d9f0fdd8 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Fri, 22 Apr 2011 12:54:25 -0400 Subject: Removed incomplete jquery carousel code --- modules/gallery/helpers/gallery_theme.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index aa3fb7bb..e07839d9 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -60,9 +60,6 @@ class gallery_theme_Core { if ($session->get("debug")) { $buf .= $theme->css("debug.css"); } - if (in_array(URI::instance()->segment(1), array("admin", "admin/dashboard"))) { - $buf .= $theme->script("jquery.jcarousel.min.js"); - } if ($session->get("l10n_mode", false)) { $buf .= $theme->css("l10n_client.css"); -- cgit v1.2.3 From 526859d9605d137ebe053ecbd80f46ca6a331194 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Apr 2011 13:56:32 -0700 Subject: Do simple transliteration when converting filenames to slugs, but check to see if the transliteration module is available and use a more complex transliteration if possible. Fixes #1668. --- modules/gallery/helpers/item.php | 12 +++++++++++- modules/gallery/models/item.php | 4 +--- modules/gallery/tests/Item_Helper_Test.php | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 1a5c631e..7e779544 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -152,8 +152,18 @@ class item_Core { * @param string $filename */ static function convert_filename_to_slug($filename) { - $result = pathinfo($filename, PATHINFO_FILENAME); + $result = str_replace("&", "-and-", $filename); + $result = str_replace(" ", "-", $result); + + // It's not easy to extend the text helper since it's called by the Input class which is + // referenced in hooks/init_gallery, so it's + if (class_exists("transliterate")) { + $result = transliterate::utf8_to_ascii($result); + } else { + $result = text::transliterate_to_ascii($result); + } $result = preg_replace("/[^A-Za-z0-9-_]+/", "-", $result); + $result = preg_replace("/-+/", "-", $result); return trim($result, "-"); } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 8f4bc5e4..f46db696 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -336,9 +336,7 @@ class Item_Model_Core extends ORM_MPTT { // Make an url friendly slug from the name, if necessary if (empty($this->slug)) { - $tmp = pathinfo($this->name, PATHINFO_FILENAME); - $tmp = preg_replace("/[^A-Za-z0-9-_]+/", "-", $tmp); - $this->slug = trim($tmp, "-"); + $this->slug = item::convert_filename_to_slug($this->name); // If the filename is all invalid characters, then the slug may be empty here. Pick a // random value. diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php index 4d5aed41..2fde7cc0 100644 --- a/modules/gallery/tests/Item_Helper_Test.php +++ b/modules/gallery/tests/Item_Helper_Test.php @@ -49,6 +49,10 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case { public function convert_filename_to_slug_test() { $this->assert_equal("foo", item::convert_filename_to_slug("{[foo]}")); $this->assert_equal("foo-bar", item::convert_filename_to_slug("{[foo!@#!$@#^$@($!(@bar]}")); + $this->assert_equal("english-text", item::convert_filename_to_slug("english text")); + $this->assert_equal("new-line", item::convert_filename_to_slug("new \n line")); + $this->assert_equal("foo-and-bar", item::convert_filename_to_slug("foo&bar")); + $this->assert_equal("special", item::convert_filename_to_slug("šṗëçîąļ")); } public function move_test() { -- cgit v1.2.3 From d7e299015222ba20ed6df7c572fb8bca7e252010 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Apr 2011 15:02:30 -0700 Subject: Insure that the number of items for a page is greater than zero. Fixes ticket 1644. --- modules/gallery/controllers/admin_theme_options.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index cb46da90..a968a56d 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -78,8 +78,10 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $group = $form->group("edit_theme")->label(t("Theme layout")); $group->input("page_size")->label(t("Items per page"))->id("g-page-size") ->rules("required|valid_digit") + ->callback(array($this, "_valididate_page_size")) ->error_messages("required", t("You must enter a number")) ->error_messages("valid_digit", t("You must enter a number")) + ->error_messages("valid_min_value", t("The value must be greater than zero")) ->value(module::get_var("gallery", "page_size")); $group->input("thumb_size")->label(t("Thumbnail size (in pixels)"))->id("g-thumb-size") ->rules("required|valid_digit") @@ -110,5 +112,12 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $group->submit("")->value(t("Save")); return $form; } + + function _valididate_page_size($input) { + if ($input->value < 1) { + $input->add_error("valid_min_value", true); + } + + } } -- cgit v1.2.3 From 6f916e49d5b431c2c1961a13d1a61fef8c02d628 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Fri, 22 Apr 2011 18:15:17 -0400 Subject: Allow timezone to be configurable * Fixes #1637 * New advanced setting gallery/timezone * Default setting comes from PHP --- modules/gallery/config/locale.php | 8 ++------ modules/gallery/helpers/gallery_installer.php | 7 +++++++ modules/gallery/module.info | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/config/locale.php b/modules/gallery/config/locale.php index 0509e45f..13de9098 100644 --- a/modules/gallery/config/locale.php +++ b/modules/gallery/config/locale.php @@ -29,14 +29,10 @@ $config['language'] = array('en_US', 'English_United States'); /** - * Locale timezone. Defaults to use the server timezone. + * Locale timezone. Set in 'Advanced' settings, falling back to the server's zone. * @see http://php.net/timezones */ -$config['timezone'] = ini_get('date.timezone'); -if (empty($config['timezone'])) { - // This is a required field. Pick something as a default. - $config['timezone'] = "America/Los_Angeles"; -} +$config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get()); // i18n settings diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 20de1fea..2cb04356 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -683,6 +683,13 @@ class gallery_installer { module::set_var("gallery", "apple_touch_icon_url", "lib/images/apple-touch-icon.png"); module::set_version("gallery", $version = 47); } + + if ($version == 47) { + // Add configuration variable to set timezone. Defaults to the currently + // used timezone (from PHP configuration). + module::set_var("gallery", "timezone", Kohana::config('locale.timezone')); + module::set_version("gallery", $version = 48); + } } static function uninstall() { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index aa1dc341..807d08fd 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 47 +version = 48 -- cgit v1.2.3 From b07bc1af082ea097adb77d2e78e69af3e20d8d29 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Apr 2011 16:15:56 -0700 Subject: Allow the administrator to set the number of tags to display in the cloud via the advanced settings. Fixes ticket #1649. --- installer/install.sql | 143 +++++++++++++++++----------------- modules/tag/controllers/tags.php | 3 +- modules/tag/helpers/tag_block.php | 2 +- modules/tag/helpers/tag_installer.php | 7 +- modules/tag/module.info | 2 +- 5 files changed, 82 insertions(+), 75 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 5dc09cca..ff29e1a0 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS {access_caches}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {access_caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -13,11 +13,11 @@ CREATE TABLE {access_caches} ( PRIMARY KEY (`id`), KEY `item_id` (`item_id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {access_caches} VALUES (1,1,'1','0','0','1','0','0'); DROP TABLE IF EXISTS {access_intents}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {access_intents} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -31,11 +31,11 @@ CREATE TABLE {access_intents} ( `add_2` binary(1) DEFAULT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {access_intents} VALUES (1,1,'1','1','0','0','1','1','0','0'); DROP TABLE IF EXISTS {caches}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, @@ -46,10 +46,10 @@ CREATE TABLE {caches} ( UNIQUE KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {comments}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {comments} ( `author_id` int(9) DEFAULT NULL, `created` int(9) NOT NULL, @@ -75,10 +75,10 @@ CREATE TABLE {comments} ( `updated` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {failed_auths}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {failed_auths} ( `id` int(9) NOT NULL AUTO_INCREMENT, `count` int(9) NOT NULL, @@ -86,10 +86,10 @@ CREATE TABLE {failed_auths} ( `time` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {graphics_rules}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {graphics_rules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -100,12 +100,12 @@ CREATE TABLE {graphics_rules} ( `target` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'thumb'); INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:640;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'resize'); DROP TABLE IF EXISTS {groups}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {groups} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` char(64) DEFAULT NULL, @@ -113,25 +113,25 @@ CREATE TABLE {groups} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {groups} VALUES (1,'Everybody',1); INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {groups_users} ( `group_id` int(9) NOT NULL, `user_id` int(9) NOT NULL, PRIMARY KEY (`group_id`,`user_id`), UNIQUE KEY `user_id` (`user_id`,`group_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {groups_users} VALUES (1,1); INSERT INTO {groups_users} VALUES (1,2); INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {incoming_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` char(32) NOT NULL, @@ -143,10 +143,10 @@ CREATE TABLE {incoming_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {items}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {items} ( `id` int(9) NOT NULL AUTO_INCREMENT, `album_cover_item_id` int(9) DEFAULT NULL, @@ -188,11 +188,11 @@ CREATE TABLE {items} ( KEY `weight` (`weight`), KEY `left_ptr` (`left_ptr`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {items} VALUES (1,NULL,NULL,UNIX_TIMESTAMP(),'',NULL,1,1,NULL,NULL,2,0,NULL,'','',1,NULL,NULL,2,NULL,'weight','ASC',1,NULL,NULL,'Gallery','album',UNIX_TIMESTAMP(),0,1,NULL,'1','1'); DROP TABLE IF EXISTS {items_tags}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {items_tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) NOT NULL, @@ -201,10 +201,10 @@ CREATE TABLE {items_tags} ( KEY `tag_id` (`tag_id`,`id`), KEY `item_id` (`item_id`,`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {logs}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {logs} ( `id` int(9) NOT NULL AUTO_INCREMENT, `category` varchar(64) DEFAULT NULL, @@ -217,10 +217,10 @@ CREATE TABLE {logs} ( `user_id` int(9) DEFAULT '0', PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {messages}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {messages} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) DEFAULT NULL, @@ -229,10 +229,10 @@ CREATE TABLE {messages} ( PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {modules}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {modules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -243,7 +243,7 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`), KEY `weight` (`weight`) ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {modules} VALUES (1,1,'gallery',47,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); INSERT INTO {modules} VALUES (3,1,'comment',4,3); @@ -252,10 +252,10 @@ INSERT INTO {modules} VALUES (5,1,'info',2,5); INSERT INTO {modules} VALUES (6,1,'rss',1,6); INSERT INTO {modules} VALUES (7,1,'search',1,7); INSERT INTO {modules} VALUES (8,1,'slideshow',2,8); -INSERT INTO {modules} VALUES (9,1,'tag',2,9); +INSERT INTO {modules} VALUES (9,1,'tag',3,9); DROP TABLE IF EXISTS {outgoing_translations}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {outgoing_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `base_revision` int(9) DEFAULT NULL, @@ -267,10 +267,10 @@ CREATE TABLE {outgoing_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {permissions}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {permissions} ( `id` int(9) NOT NULL AUTO_INCREMENT, `display_name` varchar(64) DEFAULT NULL, @@ -278,14 +278,14 @@ CREATE TABLE {permissions} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {permissions} VALUES (1,'View','view'); INSERT INTO {permissions} VALUES (2,'View full size','view_full'); INSERT INTO {permissions} VALUES (3,'Edit','edit'); INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {search_records} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -295,21 +295,21 @@ CREATE TABLE {search_records} ( KEY `item_id` (`item_id`), FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {search_records} VALUES (1,1,0,' Gallery'); DROP TABLE IF EXISTS {sessions}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {sessions} ( `session_id` varchar(127) NOT NULL, `data` text NOT NULL, `last_activity` int(10) unsigned NOT NULL, PRIMARY KEY (`session_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {tags}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, @@ -317,10 +317,10 @@ CREATE TABLE {tags} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {tasks}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {tasks} ( `id` int(9) NOT NULL AUTO_INCREMENT, `callback` varchar(128) DEFAULT NULL, @@ -335,10 +335,10 @@ CREATE TABLE {tasks} ( PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {themes}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {themes} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(64) DEFAULT NULL, @@ -346,12 +346,12 @@ CREATE TABLE {themes} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {themes} VALUES (1,'wind',1); INSERT INTO {themes} VALUES (2,'admin_wind',1); DROP TABLE IF EXISTS {users}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {users} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, @@ -369,12 +369,12 @@ CREATE TABLE {users} ( UNIQUE KEY `name` (`name`), UNIQUE KEY `hash` (`hash`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,'unknown@unknown.com',1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {vars} ( `id` int(9) NOT NULL AUTO_INCREMENT, `module_name` varchar(64) NOT NULL, @@ -382,8 +382,8 @@ CREATE TABLE {vars} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) AUTO_INCREMENT=41 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +) AUTO_INCREMENT=42 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); INSERT INTO {vars} VALUES (NULL,'gallery','page_size','9'); @@ -424,3 +424,4 @@ INSERT INTO {vars} VALUES (NULL,'info','show_owner','1'); INSERT INTO {vars} VALUES (NULL,'info','show_name','1'); INSERT INTO {vars} VALUES (NULL,'info','show_captured','1'); INSERT INTO {vars} VALUES (NULL,'slideshow','max_scale','0'); +INSERT INTO {vars} VALUES (NULL,'tag','tag_cloud_size','30'); diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index fe6d747b..bf41c4df 100644 --- a/modules/tag/controllers/tags.php +++ b/modules/tag/controllers/tags.php @@ -22,7 +22,8 @@ class Tags_Controller extends Controller { // Far from perfection, but at least require view permission for the root album $album = ORM::factory("item", 1); access::required("view", $album); - print tag::cloud(30); + + print tag::cloud(module::get_var("tag", "tag_cloud_size", 30)); } public function create($item_id) { diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php index 8df58a6e..69a9a1c4 100644 --- a/modules/tag/helpers/tag_block.php +++ b/modules/tag/helpers/tag_block.php @@ -30,7 +30,7 @@ class tag_block_Core { $block->css_id = "g-tag"; $block->title = t("Popular tags"); $block->content = new View("tag_block.html"); - $block->content->cloud = tag::cloud(30); + $block->content->cloud = tag::cloud(module::get_var("tag", "tag_cloud_size", 30)); if ($theme->item() && $theme->page_subtype() != "tag" && access::can("edit", $theme->item())) { $controller = new Tags_Controller(); diff --git a/modules/tag/helpers/tag_installer.php b/modules/tag/helpers/tag_installer.php index 16ad1239..66a78b91 100644 --- a/modules/tag/helpers/tag_installer.php +++ b/modules/tag/helpers/tag_installer.php @@ -36,7 +36,8 @@ class tag_installer { KEY(`tag_id`, `id`), KEY(`item_id`, `id`)) DEFAULT CHARSET=utf8;"); - module::set_version("tag", 2); + module::set_var("tag", "tag_cloud_size", 30); + module::set_version("tag", 3); } static function upgrade($version) { @@ -45,6 +46,10 @@ class tag_installer { $db->query("ALTER TABLE {tags} MODIFY COLUMN `name` VARCHAR(128)"); module::set_version("tag", $version = 2); } + if ($version == 2) { + module::set_var("tag", "tag_cloud_size", 30); + module::set_version("tag", $version = 3); + } } static function uninstall() { diff --git a/modules/tag/module.info b/modules/tag/module.info index 8851d119..d9d34386 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -1,3 +1,3 @@ name = "Tags" description = "Allows users to tag photos and albums" -version = 2 +version = 3 -- cgit v1.2.3 From 5040adebb5c4e1e491fbb6c3b98783f5809020a3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Apr 2011 16:30:37 -0700 Subject: Totally revamp the G2 Import UI to make it sexxxy. Fixes #1683. --- modules/g2_import/controllers/admin_g2_import.php | 44 ++++-- modules/g2_import/helpers/g2_import.php | 21 ++- modules/g2_import/helpers/g2_import_task.php | 2 +- modules/g2_import/views/admin_g2_import.html.php | 162 +++++++++++++--------- 4 files changed, 151 insertions(+), 78 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 33186fb5..55a75a3b 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -24,23 +24,42 @@ class Admin_g2_import_Controller extends Admin_Controller { g2_import::init(); } - if (class_exists("GalleryCoreApi")) { - $g2_stats = g2_import::stats(); - $g2_sizes = g2_import::common_sizes(); - } - $view = new Admin_View("admin.html"); $view->page_title = t("Gallery 2 import"); $view->content = new View("admin_g2_import.html"); + + if (class_exists("GalleryCoreApi")) { + $view->content->g2_stats = $g2_stats = g2_import::g2_stats(); + $view->content->g3_stats = $g3_stats = g2_import::g3_stats(); + $view->content->g2_sizes = g2_import::common_sizes(); + $view->content->g2_version = g2_import::version(); + + // Don't count tags because we don't track them in g2_map + $view->content->g2_resource_count = + $g2_stats["users"] + $g2_stats["groups"] + $g2_stats["albums"] + + $g2_stats["photos"] + $g2_stats["movies"] + $g2_stats["comments"]; + $view->content->g3_resource_count = + $g3_stats["user"] + $g3_stats["group"] + $g3_stats["album"] + + $g3_stats["item"] + $g3_stats["comment"] + $g3_stats["tag"]; + } + $view->content->form = $this->_get_import_form(); $view->content->version = ""; + $view->content->thumb_size = module::get_var("gallery", "thumb_size"); + $view->content->resize_size = module::get_var("gallery", "resize_size"); if (g2_import::is_initialized()) { - $view->content->g2_stats = $g2_stats; - $view->content->g2_sizes = $g2_sizes; - $view->content->thumb_size = module::get_var("gallery", "thumb_size"); - $view->content->resize_size = module::get_var("gallery", "resize_size"); - $view->content->version = g2_import::version(); + if ((bool)ini_get("eaccelerator.enable") || (bool)ini_get("xcache.cacher")) { + message::warning(t("The eAccelerator and XCache PHP performance extensions are known to cause issues. If you're using either of those and are having problems, please disable them while you do your import. Add the following lines:
      %lines
      to gallery3/.htaccess and remove them when the import is done.", array("lines" => "\n\n php_value eaccelerator.enable 0\n php_value xcache.cacher off\n php_value xcache.optimizer off\n\n"))); + } + + foreach (array("notification", "search", "exif") as $module_id) { + if (module::is_active($module_id)) { + message::warning( + t("Deactivating the %module_id module during your import will make it faster", + array("url" => url::site("admin/modules"), "module_id" => $module_id))); + } + } } else if (g2_import::is_configured()) { $view->content->form->configure_g2_import->embed_path->add_error("invalid", 1); } @@ -76,14 +95,15 @@ class Admin_g2_import_Controller extends Admin_Controller { } private function _get_import_form() { + $embed_path = module::get_var("g2_import", "embed_path", ""); $form = new Forge( "admin/g2_import/save", "", "post", array("id" => "g-admin-configure-g2-import-form")); $group = $form->group("configure_g2_import")->label(t("Configure Gallery 2 Import")); $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file")) - ->value(module::get_var("g2_import", "embed_path", "")); + ->value($embed_path); $group->embed_path->error_messages( "invalid", t("The path you entered is not a Gallery 2 installation.")); - $group->submit("")->value(t("Save")); + $group->submit("")->value($embed_path ? t("Change") : t("Continue")); return $form; } } \ No newline at end of file diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 22fb68c6..23fb29e5 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -219,7 +219,7 @@ class g2_import_Core { * Return a set of statistics about the number of users, groups, albums, photos, movies and * comments available for import from the Gallery 2 instance. */ - static function stats() { + static function g2_stats() { global $gallery; $root_album_id = g2(GalleryCoreApi::getDefaultAlbumId()); $stats["users"] = g2(GalleryCoreApi::fetchUserCount()); @@ -247,6 +247,25 @@ class g2_import_Core { return $stats; } + /** + * Return a set of statistics about the number of users, groups, albums, photos, movies and + * comments already imported into the Gallery 3 instance. + */ + static function g3_stats() { + $g3_stats = array( + "album" => 0, "comment" => 0, "item" => 0, "user" => 0, "group" => 0, "tag" => 0); + foreach (db::build() + ->select("resource_type") + ->select(array("C" => 'COUNT("*")')) + ->from("g2_maps") + ->where("resource_type", "IN", array("album", "comment", "item", "user", "group")) + ->group_by("resource_type") + ->execute() as $row) { + $g3_stats[$row->resource_type] = $row->C; + } + return $g3_stats; + } + /** * Import a single group. */ diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php index 6bda8f17..5e908676 100644 --- a/modules/g2_import/helpers/g2_import_task.php +++ b/modules/g2_import/helpers/g2_import_task.php @@ -56,7 +56,7 @@ class g2_import_task_Core { $mode = $task->get("mode"); $queue = $task->get("queue"); if (!isset($mode)) { - $stats = g2_import::stats(); + $stats = g2_import::g2_stats(); $stats["items"] = $stats["photos"] + $stats["movies"]; unset($stats["photos"]); unset($stats["movies"]); diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index cb13363a..20b243d5 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -5,20 +5,43 @@

      -
      - -
      - -
      - -
      -

      -
        -
      • - $version)) ?> + +
        +
          +
        • + +
        • +
        • + +
        • +
        • + +
        • +
        +
        + +
        +
        + +
          +
        • + $g2_version)) ?>
        • -
        • +
        • Using the same value will speed up your import.", array("g2_pixels" => $g2_sizes["thumb"]["size"], "g3_pixels" => $thumb_size, @@ -27,73 +50,84 @@ -
        • +
        • Using the same value will speed up your import.", - array("g2_pixels" => $g2_sizes["resize"]["size"], - "g3_pixels" => $resize_size, - "url" => html::mark_clean(url::site("admin/theme_options")))) ?> + array("g2_pixels" => $g2_sizes["resize"]["size"], + "g3_pixels" => $resize_size, + "url" => html::mark_clean(url::site("admin/theme_options")))) ?>
        • -
        • - -

          - , - , - , - , - , - , - -

          +
        • + + $t[0], "t1" => $t[1], "t2" => $t[2], + "t3" => $t[3], "t4" => $t[4], "t5" => $t[5])) ?>
        • -
        + +
      • + + $t[0], "t1" => $t[1], "t2" => $t[2], + "t3" => $t[3], "t4" => $t[4], "t5" => $t[5])) ?> +
      • + +

      ">

      +
      +
      +
        +
      • + Review permissions!") ?> +
      • +
      • + +
      • +
      • +

        + +

        -
        -
        -

        -
          -
        • - Review permissions after your import is done.") ?> -
        • -
        • - -
        • -
        • - notification, search and exif modules during your import will make it go faster.") ?> -
        • -
        • - %lines to gallery3/.htaccess and remove them when the import is done.", array("lines" => "\n\n php_value eaccelerator.enable 0\n php_value xcache.cacher off\n php_value xcache.optimizer off\n\n")) ?> -
        • -
        -
        -
        - -
        -
        -

        -

        - -

        - - -
        - + RewriteRule ^(.*)$ [QSA,L,R=301] + </IfModule> + +
      • +
      -- cgit v1.2.3 From c2a38087dcd77bf8c1e7a5ff81692502bdb3ff59 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 22 Apr 2011 16:52:48 -0700 Subject: A few more fixes for #1637: - Update gallery_installer::install() to set the version to 48 and set the timezone - Rebuild installer.sql --- installer/install.sql | 143 +++++++++++++------------- modules/gallery/helpers/gallery_installer.php | 5 +- 2 files changed, 75 insertions(+), 73 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index ff29e1a0..de5250d1 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS {access_caches}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {access_caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -13,11 +13,11 @@ CREATE TABLE {access_caches} ( PRIMARY KEY (`id`), KEY `item_id` (`item_id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {access_caches} VALUES (1,1,'1','0','0','1','0','0'); DROP TABLE IF EXISTS {access_intents}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {access_intents} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -31,11 +31,11 @@ CREATE TABLE {access_intents} ( `add_2` binary(1) DEFAULT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {access_intents} VALUES (1,1,'1','1','0','0','1','1','0','0'); DROP TABLE IF EXISTS {caches}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, @@ -46,10 +46,10 @@ CREATE TABLE {caches} ( UNIQUE KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {comments}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {comments} ( `author_id` int(9) DEFAULT NULL, `created` int(9) NOT NULL, @@ -75,10 +75,10 @@ CREATE TABLE {comments} ( `updated` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {failed_auths}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {failed_auths} ( `id` int(9) NOT NULL AUTO_INCREMENT, `count` int(9) NOT NULL, @@ -86,10 +86,10 @@ CREATE TABLE {failed_auths} ( `time` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {graphics_rules}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {graphics_rules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -100,12 +100,12 @@ CREATE TABLE {graphics_rules} ( `target` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'thumb'); INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:640;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'resize'); DROP TABLE IF EXISTS {groups}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {groups} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` char(64) DEFAULT NULL, @@ -113,25 +113,25 @@ CREATE TABLE {groups} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {groups} VALUES (1,'Everybody',1); INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {groups_users} ( `group_id` int(9) NOT NULL, `user_id` int(9) NOT NULL, PRIMARY KEY (`group_id`,`user_id`), UNIQUE KEY `user_id` (`user_id`,`group_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {groups_users} VALUES (1,1); INSERT INTO {groups_users} VALUES (1,2); INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {incoming_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` char(32) NOT NULL, @@ -143,10 +143,10 @@ CREATE TABLE {incoming_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {items}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {items} ( `id` int(9) NOT NULL AUTO_INCREMENT, `album_cover_item_id` int(9) DEFAULT NULL, @@ -188,11 +188,11 @@ CREATE TABLE {items} ( KEY `weight` (`weight`), KEY `left_ptr` (`left_ptr`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {items} VALUES (1,NULL,NULL,UNIX_TIMESTAMP(),'',NULL,1,1,NULL,NULL,2,0,NULL,'','',1,NULL,NULL,2,NULL,'weight','ASC',1,NULL,NULL,'Gallery','album',UNIX_TIMESTAMP(),0,1,NULL,'1','1'); DROP TABLE IF EXISTS {items_tags}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {items_tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) NOT NULL, @@ -201,10 +201,10 @@ CREATE TABLE {items_tags} ( KEY `tag_id` (`tag_id`,`id`), KEY `item_id` (`item_id`,`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {logs}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {logs} ( `id` int(9) NOT NULL AUTO_INCREMENT, `category` varchar(64) DEFAULT NULL, @@ -217,10 +217,10 @@ CREATE TABLE {logs} ( `user_id` int(9) DEFAULT '0', PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {messages}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {messages} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) DEFAULT NULL, @@ -229,10 +229,10 @@ CREATE TABLE {messages} ( PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {modules}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {modules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -243,8 +243,8 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`), KEY `weight` (`weight`) ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; -INSERT INTO {modules} VALUES (1,1,'gallery',47,1); +/*!40101 SET character_set_client = @saved_cs_client */; +INSERT INTO {modules} VALUES (1,1,'gallery',48,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); INSERT INTO {modules} VALUES (3,1,'comment',4,3); INSERT INTO {modules} VALUES (4,1,'organize',4,4); @@ -254,8 +254,8 @@ INSERT INTO {modules} VALUES (7,1,'search',1,7); INSERT INTO {modules} VALUES (8,1,'slideshow',2,8); INSERT INTO {modules} VALUES (9,1,'tag',3,9); DROP TABLE IF EXISTS {outgoing_translations}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {outgoing_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `base_revision` int(9) DEFAULT NULL, @@ -267,10 +267,10 @@ CREATE TABLE {outgoing_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {permissions}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {permissions} ( `id` int(9) NOT NULL AUTO_INCREMENT, `display_name` varchar(64) DEFAULT NULL, @@ -278,14 +278,14 @@ CREATE TABLE {permissions} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {permissions} VALUES (1,'View','view'); INSERT INTO {permissions} VALUES (2,'View full size','view_full'); INSERT INTO {permissions} VALUES (3,'Edit','edit'); INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {search_records} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -295,21 +295,21 @@ CREATE TABLE {search_records} ( KEY `item_id` (`item_id`), FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {search_records} VALUES (1,1,0,' Gallery'); DROP TABLE IF EXISTS {sessions}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {sessions} ( `session_id` varchar(127) NOT NULL, `data` text NOT NULL, `last_activity` int(10) unsigned NOT NULL, PRIMARY KEY (`session_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {tags}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, @@ -317,10 +317,10 @@ CREATE TABLE {tags} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {tasks}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {tasks} ( `id` int(9) NOT NULL AUTO_INCREMENT, `callback` varchar(128) DEFAULT NULL, @@ -335,10 +335,10 @@ CREATE TABLE {tasks} ( PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {themes}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {themes} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(64) DEFAULT NULL, @@ -346,12 +346,12 @@ CREATE TABLE {themes} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {themes} VALUES (1,'wind',1); INSERT INTO {themes} VALUES (2,'admin_wind',1); DROP TABLE IF EXISTS {users}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {users} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, @@ -369,12 +369,12 @@ CREATE TABLE {users} ( UNIQUE KEY `name` (`name`), UNIQUE KEY `hash` (`hash`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,'unknown@unknown.com',1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {vars} ( `id` int(9) NOT NULL AUTO_INCREMENT, `module_name` varchar(64) NOT NULL, @@ -382,8 +382,8 @@ CREATE TABLE {vars} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) AUTO_INCREMENT=42 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +) AUTO_INCREMENT=43 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); INSERT INTO {vars} VALUES (NULL,'gallery','page_size','9'); @@ -413,6 +413,7 @@ INSERT INTO {vars} VALUES (NULL,'gallery','email_line_length','70'); INSERT INTO {vars} VALUES (NULL,'gallery','email_header_separator','s:1:\"\n\";'); INSERT INTO {vars} VALUES (NULL,'gallery','show_user_profiles_to','registered_users'); INSERT INTO {vars} VALUES (NULL,'gallery','extra_binary_paths','/usr/local/bin:/opt/local/bin:/opt/bin'); +INSERT INTO {vars} VALUES (NULL,'gallery','timezone','PST8PDT'); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:4:{i:10;a:2:{i:0;s:7:\"gallery\";i:1;s:8:\"language\";}i:11;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:12;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:13;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}'); INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user'); INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5'); diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 2cb04356..83c5ed71 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -311,8 +311,9 @@ class gallery_installer { module::set_var("gallery", "email_header_separator", serialize("\n")); module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); + module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); - module::set_version("gallery", 47); + module::set_version("gallery", 48); } static function upgrade($version) { @@ -687,7 +688,7 @@ class gallery_installer { if ($version == 47) { // Add configuration variable to set timezone. Defaults to the currently // used timezone (from PHP configuration). - module::set_var("gallery", "timezone", Kohana::config('locale.timezone')); + module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); module::set_version("gallery", $version = 48); } } -- cgit v1.2.3 From fa4fb20f8036745a4999d05ccb2fe285a891f3a8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 06:50:47 -0700 Subject: If we've cleared out the last group in a combine_queue for a given type, unset the combine_queue for that type entirely. This way future calls to css() and script() emit an element until there's a new call to start_combining(). Fixes 1685. --- modules/gallery/libraries/Gallery_View.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 77e3d204..1395686c 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -136,6 +136,9 @@ class Gallery_View_Core extends View { } unset($this->combine_queue[$type][$group]); + if (empty($this->combine_queue[$type])) { + unset($this->combine_queue[$type]); + } if ($type == "css") { return html::stylesheet("combined/css/$key", "screen,print,projection", true); -- cgit v1.2.3 From 80af9f0f17ce5ac10ceefc9d3d0736b3d4c1c2aa Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 07:05:15 -0700 Subject: Inline admin JS into admin_server_add.html.php. Fixes #1686. --- modules/server_add/helpers/server_add_theme.php | 16 --- modules/server_add/js/admin.js | 8 -- modules/server_add/js/server_add.js | 125 --------------------- modules/server_add/views/admin_server_add.html.php | 24 +++- 4 files changed, 22 insertions(+), 151 deletions(-) delete mode 100644 modules/server_add/js/admin.js delete mode 100644 modules/server_add/js/server_add.js (limited to 'modules') diff --git a/modules/server_add/helpers/server_add_theme.php b/modules/server_add/helpers/server_add_theme.php index 50c050a8..cfca5901 100644 --- a/modules/server_add/helpers/server_add_theme.php +++ b/modules/server_add/helpers/server_add_theme.php @@ -24,20 +24,4 @@ class server_add_theme_Core { . $theme->script("server_add.js"); } } - - static function admin_head($theme) { - $buf = ""; - if (strpos(Router::$current_uri, "admin/server_add") !== false) { - $buf .= $theme->css("server_add.css") - . $theme->css("jquery.autocomplete.css"); - $base = url::site("__ARGS__"); - $csrf = access::csrf_token(); - $buf .= ""; - - $buf .= $theme->script("jquery.autocomplete.js") - . $theme->script("admin.js"); - } - - return $buf; - } } \ No newline at end of file diff --git a/modules/server_add/js/admin.js b/modules/server_add/js/admin.js deleted file mode 100644 index 9d7bd181..00000000 --- a/modules/server_add/js/admin.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Set up autocomplete on the server path list - * - */ -$("document").ready(function() { - $("#g-path").autocomplete( - base_url.replace("__ARGS__", "admin/server_add/autocomplete"), {max: 256}); -}); diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js deleted file mode 100644 index 02dda4c0..00000000 --- a/modules/server_add/js/server_add.js +++ /dev/null @@ -1,125 +0,0 @@ -(function($) { - $.widget("ui.gallery_server_add", { - _init: function() { - var self = this; - $("#g-server-add-add-button", this.element).click(function(event) { - event.preventDefault(); - $(".g-progress-bar", this.element). - progressbar(). - progressbar("value", 0); - $("#g-server-add-progress", this.element).slideDown("fast", function() { self.start_add(); }); - }); - $("#g-server-add-pause-button", this.element).click(function(event) { - self.pause = true; - $("#g-server-add-pause-button", this.element).hide(); - $("#g-server-add-continue-button", this.element).show(); - }); - $("#g-server-add-continue-button", this.element).click(function(event) { - self.pause = false; - $("#g-server-add-pause-button", this.element).show(); - $("#g-server-add-continue-button", this.element).hide(); - self.run_add(); - }); - $("#g-server-add-close-button", this.element).click(function(event) { - $("#g-dialog").dialog("close"); - window.location.reload(); - }); - $("#g-server-add-tree span.g-directory", this.element).dblclick(function(event) { - self.open_dir(event); - }); - $("#g-server-add-tree span.g-file, #g-server-add-tree span.g-directory", this.element).click(function(event) { - self.select_file(event); - }); - $("#g-server-add-tree span.g-directory", this.element).dblclick(function(event) { - self.open_dir(event); - }); - $("#g-dialog").bind("dialogclose", function(event, ui) { - window.location.reload(); - }); - }, - - taskURL: null, - pause: false, - - start_add: function() { - var self = this; - var paths = []; - $.each($("span.selected", self.element), function () { - paths.push($(this).attr("ref")); - }); - - $("#g-server-add-add-button", this.element).hide(); - $("#g-server-add-pause-button", this.element).show(); - - $.ajax({ - url: START_URL, - type: "POST", - async: false, - data: { "paths[]": paths }, - dataType: "json", - success: function(data, textStatus) { - $("#g-status").html(data.status); - $(".g-progress-bar", self.element).progressbar("value", data.percent_complete); - self.taskURL = data.url; - setTimeout(function() { self.run_add(); }, 25); - } - }); - return false; - }, - - run_add: function () { - var self = this; - $.ajax({ - url: self.taskURL, - async: false, - dataType: "json", - success: function(data, textStatus) { - $("#g-status").html(data.status); - $(".g-progress-bar", self.element).progressbar("value", data.percent_complete); - if (data.done) { - $("#g-server-add-progress", this.element).slideUp(); - $("#g-server-add-add-button", this.element).show(); - $("#g-server-add-pause-button", this.element).hide(); - $("#g-server-add-continue-button", this.element).hide(); - } else { - if (!self.pause) { - setTimeout(function() { self.run_add(); }, 25); - } - } - } - }); - }, - - /** - * Load a new directory - */ - open_dir: function(event) { - var self = this; - var path = $(event.target).attr("ref"); - $.ajax({ - url: GET_CHILDREN_URL.replace("__PATH__", path), - success: function(data, textStatus) { - $("#g-server-add-tree", self.element).html(data); - $("#g-server-add-tree span.g-directory", self.element).dblclick(function(event) { - self.open_dir(event); - }); - $("#g-server-add-tree span.g-file, #g-server-add-tree span.g-directory", this.element).click(function(event) { - self.select_file(event); - }); - } - }); - }, - - /** - * Manage file selection state. - */ - select_file: function (event) { - $(event.target).toggleClass("selected"); - if ($("#g-server-add span.selected").length) { - $("#g-server-add-add-button").enable(true).removeClass("ui-state-disabled"); - } else { - $("#g-server-add-add-button").enable(false).addClass("ui-state-disabled"); - } - } - }); -})(jQuery); diff --git a/modules/server_add/views/admin_server_add.html.php b/modules/server_add/views/admin_server_add.html.php index 933ab7f8..d921a8a4 100644 --- a/modules/server_add/views/admin_server_add.html.php +++ b/modules/server_add/views/admin_server_add.html.php @@ -1,4 +1,19 @@ +css("server_add.css") ?> +css("jquery.autocomplete.css") ?> +script("jquery.autocomplete.js") ?> +script("admin.js") ?> + +

      @@ -8,12 +23,17 @@
    • + $path): ?>
    • - " + ") ?>" id="icon_" - class="g-remove-dir g-button"> + class="g-remove-dir g-button"> + + + +
    • -- cgit v1.2.3 From efa3466a75856a219e4c282f21037aa186a806b0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 07:13:55 -0700 Subject: Oops, forgot to remove the reference to admin.js. Follow-on for #1686. --- modules/server_add/views/admin_server_add.html.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/views/admin_server_add.html.php b/modules/server_add/views/admin_server_add.html.php index d921a8a4..474ad428 100644 --- a/modules/server_add/views/admin_server_add.html.php +++ b/modules/server_add/views/admin_server_add.html.php @@ -2,7 +2,6 @@ css("server_add.css") ?> css("jquery.autocomplete.css") ?> script("jquery.autocomplete.js") ?> -script("admin.js") ?> +

      -- cgit v1.2.3 From 4b01676f323fb280ebaa4c041e6894cbb464d8fe Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 07:25:33 -0700 Subject: Fix for ticket #541 Added a theme_info variable to the theme globals. The properties in the theme.info file are now contained in this theme_info structure. Access is: author ?> will display the theme author. --- modules/gallery/libraries/Theme_View.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index a507e9c8..152efc37 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -38,6 +38,7 @@ class Theme_View_Core extends Gallery_View { $this->item = null; $this->tag = null; $this->set_global(array("theme" => $this, + "theme_info" => theme::get_info($this->theme_name), "user" => identity::active_user(), "page_type" => $page_type, "page_subtype" => $page_subtype, -- cgit v1.2.3 From bb23e28035293174f935345178f32638c09d0421 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sat, 23 Apr 2011 10:28:39 -0400 Subject: Remove enumeration unordered list class, it's no longer needed. --- modules/g2_import/views/admin_g2_import.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index 20b243d5..fb2b58c9 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -36,7 +36,7 @@

      -
        +
        • $g2_version)) ?>
        • -- cgit v1.2.3 From 171e4fd0ee6493bb82bb1de3017b83319e7fc5e4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 07:41:44 -0700 Subject: Remove displayed blocks from the admin block list. If there are no available blocks to add, just hide the block adder block. Fixes #1689. --- modules/gallery/helpers/gallery_block.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php index 0ba7c936..49d16246 100644 --- a/modules/gallery/helpers/gallery_block.php +++ b/modules/gallery/helpers/gallery_block.php @@ -82,9 +82,13 @@ class gallery_block_Core { break; case "block_adder": - $block->css_id = "g-block-adder"; - $block->title = t("Dashboard content"); - $block->content = gallery_block::get_add_block_form(); + if ($form = gallery_block::get_add_block_form()) { + $block->css_id = "g-block-adder"; + $block->title = t("Dashboard content"); + $block->content = $form; + } else { + $block = ""; + } break; case "language": @@ -118,11 +122,22 @@ class gallery_block_Core { } static function get_add_block_form() { + $available_blocks = block_manager::get_available_admin_blocks(); + + $active = array(); + foreach (array_merge(block_manager::get_active("dashboard_sidebar"), + block_manager::get_active("dashboard_center")) as $b) { + unset($available_blocks[implode(":", $b)]); + } + + if (!$available_blocks) { + return; + } + $form = new Forge("admin/dashboard/add_block", "", "post", array("id" => "g-add-dashboard-block-form")); $group = $form->group("add_block")->label(t("Add Block")); - $group->dropdown("id")->label(t("Available Blocks")) - ->options(block_manager::get_available_admin_blocks()); + $group->dropdown("id")->label(t("Available blocks"))->options($available_blocks); $group->submit("center")->value(t("Add to center")); $group->submit("sidebar")->value(t("Add to sidebar")); return $form; -- cgit v1.2.3 From 9dd91b55b03923ef3058fb965b0c927d101a396f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 07:42:28 -0700 Subject: Insure that the tag count to display is always greater than 1. Refixes #1649. --- modules/tag/helpers/tag.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 733215b3..742783d1 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -48,6 +48,7 @@ class tag_Core { * @return ORM_Iterator of Tag_Model in descending tag count order */ static function popular_tags($count) { + $count = $count >= 1 ? $count : 30; return ORM::factory("tag") ->order_by("count", "DESC") ->limit($count) -- cgit v1.2.3 From 0ec819d38161ead063c4dbd953b4b55a33a42f80 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 07:46:38 -0700 Subject: Insure that the tag count to display is always greater than 0. Refixes #1649. --- modules/tag/helpers/tag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 742783d1..c21104ee 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -48,7 +48,7 @@ class tag_Core { * @return ORM_Iterator of Tag_Model in descending tag count order */ static function popular_tags($count) { - $count = $count >= 1 ? $count : 30; + $count = max($count, 1); return ORM::factory("tag") ->order_by("count", "DESC") ->limit($count) -- cgit v1.2.3 From 3312009319d69dc834e705166ac08ad8bdc4c18e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 08:07:58 -0700 Subject: Revive server_add.js which I accidentally removed in 80af9f0f17ce5ac10ceefc9d3d0736b3d4c1c2aa as part of #1686. --- modules/server_add/js/server_add.js | 125 ++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 modules/server_add/js/server_add.js (limited to 'modules') diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js new file mode 100644 index 00000000..02dda4c0 --- /dev/null +++ b/modules/server_add/js/server_add.js @@ -0,0 +1,125 @@ +(function($) { + $.widget("ui.gallery_server_add", { + _init: function() { + var self = this; + $("#g-server-add-add-button", this.element).click(function(event) { + event.preventDefault(); + $(".g-progress-bar", this.element). + progressbar(). + progressbar("value", 0); + $("#g-server-add-progress", this.element).slideDown("fast", function() { self.start_add(); }); + }); + $("#g-server-add-pause-button", this.element).click(function(event) { + self.pause = true; + $("#g-server-add-pause-button", this.element).hide(); + $("#g-server-add-continue-button", this.element).show(); + }); + $("#g-server-add-continue-button", this.element).click(function(event) { + self.pause = false; + $("#g-server-add-pause-button", this.element).show(); + $("#g-server-add-continue-button", this.element).hide(); + self.run_add(); + }); + $("#g-server-add-close-button", this.element).click(function(event) { + $("#g-dialog").dialog("close"); + window.location.reload(); + }); + $("#g-server-add-tree span.g-directory", this.element).dblclick(function(event) { + self.open_dir(event); + }); + $("#g-server-add-tree span.g-file, #g-server-add-tree span.g-directory", this.element).click(function(event) { + self.select_file(event); + }); + $("#g-server-add-tree span.g-directory", this.element).dblclick(function(event) { + self.open_dir(event); + }); + $("#g-dialog").bind("dialogclose", function(event, ui) { + window.location.reload(); + }); + }, + + taskURL: null, + pause: false, + + start_add: function() { + var self = this; + var paths = []; + $.each($("span.selected", self.element), function () { + paths.push($(this).attr("ref")); + }); + + $("#g-server-add-add-button", this.element).hide(); + $("#g-server-add-pause-button", this.element).show(); + + $.ajax({ + url: START_URL, + type: "POST", + async: false, + data: { "paths[]": paths }, + dataType: "json", + success: function(data, textStatus) { + $("#g-status").html(data.status); + $(".g-progress-bar", self.element).progressbar("value", data.percent_complete); + self.taskURL = data.url; + setTimeout(function() { self.run_add(); }, 25); + } + }); + return false; + }, + + run_add: function () { + var self = this; + $.ajax({ + url: self.taskURL, + async: false, + dataType: "json", + success: function(data, textStatus) { + $("#g-status").html(data.status); + $(".g-progress-bar", self.element).progressbar("value", data.percent_complete); + if (data.done) { + $("#g-server-add-progress", this.element).slideUp(); + $("#g-server-add-add-button", this.element).show(); + $("#g-server-add-pause-button", this.element).hide(); + $("#g-server-add-continue-button", this.element).hide(); + } else { + if (!self.pause) { + setTimeout(function() { self.run_add(); }, 25); + } + } + } + }); + }, + + /** + * Load a new directory + */ + open_dir: function(event) { + var self = this; + var path = $(event.target).attr("ref"); + $.ajax({ + url: GET_CHILDREN_URL.replace("__PATH__", path), + success: function(data, textStatus) { + $("#g-server-add-tree", self.element).html(data); + $("#g-server-add-tree span.g-directory", self.element).dblclick(function(event) { + self.open_dir(event); + }); + $("#g-server-add-tree span.g-file, #g-server-add-tree span.g-directory", this.element).click(function(event) { + self.select_file(event); + }); + } + }); + }, + + /** + * Manage file selection state. + */ + select_file: function (event) { + $(event.target).toggleClass("selected"); + if ($("#g-server-add span.selected").length) { + $("#g-server-add-add-button").enable(true).removeClass("ui-state-disabled"); + } else { + $("#g-server-add-add-button").enable(false).addClass("ui-state-disabled"); + } + } + }); +})(jQuery); -- cgit v1.2.3 From 0235c2062e9d980a4778c4b22678238c525e1cd7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 08:13:01 -0700 Subject: Fix for ticket #1681 (and maybe #1625). Change the parameter from -v to -version. --- modules/gallery/helpers/graphics.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 04501132..f374f9da 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -316,7 +316,7 @@ class graphics_Core { // ImageMagick & GraphicsMagick $magick_kits = array( "imagemagick" => array( - "name" => "ImageMagick", "binary" => "convert", "version" => "convert -v", + "name" => "ImageMagick", "binary" => "convert", "version" => "convert -version", "version_regex" => "/Version: \S+ (\S+)/"), "graphicsmagick" => array( "name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version", -- cgit v1.2.3 From c101151616033d53587d1435881dae0fa45aeefa Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sat, 23 Apr 2011 12:04:12 -0400 Subject: Allow tags to be merged by renaming * Fixes #1628 --- modules/gallery/libraries/InPlaceEdit.php | 8 +++-- modules/tag/controllers/admin_tags.php | 11 +------ modules/tag/models/tag.php | 24 ++++++++++----- modules/tag/tests/Tag_Test.php | 50 ++++++++++++++++++++++++++++--- 4 files changed, 70 insertions(+), 23 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php index 88c30494..739cbb61 100644 --- a/modules/gallery/libraries/InPlaceEdit.php +++ b/modules/gallery/libraries/InPlaceEdit.php @@ -56,8 +56,12 @@ class InPlaceEdit_Core { } public function validate() { - $post = Validation::factory($_POST) - ->add_callbacks("input", $this->callback); + $post = Validation::factory($_POST); + + if (!empty($this->callback)) { + $post->add_callbacks("input", $this->callback); + } + foreach ($this->rules as $rule) { $post->add_rules("input", $rule); } diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php index 73042a55..fd82bc92 100644 --- a/modules/tag/controllers/admin_tags.php +++ b/modules/tag/controllers/admin_tags.php @@ -81,9 +81,7 @@ class Admin_Tags_Controller extends Admin_Controller { $in_place_edit = InPlaceEdit::factory($tag->name) ->action("admin/tags/rename/$tag->id") - ->rules(array("required", "length[1,64]")) - ->messages(array("in_use" => t("There is already a tag with that name"))) - ->callback(array($this, "check_for_duplicate")); + ->rules(array("required", "length[1,64]")); if ($in_place_edit->validate()) { $old_name = $tag->name; @@ -101,12 +99,5 @@ class Admin_Tags_Controller extends Admin_Controller { } } - public function check_for_duplicate(Validation $post_data, $field) { - $tag_exists = ORM::factory("tag")->where("name", "=", $post_data[$field])->count_all(); - if ($tag_exists) { - $post_data->add_error($field, "in_use"); - } - } - } diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index bd665667..bb79e707 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -69,13 +69,23 @@ class Tag_Model_Core extends ORM { * to this tag. */ public function save() { - $related_item_ids = array(); - foreach (db::build() - ->select("item_id") - ->from("items_tags") - ->where("tag_id", "=", $this->id) - ->execute() as $row) { - $related_item_ids[$row->item_id] = 1; + // Check to see if another tag exists with the same name + $duplicate_tag = ORM::factory("tag") + ->where("name", "=", $this->name) + ->where("id", "!=", $this->id) + ->find(); + if ($duplicate_tag->loaded()) { + // If so, tag its items with this tag so as to merge it + $duplicate_tag_items = ORM::factory("item") + ->join("items_tags", "items.id", "items_tags.item_id") + ->where("items_tags.tag_id", "=", $duplicate_tag->id) + ->find_all(); + foreach ($duplicate_tag_items as $item) { + $this->add($item); + } + + // ... and remove the duplicate tag + $duplicate_tag->delete(); } if (isset($this->object_relations["items"])) { diff --git a/modules/tag/tests/Tag_Test.php b/modules/tag/tests/Tag_Test.php index f5ccb3a2..9e10fa4a 100644 --- a/modules/tag/tests/Tag_Test.php +++ b/modules/tag/tests/Tag_Test.php @@ -18,18 +18,60 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Tag_Test extends Gallery_Unit_Test_Case { + public function teardown() { + ORM::factory("tag")->delete_all(); + } + public function create_tag_test() { $album = test::random_album(); tag::add($album, "tag1"); $tag = ORM::factory("tag")->where("name", "=", "tag1")->find(); - $this->assert_true(1, $tag->count); + $this->assert_equal(1, $tag->count); // Make sure adding the tag again doesn't increase the count tag::add($album, "tag1"); - $this->assert_true(1, $tag->reload()->count); + $this->assert_equal(1, $tag->reload()->count); tag::add(test::random_album(), "tag1"); - $this->assert_true(2, $tag->reload()->count); + $this->assert_equal(2, $tag->reload()->count); + } + + public function rename_merge_tag_test() { + $album1 = test::random_album(); + $album2 = test::random_album(); + + tag::add($album1, "tag1"); + tag::add($album2, "tag2"); + + $tag1 = ORM::factory("tag")->where("name", "=", "tag1")->find(); + $tag1->name = "tag2"; + $tag1->save(); + + // Tags should be merged; $tag2 should be deleted + $tag1->reload(); + + $this->assert_equal(2, $tag1->count); + $this->assert_true($tag1->has($album1)); + $this->assert_true($tag1->has($album2)); + $this->assert_equal(1, ORM::factory("tag")->count_all()); + } + + public function rename_merge_tag_with_same_items_test() { + $album = test::random_album(); + + tag::add($album, "tag1"); + tag::add($album, "tag2"); + + $tag1 = ORM::factory("tag")->where("name", "=", "tag1")->find(); + $tag1->name = "tag2"; + $tag1->save(); + + // Tags should be merged + $tag1->reload(); + + $this->assert_equal(1, $tag1->count); + $this->assert_true($tag1->has($album)); + $this->assert_equal(1, ORM::factory("tag")->count_all()); } -} \ No newline at end of file +} -- cgit v1.2.3 From ce2c6c3ada2854777891a7a8edec66b7b5be72ad Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 10:06:17 -0700 Subject: Add convert_to_human_readable and tests for both. Resolves #1693. --- modules/gallery/helpers/MY_num.php | 14 ++++++++++++++ modules/gallery/tests/Num_Helper_Test.php | 32 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 modules/gallery/tests/Num_Helper_Test.php (limited to 'modules') diff --git a/modules/gallery/helpers/MY_num.php b/modules/gallery/helpers/MY_num.php index 9787044c..842a2ee3 100644 --- a/modules/gallery/helpers/MY_num.php +++ b/modules/gallery/helpers/MY_num.php @@ -37,4 +37,18 @@ class num extends num_Core { return $val; } + + /** + * Convert a size value as accepted by PHP's shorthand to bytes. + * ref: http://us2.php.net/manual/en/function.ini-get.php + * ref: http://us2.php.net/manual/en/faq.using.php#faq.using.shorthandbytes + */ + static function convert_to_human_readable($num) { + foreach (array("G" => 1e9, "M" => 1e6, "K" => 1e3) as $k => $v) { + if ($num > $v) { + $num = round($num / $v) . $k; + } + } + return $num; + } } diff --git a/modules/gallery/tests/Num_Helper_Test.php b/modules/gallery/tests/Num_Helper_Test.php new file mode 100644 index 00000000..a22f9359 --- /dev/null +++ b/modules/gallery/tests/Num_Helper_Test.php @@ -0,0 +1,32 @@ +assert_equal(5 * 1024, num::convert_to_bytes("5K")); + $this->assert_equal(3 * 1024*1024, num::convert_to_bytes("3M")); + $this->assert_equal(4 * 1024*1024*1024, num::convert_to_bytes("4G")); + } + + public function convert_to_human_readable_test() { + $this->assert_equal("6K", num::convert_to_human_readable(5615)); + $this->assert_equal("1M", num::convert_to_human_readable(1205615)); + $this->assert_equal("3G", num::convert_to_human_readable(3091205615)); + } +} \ No newline at end of file -- cgit v1.2.3 From 76a7ad3161be0994d7ba98e9dff9b317b2430bb3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 10:07:32 -0700 Subject: Overhaul of the uploader code: - Propagate size limits (including detecting memory limits from GD) down to the Flash so that we don't even start uploads that won't work - Improve the error messages to be more user meaningful and provide links to the codex for errors - Tell the user up front what the file size limit is. Fixes #1638 --- modules/gallery/css/gallery.css | 6 ++--- modules/gallery/helpers/graphics.php | 19 ++++++++++++++ modules/gallery/libraries/Form_Uploadify.php | 14 +++++++++++ modules/gallery/views/form_uploadify.html.php | 36 ++++++++++++++------------- 4 files changed, 55 insertions(+), 20 deletions(-) (limited to 'modules') diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 275a3d7d..97d09454 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -29,12 +29,12 @@ #g-add-photos-canvas object, #g-add-photos-button { - left: 137px; - margin: .5em 0; + left: 93px; + margin: .5em 0; padding: .4em 1em; position: absolute; top: 0; - width: 175px; + width: auto; } #g-add-photos-canvas object { diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 04501132..d19392cf 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -423,4 +423,23 @@ class graphics_Core { return true; } + + /** + * Return the max file size that this graphics toolkit can handle. + */ + static function max_filesize() { + if (module::get_var("gallery", "graphics_toolkit") == "gd") { + $memory_limit = trim(ini_get("memory_limit")); + $memory_limit_bytes = num::convert_to_bytes($memory_limit); + + // GD expands images in memory and uses 4 bytes of RAM for every byte + // in the file. + $max_filesize = $memory_limit_bytes / 4; + $max_filesize_human_readable = num::convert_to_human_readable($max_filesize); + return array($max_filesize, $max_filesize_human_readable); + } + + // Some arbitrarily large size + return array(1000000000, "1G"); + } } diff --git a/modules/gallery/libraries/Form_Uploadify.php b/modules/gallery/libraries/Form_Uploadify.php index 27ab9684..3e35e380 100644 --- a/modules/gallery/libraries/Form_Uploadify.php +++ b/modules/gallery/libraries/Form_Uploadify.php @@ -48,6 +48,20 @@ class Form_Uploadify_Core extends Form_Input { $v->simultaneous_upload_limit = module::get_var("gallery", "simultaneous_upload_limit"); $v->movies_allowed = (bool) movie::find_ffmpeg(); $v->suhosin_session_encrypt = (bool) ini_get("suhosin.session.encrypt"); + + list ($toolkit_max_filesize_bytes, $toolkit_max_filesize) = graphics::max_filesize(); + + $upload_max_filesize = trim(ini_get("upload_max_filesize")); + $upload_max_filesize_bytes = num::convert_to_bytes($upload_max_filesize); + + if ($upload_max_filesize_bytes < $toolkit_max_filesize_bytes) { + $v->size_limit_bytes = $upload_max_filesize_bytes; + $v->size_limit = $upload_max_filesize; + } else { + $v->size_limit_bytes = $toolkit_max_filesize_bytes; + $v->size_limit = $toolkit_max_filesize; + } + return $v; } diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index 77b6d493..83dfcc68 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -32,6 +32,7 @@ fileDesc: for_js() ?>, cancelImg: "", simUploadLimit: , + sizeLimit: , wmode: "transparent", hideButton: true, /* should be true */ auto: true, @@ -66,26 +67,30 @@ return true; }, onError: function(event, queueID, fileObj, errorObj) { - var msg = " - "; if (errorObj.type == "HTTP") { if (errorObj.info == "500") { - msg += for_js() ?>; - // Server error - check server logs + error_msg = for_js() ?>; } else if (errorObj.info == "404") { - msg += for_js() ?>; - // Server script not found + error_msg = for_js() ?>; + } else if (errorObj.info == "400") { + error_msg = $size_limit))->for_js() ?>; } else { - // Server Error: status: errorObj.info - msg += (for_js() ?>.replace("__INFO__", errorObj.info)); + msg += (for_js() ?> + .replace("__INFO__", errorObj.info) + .replace("__TYPE__", errorObj.type)); } } else if (errorObj.type == "File Size") { - var sizelimit = $("#g-uploadify").uploadifySettings(sizeLimit); - msg += fileObj.name+' '+errorObj.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB'; + error_msg = $size_limit))->for_js() ?>; } else { - msg += (for_js() ?> - .replace("__INFO__", errorObj.info) - .replace("__TYPE__", errorObj.type)); + error_msg = for_js() ?> + .replace("__INFO__", errorObj.info) + .replace("__TYPE__", errorObj.type); } + msg = " - " + + error_msg + ""; + $("#g-add-photos-status ul").append( "
        • " + fileObj.name + msg + "
        • "); $("#g-uploadify").uploadifyCancel(queueID); @@ -131,10 +136,7 @@
          -

          - -

          -
            +
              parents() as $i => $parent): ?> > title) ?> @@ -143,7 +145,7 @@
          - +
          -- cgit v1.2.3 From 466f2a657ef4b22346e2232f50bc5cca4ab6e540 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 12:16:06 -0700 Subject: Fix ticket #1694. Correct Spelling of mininum_password_length to minimum_password_length --- installer/install.sql | 146 ++++++++++++++++---------------- modules/user/controllers/password.php | 2 +- modules/user/helpers/user_installer.php | 7 ++ modules/user/models/user.php | 2 +- modules/user/module.info | 2 +- 5 files changed, 84 insertions(+), 75 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index de5250d1..7f9eda59 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS {access_caches}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {access_caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -13,11 +13,11 @@ CREATE TABLE {access_caches} ( PRIMARY KEY (`id`), KEY `item_id` (`item_id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {access_caches} VALUES (1,1,'1','0','0','1','0','0'); DROP TABLE IF EXISTS {access_intents}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {access_intents} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -31,11 +31,11 @@ CREATE TABLE {access_intents} ( `add_2` binary(1) DEFAULT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {access_intents} VALUES (1,1,'1','1','0','0','1','1','0','0'); DROP TABLE IF EXISTS {caches}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, @@ -46,10 +46,10 @@ CREATE TABLE {caches} ( UNIQUE KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {comments}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {comments} ( `author_id` int(9) DEFAULT NULL, `created` int(9) NOT NULL, @@ -75,10 +75,10 @@ CREATE TABLE {comments} ( `updated` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {failed_auths}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {failed_auths} ( `id` int(9) NOT NULL AUTO_INCREMENT, `count` int(9) NOT NULL, @@ -86,10 +86,10 @@ CREATE TABLE {failed_auths} ( `time` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {graphics_rules}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {graphics_rules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -100,12 +100,12 @@ CREATE TABLE {graphics_rules} ( `target` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'thumb'); INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:640;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'resize'); DROP TABLE IF EXISTS {groups}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {groups} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` char(64) DEFAULT NULL, @@ -113,25 +113,25 @@ CREATE TABLE {groups} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {groups} VALUES (1,'Everybody',1); INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {groups_users} ( `group_id` int(9) NOT NULL, `user_id` int(9) NOT NULL, PRIMARY KEY (`group_id`,`user_id`), UNIQUE KEY `user_id` (`user_id`,`group_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {groups_users} VALUES (1,1); INSERT INTO {groups_users} VALUES (1,2); INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {incoming_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` char(32) NOT NULL, @@ -143,10 +143,10 @@ CREATE TABLE {incoming_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {items}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {items} ( `id` int(9) NOT NULL AUTO_INCREMENT, `album_cover_item_id` int(9) DEFAULT NULL, @@ -188,11 +188,11 @@ CREATE TABLE {items} ( KEY `weight` (`weight`), KEY `left_ptr` (`left_ptr`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {items} VALUES (1,NULL,NULL,UNIX_TIMESTAMP(),'',NULL,1,1,NULL,NULL,2,0,NULL,'','',1,NULL,NULL,2,NULL,'weight','ASC',1,NULL,NULL,'Gallery','album',UNIX_TIMESTAMP(),0,1,NULL,'1','1'); DROP TABLE IF EXISTS {items_tags}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {items_tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) NOT NULL, @@ -201,10 +201,10 @@ CREATE TABLE {items_tags} ( KEY `tag_id` (`tag_id`,`id`), KEY `item_id` (`item_id`,`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {logs}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {logs} ( `id` int(9) NOT NULL AUTO_INCREMENT, `category` varchar(64) DEFAULT NULL, @@ -217,10 +217,10 @@ CREATE TABLE {logs} ( `user_id` int(9) DEFAULT '0', PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {messages}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {messages} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) DEFAULT NULL, @@ -228,11 +228,12 @@ CREATE TABLE {messages} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`) -) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; +INSERT INTO {messages} VALUES (1,'upgrade_now','3','Some of your modules are out of date. Upgrade now!'); DROP TABLE IF EXISTS {modules}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {modules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -243,7 +244,7 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`), KEY `weight` (`weight`) ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {modules} VALUES (1,1,'gallery',48,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); INSERT INTO {modules} VALUES (3,1,'comment',4,3); @@ -254,8 +255,8 @@ INSERT INTO {modules} VALUES (7,1,'search',1,7); INSERT INTO {modules} VALUES (8,1,'slideshow',2,8); INSERT INTO {modules} VALUES (9,1,'tag',3,9); DROP TABLE IF EXISTS {outgoing_translations}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {outgoing_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `base_revision` int(9) DEFAULT NULL, @@ -267,10 +268,10 @@ CREATE TABLE {outgoing_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {permissions}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {permissions} ( `id` int(9) NOT NULL AUTO_INCREMENT, `display_name` varchar(64) DEFAULT NULL, @@ -278,14 +279,14 @@ CREATE TABLE {permissions} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {permissions} VALUES (1,'View','view'); INSERT INTO {permissions} VALUES (2,'View full size','view_full'); INSERT INTO {permissions} VALUES (3,'Edit','edit'); INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {search_records} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -295,21 +296,21 @@ CREATE TABLE {search_records} ( KEY `item_id` (`item_id`), FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {search_records} VALUES (1,1,0,' Gallery'); DROP TABLE IF EXISTS {sessions}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {sessions} ( `session_id` varchar(127) NOT NULL, `data` text NOT NULL, `last_activity` int(10) unsigned NOT NULL, PRIMARY KEY (`session_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {tags}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, @@ -317,10 +318,10 @@ CREATE TABLE {tags} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {tasks}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {tasks} ( `id` int(9) NOT NULL AUTO_INCREMENT, `callback` varchar(128) DEFAULT NULL, @@ -335,10 +336,10 @@ CREATE TABLE {tasks} ( PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`) ) DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {themes}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {themes} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(64) DEFAULT NULL, @@ -346,12 +347,12 @@ CREATE TABLE {themes} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {themes} VALUES (1,'wind',1); INSERT INTO {themes} VALUES (2,'admin_wind',1); DROP TABLE IF EXISTS {users}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {users} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, @@ -369,12 +370,12 @@ CREATE TABLE {users} ( UNIQUE KEY `name` (`name`), UNIQUE KEY `hash` (`hash`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +SET character_set_client = @saved_cs_client; INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,'unknown@unknown.com',1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; CREATE TABLE {vars} ( `id` int(9) NOT NULL AUTO_INCREMENT, `module_name` varchar(64) NOT NULL, @@ -382,8 +383,8 @@ CREATE TABLE {vars} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) AUTO_INCREMENT=43 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; +) AUTO_INCREMENT=44 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); INSERT INTO {vars} VALUES (NULL,'gallery','page_size','9'); @@ -413,8 +414,9 @@ INSERT INTO {vars} VALUES (NULL,'gallery','email_line_length','70'); INSERT INTO {vars} VALUES (NULL,'gallery','email_header_separator','s:1:\"\n\";'); INSERT INTO {vars} VALUES (NULL,'gallery','show_user_profiles_to','registered_users'); INSERT INTO {vars} VALUES (NULL,'gallery','extra_binary_paths','/usr/local/bin:/opt/local/bin:/opt/bin'); -INSERT INTO {vars} VALUES (NULL,'gallery','timezone','PST8PDT'); +INSERT INTO {vars} VALUES (NULL,'gallery','timezone','System/Localtime'); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:4:{i:10;a:2:{i:0;s:7:\"gallery\";i:1;s:8:\"language\";}i:11;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:12;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:13;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}'); +INSERT INTO {vars} VALUES (NULL,'user','minimum_password_length','5'); INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user'); INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5'); INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0'); diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php index 4e93d5ce..cd46bbed 100644 --- a/modules/user/controllers/password.php +++ b/modules/user/controllers/password.php @@ -105,7 +105,7 @@ class Password_Controller extends Controller { if (!empty($hash)) { $hidden->value($hash); } - $minimum_length = module::get_var("user", "mininum_password_length", 5); + $minimum_length = module::get_var("user", "minimum_password_length", 5); $input_password = $group->password("password")->label(t("Password"))->id("g-password") ->rules($minimum_length ? "required|length[$minimum_length, 40]" : "length[40]"); $group->password("password2")->label(t("Confirm Password"))->id("g-password2") diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index b889af49..b5e40a24 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -23,6 +23,7 @@ class user_installer { } static function install() { + module::set_var("user", "minimum_password_length", 5); IdentityProvider::change_provider("user"); } @@ -44,6 +45,12 @@ class user_installer { ->execute(); module::set_version("user", $version = 3); } + + if ($version == 3) { + module::set_var("user", "minimum_password_length", 5); + module::clear_var("user", "mininum_password_length"); + module::set_version("user", $version = 4); + } } static function uninstall() { diff --git a/modules/user/models/user.php b/modules/user/models/user.php index 145738ca..a8a3a0e7 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -147,7 +147,7 @@ class User_Model_Core extends ORM implements User_Definition { } if (!$this->loaded() || isset($this->password_length)) { - $minimum_length = module::get_var("user", "mininum_password_length", 5); + $minimum_length = module::get_var("user", "minimum_password_length", 5); if ($this->password_length < $minimum_length) { $v->add_error("password", "min_length"); } diff --git a/modules/user/module.info b/modules/user/module.info index 185a3e3a..b7594815 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -1,4 +1,4 @@ name = "Users and Groups" description = "Gallery 3 user and group management" -version = 3 +version = 4 -- cgit v1.2.3 From b30afaeab7d931f4d380a96c4aadd6deb86df5e2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 12:27:46 -0700 Subject: Fix ticket #1694 (continued). Reset the corrected user module variable to the value of the incorrect spelling (don't assume that the original value was still 5. --- modules/user/helpers/user_installer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index b5e40a24..b9f3c57d 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -47,7 +47,8 @@ class user_installer { } if ($version == 3) { - module::set_var("user", "minimum_password_length", 5); + $password_length = module::get_var("user", "mininum_password_length", 5); + module::set_var("user", "minimum_password_length", $password_length); module::clear_var("user", "mininum_password_length"); module::set_version("user", $version = 4); } -- cgit v1.2.3 From 59d5ddc8abe882c3cc3994ca2478d8dd0915f0fe Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 12:48:04 -0700 Subject: Set the default value for gallery.timezone to null so that each install uses date_default_timezone_get() in modules/gallery/config/locale.php but it's still overrideable in Admin > Settings > Advanced. Follow on fix for #1637. --- installer/install.sql | 142 +++++++++++++------------- modules/gallery/helpers/gallery_installer.php | 13 +-- modules/gallery/module.info | 2 +- 3 files changed, 79 insertions(+), 78 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 7f9eda59..bbc2a5c7 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -1,6 +1,6 @@ DROP TABLE IF EXISTS {access_caches}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {access_caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -13,11 +13,11 @@ CREATE TABLE {access_caches} ( PRIMARY KEY (`id`), KEY `item_id` (`item_id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {access_caches} VALUES (1,1,'1','0','0','1','0','0'); DROP TABLE IF EXISTS {access_intents}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {access_intents} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -31,11 +31,11 @@ CREATE TABLE {access_intents} ( `add_2` binary(1) DEFAULT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {access_intents} VALUES (1,1,'1','1','0','0','1','1','0','0'); DROP TABLE IF EXISTS {caches}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {caches} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, @@ -46,10 +46,10 @@ CREATE TABLE {caches} ( UNIQUE KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {comments}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {comments} ( `author_id` int(9) DEFAULT NULL, `created` int(9) NOT NULL, @@ -75,10 +75,10 @@ CREATE TABLE {comments} ( `updated` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {failed_auths}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {failed_auths} ( `id` int(9) NOT NULL AUTO_INCREMENT, `count` int(9) NOT NULL, @@ -86,10 +86,10 @@ CREATE TABLE {failed_auths} ( `time` int(9) NOT NULL, PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {graphics_rules}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {graphics_rules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -100,12 +100,12 @@ CREATE TABLE {graphics_rules} ( `target` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'thumb'); INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:640;s:6:\"master\";i:2;}','gallery','gallery_graphics::resize',100,'resize'); DROP TABLE IF EXISTS {groups}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {groups} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` char(64) DEFAULT NULL, @@ -113,25 +113,25 @@ CREATE TABLE {groups} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {groups} VALUES (1,'Everybody',1); INSERT INTO {groups} VALUES (2,'Registered Users',1); DROP TABLE IF EXISTS {groups_users}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {groups_users} ( `group_id` int(9) NOT NULL, `user_id` int(9) NOT NULL, PRIMARY KEY (`group_id`,`user_id`), UNIQUE KEY `user_id` (`user_id`,`group_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {groups_users} VALUES (1,1); INSERT INTO {groups_users} VALUES (1,2); INSERT INTO {groups_users} VALUES (2,2); DROP TABLE IF EXISTS {incoming_translations}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {incoming_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` char(32) NOT NULL, @@ -143,10 +143,10 @@ CREATE TABLE {incoming_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {items}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {items} ( `id` int(9) NOT NULL AUTO_INCREMENT, `album_cover_item_id` int(9) DEFAULT NULL, @@ -188,11 +188,11 @@ CREATE TABLE {items} ( KEY `weight` (`weight`), KEY `left_ptr` (`left_ptr`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {items} VALUES (1,NULL,NULL,UNIX_TIMESTAMP(),'',NULL,1,1,NULL,NULL,2,0,NULL,'','',1,NULL,NULL,2,NULL,'weight','ASC',1,NULL,NULL,'Gallery','album',UNIX_TIMESTAMP(),0,1,NULL,'1','1'); DROP TABLE IF EXISTS {items_tags}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {items_tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) NOT NULL, @@ -201,10 +201,10 @@ CREATE TABLE {items_tags} ( KEY `tag_id` (`tag_id`,`id`), KEY `item_id` (`item_id`,`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {logs}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {logs} ( `id` int(9) NOT NULL AUTO_INCREMENT, `category` varchar(64) DEFAULT NULL, @@ -217,10 +217,10 @@ CREATE TABLE {logs} ( `user_id` int(9) DEFAULT '0', PRIMARY KEY (`id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {messages}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {messages} ( `id` int(9) NOT NULL AUTO_INCREMENT, `key` varchar(255) DEFAULT NULL, @@ -229,11 +229,11 @@ CREATE TABLE {messages} ( PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`) ) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {messages} VALUES (1,'upgrade_now','3','Some of your modules are out of date. Upgrade now!'); DROP TABLE IF EXISTS {modules}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {modules} ( `id` int(9) NOT NULL AUTO_INCREMENT, `active` tinyint(1) DEFAULT '0', @@ -244,8 +244,8 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`), KEY `weight` (`weight`) ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; -INSERT INTO {modules} VALUES (1,1,'gallery',48,1); +/*!40101 SET character_set_client = @saved_cs_client */; +INSERT INTO {modules} VALUES (1,1,'gallery',49,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); INSERT INTO {modules} VALUES (3,1,'comment',4,3); INSERT INTO {modules} VALUES (4,1,'organize',4,4); @@ -255,8 +255,8 @@ INSERT INTO {modules} VALUES (7,1,'search',1,7); INSERT INTO {modules} VALUES (8,1,'slideshow',2,8); INSERT INTO {modules} VALUES (9,1,'tag',3,9); DROP TABLE IF EXISTS {outgoing_translations}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {outgoing_translations} ( `id` int(9) NOT NULL AUTO_INCREMENT, `base_revision` int(9) DEFAULT NULL, @@ -268,10 +268,10 @@ CREATE TABLE {outgoing_translations} ( UNIQUE KEY `key` (`key`,`locale`), KEY `locale_key` (`locale`,`key`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {permissions}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {permissions} ( `id` int(9) NOT NULL AUTO_INCREMENT, `display_name` varchar(64) DEFAULT NULL, @@ -279,14 +279,14 @@ CREATE TABLE {permissions} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {permissions} VALUES (1,'View','view'); INSERT INTO {permissions} VALUES (2,'View full size','view_full'); INSERT INTO {permissions} VALUES (3,'Edit','edit'); INSERT INTO {permissions} VALUES (4,'Add','add'); DROP TABLE IF EXISTS {search_records}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {search_records} ( `id` int(9) NOT NULL AUTO_INCREMENT, `item_id` int(9) DEFAULT NULL, @@ -296,21 +296,21 @@ CREATE TABLE {search_records} ( KEY `item_id` (`item_id`), FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {search_records} VALUES (1,1,0,' Gallery'); DROP TABLE IF EXISTS {sessions}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {sessions} ( `session_id` varchar(127) NOT NULL, `data` text NOT NULL, `last_activity` int(10) unsigned NOT NULL, PRIMARY KEY (`session_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {tags}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {tags} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, @@ -318,10 +318,10 @@ CREATE TABLE {tags} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {tasks}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {tasks} ( `id` int(9) NOT NULL AUTO_INCREMENT, `callback` varchar(128) DEFAULT NULL, @@ -336,10 +336,10 @@ CREATE TABLE {tasks} ( PRIMARY KEY (`id`), KEY `owner_id` (`owner_id`) ) DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS {themes}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {themes} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(64) DEFAULT NULL, @@ -347,12 +347,12 @@ CREATE TABLE {themes} ( PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {themes} VALUES (1,'wind',1); INSERT INTO {themes} VALUES (2,'admin_wind',1); DROP TABLE IF EXISTS {users}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {users} ( `id` int(9) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, @@ -370,12 +370,12 @@ CREATE TABLE {users} ( UNIQUE KEY `name` (`name`), UNIQUE KEY `hash` (`hash`) ) AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL); INSERT INTO {users} VALUES (2,'admin','Gallery Administrator','',0,0,'unknown@unknown.com',1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE {vars} ( `id` int(9) NOT NULL AUTO_INCREMENT, `module_name` varchar(64) NOT NULL, @@ -384,7 +384,7 @@ CREATE TABLE {vars} ( PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) ) AUTO_INCREMENT=44 DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; +/*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); INSERT INTO {vars} VALUES (NULL,'gallery','page_size','9'); @@ -414,7 +414,7 @@ INSERT INTO {vars} VALUES (NULL,'gallery','email_line_length','70'); INSERT INTO {vars} VALUES (NULL,'gallery','email_header_separator','s:1:\"\n\";'); INSERT INTO {vars} VALUES (NULL,'gallery','show_user_profiles_to','registered_users'); INSERT INTO {vars} VALUES (NULL,'gallery','extra_binary_paths','/usr/local/bin:/opt/local/bin:/opt/bin'); -INSERT INTO {vars} VALUES (NULL,'gallery','timezone','System/Localtime'); +INSERT INTO {vars} VALUES (NULL,'gallery','timezone',NULL); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:4:{i:10;a:2:{i:0;s:7:\"gallery\";i:1;s:8:\"language\";}i:11;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:12;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:13;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}'); INSERT INTO {vars} VALUES (NULL,'user','minimum_password_length','5'); INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user'); diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 83c5ed71..7a9af402 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -311,9 +311,9 @@ class gallery_installer { module::set_var("gallery", "email_header_separator", serialize("\n")); module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); - module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); + module::set_var("gallery", "timezone", null); - module::set_version("gallery", 48); + module::set_version("gallery", 49); } static function upgrade($version) { @@ -685,11 +685,12 @@ class gallery_installer { module::set_version("gallery", $version = 47); } - if ($version == 47) { + if ($version == 47 || $version == 48) { // Add configuration variable to set timezone. Defaults to the currently - // used timezone (from PHP configuration). - module::set_var("gallery", "timezone", Kohana::config("locale.timezone")); - module::set_version("gallery", $version = 48); + // used timezone (from PHP configuration). Note that in v48 we werew + // setting this value incorrectly, so we're going to stomp this value for v49. + module::set_var("gallery", "timezone", null); + module::set_version("gallery", $version = 49); } } diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 807d08fd..74c0658f 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 48 +version = 49 -- cgit v1.2.3 From 4d38c505cb0412eb4b470bdf95c6b317ef5a691d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 12:55:30 -0700 Subject: Further cleanup for minimum_password_length -- update user_installer::initialize() with the right module version number for the user module and fix the misspelling there then rebuild the installer.sql. #1694. --- installer/install.sql | 10 ++++------ modules/user/helpers/user_installer.php | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index bbc2a5c7..2b8ec11e 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -228,9 +228,8 @@ CREATE TABLE {messages} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `key` (`key`) -) AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {messages} VALUES (1,'upgrade_now','3','Some of your modules are out of date. Upgrade now!'); DROP TABLE IF EXISTS {modules}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -246,7 +245,7 @@ CREATE TABLE {modules} ( ) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {modules} VALUES (1,1,'gallery',49,1); -INSERT INTO {modules} VALUES (2,1,'user',3,2); +INSERT INTO {modules} VALUES (2,1,'user',4,2); INSERT INTO {modules} VALUES (3,1,'comment',4,3); INSERT INTO {modules} VALUES (4,1,'organize',4,4); INSERT INTO {modules} VALUES (5,1,'info',2,5); @@ -383,7 +382,7 @@ CREATE TABLE {vars} ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) AUTO_INCREMENT=44 DEFAULT CHARSET=utf8; +) AUTO_INCREMENT=43 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind'); INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind'); @@ -416,9 +415,8 @@ INSERT INTO {vars} VALUES (NULL,'gallery','show_user_profiles_to','registered_us INSERT INTO {vars} VALUES (NULL,'gallery','extra_binary_paths','/usr/local/bin:/opt/local/bin:/opt/bin'); INSERT INTO {vars} VALUES (NULL,'gallery','timezone',NULL); INSERT INTO {vars} VALUES (NULL,'gallery','blocks_site_sidebar','a:4:{i:10;a:2:{i:0;s:7:\"gallery\";i:1;s:8:\"language\";}i:11;a:2:{i:0;s:4:\"info\";i:1;s:8:\"metadata\";}i:12;a:2:{i:0;s:3:\"rss\";i:1;s:9:\"rss_feeds\";}i:13;a:2:{i:0;s:3:\"tag\";i:1;s:3:\"tag\";}}'); -INSERT INTO {vars} VALUES (NULL,'user','minimum_password_length','5'); INSERT INTO {vars} VALUES (NULL,'gallery','identity_provider','user'); -INSERT INTO {vars} VALUES (NULL,'user','mininum_password_length','5'); +INSERT INTO {vars} VALUES (NULL,'user','minimum_password_length','5'); INSERT INTO {vars} VALUES (NULL,'comment','spam_caught','0'); INSERT INTO {vars} VALUES (NULL,'comment','access_permissions','everybody'); INSERT INTO {vars} VALUES (NULL,'info','show_title','1'); diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index b9f3c57d..9b582773 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -23,8 +23,8 @@ class user_installer { } static function install() { - module::set_var("user", "minimum_password_length", 5); IdentityProvider::change_provider("user"); + // Set the latest version in initialize() below } static function upgrade($version) { @@ -137,7 +137,7 @@ class user_installer { access::allow($registered, "view", $root); access::allow($registered, "view_full", $root); - module::set_var("user", "mininum_password_length", 5); - module::set_version("user", 3); + module::set_var("user", "minimum_password_length", 5); + module::set_version("user", 4); } } \ No newline at end of file -- cgit v1.2.3 From c1df782a75193d4ee33ec1d0be10739f9320705f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 13:04:23 -0700 Subject: Use an absolute url for the upgrader link. Also, clear the upgrade_now site status message every time we go to Admin > Modules. Fixes #1695. --- modules/gallery/controllers/admin_modules.php | 6 +++--- modules/gallery/helpers/module.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_modules.php b/modules/gallery/controllers/admin_modules.php index 787785ea..b712d14f 100644 --- a/modules/gallery/controllers/admin_modules.php +++ b/modules/gallery/controllers/admin_modules.php @@ -19,6 +19,9 @@ */ class Admin_Modules_Controller extends Admin_Controller { public function index() { + // If modules need upgrading, this will get recreated in module::available() + site_status::clear("upgrade_now"); + $view = new Admin_View("admin.html"); $view->page_title = t("Modules"); $view->content = new View("admin_modules.html"); @@ -103,9 +106,6 @@ class Admin_Modules_Controller extends Admin_Controller { module::event("module_change", $changes); - // If modules need upgrading, this will get recreated - site_status::clear("upgrade_now"); - // @todo this type of collation is questionable from an i18n perspective if ($activated_names) { message::success(t("Activated: %names", array("names" => join(", ", $activated_names)))); diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 37f7f68a..4b7d4a5f 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -101,7 +101,7 @@ class module_Core { $m->locked = false; if ($m->active && $m->version != $m->code_version) { - site_status::warning(t("Some of your modules are out of date. Upgrade now!", array("upgrader_url" => url::site("upgrader"))), "upgrade_now"); + site_status::warning(t("Some of your modules are out of date. Upgrade now!", array("upgrader_url" => url::abs_site("upgrader"))), "upgrade_now"); } } -- cgit v1.2.3 From 5ce85636329b14673718836b3631a3e46efdc3bb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 13:20:22 -0700 Subject: Move the calculation for item_related_update ahead of the duplicate tag merge so that we don't trigger an item_related_update on items who semantically have the same tag after the merge. Follow-on for #1628. --- modules/tag/models/tag.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index bb79e707..d4e385a2 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -69,13 +69,24 @@ class Tag_Model_Core extends ORM { * to this tag. */ public function save() { + // Figure out what items have changed in this tag for our item_related_update event below + if (isset($this->object_relations["items"])) { + $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); + $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); + if (isset($this->changed_relations["items"])) { + $changed = array_merge($added, $removed); + } + $this->count = count($this->object_relations["items"]) + count($added) - count($removed); + } + // Check to see if another tag exists with the same name $duplicate_tag = ORM::factory("tag") ->where("name", "=", $this->name) ->where("id", "!=", $this->id) ->find(); if ($duplicate_tag->loaded()) { - // If so, tag its items with this tag so as to merge it + // If so, tag its items with this tag so as to merge it. Do this after we figure out what's + // changed so that we don't notify on this change to keep churn down. $duplicate_tag_items = ORM::factory("item") ->join("items_tags", "items.id", "items_tags.item_id") ->where("items_tags.tag_id", "=", $duplicate_tag->id) @@ -88,15 +99,6 @@ class Tag_Model_Core extends ORM { $duplicate_tag->delete(); } - if (isset($this->object_relations["items"])) { - $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); - $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); - if (isset($this->changed_relations["items"])) { - $changed = array_merge($added, $removed); - } - $this->count = count($this->object_relations["items"]) + count($added) - count($removed); - } - $result = parent::save(); if (!empty($changed)) { -- cgit v1.2.3 From cc8d881973cf82dc4681ad4ceeae9b6eaa139f86 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Sat, 23 Apr 2011 15:48:10 -0400 Subject: Add iPad/iPhone support for video playback * Resolves #1634 --- lib/flowplayer.controls.swf | Bin 27007 -> 36843 bytes lib/flowplayer.js | 216 ++++++++++++++++++++--------- lib/flowplayer.pseudostreaming.swf | Bin 3763 -> 4477 bytes lib/flowplayer.swf | Bin 110762 -> 120221 bytes modules/gallery/views/movieplayer.html.php | 2 +- 5 files changed, 153 insertions(+), 65 deletions(-) (limited to 'modules') diff --git a/lib/flowplayer.controls.swf b/lib/flowplayer.controls.swf index aacdcd30..5507a531 100644 Binary files a/lib/flowplayer.controls.swf and b/lib/flowplayer.controls.swf differ diff --git a/lib/flowplayer.js b/lib/flowplayer.js index 57f00e65..3bbdc1d3 100644 --- a/lib/flowplayer.js +++ b/lib/flowplayer.js @@ -10,13 +10,13 @@ function el(id){return document.getElementById(id);} function extend(to,from,skipFuncs){if(typeof from!='object'){return to;} if(to&&from){each(from,function(name,value){if(!skipFuncs||typeof value!='function'){to[name]=value;}});} return to;} -function select(query){var index=query.indexOf(".");if(index!=-1){var tag=query.substring(0,index)||"*";var klass=query.substring(index+1,query.length);var els=[];each(document.getElementsByTagName(tag),function(){if(this.className&&this.className.indexOf(klass)!=-1){els.push(this);}});return els;}} +function select(query){var index=query.indexOf(".");if(index!=-1){var tag=query.slice(0,index)||"*";var klass=query.slice(index+1,query.length);var els=[];each(document.getElementsByTagName(tag),function(){if(this.className&&this.className.indexOf(klass)!=-1){els.push(this);}});return els;}} function stopEvent(e){e=e||window.event;if(e.preventDefault){e.stopPropagation();e.preventDefault();}else{e.returnValue=false;e.cancelBubble=true;} return false;} function bind(to,evt,fn){to[evt]=to[evt]||[];to[evt].push(fn);} -function makeId(){return"_"+(""+Math.random()).substring(2,10);} -var Clip=function(json,index,player){var self=this;var cuepoints={};var listeners={};self.index=index;if(typeof json=='string'){json={url:json};} -extend(this,json,true);each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var evt="on"+this;if(evt.indexOf("*")!=-1){evt=evt.substring(0,evt.length-1);var before="onBefore"+evt.substring(2);self[before]=function(fn){bind(listeners,before,fn);return self;};} +function makeId(){return"_"+(""+Math.random()).slice(2,10);} +var Clip=function(json,index,player){var self=this,cuepoints={},listeners={};self.index=index;if(typeof json=='string'){json={url:json};} +extend(this,json,true);each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var evt="on"+this;if(evt.indexOf("*")!=-1){evt=evt.slice(0,evt.length-1);var before="onBefore"+evt.slice(2);self[before]=function(fn){bind(listeners,before,fn);return self;};} self[evt]=function(fn){bind(listeners,evt,fn);return self;};if(index==-1){if(self[before]){player[before]=self[before];} if(self[evt]){player[evt]=self[evt];}}});extend(this,{onCuepoint:function(points,fn){if(arguments.length==1){cuepoints.embedded=[null,points];return self;} if(typeof points=='number'){points=[points];} @@ -26,7 +26,7 @@ var conf=player.getConfig();var clip=(index==-1)?conf.clip:conf.playlist[index]; target=target||self;if(evt=='onCuepoint'){var fn=cuepoints[arg1];if(fn){return fn[1].call(player,target,arg2);}} if(arg1&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(evt)!=-1){extend(target,arg1);if(arg1.metaData){if(!target.duration){target.duration=arg1.metaData.duration;}else{target.fullDuration=arg1.metaData.duration;}}} var ret=true;each(listeners[evt],function(){ret=this.call(player,target,arg1,arg2);});return ret;}});if(json.onCuepoint){var arg=json.onCuepoint;self.onCuepoint.apply(self,typeof arg=='function'?[arg]:arg);delete json.onCuepoint;} -each(json,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete json[key];}});if(index==-1){player.onCuepoint=this.onCuepoint;}};var Plugin=function(name,json,player,fn){var listeners={};var self=this;var hasMethods=false;if(fn){extend(listeners,fn);} +each(json,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete json[key];}});if(index==-1){player.onCuepoint=this.onCuepoint;}};var Plugin=function(name,json,player,fn){var self=this,listeners={},hasMethods=false;if(fn){extend(listeners,fn);} each(json,function(key,val){if(typeof val=='function'){listeners[key]=val;delete json[key];}});extend(this,{animate:function(props,speed,fn){if(!props){return self;} if(typeof speed=='function'){fn=speed;speed=500;} if(typeof props=='string'){var key=props;props={};props[key]=speed;speed=500;} @@ -37,32 +37,37 @@ json=player._api().fp_css(name,props);extend(self,json);return self;},show:funct if(fn){var fnId=makeId();listeners[fnId]=fn;} this.display=player._api().fp_fadeTo(name,o,speed,fnId);this.opacity=o;return self;},fadeIn:function(speed,fn){return self.fadeTo(1,speed,fn);},fadeOut:function(speed,fn){return self.fadeTo(0,speed,fn);},getName:function(){return name;},getPlayer:function(){return player;},_fireEvent:function(evt,arg,arg2){if(evt=='onUpdate'){var json=player._api().fp_getPlugin(name);if(!json){return;} extend(self,json);delete self.methods;if(!hasMethods){each(json.methods,function(){var method=""+this;self[method]=function(){var a=[].slice.call(arguments);var ret=player._api().fp_invoke(name,method,a);return ret==='undefined'||ret===undefined?self:ret;};});hasMethods=true;}} -var fn=listeners[evt];if(fn){fn.apply(self,arg);if(evt.substring(0,1)=="_"){delete listeners[evt];}}}});};function Player(wrapper,params,conf){var -self=this,api=null,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,playerIndex,activeIndex,swfHeight,wrapperHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null);},getParent:function(){return wrapper;},hide:function(all){if(all){wrapper.style.height="0px";} -if(api){api.style.height="0px";} -return self;},show:function(){wrapper.style.height=wrapperHeight+"px";if(api){api.style.height=swfHeight+"px";} -return self;},isHidden:function(){return api&&parseInt(api.style.height,10)===0;},load:function(fn){if(!api&&self._fireEvent("onBeforeLoad")!==false){each(players,function(){this.unload();});html=wrapper.innerHTML;if(html&&!flashembed.isSupported(params.version)){wrapper.innerHTML="";} -flashembed(wrapper,params,{config:conf});if(fn){fn.cached=true;bind(listeners,"onLoad",fn);}} -return self;},unload:function(){if(html.replace(/\s/g,'')!==''){if(self._fireEvent("onBeforeUnload")===false){return self;} -try{if(api){api.fp_close();self._fireEvent("onUnload");}}catch(error){} -api=null;wrapper.innerHTML=html;} +var fn=listeners[evt];if(fn){var ret=fn.apply(self,arg);if(evt.slice(0,1)=="_"){delete listeners[evt];} +return ret;} +return self;}});};function Player(wrapper,params,conf){var self=this,api=null,isUnloading=false,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,playerIndex,activeIndex,swfHeight,wrapperHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null&&api.fp_play!==undefined&&!isUnloading);},getParent:function(){return wrapper;},hide:function(all){if(all){wrapper.style.height="0px";} +if(self.isLoaded()){api.style.height="0px";} +return self;},show:function(){wrapper.style.height=wrapperHeight+"px";if(self.isLoaded()){api.style.height=swfHeight+"px";} +return self;},isHidden:function(){return self.isLoaded()&&parseInt(api.style.height,10)===0;},load:function(fn){if(!self.isLoaded()&&self._fireEvent("onBeforeLoad")!==false){var onPlayersUnloaded=function(){html=wrapper.innerHTML;if(html&&!flashembed.isSupported(params.version)){wrapper.innerHTML="";} +if(fn){fn.cached=true;bind(listeners,"onLoad",fn);} +flashembed(wrapper,params,{config:conf});};var unloadedPlayersNb=0;each(players,function(){this.unload(function(wasUnloaded){if(++unloadedPlayersNb==players.length){onPlayersUnloaded();}});});} +return self;},unload:function(fn){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(fn){fn(false);} +return self;} +if(html.replace(/\s/g,'')!==''){if(self._fireEvent("onBeforeUnload")===false){if(fn){fn(false);} +return self;} +isUnloading=true;try{if(api){api.fp_close();self._fireEvent("onUnload");}}catch(error){} +var clean=function(){api=null;wrapper.innerHTML=html;isUnloading=false;if(fn){fn(true);}};setTimeout(clean,50);} +else if(fn){fn(false);} return self;},getClip:function(index){if(index===undefined){index=activeIndex;} return playlist[index];},getCommonClip:function(){return commonClip;},getPlaylist:function(){return playlist;},getPlugin:function(name){var plugin=plugins[name];if(!plugin&&self.isLoaded()){var json=self._api().fp_getPlugin(name);if(json){plugin=new Plugin(name,json,self);plugins[name]=plugin;}} -return plugin;},getScreen:function(){return self.getPlugin("screen");},getControls:function(){return self.getPlugin("controls");},getConfig:function(copy){return copy?clone(conf):conf;},getFlashParams:function(){return params;},loadPlugin:function(name,url,props,fn){if(typeof props=='function'){fn=props;props={};} -var fnId=fn?makeId():"_";self._api().fp_loadPlugin(name,url,props,fnId);var arg={};arg[fnId]=fn;var p=new Plugin(name,null,self,arg);plugins[name]=p;return p;},getState:function(){return api?api.fp_getState():-1;},play:function(clip,instream){function play(){if(clip!==undefined){self._api().fp_play(clip,instream);}else{self._api().fp_play();}} -if(api){play();}else{self.load(function(){play();});} -return self;},getVersion:function(){var js="flowplayer.js 3.1.4";if(api){var ver=api.fp_getVersion();ver.push(js);return ver;} -return js;},_api:function(){if(!api){throw"Flowplayer "+self.id()+" not loaded when calling an API method";} -return api;},setClip:function(clip){self.setPlaylist([clip]);return self;},getIndex:function(){return playerIndex;}});each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var name="on"+this;if(name.indexOf("*")!=-1){name=name.substring(0,name.length-1);var name2="onBefore"+name.substring(2);self[name2]=function(fn){bind(listeners,name2,fn);return self;};} -self[name]=function(fn){bind(listeners,name,fn);return self;};});each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed").split(","),function(){var name=this;self[name]=function(a1,a2){if(!api){return self;} +return plugin;},getScreen:function(){return self.getPlugin("screen");},getControls:function(){return self.getPlugin("controls")._fireEvent("onUpdate");},getLogo:function(){try{return self.getPlugin("logo")._fireEvent("onUpdate");}catch(ignored){}},getPlay:function(){return self.getPlugin("play")._fireEvent("onUpdate");},getConfig:function(copy){return copy?clone(conf):conf;},getFlashParams:function(){return params;},loadPlugin:function(name,url,props,fn){if(typeof props=='function'){fn=props;props={};} +var fnId=fn?makeId():"_";self._api().fp_loadPlugin(name,url,props,fnId);var arg={};arg[fnId]=fn;var p=new Plugin(name,null,self,arg);plugins[name]=p;return p;},getState:function(){return self.isLoaded()?api.fp_getState():-1;},play:function(clip,instream){var p=function(){if(clip!==undefined){self._api().fp_play(clip,instream);}else{self._api().fp_play();}};if(self.isLoaded()){p();}else if(isUnloading){setTimeout(function(){self.play(clip,instream);},50);}else{self.load(function(){p();});} +return self;},getVersion:function(){var js="flowplayer.js 3.2.6";if(self.isLoaded()){var ver=api.fp_getVersion();ver.push(js);return ver;} +return js;},_api:function(){if(!self.isLoaded()){throw"Flowplayer "+self.id()+" not loaded when calling an API method";} +return api;},setClip:function(clip){self.setPlaylist([clip]);return self;},getIndex:function(){return playerIndex;},_swfHeight:function(){return api.clientHeight;}});each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var name="on"+this;if(name.indexOf("*")!=-1){name=name.slice(0,name.length-1);var name2="onBefore"+name.slice(2);self[name2]=function(fn){bind(listeners,name2,fn);return self;};} +self[name]=function(fn){bind(listeners,name,fn);return self;};});each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var name=this;self[name]=function(a1,a2){if(!self.isLoaded()){return self;} var ret=null;if(a1!==undefined&&a2!==undefined){ret=api["fp_"+name](a1,a2);}else{ret=(a1===undefined)?api["fp_"+name]():api["fp_"+name](a1);} return ret==='undefined'||ret===undefined?self:ret;};});self._fireEvent=function(a){if(typeof a=='string'){a=[a];} var evt=a[0],arg0=a[1],arg1=a[2],arg2=a[3],i=0;if(conf.debug){log(a);} -if(!api&&evt=='onLoad'&&arg0=='player'){api=api||el(apiId);swfHeight=api.clientHeight;each(playlist,function(){this._fireEvent("onLoad");});each(plugins,function(name,p){p._fireEvent("onUpdate");});commonClip._fireEvent("onLoad");} +if(!self.isLoaded()&&evt=='onLoad'&&arg0=='player'){api=api||el(apiId);swfHeight=self._swfHeight();each(playlist,function(){this._fireEvent("onLoad");});each(plugins,function(name,p){p._fireEvent("onUpdate");});commonClip._fireEvent("onLoad");} if(evt=='onLoad'&&arg0!='player'){return;} if(evt=='onError'){if(typeof arg0=='string'||(typeof arg0=='number'&&typeof arg1=='number')){arg0=arg1;arg1=arg2;}} if(evt=='onContextMenu'){each(conf.contextMenu[arg0],function(key,fn){fn.call(self);});return;} -if(evt=='onPluginEvent'){var name=arg0.name||arg0;var p=plugins[name];if(p){p._fireEvent("onUpdate",arg0);p._fireEvent(arg1,a.slice(3));} +if(evt=='onPluginEvent'||evt=='onBeforePluginEvent'){var name=arg0.name||arg0;var p=plugins[name];if(p){p._fireEvent("onUpdate",arg0);return p._fireEvent(arg1,a.slice(3));} return;} if(evt=='onPlaylistReplace'){playlist=[];var index=0;each(arg0,function(){playlist.push(new Clip(this,index++,self));});} if(evt=='onClipAdd'){if(arg0.isInStream){return;} @@ -72,60 +77,143 @@ if(!clip||ret!==false){ret=commonClip._fireEvent(evt,arg1,arg2,clip);}} each(listeners[evt],function(){ret=this.call(self,arg0,arg1);if(this.cached){listeners[evt].splice(i,1);} if(ret===false){return false;} i++;});return ret;};function init(){if($f(wrapper)){$f(wrapper).getParent().innerHTML="";playerIndex=$f(wrapper).getIndex();players[playerIndex]=self;}else{players.push(self);playerIndex=players.length-1;} -wrapperHeight=parseInt(wrapper.style.height,10)||wrapper.clientHeight;if(typeof params=='string'){params={src:params};} -playerId=wrapper.id||"fp"+makeId();apiId=params.id||playerId+"_api";params.id=apiId;conf.playerId=playerId;if(typeof conf=='string'){conf={clip:{url:conf}};} +wrapperHeight=parseInt(wrapper.style.height,10)||wrapper.clientHeight;playerId=wrapper.id||"fp"+makeId();apiId=params.id||playerId+"_api";params.id=apiId;conf.playerId=playerId;if(typeof conf=='string'){conf={clip:{url:conf}};} if(typeof conf.clip=='string'){conf.clip={url:conf.clip};} conf.clip=conf.clip||{};if(wrapper.getAttribute("href",2)&&!conf.clip.url){conf.clip.url=wrapper.getAttribute("href",2);} commonClip=new Clip(conf.clip,-1,self);conf.playlist=conf.playlist||[conf.clip];var index=0;each(conf.playlist,function(){var clip=this;if(typeof clip=='object'&&clip.length){clip={url:""+clip};} each(conf.clip,function(key,val){if(val!==undefined&&clip[key]===undefined&&typeof val!='function'){clip[key]=val;}});conf.playlist[index]=clip;clip=new Clip(clip,index,self);playlist.push(clip);index++;});each(conf,function(key,val){if(typeof val=='function'){if(commonClip[key]){commonClip[key](val);}else{bind(listeners,key,val);} delete conf[key];}});each(conf.plugins,function(name,val){if(val){plugins[name]=new Plugin(name,val,self);}});if(!conf.plugins||conf.plugins.controls===undefined){plugins.controls=new Plugin("controls",null,self);} -plugins.canvas=new Plugin("canvas",null,self);params.bgcolor=params.bgcolor||"#000000";params.version=params.version||[9,0];params.expressInstall='http://www.flowplayer.org/swf/expressinstall.swf';function doClick(e){if(!self.isLoaded()&&self._fireEvent("onBeforeClick")!==false){self.load();} +plugins.canvas=new Plugin("canvas",null,self);html=wrapper.innerHTML;function doClick(e){var hasiPadSupport=self.hasiPadSupport&&self.hasiPadSupport();if(/iPad|iPhone|iPod/i.test(navigator.userAgent)&&!/.flv$/i.test(playlist[0].url)&&!hasiPadSupport){return true;} +if(!self.isLoaded()&&self._fireEvent("onBeforeClick")!==false){self.load();} return stopEvent(e);} -html=wrapper.innerHTML;if(html.replace(/\s/g,'')!==''){if(wrapper.addEventListener){wrapper.addEventListener("click",doClick,false);}else if(wrapper.attachEvent){wrapper.attachEvent("onclick",doClick);}}else{if(wrapper.addEventListener){wrapper.addEventListener("click",stopEvent,false);} +function installPlayer(){if(html.replace(/\s/g,'')!==''){if(wrapper.addEventListener){wrapper.addEventListener("click",doClick,false);}else if(wrapper.attachEvent){wrapper.attachEvent("onclick",doClick);}}else{if(wrapper.addEventListener){wrapper.addEventListener("click",stopEvent,false);} self.load();}} -if(typeof wrapper=='string'){flashembed.domReady(function(){var node=el(wrapper);if(!node){throw"Flowplayer cannot access element: "+wrapper;}else{wrapper=node;init();}});}else{init();}} +setTimeout(installPlayer,0);} +if(typeof wrapper=='string'){var node=el(wrapper);if(!node){throw"Flowplayer cannot access element: "+wrapper;} +wrapper=node;init();}else{init();}} var players=[];function Iterator(arr){this.length=arr.length;this.each=function(fn){each(arr,fn);};this.size=function(){return arr.length;};} window.flowplayer=window.$f=function(){var instance=null;var arg=arguments[0];if(!arguments.length){each(players,function(){if(this.isLoaded()){instance=this;return false;}});return instance||players[0];} if(arguments.length==1){if(typeof arg=='number'){return players[arg];}else{if(arg=='*'){return new Iterator(players);} each(players,function(){if(this.id()==arg.id||this.id()==arg||this.getParent()==arg){instance=this;return false;}});return instance;}} -if(arguments.length>1){var swf=arguments[1];var conf=(arguments.length==3)?arguments[2]:{};if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(swf),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:arg,swf,conf);}}else if(arg){return new Player(arg,swf,conf);}} -return null;};extend(window.$f,{fireEvent:function(){var a=[].slice.call(arguments);var p=$f(a[0]);return p?p._fireEvent(a.slice(1)):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(typeof jQuery=='function'){jQuery.prototype.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);} -return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}})();(function(){var jQ=typeof jQuery=='function';var options={width:'100%',height:'100%',allowfullscreen:true,allowscriptaccess:'always',quality:'high',version:null,onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(jQ){jQuery.tools=jQuery.tools||{};jQuery.tools.flashembed={version:'1.0.4',conf:options};} -function isDomReady(){if(domReady.done){return false;} -var d=document;if(d&&d.getElementsByTagName&&d.getElementById&&d.body){clearInterval(domReady.timer);domReady.timer=null;for(var i=0;i1){var params=arguments[1],conf=(arguments.length==3)?arguments[2]:{};if(typeof params=='string'){params={src:params};} +params=extend({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:false},params);if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(params),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:arg,params,conf);}}else if(arg){return new Player(arg,params,conf);}} +return null;};extend(window.$f,{fireEvent:function(){var a=[].slice.call(arguments);var p=$f(a[0]);return p?p._fireEvent(a.slice(1)):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(typeof jQuery=='function'){jQuery.fn.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);} +return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}})();(function(){var IE=document.all,URL='http://www.adobe.com/go/getflashplayer',JQUERY=typeof jQuery=='function',RE=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,GLOBAL_OPTS={width:'100%',height:'100%',id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:'always',quality:'high',version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});} +function extend(to,from){if(from){for(var key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}} return to;} -var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function string2JsonString(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';} -function asString(obj){switch(typeOf(obj)){case'string':return string2JsonString(obj);case'array':return'['+map(obj,function(el){return asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+asString(obj[prop]));}} -return'{'+str.join(',')+'}';} -return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");} -function typeOf(obj){if(obj===null||obj===undefined){return false;} -var type=typeof obj;return(type=='object'&&obj.push)?'array':type;} -if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});} function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}} return newArr;} -function getHTML(p,c){var e=extend({},p);var ie=document.all;var html='';} -e.width=e.height=e.id=e.w3c=e.src=null;for(var k in e){if(e[k]!==null){html+='';}} -var vars="";if(c){for(var key in c){if(c[key]!==null){vars+=encodeURIComponent(key)+'=' -+encodeURIComponent(typeof c[key]=='object'?asString(c[key]):c[key]) +window.flashembed=function(root,opts,conf){if(typeof root=='string'){root=document.getElementById(root.replace("#",""));} +if(!root){return;} +if(typeof opts=='string'){opts={src:opts};} +return new Flash(root,extend(extend({},GLOBAL_OPTS),opts),conf);};var f=extend(window.flashembed,{conf:GLOBAL_OPTS,getVersion:function(){var fo,ver;try{ver=navigator.plugins["Shockwave Flash"].description.slice(16);}catch(e){try{fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");ver=fo&&fo.GetVariable("$version");}catch(err){try{fo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");ver=fo&&fo.GetVariable("$version");}catch(err2){}}} +ver=RE.exec(ver);return ver?[ver[1],ver[3]]:[0,0];},asString:function(obj){if(obj===null||obj===undefined){return null;} +var type=typeof obj;if(type=='object'&&obj.push){type='array';} +switch(type){case'string':return string2JsonString(obj);case'array':return'['+map(obj,function(el){return f.asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+f.asString(obj[prop]));}} +return'{'+str.join(',')+'}';} +return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");},getHTML:function(opts,conf){opts=extend({},opts);var html='';} +opts.width=opts.height=opts.id=opts.w3c=opts.src=null;opts.onFail=opts.version=opts.expressInstall=null;for(var key in opts){if(opts[key]){html+='';}} +var vars="";if(conf){for(var k in conf){if(conf[k]){var val=conf[k];vars+=encodeURIComponent(k)+'=' ++encodeURIComponent(/function|object/.test(typeof val)?f.asString(val):val) +'&';}} -vars=vars.substring(0,vars.length-1);html+='';} -html+="";return html;} -function Flash(root,opts,flashvars){var version=flashembed.getVersion();extend(this,{getContainer:function(){return root;},getConf:function(){return opts;},getVersion:function(){return version;},getFlashvars:function(){return flashvars;},getApi:function(){return root.firstChild;},getHTML:function(){return getHTML(opts,flashvars);}});var required=opts.version;var express=opts.expressInstall;var ok=!required||flashembed.isSupported(required);if(ok){opts.onFail=opts.version=opts.expressInstall=null;root.innerHTML=getHTML(opts,flashvars);}else if(required&&express&&flashembed.isSupported([6,65])){extend(opts,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML(opts,flashvars);}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="

          Flash version "+required+" or greater is required

          "+"

          "+ -(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"

          "+ -(root.tagName=='A'?"

          Click here to download latest version

          ":"

          Download latest version from here

          ");if(root.tagName=='A'){root.onclick=function(){location.href='http://www.adobe.com/go/getflashplayer';};}}} -if(!ok&&opts.onFail){var ret=opts.onFail.call(this);if(typeof ret=='string'){root.innerHTML=ret;}} -if(document.all){window[opts.id]=document.getElementById(opts.id);}} -window.flashembed=function(root,conf,flashvars){if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{domReady(function(){flashembed(root,conf,flashvars);});return;}} +vars=vars.slice(0,-1);html+='';} +html+="
          ";return html;},isSupported:function(ver){return VERSION[0]>ver[0]||VERSION[0]==ver[0]&&VERSION[1]>=ver[1];}});var VERSION=f.getVersion();function Flash(root,opts,conf){if(f.isSupported(opts.version)){root.innerHTML=f.getHTML(opts,conf);}else if(opts.expressInstall&&f.isSupported([6,65])){root.innerHTML=f.getHTML(extend(opts,{src:opts.expressInstall}),{MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title});}else{if(!root.innerHTML.replace(/\s/g,'')){root.innerHTML="

          Flash version "+opts.version+" or greater is required

          "+"

          "+ +(VERSION[0]>0?"Your version is "+VERSION:"You have no flash plugin installed")+"

          "+ +(root.tagName=='A'?"

          Click here to download latest version

          ":"

          Download latest version from here

          ");if(root.tagName=='A'){root.onclick=function(){location.href=URL;};}} +if(opts.onFail){var ret=opts.onFail.call(this);if(typeof ret=='string'){root.innerHTML=ret;}}} +if(IE){window[opts.id]=document.getElementById(opts.id);} +extend(this,{getRoot:function(){return root;},getOptions:function(){return opts;},getConf:function(){return conf;},getApi:function(){return root.firstChild;}});} +var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function string2JsonString(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';} +if(JQUERY){jQuery.tools=jQuery.tools||{version:'3.2.6'};jQuery.tools.flashembed={conf:GLOBAL_OPTS};jQuery.fn.flashembed=function(opts,conf){return this.each(function(){jQuery(this).data("flashembed",flashembed(this,opts,conf));});};}})();$f.addPlugin("ipad",function(options){var STATE_UNLOADED=-1;var STATE_LOADED=0;var STATE_UNSTARTED=1;var STATE_BUFFERING=2;var STATE_PLAYING=3;var STATE_PAUSED=4;var STATE_ENDED=5;var self=this;var currentVolume=1;var onStartFired=false;var stopping=false;var playAfterSeek=false;var activeIndex=0;var activePlaylist=[];var clipDefaults={accelerated:false,autoBuffering:false,autoPlay:true,baseUrl:null,bufferLength:3,connectionProvider:null,cuepointMultiplier:1000,cuepoints:[],controls:{},duration:0,extension:'',fadeInSpeed:1000,fadeOutSpeed:1000,image:false,linkUrl:null,linkWindow:'_self',live:false,metaData:{},originalUrl:null,position:0,playlist:[],provider:'http',scaling:'scale',seekableOnBegin:false,start:0,url:null,urlResolvers:[]};var currentState=STATE_UNLOADED;var previousState=STATE_UNLOADED;var isiDevice=/iPad|iPhone|iPod/i.test(navigator.userAgent);var video=null;function extend(to,from,includeFuncs){if(from){for(key in from){if(key){if(from[key]&&typeof from[key]=="function"&&!includeFuncs) +continue;if(from[key]&&typeof from[key]=="object"&&from[key].length==undefined){var cp={};extend(cp,from[key]);to[key]=cp;}else{to[key]=from[key];}}}} +return to;} +var opts={simulateiDevice:false,controlsSizeRatio:1.5,controls:true,debug:false,validExtensions:/mov|m4v|mp4|avi/gi};extend(opts,options);function log(){if(opts.debug){if(isiDevice){var str=[].splice.call(arguments,0).join(', ');console.log.apply(console,[str]);}else{console.log.apply(console,arguments);}}} +function stateDescription(state){switch(state){case-1:return"UNLOADED";case 0:return"LOADED";case 1:return"UNSTARTED";case 2:return"BUFFERING";case 3:return"PLAYING";case 4:return"PAUSED";case 5:return"ENDED";} +return"UNKOWN";} +function actionAllowed(eventName){var ret=$f.fireEvent(self.id(),"onBefore"+eventName,activeIndex);return ret!==false;} +function stopEvent(e){e.stopPropagation();e.preventDefault();return false;} +function setState(state,force){if(currentState==STATE_UNLOADED&&!force) +return;previousState=currentState;currentState=state;stopPlayTimeTracker();if(state==STATE_PLAYING) +startPlayTimeTracker();log(stateDescription(state));} +function resetState(){video.fp_stop();onStartFired=false;stopping=false;playAfterSeek=false;setState(STATE_UNSTARTED);setState(STATE_UNSTARTED);} +var _playTimeTracker=null;function startPlayTimeTracker(){if(_playTimeTracker) +return;console.log("starting tracker");_playTimeTracker=setInterval(onTimeTracked,100);onTimeTracked();} +function stopPlayTimeTracker(){clearInterval(_playTimeTracker);_playTimeTracker=null;} +function onTimeTracked(){var currentTime=Math.floor(video.fp_getTime()*10)*100;var duration=Math.floor(video.duration*10)*100;var fireTime=(new Date()).time;function fireCuePointsIfNeeded(time,cues){time=time>=0?time:duration-Math.abs(time);for(var i=0;ifireTime){cues[i].lastTimeFired=-1;}else if(cues[i].lastTimeFired+500>fireTime){continue;}else{if(time==currentTime||(currentTime-500time)){cues[i].lastTimeFired=fireTime;$f.fireEvent(self.id(),'onCuepoint',activeIndex,cues[i].fnId,cues[i].parameters);}}}} +$f.each(self.getCommonClip()._cuepoints,fireCuePointsIfNeeded);$f.each(activePlaylist[activeIndex]._cuepoints,fireCuePointsIfNeeded);} +function replay(){resetState();playAfterSeek=true;video.fp_seek(0);} +function scaleVideo(clip){} +function addAPI(){function fixClip(clip){var extendedClip={};extend(extendedClip,clipDefaults);extend(extendedClip,self.getCommonClip());extend(extendedClip,clip);if(extendedClip.ipadUrl) +url=decodeURIComponent(extendedClip.ipadUrl);else if(extendedClip.url) +url=extendedClip.url;if(url&&url.indexOf('://')==-1&&extendedClip.baseUrl) +url=extendedClip.baseUrl+'/'+url;extendedClip.originalUrl=extendedClip.url;extendedClip.completeUrl=url;extendedClip.extension=extendedClip.completeUrl.substr(extendedClip.completeUrl.lastIndexOf('.'));extendedClip.type='video';delete extendedClip.index;log("fixed clip",extendedClip);return extendedClip;} +video.fp_play=function(clip,inStream,forcePlay){var url=null;var autoBuffering=true;var autoPlay=true;log("Calling play() "+clip,clip);if(inStream){log("ERROR: inStream clips not yet supported");return;} +if(clip!==undefined){if(typeof clip=="number"){if(activeIndex>=activePlaylist.length) +return;activeIndex=clip;clip=activePlaylist[activeIndex];}else{if(typeof clip=="string"){clip={url:clip};} +video.fp_setPlaylist(clip.length!==undefined?clip:[clip]);} +if(!opts.validExtensions.test(activePlaylist[activeIndex].extension)){if(activePlaylist.length>1&&activeIndex<(activePlaylist.length-1)){log("Not last clip in the playlist, moving to next one");video.fp_play(++activeIndex,false,true);} +return;} +clip=activePlaylist[activeIndex];url=clip.completeUrl;if(clip.autoBuffering!==undefined&&clip.autoBuffering===false) +autoBuffering=false;if(clip.autoPlay===undefined||clip.autoPlay===true||forcePlay===true){autoBuffering=true;autoPlay=true;}else{autoPlay=false;}}else{log("clip was not given, simply calling video.play, if not already buffering");if(currentState!=STATE_BUFFERING) +video.play();return;} +log("about to play "+url,autoBuffering,autoPlay);resetState();if(url){log("Changing SRC attribute"+url);video.setAttribute('src',url);} +if(autoBuffering){if(!actionAllowed('Begin')) +return false;$f.fireEvent(self.id(),'onBegin',activeIndex);log("calling video.load()");video.load();} +if(autoPlay){log("calling video.play()");video.play();}} +video.fp_pause=function(){log("pause called");if(!actionAllowed('Pause')) +return false;video.pause();};video.fp_resume=function(){log("resume called");if(!actionAllowed('Resume')) +return false;video.play();};video.fp_stop=function(){log("stop called");if(!actionAllowed('Stop')) +return false;stopping=true;video.pause();try{video.currentTime=0;}catch(ignored){}};video.fp_seek=function(position){log("seek called "+position);if(!actionAllowed('Seek')) +return false;var seconds=0;var position=position+"";if(position.charAt(position.length-1)=='%'){var percentage=parseInt(position.substr(0,position.length-1))/100;var duration=video.duration;seconds=duration*percentage;}else{seconds=position;} +try{video.currentTime=seconds;}catch(e){log("Wrong seek time");}};video.fp_getTime=function(){return video.currentTime;};video.fp_mute=function(){log("mute called");if(!actionAllowed('Mute')) +return false;currentVolume=video.volume;video.volume=0;};video.fp_unmute=function(){if(!actionAllowed('Unmute')) +return false;video.volume=currentVolume;};video.fp_getVolume=function(){return video.volume*100;};video.fp_setVolume=function(volume){if(!actionAllowed('Volume')) +return false;video.volume=volume/100;};video.fp_toggle=function(){log('toggle called');if(self.getState()==STATE_ENDED){replay();return;} +if(video.paused) +video.fp_play();else +video.fp_pause();};video.fp_isPaused=function(){return video.paused;};video.fp_isPlaying=function(){return!video.paused;};video.fp_getPlugin=function(name){if(name=='canvas'||name=='controls'){var config=self.getConfig();return config['plugins']&&config['plugins'][name]?config['plugins'][name]:null;} +log("ERROR: no support for "+name+" plugin on iDevices");return null;};video.fp_close=function(){setState(STATE_UNLOADED);video.parentNode.removeChild(video);video=null;};video.fp_getStatus=function(){var bufferStart=0;var bufferEnd=0;try{bufferStart=video.buffered.start();bufferEnd=video.buffered.end();}catch(ignored){} +return{bufferStart:bufferStart,bufferEnd:bufferEnd,state:currentState,time:video.fp_getTime(),muted:video.muted,volume:video.fp_getVolume()};};video.fp_getState=function(){return currentState;};video.fp_startBuffering=function(){if(currentState==STATE_UNSTARTED) +video.load();};video.fp_setPlaylist=function(playlist){log("Setting playlist");activeIndex=0;for(var i=0;i1&&activeIndex<(activePlaylist.length-1)){log("Not last clip in the playlist, moving to next one");video.fp_play(++activeIndex,false,true);}};video.addEventListener('ended',onFinish,false);var onError=function(e){setState(STATE_LOADED,true);$f.fireEvent(self.id(),'onError',activeIndex,201);if(opts.onFail&&opts.onFail instanceof Function) +opts.onFail.apply(self,[]);};video.addEventListener('error',onError,false);var onPause=function(e){log("got pause event from player"+self.id());if(stopping) +return;if(currentState==STATE_BUFFERING&&previousState==STATE_UNSTARTED){log("forcing play");setTimeout(function(){video.play();},0);return;} +if(!actionAllowed('Pause')){video.fp_resume();return stopEvent(e);} +setState(STATE_PAUSED);$f.fireEvent(self.id(),'onPause',activeIndex);} +video.addEventListener('pause',onPause,false);var onSeek=function(e){$f.fireEvent(self.id(),'onBeforeSeek',activeIndex);};video.addEventListener('seeking',onSeek,false);var onSeekDone=function(e){if(stopping){stopping=false;$f.fireEvent(self.id(),'onStop',activeIndex);} +else +$f.fireEvent(self.id(),'onSeek',activeIndex);log("seek done, currentState",stateDescription(currentState));if(playAfterSeek){playAfterSeek=false;video.fp_play();}else if(currentState!=STATE_PLAYING) +video.fp_pause();};video.addEventListener('seeked',onSeekDone,false);var onVolumeChange=function(e){$f.fireEvent(self.id(),'onVolume',video.fp_getVolume());};video.addEventListener('volumechange',onVolumeChange,false);} +function onPlayerLoaded(){video.fp_play(0);} +function installControlbar(){} +if(isiDevice||opts.simulateiDevice){if(!window.flashembed.__replaced){var realFlashembed=window.flashembed;window.flashembed=function(root,opts,conf){if(typeof root=='string'){root=document.getElementById(root.replace("#",""));} if(!root){return;} -if(typeof conf=='string'){conf={src:conf};} -var opts=extend({},options);extend(opts,conf);return new Flash(root,opts,flashvars);};extend(window.flashembed,{getVersion:function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return version;}} -try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}} -if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}} -return version;},isSupported:function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;},domReady:domReady,asString:asString,getHTML:getHTML});if(jQ){jQuery.fn.flashembed=function(conf,flashvars){var el=null;this.each(function(){el=flashembed(this,conf,flashvars);});return conf.api===false?this:el;};}})(); \ No newline at end of file +var style=window.getComputedStyle(root,null);var width=parseInt(style.width);var height=parseInt(style.height);while(root.firstChild) +root.removeChild(root.firstChild);var container=document.createElement('div');var api=document.createElement('video');container.appendChild(api);root.appendChild(container);container.style.height=height+'px';container.style.width=width+'px';container.style.display='block';container.style.position='relative';container.style.background='-webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0.7)))';container.style.cursor='default';container.style.webkitUserDrag='none';api.style.height='100%';api.style.width='100%';api.style.display='block';api.id=opts.id;api.name=opts.id;api.style.cursor='pointer';api.style.webkitUserDrag='none';api.type="video/mp4";api.playerConfig=conf.config;$f.fireEvent(conf.config.playerId,'onLoad','player');};flashembed.getVersion=realFlashembed.getVersion;flashembed.asString=realFlashembed.asString;flashembed.isSupported=function(){return true;} +flashembed.__replaced=true;} +var __fireEvent=self._fireEvent;self._fireEvent=function(a){if(a[0]=='onLoad'&&a[1]=='player'){video=self.getParent().querySelector('video');if(opts.controls) +video.controls="controls";addAPI();addListeners();setState(STATE_LOADED,true);video.fp_setPlaylist(video.playerConfig.playlist);onPlayerLoaded();__fireEvent.apply(self,[a]);} +var shouldFireEvent=currentState!=STATE_UNLOADED;if(currentState==STATE_UNLOADED&&typeof a=='string') +shouldFireEvent=true;if(shouldFireEvent) +return __fireEvent.apply(self,[a]);} +self._swfHeight=function(){return parseInt(video.style.height);} +self.hasiPadSupport=function(){return true;}} +return self;}); \ No newline at end of file diff --git a/lib/flowplayer.pseudostreaming.swf b/lib/flowplayer.pseudostreaming.swf index 91b3fdd6..28f5d72a 100644 Binary files a/lib/flowplayer.pseudostreaming.swf and b/lib/flowplayer.pseudostreaming.swf differ diff --git a/lib/flowplayer.swf b/lib/flowplayer.swf index 63f3934a..20a41193 100644 Binary files a/lib/flowplayer.swf and b/lib/flowplayer.swf differ diff --git a/modules/gallery/views/movieplayer.html.php b/modules/gallery/views/movieplayer.html.php index 5c280a36..96d6532c 100644 --- a/modules/gallery/views/movieplayer.html.php +++ b/modules/gallery/views/movieplayer.html.php @@ -22,5 +22,5 @@ } } } - ) + ).ipad(); -- cgit v1.2.3 From 7ec0cc748ac4c2a3b3d11abfbfd0ba50eb63f182 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 13:55:23 -0700 Subject: Fix for ticket #1699. Make the link to return to the gallery installation clearer. --- modules/gallery/views/upgrader.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php index ad2e3421..70d37dd1 100644 --- a/modules/gallery/views/upgrader.html.php +++ b/modules/gallery/views/upgrader.html.php @@ -27,7 +27,7 @@ -- cgit v1.2.3 From a469146084e7ba064f171609849c4d8590424f88 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 14:43:33 -0700 Subject: module.info and theme.info files now support author name, author url, info url and discussion url fields. Those fields show up in the Admin > Modules and Admin > Appearance > Theme Choice pages. All official modules and themes updated to contain these values. Fixes #1696, #1698. --- modules/gallery/module.info | 4 ++ modules/gallery/views/admin_modules.html.php | 52 +++++++++++++++++++++- modules/gallery/views/admin_themes.html.php | 12 +++-- .../gallery/views/admin_themes_buttonset.html.php | 47 +++++++++++++++++++ 4 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 modules/gallery/views/admin_themes_buttonset.html.php (limited to 'modules') diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 74c0658f..fc522d78 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,7 @@ name = "Gallery 3" description = "Gallery core application" version = 49 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:gallery" +discuss_url = "http://gallery.menalto.com/forum_module_gallery" diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index 2cc81b0d..ecd51d30 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -43,7 +43,7 @@

          - + adding more modules! Each module provides new cool features.", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Modules")) ?>

          @@ -55,6 +55,7 @@
      + $module_info): ?> "> @@ -64,6 +65,55 @@ +
      name) ?> version ?> description) ?> + +
      diff --git a/modules/gallery/views/admin_themes.html.php b/modules/gallery/views/admin_themes.html.php index d14e8bd4..7d947b28 100644 --- a/modules/gallery/views/admin_themes.html.php +++ b/modules/gallery/views/admin_themes.html.php @@ -10,7 +10,7 @@

      - + with a new theme! There are separate themes for the regular site and for the administration interface. Click a theme below to preview and activate it.", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?>

      @@ -23,6 +23,7 @@

      description ?>

      + info = $themes[$site]; print $v; ?>

      @@ -40,13 +41,14 @@ description ?>

      + info = $info; print $v; ?>

      - + Download one now!", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Modules")) ?>

    @@ -61,6 +63,7 @@

    description ?>

    + info = $themes[$admin]; print $v; ?>

    @@ -78,17 +81,18 @@ description ?>

    + info = $info; print $v; ?>

    - + Download one now!", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Modules")) ?>

    - \ No newline at end of file + diff --git a/modules/gallery/views/admin_themes_buttonset.html.php b/modules/gallery/views/admin_themes_buttonset.html.php new file mode 100644 index 00000000..5166f36c --- /dev/null +++ b/modules/gallery/views/admin_themes_buttonset.html.php @@ -0,0 +1,47 @@ + -- cgit v1.2.3 From ba20d5a500fbc724376a2fc749ee2c645041a6e1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 14:46:07 -0700 Subject: Oops, this is the rest of the modules and themes for #1696 and #1698. --- modules/akismet/module.info | 4 ++++ modules/comment/module.info | 4 ++++ modules/digibug/module.info | 4 ++++ modules/exif/module.info | 4 ++++ modules/g2_import/module.info | 4 ++++ modules/image_block/module.info | 4 ++++ modules/info/module.info | 4 ++++ modules/notification/module.info | 4 ++++ modules/organize/module.info | 4 ++++ modules/recaptcha/module.info | 4 ++++ modules/rest/module.info | 4 ++++ modules/rss/module.info | 4 ++++ modules/search/module.info | 4 ++++ modules/server_add/module.info | 4 ++++ modules/slideshow/module.info | 4 ++++ modules/tag/module.info | 4 ++++ modules/user/module.info | 4 ++++ modules/watermark/module.info | 4 ++++ themes/admin_wind/theme.info | 4 ++++ themes/wind/theme.info | 4 ++++ 20 files changed, 80 insertions(+) (limited to 'modules') diff --git a/modules/akismet/module.info b/modules/akismet/module.info index b61ed107..afc649d3 100644 --- a/modules/akismet/module.info +++ b/modules/akismet/module.info @@ -1,3 +1,7 @@ name = "Akismet" description = "Filter comments through the Akismet web service to detect and eliminate spam (http://akismet.com). You'll need a WordPress.com API key to use it." version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:akismet" +discuss_url = "http://gallery.menalto.com/forum_module_akismet" diff --git a/modules/comment/module.info b/modules/comment/module.info index e5aa454d..63c6af1c 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,7 @@ name = "Comments" description = "Allows users and guests to leave comments on photos and albums." version = 4 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:comment" +discuss_url = "http://gallery.menalto.com/forum_module_comment" diff --git a/modules/digibug/module.info b/modules/digibug/module.info index be4e880a..ce437611 100644 --- a/modules/digibug/module.info +++ b/modules/digibug/module.info @@ -1,3 +1,7 @@ name = "Digibug" description = "Digibug Photo Printing Module" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:digibug" +discuss_url = "http://gallery.menalto.com/forum_module_digibug" diff --git a/modules/exif/module.info b/modules/exif/module.info index c8ae688e..c2ffbfa7 100644 --- a/modules/exif/module.info +++ b/modules/exif/module.info @@ -1,3 +1,7 @@ name = "Exif Data" description = "Extract Exif data and display it on photo pages." version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:exif" +discuss_url = "http://gallery.menalto.com/forum_module_exif" diff --git a/modules/g2_import/module.info b/modules/g2_import/module.info index 977af251..0e766255 100644 --- a/modules/g2_import/module.info +++ b/modules/g2_import/module.info @@ -1,3 +1,7 @@ name = "Gallery2 Import" description = "Import your Gallery 2 content into Gallery 3" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:g2_import" +discuss_url = "http://gallery.menalto.com/forum_module_g2_import" diff --git a/modules/image_block/module.info b/modules/image_block/module.info index 6836fabc..aa3c5461 100644 --- a/modules/image_block/module.info +++ b/modules/image_block/module.info @@ -1,3 +1,7 @@ name = "Image Block" description = "Display a random image in the sidebar" version = 3 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:image_block" +discuss_url = "http://gallery.menalto.com/forum_module_image_block" diff --git a/modules/info/module.info b/modules/info/module.info index 5f84cbb9..e8f30594 100644 --- a/modules/info/module.info +++ b/modules/info/module.info @@ -1,3 +1,7 @@ name = "Info" description = "Display extra information about photos and albums" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:info" +discuss_url = "http://gallery.menalto.com/forum_module_info" diff --git a/modules/notification/module.info b/modules/notification/module.info index 8c5e1162..dacc00f9 100644 --- a/modules/notification/module.info +++ b/modules/notification/module.info @@ -1,3 +1,7 @@ name = "Notification" description = "Send notifications to users when changes are made to watched albums." version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:notification" +discuss_url = "http://gallery.menalto.com/forum_module_notification" diff --git a/modules/organize/module.info b/modules/organize/module.info index 0d16144d..31d24379 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -1,3 +1,7 @@ name = "Organize" description = "Visually rearrange and move photos in your gallery" version = 4 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:organize" +discuss_url = "http://gallery.menalto.com/forum_module_organize" diff --git a/modules/recaptcha/module.info b/modules/recaptcha/module.info index cfa1bf7a..2a0b419b 100644 --- a/modules/recaptcha/module.info +++ b/modules/recaptcha/module.info @@ -1,3 +1,7 @@ name = "reCAPTCHA" description = "reCAPTCHA displays a graphical verification that protects the input form from abuse from 'bots,' or automated programs usually written to generate spam (http://recaptcha.net)." version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:recaptcha" +discuss_url = "http://gallery.menalto.com/forum_module_recaptcha" diff --git a/modules/rest/module.info b/modules/rest/module.info index 5aaffc28..c71c64f9 100644 --- a/modules/rest/module.info +++ b/modules/rest/module.info @@ -2,3 +2,7 @@ name = "REST API Module" description = "A REST-based API that allows desktop clients and other apps to interact with Gallery 3" version = 3 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:rest" +discuss_url = "http://gallery.menalto.com/forum_module_rest" diff --git a/modules/rss/module.info b/modules/rss/module.info index 48375da1..5ebae9e7 100644 --- a/modules/rss/module.info +++ b/modules/rss/module.info @@ -1,3 +1,7 @@ name = "RSS" description = "Provides RSS feeds" version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:rss" +discuss_url = "http://gallery.menalto.com/forum_module_rss" diff --git a/modules/search/module.info b/modules/search/module.info index f417c4fa..a1c58af5 100644 --- a/modules/search/module.info +++ b/modules/search/module.info @@ -1,3 +1,7 @@ name = "Search" description = "Allows users to search their Gallery" version = 1 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:search" +discuss_url = "http://gallery.menalto.com/forum_module_search" diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 87b317b1..754e06c1 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -1,3 +1,7 @@ name = "Server Add" description = "Allows authorized users to load images directly from your web server" version = 4 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:server_add" +discuss_url = "http://gallery.menalto.com/forum_module_server_add" diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info index b56eac81..55cdf9b8 100644 --- a/modules/slideshow/module.info +++ b/modules/slideshow/module.info @@ -1,3 +1,7 @@ name = "Slideshow" description = "Allows users to view a slideshow of photos" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:slideshow" +discuss_url = "http://gallery.menalto.com/forum_module_slideshow" diff --git a/modules/tag/module.info b/modules/tag/module.info index d9d34386..59d8dfbd 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -1,3 +1,7 @@ name = "Tags" description = "Allows users to tag photos and albums" version = 3 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:tag" +discuss_url = "http://gallery.menalto.com/forum_module_tag" diff --git a/modules/user/module.info b/modules/user/module.info index b7594815..f6dd9529 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -2,3 +2,7 @@ name = "Users and Groups" description = "Gallery 3 user and group management" version = 4 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:user" +discuss_url = "http://gallery.menalto.com/forum_module_user" diff --git a/modules/watermark/module.info b/modules/watermark/module.info index 41a871bd..1f440016 100644 --- a/modules/watermark/module.info +++ b/modules/watermark/module.info @@ -1,3 +1,7 @@ name = "Watermarks" description = "Allows users to watermark their photos" version = 2 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Module:watermark" +discuss_url = "http://gallery.menalto.com/forum_module_watermark" diff --git a/themes/admin_wind/theme.info b/themes/admin_wind/theme.info index 4034b64a..aca5c6c5 100644 --- a/themes/admin_wind/theme.info +++ b/themes/admin_wind/theme.info @@ -4,3 +4,7 @@ version = 1 author = "Gallery Team" admin = 1 site = 0 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Theme:admin_wind" +discuss_url = "http://gallery.menalto.com/forum_theme_admin_wind" diff --git a/themes/wind/theme.info b/themes/wind/theme.info index 17ea7c20..c2344c48 100644 --- a/themes/wind/theme.info +++ b/themes/wind/theme.info @@ -4,3 +4,7 @@ version = 1 author = "Gallery Team" site = 1 admin = 0 +author_name = "Gallery Team" +author_url = "http://codex.gallery2.org/Gallery:Team" +info_url = "http://codex.gallery2.org/Gallery3:Theme:wind" +discuss_url = "http://gallery.menalto.com/forum_theme_wind" -- cgit v1.2.3 From c07af35a19905f3241fb77662e8b7c84e41e9a62 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 14:53:34 -0700 Subject: Oops, fix broken codex urls. For #1698. --- modules/akismet/module.info | 2 +- modules/comment/module.info | 2 +- modules/digibug/module.info | 2 +- modules/exif/module.info | 2 +- modules/g2_import/module.info | 2 +- modules/gallery/module.info | 2 +- modules/image_block/module.info | 2 +- modules/info/module.info | 2 +- modules/notification/module.info | 2 +- modules/organize/module.info | 2 +- modules/recaptcha/module.info | 2 +- modules/rest/module.info | 2 +- modules/rss/module.info | 2 +- modules/search/module.info | 2 +- modules/server_add/module.info | 2 +- modules/slideshow/module.info | 2 +- modules/tag/module.info | 2 +- modules/user/module.info | 2 +- modules/watermark/module.info | 2 +- themes/admin_wind/theme.info | 2 +- themes/wind/theme.info | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) (limited to 'modules') diff --git a/modules/akismet/module.info b/modules/akismet/module.info index afc649d3..63473468 100644 --- a/modules/akismet/module.info +++ b/modules/akismet/module.info @@ -3,5 +3,5 @@ description = "Filter comments through the Akismet web service to detect and eli version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:akismet" +info_url = "http://codex.gallery2.org/Gallery3:Modules:akismet" discuss_url = "http://gallery.menalto.com/forum_module_akismet" diff --git a/modules/comment/module.info b/modules/comment/module.info index 63c6af1c..4e7df6f1 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -3,5 +3,5 @@ description = "Allows users and guests to leave comments on photos and albums." version = 4 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:comment" +info_url = "http://codex.gallery2.org/Gallery3:Modules:comment" discuss_url = "http://gallery.menalto.com/forum_module_comment" diff --git a/modules/digibug/module.info b/modules/digibug/module.info index ce437611..781d5f01 100644 --- a/modules/digibug/module.info +++ b/modules/digibug/module.info @@ -3,5 +3,5 @@ description = "Digibug Photo Printing Module" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:digibug" +info_url = "http://codex.gallery2.org/Gallery3:Modules:digibug" discuss_url = "http://gallery.menalto.com/forum_module_digibug" diff --git a/modules/exif/module.info b/modules/exif/module.info index c2ffbfa7..e266e20e 100644 --- a/modules/exif/module.info +++ b/modules/exif/module.info @@ -3,5 +3,5 @@ description = "Extract Exif data and display it on photo pages." version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:exif" +info_url = "http://codex.gallery2.org/Gallery3:Modules:exif" discuss_url = "http://gallery.menalto.com/forum_module_exif" diff --git a/modules/g2_import/module.info b/modules/g2_import/module.info index 0e766255..30fb46d4 100644 --- a/modules/g2_import/module.info +++ b/modules/g2_import/module.info @@ -3,5 +3,5 @@ description = "Import your Gallery 2 content into Gallery 3" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:g2_import" +info_url = "http://codex.gallery2.org/Gallery3:Modules:g2_import" discuss_url = "http://gallery.menalto.com/forum_module_g2_import" diff --git a/modules/gallery/module.info b/modules/gallery/module.info index fc522d78..42345531 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -3,5 +3,5 @@ description = "Gallery core application" version = 49 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:gallery" +info_url = "http://codex.gallery2.org/Gallery3:Modules:gallery" discuss_url = "http://gallery.menalto.com/forum_module_gallery" diff --git a/modules/image_block/module.info b/modules/image_block/module.info index aa3c5461..6722cc8f 100644 --- a/modules/image_block/module.info +++ b/modules/image_block/module.info @@ -3,5 +3,5 @@ description = "Display a random image in the sidebar" version = 3 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:image_block" +info_url = "http://codex.gallery2.org/Gallery3:Modules:image_block" discuss_url = "http://gallery.menalto.com/forum_module_image_block" diff --git a/modules/info/module.info b/modules/info/module.info index e8f30594..f8964a78 100644 --- a/modules/info/module.info +++ b/modules/info/module.info @@ -3,5 +3,5 @@ description = "Display extra information about photos and albums" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:info" +info_url = "http://codex.gallery2.org/Gallery3:Modules:info" discuss_url = "http://gallery.menalto.com/forum_module_info" diff --git a/modules/notification/module.info b/modules/notification/module.info index dacc00f9..84be8f99 100644 --- a/modules/notification/module.info +++ b/modules/notification/module.info @@ -3,5 +3,5 @@ description = "Send notifications to users when changes are made to watched albu version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:notification" +info_url = "http://codex.gallery2.org/Gallery3:Modules:notification" discuss_url = "http://gallery.menalto.com/forum_module_notification" diff --git a/modules/organize/module.info b/modules/organize/module.info index 31d24379..07b9dc38 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -3,5 +3,5 @@ description = "Visually rearrange and move photos in your gallery" version = 4 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:organize" +info_url = "http://codex.gallery2.org/Gallery3:Modules:organize" discuss_url = "http://gallery.menalto.com/forum_module_organize" diff --git a/modules/recaptcha/module.info b/modules/recaptcha/module.info index 2a0b419b..ebaff7de 100644 --- a/modules/recaptcha/module.info +++ b/modules/recaptcha/module.info @@ -3,5 +3,5 @@ description = "reCAPTCHA displays a graphical verification that protects the inp version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:recaptcha" +info_url = "http://codex.gallery2.org/Gallery3:Modules:recaptcha" discuss_url = "http://gallery.menalto.com/forum_module_recaptcha" diff --git a/modules/rest/module.info b/modules/rest/module.info index c71c64f9..33c9f1cf 100644 --- a/modules/rest/module.info +++ b/modules/rest/module.info @@ -4,5 +4,5 @@ description = "A REST-based API that allows desktop clients and other apps to in version = 3 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:rest" +info_url = "http://codex.gallery2.org/Gallery3:Modules:rest" discuss_url = "http://gallery.menalto.com/forum_module_rest" diff --git a/modules/rss/module.info b/modules/rss/module.info index 5ebae9e7..cd13c1b0 100644 --- a/modules/rss/module.info +++ b/modules/rss/module.info @@ -3,5 +3,5 @@ description = "Provides RSS feeds" version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:rss" +info_url = "http://codex.gallery2.org/Gallery3:Modules:rss" discuss_url = "http://gallery.menalto.com/forum_module_rss" diff --git a/modules/search/module.info b/modules/search/module.info index a1c58af5..1389798d 100644 --- a/modules/search/module.info +++ b/modules/search/module.info @@ -3,5 +3,5 @@ description = "Allows users to search their Gallery" version = 1 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:search" +info_url = "http://codex.gallery2.org/Gallery3:Modules:search" discuss_url = "http://gallery.menalto.com/forum_module_search" diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 754e06c1..4ce0a97d 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -3,5 +3,5 @@ description = "Allows authorized users to load images directly from your web ser version = 4 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:server_add" +info_url = "http://codex.gallery2.org/Gallery3:Modules:server_add" discuss_url = "http://gallery.menalto.com/forum_module_server_add" diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info index 55cdf9b8..8c9a3176 100644 --- a/modules/slideshow/module.info +++ b/modules/slideshow/module.info @@ -3,5 +3,5 @@ description = "Allows users to view a slideshow of photos" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:slideshow" +info_url = "http://codex.gallery2.org/Gallery3:Modules:slideshow" discuss_url = "http://gallery.menalto.com/forum_module_slideshow" diff --git a/modules/tag/module.info b/modules/tag/module.info index 59d8dfbd..75d16bf0 100644 --- a/modules/tag/module.info +++ b/modules/tag/module.info @@ -3,5 +3,5 @@ description = "Allows users to tag photos and albums" version = 3 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:tag" +info_url = "http://codex.gallery2.org/Gallery3:Modules:tag" discuss_url = "http://gallery.menalto.com/forum_module_tag" diff --git a/modules/user/module.info b/modules/user/module.info index f6dd9529..503bcd0d 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -4,5 +4,5 @@ version = 4 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:user" +info_url = "http://codex.gallery2.org/Gallery3:Modules:user" discuss_url = "http://gallery.menalto.com/forum_module_user" diff --git a/modules/watermark/module.info b/modules/watermark/module.info index 1f440016..58efa43f 100644 --- a/modules/watermark/module.info +++ b/modules/watermark/module.info @@ -3,5 +3,5 @@ description = "Allows users to watermark their photos" version = 2 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Module:watermark" +info_url = "http://codex.gallery2.org/Gallery3:Modules:watermark" discuss_url = "http://gallery.menalto.com/forum_module_watermark" diff --git a/themes/admin_wind/theme.info b/themes/admin_wind/theme.info index aca5c6c5..466d8e43 100644 --- a/themes/admin_wind/theme.info +++ b/themes/admin_wind/theme.info @@ -6,5 +6,5 @@ admin = 1 site = 0 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Theme:admin_wind" +info_url = "http://codex.gallery2.org/Gallery3:Themes:admin_wind" discuss_url = "http://gallery.menalto.com/forum_theme_admin_wind" diff --git a/themes/wind/theme.info b/themes/wind/theme.info index c2344c48..e0be78b9 100644 --- a/themes/wind/theme.info +++ b/themes/wind/theme.info @@ -6,5 +6,5 @@ site = 1 admin = 0 author_name = "Gallery Team" author_url = "http://codex.gallery2.org/Gallery:Team" -info_url = "http://codex.gallery2.org/Gallery3:Theme:wind" +info_url = "http://codex.gallery2.org/Gallery3:Themes:wind" discuss_url = "http://gallery.menalto.com/forum_theme_wind" -- cgit v1.2.3 From 92c23ea92d7c943d330c12a1c84fdcbdf2678202 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 15:10:04 -0700 Subject: Set the width of the information column to 60px to prevent icon wrap --- modules/gallery/views/admin_modules.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_modules.html.php b/modules/gallery/views/admin_modules.html.php index ecd51d30..03993bb2 100644 --- a/modules/gallery/views/admin_modules.html.php +++ b/modules/gallery/views/admin_modules.html.php @@ -55,7 +55,7 @@ - + $module_info): ?> "> -- cgit v1.2.3 From dfd50a6c1f2afc4b4e971ab6899aa69f43397e1c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 15:18:23 -0700 Subject: Partially revert the CSS change in 76a7ad3161be0994d7ba98e9dff9b317b2430bb3 to center the "Select..." button because it was causing the SWF object to vanish in Firefox. #1638. --- modules/gallery/css/gallery.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 97d09454..ecf89565 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -29,12 +29,12 @@ #g-add-photos-canvas object, #g-add-photos-button { - left: 93px; + left: 90px; margin: .5em 0; padding: .4em 1em; position: absolute; top: 0; - width: auto; + width: 300px; } #g-add-photos-canvas object { -- cgit v1.2.3 From 67d2e8081c6e5f0b679881bca3fdc81fe1e78ccc Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 16:12:10 -0700 Subject: Undo the change made in 5ce85636329b14673718836b3631a3e46efdc3bb because it messes up tag counts (and makes the test fail-- I should have run that!). Also, use Tag_Model::items() in save() to avoid code duplication. Follow-on for #1628. --- modules/tag/models/tag.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'modules') diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index d4e385a2..13e253ba 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -69,29 +69,14 @@ class Tag_Model_Core extends ORM { * to this tag. */ public function save() { - // Figure out what items have changed in this tag for our item_related_update event below - if (isset($this->object_relations["items"])) { - $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); - $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); - if (isset($this->changed_relations["items"])) { - $changed = array_merge($added, $removed); - } - $this->count = count($this->object_relations["items"]) + count($added) - count($removed); - } - // Check to see if another tag exists with the same name $duplicate_tag = ORM::factory("tag") ->where("name", "=", $this->name) ->where("id", "!=", $this->id) ->find(); if ($duplicate_tag->loaded()) { - // If so, tag its items with this tag so as to merge it. Do this after we figure out what's - // changed so that we don't notify on this change to keep churn down. - $duplicate_tag_items = ORM::factory("item") - ->join("items_tags", "items.id", "items_tags.item_id") - ->where("items_tags.tag_id", "=", $duplicate_tag->id) - ->find_all(); - foreach ($duplicate_tag_items as $item) { + // If so, tag its items with this tag so as to merge it. + foreach ($duplicate_tag->items() as $item) { $this->add($item); } @@ -99,6 +84,16 @@ class Tag_Model_Core extends ORM { $duplicate_tag->delete(); } + // Figure out what items have changed in this tag for our item_related_update event below + if (isset($this->object_relations["items"])) { + $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); + $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); + if (isset($this->changed_relations["items"])) { + $changed = array_merge($added, $removed); + } + $this->count = count($this->object_relations["items"]) + count($added) - count($removed); + } + $result = parent::save(); if (!empty($changed)) { -- cgit v1.2.3 From c3b0c96460da336bf720db0de2b396517004f514 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 23 Apr 2011 19:59:54 -0700 Subject: Revert 0235c2062e9d980a4778c4b22678238c525e1cd7 and instead apply the fix from iptox.net listed here: http://gallery.menalto.com/node/98768#comment-372398 Fixes for #1681, #1625 --- modules/gallery/helpers/graphics.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 8d8853b0..acb11bfb 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -316,10 +316,10 @@ class graphics_Core { // ImageMagick & GraphicsMagick $magick_kits = array( "imagemagick" => array( - "name" => "ImageMagick", "binary" => "convert", "version" => "convert -version", + "name" => "ImageMagick", "binary" => "convert", "version_arg" => "-v", "version_regex" => "/Version: \S+ (\S+)/"), "graphicsmagick" => array( - "name" => "GraphicsMagick", "binary" => "gm", "version" => "gm version", + "name" => "GraphicsMagick", "binary" => "gm", "version_arg" => "version", "version_regex" => "/\S+ (\S+)/")); // Loop through the kits foreach ($magick_kits as $index => $settings) { @@ -328,7 +328,8 @@ class graphics_Core { $toolkits->$index->name = $settings["name"]; if ($path) { if (@is_file($path) && - preg_match($settings["version_regex"], shell_exec($settings["version"]), $matches)) { + preg_match( + $settings["version_regex"], shell_exec($path . " " . $settings["version_arg"]), $matches)) { $version = $matches[1]; $toolkits->$index->installed = true; -- cgit v1.2.3 From c01a0eac9a09e0fc2ef4ba45a74c23a8a70f51b7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 23 Apr 2011 20:30:30 -0700 Subject: Allow the tag rename function to split a tag into multiple tags if a comma is used to delinate the seperate tags. --- modules/tag/controllers/admin_tags.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php index fd82bc92..5dc181bd 100644 --- a/modules/tag/controllers/admin_tags.php +++ b/modules/tag/controllers/admin_tags.php @@ -85,11 +85,23 @@ class Admin_Tags_Controller extends Admin_Controller { if ($in_place_edit->validate()) { $old_name = $tag->name; - $tag->name = $in_place_edit->value(); + $tag_name = $in_place_edit->value(); + Kohana_Log::add("error", $tag_name); + $tags = explode(",", $tag_name); + $tag_count = count($tags); + + $tag->name = array_shift($tags); $tag->save(); - $message = t("Renamed tag %old_name to %new_name", - array("old_name" => $old_name, "new_name" => $tag->name)); + if (!empty($tags)) { + $this->_copy_items_for_tags($tag, $tags); + $message = t("Split tag %old_name into %new_tags", + array("old_name" => $old_name, "new_tags" => $tag_name)); + } else { + $message = t("Renamed tag %old_name to %new_name", + array("old_name" => $old_name, "new_name" => $tag->name)); + } + message::success($message); log::success("tags", $message); @@ -99,5 +111,11 @@ class Admin_Tags_Controller extends Admin_Controller { } } + private function _copy_items_for_tags($tag, $tags) { + foreach ($tag->items() as $item) { + foreach ($tags as $idx => $new_tag) { + tag::add($item, trim($new_tag)); + } + } + } } - -- cgit v1.2.3 From 41f90e669f75e8e93bd31bf649011d5d315ac326 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 24 Apr 2011 07:04:11 -0700 Subject: Clarify the meaning of variable names. --- modules/tag/controllers/admin_tags.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php index 5dc181bd..7a64f7ab 100644 --- a/modules/tag/controllers/admin_tags.php +++ b/modules/tag/controllers/admin_tags.php @@ -85,18 +85,17 @@ class Admin_Tags_Controller extends Admin_Controller { if ($in_place_edit->validate()) { $old_name = $tag->name; - $tag_name = $in_place_edit->value(); - Kohana_Log::add("error", $tag_name); - $tags = explode(",", $tag_name); - $tag_count = count($tags); + $new_name_or_list = $in_place_edit->value(); + $tag_list = explode(",", $new_name_or_list); + $tag_count = count($tag_list); - $tag->name = array_shift($tags); + $tag->name = array_shift($tag_list); $tag->save(); - if (!empty($tags)) { - $this->_copy_items_for_tags($tag, $tags); - $message = t("Split tag %old_name into %new_tags", - array("old_name" => $old_name, "new_tags" => $tag_name)); + if (!empty($tag_list)) { + $this->_copy_items_for_tags($tag, $tag_list); + $message = t("Split tag %old_name into %tag_list", + array("old_name" => $old_name, "tag_list" => $new_name_or_list)); } else { $message = t("Renamed tag %old_name to %new_name", array("old_name" => $old_name, "new_name" => $tag->name)); @@ -111,10 +110,10 @@ class Admin_Tags_Controller extends Admin_Controller { } } - private function _copy_items_for_tags($tag, $tags) { + private function _copy_items_for_tags($tag, $tag_list) { foreach ($tag->items() as $item) { - foreach ($tags as $idx => $new_tag) { - tag::add($item, trim($new_tag)); + foreach ($tag_list as $new_tag_name) { + tag::add($item, trim($new_tag_name)); } } } -- cgit v1.2.3 From 7f48671186a4bf3a4745cd7a31b48a891dd83078 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 24 Apr 2011 07:15:30 -0700 Subject: For ticket #1701. Remove unused variable. --- modules/tag/controllers/admin_tags.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules') diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php index 7a64f7ab..77b5f20a 100644 --- a/modules/tag/controllers/admin_tags.php +++ b/modules/tag/controllers/admin_tags.php @@ -87,7 +87,6 @@ class Admin_Tags_Controller extends Admin_Controller { $old_name = $tag->name; $new_name_or_list = $in_place_edit->value(); $tag_list = explode(",", $new_name_or_list); - $tag_count = count($tag_list); $tag->name = array_shift($tag_list); $tag->save(); -- cgit v1.2.3 From b89c40242f85ecb49393e4fe6aeb3659550f60a4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 24 Apr 2011 07:49:41 -0700 Subject: Sentence-case the url. Fixes #1706. --- modules/g2_import/helpers/g2_import_event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import_event.php b/modules/g2_import/helpers/g2_import_event.php index 0e078d08..0afa62d8 100644 --- a/modules/g2_import/helpers/g2_import_event.php +++ b/modules/g2_import/helpers/g2_import_event.php @@ -34,7 +34,7 @@ class g2_import_event_Core { ->get("settings_menu") ->append(Menu::factory("link") ->id("g2_import") - ->label(t("Gallery 2 Import")) + ->label(t("Gallery 2 import")) ->url(url::site("admin/g2_import"))); } } -- cgit v1.2.3 From b4cdd016dc97f2df608bb14d2088cb4ddbd32c35 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 24 Apr 2011 11:53:29 -0400 Subject: Third times the charm. Rethink unordered lists and bullets. Revert to turning them off by default and provide a new class, g-text, to define a list or a section of text as needing to display bullets. --- modules/g2_import/views/admin_g2_import.html.php | 4 ++-- modules/gallery/views/admin_block_welcome.html.php | 2 +- themes/admin_wind/css/screen.css | 17 ++--------------- 3 files changed, 5 insertions(+), 18 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index cf5e4755..2f4a1b28 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -112,8 +112,8 @@ $("document").ready(function() {

    -
    -
      +
      +
      • Review permissions!") ?>
      • diff --git a/modules/gallery/views/admin_block_welcome.html.php b/modules/gallery/views/admin_block_welcome.html.php index d8c96187..d3765d19 100644 --- a/modules/gallery/views/admin_block_welcome.html.php +++ b/modules/gallery/views/admin_block_welcome.html.php @@ -2,7 +2,7 @@

        -
          +
          • graphics and language settings.", array("graphics_url" => html::mark_clean(url::site("admin/graphics")), diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index f01c2a94..6f1c0962 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -92,25 +92,12 @@ a:hover, /* Lists ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#g-content ul li { +ul.g-text li, +.g-text ul li { list-style-type: disc; margin-left: 1em; } -form ul li, -#g-action-status li, -#g-log-entries li, -#g-tag-admin li, -.g-buttonset li, -.g-buttonset-vertical li, -.g-paginator li, -.ui-sortable li, -.ui-widget-header li { - list-style: none !important; - margin-left: 0 !important; -} - - /* Forms ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ form { -- cgit v1.2.3 From f8493a1df26f242959e931d862c5f1282dd324e8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 24 Apr 2011 08:57:09 -0700 Subject: Revert my two "fixes" on top of Andy's tag combine change. Leave Tag_Model::items() calling Item_Model::viewable() because it's too dangerous to separate that out, and it's fragile to rely on only admins doing tag combines. Revert "Undo the change made in 5ce85636329b14673718836b3631a3e46efdc3bb because it messes up tag counts" - This reverts commit 67d2e8081c6e5f0b679881bca3fdc81fe1e78ccc. Revert "Move the calculation for item_related_update ahead of the duplicate" - This reverts commit 5ce85636329b14673718836b3631a3e46efdc3bb. --- modules/tag/models/tag.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index 13e253ba..bb79e707 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -75,8 +75,12 @@ class Tag_Model_Core extends ORM { ->where("id", "!=", $this->id) ->find(); if ($duplicate_tag->loaded()) { - // If so, tag its items with this tag so as to merge it. - foreach ($duplicate_tag->items() as $item) { + // If so, tag its items with this tag so as to merge it + $duplicate_tag_items = ORM::factory("item") + ->join("items_tags", "items.id", "items_tags.item_id") + ->where("items_tags.tag_id", "=", $duplicate_tag->id) + ->find_all(); + foreach ($duplicate_tag_items as $item) { $this->add($item); } @@ -84,7 +88,6 @@ class Tag_Model_Core extends ORM { $duplicate_tag->delete(); } - // Figure out what items have changed in this tag for our item_related_update event below if (isset($this->object_relations["items"])) { $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); -- cgit v1.2.3 From f4d76a8abe04612efe01f146617d760ffdd4b69f Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 24 Apr 2011 13:56:39 -0400 Subject: Don't put the Admin > Theme Options Save button in a fieldset. --- modules/gallery/controllers/admin_theme_options.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_theme_options.php b/modules/gallery/controllers/admin_theme_options.php index a968a56d..d9323ea0 100644 --- a/modules/gallery/controllers/admin_theme_options.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -108,7 +108,6 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::event("theme_edit_form", $form); - $group = $form->group("buttons"); $group->submit("")->value(t("Save")); return $form; } -- cgit v1.2.3 From ea2127c3b2ddef5709e02b4804c074bd1f942159 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 24 Apr 2011 21:02:34 -0700 Subject: Fix a bug introduced in f2477703faa7cd05ff1aa16da3ecef7b666bef40 which was a fix for #1581 that caused us to skip adding highlights for any albums that had no sub-albums. --- modules/g2_import/helpers/g2_import.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 23fb29e5..e9c19c9d 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -518,12 +518,11 @@ class g2_import_Core { static function set_album_highlight(&$queue) { // Dequeue the current album and enqueue its children list($g2_album_id, $children) = each($queue); - if (empty($children)) { - return; - } unset($queue[$g2_album_id]); - foreach ($children as $key => $value) { - $queue[$key] = $value; + if (!empty($children)) { + foreach ($children as $key => $value) { + $queue[$key] = $value; + } } $messages = array(); -- cgit v1.2.3 From 701c1fb12f2f254d8d7e7756a09cb5e825123a2f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 24 Apr 2011 22:45:45 -0700 Subject: Ignore the presort when transferring over sort orders. Fixes #1710. --- modules/g2_import/helpers/g2_import.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index e9c19c9d..50ab8a23 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -475,9 +475,10 @@ class g2_import_Core { 1 => "ASC", ORDER_ASCENDING => "ASC", ORDER_DESCENDING => "DESC"); - // Only consider G2's first sort order + // G2 sorts can either be or |. Right now we can't + // map presorts so ignore them. $g2_order = explode("|", $g2_album->getOrderBy() . ""); - $g2_order = $g2_order[0]; + $g2_order = end($g2_order); if (empty($g2_order)) { $g2_order = g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderBy')); } -- cgit v1.2.3 From 953be781dc91254599224fa6e95fcc435e787975 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 24 Apr 2011 22:51:14 -0700 Subject: Refactor the meat of g2_import::import_album() off into a separate function so taht we can call it on the root album as well. Fixes --- modules/g2_import/helpers/g2_import.php | 96 +++++++++++++++------------- modules/g2_import/helpers/g2_import_task.php | 6 ++ 2 files changed, 58 insertions(+), 44 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 50ab8a23..22a054ac 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -448,50 +448,8 @@ class g2_import_Core { $album = ORM::factory("item"); $album->type = "album"; $album->parent_id = self::map($g2_album->getParentId()); - $album->name = $g2_album->getPathComponent(); - $album->title = self::_decode_html_special_chars($g2_album->getTitle()); - $album->title or $album->title = $album->name; - $album->description = self::_decode_html_special_chars(self::extract_description($g2_album)); - $album->owner_id = self::map($g2_album->getOwnerId()); - try { - $album->view_count = (int) g2(GalleryCoreApi::fetchItemViewCount($g2_album_id)); - } catch (Exception $e) { - // @todo log - $album->view_count = 0; - } - $album->created = $g2_album->getCreationTimestamp(); - - $order_map = array( - "originationTimestamp" => "captured", - "creationTimestamp" => "created", - "description" => "description", - "modificationTimestamp" => "updated", - "orderWeight" => "weight", - "pathComponent" => "name", - "summary" => "description", - "title" => "title", - "viewCount" => "view_count"); - $direction_map = array( - 1 => "ASC", - ORDER_ASCENDING => "ASC", - ORDER_DESCENDING => "DESC"); - // G2 sorts can either be or |. Right now we can't - // map presorts so ignore them. - $g2_order = explode("|", $g2_album->getOrderBy() . ""); - $g2_order = end($g2_order); - if (empty($g2_order)) { - $g2_order = g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderBy')); - } - $g2_order_direction = explode("|", $g2_album->getOrderDirection() . ""); - $g2_order_direction = $g2_order_direction[0]; - if (empty($g2_order_direction)) { - $g2_order_direction = - g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderDirection')); - } - if (array_key_exists($g2_order, $order_map)) { - $album->sort_column = $order_map[$g2_order]; - $album->sort_order = $direction_map[$g2_order_direction]; - } + + g2_import::set_album_values($album, $g2_album); try { $album->save(); @@ -513,6 +471,56 @@ class g2_import_Core { self::_import_permissions($g2_album, $album); } + /** + * Transfer over all the values from a G2 album to a G3 album. + */ + static function set_album_values($album, $g2_album) { + $album->name = $g2_album->getPathComponent(); + $album->title = self::_decode_html_special_chars($g2_album->getTitle()); + $album->title or $album->title = $album->name; + $album->description = self::_decode_html_special_chars(self::extract_description($g2_album)); + $album->owner_id = self::map($g2_album->getOwnerId()); + try { + $album->view_count = (int) g2(GalleryCoreApi::fetchItemViewCount($g2_album_id)); + } catch (Exception $e) { + // @todo log + $album->view_count = 0; + } + $album->created = $g2_album->getCreationTimestamp(); + + $order_map = array( + "originationTimestamp" => "captured", + "creationTimestamp" => "created", + "description" => "description", + "modificationTimestamp" => "updated", + "orderWeight" => "weight", + "pathComponent" => "name", + "summary" => "description", + "title" => "title", + "viewCount" => "view_count"); + $direction_map = array( + 1 => "ASC", + ORDER_ASCENDING => "ASC", + ORDER_DESCENDING => "DESC"); + // G2 sorts can either be or |. Right now we can't + // map presorts so ignore them. + $g2_order = explode("|", $g2_album->getOrderBy() . ""); + $g2_order = end($g2_order); + if (empty($g2_order)) { + $g2_order = g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderBy')); + } + $g2_order_direction = explode("|", $g2_album->getOrderDirection() . ""); + $g2_order_direction = $g2_order_direction[0]; + if (empty($g2_order_direction)) { + $g2_order_direction = + g2(GalleryCoreApi::getPluginParameter('module', 'core', 'default.orderDirection')); + } + if (array_key_exists($g2_order, $order_map)) { + $album->sort_column = $order_map[$g2_order]; + $album->sort_order = $direction_map[$g2_order_direction]; + } + } + /** * Set the highlight properly for a single album */ diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php index 5e908676..31615a55 100644 --- a/modules/g2_import/helpers/g2_import_task.php +++ b/modules/g2_import/helpers/g2_import_task.php @@ -127,6 +127,12 @@ class g2_import_task_Core { $g2_root_id = g2(GalleryCoreApi::getDefaultAlbumId()); $tree = g2(GalleryCoreApi::fetchAlbumTree()); $task->set("queue", $queue = array($g2_root_id => $tree)); + + // Update the root album to reflect the Gallery2 root album. + $root_album = item::root(); + g2_import::set_album_values( + $root_album, g2(GalleryCoreApi::loadEntitiesById($g2_root_id))); + $root_album->save(); } $log_message = g2_import::import_album($queue); if ($log_message) { -- cgit v1.2.3 From 8533420f5d307e81a90c3d26a75b666350aee0f2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 24 Apr 2011 22:55:01 -0700 Subject: Look for and return embed.php files in the autocomplete list if we can find them. Fixes #1708. --- modules/g2_import/controllers/admin_g2_import.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules') diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index cf68d911..5c4995c9 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -100,6 +100,11 @@ class Admin_g2_import_Controller extends Admin_Controller { foreach (glob("{$path_prefix}*") as $file) { if (is_dir($file) && !is_link($file)) { $directories[] = $file; + + // If we find an embed.php, include it as well + if (file_exists("$file/embed.php")) { + $directories[] = "$file/embed.php"; + } } } -- cgit v1.2.3 From 4e7524664a24dd2ca2309c9d67843a19e74b48e0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 24 Apr 2011 23:04:50 -0700 Subject: Show the tabs after the page has loaded to prevent Firefox from rendering the unstyled page and then flashing. Fixes #1705. --- modules/g2_import/views/admin_g2_import.html.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php index 2f4a1b28..9c4eb840 100644 --- a/modules/g2_import/views/admin_g2_import.html.php +++ b/modules/g2_import/views/admin_g2_import.html.php @@ -30,9 +30,13 @@ $("document").ready(function() { .tabs("select", 1) ; + + // Show the tabs after the page has loaded to prevent Firefox from rendering the + // unstyled page and then flashing. + $("#g-admin-g2-import-tabs").show(); }); -
            + diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 1395686c..e04b9169 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -30,6 +30,52 @@ class Gallery_View_Core extends View { return $absolute_url ? url::abs_file($arg) : url::file($arg); } + /** + * Set up the data and render a pager. + * + * See themes/wind/views/pager.html for documentation on the variables generated here. + */ + public function paginator() { + $v = new View("paginator.html"); + $v->page_type = $this->page_type; + $v->page_subtype = $this->page_subtype; + $v->first_page_url = null; + $v->previous_page_url = null; + $v->next_page_url = null; + $v->last_page_url = null; + + if ($this->page_type == "collection") { + $v->page = $this->page; + $v->max_pages = $this->max_pages; + $v->total = $this->children_count; + + if ($this->page != 1) { + $v->first_page_url = url::site(url::merge(array("page" => 1))); + $v->previous_page_url = url::site(url::merge(array("page" => $this->page - 1))); + } + + if ($this->page != $this->max_pages) { + $v->next_page_url = url::site(url::merge(array("page" => $this->page + 1))); + $v->last_page_url = url::site(url::merge(array("page" => $this->max_pages))); + } + + $v->first_visible_position = ($this->page - 1) * $this->page_size + 1; + $v->last_visible_position = min($this->page * $this->page_size, $v->total); + } else if ($this->page_type == "item") { + $v->position = $this->position; + $v->total = $this->sibling_count; + if ($this->previous_item) { + $v->previous_page_url = $this->previous_item->url(); + } + + if ($this->next_item) { + $v->next_page_url = $this->next_item->url(); + } + } + + return $v; + } + /** * Begin gather up scripts or css files so that they can be combined into a single request. * diff --git a/modules/gallery/libraries/MY_Pagination.php b/modules/gallery/libraries/MY_Pagination.php deleted file mode 100644 index e697c0bd..00000000 --- a/modules/gallery/libraries/MY_Pagination.php +++ /dev/null @@ -1,35 +0,0 @@ -auto_hide === TRUE AND $this->total_pages <= 1) { - return ""; - } - - if ($style === NULL) { - // Use default style - $style = $this->style; - } - - // Return rendered pagination view - return View::factory("pager.html", get_object_vars($this))->render(); - } -} diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 152efc37..d6834464 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -138,52 +138,6 @@ class Theme_View_Core extends Gallery_View { return $menu->render(); } - /** - * Set up the data and render a pager. - * - * See themes/wind/views/pager.html for documentation on the variables generated here. - */ - public function paginator() { - $v = new View("paginator.html"); - $v->page_type = $this->page_type; - $v->page_subtype = $this->page_subtype; - $v->first_page_url = null; - $v->previous_page_url = null; - $v->next_page_url = null; - $v->last_page_url = null; - - if ($this->page_type == "collection") { - $v->page = $this->page; - $v->max_pages = $this->max_pages; - $v->total = $this->children_count; - - if ($this->page != 1) { - $v->first_page_url = url::site(url::merge(array("page" => 1))); - $v->previous_page_url = url::site(url::merge(array("page" => $this->page - 1))); - } - - if ($this->page != $this->max_pages) { - $v->next_page_url = url::site(url::merge(array("page" => $this->page + 1))); - $v->last_page_url = url::site(url::merge(array("page" => $this->max_pages))); - } - - $v->first_visible_position = ($this->page - 1) * $this->page_size + 1; - $v->last_visible_position = min($this->page * $this->page_size, $v->total); - } else if ($this->page_type == "item") { - $v->position = $this->position; - $v->total = $this->sibling_count; - if ($this->previous_item) { - $v->previous_page_url = $this->previous_item->url(); - } - - if ($this->next_item) { - $v->next_page_url = $this->next_item->url(); - } - } - - return $v; - } - /** * Print out any site wide status information. */ diff --git a/modules/user/controllers/admin_users.php b/modules/user/controllers/admin_users.php index a3633b52..41be6c03 100644 --- a/modules/user/controllers/admin_users.php +++ b/modules/user/controllers/admin_users.php @@ -21,6 +21,8 @@ class Admin_Users_Controller extends Admin_Controller { public function index() { $view = new Admin_View("admin.html"); $view->page_title = t("Users and groups"); + $view->page_type = "collection"; + $view->page_subtype = "admin_users"; $view->content = new View("admin_users.html"); // @todo: add this as a config option @@ -29,6 +31,12 @@ class Admin_Users_Controller extends Admin_Controller { $builder = db::build(); $user_count = $builder->from("users")->count_records(); + // Pagination info + $view->page = $page; + $view->page_size = $page_size; + $view->children_count = $user_count; + $view->max_pages = ceil($view->children_count / $view->page_size); + $view->content->pager = new Pagination(); $view->content->pager->initialize( array("query_string" => "page", diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index a7bd6b27..033c9dae 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -110,7 +110,7 @@
            - + paginator() ?>
            diff --git a/themes/admin_wind/views/pager.html.php b/themes/admin_wind/views/pager.html.php deleted file mode 100644 index 5fff5845..00000000 --- a/themes/admin_wind/views/pager.html.php +++ /dev/null @@ -1,44 +0,0 @@ - - -
              - $current_first_item, - "to_number" => $current_last_item, - "count" => $total_items)) ?> -
            • - - - - - - - - - - - - - - -
            • -
            • -
            • - - - - - - - - - - - - - - -
            • -
            diff --git a/themes/admin_wind/views/paginator.html.php b/themes/admin_wind/views/paginator.html.php new file mode 100644 index 00000000..3cb0223d --- /dev/null +++ b/themes/admin_wind/views/paginator.html.php @@ -0,0 +1,88 @@ + + + +
              +
            • + + + + + + + + + + + + + + + + + +
            • + +
            • + + + $first_visible_position, + "to_number" => $last_visible_position, + "count" => $total)) ?> + + $position, "total" => $total)) ?> + + + + +
            • + +
            • + + + + + + + + + + + + + + + + + +
            • +
            -- cgit v1.2.3 From 743e2f88d8cbba7ea5f7b3b78ab721c141d1ec99 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 26 Apr 2011 21:02:43 -0700 Subject: Overhaul the Admin > Content > Comments page. Use a tabbed interface for consistency with other parts of the admin UI (ie: G2 import). The UI is now Ajax driven because that's how jQuery tabs works best in this case. This requires a little finagling in JS to get the paginator links to load properly. While I'm in there, add a paginator at the top of the table, make the buttons in the delete tab sane and smooth scroll back to the top of the tab when switching pages. Fixes #1702 --- .../comment/controllers/admin_manage_comments.php | 32 ++-- .../comment/views/admin_manage_comments.html.php | 211 +++------------------ .../views/admin_manage_comments_queue.html.php | 157 +++++++++++++++ 3 files changed, 205 insertions(+), 195 deletions(-) create mode 100644 modules/comment/views/admin_manage_comments_queue.html.php (limited to 'modules') diff --git a/modules/comment/controllers/admin_manage_comments.php b/modules/comment/controllers/admin_manage_comments.php index effefcbb..72684e70 100644 --- a/modules/comment/controllers/admin_manage_comments.php +++ b/modules/comment/controllers/admin_manage_comments.php @@ -28,8 +28,10 @@ class Admin_Manage_Comments_Controller extends Admin_Controller { ->where("updated", "<", db::expr("UNIX_TIMESTAMP() - 86400 * 7")) ->execute(); - // Redirect to the appropriate queue - url::redirect("admin/manage_comments/queue/unpublished"); + $view = new Admin_View("admin.html"); + $view->content = new View("admin_manage_comments.html"); + $view->content->menu = $this->_menu($this->_counts()); + print $view; } public function menu_labels() { @@ -43,15 +45,11 @@ class Admin_Manage_Comments_Controller extends Admin_Controller { public function queue($state) { $page = max(Input::instance()->get("page"), 1); - $view = new Admin_View("admin.html"); - $view->page_title = t("Manage comments"); - $view->page_type = "collection"; - $view->page_subtype = "admin_comments"; - $view->content = new View("admin_manage_comments.html"); - $view->content->counts = $this->_counts(); - $view->content->menu = $this->_menu($view->content->counts); - $view->content->state = $state; - $view->content->comments = ORM::factory("comment") + $view = new Gallery_View("admin_manage_comments_queue.html"); + $view->counts = $this->_counts(); + $view->menu = $this->_menu($view->counts); + $view->state = $state; + $view->comments = ORM::factory("comment") ->order_by("created", "DESC") ->order_by("id", "DESC") ->where("state", "=", $state) @@ -59,11 +57,21 @@ class Admin_Manage_Comments_Controller extends Admin_Controller { ->offset(($page - 1) * self::$items_per_page) ->find_all(); - // Pagination info + // This view is not themed so we can't use $theme->url() in the view and have to + // reproduce Gallery_View::url() logic here. + $atn = theme::$admin_theme_name; + $view->fallback_avatar_url = url::abs_file("themes/$atn/images/avatar.jpg"); + $view->page = $page; + $view->page_type = "collection"; + $view->page_subtype = "admin_comments"; $view->page_size = self::$items_per_page; $view->children_count = $this->_counts()->$state; $view->max_pages = ceil($view->children_count / $view->page_size); + + // Also we want to use $theme->paginator() so we need a dummy theme + $view->theme = $view; + print $view; } diff --git a/modules/comment/views/admin_manage_comments.html.php b/modules/comment/views/admin_manage_comments.html.php index e7a61837..e3c8546c 100644 --- a/modules/comment/views/admin_manage_comments.html.php +++ b/modules/comment/views/admin_manage_comments.html.php @@ -2,200 +2,45 @@ - -
            -

            -
            - -
            - render() ?> -
            - - -

            - - - - - - - - - -

            - - -
            - - 0): ?> -

            - -

            - -

            - spam): ?> - spam) ?> -

            -

            - "> - - - - - -

            -
            - - - -
            -

            - -

            -
            - - - - - - - - - - "> - - - - - -
            - - - - - -
            - - " - class="g-avatar" - alt="author_name()) ?>" - width="40" - height="40" /> - -

            author_name()) ?>

            -
            - -

            created) ?>

            - text)) ?> -
            -
              - state != "unpublished"): ?> -
            • - - - - -
            • - - state != "published"): ?> -
            • - - - - -
            • - - state != "spam"): ?> -
            • - - - - -
            • - - -
            • - - - - -
            • -
            -
            + // Paginator clicks load their href in the active tab panel + var fix_links = function() { + $(".g-paginator a, a#g-delete-all-spam").click(function(event) { + event.stopPropagation(); + $.scrollTo(0, 800, { easing: "swing" }); + $(this).parents(".ui-tabs-panel").load( + $(this).attr("href"), + function() { + fix_links(); + }); + return false; + }); + } -
            - paginator() ?> -
            + $(document).ready(function() { + $("#g-admin-comments").tabs({ + show: fix_links, + }); + }); + -
            +
            + render() ?>
            diff --git a/modules/comment/views/admin_manage_comments_queue.html.php b/modules/comment/views/admin_manage_comments_queue.html.php new file mode 100644 index 00000000..d847d729 --- /dev/null +++ b/modules/comment/views/admin_manage_comments_queue.html.php @@ -0,0 +1,157 @@ + +
            + +
            + + 0): ?> +

            + +

            + +

            + spam): ?> + spam) ?> +

            +

            + "> + + + + + +

            +
            + + + +
            +

            + +

            +
            + + +
            + paginator() ?> +
            + + + + + + + + "> + + + + + +
            + + + + + +
            + + <?= html::clean_attribute($comment->author_name()) ?> + +

            + + author_name()) ?> + +

            +
            + +

            created) ?>

            + text)) ?> +
            +
              + state != "unpublished" && $comment->state != "deleted"): ?> +
            • + + + + +
            • + + state != "published"): ?> +
            • + + + + + + + + +
            • + + state != "spam"): ?> +
            • + + + + +
            • + + + state != "deleted"): ?> +
            • + + + + +
            • + +
            +
            + +
            + paginator() ?> +
            +
            -- cgit v1.2.3 From b875368167658fd7992812504674afeb61c64831 Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Thu, 28 Apr 2011 19:41:44 -0600 Subject: This patch helps provide raw photo support with some small changes to the framework. Items can now change their extension and MIME type. Squashed commit of the following: commit 4c2b2ebd3f2052898fbfb175650ed4cf49c8006e Author: Chad Parry Date: Wed Apr 27 20:52:35 2011 -0600 Remove a newline at the end of the file that I accidentally introduced. commit 6d564f185e5279d6cca9a7385066514ff18a2455 Merge: 7ff485f 4060640 Author: Chad Parry Date: Wed Apr 27 20:35:58 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit 7ff485fa48c392bbbb0370f67cb1bd6fcc00c2a4 Author: Chad Parry Date: Wed Apr 27 20:29:06 2011 -0600 Move the extensions helpers out of the Kohana system directory and into their own Gallery Extensions class. commit 26585fed03236f0f70a75959e1d3002025f4e15e Merge: 809567f c8f90e8 Author: Chad Parry Date: Sun Apr 24 08:28:39 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit 809567f12850f59bdeb47a2963f6968b99b5a201 Author: Chad Parry Date: Sun Apr 24 08:10:04 2011 -0600 Expose the data file field. commit fcb06bf175bb9eeff36d9c294e97ace9374ef0f3 Author: Chad Parry Date: Sun Apr 24 00:45:12 2011 -0600 Don't assign to the item->name field if the name is unchanged, because the save method will crash. commit c6ef706d70c7e48bea1145eec1b13fb5683e023f Author: Chad Parry Date: Sat Apr 23 22:55:59 2011 -0600 Preserve old data files long enough for them to be available to event handlers. commit 0d6a3a3cfc4f38f450db9e18da47a5e2ad826af8 Author: Chad Parry Date: Sat Apr 23 21:19:47 2011 -0600 Create a tempnam substitute that safely creates files with a given extension. commit e149cf7238a1f8eaddfc68580f2d636dd8255795 Author: Chad Parry Date: Sat Apr 23 16:39:25 2011 -0600 Support data files that change their extension and MIME type. commit 6702104f571413e4d57db3515b2070c48d3e9b55 Author: Chad Parry Date: Sat Apr 23 16:35:00 2011 -0600 Resolve an infinite recursion that happens when the path caches are updated during saving. commit 944cb72eea946f4c45a04b7e4c7c33929fa8b9f3 Merge: 567522b 5af74d4 Author: Chad Parry Date: Fri Apr 22 14:10:42 2011 -0600 Merge remote branch 'origin/master' into rawphoto commit 567522bfa08c370bb5baf8454afc5b04bc9e49b4 Author: Chad Parry Date: Thu Apr 21 20:12:32 2011 -0600 Add an event for when a new graphics toolkit is chosen. commit 31ba081b793141ca36866a6dd349cd2eac5af68e Author: Chad Parry Date: Thu Apr 21 02:06:53 2011 -0600 Add an event that will collect all valid filename extensions. --- modules/gallery/controllers/admin_graphics.php | 2 + modules/gallery/controllers/quick.php | 4 +- modules/gallery/controllers/uploader.php | 2 +- modules/gallery/helpers/extensions.php | 39 ++++++++++++++++ modules/gallery/helpers/system.php | 25 ++++++++++ modules/gallery/libraries/Form_Uploadify.php | 1 + modules/gallery/models/item.php | 63 ++++++++++++++------------ modules/gallery/tests/Mock_Built_In.php | 39 ++++++++++++++++ modules/gallery/tests/System_Helper_Test.php | 49 ++++++++++++++++++++ modules/gallery/views/form_uploadify.html.php | 2 +- 10 files changed, 194 insertions(+), 32 deletions(-) create mode 100644 modules/gallery/helpers/extensions.php create mode 100644 modules/gallery/tests/Mock_Built_In.php create mode 100644 modules/gallery/tests/System_Helper_Test.php (limited to 'modules') diff --git a/modules/gallery/controllers/admin_graphics.php b/modules/gallery/controllers/admin_graphics.php index a2d19d4a..a8a7cdc0 100644 --- a/modules/gallery/controllers/admin_graphics.php +++ b/modules/gallery/controllers/admin_graphics.php @@ -40,6 +40,8 @@ class Admin_Graphics_Controller extends Admin_Controller { $msg = t("Changed graphics toolkit to: %toolkit", array("toolkit" => $tk->$toolkit_id->name)); message::success($msg); log::success("graphics", $msg); + + module::event("graphics_toolkit_change", $toolkit_id); } url::redirect("admin/graphics"); diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index da4768fd..ce52cb8d 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -36,8 +36,8 @@ class Quick_Controller extends Controller { } if ($degrees) { - $tmpfile = tempnam(TMPPATH, "rotate") . "." . - pathinfo($item->file_path(), PATHINFO_EXTENSION); + $tmpfile = system::tempnam(TMPPATH, "rotate", + "." . pathinfo($item->file_path(), PATHINFO_EXTENSION)); gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item); $item->set_data_file($tmpfile); $item->save(); diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php index 6b1455e4..5f3e9ca4 100644 --- a/modules/gallery/controllers/uploader.php +++ b/modules/gallery/controllers/uploader.php @@ -51,7 +51,7 @@ class Uploader_Controller extends Controller { $file_validation = new Validation($_FILES); $file_validation->add_rules( "Filedata", "upload::valid", "upload::required", - "upload::type[gif,jpg,jpeg,png,flv,mp4,m4v]"); + "upload::type[" . implode(",", extensions::get_upload_extensions()) . "]"); if ($form->validate() && $file_validation->validate()) { $temp_filename = upload::save("Filedata"); diff --git a/modules/gallery/helpers/extensions.php b/modules/gallery/helpers/extensions.php new file mode 100644 index 00000000..bccbfc41 --- /dev/null +++ b/modules/gallery/helpers/extensions.php @@ -0,0 +1,39 @@ +extensions = array("gif", "jpg", "jpeg", "png"); + if (movie::find_ffmpeg()) { + array_push($extensions_wrapper->extensions, "flv", "mp4", "m4v"); + } + module::event("upload_extensions", $extensions_wrapper); + return $extensions_wrapper->extensions; + } + + static function get_upload_filters() { + $filters = array(); + foreach (self::get_upload_extensions() as $extension) { + array_push($filters, "*." . $extension, "*." . strtoupper($extension)); + } + return $filters; + } +} diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index c39c7227..31ecafa7 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -40,4 +40,29 @@ class system_Core { } return null; } + + /** + * Create a file with a unique file name. + * This helper is similar to the built-in tempnam, except that it supports an optional postfix. + */ + static function tempnam($dir = TMPPATH, $prefix = "", $postfix = "") { + return self::_tempnam($dir, $prefix, $postfix, "tempnam"); + } + + // This helper provides a dependency-injected implementation of tempnam. + static function _tempnam($dir, $prefix, $postfix, $builtin) { + $success = false; + do { + $basename = call_user_func($builtin, $dir, $prefix); + if (!$basename) { + return false; + } + $filename = $basename . $postfix; + $success = !file_exists($filename) && @rename($basename, $filename); + if (!$success) { + @unlink($basename); + } + } while (!$success); + return $filename; + } } \ No newline at end of file diff --git a/modules/gallery/libraries/Form_Uploadify.php b/modules/gallery/libraries/Form_Uploadify.php index 3e35e380..884653e2 100644 --- a/modules/gallery/libraries/Form_Uploadify.php +++ b/modules/gallery/libraries/Form_Uploadify.php @@ -47,6 +47,7 @@ class Form_Uploadify_Core extends Form_Input { $v->script_data = $this->data["script_data"]; $v->simultaneous_upload_limit = module::get_var("gallery", "simultaneous_upload_limit"); $v->movies_allowed = (bool) movie::find_ffmpeg(); + $v->extensions = extensions::get_upload_filters(); $v->suhosin_session_encrypt = (bool) ini_get("suhosin.session.encrypt"); list ($toolkit_max_filesize_bytes, $toolkit_max_filesize) = graphics::max_filesize(); diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 2a5e6894..5ccbe75c 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -127,6 +127,15 @@ class Item_Model_Core extends ORM_MPTT { return $this; } + /** + * Get the path to the data file associated with this item. + * This data file field is only set until you call save(). + * After that, you can get the path using get_file_path(). + */ + public function get_data_file() { + return $this->data_file; + } + /** * Return the server-relative url to this item, eg: * /gallery3/index.php/BobsWedding?page=2 @@ -408,6 +417,16 @@ class Item_Model_Core extends ORM_MPTT { // If any significant fields have changed, load up a copy of the original item and // keep it around. $original = ORM::factory("item", $this->id); + + // Preserve the extension of the data file. + if (isset($this->data_file)) { + $extension = pathinfo($this->data_file, PATHINFO_EXTENSION); + $new_name = pathinfo($this->name, PATHINFO_FILENAME) . ".$extension"; + if (!empty($extension) && strcmp($this->name, $new_name)) { + $this->name = $new_name; + } + } + if (array_intersect($this->changed, array("parent_id", "name", "slug"))) { $original->_build_relative_caches(); $this->relative_path_cache = null; @@ -430,7 +449,10 @@ class Item_Model_Core extends ORM_MPTT { if ($original->parent_id != $this->parent_id || $original->name != $this->name) { // Move all of the items associated data files - @rename($original->file_path(), $this->file_path()); + $this->_build_relative_caches(); + if (!isset($this->data_file)) { + @rename($original->file_path(), $this->file_path()); + } if ($this->is_album()) { @rename(dirname($original->resize_path()), dirname($this->resize_path())); @rename(dirname($original->thumb_path()), dirname($this->thumb_path())); @@ -460,8 +482,6 @@ class Item_Model_Core extends ORM_MPTT { } // Replace the data file, if requested. - // @todo: we don't handle the case where you swap in a file of a different mime type - // should we prevent that in validation? or in set_data_file() if ($this->data_file && ($this->is_photo() || $this->is_movie())) { copy($this->data_file, $this->file_path()); @@ -481,6 +501,9 @@ class Item_Model_Core extends ORM_MPTT { // Null out the data file variable here, otherwise this event will trigger another // save() which will think that we're doing another file move. $this->data_file = null; + if ($original->file_path() != $this->file_path()) { + @unlink($original->file_path()); + } module::event("item_updated_data_file", $this); } } @@ -517,6 +540,8 @@ class Item_Model_Core extends ORM_MPTT { $this->name = "$base_name-$rand"; } $this->slug = "$base_slug-$rand"; + $this->relative_path_cache = null; + $this->relative_url_cache = null; } } @@ -768,16 +793,7 @@ class Item_Model_Core extends ORM_MPTT { } if ($this->is_movie() || $this->is_photo()) { - if ($this->loaded()) { - // Existing items can't change their extension - $original = ORM::factory("item", $this->id); - $new_ext = pathinfo($this->name, PATHINFO_EXTENSION); - $old_ext = pathinfo($original->name, PATHINFO_EXTENSION); - if (strcasecmp($new_ext, $old_ext)) { - $v->add_error("name", "illegal_data_file_extension"); - return; - } - } else { + if (!$this->loaded()) { // New items must have an extension $ext = pathinfo($this->name, PATHINFO_EXTENSION); if (!$ext) { @@ -785,9 +801,11 @@ class Item_Model_Core extends ORM_MPTT { return; } - if ($this->is_movie() && !preg_match("/^(flv|mp4|m4v)$/i", $ext)) { - $v->add_error("name", "illegal_data_file_extension"); - } else if ($this->is_photo() && !preg_match("/^(gif|jpg|jpeg|png)$/i", $ext)) { + if (($this->is_movie() || $this->is_photo()) && + !preg_match("/^(" . + implode("|", array_map("preg_quote", + extensions::get_upload_extensions())) . + ")\$/i", $ext)) { $v->add_error("name", "illegal_data_file_extension"); } } @@ -813,17 +831,6 @@ class Item_Model_Core extends ORM_MPTT { } else if (filesize($this->data_file) == 0) { $v->add_error("name", "empty_data_file"); } - - if ($this->loaded()) { - if ($this->is_photo()) { - list ($a, $b, $mime_type) = photo::get_file_metadata($this->data_file); - } else if ($this->is_movie()) { - list ($a, $b, $mime_type) = movie::get_file_metadata($this->data_file); - } - if ($mime_type != $this->mime_type) { - $v->add_error("name", "cant_change_mime_type"); - } - } } /** @@ -879,7 +886,7 @@ class Item_Model_Core extends ORM_MPTT { if ($this->is_movie()) { $legal_values = array("video/flv", "video/x-flv", "video/mp4"); } if ($this->is_photo()) { - $legal_values = array("image/jpeg", "image/gif", "image/png"); + $legal_values = array("image/jpeg", "image/gif", "image/png", "image/tiff"); } break; diff --git a/modules/gallery/tests/Mock_Built_In.php b/modules/gallery/tests/Mock_Built_In.php new file mode 100644 index 00000000..b02e5ecf --- /dev/null +++ b/modules/gallery/tests/Mock_Built_In.php @@ -0,0 +1,39 @@ +nonces = func_get_args(); + } + + function _tempnam($dir, $prefix) { + if (empty($this->nonces)) + return false; + $filename = "$dir/$prefix" . array_shift($this->nonces); + if (!touch($filename)) + return false; + return $filename; + } +} diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php new file mode 100644 index 00000000..734f98ac --- /dev/null +++ b/modules/gallery/tests/System_Helper_Test.php @@ -0,0 +1,49 @@ +assert_true(file_exists($filename), "File not created"); + unlink($filename); + } + + public function tempnam_collision_test() { + require_once('Mock_Built_In.php'); + $existing = TMPPATH . "/file1.ext"; + $available = TMPPATH . "/file2.ext"; + touch($existing); + $filename = system::_tempnam(TMPPATH, "file", ".ext", + array(new Mock_Built_In("1", "2"), "_tempnam")); + unlink($existing); + $this->assert_true(file_exists($filename), "File not created"); + unlink($filename); + $this->assert_equal($available, $filename, "Incorrect filename created"); + } + + public function tempnam_abort_test() { + require_once('Mock_Built_In.php'); + $filename = system::_tempnam(TMPPATH, "file", ".ext", + array(new Mock_Built_In(), "_tempnam")); + if ($filename) { + @unlink($filename); + } + $this->assert_false($filename, "Operation not aborted"); + } +} diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php index 83dfcc68..ba4a3621 100644 --- a/modules/gallery/views/form_uploadify.html.php +++ b/modules/gallery/views/form_uploadify.html.php @@ -28,7 +28,7 @@ uploader: "", script: "id}") ?>", scriptData: , - fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.GIF;*.JPG;*.JPEG;*.PNG;*.flv;*.mp4;*.m4v;*.FLV;*.MP4;*.M4V", + fileExt: "", fileDesc: for_js() ?>, cancelImg: "", simUploadLimit: , -- cgit v1.2.3 From 9e080efff3cf9c706dfb2c69dacc19328196ec01 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 30 Apr 2011 15:43:57 -0700 Subject: Differentiate between invalid, missing and broken G2 configs and present the user with feedback in the form. Fixes #1727. --- modules/g2_import/controllers/admin_g2_import.php | 8 +- modules/g2_import/helpers/g2_import.php | 265 ++++++++++++---------- 2 files changed, 147 insertions(+), 126 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 5c4995c9..1a705bea 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -78,12 +78,12 @@ class Admin_g2_import_Controller extends Admin_Controller { $embed_path = "$embed_path/embed.php"; } - if (g2_import::is_valid_embed_path($embed_path)) { + if (($g2_init_error = g2_import::is_valid_embed_path($embed_path)) == "ok") { message::success(t("Gallery 2 path saved")); module::set_var("g2_import", "embed_path", $embed_path); url::redirect("admin/g2_import"); } else { - $form->configure_g2_import->embed_path->add_error("invalid", 1); + $form->configure_g2_import->embed_path->add_error($g2_init_error, 1); } } @@ -120,6 +120,10 @@ class Admin_g2_import_Controller extends Admin_Controller { ->value($embed_path); $group->embed_path->error_messages( "invalid", t("The path you entered is not a Gallery 2 installation.")); + $group->embed_path->error_messages( + "broken", t("Your Gallery 2 install isn't working properly. Please verify it!")); + $group->embed_path->error_messages( + "missing", t("The path you entered does not exist.")); $group->submit("")->value($embed_path ? t("Change") : t("Continue")); return $form; } diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 22a054ac..3606c7ef 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -31,7 +31,7 @@ class g2_import_Core { } static function is_initialized() { - return g2_import::$init; + return g2_import::$init == "ok"; } static function init() { @@ -52,146 +52,163 @@ class g2_import_Core { if (file_exists($mod_path)) { dir::unlink($mod_path); } - return file_exists($embed_path) && g2_import::init_embed($embed_path); + return g2_import::init_embed($embed_path); } /** * Initialize the embedded Gallery 2 instance. Call this before any other Gallery 2 calls. + * + * Return values: + * "ok" - the Gallery 2 install is fine + * "missing" - the embed path does not exist + * "invalid" - the install path is not a valid Gallery 2 code base + * "broken" - the embed path is correct, but the Gallery 2 install is broken */ static function init_embed($embed_path) { if (!is_file($embed_path)) { - return false; + return "missing"; } - // Gallery 2 defines a class called Gallery. So does Gallery 3. They don't get along. So do - // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc - // and Gallery.class) and munge them so that we can rename the Gallery class to be - // G2_Gallery. Is this retarded? Why yes it is. - // - // Store the munged files in a directory that's the md5 hash of the embed path so that - // multiple import sources don't interfere with each other. - - $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path); - if (!file_exists($mod_path) || !file_exists("$mod_path/embed.php")) { - @dir::unlink($mod_path); - mkdir($mod_path); - - $config_dir = dirname($embed_path); - if (filesize($embed_path) > 200) { - // Regular install - $base_dir = $config_dir; - } else { - // Multisite install. Line 2 of embed.php will be something like: - // require('/usr/home/bharat/public_html/gallery2/embed.php'); - $lines = file($embed_path); - preg_match("#require\('(.*)/embed.php'\);#", $lines[2], $matches); - $base_dir = $matches[1]; + try { + // Gallery 2 defines a class called Gallery. So does Gallery 3. They don't get along. So do + // a total hack here and copy over a few critical files (embed.php, main.php, bootstrap.inc + // and Gallery.class) and munge them so that we can rename the Gallery class to be + // G2_Gallery. Is this retarded? Why yes it is. + // + // Store the munged files in a directory that's the md5 hash of the embed path so that + // multiple import sources don't interfere with each other. + + $mod_path = VARPATH . "modules/g2_import/" . md5($embed_path); + if (!file_exists($mod_path) || !file_exists("$mod_path/embed.php")) { + @dir::unlink($mod_path); + mkdir($mod_path); + + $config_dir = dirname($embed_path); + if (filesize($embed_path) > 200) { + // Regular install + $base_dir = $config_dir; + } else { + // Multisite install. Line 2 of embed.php will be something like: + // require('/usr/home/bharat/public_html/gallery2/embed.php'); + $lines = file($embed_path); + preg_match("#require\('(.*)/embed.php'\);#", $lines[2], $matches); + $base_dir = $matches[1]; + } + + file_put_contents( + "$mod_path/embed.php", + str_replace( + array( + "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", + "require(dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class');"), + array( + "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", + "require('$base_dir/modules/core/classes/GalleryEmbed.class');"), + array_merge( + array("\n"), + file("$base_dir/embed.php")))); + + file_put_contents( + "$mod_path/main.php", + str_replace( + array( + "include(dirname(__FILE__) . '/bootstrap.inc');", + "require_once(dirname(__FILE__) . '/init.inc');"), + array( + "include(dirname(__FILE__) . '/bootstrap.inc');", + "require_once('$base_dir/init.inc');"), + array_merge( + array("\n"), + file("$base_dir/main.php")))); + + file_put_contents( + "$mod_path/bootstrap.inc", + str_replace( + array( + "require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", + "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", + "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", + "\$gallery =& new Gallery();", + "\$GLOBALS['gallery'] =& new Gallery();", + "\$gallery = new Gallery();"), + array( + "require_once(dirname(__FILE__) . '/Gallery.class');", + "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", + "define('GALLERY_CONFIG_DIR', '$config_dir');", + "\$gallery =& new G2_Gallery();", + "\$GLOBALS['gallery'] =& new G2_Gallery();", + "\$gallery = new G2_Gallery();"), + array_merge( + array("\n"), + file("$base_dir/bootstrap.inc")))); + + file_put_contents( + "$mod_path/Gallery.class", + str_replace( + array("class Gallery", + "function Gallery"), + array("class G2_Gallery", + "function G2_Gallery"), + array_merge( + array("\n"), + file("$base_dir/modules/core/classes/Gallery.class")))); + } else { + // Ok, this is a good one. If you're running a bytecode accelerator and you move your + // Gallery install, these files sometimes get cached with the wrong path and then fail to + // load properly. + // Documented in https://sourceforge.net/apps/trac/gallery/ticket/1253 + touch("$mod_path/embed.php"); + touch("$mod_path/main.php"); + touch("$mod_path/bootstrap.inc"); + touch("$mod_path/Gallery.class.inc"); + } + + require("$mod_path/embed.php"); + if (!class_exists("GalleryEmbed")) { + return "invalid"; } - file_put_contents( - "$mod_path/embed.php", - str_replace( - array( - "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", - "require(dirname(__FILE__) . '/modules/core/classes/GalleryEmbed.class');"), - array( - "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", - "require('$base_dir/modules/core/classes/GalleryEmbed.class');"), - array_merge(array("\n"), - file("$base_dir/embed.php")))); - - file_put_contents( - "$mod_path/main.php", - str_replace( - array( - "include(dirname(__FILE__) . '/bootstrap.inc');", - "require_once(dirname(__FILE__) . '/init.inc');"), - array( - "include(dirname(__FILE__) . '/bootstrap.inc');", - "require_once('$base_dir/init.inc');"), - array_merge(array("\n"), - file("$base_dir/main.php")))); - - file_put_contents( - "$mod_path/bootstrap.inc", - str_replace( - array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');", - "require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');", - "define('GALLERY_CONFIG_DIR', dirname(__FILE__));", - "\$gallery =& new Gallery();", - "\$GLOBALS['gallery'] =& new Gallery();", - "\$gallery = new Gallery();"), - array("require_once(dirname(__FILE__) . '/Gallery.class');", - "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", - "define('GALLERY_CONFIG_DIR', '$config_dir');", - "\$gallery =& new G2_Gallery();", - "\$GLOBALS['gallery'] =& new G2_Gallery();", - "\$gallery = new G2_Gallery();"), - array_merge(array("\n"), - file("$base_dir/bootstrap.inc")))); - - file_put_contents( - "$mod_path/Gallery.class", - str_replace( - array("class Gallery", - "function Gallery"), - array("class G2_Gallery", - "function G2_Gallery"), - array_merge(array("\n"), - file("$base_dir/modules/core/classes/Gallery.class")))); - } else { - // Ok, this is a good one. If you're running a bytecode accelerator and you move your - // Gallery install, these files sometimes get cached with the wrong path and then fail to - // load properly. - // Documented in https://sourceforge.net/apps/trac/gallery/ticket/1253 - touch("$mod_path/embed.php"); - touch("$mod_path/main.php"); - touch("$mod_path/bootstrap.inc"); - touch("$mod_path/Gallery.class.inc"); - } - - require("$mod_path/embed.php"); - if (!class_exists("GalleryEmbed")) { - return false; - } - - $ret = GalleryEmbed::init(); - if ($ret) { - Kohana_Log::add("error", "Gallery 2 call failed with: " . $ret->getAsText()); - return false; - } - - $admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup")); - $admins = g2(GalleryCoreApi::fetchUsersForGroup($admin_group_id, 1)); - $admin_id = current(array_flip($admins)); - $admin = g2(GalleryCoreApi::loadEntitiesById($admin_id)); - $GLOBALS["gallery"]->setActiveUser($admin); + $ret = GalleryEmbed::init(); + if ($ret) { + Kohana_Log::add("error", "Gallery 2 call failed with: " . $ret->getAsText()); + return "broken"; + } - // Make sure we have an embed location so that embedded url generation comes out ok. Without - // this, the Gallery2 ModRewrite code won't try to do url generation. - $g2_embed_location = - g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.embeddedLocation")); + $admin_group_id = g2(GalleryCoreApi::getPluginParameter("module", "core", "id.adminGroup")); + $admins = g2(GalleryCoreApi::fetchUsersForGroup($admin_group_id, 1)); + $admin_id = current(array_flip($admins)); + $admin = g2(GalleryCoreApi::loadEntitiesById($admin_id)); + $GLOBALS["gallery"]->setActiveUser($admin); - if (empty($g2_embed_location)) { + // Make sure we have an embed location so that embedded url generation comes out ok. Without + // this, the Gallery2 ModRewrite code won't try to do url generation. $g2_embed_location = - g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.galleryLocation")); - g2(GalleryCoreApi::setPluginParameter( - "module", "rewrite", "modrewrite.embeddedLocation", $g2_embed_location)); - g2($gallery->getStorage()->checkPoint()); - } + g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.embeddedLocation")); + + if (empty($g2_embed_location)) { + $g2_embed_location = + g2(GalleryCoreApi::getPluginParameter("module", "rewrite", "modrewrite.galleryLocation")); + g2(GalleryCoreApi::setPluginParameter("module", "rewrite", "modrewrite.embeddedLocation", + $g2_embed_location)); + g2($gallery->getStorage()->checkPoint()); + } - if ($g2_embed_location) { - self::$g2_base_url = $g2_embed_location; - } else { - self::$g2_base_url = $GLOBALS["gallery"]->getUrlGenerator()->generateUrl( - array(), - array("forceSessionId" => false, - "htmlEntities" => false, - "urlEncode" => false, - "useAuthToken" => false)); + if ($g2_embed_location) { + self::$g2_base_url = $g2_embed_location; + } else { + self::$g2_base_url = $GLOBALS["gallery"]->getUrlGenerator()->generateUrl( + array(), + array("forceSessionId" => false, + "htmlEntities" => false, + "urlEncode" => false, + "useAuthToken" => false)); + } + } catch (ErrorException $e) { + Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString()); + return "broken"; } - return true; + return "ok"; } /** -- cgit v1.2.3 From 5c9a3b3f39f6ff0d5c84c2cf283d27eaebe2e66e Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Sat, 23 Apr 2011 21:19:47 -0600 Subject: Create a tempnam substitute that safely creates files with a given extension. --- modules/gallery/controllers/quick.php | 4 +-- modules/gallery/helpers/system.php | 25 ++++++++++++++ modules/gallery/tests/Mock_Built_In.php | 39 ++++++++++++++++++++++ modules/gallery/tests/System_Helper_Test.php | 49 ++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 modules/gallery/tests/Mock_Built_In.php create mode 100644 modules/gallery/tests/System_Helper_Test.php (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index da4768fd..ce52cb8d 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -36,8 +36,8 @@ class Quick_Controller extends Controller { } if ($degrees) { - $tmpfile = tempnam(TMPPATH, "rotate") . "." . - pathinfo($item->file_path(), PATHINFO_EXTENSION); + $tmpfile = system::tempnam(TMPPATH, "rotate", + "." . pathinfo($item->file_path(), PATHINFO_EXTENSION)); gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item); $item->set_data_file($tmpfile); $item->save(); diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index c39c7227..31ecafa7 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -40,4 +40,29 @@ class system_Core { } return null; } + + /** + * Create a file with a unique file name. + * This helper is similar to the built-in tempnam, except that it supports an optional postfix. + */ + static function tempnam($dir = TMPPATH, $prefix = "", $postfix = "") { + return self::_tempnam($dir, $prefix, $postfix, "tempnam"); + } + + // This helper provides a dependency-injected implementation of tempnam. + static function _tempnam($dir, $prefix, $postfix, $builtin) { + $success = false; + do { + $basename = call_user_func($builtin, $dir, $prefix); + if (!$basename) { + return false; + } + $filename = $basename . $postfix; + $success = !file_exists($filename) && @rename($basename, $filename); + if (!$success) { + @unlink($basename); + } + } while (!$success); + return $filename; + } } \ No newline at end of file diff --git a/modules/gallery/tests/Mock_Built_In.php b/modules/gallery/tests/Mock_Built_In.php new file mode 100644 index 00000000..b02e5ecf --- /dev/null +++ b/modules/gallery/tests/Mock_Built_In.php @@ -0,0 +1,39 @@ +nonces = func_get_args(); + } + + function _tempnam($dir, $prefix) { + if (empty($this->nonces)) + return false; + $filename = "$dir/$prefix" . array_shift($this->nonces); + if (!touch($filename)) + return false; + return $filename; + } +} diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php new file mode 100644 index 00000000..734f98ac --- /dev/null +++ b/modules/gallery/tests/System_Helper_Test.php @@ -0,0 +1,49 @@ +assert_true(file_exists($filename), "File not created"); + unlink($filename); + } + + public function tempnam_collision_test() { + require_once('Mock_Built_In.php'); + $existing = TMPPATH . "/file1.ext"; + $available = TMPPATH . "/file2.ext"; + touch($existing); + $filename = system::_tempnam(TMPPATH, "file", ".ext", + array(new Mock_Built_In("1", "2"), "_tempnam")); + unlink($existing); + $this->assert_true(file_exists($filename), "File not created"); + unlink($filename); + $this->assert_equal($available, $filename, "Incorrect filename created"); + } + + public function tempnam_abort_test() { + require_once('Mock_Built_In.php'); + $filename = system::_tempnam(TMPPATH, "file", ".ext", + array(new Mock_Built_In(), "_tempnam")); + if ($filename) { + @unlink($filename); + } + $this->assert_false($filename, "Operation not aborted"); + } +} -- cgit v1.2.3 From 0e844766baf3b3875cbb2d84579626e05e879420 Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Sat, 30 Apr 2011 16:40:55 -0600 Subject: Change the signature of system::tempnam to something more appropriate for Gallery. --- modules/gallery/controllers/quick.php | 4 ++-- modules/gallery/helpers/system.php | 13 ++++++++----- modules/gallery/tests/System_Helper_Test.php | 5 +++-- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index ce52cb8d..b6576ec0 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -36,8 +36,8 @@ class Quick_Controller extends Controller { } if ($degrees) { - $tmpfile = system::tempnam(TMPPATH, "rotate", - "." . pathinfo($item->file_path(), PATHINFO_EXTENSION)); + $tmpfile = system::temp_filename("rotate", + pathinfo($item->file_path(), PATHINFO_EXTENSION)); gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item); $item->set_data_file($tmpfile); $item->save(); diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index 31ecafa7..9815d588 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -43,15 +43,18 @@ class system_Core { /** * Create a file with a unique file name. - * This helper is similar to the built-in tempnam, except that it supports an optional postfix. + * This helper is similar to the built-in tempnam. + * It allows the caller to specify a prefix and an extension. + * It always places the file in TMPPATH. */ - static function tempnam($dir = TMPPATH, $prefix = "", $postfix = "") { - return self::_tempnam($dir, $prefix, $postfix, "tempnam"); + static function temp_filename($prefix = "", $extension = "") { + return self::_tempnam(TMPPATH, $prefix, ".$extension", "tempnam"); } - // This helper provides a dependency-injected implementation of tempnam. + /** + * This helper provides a dependency-injected implementation of tempnam. + */ static function _tempnam($dir, $prefix, $postfix, $builtin) { - $success = false; do { $basename = call_user_func($builtin, $dir, $prefix); if (!$basename) { diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php index 734f98ac..dfe5d9ab 100644 --- a/modules/gallery/tests/System_Helper_Test.php +++ b/modules/gallery/tests/System_Helper_Test.php @@ -18,10 +18,11 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class System_Helper_Test extends Gallery_Unit_Test_Case { - public function tempnam_random_test() { - $filename = system::tempnam(TMPPATH, "file", ".ext"); + public function temp_filename_random_test() { + $filename = system::temp_filename("file", "ext"); $this->assert_true(file_exists($filename), "File not created"); unlink($filename); + $this->assert_pattern($filename, "|/file.*\\.ext$|"); } public function tempnam_collision_test() { -- cgit v1.2.3 From d2d37fe3f2e550dff0c62afa9faa3100f305df0e Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Sat, 30 Apr 2011 21:33:20 -0600 Subject: Results from a round of feedback with Bharat. Squashed commit of the following: commit 13dbd3515bfb5324cfbcb3bbeafc179771b54f75 Merge: f0f094c 97400b7 Author: Chad Parry Date: Sat Apr 30 20:33:02 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit f0f094c3f79b09536f58083681c28f73271c506d Author: Chad Parry Date: Sat Apr 30 20:22:49 2011 -0600 Explain the conditional rename in item::save() with a comment. commit 1b3a6b85c156e4777d2aa8205b130984f55dc66d Author: Chad Parry Date: Sat Apr 30 18:29:34 2011 -0600 Improve the comment explaining why the data_file extension is important. commit c3e8c1e3b5e3cb1046acd4c923bb0ae9dbcd603a Author: Chad Parry Date: Sat Apr 30 18:12:56 2011 -0600 The data_file field is public, so we don't need to supply an accessor method. commit 2375a02e2cdbd1ccaf7dc4d3db9d85119972e3a9 Author: Chad Parry Date: Sat Apr 30 16:40:55 2011 -0600 Change the signature of system::tempnam to something more appropriate for Gallery. commit a8ca9dcf9edd54633c0c78b3af76aa974d38fc64 Author: Chad Parry Date: Sat Apr 30 16:10:06 2011 -0600 Change the name of the extensions helper to legal_file. commit 7e61a01a96f5eab7212dba754ac64fdfb4d9e8ab Author: Chad Parry Date: Sat Apr 30 16:08:49 2011 -0600 Change the name of the extensions helper to legal_file. commit 4c2b2ebd3f2052898fbfb175650ed4cf49c8006e Author: Chad Parry Date: Wed Apr 27 20:52:35 2011 -0600 Remove a newline at the end of the file that I accidentally introduced. commit 6d564f185e5279d6cca9a7385066514ff18a2455 Merge: 7ff485f 4060640 Author: Chad Parry Date: Wed Apr 27 20:35:58 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit 7ff485fa48c392bbbb0370f67cb1bd6fcc00c2a4 Author: Chad Parry Date: Wed Apr 27 20:29:06 2011 -0600 Move the extensions helpers out of the Kohana system directory and into their own Gallery Extensions class. commit 26585fed03236f0f70a75959e1d3002025f4e15e Merge: 809567f c8f90e8 Author: Chad Parry Date: Sun Apr 24 08:28:39 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit 809567f12850f59bdeb47a2963f6968b99b5a201 Author: Chad Parry Date: Sun Apr 24 08:10:04 2011 -0600 Expose the data file field. commit fcb06bf175bb9eeff36d9c294e97ace9374ef0f3 Author: Chad Parry Date: Sun Apr 24 00:45:12 2011 -0600 Don't assign to the item->name field if the name is unchanged, because the save method will crash. commit c6ef706d70c7e48bea1145eec1b13fb5683e023f Author: Chad Parry Date: Sat Apr 23 22:55:59 2011 -0600 Preserve old data files long enough for them to be available to event handlers. commit 0d6a3a3cfc4f38f450db9e18da47a5e2ad826af8 Author: Chad Parry Date: Sat Apr 23 21:19:47 2011 -0600 Create a tempnam substitute that safely creates files with a given extension. commit e149cf7238a1f8eaddfc68580f2d636dd8255795 Author: Chad Parry Date: Sat Apr 23 16:39:25 2011 -0600 Support data files that change their extension and MIME type. commit 6702104f571413e4d57db3515b2070c48d3e9b55 Author: Chad Parry Date: Sat Apr 23 16:35:00 2011 -0600 Resolve an infinite recursion that happens when the path caches are updated during saving. commit 944cb72eea946f4c45a04b7e4c7c33929fa8b9f3 Merge: 567522b 5af74d4 Author: Chad Parry Date: Fri Apr 22 14:10:42 2011 -0600 Merge remote branch 'origin/master' into rawphoto commit 567522bfa08c370bb5baf8454afc5b04bc9e49b4 Author: Chad Parry Date: Thu Apr 21 20:12:32 2011 -0600 Add an event for when a new graphics toolkit is chosen. commit 31ba081b793141ca36866a6dd349cd2eac5af68e Author: Chad Parry Date: Thu Apr 21 02:06:53 2011 -0600 Add an event that will collect all valid filename extensions. --- modules/gallery/controllers/quick.php | 4 +-- modules/gallery/controllers/uploader.php | 2 +- modules/gallery/helpers/legal_file.php | 39 ++++++++++++++++++++++++++++ modules/gallery/helpers/system.php | 13 ++++++---- modules/gallery/libraries/Form_Uploadify.php | 2 +- modules/gallery/models/item.php | 18 ++++++++++--- modules/gallery/tests/System_Helper_Test.php | 5 ++-- 7 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 modules/gallery/helpers/legal_file.php (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index ce52cb8d..b6576ec0 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -36,8 +36,8 @@ class Quick_Controller extends Controller { } if ($degrees) { - $tmpfile = system::tempnam(TMPPATH, "rotate", - "." . pathinfo($item->file_path(), PATHINFO_EXTENSION)); + $tmpfile = system::temp_filename("rotate", + pathinfo($item->file_path(), PATHINFO_EXTENSION)); gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees), $item); $item->set_data_file($tmpfile); $item->save(); diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php index 5f3e9ca4..9c2bf7d7 100644 --- a/modules/gallery/controllers/uploader.php +++ b/modules/gallery/controllers/uploader.php @@ -51,7 +51,7 @@ class Uploader_Controller extends Controller { $file_validation = new Validation($_FILES); $file_validation->add_rules( "Filedata", "upload::valid", "upload::required", - "upload::type[" . implode(",", extensions::get_upload_extensions()) . "]"); + "upload::type[" . implode(",", legal_file::get_extensions()) . "]"); if ($form->validate() && $file_validation->validate()) { $temp_filename = upload::save("Filedata"); diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php new file mode 100644 index 00000000..2cb0fb25 --- /dev/null +++ b/modules/gallery/helpers/legal_file.php @@ -0,0 +1,39 @@ +extensions = array("gif", "jpg", "jpeg", "png"); + if (movie::find_ffmpeg()) { + array_push($extensions_wrapper->extensions, "flv", "mp4", "m4v"); + } + module::event("legal_file_extensions", $extensions_wrapper); + return $extensions_wrapper->extensions; + } + + static function get_filters() { + $filters = array(); + foreach (self::get_extensions() as $extension) { + array_push($filters, "*." . $extension, "*." . strtoupper($extension)); + } + return $filters; + } +} diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index 31ecafa7..9815d588 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -43,15 +43,18 @@ class system_Core { /** * Create a file with a unique file name. - * This helper is similar to the built-in tempnam, except that it supports an optional postfix. + * This helper is similar to the built-in tempnam. + * It allows the caller to specify a prefix and an extension. + * It always places the file in TMPPATH. */ - static function tempnam($dir = TMPPATH, $prefix = "", $postfix = "") { - return self::_tempnam($dir, $prefix, $postfix, "tempnam"); + static function temp_filename($prefix = "", $extension = "") { + return self::_tempnam(TMPPATH, $prefix, ".$extension", "tempnam"); } - // This helper provides a dependency-injected implementation of tempnam. + /** + * This helper provides a dependency-injected implementation of tempnam. + */ static function _tempnam($dir, $prefix, $postfix, $builtin) { - $success = false; do { $basename = call_user_func($builtin, $dir, $prefix); if (!$basename) { diff --git a/modules/gallery/libraries/Form_Uploadify.php b/modules/gallery/libraries/Form_Uploadify.php index 884653e2..450320b3 100644 --- a/modules/gallery/libraries/Form_Uploadify.php +++ b/modules/gallery/libraries/Form_Uploadify.php @@ -47,7 +47,7 @@ class Form_Uploadify_Core extends Form_Input { $v->script_data = $this->data["script_data"]; $v->simultaneous_upload_limit = module::get_var("gallery", "simultaneous_upload_limit"); $v->movies_allowed = (bool) movie::find_ffmpeg(); - $v->extensions = extensions::get_upload_filters(); + $v->extensions = legal_file::get_filters(); $v->suhosin_session_encrypt = (bool) ini_get("suhosin.session.encrypt"); list ($toolkit_max_filesize_bytes, $toolkit_max_filesize) = graphics::max_filesize(); diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 5ccbe75c..6eb93cfa 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -418,7 +418,11 @@ class Item_Model_Core extends ORM_MPTT { // keep it around. $original = ORM::factory("item", $this->id); - // Preserve the extension of the data file. + // Preserve the extension of the data file. Many helpers, (e.g. ImageMagick), assume + // the MIME type from the extension. So when we adopt the new data file, it's important + // to adopt the new extension. That ensures that the item's extension is always + // appropriate for its data. We don't try to preserve the name of the data file, though, + // because the name is typically a temporary randomly-generated name. if (isset($this->data_file)) { $extension = pathinfo($this->data_file, PATHINFO_EXTENSION); $new_name = pathinfo($this->name, PATHINFO_FILENAME) . ".$extension"; @@ -448,11 +452,19 @@ class Item_Model_Core extends ORM_MPTT { } if ($original->parent_id != $this->parent_id || $original->name != $this->name) { - // Move all of the items associated data files $this->_build_relative_caches(); + // If there is a data file, then we want to preserve both the old data and the new data. + // (Third-party event handlers would like access to both). The old data file will be + // accessible via the $original item, and the new one via $this item. But in that case, + // we don't want to rename the original as below, because the old data would end up being + // clobbered by the new data file. Also, the rename isn't necessary, because the new item + // data is coming from the data file anyway. So we only perform the rename if there isn't + // a data file. Another way to solve this would be to copy the original file rather than + // conditionally rename it, but a copy would cost far more than the rename. if (!isset($this->data_file)) { @rename($original->file_path(), $this->file_path()); } + // Move all of the items associated data files if ($this->is_album()) { @rename(dirname($original->resize_path()), dirname($this->resize_path())); @rename(dirname($original->thumb_path()), dirname($this->thumb_path())); @@ -804,7 +816,7 @@ class Item_Model_Core extends ORM_MPTT { if (($this->is_movie() || $this->is_photo()) && !preg_match("/^(" . implode("|", array_map("preg_quote", - extensions::get_upload_extensions())) . + legal_file::get_extensions())) . ")\$/i", $ext)) { $v->add_error("name", "illegal_data_file_extension"); } diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php index 734f98ac..dfe5d9ab 100644 --- a/modules/gallery/tests/System_Helper_Test.php +++ b/modules/gallery/tests/System_Helper_Test.php @@ -18,10 +18,11 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class System_Helper_Test extends Gallery_Unit_Test_Case { - public function tempnam_random_test() { - $filename = system::tempnam(TMPPATH, "file", ".ext"); + public function temp_filename_random_test() { + $filename = system::temp_filename("file", "ext"); $this->assert_true(file_exists($filename), "File not created"); unlink($filename); + $this->assert_pattern($filename, "|/file.*\\.ext$|"); } public function tempnam_collision_test() { -- cgit v1.2.3 From 68370b92f5f6fa68744655f8c68b4b0ca59bf4fd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 2 May 2011 21:36:17 -0700 Subject: Map the G2 album highlight thumbnail derivative id to the G3 album's thumbnail. Fixes #1729. --- modules/g2_import/helpers/g2_import.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 3606c7ef..c79a8d36 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -560,7 +560,7 @@ class g2_import_Core { $table = g2(GalleryCoreApi::fetchThumbnailsByItemIds(array($g2_album_id))); if (isset($table[$g2_album_id])) { // Backtrack the source id to an item - $g2_source = $table[$g2_album_id]; + $orig_g2_source = $g2_source = $table[$g2_album_id]; while (GalleryUtilities::isA($g2_source, "GalleryDerivative")) { $g2_source = g2(GalleryCoreApi::loadEntitiesById($g2_source->getDerivativeSourceId())); } @@ -584,6 +584,11 @@ class g2_import_Core { array("name" => $g3_album->name)), $e); } + + self::set_map( + $orig_g2_source->getId(), $g3_album->id, + "thumbnail", + self::g2_url(array("view" => "core.DownloadItem", "itemId" => $orig_g2_source->getId()))); } } } -- cgit v1.2.3 From 229bfc5c7c760c53d1357503fd61bf9a165acf6e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 2 May 2011 21:37:04 -0700 Subject: Track and redirect core.DownloadItem requests properly. This can happen if the G2 was imported with rewrite on, so the g2_url in the g2_map table has a shortened url, but then rewrite is disabled and the .htaccess mod_rewrite rules are sending over a &g2_view=core.DownloadItem request. Fixes #1728. --- modules/g2_import/controllers/g2.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 6e60bed0..90984e84 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -41,7 +41,9 @@ class G2_Controller extends Controller { // (bbcode, embedding) people are using the id style URLs although URL rewriting is enabled. $where = array(array("g2_id", "=", $id)); $view = $input->get("g2_view"); - if ($view) { + if ($view == "core.DownloadItem") { + $where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full")); + } else if ($view) { $where[] = array("g2_url", "like", "%g2_view=$view%"); } // else: Assuming that the first search hit is sufficiently good. } else if ($path) { -- cgit v1.2.3 From d2331bf43457a8d33491921f106879f087438171 Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 4 May 2011 17:48:25 -0600 Subject: Simplified the temp_filename implementation and removed the mocks. --- modules/gallery/helpers/system.php | 15 +++-------- modules/gallery/tests/Mock_Built_In.php | 39 ---------------------------- modules/gallery/tests/System_Helper_Test.php | 25 +----------------- 3 files changed, 5 insertions(+), 74 deletions(-) delete mode 100644 modules/gallery/tests/Mock_Built_In.php (limited to 'modules') diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index 9815d588..e7e58a70 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -47,20 +47,13 @@ class system_Core { * It allows the caller to specify a prefix and an extension. * It always places the file in TMPPATH. */ - static function temp_filename($prefix = "", $extension = "") { - return self::_tempnam(TMPPATH, $prefix, ".$extension", "tempnam"); - } - - /** - * This helper provides a dependency-injected implementation of tempnam. - */ - static function _tempnam($dir, $prefix, $postfix, $builtin) { + static function temp_filename($prefix="", $extension="") { do { - $basename = call_user_func($builtin, $dir, $prefix); + $basename = tempnam(TMPPATH, $prefix); if (!$basename) { return false; } - $filename = $basename . $postfix; + $filename = "$basename.$extension"; $success = !file_exists($filename) && @rename($basename, $filename); if (!$success) { @unlink($basename); @@ -68,4 +61,4 @@ class system_Core { } while (!$success); return $filename; } -} \ No newline at end of file +} diff --git a/modules/gallery/tests/Mock_Built_In.php b/modules/gallery/tests/Mock_Built_In.php deleted file mode 100644 index b02e5ecf..00000000 --- a/modules/gallery/tests/Mock_Built_In.php +++ /dev/null @@ -1,39 +0,0 @@ -nonces = func_get_args(); - } - - function _tempnam($dir, $prefix) { - if (empty($this->nonces)) - return false; - $filename = "$dir/$prefix" . array_shift($this->nonces); - if (!touch($filename)) - return false; - return $filename; - } -} diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php index dfe5d9ab..3d56c516 100644 --- a/modules/gallery/tests/System_Helper_Test.php +++ b/modules/gallery/tests/System_Helper_Test.php @@ -18,33 +18,10 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class System_Helper_Test extends Gallery_Unit_Test_Case { - public function temp_filename_random_test() { + public function temp_filename_test() { $filename = system::temp_filename("file", "ext"); $this->assert_true(file_exists($filename), "File not created"); unlink($filename); $this->assert_pattern($filename, "|/file.*\\.ext$|"); } - - public function tempnam_collision_test() { - require_once('Mock_Built_In.php'); - $existing = TMPPATH . "/file1.ext"; - $available = TMPPATH . "/file2.ext"; - touch($existing); - $filename = system::_tempnam(TMPPATH, "file", ".ext", - array(new Mock_Built_In("1", "2"), "_tempnam")); - unlink($existing); - $this->assert_true(file_exists($filename), "File not created"); - unlink($filename); - $this->assert_equal($available, $filename, "Incorrect filename created"); - } - - public function tempnam_abort_test() { - require_once('Mock_Built_In.php'); - $filename = system::_tempnam(TMPPATH, "file", ".ext", - array(new Mock_Built_In(), "_tempnam")); - if ($filename) { - @unlink($filename); - } - $this->assert_false($filename, "Operation not aborted"); - } } -- cgit v1.2.3 From 46da011bf69bbc4e45757feda8f0d28e91e7fb6a Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 4 May 2011 17:51:00 -0600 Subject: Remove a newline I accidentally introduced. --- modules/gallery/helpers/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index e7e58a70..4110b4ed 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -61,4 +61,4 @@ class system_Core { } while (!$success); return $filename; } -} +} \ No newline at end of file -- cgit v1.2.3 From 5bae21864f54a03b557ab349cf97ba5f1d4276dc Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 5 May 2011 14:52:47 -0700 Subject: Follow-on to 6f916e49d5b431c2c1961a13d1a61fef8c02d628 -- don't make database calls if Gallery isn't installed, else we fail to bounce the user to the installer on fresh packages. #1637. --- modules/gallery/config/locale.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/config/locale.php b/modules/gallery/config/locale.php index 13de9098..bce7fb49 100644 --- a/modules/gallery/config/locale.php +++ b/modules/gallery/config/locale.php @@ -32,7 +32,12 @@ $config['language'] = array('en_US', 'English_United States'); * Locale timezone. Set in 'Advanced' settings, falling back to the server's zone. * @see http://php.net/timezones */ -$config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get()); +if (file_exists(VARPATH . "database.php")) { + $config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get()); +} else { + // Gallery3 is not installed yet -- don't make module::get_var() calls. + $config['timezone'] = date_default_timezone_get(); +} // i18n settings -- cgit v1.2.3 From 57f7e42a128848d73ad2a7ac0bf9df2fee6ba8b8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 8 May 2011 11:42:40 -0700 Subject: Add the item id to the print_proxy line so that we have a little more info about what the original was, and extend the timeout to 90 days from 10. Fixes #1733. --- modules/digibug/controllers/digibug.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 4acb6513..672afe57 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -33,8 +33,8 @@ class Digibug_Controller extends Controller { $proxy->uuid = random::hash(); $proxy->item_id = $item->id; $proxy->save(); - $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid"); - $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid"); + $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid/$item->id"); + $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid/$item->id"); } $v = new View("digibug_form.html"); @@ -114,7 +114,7 @@ class Digibug_Controller extends Controller { private function _clean_expired() { db::build() ->delete("digibug_proxies") - ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 10 DAY)")) + ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 90 DAY)")) ->limit(20) ->execute(); } -- cgit v1.2.3 From 97c3ded2bae24fa18801c94548d1cfd97e19cf2a Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 18 May 2011 22:01:51 -0600 Subject: Better validation for uploaded files, especially where third-party modules might make a mistake. Squashed commit of the following: commit f2336a5aaa0eb797f252388ecd7b93a82f9646fd Author: Chad Parry Date: Wed May 18 21:56:10 2011 -0600 Behave reasonably if the image cannot be resized. commit e06b20738d0e0bdb80bae68b7fec2b3746192f6e Author: Chad Parry Date: Wed May 18 21:10:08 2011 -0600 Adding an image representing a broken thumbnail. This image was derived from the equivalent Gallery2 icon. It uses the same washed-out gray color scheme as the Gallery3 missing_movie icon. commit 4e3964527b66d8ccd76fb261d549cd9861a7a780 Author: Chad Parry Date: Wed May 18 20:30:28 2011 -0600 Initialize legal file arrays correctly. commit e9862d8fbc4d6fd06abf157f48dce671a7283993 Author: Chad Parry Date: Wed May 18 20:20:19 2011 -0600 Correction for the merge conflict markers I accidentally committed. commit 5e62d327a8dc477d3edea99826183548aca3e7f3 Author: Chad Parry Date: Wed May 18 20:17:36 2011 -0600 Expand the legal_file events to include separate photo and movie events, and to support MIME types. commit f0bfd1fef0b6d17da9a491f7c724ae53491926a2 Merge: 72f3fc4 db73413 Author: Chad Parry Date: Wed May 18 19:49:25 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto Conflicts: modules/gallery/helpers/system.php modules/gallery/tests/System_Helper_Test.php commit db734130c5fe10408040b2326b28b102f3131271 Author: Automatic Build Number Updater Date: Mon May 16 21:38:07 2011 -0700 Automated update of .build_number to 153 for branch master Last update: 9aeb824aa1d15bd94bd7cef0a322c4e8a667e67b (1 commits ago) commit 8549ba30ca5045211d2efcf8e1c4f98f8a1e9f25 Author: Chad Kieffer Date: Mon May 16 22:37:09 2011 -0600 Stop IE 9 album grid craziness. Thanks floridave. Fixes #1430. commit 9aeb824aa1d15bd94bd7cef0a322c4e8a667e67b Author: Automatic Build Number Updater Date: Sun May 8 11:43:38 2011 -0700 Automated update of .build_number to 152 for branch master Last update: 7c80e6ef84b460dcade80c4dd5a65b41b0523505 (1 commits ago) commit 57f7e42a128848d73ad2a7ac0bf9df2fee6ba8b8 Author: Bharat Mediratta Date: Sun May 8 11:42:40 2011 -0700 Add the item id to the print_proxy line so that we have a little more info about what the original was, and extend the timeout to 90 days from 10. Fixes #1733. commit 7c80e6ef84b460dcade80c4dd5a65b41b0523505 Author: Automatic Build Number Updater Date: Fri May 6 11:48:43 2011 -0700 Automated update of .build_number to 151 for branch master Last update: 5d09cbff048fc2f457c8b19adb2177a12445890a (1 commits ago) commit 80dda6f64fd26f373cc138a199652099accceb26 Merge: 5d09cbf 46da011 Author: Bharat Mediratta Date: Fri May 6 11:48:13 2011 -0700 Merge pull request #52 from chadparry/tempnam Fixes #1732 commit 5d09cbff048fc2f457c8b19adb2177a12445890a Author: Automatic Build Number Updater Date: Thu May 5 21:53:39 2011 -0700 Automated update of .build_number to 150 for branch master Last update: 011eaa6480cbee8d328a31c9ac5c8e0ddc1f8a84 (1 commits ago) commit d5a31ceedee5841531f57342266746bb62d7d923 Author: Tim Almdal Date: Thu May 5 21:53:10 2011 -0700 Fix for ticket 1275. Do the same checking as Kohana uses and don't worry about calling the utf8_encode routine. Corrected the error messages and also added a check to insure the XML Parser extension is loaded as we still need the utf8_encode function from it. commit 011eaa6480cbee8d328a31c9ac5c8e0ddc1f8a84 Author: Automatic Build Number Updater Date: Thu May 5 14:53:06 2011 -0700 Automated update of .build_number to 149 for branch master Last update: 05ecfda36b7acee7f8d36df8391ba960097178a8 (1 commits ago) commit 5bae21864f54a03b557ab349cf97ba5f1d4276dc Author: Bharat Mediratta Date: Thu May 5 14:52:47 2011 -0700 Follow-on to 6f916e49d5b431c2c1961a13d1a61fef8c02d628 -- don't make database calls if Gallery isn't installed, else we fail to bounce the user to the installer on fresh packages. #1637. commit 46da011bf69bbc4e45757feda8f0d28e91e7fb6a Author: Chad Parry Date: Wed May 4 17:51:00 2011 -0600 Remove a newline I accidentally introduced. commit 5c6c71ffcdea354b5b9b30aaea2c1f92c8860d42 Merge: d2331bf 05ecfda Author: Chad Parry Date: Wed May 4 17:49:42 2011 -0600 Merge branch 'master' into tempnam commit d2331bf43457a8d33491921f106879f087438171 Author: Chad Parry Date: Wed May 4 17:48:25 2011 -0600 Simplified the temp_filename implementation and removed the mocks. commit 72f3fc46f6c7c9043e730063051ecfd88bf314c8 Author: Chad Parry Date: Wed May 4 17:22:15 2011 -0600 Avoid "self::" because Kohana can't override it. commit 05ecfda36b7acee7f8d36df8391ba960097178a8 Author: Automatic Build Number Updater Date: Mon May 2 21:38:50 2011 -0700 Automated update of .build_number to 148 for branch master Last update: 97400b78153620262120868b37545170416413c9 (2 commits ago) commit 229bfc5c7c760c53d1357503fd61bf9a165acf6e Author: Bharat Mediratta Date: Mon May 2 21:37:04 2011 -0700 Track and redirect core.DownloadItem requests properly. This can happen if the G2 was imported with rewrite on, so the g2_url in the g2_map table has a shortened url, but then rewrite is disabled and the .htaccess mod_rewrite rules are sending over a &g2_view=core.DownloadItem request. Fixes #1728. commit 68370b92f5f6fa68744655f8c68b4b0ca59bf4fd Author: Bharat Mediratta Date: Mon May 2 21:36:17 2011 -0700 Map the G2 album highlight thumbnail derivative id to the G3 album's thumbnail. Fixes #1729. commit 13dbd3515bfb5324cfbcb3bbeafc179771b54f75 Merge: f0f094c 97400b7 Author: Chad Parry Date: Sat Apr 30 20:33:02 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit f0f094c3f79b09536f58083681c28f73271c506d Author: Chad Parry Date: Sat Apr 30 20:22:49 2011 -0600 Explain the conditional rename in item::save() with a comment. commit 1b3a6b85c156e4777d2aa8205b130984f55dc66d Author: Chad Parry Date: Sat Apr 30 18:29:34 2011 -0600 Improve the comment explaining why the data_file extension is important. commit c3e8c1e3b5e3cb1046acd4c923bb0ae9dbcd603a Author: Chad Parry Date: Sat Apr 30 18:12:56 2011 -0600 The data_file field is public, so we don't need to supply an accessor method. commit 0e844766baf3b3875cbb2d84579626e05e879420 Author: Chad Parry Date: Sat Apr 30 16:40:55 2011 -0600 Change the signature of system::tempnam to something more appropriate for Gallery. commit 5c9a3b3f39f6ff0d5c84c2cf283d27eaebe2e66e Author: Chad Parry Date: Sat Apr 23 21:19:47 2011 -0600 Create a tempnam substitute that safely creates files with a given extension. commit 2375a02e2cdbd1ccaf7dc4d3db9d85119972e3a9 Author: Chad Parry Date: Sat Apr 30 16:40:55 2011 -0600 Change the signature of system::tempnam to something more appropriate for Gallery. commit a8ca9dcf9edd54633c0c78b3af76aa974d38fc64 Author: Chad Parry Date: Sat Apr 30 16:10:06 2011 -0600 Change the name of the extensions helper to legal_file. commit 7e61a01a96f5eab7212dba754ac64fdfb4d9e8ab Author: Chad Parry Date: Sat Apr 30 16:08:49 2011 -0600 Change the name of the extensions helper to legal_file. commit 4c2b2ebd3f2052898fbfb175650ed4cf49c8006e Author: Chad Parry Date: Wed Apr 27 20:52:35 2011 -0600 Remove a newline at the end of the file that I accidentally introduced. commit 6d564f185e5279d6cca9a7385066514ff18a2455 Merge: 7ff485f 4060640 Author: Chad Parry Date: Wed Apr 27 20:35:58 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit 7ff485fa48c392bbbb0370f67cb1bd6fcc00c2a4 Author: Chad Parry Date: Wed Apr 27 20:29:06 2011 -0600 Move the extensions helpers out of the Kohana system directory and into their own Gallery Extensions class. commit 26585fed03236f0f70a75959e1d3002025f4e15e Merge: 809567f c8f90e8 Author: Chad Parry Date: Sun Apr 24 08:28:39 2011 -0600 Merge branch 'master' of https://github.com/gallery/gallery3 into rawphoto commit 809567f12850f59bdeb47a2963f6968b99b5a201 Author: Chad Parry Date: Sun Apr 24 08:10:04 2011 -0600 Expose the data file field. commit fcb06bf175bb9eeff36d9c294e97ace9374ef0f3 Author: Chad Parry Date: Sun Apr 24 00:45:12 2011 -0600 Don't assign to the item->name field if the name is unchanged, because the save method will crash. commit c6ef706d70c7e48bea1145eec1b13fb5683e023f Author: Chad Parry Date: Sat Apr 23 22:55:59 2011 -0600 Preserve old data files long enough for them to be available to event handlers. commit 0d6a3a3cfc4f38f450db9e18da47a5e2ad826af8 Author: Chad Parry Date: Sat Apr 23 21:19:47 2011 -0600 Create a tempnam substitute that safely creates files with a given extension. commit e149cf7238a1f8eaddfc68580f2d636dd8255795 Author: Chad Parry Date: Sat Apr 23 16:39:25 2011 -0600 Support data files that change their extension and MIME type. commit 6702104f571413e4d57db3515b2070c48d3e9b55 Author: Chad Parry Date: Sat Apr 23 16:35:00 2011 -0600 Resolve an infinite recursion that happens when the path caches are updated during saving. commit 944cb72eea946f4c45a04b7e4c7c33929fa8b9f3 Merge: 567522b 5af74d4 Author: Chad Parry Date: Fri Apr 22 14:10:42 2011 -0600 Merge remote branch 'origin/master' into rawphoto commit 567522bfa08c370bb5baf8454afc5b04bc9e49b4 Author: Chad Parry Date: Thu Apr 21 20:12:32 2011 -0600 Add an event for when a new graphics toolkit is chosen. commit 31ba081b793141ca36866a6dd349cd2eac5af68e Author: Chad Parry Date: Thu Apr 21 02:06:53 2011 -0600 Add an event that will collect all valid filename extensions. --- .build_number | 2 +- installer/installer.php | 10 +++++-- modules/digibug/controllers/digibug.php | 6 ++--- modules/g2_import/controllers/g2.php | 4 ++- modules/g2_import/helpers/g2_import.php | 7 ++++- modules/gallery/config/locale.php | 7 ++++- modules/gallery/helpers/graphics.php | 22 ++++++++++++--- modules/gallery/helpers/legal_file.php | 39 +++++++++++++++++++++++---- modules/gallery/helpers/system.php | 13 +++------ modules/gallery/images/missing_photo.png | Bin 0 -> 1570 bytes modules/gallery/models/item.php | 15 ++++++----- modules/gallery/tests/System_Helper_Test.php | 25 +---------------- themes/wind/js/ui.init.js | 2 +- 13 files changed, 93 insertions(+), 59 deletions(-) create mode 100644 modules/gallery/images/missing_photo.png (limited to 'modules') diff --git a/.build_number b/.build_number index 1bdd507d..190e1781 100644 --- a/.build_number +++ b/.build_number @@ -3,4 +3,4 @@ ; process. You don't need to edit it. In fact.. ; ; DO NOT EDIT THIS FILE BY HAND! -build_number=147 +build_number=153 diff --git a/installer/installer.php b/installer/installer.php index c23d918f..0bef57ae 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -191,8 +191,10 @@ class installer { $errors[] = "Gallery 3 requires a MySQL database, but PHP doesn't have either the MySQL or the MySQLi extension."; } - if (!@preg_match("/^.$/u", utf8_encode("\xF1"))) { - $errors[] = "PHP is missing Perl-Compatible Regular Expression support."; + if (!preg_match("/^.$/u", "ñ")) { + $errors[] = "PHP is missing Perl-Compatible Regular Expression with UTF-8 support."; + } else if (!preg_match("/^\pL$/u", "ñ")) { + $errors[] = "PHP is missing Perl-Compatible Regular Expression with Unicode support."; } if (!(function_exists("spl_autoload_register"))) { @@ -211,6 +213,10 @@ class installer { $errors[] = "PHP is missing the iconv extension"; } + if (!(extension_loaded("xml"))) { + $errors[] = "PHP is missing the XML Parser extension"; + } + if (!(extension_loaded("simplexml"))) { $errors[] = "PHP is missing the SimpleXML extension"; } diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index 4acb6513..672afe57 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -33,8 +33,8 @@ class Digibug_Controller extends Controller { $proxy->uuid = random::hash(); $proxy->item_id = $item->id; $proxy->save(); - $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid"); - $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid"); + $full_url = url::abs_site("digibug/print_proxy/full/$proxy->uuid/$item->id"); + $thumb_url = url::abs_site("digibug/print_proxy/thumb/$proxy->uuid/$item->id"); } $v = new View("digibug_form.html"); @@ -114,7 +114,7 @@ class Digibug_Controller extends Controller { private function _clean_expired() { db::build() ->delete("digibug_proxies") - ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 10 DAY)")) + ->where("request_date", "<=", db::expr("(CURDATE() - INTERVAL 90 DAY)")) ->limit(20) ->execute(); } diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 6e60bed0..90984e84 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -41,7 +41,9 @@ class G2_Controller extends Controller { // (bbcode, embedding) people are using the id style URLs although URL rewriting is enabled. $where = array(array("g2_id", "=", $id)); $view = $input->get("g2_view"); - if ($view) { + if ($view == "core.DownloadItem") { + $where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full")); + } else if ($view) { $where[] = array("g2_url", "like", "%g2_view=$view%"); } // else: Assuming that the first search hit is sufficiently good. } else if ($path) { diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 3606c7ef..c79a8d36 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -560,7 +560,7 @@ class g2_import_Core { $table = g2(GalleryCoreApi::fetchThumbnailsByItemIds(array($g2_album_id))); if (isset($table[$g2_album_id])) { // Backtrack the source id to an item - $g2_source = $table[$g2_album_id]; + $orig_g2_source = $g2_source = $table[$g2_album_id]; while (GalleryUtilities::isA($g2_source, "GalleryDerivative")) { $g2_source = g2(GalleryCoreApi::loadEntitiesById($g2_source->getDerivativeSourceId())); } @@ -584,6 +584,11 @@ class g2_import_Core { array("name" => $g3_album->name)), $e); } + + self::set_map( + $orig_g2_source->getId(), $g3_album->id, + "thumbnail", + self::g2_url(array("view" => "core.DownloadItem", "itemId" => $orig_g2_source->getId()))); } } } diff --git a/modules/gallery/config/locale.php b/modules/gallery/config/locale.php index 13de9098..bce7fb49 100644 --- a/modules/gallery/config/locale.php +++ b/modules/gallery/config/locale.php @@ -32,7 +32,12 @@ $config['language'] = array('en_US', 'English_United States'); * Locale timezone. Set in 'Advanced' settings, falling back to the server's zone. * @see http://php.net/timezones */ -$config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get()); +if (file_exists(VARPATH . "database.php")) { + $config['timezone'] = module::get_var("gallery", "timezone", date_default_timezone_get()); +} else { + // Gallery3 is not installed yet -- don't make module::get_var() calls. + $config['timezone'] = date_default_timezone_get(); +} // i18n settings diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index acb11bfb..3b9769de 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -170,23 +170,37 @@ class graphics_Core { foreach (self::_get_rules($target) as $rule) { $args = array($working_file, $output_file, unserialize($rule->args), $item); - call_user_func_array($rule->operation, $args); - $working_file = $output_file; + try { + call_user_func_array($rule->operation, $args); + $working_file = $output_file; + } catch (Exception $e) { + // Ignore this filter and move on. + Kohana_Log::add("error", "Caught exception filtering image: {$item->title}\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + } } } if (!empty($ops["thumb"])) { + if (file_exists($item->thumb_path())) { + $item->thumb_dirty = 0; + } else { + copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path()); + } $dims = getimagesize($item->thumb_path()); $item->thumb_width = $dims[0]; $item->thumb_height = $dims[1]; - $item->thumb_dirty = 0; } if (!empty($ops["resize"])) { + if (file_exists($item->resize_path())) { + $item->resize_dirty = 0; + } else { + copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path()); + } $dims = getimagesize($item->resize_path()); $item->resize_width = $dims[0]; $item->resize_height = $dims[1]; - $item->resize_dirty = 0; } $item->save(); } catch (Exception $e) { diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php index 2cb0fb25..0d3e9728 100644 --- a/modules/gallery/helpers/legal_file.php +++ b/modules/gallery/helpers/legal_file.php @@ -18,22 +18,51 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class legal_file_Core { - static function get_extensions() { + static function get_photo_extensions() { // Create a default list of allowed extensions and then let modules modify it. $extensions_wrapper = new stdClass(); $extensions_wrapper->extensions = array("gif", "jpg", "jpeg", "png"); + module::event("legal_photo_extensions", $extensions_wrapper); + return $extensions_wrapper->extensions; + } + + static function get_movie_extensions() { + // Create a default list of allowed extensions and then let modules modify it. + $extensions_wrapper = new stdClass(); + $extensions_wrapper->extensions = array("flv", "mp4", "m4v"); + module::event("legal_movie_extensions", $extensions_wrapper); + return $extensions_wrapper->extensions; + } + + static function get_extensions() { + $extensions = legal_file::get_photo_extensions(); if (movie::find_ffmpeg()) { - array_push($extensions_wrapper->extensions, "flv", "mp4", "m4v"); + $extensions = array_merge($extensions, legal_file::get_movie_extensions()); } - module::event("legal_file_extensions", $extensions_wrapper); - return $extensions_wrapper->extensions; + return $extensions; } static function get_filters() { $filters = array(); - foreach (self::get_extensions() as $extension) { + foreach (legal_file::get_extensions() as $extension) { array_push($filters, "*." . $extension, "*." . strtoupper($extension)); } return $filters; } + + static function get_photo_types() { + // Create a default list of allowed types and then let modules modify it. + $types_wrapper = new stdClass(); + $types_wrapper->types = array("image/jpeg", "image/gif", "image/png"); + module::event("legal_photo_types", $types_wrapper); + return $types_wrapper->types; + } + + static function get_movie_types() { + // Create a default list of allowed types and then let modules modify it. + $types_wrapper = new stdClass(); + $types_wrapper->types = array("video/flv", "video/x-flv", "video/mp4"); + module::event("legal_movie_types", $types_wrapper); + return $types_wrapper->types; + } } diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php index 9815d588..4110b4ed 100644 --- a/modules/gallery/helpers/system.php +++ b/modules/gallery/helpers/system.php @@ -47,20 +47,13 @@ class system_Core { * It allows the caller to specify a prefix and an extension. * It always places the file in TMPPATH. */ - static function temp_filename($prefix = "", $extension = "") { - return self::_tempnam(TMPPATH, $prefix, ".$extension", "tempnam"); - } - - /** - * This helper provides a dependency-injected implementation of tempnam. - */ - static function _tempnam($dir, $prefix, $postfix, $builtin) { + static function temp_filename($prefix="", $extension="") { do { - $basename = call_user_func($builtin, $dir, $prefix); + $basename = tempnam(TMPPATH, $prefix); if (!$basename) { return false; } - $filename = $basename . $postfix; + $filename = "$basename.$extension"; $success = !file_exists($filename) && @rename($basename, $filename); if (!$success) { @unlink($basename); diff --git a/modules/gallery/images/missing_photo.png b/modules/gallery/images/missing_photo.png new file mode 100644 index 00000000..67786275 Binary files /dev/null and b/modules/gallery/images/missing_photo.png differ diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 6eb93cfa..4a0c8e38 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -813,10 +813,13 @@ class Item_Model_Core extends ORM_MPTT { return; } - if (($this->is_movie() || $this->is_photo()) && + if ($this->is_photo() && !preg_match("/^(" . - implode("|", array_map("preg_quote", - legal_file::get_extensions())) . + implode("|", array_map("preg_quote", legal_file::get_photo_extensions())) . + ")\$/i", $ext) || + $this->is_movie() && + !preg_match("/^(" . + implode("|", array_map("preg_quote", legal_file::get_movie_extensions())) . ")\$/i", $ext)) { $v->add_error("name", "illegal_data_file_extension"); } @@ -896,9 +899,9 @@ class Item_Model_Core extends ORM_MPTT { switch($field) { case "mime_type": if ($this->is_movie()) { - $legal_values = array("video/flv", "video/x-flv", "video/mp4"); - } if ($this->is_photo()) { - $legal_values = array("image/jpeg", "image/gif", "image/png", "image/tiff"); + $legal_values = legal_file::get_movie_types(); + } else if ($this->is_photo()) { + $legal_values = legal_file::get_photo_types(); } break; diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php index dfe5d9ab..3d56c516 100644 --- a/modules/gallery/tests/System_Helper_Test.php +++ b/modules/gallery/tests/System_Helper_Test.php @@ -18,33 +18,10 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class System_Helper_Test extends Gallery_Unit_Test_Case { - public function temp_filename_random_test() { + public function temp_filename_test() { $filename = system::temp_filename("file", "ext"); $this->assert_true(file_exists($filename), "File not created"); unlink($filename); $this->assert_pattern($filename, "|/file.*\\.ext$|"); } - - public function tempnam_collision_test() { - require_once('Mock_Built_In.php'); - $existing = TMPPATH . "/file1.ext"; - $available = TMPPATH . "/file2.ext"; - touch($existing); - $filename = system::_tempnam(TMPPATH, "file", ".ext", - array(new Mock_Built_In("1", "2"), "_tempnam")); - unlink($existing); - $this->assert_true(file_exists($filename), "File not created"); - unlink($filename); - $this->assert_equal($available, $filename, "Incorrect filename created"); - } - - public function tempnam_abort_test() { - require_once('Mock_Built_In.php'); - $filename = system::_tempnam(TMPPATH, "file", ".ext", - array(new Mock_Built_In(), "_tempnam")); - if ($filename) { - @unlink($filename); - } - $this->assert_false($filename, "Operation not aborted"); - } } diff --git a/themes/wind/js/ui.init.js b/themes/wind/js/ui.init.js index 2c67bf3a..3ee3e32e 100644 --- a/themes/wind/js/ui.init.js +++ b/themes/wind/js/ui.init.js @@ -82,7 +82,7 @@ $(document).ready(function() { } else { var sib_height = $(this).prev().height(); } - if ($.browser.msie && $.browser.version >= 8) { + if ($.browser.msie && $.browser.version <= 8) { sib_height = sib_height + 1; } $(this).css("height", sib_height); -- cgit v1.2.3 From 1807e10a56be504b11900f3ffe3cfb28b7bca5ed Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 18 May 2011 22:05:40 -0600 Subject: Merging some changes from rawphoto --- modules/gallery/helpers/extensions.php | 39 ---------------------------------- modules/gallery/models/item.php | 9 -------- 2 files changed, 48 deletions(-) delete mode 100644 modules/gallery/helpers/extensions.php (limited to 'modules') diff --git a/modules/gallery/helpers/extensions.php b/modules/gallery/helpers/extensions.php deleted file mode 100644 index bccbfc41..00000000 --- a/modules/gallery/helpers/extensions.php +++ /dev/null @@ -1,39 +0,0 @@ -extensions = array("gif", "jpg", "jpeg", "png"); - if (movie::find_ffmpeg()) { - array_push($extensions_wrapper->extensions, "flv", "mp4", "m4v"); - } - module::event("upload_extensions", $extensions_wrapper); - return $extensions_wrapper->extensions; - } - - static function get_upload_filters() { - $filters = array(); - foreach (self::get_upload_extensions() as $extension) { - array_push($filters, "*." . $extension, "*." . strtoupper($extension)); - } - return $filters; - } -} diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 4a0c8e38..1dd9b00b 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -127,15 +127,6 @@ class Item_Model_Core extends ORM_MPTT { return $this; } - /** - * Get the path to the data file associated with this item. - * This data file field is only set until you call save(). - * After that, you can get the path using get_file_path(). - */ - public function get_data_file() { - return $this->data_file; - } - /** * Return the server-relative url to this item, eg: * /gallery3/index.php/BobsWedding?page=2 -- cgit v1.2.3 From 1f464cb7d84a9c701f88ca3c8efb4c92e8de1151 Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 18 May 2011 22:12:41 -0600 Subject: Removing an unused file. --- modules/gallery/tests/Mock_Built_In.php | 39 --------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 modules/gallery/tests/Mock_Built_In.php (limited to 'modules') diff --git a/modules/gallery/tests/Mock_Built_In.php b/modules/gallery/tests/Mock_Built_In.php deleted file mode 100644 index b02e5ecf..00000000 --- a/modules/gallery/tests/Mock_Built_In.php +++ /dev/null @@ -1,39 +0,0 @@ -nonces = func_get_args(); - } - - function _tempnam($dir, $prefix) { - if (empty($this->nonces)) - return false; - $filename = "$dir/$prefix" . array_shift($this->nonces); - if (!touch($filename)) - return false; - return $filename; - } -} -- cgit v1.2.3 From 784ebe75321304fe3f83cddaf3cb1030410fb5ed Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 22 May 2011 21:24:27 -0700 Subject: Leave the "updated" field alone when importing comments so that if Akismet marks them as spam, we don't immediately flush them out of the database on the next visit to Admin > Content > Comments. Also warn the user about Akismet, and fix up the G2 import code to reimport deleted comments. --- modules/g2_import/controllers/admin_g2_import.php | 5 +++++ modules/g2_import/helpers/g2_import.php | 26 ++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php index 1a705bea..4c8af852 100644 --- a/modules/g2_import/controllers/admin_g2_import.php +++ b/modules/g2_import/controllers/admin_g2_import.php @@ -60,6 +60,11 @@ class Admin_g2_import_Controller extends Admin_Controller { array("url" => url::site("admin/modules"), "module_id" => $module_id))); } } + if (module::is_active("akismet")) { + message::warning( + t("The Akismet module may mark some or all of your imported comments as spam. Deactivate it to avoid that outcome.", + array("url" => url::site("admin/modules")))); + } } else if (g2_import::is_configured()) { $view->content->form->configure_g2_import->embed_path->add_error("invalid", 1); } diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index c79a8d36..5c690da4 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -908,9 +908,14 @@ class g2_import_Core { array("id" => $g2_comment_id, "exception" => (string)$e)); } - if (self::map($g2_comment->getId())) { - // Already imported - return; + if ($id = self::map($g2_comment->getId())) { + if (ORM::factory("comment", $id)->loaded()) { + // Already imported and still exists + return; + } + // This comment was already imported, but now it no longer exists. Import it again, per + // ticket #1736. + self::clear_map($g2_comment_id); } $item_id = self::map($g2_comment->getParentId()); @@ -948,10 +953,11 @@ class g2_import_Core { self::set_map($g2_comment->getId(), $comment->id, "comment"); // Backdate the creation date. We can't do this at creation time because - // Comment_Model::save() will override it. + // Comment_Model::save() will override it. Leave the updated date alone + // so that if the comments get marked as spam, they don't immediately get + // flushed (see ticket #1736) db::update("comments") ->set("created", $g2_comment->getDate()) - ->set("updated", $g2_comment->getDate()) ->where("id", "=", $comment->id) ->execute(); } @@ -1306,6 +1312,16 @@ class g2_import_Core { self::$map[$g2_id] = $g3_id; } + /** + * Remove all map entries associated with the given Gallery 2 id. + */ + static function clear_map($g2_id) { + db::build() + ->delete("g2_maps") + ->where("g2_id", "=", $g2_id) + ->execute(); + } + static function log($msg) { message::warning($msg); Kohana_Log::add("alert", $msg); -- cgit v1.2.3 From f567bdde2817a52afbd436421b61adad8f4a9fd8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 22 May 2011 21:36:16 -0700 Subject: Clear any existing, matching g2_map rows before mapping new rows. This is an extra query, but should keep duplicate rows out of the database and let new rows supercede old ones. Fixes #1737. --- modules/g2_import/helpers/g2_import.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 5c690da4..8a5d2c5f 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -915,7 +915,6 @@ class g2_import_Core { } // This comment was already imported, but now it no longer exists. Import it again, per // ticket #1736. - self::clear_map($g2_comment_id); } $item_id = self::map($g2_comment->getParentId()); @@ -1298,6 +1297,7 @@ class g2_import_Core { * Associate a Gallery 2 id with a Gallery 3 item id. */ static function set_map($g2_id, $g3_id, $resource_type, $g2_url=null) { + self::clear_map($g2_id, $resource_type); $g2_map = ORM::factory("g2_map"); $g2_map->g3_id = $g3_id; $g2_map->g2_id = $g2_id; @@ -1315,10 +1315,11 @@ class g2_import_Core { /** * Remove all map entries associated with the given Gallery 2 id. */ - static function clear_map($g2_id) { + static function clear_map($g2_id, $resource_type) { db::build() ->delete("g2_maps") ->where("g2_id", "=", $g2_id) + ->where("resource_type", "=", $resource_type) ->execute(); } -- cgit v1.2.3 From c71bb5418557c4a6ac4ff3101f7dca296a4dced5 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 May 2011 20:32:43 -0700 Subject: Reassign the copyright to the standard custodian (Bharat). #1732. --- modules/gallery/tests/System_Helper_Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/tests/System_Helper_Test.php b/modules/gallery/tests/System_Helper_Test.php index 3d56c516..b6c00f4c 100644 --- a/modules/gallery/tests/System_Helper_Test.php +++ b/modules/gallery/tests/System_Helper_Test.php @@ -1,7 +1,7 @@ Date: Tue, 24 May 2011 20:33:36 -0700 Subject: Checkpoint --- modules/gallery/tests/xss_data.txt | 92 +++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 7da79b23..954caf54 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -5,21 +5,22 @@ modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY_ATTR text modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(32,$theme->url(,true)) modules/comment/views/admin_block_recent_comments.html.php 10 DIRTY gallery::date_time($comment->created) modules/comment/views/admin_comments.html.php 5 DIRTY $form -modules/comment/views/admin_manage_comments.html.php 43 DIRTY $menu->render() -modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR $comment->id -modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR text::alternate("g-odd","g-even") -modules/comment/views/admin_manage_comments.html.php 110 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) -modules/comment/views/admin_manage_comments.html.php 123 DIRTY_JS $item->url() -modules/comment/views/admin_manage_comments.html.php 125 DIRTY_ATTR $item->thumb_url() -modules/comment/views/admin_manage_comments.html.php 127 DIRTY photo::img_dimensions($item->thumb_width,$item->thumb_height,75) -modules/comment/views/admin_manage_comments.html.php 135 DIRTY gallery::date($comment->created) -modules/comment/views/admin_manage_comments.html.php 142 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 151 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 160 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 169 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 176 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 184 DIRTY_JS $comment->id -modules/comment/views/admin_manage_comments.html.php 197 DIRTY $pager +modules/comment/views/admin_manage_comments.html.php 45 DIRTY $menu->render() +modules/comment/views/admin_manage_comments_queue.html.php 40 DIRTY $theme->paginator() +modules/comment/views/admin_manage_comments_queue.html.php 55 DIRTY_ATTR $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 55 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/comment/views/admin_manage_comments_queue.html.php 58 DIRTY_ATTR $comment->author()->avatar_url(40,$fallback_avatar_url) +modules/comment/views/admin_manage_comments_queue.html.php 75 DIRTY_JS $item->url() +modules/comment/views/admin_manage_comments_queue.html.php 77 DIRTY_ATTR $item->thumb_url() +modules/comment/views/admin_manage_comments_queue.html.php 79 DIRTY photo::img_dimensions($item->thumb_width,$item->thumb_height,75) +modules/comment/views/admin_manage_comments_queue.html.php 87 DIRTY gallery::date($comment->created) +modules/comment/views/admin_manage_comments_queue.html.php 94 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 103 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 116 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 125 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 132 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 141 DIRTY_JS $comment->id +modules/comment/views/admin_manage_comments_queue.html.php 155 DIRTY $theme->paginator() modules/comment/views/comment.html.php 2 DIRTY_ATTR $comment->id; modules/comment/views/comment.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true)) modules/comment/views/comment.mrss.php 10 DIRTY $feed->uri @@ -367,7 +368,7 @@ modules/user/views/admin_users.html.php 73 DIRTY_ATTR $use modules/user/views/admin_users.html.php 74 DIRTY_ATTR $user->avatar_url(20,$theme->url(,true)) modules/user/views/admin_users.html.php 88 DIRTY ($user->last_login==0)?"":gallery::date($user->last_login) modules/user/views/admin_users.html.php 91 DIRTY db::build()->from("items")->where("owner_id","=",$user->id)->count_records() -modules/user/views/admin_users.html.php 113 DIRTY $pager +modules/user/views/admin_users.html.php 113 DIRTY $theme->paginator() modules/user/views/admin_users.html.php 132 DIRTY_ATTR $group->id modules/user/views/admin_users.html.php 132 DIRTY_ATTR ($group->special?"g-default-group":"") modules/user/views/admin_users.html.php 134 DIRTY $v @@ -378,31 +379,30 @@ modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $wid modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url themes/admin_wind/views/admin.html.php 4 DIRTY $theme->html_attributes() -themes/admin_wind/views/admin.html.php 33 DIRTY $theme->admin_head() -themes/admin_wind/views/admin.html.php 42 DIRTY_JS $theme->url() -themes/admin_wind/views/admin.html.php 47 DIRTY $theme->get_combined("css") -themes/admin_wind/views/admin.html.php 50 DIRTY $theme->get_combined("script") -themes/admin_wind/views/admin.html.php 54 DIRTY $theme->admin_page_top() -themes/admin_wind/views/admin.html.php 62 DIRTY $theme->admin_header_top() -themes/admin_wind/views/admin.html.php 63 DIRTY_JS item::root()->url() -themes/admin_wind/views/admin.html.php 66 DIRTY $theme->user_menu() -themes/admin_wind/views/admin.html.php 69 DIRTY $theme->admin_menu() -themes/admin_wind/views/admin.html.php 72 DIRTY $theme->admin_header_bottom() -themes/admin_wind/views/admin.html.php 79 DIRTY $content -themes/admin_wind/views/admin.html.php 85 DIRTY $sidebar -themes/admin_wind/views/admin.html.php 90 DIRTY $theme->admin_footer() -themes/admin_wind/views/admin.html.php 93 DIRTY $theme->admin_credits() -themes/admin_wind/views/admin.html.php 98 DIRTY $theme->admin_page_bottom() +themes/admin_wind/views/admin.html.php 34 DIRTY $theme->admin_head() +themes/admin_wind/views/admin.html.php 46 DIRTY_JS $theme->url() +themes/admin_wind/views/admin.html.php 51 DIRTY $theme->get_combined("css") +themes/admin_wind/views/admin.html.php 54 DIRTY $theme->get_combined("script") +themes/admin_wind/views/admin.html.php 58 DIRTY $theme->admin_page_top() +themes/admin_wind/views/admin.html.php 66 DIRTY $theme->admin_header_top() +themes/admin_wind/views/admin.html.php 67 DIRTY_JS item::root()->url() +themes/admin_wind/views/admin.html.php 70 DIRTY $theme->user_menu() +themes/admin_wind/views/admin.html.php 73 DIRTY $theme->admin_menu() +themes/admin_wind/views/admin.html.php 76 DIRTY $theme->admin_header_bottom() +themes/admin_wind/views/admin.html.php 83 DIRTY $content +themes/admin_wind/views/admin.html.php 89 DIRTY $sidebar +themes/admin_wind/views/admin.html.php 94 DIRTY $theme->admin_footer() +themes/admin_wind/views/admin.html.php 97 DIRTY $theme->admin_credits() +themes/admin_wind/views/admin.html.php 102 DIRTY $theme->admin_page_bottom() themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor themes/admin_wind/views/block.html.php 5 DIRTY $id themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id themes/admin_wind/views/block.html.php 13 DIRTY $title themes/admin_wind/views/block.html.php 16 DIRTY $content -themes/admin_wind/views/pager.html.php 13 DIRTY_JS str_replace('{page}',1,$url) -themes/admin_wind/views/pager.html.php 20 DIRTY_JS str_replace('{page}',$previous_page,$url) -themes/admin_wind/views/pager.html.php 27 DIRTY $from_to_msg -themes/admin_wind/views/pager.html.php 30 DIRTY_JS str_replace('{page}',$next_page,$url) -themes/admin_wind/views/pager.html.php 37 DIRTY_JS str_replace('{page}',$last_page,$url) +themes/admin_wind/views/paginator.html.php 35 DIRTY_JS $first_page_url +themes/admin_wind/views/paginator.html.php 44 DIRTY_JS $previous_page_url +themes/admin_wind/views/paginator.html.php 70 DIRTY_JS $next_page_url +themes/admin_wind/views/paginator.html.php 79 DIRTY_JS $last_page_url themes/wind/views/album.html.php 16 DIRTY_ATTR $child->id themes/wind/views/album.html.php 16 DIRTY_ATTR $item_class themes/wind/views/album.html.php 18 DIRTY_JS $child->url() @@ -430,16 +430,16 @@ themes/wind/views/page.html.php 17 DIRTY item:: themes/wind/views/page.html.php 32 DIRTY $new_width themes/wind/views/page.html.php 33 DIRTY $new_height themes/wind/views/page.html.php 34 DIRTY $thumb_proportion -themes/wind/views/page.html.php 71 DIRTY_JS $theme->url() -themes/wind/views/page.html.php 76 DIRTY $theme->get_combined("css") -themes/wind/views/page.html.php 79 DIRTY $theme->get_combined("script") -themes/wind/views/page.html.php 89 DIRTY $header_text -themes/wind/views/page.html.php 91 DIRTY_JS item::root()->url() -themes/wind/views/page.html.php 95 DIRTY $theme->user_menu() -themes/wind/views/page.html.php 116 DIRTY_JS $parent->url($parent->id==$theme->item()->parent_id?"show={$theme->item()->id}":null) -themes/wind/views/page.html.php 137 DIRTY $content -themes/wind/views/page.html.php 143 DIRTY newView("sidebar.html") -themes/wind/views/page.html.php 150 DIRTY $footer_text +themes/wind/views/page.html.php 74 DIRTY_JS $theme->url() +themes/wind/views/page.html.php 79 DIRTY $theme->get_combined("css") +themes/wind/views/page.html.php 82 DIRTY $theme->get_combined("script") +themes/wind/views/page.html.php 92 DIRTY $header_text +themes/wind/views/page.html.php 94 DIRTY_JS item::root()->url() +themes/wind/views/page.html.php 98 DIRTY $theme->user_menu() +themes/wind/views/page.html.php 119 DIRTY_JS $parent->url($parent->id==$theme->item()->parent_id?"show={$theme->item()->id}":null) +themes/wind/views/page.html.php 140 DIRTY $content +themes/wind/views/page.html.php 146 DIRTY newView("sidebar.html") +themes/wind/views/page.html.php 153 DIRTY $footer_text themes/wind/views/paginator.html.php 33 DIRTY_JS $first_page_url themes/wind/views/paginator.html.php 42 DIRTY_JS $previous_page_url themes/wind/views/paginator.html.php 70 DIRTY_JS $next_page_url -- cgit v1.2.3 From 44247fb2d1698286e558cd6f5ee5bb87a8612f9b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 May 2011 20:37:51 -0700 Subject: Allow password reset even when we're in maintenance or private gallery mode, otherwise you can't reset your password if you forgot it when the Gallery is locked down. #1735. --- modules/user/controllers/password.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules') diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php index cd46bbed..ab31c6b4 100644 --- a/modules/user/controllers/password.php +++ b/modules/user/controllers/password.php @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Password_Controller extends Controller { + const ALLOW_MAINTENANCE_MODE = true; + const ALLOW_PRIVATE_GALLERY = true; + public function reset() { $form = self::_reset_form(); if (request::method() == "post") { -- cgit v1.2.3 From 5e6a6d58c2946caf54af9bb4b67f6f9a12d7449f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 May 2011 20:48:23 -0700 Subject: Follow on to c101151616033d53587d1435881dae0fa45aeefa -- delete all tags in setup so that we have a blank slate, otherwise create_tag() will fail because sometimes there'll be other tags in the system. #1628 --- modules/tag/tests/Tag_Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/tag/tests/Tag_Test.php b/modules/tag/tests/Tag_Test.php index 9e10fa4a..52fd4fdd 100644 --- a/modules/tag/tests/Tag_Test.php +++ b/modules/tag/tests/Tag_Test.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Tag_Test extends Gallery_Unit_Test_Case { - public function teardown() { + public function setup() { ORM::factory("tag")->delete_all(); } -- cgit v1.2.3 From 61691fdf713950f704427640bc30776990768d98 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 5 Jun 2011 17:16:07 -0700 Subject: Use the strict form of mb_detect_encoding for best results. Thanks to guthy in https://github.com/gallery/gallery3/commit/fa6f233603267505c216abc4f12663d245cd23e7#commitcomment-403145 Fixes #1745. --- modules/gallery/helpers/encoding.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/encoding.php b/modules/gallery/helpers/encoding.php index c5928634..7d5add34 100644 --- a/modules/gallery/helpers/encoding.php +++ b/modules/gallery/helpers/encoding.php @@ -19,13 +19,16 @@ */ class encoding_Core { static function convert_to_utf8($value) { - if (function_exists("mb_detect_encoding") && - function_exists("mb_convert_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value)); - } else if (function_exists("mb_detect_encoding") && - mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") { - $value = utf8_encode($value); + if (function_exists("mb_detect_encoding")) { + // Rely on mb_detect_encoding()'s strict mode + $src_encoding = mb_detect_encoding($value, mb_detect_order(), true); + if ($src_encoding != "UTF-8") { + if (function_exists("mb_convert_encoding") && $src_encoding) { + $value = mb_convert_encoding($value, "UTF-8", $src_encoding); + } else { + $value = utf8_encode($value); + } + } } return $value; } -- cgit v1.2.3 From c76c4e654880a6e03d70522ed8427154d53c1590 Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 15 Jun 2011 20:15:20 -0600 Subject: Refer to "rules" not "filters" --- modules/gallery/helpers/graphics.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 3b9769de..39c87fbd 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -174,8 +174,8 @@ class graphics_Core { call_user_func_array($rule->operation, $args); $working_file = $output_file; } catch (Exception $e) { - // Ignore this filter and move on. - Kohana_Log::add("error", "Caught exception filtering image: {$item->title}\n" . + // Ignore this rule and move on. + Kohana_Log::add("error", "Caught exception processing image: {$item->title}\n" . $e->getMessage() . "\n" . $e->getTraceAsString()); } } -- cgit v1.2.3 From 20d7bfd6b904053c2bc27b69d32c71a321e0dae9 Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 15 Jun 2011 20:21:06 -0600 Subject: Write more PHP docs --- modules/gallery/helpers/legal_file.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php index 0d3e9728..d78efdda 100644 --- a/modules/gallery/helpers/legal_file.php +++ b/modules/gallery/helpers/legal_file.php @@ -18,22 +18,29 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class legal_file_Core { + /** + * Create a default list of allowed photo extensions and then let modules modify it. + */ static function get_photo_extensions() { - // Create a default list of allowed extensions and then let modules modify it. $extensions_wrapper = new stdClass(); $extensions_wrapper->extensions = array("gif", "jpg", "jpeg", "png"); module::event("legal_photo_extensions", $extensions_wrapper); return $extensions_wrapper->extensions; } + /** + * Create a default list of allowed movie extensions and then let modules modify it. + */ static function get_movie_extensions() { - // Create a default list of allowed extensions and then let modules modify it. $extensions_wrapper = new stdClass(); $extensions_wrapper->extensions = array("flv", "mp4", "m4v"); module::event("legal_movie_extensions", $extensions_wrapper); return $extensions_wrapper->extensions; } + /** + * Create a merged list of all allowed photo and movie extensions. + */ static function get_extensions() { $extensions = legal_file::get_photo_extensions(); if (movie::find_ffmpeg()) { @@ -42,6 +49,10 @@ class legal_file_Core { return $extensions; } + /** + * Create a merged list of all photo and movie filename filters, + * (e.g. "*.gif"), based on allowed extensions. + */ static function get_filters() { $filters = array(); foreach (legal_file::get_extensions() as $extension) { @@ -50,16 +61,20 @@ class legal_file_Core { return $filters; } + /** + * Create a default list of allowed photo MIME types and then let modules modify it. + */ static function get_photo_types() { - // Create a default list of allowed types and then let modules modify it. $types_wrapper = new stdClass(); $types_wrapper->types = array("image/jpeg", "image/gif", "image/png"); module::event("legal_photo_types", $types_wrapper); return $types_wrapper->types; } + /** + * Create a default list of allowed movie MIME types and then let modules modify it. + */ static function get_movie_types() { - // Create a default list of allowed types and then let modules modify it. $types_wrapper = new stdClass(); $types_wrapper->types = array("video/flv", "video/x-flv", "video/mp4"); module::event("legal_movie_types", $types_wrapper); -- cgit v1.2.3 From 142088a6353dfd051e0dc72e1e30fa51fb6d7f2b Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Wed, 15 Jun 2011 20:46:23 -0600 Subject: Gracefully handle rule failures with a broken image icon. This will be especially useful as third-party modules start supporting a larger variety of image types, and as errors creep into their image processing. --- modules/gallery/helpers/graphics.php | 22 ++++++++++++++++++---- modules/gallery/images/missing_photo.png | Bin 0 -> 1570 bytes 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 modules/gallery/images/missing_photo.png (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index acb11bfb..39c87fbd 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -170,23 +170,37 @@ class graphics_Core { foreach (self::_get_rules($target) as $rule) { $args = array($working_file, $output_file, unserialize($rule->args), $item); - call_user_func_array($rule->operation, $args); - $working_file = $output_file; + try { + call_user_func_array($rule->operation, $args); + $working_file = $output_file; + } catch (Exception $e) { + // Ignore this rule and move on. + Kohana_Log::add("error", "Caught exception processing image: {$item->title}\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + } } } if (!empty($ops["thumb"])) { + if (file_exists($item->thumb_path())) { + $item->thumb_dirty = 0; + } else { + copy(MODPATH . "gallery/images/missing_photo.png", $item->thumb_path()); + } $dims = getimagesize($item->thumb_path()); $item->thumb_width = $dims[0]; $item->thumb_height = $dims[1]; - $item->thumb_dirty = 0; } if (!empty($ops["resize"])) { + if (file_exists($item->resize_path())) { + $item->resize_dirty = 0; + } else { + copy(MODPATH . "gallery/images/missing_photo.png", $item->resize_path()); + } $dims = getimagesize($item->resize_path()); $item->resize_width = $dims[0]; $item->resize_height = $dims[1]; - $item->resize_dirty = 0; } $item->save(); } catch (Exception $e) { diff --git a/modules/gallery/images/missing_photo.png b/modules/gallery/images/missing_photo.png new file mode 100644 index 00000000..67786275 Binary files /dev/null and b/modules/gallery/images/missing_photo.png differ -- cgit v1.2.3 From 44b624f6fbc34cbc638afa1c2a1f6cb0ae154a03 Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Thu, 21 Jul 2011 00:11:52 -0600 Subject: Squashed commit of the following: commit 41d379c2b777ae7b3a11f528971228e234f8976f Author: Chad Parry Date: Thu Jul 21 00:10:10 2011 -0600 Replace an overly-complicated regular expression with a simple in_array, at Bharat's suggestion. commit 1b3f7111d4c2607baaa2da0aab3b501f2d9a1426 Merge: 8f7904a 403f64b Author: Chad Parry Date: Wed Jul 20 21:02:56 2011 -0600 Merge branch 'master' into rawphoto commit 403f64bf2a91fe3ac2496a0a6a6180ece26afd82 Author: Automatic Build Number Updater Date: Tue Jul 12 21:44:14 2011 -0700 Automated update of .build_number to 163 for branch master Last update: e8382b960a3c19bb28140833e348e6c9c9db8a8a (1 commits ago) commit 51726f9e4b8372c40b27f843fca7b783e6db9623 Author: Tim Almdal Date: Tue Jul 12 21:44:40 2011 -0700 Fix for ticket #1752. Add an RSS field link for the current album. Or, in the case of a photo or movie, add a link to the rss field of the parent album. commit e8382b960a3c19bb28140833e348e6c9c9db8a8a Author: Automatic Build Number Updater Date: Mon Jun 27 22:27:04 2011 -0700 Automated update of .build_number to 162 for branch master Last update: 40cda7fa3fa8d9ede1f24bfa8460aab1ac681c34 (1 commits ago) commit 1afbcafe0e556ac571a5282f8b481fb90f5fb05a Merge: 40cda7f fc6c139 Author: Bharat Mediratta Date: Mon Jun 27 22:26:41 2011 -0700 Merge pull request #56 from alindeman/alindeman/1758 [Fixes #1758] Link to themes codex page instead of modules codex page commit 40cda7fa3fa8d9ede1f24bfa8460aab1ac681c34 Author: Automatic Build Number Updater Date: Mon Jun 27 22:25:54 2011 -0700 Automated update of .build_number to 161 for branch master Last update: 771de0a3746ac0d780cb5dce2a14aa5a6ddf06d7 (1 commits ago) commit aa08df7f0a839c95d268853cd745f622c98cadd0 Merge: 771de0a 784c429 Author: Bharat Mediratta Date: Mon Jun 27 22:25:46 2011 -0700 Merge pull request #55 from alindeman/alindeman/1757 [Fixes #1757] Redirect to root album if path comes in as main.php or index.php commit fc6c1390d3d5f3d99d75b04acf208ae3729c11ce Author: Andy Lindeman Date: Mon Jun 27 08:25:50 2011 -0400 [Fixes #1758] Link to themes codex page instead of modules codex page commit 784c429070db54e183feb3e0ea6f2726b6507081 Author: Andy Lindeman Date: Mon Jun 27 07:24:37 2011 -0400 [Fixes #1757] Redirect to root album if path comes in as main.php or index.php commit 8f7904ab62c71a7e4ee68762f936030b4dcb4ea1 Merge: e950573 771de0a Author: Chad Parry Date: Sat Jun 25 14:12:39 2011 -0600 Merge branches 'master' and 'rawphoto' into rawphoto commit e95057337996351e49915d9f85d007d50103a4be Author: Chad Parry Date: Wed Jun 15 20:24:18 2011 -0600 Merge branches 'rawphoto-squash' and 'rawphoto' into rawphoto --- .build_number | 2 +- modules/g2_import/controllers/g2.php | 2 +- modules/gallery/helpers/gallery_rss.php | 8 ++++++++ modules/gallery/models/item.php | 8 ++------ modules/gallery/views/admin_themes.html.php | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/.build_number b/.build_number index e627526e..a10819e7 100644 --- a/.build_number +++ b/.build_number @@ -3,4 +3,4 @@ ; process. You don't need to edit it. In fact.. ; ; DO NOT EDIT THIS FILE BY HAND! -build_number=160 +build_number=163 diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php index 90984e84..1252014f 100644 --- a/modules/g2_import/controllers/g2.php +++ b/modules/g2_import/controllers/g2.php @@ -34,7 +34,7 @@ class G2_Controller extends Controller { $path = $input->get("path"); $id = $input->get("g2_itemId"); - if ($path || $id) { + if (($path && $path != 'index.php' && $path != 'main.php') || $id) { if ($id) { // Requests by id are either core.DownloadItem or core.ShowItem requests. Later versions of // Gallery 2 don't specify g2_view if it's the default (core.ShowItem). And in some cases diff --git a/modules/gallery/helpers/gallery_rss.php b/modules/gallery/helpers/gallery_rss.php index 612872e6..9af67118 100644 --- a/modules/gallery/helpers/gallery_rss.php +++ b/modules/gallery/helpers/gallery_rss.php @@ -21,6 +21,14 @@ class gallery_rss_Core { static function available_feeds($item, $tag) { $feeds["gallery/latest"] = t("Latest photos and movies"); + + if ($item) { + $feed_item = $item -> is_album() ? $item : $item->parent(); + + $feeds["gallery/album/{$feed_item->id}"] = + t("%title photos and movies", array("title" => $feed_item->title)); + } + return $feeds; } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 1dd9b00b..cccb7074 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -805,13 +805,9 @@ class Item_Model_Core extends ORM_MPTT { } if ($this->is_photo() && - !preg_match("/^(" . - implode("|", array_map("preg_quote", legal_file::get_photo_extensions())) . - ")\$/i", $ext) || + !in_array(strtolower($ext), array_map("strtolower", legal_file::get_photo_extensions())) || $this->is_movie() && - !preg_match("/^(" . - implode("|", array_map("preg_quote", legal_file::get_movie_extensions())) . - ")\$/i", $ext)) { + !in_array(strtolower($ext), array_map("strtolower", legal_file::get_movie_extensions()))) { $v->add_error("name", "illegal_data_file_extension"); } } diff --git a/modules/gallery/views/admin_themes.html.php b/modules/gallery/views/admin_themes.html.php index 7d947b28..9d53779f 100644 --- a/modules/gallery/views/admin_themes.html.php +++ b/modules/gallery/views/admin_themes.html.php @@ -48,7 +48,7 @@

            - Download one now!", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Modules")) ?> + Download one now!", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?>

            @@ -88,7 +88,7 @@

            - Download one now!", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Modules")) ?> + Download one now!", array("url" => "http://codex.gallery2.org/Category:Gallery_3:Themes")) ?>

      -- cgit v1.2.3 From 0672c8f83f068c546454bacefac123b5acb508cc Mon Sep 17 00:00:00 2001 From: Chad Parry Date: Thu, 21 Jul 2011 01:12:26 -0600 Subject: Polishing the rawphoto changes, including adding some tests. Squashed commit of the following: commit 945316a8c220b12adb687c896bcc5e86f99f46a4 Author: Chad Parry Date: Thu Jul 21 01:11:13 2011 -0600 Add a test for the sunny-day scenario where a rule changes a data file's MIME type. commit 4ee1ee000c8f4d8ebaae66f637bc71080486fd73 Author: Chad Parry Date: Thu Jul 21 00:49:47 2011 -0600 Ensure that a third-party cannot swap out a legitimate photo with an unsafe file type. commit 7dd0105bfc59c150e5640e693778f51bbaa44eab Author: Chad Parry Date: Thu Jul 21 00:48:19 2011 -0600 Update the MIME type and other meta-data when a new data file is provided. commit 5a8844c7947b21cf658f22cc61f20ffa9e8f07f2 Author: Chad Parry Date: Thu Jul 21 00:30:01 2011 -0600 Remove a unit test that no longer applies. Replacement data files are allowed to have different MIME types. commit 0de9c6283ce4f5773cad8e92b6785d6a1f7b5e46 Author: Chad Parry Date: Thu Jul 21 00:27:45 2011 -0600 If one rule fails, then abort processing, rather than trying to proceed to subsequent rules. commit 41d379c2b777ae7b3a11f528971228e234f8976f Author: Chad Parry Date: Thu Jul 21 00:10:10 2011 -0600 Replace an overly-complicated regular expression with a simple in_array, at Bharat's suggestion. commit 1b3f7111d4c2607baaa2da0aab3b501f2d9a1426 Merge: 8f7904a 403f64b Author: Chad Parry Date: Wed Jul 20 21:02:56 2011 -0600 Merge branch 'master' into rawphoto commit 8f7904ab62c71a7e4ee68762f936030b4dcb4ea1 Merge: e950573 771de0a Author: Chad Parry Date: Sat Jun 25 14:12:39 2011 -0600 Merge branches 'master' and 'rawphoto' into rawphoto commit e95057337996351e49915d9f85d007d50103a4be Author: Chad Parry Date: Wed Jun 15 20:24:18 2011 -0600 Merge branches 'rawphoto-squash' and 'rawphoto' into rawphoto --- modules/gallery/helpers/graphics.php | 10 ++-------- modules/gallery/models/item.php | 7 +++++++ modules/gallery/tests/Item_Model_Test.php | 23 +++++++++++++++++++++-- 3 files changed, 30 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 39c87fbd..3548faa1 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -170,14 +170,8 @@ class graphics_Core { foreach (self::_get_rules($target) as $rule) { $args = array($working_file, $output_file, unserialize($rule->args), $item); - try { - call_user_func_array($rule->operation, $args); - $working_file = $output_file; - } catch (Exception $e) { - // Ignore this rule and move on. - Kohana_Log::add("error", "Caught exception processing image: {$item->title}\n" . - $e->getMessage() . "\n" . $e->getTraceAsString()); - } + call_user_func_array($rule->operation, $args); + $working_file = $output_file; } } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index cccb7074..93e97af6 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -420,6 +420,13 @@ class Item_Model_Core extends ORM_MPTT { if (!empty($extension) && strcmp($this->name, $new_name)) { $this->name = $new_name; } + if ($this->is_photo()) { + list ($this->width, $this->height, $this->mime_type, $extension) = + photo::get_file_metadata($this->data_file); + } else if ($this->is_movie()) { + list ($this->width, $this->height, $this->mime_type, $extension) = + movie::get_file_metadata($this->data_file); + } } if (array_intersect($this->changed, array("parent_id", "name", "slug"))) { diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 968d7510..19ab8ec4 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -394,15 +394,34 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $this->assert_equal(20337, filesize($photo->file_path())); } - public function replacement_data_file_must_be_same_mime_type_test() { + public function replace_data_file_type_test() { // Random photo is modules/gallery/tests/test.jpg $photo = test::random_photo(); + $this->assert_equal(1024, $photo->width); + $this->assert_equal(768, $photo->height); + $this->assert_equal(6232, filesize($photo->file_path())); + $this->assert_equal("image/jpeg", $photo->mime_type); + $orig_name = $photo->name; + + // Random photo is gallery/images/graphicsmagick.png is 104x76 and 1486 bytes $photo->set_data_file(MODPATH . "gallery/images/graphicsmagick.png"); + $photo->save(); + + $this->assert_equal(104, $photo->width); + $this->assert_equal(76, $photo->height); + $this->assert_equal(1486, filesize($photo->file_path())); + $this->assert_equal("image/png", $photo->mime_type); + $this->assert_equal("png", pathinfo($photo->name, PATHINFO_EXTENSION)); + $this->assert_equal(pathinfo($orig_name, PATHINFO_FILENAME), pathinfo($photo->name, PATHINFO_FILENAME)); + } + public function unsafe_data_file_replacement_test() { try { + $photo = test::random_photo(); + $photo->set_data_file(MODPATH . "gallery/tests/Item_Model_Test.php"); $photo->save(); } catch (ORM_Validation_Exception $e) { - $this->assert_same(array("name" => "cant_change_mime_type"), $e->validation->errors()); + $this->assert_same(array("mime_type" => "invalid"), $e->validation->errors()); return; // pass } $this->assert_true(false, "Shouldn't get here"); -- cgit v1.2.3 From 458c6316e7810cb430b5e00b22808175f3134bc2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 24 Jul 2011 08:31:39 -0700 Subject: Assign copyright to Bharat Mediratta as trustee for Gallery, per https://github.com/gallery/gallery3/pull/51/files --- modules/gallery/helpers/legal_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php index d78efdda..6f66c85c 100644 --- a/modules/gallery/helpers/legal_file.php +++ b/modules/gallery/helpers/legal_file.php @@ -1,7 +1,7 @@ Date: Sun, 24 Jul 2011 08:32:14 -0700 Subject: Update golden file. --- modules/gallery/tests/xss_data.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 954caf54..df087669 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -184,6 +184,7 @@ modules/gallery/views/form_uploadify.html.php 16 DIRTY_JS url::s modules/gallery/views/form_uploadify.html.php 24 DIRTY_JS $flash_minimum_version modules/gallery/views/form_uploadify.html.php 28 DIRTY_JS url::file("lib/uploadify/uploadify.swf") modules/gallery/views/form_uploadify.html.php 29 DIRTY_JS url::site("uploader/add_photo/{$album->id}") +modules/gallery/views/form_uploadify.html.php 31 DIRTY_JS implode(";",$extensions) modules/gallery/views/form_uploadify.html.php 33 DIRTY_JS url::file("lib/uploadify/cancel.png") modules/gallery/views/form_uploadify.html.php 34 DIRTY_JS $simultaneous_upload_limit modules/gallery/views/form_uploadify.html.php 35 DIRTY_JS $size_limit_bytes -- cgit v1.2.3 From de1b4082cd99337242287889e56edc15a9fe9cda Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 24 Jul 2011 17:11:04 -0700 Subject: Patch for ticket #1763. Where offset could be converted to a null string. It's not really a problem in the current release, but will cause isses when we serialize the offset as part of the display context. --- modules/search/helpers/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index bbde8feb..a3fd795a 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -54,7 +54,7 @@ class search_Core { "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . $access_sql . "ORDER BY `score` DESC " . - "LIMIT $limit OFFSET $offset"; + "LIMIT $limit OFFSET " . (int)$offset; $data = $db->query($query); $count = $db->query("SELECT FOUND_ROWS() as c")->current()->c; -- cgit v1.2.3 From 7f8056b593d04a9abd070399c0d4d176c650a309 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 4 Aug 2011 19:44:19 -0700 Subject: fix for ticket #1759. correct parameter names to match usage. --- modules/gallery/libraries/IdentityProvider.php | 12 ++++++------ modules/user/libraries/drivers/IdentityProvider/Gallery.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php index 153446e6..3f995923 100644 --- a/modules/gallery/libraries/IdentityProvider.php +++ b/modules/gallery/libraries/IdentityProvider.php @@ -110,11 +110,11 @@ class IdentityProvider_Core { Kohana_Log::add("error", "Error restoring original identity provider\n" . $e2->getMessage() . "\n" . $e2->getTraceAsString()); } - + message::error( t("Error attempting to enable \"%new_provider\" identity provider, reverted to \"%old_provider\" identity provider", array("new_provider" => $new_provider, "old_provider" => $current_provider))); - + $restore_already_running = false; } throw $e; @@ -260,14 +260,14 @@ class IdentityProvider_Core { /** * @see IdentityProvider_Driver::add_user_to_group. */ - public function add_user_to_group($user, $group_id) { - return $this->driver->add_user_to_group($user, $group_id); + public function add_user_to_group($user, $group) { + return $this->driver->add_user_to_group($user, $group); } /** * @see IdentityProvider_Driver::remove_user_to_group. */ - public function remove_user_from_group($user, $group_id) { - return $this->driver->remove_user_from_group($user, $group_id); + public function remove_user_from_group($user, $group) { + return $this->driver->remove_user_from_group($user, $group); } } // End Identity diff --git a/modules/user/libraries/drivers/IdentityProvider/Gallery.php b/modules/user/libraries/drivers/IdentityProvider/Gallery.php index 8cba3c82..79d31f7c 100644 --- a/modules/user/libraries/drivers/IdentityProvider/Gallery.php +++ b/modules/user/libraries/drivers/IdentityProvider/Gallery.php @@ -156,7 +156,7 @@ class IdentityProvider_Gallery_Driver implements IdentityProvider_Driver { /** * @see IdentityProvider_Driver::remove_user_to_group. */ - public function remove_user_from_group($user, $group_id) { + public function remove_user_from_group($user, $group) { $group->remove($user); $group->save(); } -- cgit v1.2.3 From 11c76572f0875e69f513e236a4c65e2d103d56c4 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 4 Aug 2011 20:29:06 -0700 Subject: Patch for ticket #1769. Remove the rows in groups_users when the user or the group is deleted. --- modules/user/models/group.php | 6 ++++++ modules/user/models/user.php | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'modules') diff --git a/modules/user/models/group.php b/modules/user/models/group.php index 4409dcb8..46642203 100644 --- a/modules/user/models/group.php +++ b/modules/user/models/group.php @@ -28,6 +28,12 @@ class Group_Model_Core extends ORM implements Group_Definition { $old = clone $this; module::event("group_before_delete", $this); parent::delete($id); + + db::build() + ->delete("groups_users") + ->where("group_id", "=", empty($id) ? $old->id : $id) + ->execute(); + module::event("group_deleted", $old); $this->users_cache = null; } diff --git a/modules/user/models/user.php b/modules/user/models/user.php index a8a3a0e7..8fe0a87b 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -43,6 +43,12 @@ class User_Model_Core extends ORM implements User_Definition { $old = clone $this; module::event("user_before_delete", $this); parent::delete($id); + + db::build() + ->delete("groups_users") + ->where("user_id", "=", empty($id) ? $old->id : $id) + ->execute(); + module::event("user_deleted", $old); $this->groups_cache = null; } -- cgit v1.2.3 From e736d98eaa37df24122c746c21c473f0988d58f2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 4 Aug 2011 21:00:21 -0700 Subject: Patch for ticket #1765. Provide the full site url for the the gallery link instead of trying to use url_base for the hidden link and the presentation text. --- modules/user/views/reset_password.html.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/user/views/reset_password.html.php b/modules/user/views/reset_password.html.php index 3afca881..d939ad42 100644 --- a/modules/user/views/reset_password.html.php +++ b/modules/user/views/reset_password.html.php @@ -9,8 +9,9 @@ $user->full_name ? $user->full_name : $user->name)) ?>

      - %site_url. If you made this request, you can confirm it by clicking this link. If you didn't request this password reset, it's ok to ignore this mail.", - array("site_url" => html::mark_clean(url::base(false, "http")), + %base_url. If you made this request, you can confirm it by clicking this link. If you didn't request this password reset, it's ok to ignore this mail.", + array("site_url" => html::mark_clean(url::abs_site("/")), + "base_url" => html::mark_clean(url::base(false)), "confirm_url" => $confirm_url)) ?>

      -- cgit v1.2.3 From dd0b622ae9e269e828699928fa8bddcd17d66225 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 7 Aug 2011 13:27:27 -0700 Subject: Initial commit of a patch for Ticket #1764. as discussed here: https://github.com/gallery/gallery3/pull/58/files#r72949. Create a Breadcrumb library which has two static methods for_item (which takes a an item and builds the entire breadcrumb for the item) or build (which takes a variable number of Breadcrumb elements and creates a breadcrumb based on the specified elements). Used tag->url() to build the tag album url. Escaped the query string for the search. Tightened up the breadcrumb code in page.html.php. When adding the show query parameter, we can't blindly concatenate using the ? separator. We have to check that we use a & if a query parameter already exists. --- modules/gallery/controllers/albums.php | 1 + modules/gallery/controllers/movies.php | 1 + modules/gallery/controllers/photos.php | 1 + modules/gallery/libraries/Breadcrumb.php | 74 +++++++++++++++++++++++++++++++ modules/gallery/tests/Breadcrumb_Test.php | 51 +++++++++++++++++++++ modules/search/controllers/search.php | 5 +++ modules/tag/controllers/tag.php | 3 ++ themes/wind/views/page.html.php | 27 +++-------- 8 files changed, 143 insertions(+), 20 deletions(-) create mode 100644 modules/gallery/libraries/Breadcrumb.php create mode 100644 modules/gallery/tests/Breadcrumb_Test.php (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index ccf6c1cb..90071fb5 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -69,6 +69,7 @@ class Albums_Controller extends Items_Controller { "item" => $album, "children" => $album->viewable()->children($page_size, $offset), "parents" => $album->parents()->as_array(), // view calls empty() on this + "breadcrumbs" => Breadcrumb::build_from_item($album), "children_count" => $children_count)); $template->content = new View("album.html"); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 8e81c594..77d92e13 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -43,6 +43,7 @@ class Movies_Controller extends Items_Controller { "children" => array(), "children_count" => 0, "parents" => $movie->parents()->as_array(), + "breadcrumbs" => Breadcrumb::build_from_item($movie), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $movie->parent()->viewable()->children_count($where), diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 054300a1..5c8c7b34 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -43,6 +43,7 @@ class Photos_Controller extends Items_Controller { "children" => array(), "children_count" => 0, "parents" => $photo->parents()->as_array(), + "breadcrumbs" => Breadcrumb::build_from_item($photo), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $photo->parent()->viewable()->children_count($where), diff --git a/modules/gallery/libraries/Breadcrumb.php b/modules/gallery/libraries/Breadcrumb.php new file mode 100644 index 00000000..3a2499ba --- /dev/null +++ b/modules/gallery/libraries/Breadcrumb.php @@ -0,0 +1,74 @@ +parents() as $element) { + $breadcrumbs[] = new Breadcrumb($element->title, $element->url(), $element->id); + } + + if (!empty($breadcrumbs)) { + $breadcrumbs[] = new Breadcrumb($item->title, $item->url(), $item->id); + } + + return self::generate_show_query_strings($breadcrumbs); + } + + /** + * This static function takes a list (variable arguments) of Breadcrumbs and builds a dynamic + * breadcrumb list. Used to create a breadcrumb for dynamic albums. Will really be useful + * for the display context change. + */ + static function build_from_list() { + return self::generate_show_query_strings(func_get_args()); + } + + private static function generate_show_query_strings($breadcrumbs) { + if (!empty($breadcrumbs)) { + + end($breadcrumbs)->last = true;; + while ($breadcrumb = current($breadcrumbs)) { + if (isset($last_id) && $last_id > 0) { + $query = parse_url($breadcrumb->url, PHP_URL_QUERY); + $breadcrumb->url = $breadcrumb->url . ($query ? "&" : "?") . "show={$last_id}"; + } + $last_id = $breadcrumb->id; + $breadcrumb = prev($breadcrumbs); + } + $breadcrumbs[0]->first = true; + } + + return $breadcrumbs; + } + + public function __construct($title, $url, $id=0) { + $this->title = $title; + $this->url = $url; + $this->id = $id; + $this->first = false; + $this->last = false; + } +} diff --git a/modules/gallery/tests/Breadcrumb_Test.php b/modules/gallery/tests/Breadcrumb_Test.php new file mode 100644 index 00000000..9f9aeddc --- /dev/null +++ b/modules/gallery/tests/Breadcrumb_Test.php @@ -0,0 +1,51 @@ +album = test::random_album(); + $this->item = test::random_photo($this->album); + $this->album->reload(); + } + + public function teardown() { + $this->album = null; + $this->item = null; + } + + public function build_breadcrumbs_for_item_test() { + $breadcrumbs = Breadcrumb::build_from_item($this->item); + $this->assert_equal("Gallery", $breadcrumbs[0]->title); + $this->assert_equal($this->album->title, $breadcrumbs[1]->title); + $this->assert_equal($this->item->title, $breadcrumbs[2]->title); + } + + public function build_breadcrumbs_from_items_test() { + $breadcrumbs = Breadcrumb::build_from_list( + new Breadcrumb(item::root()->title, "/", item::root()->id), + new Breadcrumb($this->album->title, $this->album->relative_path(), $this->album->id), + new Breadcrumb($this->item->title, $this->item->relative_path(), $this->item->id)); + $this->assert_equal("Gallery", $breadcrumbs[0]->title); + $this->assert_equal($this->album->title, $breadcrumbs[1]->title); + $this->assert_equal($this->item->title, $breadcrumbs[2]->title); + } +} \ No newline at end of file diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index 261d67ee..d30ffa67 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -36,9 +36,14 @@ class Search_Controller extends Controller { $max_pages = max(ceil($count / $page_size), 1); $template = new Theme_View("page.html", "collection", "search"); + $root = item::root(); + $search_url = url::abs_site("search?q=" . urlencode($q)); $template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, + "breadcrumbs" => Breadcrumb::build_from_list( + new Breadcrumb(item::root()->title, "/", item::root()->id), + new Breadcrumb($q, $search_url)), "children_count" => $count)); $template->content = new View("search.html"); diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 8f885dea..44a171fd 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -40,6 +40,9 @@ class Tag_Controller extends Controller { "page_size" => $page_size, "tag" => $tag, "children" => $tag->items($page_size, $offset), + "breadcrumbs" => Breadcrumb::build_from_list( + new Breadcrumb(item::root()->title, "/", item::root()->id), + new Breadcrumb($tag->name, $tag->url())), "children_count" => $children_count)); $template->content = new View("dynamic.html"); $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name)); diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 045e3c45..534b7de4 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -107,28 +107,15 @@ header_bottom() ?>
    - item() && !empty($parents)): ?> + -- cgit v1.2.3 From da523de77727a3d529a88b8ca1abec5ec4d2a4cc Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 8 Aug 2011 20:28:31 -0700 Subject: Simplification of 59b04b897b8a664cd7334b017fac8158a6281434 for #1764: - Breadcrumb::build_from_item becomes Breadcrumb::array_from_item_parents - Eliminate Breadcrumb::$id -- it's no longer necessary - Fold Breadcrumb::generate_show_query_strings into Breadcrumb::array_from_item_parents - Create Breadcrumb::set_first() and Breadcrumb::set_last() - Breadcrumb::build_from_list goes away, we just use arrays for this - Change Search_Controller and Tag_Controller to just create an array of Breadcrumb instances with the first/last marked appropriately - Breadcrumb_Test loses a bunch of complexity. --- modules/gallery/controllers/albums.php | 2 +- modules/gallery/controllers/movies.php | 2 +- modules/gallery/controllers/photos.php | 2 +- modules/gallery/libraries/Breadcrumb.php | 70 +++++++++++++++---------------- modules/gallery/tests/Breadcrumb_Test.php | 33 ++++----------- modules/search/controllers/search.php | 17 ++++---- modules/tag/controllers/tag.php | 20 +++++---- 7 files changed, 65 insertions(+), 81 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 90071fb5..1c48c734 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -69,7 +69,7 @@ class Albums_Controller extends Items_Controller { "item" => $album, "children" => $album->viewable()->children($page_size, $offset), "parents" => $album->parents()->as_array(), // view calls empty() on this - "breadcrumbs" => Breadcrumb::build_from_item($album), + "breadcrumbs" => Breadcrumb::array_from_item_parents($album), "children_count" => $children_count)); $template->content = new View("album.html"); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 77d92e13..0f12c3fb 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -43,7 +43,7 @@ class Movies_Controller extends Items_Controller { "children" => array(), "children_count" => 0, "parents" => $movie->parents()->as_array(), - "breadcrumbs" => Breadcrumb::build_from_item($movie), + "breadcrumbs" => Breadcrumb::array_from_item_parents($movie), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $movie->parent()->viewable()->children_count($where), diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 5c8c7b34..af8aed16 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -43,7 +43,7 @@ class Photos_Controller extends Items_Controller { "children" => array(), "children_count" => 0, "parents" => $photo->parents()->as_array(), - "breadcrumbs" => Breadcrumb::build_from_item($photo), + "breadcrumbs" => Breadcrumb::array_from_item_parents($photo), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $photo->parent()->viewable()->children_count($where), diff --git a/modules/gallery/libraries/Breadcrumb.php b/modules/gallery/libraries/Breadcrumb.php index 3a2499ba..e151890d 100644 --- a/modules/gallery/libraries/Breadcrumb.php +++ b/modules/gallery/libraries/Breadcrumb.php @@ -20,55 +20,51 @@ class Breadcrumb_Core { public $title; public $url; - public $id; public $first; public $last; - static function build_from_item($item) { - $breadcrumbs = array(); - foreach ($item->parents() as $element) { - $breadcrumbs[] = new Breadcrumb($element->title, $element->url(), $element->id); - } - - if (!empty($breadcrumbs)) { - $breadcrumbs[] = new Breadcrumb($item->title, $item->url(), $item->id); - } + static function instance($title, $url) { + return new Breadcrumb($title, $url); + } - return self::generate_show_query_strings($breadcrumbs); + public function __construct($title, $url) { + $this->title = $title; + $this->url = $url; + $this->first = false; + $this->last = false; } /** - * This static function takes a list (variable arguments) of Breadcrumbs and builds a dynamic - * breadcrumb list. Used to create a breadcrumb for dynamic albums. Will really be useful - * for the display context change. + * Return an array of Breadcrumb instances build from the parents of a given item. + * The first and last Breadcrumb instances will be marked first/last as appropriate. + * Each breadcrumb will have a ?show= query parameter that refers to the id of the next + * item in line. + * + * @return array Breadcrumb instances */ - static function build_from_list() { - return self::generate_show_query_strings(func_get_args()); - } - - private static function generate_show_query_strings($breadcrumbs) { - if (!empty($breadcrumbs)) { + static function array_from_item_parents($item) { + if ($item->id == item::root()->id) { + return array(); + } - end($breadcrumbs)->last = true;; - while ($breadcrumb = current($breadcrumbs)) { - if (isset($last_id) && $last_id > 0) { - $query = parse_url($breadcrumb->url, PHP_URL_QUERY); - $breadcrumb->url = $breadcrumb->url . ($query ? "&" : "?") . "show={$last_id}"; - } - $last_id = $breadcrumb->id; - $breadcrumb = prev($breadcrumbs); - } - $breadcrumbs[0]->first = true; + $bc = array_merge($item->parents()->as_array(), array($item)); + for ($i = 0; $i < count($bc) - 1; $i++) { + $bc[$i] = new Breadcrumb($bc[$i]->title, $bc[$i]->url("show={$bc[$i+1]->id}")); } + $bc[$i] = new Breadcrumb($item->title, $item->url()); - return $breadcrumbs; + $bc[0]->set_first(); + end($bc)->set_last(); + return $bc; } - public function __construct($title, $url, $id=0) { - $this->title = $title; - $this->url = $url; - $this->id = $id; - $this->first = false; - $this->last = false; + public function set_first() { + $this->first = true; + return $this; + } + + public function set_last() { + $this->last = true; + return $this; } } diff --git a/modules/gallery/tests/Breadcrumb_Test.php b/modules/gallery/tests/Breadcrumb_Test.php index 9f9aeddc..ed2e5608 100644 --- a/modules/gallery/tests/Breadcrumb_Test.php +++ b/modules/gallery/tests/Breadcrumb_Test.php @@ -21,31 +21,16 @@ class Breadcrumb_Test extends Gallery_Unit_Test_Case { private $album; private $item; - public function setup() { - $this->album = test::random_album(); - $this->item = test::random_photo($this->album); - $this->album->reload(); - } - - public function teardown() { - $this->album = null; - $this->item = null; - } - public function build_breadcrumbs_for_item_test() { - $breadcrumbs = Breadcrumb::build_from_item($this->item); - $this->assert_equal("Gallery", $breadcrumbs[0]->title); - $this->assert_equal($this->album->title, $breadcrumbs[1]->title); - $this->assert_equal($this->item->title, $breadcrumbs[2]->title); - } + $album = test::random_album(); + $item = test::random_photo($album); - public function build_breadcrumbs_from_items_test() { - $breadcrumbs = Breadcrumb::build_from_list( - new Breadcrumb(item::root()->title, "/", item::root()->id), - new Breadcrumb($this->album->title, $this->album->relative_path(), $this->album->id), - new Breadcrumb($this->item->title, $this->item->relative_path(), $this->item->id)); - $this->assert_equal("Gallery", $breadcrumbs[0]->title); - $this->assert_equal($this->album->title, $breadcrumbs[1]->title); - $this->assert_equal($this->item->title, $breadcrumbs[2]->title); + $expected = array(); + $expected[] = Breadcrumb::instance( + item::root()->title, item::root()->url("show={$album->id}"))->set_first(); + $expected[] = + Breadcrumb::instance($album->title, $album->url("show={$item->id}")); + $expected[] = Breadcrumb::instance($item->title, $item->url())->set_last(); + $this->assert_equal($expected, Breadcrumb::array_from_item_parents($item)); } } \ No newline at end of file diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index d30ffa67..5db63ab0 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -37,14 +37,15 @@ class Search_Controller extends Controller { $template = new Theme_View("page.html", "collection", "search"); $root = item::root(); - $search_url = url::abs_site("search?q=" . urlencode($q)); - $template->set_global(array("page" => $page, - "max_pages" => $max_pages, - "page_size" => $page_size, - "breadcrumbs" => Breadcrumb::build_from_list( - new Breadcrumb(item::root()->title, "/", item::root()->id), - new Breadcrumb($q, $search_url)), - "children_count" => $count)); + $template->set_global( + array("page" => $page, + "max_pages" => $max_pages, + "page_size" => $page_size, + "breadcrumbs" => array( + Breadcrumb::instance($root->title, $root->url())->set_first(), + Breadcrumb::instance($q, url::abs_site("search?q=" . urlencode($q)))->set_last(), + ), + "children_count" => $count)); $template->content = new View("search.html"); $template->content->items = $result; diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 44a171fd..7786daa1 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -34,16 +34,18 @@ class Tag_Controller extends Controller { url::redirect(url::merge(array("page" => $max_pages))); } + $root = item::root(); $template = new Theme_View("page.html", "collection", "tag"); - $template->set_global(array("page" => $page, - "max_pages" => $max_pages, - "page_size" => $page_size, - "tag" => $tag, - "children" => $tag->items($page_size, $offset), - "breadcrumbs" => Breadcrumb::build_from_list( - new Breadcrumb(item::root()->title, "/", item::root()->id), - new Breadcrumb($tag->name, $tag->url())), - "children_count" => $children_count)); + $template->set_global( + array("page" => $page, + "max_pages" => $max_pages, + "page_size" => $page_size, + "tag" => $tag, + "children" => $tag->items($page_size, $offset), + "breadcrumbs" => array( + Breadcrumb::instance($root->title, $root->url())->set_first(), + Breadcrumb::instance($tag->name, $tag->url())->set_last()), + "children_count" => $children_count)); $template->content = new View("dynamic.html"); $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name)); -- cgit v1.2.3 From 66a6986d37f79d82ef56b0d666d504e0895feaaa Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 4 Aug 2011 20:29:06 -0700 Subject: Patch for ticket #1769. Remove the rows in groups_users when the user or the group is deleted. --- modules/user/models/group.php | 6 ++++++ modules/user/models/user.php | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'modules') diff --git a/modules/user/models/group.php b/modules/user/models/group.php index 4409dcb8..46642203 100644 --- a/modules/user/models/group.php +++ b/modules/user/models/group.php @@ -28,6 +28,12 @@ class Group_Model_Core extends ORM implements Group_Definition { $old = clone $this; module::event("group_before_delete", $this); parent::delete($id); + + db::build() + ->delete("groups_users") + ->where("group_id", "=", empty($id) ? $old->id : $id) + ->execute(); + module::event("group_deleted", $old); $this->users_cache = null; } diff --git a/modules/user/models/user.php b/modules/user/models/user.php index a8a3a0e7..8fe0a87b 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -43,6 +43,12 @@ class User_Model_Core extends ORM implements User_Definition { $old = clone $this; module::event("user_before_delete", $this); parent::delete($id); + + db::build() + ->delete("groups_users") + ->where("user_id", "=", empty($id) ? $old->id : $id) + ->execute(); + module::event("user_deleted", $old); $this->groups_cache = null; } -- cgit v1.2.3 From eb5c7e5e18076eeeff0193da4add214433ccb4a1 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 4 Aug 2011 21:00:21 -0700 Subject: Patch for ticket #1765. Provide the full site url for the the gallery link instead of trying to use url_base for the hidden link and the presentation text. --- modules/user/views/reset_password.html.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/user/views/reset_password.html.php b/modules/user/views/reset_password.html.php index 3afca881..d939ad42 100644 --- a/modules/user/views/reset_password.html.php +++ b/modules/user/views/reset_password.html.php @@ -9,8 +9,9 @@ $user->full_name ? $user->full_name : $user->name)) ?>

    - %site_url. If you made this request, you can confirm it by clicking this link. If you didn't request this password reset, it's ok to ignore this mail.", - array("site_url" => html::mark_clean(url::base(false, "http")), + %base_url. If you made this request, you can confirm it by clicking this link. If you didn't request this password reset, it's ok to ignore this mail.", + array("site_url" => html::mark_clean(url::abs_site("/")), + "base_url" => html::mark_clean(url::base(false)), "confirm_url" => $confirm_url)) ?>

    -- cgit v1.2.3 From a246b6fe450e21f735824d5a089a8e652b12885f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 7 Aug 2011 13:27:27 -0700 Subject: Initial commit of a patch for Ticket #1764. as discussed here: https://github.com/gallery/gallery3/pull/58/files#r72949. Create a Breadcrumb library which has two static methods for_item (which takes a an item and builds the entire breadcrumb for the item) or build (which takes a variable number of Breadcrumb elements and creates a breadcrumb based on the specified elements). Used tag->url() to build the tag album url. Escaped the query string for the search. Tightened up the breadcrumb code in page.html.php. When adding the show query parameter, we can't blindly concatenate using the ? separator. We have to check that we use a & if a query parameter already exists. --- modules/gallery/controllers/albums.php | 1 + modules/gallery/controllers/movies.php | 1 + modules/gallery/controllers/photos.php | 1 + modules/gallery/libraries/Breadcrumb.php | 74 +++++++++++++++++++++++++++++++ modules/gallery/tests/Breadcrumb_Test.php | 51 +++++++++++++++++++++ modules/search/controllers/search.php | 5 +++ modules/tag/controllers/tag.php | 3 ++ themes/wind/views/page.html.php | 27 +++-------- 8 files changed, 143 insertions(+), 20 deletions(-) create mode 100644 modules/gallery/libraries/Breadcrumb.php create mode 100644 modules/gallery/tests/Breadcrumb_Test.php (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index ccf6c1cb..90071fb5 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -69,6 +69,7 @@ class Albums_Controller extends Items_Controller { "item" => $album, "children" => $album->viewable()->children($page_size, $offset), "parents" => $album->parents()->as_array(), // view calls empty() on this + "breadcrumbs" => Breadcrumb::build_from_item($album), "children_count" => $children_count)); $template->content = new View("album.html"); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 8e81c594..77d92e13 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -43,6 +43,7 @@ class Movies_Controller extends Items_Controller { "children" => array(), "children_count" => 0, "parents" => $movie->parents()->as_array(), + "breadcrumbs" => Breadcrumb::build_from_item($movie), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $movie->parent()->viewable()->children_count($where), diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 054300a1..5c8c7b34 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -43,6 +43,7 @@ class Photos_Controller extends Items_Controller { "children" => array(), "children_count" => 0, "parents" => $photo->parents()->as_array(), + "breadcrumbs" => Breadcrumb::build_from_item($photo), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $photo->parent()->viewable()->children_count($where), diff --git a/modules/gallery/libraries/Breadcrumb.php b/modules/gallery/libraries/Breadcrumb.php new file mode 100644 index 00000000..3a2499ba --- /dev/null +++ b/modules/gallery/libraries/Breadcrumb.php @@ -0,0 +1,74 @@ +parents() as $element) { + $breadcrumbs[] = new Breadcrumb($element->title, $element->url(), $element->id); + } + + if (!empty($breadcrumbs)) { + $breadcrumbs[] = new Breadcrumb($item->title, $item->url(), $item->id); + } + + return self::generate_show_query_strings($breadcrumbs); + } + + /** + * This static function takes a list (variable arguments) of Breadcrumbs and builds a dynamic + * breadcrumb list. Used to create a breadcrumb for dynamic albums. Will really be useful + * for the display context change. + */ + static function build_from_list() { + return self::generate_show_query_strings(func_get_args()); + } + + private static function generate_show_query_strings($breadcrumbs) { + if (!empty($breadcrumbs)) { + + end($breadcrumbs)->last = true;; + while ($breadcrumb = current($breadcrumbs)) { + if (isset($last_id) && $last_id > 0) { + $query = parse_url($breadcrumb->url, PHP_URL_QUERY); + $breadcrumb->url = $breadcrumb->url . ($query ? "&" : "?") . "show={$last_id}"; + } + $last_id = $breadcrumb->id; + $breadcrumb = prev($breadcrumbs); + } + $breadcrumbs[0]->first = true; + } + + return $breadcrumbs; + } + + public function __construct($title, $url, $id=0) { + $this->title = $title; + $this->url = $url; + $this->id = $id; + $this->first = false; + $this->last = false; + } +} diff --git a/modules/gallery/tests/Breadcrumb_Test.php b/modules/gallery/tests/Breadcrumb_Test.php new file mode 100644 index 00000000..9f9aeddc --- /dev/null +++ b/modules/gallery/tests/Breadcrumb_Test.php @@ -0,0 +1,51 @@ +album = test::random_album(); + $this->item = test::random_photo($this->album); + $this->album->reload(); + } + + public function teardown() { + $this->album = null; + $this->item = null; + } + + public function build_breadcrumbs_for_item_test() { + $breadcrumbs = Breadcrumb::build_from_item($this->item); + $this->assert_equal("Gallery", $breadcrumbs[0]->title); + $this->assert_equal($this->album->title, $breadcrumbs[1]->title); + $this->assert_equal($this->item->title, $breadcrumbs[2]->title); + } + + public function build_breadcrumbs_from_items_test() { + $breadcrumbs = Breadcrumb::build_from_list( + new Breadcrumb(item::root()->title, "/", item::root()->id), + new Breadcrumb($this->album->title, $this->album->relative_path(), $this->album->id), + new Breadcrumb($this->item->title, $this->item->relative_path(), $this->item->id)); + $this->assert_equal("Gallery", $breadcrumbs[0]->title); + $this->assert_equal($this->album->title, $breadcrumbs[1]->title); + $this->assert_equal($this->item->title, $breadcrumbs[2]->title); + } +} \ No newline at end of file diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index 261d67ee..d30ffa67 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -36,9 +36,14 @@ class Search_Controller extends Controller { $max_pages = max(ceil($count / $page_size), 1); $template = new Theme_View("page.html", "collection", "search"); + $root = item::root(); + $search_url = url::abs_site("search?q=" . urlencode($q)); $template->set_global(array("page" => $page, "max_pages" => $max_pages, "page_size" => $page_size, + "breadcrumbs" => Breadcrumb::build_from_list( + new Breadcrumb(item::root()->title, "/", item::root()->id), + new Breadcrumb($q, $search_url)), "children_count" => $count)); $template->content = new View("search.html"); diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 8f885dea..44a171fd 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -40,6 +40,9 @@ class Tag_Controller extends Controller { "page_size" => $page_size, "tag" => $tag, "children" => $tag->items($page_size, $offset), + "breadcrumbs" => Breadcrumb::build_from_list( + new Breadcrumb(item::root()->title, "/", item::root()->id), + new Breadcrumb($tag->name, $tag->url())), "children_count" => $children_count)); $template->content = new View("dynamic.html"); $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name)); diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index 045e3c45..534b7de4 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -107,28 +107,15 @@ header_bottom() ?> - item() && !empty($parents)): ?> + -- cgit v1.2.3 From 67719c6f610a71c1bc12d5126e0adac84d7b85c6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 8 Aug 2011 20:28:31 -0700 Subject: Simplification of 59b04b897b8a664cd7334b017fac8158a6281434 for #1764: - Breadcrumb::build_from_item becomes Breadcrumb::array_from_item_parents - Eliminate Breadcrumb::$id -- it's no longer necessary - Fold Breadcrumb::generate_show_query_strings into Breadcrumb::array_from_item_parents - Create Breadcrumb::set_first() and Breadcrumb::set_last() - Breadcrumb::build_from_list goes away, we just use arrays for this - Change Search_Controller and Tag_Controller to just create an array of Breadcrumb instances with the first/last marked appropriately - Breadcrumb_Test loses a bunch of complexity. --- modules/gallery/controllers/albums.php | 2 +- modules/gallery/controllers/movies.php | 2 +- modules/gallery/controllers/photos.php | 2 +- modules/gallery/libraries/Breadcrumb.php | 70 +++++++++++++++---------------- modules/gallery/tests/Breadcrumb_Test.php | 33 ++++----------- modules/search/controllers/search.php | 17 ++++---- modules/tag/controllers/tag.php | 20 +++++---- 7 files changed, 65 insertions(+), 81 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 90071fb5..1c48c734 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -69,7 +69,7 @@ class Albums_Controller extends Items_Controller { "item" => $album, "children" => $album->viewable()->children($page_size, $offset), "parents" => $album->parents()->as_array(), // view calls empty() on this - "breadcrumbs" => Breadcrumb::build_from_item($album), + "breadcrumbs" => Breadcrumb::array_from_item_parents($album), "children_count" => $children_count)); $template->content = new View("album.html"); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 77d92e13..0f12c3fb 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -43,7 +43,7 @@ class Movies_Controller extends Items_Controller { "children" => array(), "children_count" => 0, "parents" => $movie->parents()->as_array(), - "breadcrumbs" => Breadcrumb::build_from_item($movie), + "breadcrumbs" => Breadcrumb::array_from_item_parents($movie), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $movie->parent()->viewable()->children_count($where), diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 5c8c7b34..af8aed16 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -43,7 +43,7 @@ class Photos_Controller extends Items_Controller { "children" => array(), "children_count" => 0, "parents" => $photo->parents()->as_array(), - "breadcrumbs" => Breadcrumb::build_from_item($photo), + "breadcrumbs" => Breadcrumb::array_from_item_parents($photo), "next_item" => $next_item, "previous_item" => $previous_item, "sibling_count" => $photo->parent()->viewable()->children_count($where), diff --git a/modules/gallery/libraries/Breadcrumb.php b/modules/gallery/libraries/Breadcrumb.php index 3a2499ba..e151890d 100644 --- a/modules/gallery/libraries/Breadcrumb.php +++ b/modules/gallery/libraries/Breadcrumb.php @@ -20,55 +20,51 @@ class Breadcrumb_Core { public $title; public $url; - public $id; public $first; public $last; - static function build_from_item($item) { - $breadcrumbs = array(); - foreach ($item->parents() as $element) { - $breadcrumbs[] = new Breadcrumb($element->title, $element->url(), $element->id); - } - - if (!empty($breadcrumbs)) { - $breadcrumbs[] = new Breadcrumb($item->title, $item->url(), $item->id); - } + static function instance($title, $url) { + return new Breadcrumb($title, $url); + } - return self::generate_show_query_strings($breadcrumbs); + public function __construct($title, $url) { + $this->title = $title; + $this->url = $url; + $this->first = false; + $this->last = false; } /** - * This static function takes a list (variable arguments) of Breadcrumbs and builds a dynamic - * breadcrumb list. Used to create a breadcrumb for dynamic albums. Will really be useful - * for the display context change. + * Return an array of Breadcrumb instances build from the parents of a given item. + * The first and last Breadcrumb instances will be marked first/last as appropriate. + * Each breadcrumb will have a ?show= query parameter that refers to the id of the next + * item in line. + * + * @return array Breadcrumb instances */ - static function build_from_list() { - return self::generate_show_query_strings(func_get_args()); - } - - private static function generate_show_query_strings($breadcrumbs) { - if (!empty($breadcrumbs)) { + static function array_from_item_parents($item) { + if ($item->id == item::root()->id) { + return array(); + } - end($breadcrumbs)->last = true;; - while ($breadcrumb = current($breadcrumbs)) { - if (isset($last_id) && $last_id > 0) { - $query = parse_url($breadcrumb->url, PHP_URL_QUERY); - $breadcrumb->url = $breadcrumb->url . ($query ? "&" : "?") . "show={$last_id}"; - } - $last_id = $breadcrumb->id; - $breadcrumb = prev($breadcrumbs); - } - $breadcrumbs[0]->first = true; + $bc = array_merge($item->parents()->as_array(), array($item)); + for ($i = 0; $i < count($bc) - 1; $i++) { + $bc[$i] = new Breadcrumb($bc[$i]->title, $bc[$i]->url("show={$bc[$i+1]->id}")); } + $bc[$i] = new Breadcrumb($item->title, $item->url()); - return $breadcrumbs; + $bc[0]->set_first(); + end($bc)->set_last(); + return $bc; } - public function __construct($title, $url, $id=0) { - $this->title = $title; - $this->url = $url; - $this->id = $id; - $this->first = false; - $this->last = false; + public function set_first() { + $this->first = true; + return $this; + } + + public function set_last() { + $this->last = true; + return $this; } } diff --git a/modules/gallery/tests/Breadcrumb_Test.php b/modules/gallery/tests/Breadcrumb_Test.php index 9f9aeddc..ed2e5608 100644 --- a/modules/gallery/tests/Breadcrumb_Test.php +++ b/modules/gallery/tests/Breadcrumb_Test.php @@ -21,31 +21,16 @@ class Breadcrumb_Test extends Gallery_Unit_Test_Case { private $album; private $item; - public function setup() { - $this->album = test::random_album(); - $this->item = test::random_photo($this->album); - $this->album->reload(); - } - - public function teardown() { - $this->album = null; - $this->item = null; - } - public function build_breadcrumbs_for_item_test() { - $breadcrumbs = Breadcrumb::build_from_item($this->item); - $this->assert_equal("Gallery", $breadcrumbs[0]->title); - $this->assert_equal($this->album->title, $breadcrumbs[1]->title); - $this->assert_equal($this->item->title, $breadcrumbs[2]->title); - } + $album = test::random_album(); + $item = test::random_photo($album); - public function build_breadcrumbs_from_items_test() { - $breadcrumbs = Breadcrumb::build_from_list( - new Breadcrumb(item::root()->title, "/", item::root()->id), - new Breadcrumb($this->album->title, $this->album->relative_path(), $this->album->id), - new Breadcrumb($this->item->title, $this->item->relative_path(), $this->item->id)); - $this->assert_equal("Gallery", $breadcrumbs[0]->title); - $this->assert_equal($this->album->title, $breadcrumbs[1]->title); - $this->assert_equal($this->item->title, $breadcrumbs[2]->title); + $expected = array(); + $expected[] = Breadcrumb::instance( + item::root()->title, item::root()->url("show={$album->id}"))->set_first(); + $expected[] = + Breadcrumb::instance($album->title, $album->url("show={$item->id}")); + $expected[] = Breadcrumb::instance($item->title, $item->url())->set_last(); + $this->assert_equal($expected, Breadcrumb::array_from_item_parents($item)); } } \ No newline at end of file diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index d30ffa67..5db63ab0 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -37,14 +37,15 @@ class Search_Controller extends Controller { $template = new Theme_View("page.html", "collection", "search"); $root = item::root(); - $search_url = url::abs_site("search?q=" . urlencode($q)); - $template->set_global(array("page" => $page, - "max_pages" => $max_pages, - "page_size" => $page_size, - "breadcrumbs" => Breadcrumb::build_from_list( - new Breadcrumb(item::root()->title, "/", item::root()->id), - new Breadcrumb($q, $search_url)), - "children_count" => $count)); + $template->set_global( + array("page" => $page, + "max_pages" => $max_pages, + "page_size" => $page_size, + "breadcrumbs" => array( + Breadcrumb::instance($root->title, $root->url())->set_first(), + Breadcrumb::instance($q, url::abs_site("search?q=" . urlencode($q)))->set_last(), + ), + "children_count" => $count)); $template->content = new View("search.html"); $template->content->items = $result; diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 44a171fd..7786daa1 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -34,16 +34,18 @@ class Tag_Controller extends Controller { url::redirect(url::merge(array("page" => $max_pages))); } + $root = item::root(); $template = new Theme_View("page.html", "collection", "tag"); - $template->set_global(array("page" => $page, - "max_pages" => $max_pages, - "page_size" => $page_size, - "tag" => $tag, - "children" => $tag->items($page_size, $offset), - "breadcrumbs" => Breadcrumb::build_from_list( - new Breadcrumb(item::root()->title, "/", item::root()->id), - new Breadcrumb($tag->name, $tag->url())), - "children_count" => $children_count)); + $template->set_global( + array("page" => $page, + "max_pages" => $max_pages, + "page_size" => $page_size, + "tag" => $tag, + "children" => $tag->items($page_size, $offset), + "breadcrumbs" => array( + Breadcrumb::instance($root->title, $root->url())->set_first(), + Breadcrumb::instance($tag->name, $tag->url())->set_last()), + "children_count" => $children_count)); $template->content = new View("dynamic.html"); $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name)); -- cgit v1.2.3 From 933a34986dbca248f388e8aa3c3aea4a6d71a94b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 11 Aug 2011 22:04:20 -0700 Subject: Patch for tickets #1428 and #1760 Create the concept of a Photo_Display_Context. If the user is browsing a dynamic album (i.e. tags) and chooses to look at an image in that album. The display of the image happens correctly, but the 'next' and 'previous' buttons are no longer consistent. When one of these is clicked, Gallery will open the adjacent image in the actuall album, not the dynamic album. --- modules/gallery/controllers/albums.php | 3 + modules/gallery/controllers/movies.php | 23 ++----- modules/gallery/controllers/photos.php | 23 ++----- modules/gallery/libraries/Display_Context.php | 71 ++++++++++++++++++++++ modules/gallery/libraries/Item_Display_Context.php | 44 ++++++++++++++ modules/search/controllers/search.php | 21 ++++++- modules/search/helpers/search.php | 45 +++++++++++--- .../search/libraries/Search_Display_Context.php | 52 ++++++++++++++++ modules/tag/controllers/tag.php | 22 ++++++- modules/tag/helpers/tag.php | 19 ++++++ modules/tag/libraries/Tag_Display_Context.php | 49 +++++++++++++++ modules/tag/models/tag.php | 38 ++++++------ 12 files changed, 344 insertions(+), 66 deletions(-) create mode 100644 modules/gallery/libraries/Display_Context.php create mode 100644 modules/gallery/libraries/Item_Display_Context.php create mode 100644 modules/search/libraries/Search_Display_Context.php create mode 100644 modules/tag/libraries/Tag_Display_Context.php (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 1c48c734..9bf7b9bf 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -60,6 +60,9 @@ class Albums_Controller extends Items_Controller { url::redirect($album->abs_url("page=$max_pages")); } + Display_Context::factory("item") + ->save(); + $template = new Theme_View("page.html", "collection", "album"); $template->set_global( array("page" => $page, diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 0f12c3fb..bbf89f17 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -27,27 +27,12 @@ class Movies_Controller extends Items_Controller { access::required("view", $movie); - $where = array(array("type", "!=", "album")); - $position = item::get_position($movie, $where); - if ($position > 1) { - list ($previous_item, $ignore, $next_item) = - $movie->parent()->viewable()->children(3, $position - 2, $where); - } else { - $previous_item = null; - list ($next_item) = $movie->parent()->viewable()->children(1, $position, $where); - } - $template = new Theme_View("page.html", "item", "movie"); $template->set_global( - array("item" => $movie, - "children" => array(), - "children_count" => 0, - "parents" => $movie->parents()->as_array(), - "breadcrumbs" => Breadcrumb::array_from_item_parents($movie), - "next_item" => $next_item, - "previous_item" => $previous_item, - "sibling_count" => $movie->parent()->viewable()->children_count($where), - "position" => $position)); + array_merge(array("item" => $movie, + "children" => array(), + "children_count" => 0), + Display_Context::factory()->display_context($movie))); $template->content = new View("movie.html"); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index af8aed16..49bb5a25 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -27,27 +27,12 @@ class Photos_Controller extends Items_Controller { access::required("view", $photo); - $where = array(array("type", "!=", "album")); - $position = item::get_position($photo, $where); - if ($position > 1) { - list ($previous_item, $ignore, $next_item) = - $photo->parent()->viewable()->children(3, $position - 2, $where); - } else { - $previous_item = null; - list ($next_item) = $photo->parent()->viewable()->children(1, $position, $where); - } - $template = new Theme_View("page.html", "item", "photo"); $template->set_global( - array("item" => $photo, - "children" => array(), - "children_count" => 0, - "parents" => $photo->parents()->as_array(), - "breadcrumbs" => Breadcrumb::array_from_item_parents($photo), - "next_item" => $next_item, - "previous_item" => $previous_item, - "sibling_count" => $photo->parent()->viewable()->children_count($where), - "position" => $position)); + array_merge(array("item" => $photo, + "children" => array(), + "children_count" => 0), + Display_Context::factory()->display_context($photo))); $template->content = new View("photo.html"); diff --git a/modules/gallery/libraries/Display_Context.php b/modules/gallery/libraries/Display_Context.php new file mode 100644 index 00000000..5054cffb --- /dev/null +++ b/modules/gallery/libraries/Display_Context.php @@ -0,0 +1,71 @@ +get("display_context_id", ""); + $context = Cache::instance()->get($display_context_id, null); + $context = empty($context) ? new Item_Display_Context() : unserialize($context); + } else { + $class_prefix = ucfirst(strtolower($display_context_name)); + $class_name = "{$class_prefix}_Display_Context"; + $context = new $class_name(); + } + + return $context; + } + + protected function __construct($display_context_name) { + // $this->reset($display_context_name); + $this->_data = array(); + $this->_display_context_name = $display_context_name; + } + + final function get($key) { + return empty($this->_data[$key]) ? null : $this->_data[$key]; + } + + final function set($key, $value=null) { + if (is_array($key)) { + if ((array)$key == $key) { + $this->_data = array_merge($this->_data, $key); + } else { + $this->_data = array_merge($this->_data, array_fill_keys($key, $value)); + } + } else { + $this->_data[$key] = $value; + } + return $this; + } + + final function save() { + $context_data = serialize($this); + $display_context_id = "display_context_" . md5($context_data); + Session::instance()->set("display_context_id", $display_context_id); + Cache::instance()->set($display_context_id, $context_data); + return $this; + } + + abstract function display_context($item); +} diff --git a/modules/gallery/libraries/Item_Display_Context.php b/modules/gallery/libraries/Item_Display_Context.php new file mode 100644 index 00000000..d0562790 --- /dev/null +++ b/modules/gallery/libraries/Item_Display_Context.php @@ -0,0 +1,44 @@ + 1) { + list ($previous_item, $ignore, $next_item) = + $item->parent()->viewable()->children(3, $position - 2, $where); + } else { + $previous_item = null; + list ($next_item) = $item->parent()->viewable()->children(1, $position, $where); + } + + return array("position" =>$position, + "previous_item" => $previous_item, + "next_item" =>$next_item, + "sibling_count" => $item->parent()->viewable()->children_count($where), + "parents" => $item->parents()->as_array(), + "breadcrumbs" => Breadcrumb::array_from_item_parents($item)); + } +} diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index 5db63ab0..1d5a55bf 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -21,6 +21,18 @@ class Search_Controller extends Controller { public function index() { $page_size = module::get_var("gallery", "page_size", 9); $q = Input::instance()->get("q"); + $q_with_more_terms = search::add_query_terms($q); + $show = Input::instance()->get("show"); + + if ($show) { + $child = ORM::factory("item", $show); + $index = search::get_position($child, $q_with_more_terms); + if ($index) { + $page = ceil($index / $page_size); + url::redirect( url::abs_site("search?q=" . urlencode($q) . ($page == 1 ? "" : "&page=$page"))); + } + } + $page = Input::instance()->get("page", 1); // Make sure that the page references a valid offset @@ -30,11 +42,18 @@ class Search_Controller extends Controller { $offset = ($page - 1) * $page_size; - $q_with_more_terms = search::add_query_terms($q); list ($count, $result) = search::search($q_with_more_terms, $page_size, $offset); + $title = t("Search: %q", array("q" => $q_with_more_terms)); + $max_pages = max(ceil($count / $page_size), 1); + Display_Context::factory("search") + ->set(array("title" => $title, + "query_terms" => $q_with_more_terms, + "q" => $q)) + ->save(); + $template = new Theme_View("page.html", "collection", "search"); $root = item::root(); $template->set_global( diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index a3fd795a..a77a2433 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -36,8 +36,19 @@ class search_Core { static function search($q, $limit, $offset) { $db = Database::instance(); - $q = $db->escape($q); + $query = self::_build_query_base($q) . + "ORDER BY `score` DESC " . + "LIMIT $limit OFFSET " . (int)$offset; + + $data = $db->query($query); + $count = $db->query("SELECT FOUND_ROWS() as c")->current()->c; + + return array($count, new ORM_Iterator(ORM::factory("item"), $data)); + } + + private static function _build_query_base($q, $where=array()) { + $q = Database::instance()->escape($q); if (!identity::active_user()->admin) { foreach (identity::group_ids_for_active_user() as $id) { $fields[] = "`view_$id` = TRUE"; // access::ALLOW @@ -47,18 +58,13 @@ class search_Core { $access_sql = ""; } - $query = + return "SELECT SQL_CALC_FOUND_ROWS {items}.*, " . " MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " . "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " . "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . - $access_sql . - "ORDER BY `score` DESC " . - "LIMIT $limit OFFSET " . (int)$offset; - $data = $db->query($query); - $count = $db->query("SELECT FOUND_ROWS() as c")->current()->c; - - return array($count, new ORM_Iterator(ORM::factory("item"), $data)); + (empty($where) ? "" : " AND " . join(" AND ", $where)) . + $access_sql; } /** @@ -103,4 +109,25 @@ class search_Core { return array($remaining, $total, $percent); } + + static function get_position($item, $q) { + $page_size = module::get_var("gallery", "page_size", 9); + + $query = self::_build_query_base($q, array("{items}.id = " . $item->id)); + + $db = Database::instance(); + + // Truncate the score by two decimal places as this resolves the issues + // that arise due to in exact numeric conversions. + $score = $db->query($query)->current()->score; + $score = substr($score, 0, strlen($score) - 2); + + $data = $db->query(self::_build_query_base($q) . "having `score` >= " . $score); + + $data->seek($data->count() - 1); + + while ($data->get("id") != $item->id && $data->prev()->valid()); + + return $data->key() + 1; + } } diff --git a/modules/search/libraries/Search_Display_Context.php b/modules/search/libraries/Search_Display_Context.php new file mode 100644 index 00000000..aed3a125 --- /dev/null +++ b/modules/search/libraries/Search_Display_Context.php @@ -0,0 +1,52 @@ +get("query_terms")); + + if ($position > 1) { + list ($count, $result_data) = + search::search($this->get("query_terms"), 3, $position - 2); + list ($previous_item, $ignore, $next_item) = $result_data; + } else { + $previous_item = null; + list ($count, $result_data) = search::search($this->get("query_terms"), 1, $position); + list ($next_item) = $result_data; + } + + $q = $this->get("q"); + $search_url = url::abs_site("search?q=" . urlencode($q) . "&show={$item->id}"); + $root = item::root(); + + return array("position" =>$position, + "previous_item" => $previous_item, + "next_item" =>$next_item, + "sibling_count" => $count, + "breadcrumbs" => array( + Breadcrumb::instance($root->title, "/", $root->id), + Breadcrumb::instance($q, $search_url), + Breadcrumb::instance($item->title, $item->url()))); + } +} diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 7786daa1..06e2b5ed 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -22,7 +22,22 @@ class Tag_Controller extends Controller { $tag_id = $function; $tag = ORM::factory("tag")->where("id", "=", $tag_id)->find(); $page_size = module::get_var("gallery", "page_size", 9); - $page = (int) Input::instance()->get("page", "1"); + + $input = Input::instance(); + $show = $input->get("show"); + + if ($show) { + $child = ORM::factory("item", $show); + $index = tag::get_position($tag, $child); + if ($index) { + $page = ceil($index / $page_size); + $uri = "tag/$tag_id/" . urlencode($tag->name); + url::redirect($uri . ($page == 1 ? "" : "?page=$page")); + } + } else { + $page = (int) $input->get("page", "1"); + } + $children_count = $tag->items_count(); $offset = ($page-1) * $page_size; $max_pages = max(ceil($children_count / $page_size), 1); @@ -35,6 +50,11 @@ class Tag_Controller extends Controller { } $root = item::root(); + $title = t("Tag: %tag_name", array("tag_name" => $tag->name)); + Display_Context::factory("tag") + ->set(array("tag" => $tag)) + ->save(); + $template = new Theme_View("page.html", "collection", "tag"); $template->set_global( array("page" => $page, diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index c21104ee..83a00080 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -136,4 +136,23 @@ class tag_Core { // extremely rare case. db::build()->delete("tags")->where("count", "=", 0)->execute(); } + + /** + * Find the position of the given item in the tag collection. The resulting + * value is 1-indexed, so the first child in the album is at position 1. + * + * @param Tag_Model $tag + * @param Item_Model $item + * @param array $where an array of arrays, each compatible with ORM::where() + */ + static function get_position($tag, $item, $where=array()) { + return ORM::factory("item") + ->viewable() + ->join("items_tags", "items.id", "items_tags.item_id") + ->where("items_tags.tag_id", "=", $tag->id) + ->where("items.id", "<=", $item->id) + ->merge_where($where) + ->order_by("items.id") + ->count_all(); + } } \ No newline at end of file diff --git a/modules/tag/libraries/Tag_Display_Context.php b/modules/tag/libraries/Tag_Display_Context.php new file mode 100644 index 00000000..47c79088 --- /dev/null +++ b/modules/tag/libraries/Tag_Display_Context.php @@ -0,0 +1,49 @@ +get("tag"); + + $where = array(array("type", "!=", "album")); + + $position = tag::get_position($tag, $item, $where); + if ($position > 1) { + list ($previous_item, $ignore, $next_item) = $tag->items(3, $position - 2, $where); + } else { + $previous_item = null; + list ($next_item) = $tag->items(1, $position, $where); + } + + $root = item::root(); + return array("position" =>$position, + "previous_item" => $previous_item, + "next_item" =>$next_item, + "sibling_count" => $tag->items_count($where), + "breadcrumbs" => array( + Breadcrumb::instance($root->title, $root->url())->set_first(), + Breadcrumb::instance($tag->name, $tag->url("show={$item->id}")), + Breadcrumb::instance($item->title, $item->url())->set_last())); + } +} diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index bb79e707..a7150df8 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -33,35 +33,39 @@ class Tag_Model_Core extends ORM { * Return all viewable items associated with this tag. * @param integer $limit number of rows to limit result to * @param integer $offset offset in result to start returning rows from - * @param string $type the type of item (album, photo) + * @param string $where an array of arrays, each compatible with ORM::where() * @return ORM_Iterator */ - public function items($limit=null, $offset=null, $type=null) { - $model = ORM::factory("item") + public function items($limit=null, $offset=null, $where=array()) { + if (is_scalar($where)) { + // backwards compatibility + $where = array(array("items.type", "=", $where)); + } + return ORM::factory("item") ->viewable() ->join("items_tags", "items.id", "items_tags.item_id") - ->where("items_tags.tag_id", "=", $this->id); - if ($type) { - $model->where("items.type", "=", $type); - } - return $model->find_all($limit, $offset); + ->where("items_tags.tag_id", "=", $this->id) + ->merge_where($where) + ->order_by("items.id") + ->find_all($limit, $offset); } /** * Return the count of all viewable items associated with this tag. - * @param string $type the type of item (album, photo) + * @param string $where an array of arrays, each compatible with ORM::where() * @return integer */ - public function items_count($type=null) { - $model = ORM::factory("item") + public function items_count($where=array()) { + if (is_scalar($where)) { + // backwards compatibility + $where = array(array("items.type", "=", $where)); + } + return $model = ORM::factory("item") ->viewable() ->join("items_tags", "items.id", "items_tags.item_id") - ->where("items_tags.tag_id", "=", $this->id); - - if ($type) { - $model->where("items.type", "=", $type); - } - return $model->count_all(); + ->where("items_tags.tag_id", "=", $this->id) + ->merge_where($where) + ->count_all(); } /** -- cgit v1.2.3 From ce43f29e2ceaac3d638061f81dc6037b5e0018d3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 27 Aug 2011 11:18:07 -0700 Subject: Refactor the display context code a bit: 1) Move the display context code into the controller themselves so that it's more logically a continuation callback from the original controller rendering code. 2) Simplify the display context set/get code and put it in the item helper, it's just a couple of lines of code now. 3) Add more descriptive breadcrumb strings --- modules/gallery/controllers/albums.php | 24 ++++++-- modules/gallery/controllers/movies.php | 10 ++- modules/gallery/controllers/photos.php | 10 ++- modules/gallery/helpers/item.php | 17 ++++++ modules/gallery/libraries/Display_Context.php | 71 ---------------------- modules/gallery/libraries/Item_Display_Context.php | 44 -------------- modules/search/controllers/search.php | 36 ++++++++--- .../search/libraries/Search_Display_Context.php | 52 ---------------- modules/tag/controllers/tag.php | 34 +++++++++-- modules/tag/libraries/Tag_Display_Context.php | 49 --------------- 10 files changed, 102 insertions(+), 245 deletions(-) delete mode 100644 modules/gallery/libraries/Display_Context.php delete mode 100644 modules/gallery/libraries/Item_Display_Context.php delete mode 100644 modules/search/libraries/Search_Display_Context.php delete mode 100644 modules/tag/libraries/Tag_Display_Context.php (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 9bf7b9bf..8aa3bb35 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -60,9 +60,6 @@ class Albums_Controller extends Items_Controller { url::redirect($album->abs_url("page=$max_pages")); } - Display_Context::factory("item") - ->save(); - $template = new Theme_View("page.html", "collection", "album"); $template->set_global( array("page" => $page, @@ -75,10 +72,29 @@ class Albums_Controller extends Items_Controller { "breadcrumbs" => Breadcrumb::array_from_item_parents($album), "children_count" => $children_count)); $template->content = new View("album.html"); - $album->increment_view_count(); print $template; + item::set_display_context_callback("Albums_Controller::get_display_context"); + } + + static function get_display_context($item) { + $where = array(array("type", "!=", "album")); + $position = item::get_position($item, $where); + if ($position > 1) { + list ($previous_item, $ignore, $next_item) = + $item->parent()->viewable()->children(3, $position - 2, $where); + } else { + $previous_item = null; + list ($next_item) = $item->parent()->viewable()->children(1, $position, $where); + } + + return array("position" => $position, + "previous_item" => $previous_item, + "next_item" => $next_item, + "sibling_count" => $item->parent()->viewable()->children_count($where), + "parents" => $item->parents()->as_array(), + "breadcrumbs" => Breadcrumb::array_from_item_parents($item)); } public function create($parent_id) { diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index bbf89f17..76263dc0 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -28,12 +28,10 @@ class Movies_Controller extends Items_Controller { access::required("view", $movie); $template = new Theme_View("page.html", "item", "movie"); - $template->set_global( - array_merge(array("item" => $movie, - "children" => array(), - "children_count" => 0), - Display_Context::factory()->display_context($movie))); - + $template->set_global(array("item" => $movie, + "children" => array(), + "children_count" => 0)); + $template->set_global(item::get_display_context($movie)); $template->content = new View("movie.html"); $movie->increment_view_count(); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 49bb5a25..7e78b205 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -28,12 +28,10 @@ class Photos_Controller extends Items_Controller { access::required("view", $photo); $template = new Theme_View("page.html", "item", "photo"); - $template->set_global( - array_merge(array("item" => $photo, - "children" => array(), - "children_count" => 0), - Display_Context::factory()->display_context($photo))); - + $template->set_global(array("item" => $photo, + "children" => array(), + "children_count" => 0)); + $template->set_global(item::get_display_context($photo)); $template->content = new View("photo.html"); $photo->increment_view_count(); diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 7e779544..494c6db4 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -402,4 +402,21 @@ class item_Core { return $position; } + + /** + * Set the display context callback for any future item renders. + */ + static function set_display_context_callback() { + Cache::instance()->set("display_context_" . $sid = Session::instance()->id(), func_get_args()); + } + + /** + * Call the display context callback for the given item + */ + static function get_display_context($item) { + $args = Cache::instance()->get("display_context_" . $sid = Session::instance()->id()); + $callback = $args[0]; + $args[0] = $item; + return call_user_func_array($callback, $args); + } } \ No newline at end of file diff --git a/modules/gallery/libraries/Display_Context.php b/modules/gallery/libraries/Display_Context.php deleted file mode 100644 index 5054cffb..00000000 --- a/modules/gallery/libraries/Display_Context.php +++ /dev/null @@ -1,71 +0,0 @@ -get("display_context_id", ""); - $context = Cache::instance()->get($display_context_id, null); - $context = empty($context) ? new Item_Display_Context() : unserialize($context); - } else { - $class_prefix = ucfirst(strtolower($display_context_name)); - $class_name = "{$class_prefix}_Display_Context"; - $context = new $class_name(); - } - - return $context; - } - - protected function __construct($display_context_name) { - // $this->reset($display_context_name); - $this->_data = array(); - $this->_display_context_name = $display_context_name; - } - - final function get($key) { - return empty($this->_data[$key]) ? null : $this->_data[$key]; - } - - final function set($key, $value=null) { - if (is_array($key)) { - if ((array)$key == $key) { - $this->_data = array_merge($this->_data, $key); - } else { - $this->_data = array_merge($this->_data, array_fill_keys($key, $value)); - } - } else { - $this->_data[$key] = $value; - } - return $this; - } - - final function save() { - $context_data = serialize($this); - $display_context_id = "display_context_" . md5($context_data); - Session::instance()->set("display_context_id", $display_context_id); - Cache::instance()->set($display_context_id, $context_data); - return $this; - } - - abstract function display_context($item); -} diff --git a/modules/gallery/libraries/Item_Display_Context.php b/modules/gallery/libraries/Item_Display_Context.php deleted file mode 100644 index d0562790..00000000 --- a/modules/gallery/libraries/Item_Display_Context.php +++ /dev/null @@ -1,44 +0,0 @@ - 1) { - list ($previous_item, $ignore, $next_item) = - $item->parent()->viewable()->children(3, $position - 2, $where); - } else { - $previous_item = null; - list ($next_item) = $item->parent()->viewable()->children(1, $position, $where); - } - - return array("position" =>$position, - "previous_item" => $previous_item, - "next_item" =>$next_item, - "sibling_count" => $item->parent()->viewable()->children_count($where), - "parents" => $item->parents()->as_array(), - "breadcrumbs" => Breadcrumb::array_from_item_parents($item)); - } -} diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index 1d5a55bf..e4ac6702 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -29,7 +29,7 @@ class Search_Controller extends Controller { $index = search::get_position($child, $q_with_more_terms); if ($index) { $page = ceil($index / $page_size); - url::redirect( url::abs_site("search?q=" . urlencode($q) . ($page == 1 ? "" : "&page=$page"))); + url::redirect(url::abs_site("search?q=" . urlencode($q) . ($page == 1 ? "" : "&page=$page"))); } } @@ -48,12 +48,6 @@ class Search_Controller extends Controller { $max_pages = max(ceil($count / $page_size), 1); - Display_Context::factory("search") - ->set(array("title" => $title, - "query_terms" => $q_with_more_terms, - "q" => $q)) - ->save(); - $template = new Theme_View("page.html", "collection", "search"); $root = item::root(); $template->set_global( @@ -71,5 +65,33 @@ class Search_Controller extends Controller { $template->content->q = $q; print $template; + + item::set_display_context_callback( + "Search_Controller::get_display_context", $title, $q_with_more_terms, $q); + } + + static function get_display_context($item, $title, $query_terms, $q) { + $position = search::get_position($item, $query_terms); + + if ($position > 1) { + list ($count, $result_data) = search::search($query_terms, 3, $position - 2); + list ($previous_item, $ignore, $next_item) = $result_data; + } else { + $previous_item = null; + list ($count, $result_data) = search::search($query_terms, 1, $position); + list ($next_item) = $result_data; + } + + $search_url = url::abs_site("search?q=" . urlencode($q) . "&show={$item->id}"); + $root = item::root(); + + return array("position" => $position, + "previous_item" => $previous_item, + "next_item" => $next_item, + "sibling_count" => $count, + "breadcrumbs" => array( + Breadcrumb::instance($root->title, "/", $root->id)->set_first(), + Breadcrumb::instance(t("Search: %q", array("q" => $q)), $search_url), + Breadcrumb::instance($item->title, $item->url())->set_last())); } } diff --git a/modules/search/libraries/Search_Display_Context.php b/modules/search/libraries/Search_Display_Context.php deleted file mode 100644 index aed3a125..00000000 --- a/modules/search/libraries/Search_Display_Context.php +++ /dev/null @@ -1,52 +0,0 @@ -get("query_terms")); - - if ($position > 1) { - list ($count, $result_data) = - search::search($this->get("query_terms"), 3, $position - 2); - list ($previous_item, $ignore, $next_item) = $result_data; - } else { - $previous_item = null; - list ($count, $result_data) = search::search($this->get("query_terms"), 1, $position); - list ($next_item) = $result_data; - } - - $q = $this->get("q"); - $search_url = url::abs_site("search?q=" . urlencode($q) . "&show={$item->id}"); - $root = item::root(); - - return array("position" =>$position, - "previous_item" => $previous_item, - "next_item" =>$next_item, - "sibling_count" => $count, - "breadcrumbs" => array( - Breadcrumb::instance($root->title, "/", $root->id), - Breadcrumb::instance($q, $search_url), - Breadcrumb::instance($item->title, $item->url()))); - } -} diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 1628f0ac..559e2a5a 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -50,10 +50,6 @@ class Tag_Controller extends Controller { } $root = item::root(); - Display_Context::factory("tag") - ->set(array("tag" => $tag)) - ->save(); - $template = new Theme_View("page.html", "collection", "tag"); $template->set_global( array("page" => $page, @@ -63,11 +59,37 @@ class Tag_Controller extends Controller { "children" => $tag->items($page_size, $offset), "breadcrumbs" => array( Breadcrumb::instance($root->title, $root->url())->set_first(), - Breadcrumb::instance($tag->name, $tag->url())->set_last()), + Breadcrumb::instance(t("Tag: %tag_name", array("tag_name" => $tag->name)), + $tag->url())->set_last()), "children_count" => $children_count)); $template->content = new View("dynamic.html"); $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name)); - print $template; + + item::set_display_context_callback("Tag_Controller::get_display_context", $tag->id); + } + + static function get_display_context($item, $tag_id) { + $tag = ORM::factory("tag", $tag_id); + $where = array(array("type", "!=", "album")); + + $position = tag::get_position($tag, $item, $where); + if ($position > 1) { + list ($previous_item, $ignore, $next_item) = $tag->items(3, $position - 2, $where); + } else { + $previous_item = null; + list ($next_item) = $tag->items(1, $position, $where); + } + + $root = item::root(); + return array("position" => $position, + "previous_item" => $previous_item, + "next_item" => $next_item, + "sibling_count" => $tag->items_count($where), + "breadcrumbs" => array( + Breadcrumb::instance($root->title, $root->url())->set_first(), + Breadcrumb::instance(t("Tag: %tag_name", array("tag_name" => $tag->name)), + $tag->url("show={$item->id}")), + Breadcrumb::instance($item->title, $item->url())->set_last())); } } diff --git a/modules/tag/libraries/Tag_Display_Context.php b/modules/tag/libraries/Tag_Display_Context.php deleted file mode 100644 index 47c79088..00000000 --- a/modules/tag/libraries/Tag_Display_Context.php +++ /dev/null @@ -1,49 +0,0 @@ -get("tag"); - - $where = array(array("type", "!=", "album")); - - $position = tag::get_position($tag, $item, $where); - if ($position > 1) { - list ($previous_item, $ignore, $next_item) = $tag->items(3, $position - 2, $where); - } else { - $previous_item = null; - list ($next_item) = $tag->items(1, $position, $where); - } - - $root = item::root(); - return array("position" =>$position, - "previous_item" => $previous_item, - "next_item" =>$next_item, - "sibling_count" => $tag->items_count($where), - "breadcrumbs" => array( - Breadcrumb::instance($root->title, $root->url())->set_first(), - Breadcrumb::instance($tag->name, $tag->url("show={$item->id}")), - Breadcrumb::instance($item->title, $item->url())->set_last())); - } -} -- cgit v1.2.3