From 04f34516f89451b5a3af6a122f740dc30112e597 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Tue, 23 Jun 2009 10:05:15 +0200 Subject: Improve compatibility with other RDBMS --- 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 15efa3b2..9046ad2d 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -45,7 +45,7 @@ class search_Core { "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . $access_sql . "ORDER BY `score` DESC " . - "LIMIT $offset, $limit"; + "LIMIT $limit OFFSET $offset"; return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } -- cgit v1.2.3 From 2e6a1d6fdc562b2ff797deaf8b8ab019c17ed113 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Tue, 23 Jun 2009 10:08:55 +0200 Subject: SQL is case insensitive --- modules/search/helpers/search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 9046ad2d..ea8dad81 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -34,11 +34,11 @@ class search_Core { // Count the total number of rows. We can't do this with our regular query because of the // limit statement. It's possible that if we get rid of the limit (but keep the offset) on // the 2nd query and combine the two, it might be faster than making 2 separate queries. - $count_query = "SELECT COUNT(*) AS C " . + $count_query = "SELECT COUNT(*) AS c " . "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " . "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " . $access_sql; - $count = $db->query($count_query)->current()->C; + $count = $db->query($count_query)->current()->c; $query = "SELECT {items}.*, MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " . "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " . -- cgit v1.2.3 From c80d2da0a95a63b76f5a4c835f1a0e1022ec2f53 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Tue, 23 Jun 2009 10:09:46 +0200 Subject: Remove an useless ORDER BY. It improves compatibility with PgSQL. --- modules/gallery/models/item.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 7dce9e51..44d79d5b 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -382,8 +382,7 @@ class Item_Model extends ORM_MPTT { SELECT COUNT(*) AS position FROM {items} WHERE parent_id = {$this->id} AND {$this->sort_column} <= (SELECT {$this->sort_column} - FROM {items} WHERE id = $child_id) - ORDER BY {$this->sort_column} {$this->sort_order}"); + FROM {items} WHERE id = $child_id)"); return $result->current()->position; } -- cgit v1.2.3 From d601ab93beb9be2cc69d64fa04803ff3c3601c3a Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Tue, 23 Jun 2009 10:12:09 +0200 Subject: Value stored in comment.state is not 15 char length. Use a VARCHAR instead of a CHAR. It improves compatibility with PgSQL. --- installer/install.sql | 2 +- modules/comment/helpers/comment_installer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 432aee64..b9c56043 100755 --- a/installer/install.sql +++ b/installer/install.sql @@ -55,7 +55,7 @@ CREATE TABLE {comments} ( `server_remote_addr` varchar(32) default NULL, `server_remote_host` varchar(64) default NULL, `server_remote_port` varchar(16) default NULL, - `state` char(15) default 'unpublished', + `state` varchar(15) default 'unpublished', `text` text, `updated` int(9) NOT NULL, PRIMARY KEY (`id`) diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index b1cfcdc0..58bce8e0 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -43,7 +43,7 @@ class comment_installer { `server_remote_addr` varchar(32) default NULL, `server_remote_host` varchar(64) default NULL, `server_remote_port` varchar(16) default NULL, - `state` char(15) default 'unpublished', + `state` varchar(15) default 'unpublished', `text` text, `updated` int(9) NOT NULL, PRIMARY KEY (`id`)) -- cgit v1.2.3 From de28b0350e5d5bf6c3e1eb5a9531298b08fd7cba Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Tue, 23 Jun 2009 10:14:38 +0200 Subject: Use an integer because the code store 0 and 1. It improves compatiblity with PgSQL. The right way is to use a BOOLEAN and code with booleans. The values would be : - FALSE => deny - TRUE => allow - NULL => unknow --- modules/gallery/helpers/access.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index c48f0b79..7b01058c 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -426,7 +426,7 @@ class access_Core { $field = "{$perm_name}_{$group->id}"; $cache_table = $perm_name == "view" ? "items" : "access_caches"; $db->query("ALTER TABLE {{$cache_table}} ADD `$field` SMALLINT NOT NULL DEFAULT 0"); - $db->query("ALTER TABLE {access_intents} ADD `$field` BOOLEAN DEFAULT NULL"); + $db->query("ALTER TABLE {access_intents} ADD `$field` SMALLINT DEFAULT NULL"); $db->update("access_intents", array($field => 0), array("item_id" => 1)); ORM::factory("access_intent")->clear_cache(); } -- cgit v1.2.3 From be354ab98bbb08abad0a7efd6fb1d110e11381de Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Wed, 24 Jun 2009 23:40:47 +0200 Subject: Remove an useless ORDER BY. It improves compatibility with PgSQL. (Replay of c80d2da0a95a63b76f5a4c835f1a0e1022ec2f53) --- modules/gallery/models/item.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 430119b5..7dbbbcb1 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -389,8 +389,7 @@ class Item_Model extends ORM_MPTT { SELECT COUNT(*) AS position FROM {items} WHERE parent_id = {$this->id} AND `{$this->sort_column}` $comp (SELECT `{$this->sort_column}` - FROM {items} WHERE id = $child_id) - ORDER BY `{$this->sort_column}` {$this->sort_order}")->current()->position; + FROM {items} WHERE id = $child_id)")->current()->position; // We stopped short of our target value in the sort (notice that we're using a < comparator // above) because it's possible that we have duplicate values in the sort column. An -- cgit v1.2.3 From 923732ca4dca6db218f6252a7133cd72f98fa086 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Thu, 25 Jun 2009 10:07:12 +0200 Subject: Go back to the upstream version because we choosed to use real booleans. --- modules/gallery/helpers/access.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index 7b01058c..c48f0b79 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -426,7 +426,7 @@ class access_Core { $field = "{$perm_name}_{$group->id}"; $cache_table = $perm_name == "view" ? "items" : "access_caches"; $db->query("ALTER TABLE {{$cache_table}} ADD `$field` SMALLINT NOT NULL DEFAULT 0"); - $db->query("ALTER TABLE {access_intents} ADD `$field` SMALLINT DEFAULT NULL"); + $db->query("ALTER TABLE {access_intents} ADD `$field` BOOLEAN DEFAULT NULL"); $db->update("access_intents", array($field => 0), array("item_id" => 1)); ORM::factory("access_intent")->clear_cache(); } -- cgit v1.2.3 From 14d7797cda340f373e6b2d048155e4d670c8fa68 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 04:35:03 -0700 Subject: In remove_path(), if the path is invalid don't echo it back in the UI. --- modules/server_add/controllers/admin_server_add.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/admin_server_add.php b/modules/server_add/controllers/admin_server_add.php index a3f9aa96..7c39495f 100644 --- a/modules/server_add/controllers/admin_server_add.php +++ b/modules/server_add/controllers/admin_server_add.php @@ -38,10 +38,7 @@ class Admin_Server_Add_Controller extends Admin_Controller { $path = $form->add_path->path->value; $paths[$path] = 1; module::set_var("server_add", "authorized_paths", serialize($paths)); - $form->add_path->inputs->path->value = ""; - message::success(t("Added path %path", array("path" => $path))); - server_add::check_config($paths); url::redirect("admin/server_add"); } else { @@ -61,10 +58,12 @@ class Admin_Server_Add_Controller extends Admin_Controller { $path = $this->input->get("path"); $paths = unserialize(module::get_var("server_add", "authorized_paths")); - unset($paths[$path]); - message::success(t("Removed path %path", array("path" => $path))); - module::set_var("server_add", "authorized_paths", serialize($paths)); - server_add::check_config($paths); + if (isset($paths[$path])) { + unset($paths[$path]); + message::success(t("Removed path %path", array("path" => $path))); + module::set_var("server_add", "authorized_paths", serialize($paths)); + server_add::check_config($paths); + } url::redirect("admin/server_add"); } -- cgit v1.2.3 From c60d7f431dab7b294790b7636257699668a0f91f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 04:37:03 -0700 Subject: ORM::Factory -> ORM::factory --- modules/gallery/helpers/movie.php | 2 +- modules/gallery/helpers/photo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index fcf1cc54..54159294 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -82,7 +82,7 @@ class movie_Core { $movie->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::Factory("item") + while (ORM::factory("item") ->where("parent_id", $parent->id) ->where("name", $movie->name) ->find()->id) { diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index a4bc853b..e8a4f357 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -81,7 +81,7 @@ class photo_Core { $photo->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::Factory("item") + while (ORM::factory("item") ->where("parent_id", $parent->id) ->where("name", $photo->name) ->find()->id) { -- cgit v1.2.3 From d4e976cc53b32122c2047d9b697a9d5155e66937 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 05:06:17 -0700 Subject: Remove empty
    $file_info): ?>
  • "> -- cgit v1.2.3 From 495c76f729372e09f7511967c63948e36303e3d7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 05:11:03 -0700 Subject: Eliminate temporary variables by passing the $item into the view and making API calls on the item. --- modules/server_add/controllers/server_add.php | 4 +--- modules/server_add/views/server_add_tree_dialog.html.php | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index c92b4f7e..4cd3cec7 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -27,9 +27,7 @@ class Server_Add_Controller extends Controller { $item = ORM::factory("item", $id); $view = new View("server_add_tree_dialog.html"); - $view->action = url::abs_site("__ARGS__/{$id}__TASK_ID__?csrf=" . access::csrf_token()); - $view->parents = $item->parents(); - $view->album_title = $item->title; + $view->item = $item; $tree = new View("server_add_tree.html"); $tree->data = array(); diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 8b296987..e2aa5d44 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -7,17 +7,17 @@ });
    -

    p::clean($album_title))) ?>

    +

    p::clean($item->title))) ?>

      - + parents() as $parent): ?>
    • title) ?>
    • -
    • +
    • title) ?>
    - "post")) ?> + "post")) ?>
    -- cgit v1.2.3 From e5b6193b26cf0f8509a98f7913a1d87fa354da05 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 11:23:40 -0700 Subject: Partial pass of server_add cleanup. It's broken at this stage since I've redone the browsing code but I have not implemented the adding code. 1) Rename index() to browse() since index is too generic. 2) Simplify the data that we pass to _dialog and _tree 3) Change _tree to return list items only, so that the outer dialog can be a
      for consistency. 4) Simplify the data structures so that we're not tracking checked vs. unchecked status in the PHP code, it's all done in jquery where we can do it with just a line or two of JS 5) use glob() which pretty much entirely replaces _get_children --- modules/server_add/controllers/server_add.php | 103 +++++++++------------ modules/server_add/helpers/server_add_menu.php | 2 +- modules/server_add/js/server_add.js | 52 +++++++++-- modules/server_add/views/server_add_tree.html.php | 29 +++--- .../views/server_add_tree_dialog.html.php | 25 ++--- 5 files changed, 117 insertions(+), 94 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 4cd3cec7..45ec0a2e 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -18,26 +18,38 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Server_Add_Controller extends Controller { - public function index($id) { - $paths = unserialize(module::get_var("server_add", "authorized_paths")); - + public function browse($id) { if (!user::active()->admin) { access::forbidden(); } + + $paths = unserialize(module::get_var("server_add", "authorized_paths")); + foreach (array_keys($paths) as $path) { + $files[$path] = basename($path); + } + $item = ORM::factory("item", $id); $view = new View("server_add_tree_dialog.html"); $view->item = $item; + $view->tree = new View("server_add_tree.html"); + $view->tree->files = $files; + print $view; + } - $tree = new View("server_add_tree.html"); - $tree->data = array(); - $tree->checked = false; - $tree->tree_id = "tree_$id"; - foreach (array_keys($paths) as $path) { - $tree->data[$path] = array("path" => $path, "is_dir" => true); + private function _validate_path($path) { + if (!is_readable($path) || is_link($path)) { + throw new Exception("@todo BAD_PATH"); } - $view->tree = $tree->__toString(); - print $view; + + $authorized_paths = unserialize(module::get_var("server_add", "authorized_paths")); + foreach (array_keys($authorized_paths) as $valid_path) { + if (strpos($path, $valid_path) === 0) { + return; + } + } + + throw new Exception("@todo BAD_PATH"); } public function children() { @@ -45,31 +57,32 @@ class Server_Add_Controller extends Controller { access::forbidden(); } - $paths = unserialize(module::get_var("server_add", "authorized_paths")); - $path_valid = false; - $path = $this->input->post("path"); - $checked = $this->input->post("checked") == "true"; + $path = $this->input->get("path"); + $this->_validate_path($path); - foreach (array_keys($paths) as $valid_path) { - if ($path_valid = strpos($path, $valid_path) === 0) { - break; + $tree = new View("server_add_tree.html"); + $tree->files = array(); + $tree->tree_id = substr(md5($path), 10); + + foreach (glob("$path/*") as $file) { + if (!is_readable($file)) { + continue; } - } - if (empty($path_valid)) { - throw new Exception("@todo BAD_PATH"); - } - if (!is_readable($path) || is_link($path)) { - kohana::show_404(); - } + if (!is_dir($file)) { + $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); + if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { + continue; + } + } - $tree = new View("server_add_tree.html"); - $tree->data = $this->_get_children($path); - $tree->checked = $checked; - $tree->tree_id = "tree_" . md5($path); + $tree->files[$file] = basename($file); + } print $tree; } + /* ================================================================================ */ + function start($id) { if (!user::active()->admin) { access::forbidden(); @@ -237,36 +250,4 @@ class Server_Add_Controller extends Controller { return $count; } - - private function _get_children($path) { - $directory_list = $file_list = array(); - $files = new DirectoryIterator($path); - foreach ($files as $file) { - if ($file->isDot() || $file->isLink()) { - continue; - } - $filename = $file->getFilename(); - if ($filename[0] != ".") { - if ($file->isDir()) { - $directory_list[$filename] = array("path" => $file->getPathname(), "is_dir" => true); - } else { - $extension = strtolower(substr(strrchr($filename, '.'), 1)); - if ($file->isReadable() && - in_array($extension, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { - $file_list[$filename] = array("path" => $file->getPathname(), "is_dir" => false); - } - } - } - } - - ksort($directory_list); - ksort($file_list); - - // We can't use array_merge here because if a file name is numeric, it will - // get renumbered, so lets do it ourselves - foreach ($file_list as $file => $fileinfo) { - $directory_list[$file] = $fileinfo; - } - return $directory_list; - } } \ No newline at end of file diff --git a/modules/server_add/helpers/server_add_menu.php b/modules/server_add/helpers/server_add_menu.php index 23878913..0f01eb64 100644 --- a/modules/server_add/helpers/server_add_menu.php +++ b/modules/server_add/helpers/server_add_menu.php @@ -38,7 +38,7 @@ class server_add_menu_Core { $server_add = Menu::factory("dialog") ->id("server_add") ->label(t("Add from server")) - ->url(url::site("server_add/index/$item->id")); + ->url(url::site("server_add/browse/$item->id")); $add_photos_item = $menu->get("add_photos_item"); $add_photos_menu = $menu->get("add_photos_menu"); diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index e2526dbe..47340c45 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -1,3 +1,44 @@ +function open_close_branch(path, id) { + var parent = $("#file_" + id); + var children = $("#tree_" + id); + var icon = parent.find(".ui-icon:first"); + + if (!children.html()) { + parent.addClass("gLoadingSmall"); + $.ajax({ + url: GET_CHILDREN_URL.replace("__PATH__", path), + success: function(data, textStatus) { + children.html(data); + parent.removeClass("gLoadingSmall"); + + // Propagate checkbox value + children.find("input[type=checkbox]").attr( + "checked", parent.find("input[type=checkbox]:first").attr("checked")); + }, + }); + } + + children.slideToggle("fast", function() { + if (children.is(":hidden")) { + icon.addClass("ui-icon-plus"); + icon.removeClass("ui-icon-minus"); + } else { + icon.addClass("ui-icon-minus"); + icon.removeClass("ui-icon-plus"); + parent.removeClass("gCollapsed"); + } + }); +} + +function click_node(checkbox) { + var parent = $(checkbox).parents("li").get(0); + var checked = $(checkbox).attr("checked"); + $(parent).find("input[type=checkbox]").attr("checked", checked); +} + +/* ================================================================================ */ + +/* var paused = false; var task = null; @@ -82,16 +123,6 @@ function get_url(uri, task_id) { return url; } -function checkbox_click(checkbox) { - var parent = $(checkbox).parents("li").get(0); - var checked = $(checkbox).attr("checked"); - if (!$(parent).hasClass("gCollapsed")) { - $(parent).find(".gCheckboxTree input[type=checkbox]").attr("checked", checked); - } - var checkboxes = $("#gServerAdd :checkbox[checked]"); - $("#gServerAdd form :submit").attr("disabled", checkboxes.length == 0); -} - function load_children(icon) { $("#gDialog").addClass("gDialogLoadingLarge"); var parent = icon.parentNode; @@ -203,3 +234,4 @@ function display_upload_error(error) { }); } +*/ diff --git a/modules/server_add/views/server_add_tree.html.php b/modules/server_add/views/server_add_tree.html.php index 44f6bfbc..f8205a8b 100644 --- a/modules/server_add/views/server_add_tree.html.php +++ b/modules/server_add/views/server_add_tree.html.php @@ -1,12 +1,19 @@ -
        - $file_info): ?> -
      • "> - - - - - -
      • - -
      + $name): ?> + +
    • "> + + + + + + + +
    • + + +
    • + diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index e2aa5d44..6e4db620 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -1,26 +1,29 @@ - +

      p::clean($item->title))) ?>

        parents() as $parent): ?> -
      • title) ?>
      • +
      • + title) ?> +
      • -
      • title) ?>
      • +
      • + title) ?> +
      - "post")) ?> -
      + "post")) ?> + +
        -
      +
    + "gServerPauseButton", "name" => "add", "disabled" => true, "class" => "submit", "style" => "display:none"), t("Pause")) ?> "gServerAddButton", "name" => "add", "disabled" => true, "class" => "submit"), t("Add")) ?> -- cgit v1.2.3 From a619bb81966102a9f684dd8d37f1127b4f16a390 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 11:30:21 -0700 Subject: Add some jsDoc. --- modules/server_add/js/server_add.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules') diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index 47340c45..918bd14b 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -1,3 +1,7 @@ +/** + * We've clicked the + icon next to a directory. Load up children of this + * directory from the server and display them. + */ function open_close_branch(path, id) { var parent = $("#file_" + id); var children = $("#tree_" + id); @@ -30,6 +34,9 @@ function open_close_branch(path, id) { }); } +/** + * We've clicked a checkbox. Propagate the value downwards as necessary. + */ function click_node(checkbox) { var parent = $(checkbox).parents("li").get(0); var checked = $(checkbox).attr("checked"); -- cgit v1.2.3 From d4075a4657eddcf1aca71de9996a421cd577ec36 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 11:49:45 -0700 Subject: Only enable the [add] button when boxes are checked. --- modules/server_add/js/server_add.js | 8 ++++++++ modules/server_add/views/server_add_tree_dialog.html.php | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index 918bd14b..ada09d65 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -41,6 +41,14 @@ function click_node(checkbox) { var parent = $(checkbox).parents("li").get(0); var checked = $(checkbox).attr("checked"); $(parent).find("input[type=checkbox]").attr("checked", checked); + + if ($("#gServerAddTree").find("input[type=checkbox]").is(":checked")) { + $("#gServerAddAddButton").attr("disabled", true); + $("#gServerAddAddButton").removeClass("ui-state-disabled"); + } else { + $("#gServerAddAddButton").attr("disabled", false); + $("#gServerAddAddButton").addClass("ui-state-disabled"); + } } /* ================================================================================ */ diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 6e4db620..723d388e 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -25,8 +25,10 @@
- "gServerPauseButton", "name" => "add", "disabled" => true, "class" => "submit", "style" => "display:none"), t("Pause")) ?> - "gServerAddButton", "name" => "add", "disabled" => true, "class" => "submit"), t("Add")) ?> + " style="display: none"> + "> -- cgit v1.2.3 From 1cd321901b7225e0297ee4b14a9f7234e09748e3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 13:02:26 -0700 Subject: Properly manage disabled state for the [add] button. --- modules/server_add/js/server_add.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index ada09d65..32176108 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -43,10 +43,10 @@ function click_node(checkbox) { $(parent).find("input[type=checkbox]").attr("checked", checked); if ($("#gServerAddTree").find("input[type=checkbox]").is(":checked")) { - $("#gServerAddAddButton").attr("disabled", true); + $("#gServerAddAddButton").enable(true); $("#gServerAddAddButton").removeClass("ui-state-disabled"); } else { - $("#gServerAddAddButton").attr("disabled", false); + $("#gServerAddAddButton").enable(false); $("#gServerAddAddButton").addClass("ui-state-disabled"); } } -- cgit v1.2.3 From 9eee3b07a8abb1cd798372a20725290130ec183f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 17:54:22 -0700 Subject: @todo if we uncheck all the children for a parent, we should uncheck the parent itself, otherwise in the code we'll add the entire parent since if we find an album as a leaf, we assume that it's never been expanded in the UI. --- modules/server_add/js/server_add.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules') diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index 32176108..568ef91f 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -42,6 +42,9 @@ function click_node(checkbox) { var checked = $(checkbox).attr("checked"); $(parent).find("input[type=checkbox]").attr("checked", checked); + // @todo if we uncheck all the children for a parent, we should uncheck the + // parent itself, otherwise in the code we'll add the entire parent since if + // we find an album as a leaf, we assume that it's never been expanded in the UI. if ($("#gServerAddTree").find("input[type=checkbox]").is(":checked")) { $("#gServerAddAddButton").enable(true); $("#gServerAddAddButton").removeClass("ui-state-disabled"); -- cgit v1.2.3 From 1a5fe42b555d51d22bde1521100a31d2b434486b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 17:54:48 -0700 Subject: Temporary version add() that just dumps out the values for now. --- modules/server_add/controllers/server_add.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 45ec0a2e..2204b338 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -81,6 +81,29 @@ class Server_Add_Controller extends Controller { print $tree; } + public function add() { + if (!user::active()->admin) { + access::forbidden(); + } + access::verify_csrf(); + + $authorized_paths = unserialize(module::get_var("server_add", "authorized_paths")); + + // The paths we receive are full pathnames. Convert that into a tree structure to save space + // in our task. + foreach (Input::instance()->post("path") as $path) { + if (is_dir($path)) { + $dirs[$path] = array(); + } else if (is_file($path)) { + $dir = dirname($path); + $file = basename($path); + $dirs[$dir][] = $file; + } + } + + Kohana::log("alert",print_r($dirs,1)); + } + /* ================================================================================ */ function start($id) { -- cgit v1.2.3 From 67e61d30e5ae22a8c01d76d8e202ead443ae19d4 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Tue, 7 Jul 2009 13:08:35 -0700 Subject: More fixes for ticket 470 (capitalization of reCAPTCHA) --- modules/recaptcha/libraries/Form_Recaptcha.php | 2 +- modules/recaptcha/views/admin_recaptcha.html.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/recaptcha/libraries/Form_Recaptcha.php b/modules/recaptcha/libraries/Form_Recaptcha.php index 4c0c4997..f4e9d4ac 100644 --- a/modules/recaptcha/libraries/Form_Recaptcha.php +++ b/modules/recaptcha/libraries/Form_Recaptcha.php @@ -28,7 +28,7 @@ class Form_Recaptcha_Core extends Form_Input { public function __construct($name) { parent::__construct($name); $this->error_messages("incorrect-captcha-sol", - t("The values supplied to recaptcha are incorrect.")); + t("The values supplied to reCAPTCHA are incorrect.")); $this->error_messages("invalid-site-private-key", t("The site private key is incorrect.")); } diff --git a/modules/recaptcha/views/admin_recaptcha.html.php b/modules/recaptcha/views/admin_recaptcha.html.php index 9c2911ef..43b4da8a 100644 --- a/modules/recaptcha/views/admin_recaptcha.html.php +++ b/modules/recaptcha/views/admin_recaptcha.html.php @@ -14,7 +14,7 @@

- +

-- cgit v1.2.3 From faabae5dae712ebff656abe8ebc493d8e031d4a3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 7 Jul 2009 21:16:36 -0700 Subject: Rework server_add. It's smaller and leaner now, storing the list of files out in a separate model for scalability. Removed the "pause" functionality. - Server_Add_Controller extends Admin_Controller so that we don't have to check for admin every time. - Task completion time now factors in the time it takes to walk the arbitrarily deep trees - Moved checkbox management entirely into JS using jQuery - Simplified the JS considerably --- modules/server_add/controllers/server_add.php | 348 ++++++++++----------- modules/server_add/helpers/server_add.php | 15 + .../server_add/helpers/server_add_installer.php | 22 +- modules/server_add/helpers/server_add_task.php | 85 ----- modules/server_add/js/server_add.js | 222 ++----------- modules/server_add/models/server_add_file.php | 21 ++ modules/server_add/module.info | 2 +- .../views/server_add_tree_dialog.html.php | 23 +- 8 files changed, 266 insertions(+), 472 deletions(-) delete mode 100644 modules/server_add/helpers/server_add_task.php create mode 100644 modules/server_add/models/server_add_file.php (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index e2b1b01a..288e6342 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -17,13 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class Server_Add_Controller extends Controller { +class Server_Add_Controller extends Admin_Controller { public function browse($id) { - if (!user::active()->admin) { - access::forbidden(); - } - - $paths = unserialize(module::get_var("server_add", "authorized_paths")); foreach (array_keys($paths) as $path) { $files[$path] = basename($path); @@ -37,28 +32,11 @@ class Server_Add_Controller extends Controller { print $view; } - private function _validate_path($path) { - if (!is_readable($path) || is_link($path)) { - throw new Exception("@todo BAD_PATH"); - } - - $authorized_paths = unserialize(module::get_var("server_add", "authorized_paths")); - foreach (array_keys($authorized_paths) as $valid_path) { - if (strpos($path, $valid_path) === 0) { - return; - } - } - - throw new Exception("@todo BAD_PATH"); - } - public function children() { - if (!user::active()->admin) { - access::forbidden(); - } - $path = $this->input->get("path"); - $this->_validate_path($path); + if (!server_add::is_valid_path($path)) { + throw new Exception("@todo BAD_PATH"); + } $tree = new View("server_add_tree.html"); $tree->files = array(); @@ -81,196 +59,194 @@ class Server_Add_Controller extends Controller { print $tree; } - public function add() { - if (!user::active()->admin) { - access::forbidden(); - } + public function start() { access::verify_csrf(); - $authorized_paths = unserialize(module::get_var("server_add", "authorized_paths")); + $item = ORM::factory("item", Input::instance()->get("item_id")); + // We're an admin so this isn't necessary, but we'll eventually open this up to non-admins and + // this also verifies that the item was loaded properly. + access::required("edit", $item); - // The paths we receive are full pathnames. Convert that into a tree structure to save space - // in our task. - foreach (Input::instance()->post("path") as $path) { + // Gather up all the paths and associate them by directory, so that we can locate any empty + // directories for the next round. + foreach (Input::instance()->post("paths") as $path) { if (is_dir($path)) { - $dirs[$path] = array(); + $selections[$path] = array(); } else if (is_file($path)) { - $dir = dirname($path); - $file = basename($path); - $dirs[$dir][] = $file; + $selections[dirname($path)][] = $path; } } - Kohana::log("alert",print_r($dirs,1)); - } - - /* ================================================================================ */ - - function start($id) { - if (!user::active()->admin) { - access::forbidden(); - } - access::verify_csrf(); - - $item = ORM::factory("item", $id); - $paths = unserialize(module::get_var("server_add", "authorized_paths")); - $input_files = $this->input->post("path"); - $collapsed = $this->input->post("collapsed"); - $files = array(); - $total_count = 0; - foreach (array_keys($paths) as $valid_path) { - $path_length = strlen($valid_path); - foreach ($input_files as $key => $path) { - if (!empty($path)) { - if ($valid_path != $path && strpos($path, $valid_path) === 0) { - $relative_path = substr(dirname($path), $path_length); - $name = basename($path); - $files[$valid_path][] = array("path" => $relative_path, - "parent_id" => $id, "name" => basename($path), - "type" => is_dir($path) ? "album" : "file"); - $total_count++; - } - if ($collapsed[$key] === "true") { - $total_count += $this->_select_children($id, $valid_path, $path, $files[$valid_path]); - } - unset($input_files[$key]); - unset($collapsed[$key]); - } - } - } - - if ($total_count == 0) { - print json_encode(array("result" => "success", - "url" => "", - "task" => array( - "id" => -1, "done" => 1, "percent_complete" => 100, - "status" => t("No eligible files, import cancelled")))); - return; - } - $task_def = Task_Definition::factory() - ->callback("server_add_task::add_from_server") + ->callback("Server_Add_Controller::add") ->description(t("Add photos or movies from the local server")) ->name(t("Add from server")); - $task = task::create($task_def, array("item_id" => $id, "next_path" => 0, "files" => $files, - "counter" => 0, "position" => 0, "total" => $total_count)); + $task = task::create( + $task_def, array("item_id" => $item->id, "selections" => $selections)); - batch::start(); - print json_encode(array("result" => "started", - "url" => url::site("server_add/add_photo/{$task->id}?csrf=" . - access::csrf_token()), - "task" => array( - "id" => $task->id, - "percent_complete" => $task->percent_complete, - "status" => $task->status, - "done" => $task->done))); + print json_encode( + array("result" => "started", + "url" => url::site("server_add/run/$task->id?csrf=" . access::csrf_token()))); } - function add_photo($task_id) { - if (!user::active()->admin) { - access::forbidden(); - } + function run($task_id) { access::verify_csrf(); - $task = task::run($task_id); - // @todo the task is already run... its a little late to check the access - if (!$task->loaded || $task->owner_id != user::active()->id) { - access::forbidden(); - } - - if ($task->done) { - switch ($task->state) { - case "success": - message::success(t("Add from server completed")); - break; - - case "error": - message::warning(t("Add from server completed with errors")); - break; - } - print json_encode(array("result" => "success", - "task" => array( - "id" => $task->id, - "percent_complete" => $task->percent_complete, - "status" => $task->status, - "done" => $task->done))); - - } else { - print json_encode(array("result" => "in_progress", - "task" => array( - "id" => $task->id, - "percent_complete" => $task->percent_complete, - "status" => $task->status, - "done" => $task->done))); - } - } - - public function finish($id, $task_id) { - if (!user::active()->admin) { - access::forbidden(); - } - access::verify_csrf(); $task = ORM::factory("task", $task_id); - if (!$task->loaded || $task->owner_id != user::active()->id) { access::forbidden(); } - if (!$task->done) { - message::warning(t("Add from server was cancelled prior to completion")); - } - - batch::stop(); - print json_encode(array("result" => "success")); + $task = task::run($task_id); + print json_encode(array("done" => $task->done, + "percent_complete" => $task->percent_complete)); } - public function pause($id, $task_id) { - if (!user::active()->admin) { - access::forbidden(); - } - access::verify_csrf(); - $task = ORM::factory("task", $task_id); - if (!$task->loaded || $task->owner_id != user::active()->id) { - access::forbidden(); - } - - message::warning(t("Add from server was cancelled prior to completion")); - batch::stop(); - print json_encode(array("result" => "success")); - } + /** + * This is the task code that adds photos and albums. It first examines all the target files + * and creates a set of Server_Add_File_Models, then runs through the list of models and adds + * them one at a time. + */ + static function add($task) { + $selections = $task->get("selections"); + $mode = $task->get("mode", "init"); + $start = microtime(true); + $item_id = $task->get("item_id"); + + switch ($mode) { + case "init": + $task->set("mode", "build-file-list"); + $task->set("queue", array_keys($selections)); + $task->percent_complete = 0; + batch::start(); + break; + + case "build-file-list": /* 0% to 10% */ + // We can't fit an arbitrary number of paths in a task, so store them in a separate table. + // Don't use an iterator here because we can't get enough control over it when we're dealing + // with a deep hierarchy and we don't want to go over our time quota. + $queue = $task->get("queue"); + Kohana::log("alert",print_r($queue,1)); + while ($queue && microtime(true) - $start < 0.5) { + $file = array_shift($queue); + $entry = ORM::factory("server_add_file"); + $entry->task_id = $task->id; + $entry->file = $file; + $entry->save(); + + if (is_dir($file)) { + $queue = array_merge( + $queue, empty($selections[$file]) ? glob("$file/*") : $selections[$file]); + } + } + // We have no idea how long this can take because we have no idea how deep the tree + // hierarchy rabbit hole goes. Leave ourselves room here for 100 iterations and don't go + // over 10% in percent_complete. + $task->set("queue", $queue); + $task->percent_complete = min($task->percent_complete + 0.1, 10); + + if (!$queue) { + $task->set("mode", "add-files"); + $task->set( + "total_files", database::instance()->count_records( + "server_add_files", array("task_id" => $task->id))); + $task->set("albums", array()); + $task->set("completed", 0); + $task->percent_complete = 10; + } + break; + + case "add-files": /* 10% to 100% */ + $completed_files = $task->get("completed_files"); + $total_files = $task->get("total_files"); + $albums = $task->get("albums"); + + // Ordering by id ensures that we add them in the order that we created the entries, which + // will create albums first. + $entries = ORM::factory("server_add_file") + ->where("task_id", $task->id) + ->orderby("id", "ASC") + ->limit(10) + ->find_all(); + if ($entries->count() == 0) { + $task->set("mode", "done"); + } - private function _select_children($id, $valid_path, $path, &$files) { - $count = 0; - $children = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($path), - RecursiveIteratorIterator::SELF_FIRST); + $item = model_cache::get("item", $item_id); + foreach ($entries as $entry) { + if (microtime(true) - $start > 0.5) { + break; + } - $path_length = strlen($valid_path); - foreach($children as $name => $file){ - if ($file->isLink()) { - continue; - } - $filename = $file->getFilename(); - if ($filename[0] != ".") { - if ($file->isDir()) { - $relative_path = substr(dirname($file->getPathname()), $path_length); - $files[] = array("path" => $relative_path, - "parent_id" => $id, "name" => $filename, "type" => "album"); - $count++; + $relative_path = self::_relative_path($entry->file); + $name = basename($relative_path); + $title = item::convert_filename_to_title($name); + if (is_dir($entry->file)) { + if (isset($albums[$relative_path]) && $parent_id = $albums[$relative_path]) { + $parent = ORM::factory("item", $parent_id); + } else { + $album = album::create($item, $name, $title, null, user::active()->id); + $albums[$relative_path] = $album->id; + $task->set("albums", $albums); + } } else { - $extension = strtolower(substr(strrchr($filename, '.'), 1)); - if ($file->isReadable() && - in_array($extension, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { - $relative_path = substr(dirname($file->getPathname()), $path_length); - $files[] = array("path" => $relative_path, - "parent_id" => $id, "name" => $filename, "type" => "file"); - $count++; + if (strpos($relative_path, "/") !== false) { + $parent = ORM::factory("item", $albums[dirname($relative_path)]); + } else { + $parent = $item; + } + + $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION)); + if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) { + photo::create($parent, $entry->file, $name, $title, null, user::active()->id); + } else if (in_array($extension, array("flv", "mp4"))) { + movie::create($parent, $entry->file, $name, $title, null, user::active()->id); + } else { + // Unsupported type + // @todo: $task->log this } } + + $completed_files++; + $entry->delete(); } + $task->set("completed_files", $completed_files); + $task->percent_complete = 10 + 100 * ($completed_files / $total_files); + Kohana::log("alert",print_r($task->as_array(),1)); + break; + + case "done": + batch::stop(); + $task->done = true; + $task->state = "success"; + $task->percent_complete = 100; + message::info(t2("Successfully added one photo", + "Successfully added %count photos", + $task->get("completed_files"))); + } + } + /** + * Given a path that's somewhere in our authorized_paths list, return just the part that's + * relative to the nearest authorized path. + */ + static function _relative_path($path) { + static $authorized_paths; + // @todo this doesn't deal well with overlapping authorized paths, it'll just use the first one + // that matches. If we sort $authorized_paths by length in descending order, that should take + // care of the problem. + if (!$authorized_paths) { + $authorized_paths = + array_keys(unserialize(module::get_var("server_add", "authorized_paths"))); + } + + foreach ($authorized_paths as $candidate) { + $candidate = dirname($candidate); + if (strpos($path, $candidate) === 0) { + return substr($path, strlen($candidate) + 1); + } } - return $count; + throw new Exception("@todo BAD_PATH"); } -} \ No newline at end of file +} diff --git a/modules/server_add/helpers/server_add.php b/modules/server_add/helpers/server_add.php index f75a09d2..74f51ad9 100644 --- a/modules/server_add/helpers/server_add.php +++ b/modules/server_add/helpers/server_add.php @@ -31,4 +31,19 @@ class server_add_Core { site_status::clear("server_add_configuration"); } } + + static function is_valid_path($path) { + if (!is_readable($path) || is_link($path)) { + return false; + } + + $authorized_paths = unserialize(module::get_var("server_add", "authorized_paths")); + foreach (array_keys($authorized_paths) as $valid_path) { + if (strpos($path, $valid_path) === 0) { + return true; + } + } + + return false; + } } diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php index c9d92e69..6956a72c 100644 --- a/modules/server_add/helpers/server_add_installer.php +++ b/modules/server_add/helpers/server_add_installer.php @@ -19,10 +19,30 @@ */ class server_add_installer { static function install() { - module::set_version("server_add", 1); + $db = Database::instance(); + $db->query("CREATE TABLE {server_add_files} ( + `id` int(9) NOT NULL auto_increment, + `task_id` int(9) NOT NULL, + `file` varchar(255) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + module::set_version("server_add", 2); server_add::check_config(); } + static function upgrade($version) { + $db = Database::instance(); + if ($version == 1) { + $db->query("CREATE TABLE {server_add_files} ( + `id` int(9) NOT NULL auto_increment, + `task_id` int(9) NOT NULL, + `file` varchar(255) NOT NULL, + PRIMARY KEY (`id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + module::set_version("server_add", $version = 2); + } + } + static function deactivate() { site_status::clear("server_add_configuration"); } diff --git a/modules/server_add/helpers/server_add_task.php b/modules/server_add/helpers/server_add_task.php deleted file mode 100644 index 0482b47c..00000000 --- a/modules/server_add/helpers/server_add_task.php +++ /dev/null @@ -1,85 +0,0 @@ -context); - try { - $paths = array_keys(unserialize(module::get_var("server_add", "authorized_paths"))); - $path = $paths[$context["next_path"]]; - if (!empty($context["files"][$path])) { - $file = $context["files"][$path][$context["position"]]; - $parent = ORM::factory("item", $file["parent_id"]); - access::required("add", $parent); - if (!$parent->is_album()) { - throw new Exception("@todo BAD_ALBUM"); - } - - $name = $file["name"]; - if ($file["type"] == "album") { - $album = ORM::factory("item") - ->where("name", $name) - ->where("parent_id", $parent->id) - ->find(); - if (!$album->loaded) { - $album = album::create($parent, $name, $name, null, user::active()->id); - } - // Now that we have a new album. Go through the remaining files to import and change the - // parent_id of any file that has the same relative path as this album's path. - $album_path = "{$file['path']}/$name"; - for ($idx = $context["position"] + 1; $idx < count($context["files"][$path]); $idx++) { - if (strpos($context["files"][$path][$idx]["path"], $album_path) === 0) { - $context["files"][$path][$idx]["parent_id"] = $album->id; - } - } - } else { - $extension = strtolower(substr(strrchr($name, '.'), 1)); - $source_path = "$path{$file['path']}/$name"; - $title = item::convert_filename_to_title($name); - if (in_array($extension, array("flv", "mp4"))) { - $movie = movie::create($parent, $source_path, $name, $title, - null, user::active()->id); - } else { - $photo = photo::create($parent, $source_path, $name, $title, - null, user::active()->id); - } - } - - $context["counter"]++; - if (++$context["position"] >= count($context["files"][$path])) { - $context["next_path"]++; - $context["position"] = 0; - } - } else { - $context["next_path"]++; - } - } catch(Exception $e) { - $context["errors"][$path] = $e->getMessage(); - } - $task->context = serialize($context); - $task->state = "success"; - $task->percent_complete = ($context["counter"] / (float)$context["total"]) * 100; - $task->done = $context["counter"] == (float)$context["total"]; - } -} \ No newline at end of file diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index 568ef91f..cba8c9ce 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -12,13 +12,13 @@ function open_close_branch(path, id) { $.ajax({ url: GET_CHILDREN_URL.replace("__PATH__", path), success: function(data, textStatus) { - children.html(data); - parent.removeClass("gLoadingSmall"); + children.html(data); + parent.removeClass("gLoadingSmall"); - // Propagate checkbox value - children.find("input[type=checkbox]").attr( - "checked", parent.find("input[type=checkbox]:first").attr("checked")); - }, + // Propagate checkbox value + children.find("input[type=checkbox]").attr( + "checked", parent.find("input[type=checkbox]:first").attr("checked")); + } }); } @@ -54,202 +54,38 @@ function click_node(checkbox) { } } -/* ================================================================================ */ - -/* -var paused = false; -var task = null; - -$("#gServerAdd").ready(function() { - init_server_add_form(); -}); - -function init_server_add_form() { - $("#gServerAdd #gServerAddButton").click(function(event) { - do_add(this, event); - }); - $("#gServerAdd #gServerPauseButton").click(function(event) { - event.preventDefault(); - paused = true; - }); - $(".gProgressBar").progressbar(); - $("#gServerAddTree ul").css("display", "block"); - $("#gServerAdd form").bind("form_closing", function(target) { - if (task != null && !task.done) { - $.ajax({async: false, - success: function(data, textStatus) { - document.location.reload(); - }, - dataType: "json", - type: "POST", - url: get_url("server_add/pause", task.id) - }); - } else { - document.location.reload(); - } - }); - set_click_events(); -} - -function set_click_events() { - $(".ui-icon").unbind("click"); - $(":checkbox").unbind("click"); - $(".ui-icon").click(function(event) { - open_close_branch(this, event); - }); - - $("input[type=checkbox]").click(function(event) { - checkbox_click(this); +function start_add() { + var paths = []; + $.each($("#gServerAdd :checkbox[checked]"), function () { + paths.push(this.value); }); -} - -function open_close_branch(icon, event) { - var parent = icon.parentNode; - var closed = $(icon).hasClass("ui-icon-plus"); - var children = $(parent).find(".gCheckboxTree"); - - if (closed) { - if (children.length == 0) { - load_children(icon); - } else { - toggle_branch("open", icon); - } - } else { - toggle_branch("close", icon); - } -} - -function toggle_branch(direction, icon) { - var parent = icon.parentNode; - var branch = $(parent).children(".gServerAddChildren"); - $(branch).slideToggle("fast", function() { - if (direction == "open") { - $(icon).addClass("ui-icon-minus"); - $(icon).removeClass("ui-icon-plus"); - $(parent).removeClass("gCollapsed"); - } else { - $(icon).addClass("ui-icon-plus"); - $(icon).removeClass("ui-icon-minus"); + $.ajax({ + url: START_URL, + type: "POST", + async: false, + data: { "paths[]": paths }, + dataType: "json", + success: function(data, textStatus) { + $("#gServerAdd .gProgressBar").progressbar("value", data.percent_complete); + setTimeout(function() { run_add(data.url); }, 0); } }); + return false; } -function get_url(uri, task_id) { - var url = $("#gServerAdd form").attr("action"); - url = url.replace("__ARGS__", uri); - url = url.replace("__TASK_ID__", !task_id ? "" : "/" + task_id); - return url; -} - -function load_children(icon) { - $("#gDialog").addClass("gDialogLoadingLarge"); - var parent = icon.parentNode; - var checkbox = $(parent).find("input[type=checkbox]"); - var parms = "&path=" + $(checkbox).attr("value"); - parms += "&checked=" + $(checkbox).is(":checked"); - parms += "&collapsed=" + $(parent).hasClass("gCollapsed"); - - $.ajax({success: function(data, textStatus) { - $(parent).children(".gServerAddChildren").html(data); - set_click_events(); - $("#gDialog").removeClass("gDialogLoadingLarge"); - toggle_branch("open", icon); - }, - data: parms, - dataType: "html", - type: "POST", - url: get_url("server_add/children") - }); -} - -function do_add(submit, event) { - event.preventDefault(); - - $("#gServerAdd #gServerAddButton").hide(); - $("#gServerAdd #gServerPauseButton").show(); - - var parms = ""; - if (!paused) { - $(".gProgressBar").progressbar("value", 0); - $(".gProgressBar").css("visibility", "visible"); - var check_list = $("#gServerAdd :checkbox[checked]"); - - var paths = ""; - var collapsed = ""; - $.each(check_list, function () { - var parent = $(this).parents("li")[0]; - paths += "&path[]=" + this.value; - collapsed += "&collapsed[]=" + $(parent).hasClass("gCollapsed"); - }); - parms = paths + collapsed; - } - paused = false; - - $.ajax({async: false, - data: parms, +function run_add(url) { + $.ajax({ + url: url, + async: false, dataType: "json", success: function(data, textStatus) { - var done = data.task.done; - if (done) { - task = null; - $("body").append("
" + data.task.status + "
"); - - $("#gNoFilesDialog").dialog({modal: true, - autoOpen: true, - title: FILE_IMPORT_WARNING}); - $(".gProgressBar").css("visibility", "hidden"); - $("#gServerAdd #gServerAddButton").show(); - $("#gServerAdd #gServerPauseButton").hide(); - return; - } - task = data.task; - var url = data.url; - while (!done && !paused) { - $.ajax({async: false, - success: function(data, textStatus) { - $(".gProgressBar").progressbar("value", data.task.percent_complete); - done = data.task.done; - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - paused = true; - display_upload_error(XMLHttpRequest.responseText); - }, - dataType: "json", - type: "POST", - url: url - }); - } - if (!paused) { - $.ajax({async: false, - success: function(data, textStatus) { - document.location.reload(); - }, - dataType: "json", - type: "POST", - url: get_url("server_add/finish", task.id) - }); + $("#gServerAdd .gProgressBar").progressbar("value", data.percent_complete); + if (data.done) { + $("#gServerAdd .gProgressBar").slideUp(); } else { - $("#gServerAdd #gServerAddButton").show(); - $("#gServerAdd #gServerPauseButton").hide(); + setTimeout(function() { run_add(url); }, 0); } - }, - type: "POST", - url: get_url("server_add/start") + } }); - - return false; -} - -function display_upload_error(error) { - $("body").append("
" + error + "
"); - $("#gServerAddError").dialog({ - autoOpen: true, - autoResize: false, - modal: true, - resizable: true, - width: 610, - height: $("#gDialog").height() - }); } -*/ diff --git a/modules/server_add/models/server_add_file.php b/modules/server_add/models/server_add_file.php new file mode 100644 index 00000000..8b1ed924 --- /dev/null +++ b/modules/server_add/models/server_add_file.php @@ -0,0 +1,21 @@ +
@@ -18,18 +19,28 @@ - "post")) ?> + id"), array("method" => "post")) ?>
+ + - " style="display: none"> - "> + "> - +
-- cgit v1.2.3 From 2852161ca31f1a5b90bfd16a14615dd1812bd78a Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 7 Jul 2009 21:49:54 -0700 Subject: Provide some clarity on the action links by formating them as buttons on the Maintenance Tasks admin page. --- modules/gallery/views/admin_maintenance.html.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index eecc045c..501daa0b 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -161,22 +161,23 @@ done): ?> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" class="gButtonLink ui-state-default ui-corner-all"> get_log()): ?> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" class="gDialogLink gButtonLink ui-state-default ui-corner-all"> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" class="gDialogLink gButtonLink" ui-state-default ui-corner-all> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" class="gButtonLink ui-state-default ui-corner-all"> + -- cgit v1.2.3 From 47fbb56fa25fc98d4e0695ed08b7fbaec916c003 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 08:22:40 -0700 Subject: Added task logging to the Rebuild Images task. --- modules/gallery/helpers/gallery_task.php | 83 ++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 35 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index 1152cda2..c673411d 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -45,50 +45,63 @@ class gallery_task_Core { * @param Task_Model the task */ static function rebuild_dirty_images($task) { - $result = graphics::find_dirty_images_query(); - $completed = $task->get("completed", 0); - $ignored = $task->get("ignored", array()); - $remaining = $result->count() - count($ignored); - - $i = 0; - foreach ($result as $row) { - if (array_key_exists($row->id, $ignored)) { - continue; - } + try { + $result = graphics::find_dirty_images_query(); + $completed = $task->get("completed", 0); + $ignored = $task->get("ignored", array()); + $remaining = $result->count() - count($ignored); + + $i = 0; + foreach ($result as $row) { + if (array_key_exists($row->id, $ignored)) { + continue; + } - $item = ORM::factory("item", $row->id); - if ($item->loaded) { - $success = graphics::generate($item); - if (!$success) { - $ignored[$item->id] = 1; + $item = ORM::factory("item", $row->id); + if ($item->loaded) { + $success = graphics::generate($item); + if (!$success) { + $ignored[$item->id] = 1; + $message = t("Unable to rebuild images for '%title'", + array("title" => p::purify($item->title))); + } else { + $message = t("Successfully rebuilt images for '%title'", + array("title" => p::purify($item->title))); + } + $task->log($message); } - } - $completed++; - $remaining--; + $completed++; + $remaining--; - if (++$i == 2) { - break; + if (++$i == 2) { + break; + } } - } - $task->status = t2("Updated: 1 image. Total: %total_count.", - "Updated: %count images. Total: %total_count.", - $completed, - array("total_count" => ($remaining + $completed))); + $task->status = t2("Updated: 1 image. Total: %total_count.", + "Updated: %count images. Total: %total_count.", + $completed, + array("total_count" => ($remaining + $completed))); - if ($completed + $remaining > 0) { - $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); - } else { - $task->percent_complete = 100; - } + if ($completed + $remaining > 0) { + $task->percent_complete = (int)(100 * $completed / ($completed + $remaining)); + } else { + $task->percent_complete = 100; + } - $task->set("completed", $completed); - $task->set("ignored", $ignored); - if ($remaining == 0) { + $task->set("completed", $completed); + $task->set("ignored", $ignored); + if ($remaining == 0) { + $task->done = true; + $task->state = "success"; + site_status::clear("graphics_dirty"); + } + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - site_status::clear("graphics_dirty"); + $task->state = "error"; + $task->status = $e->getMessage(); + $task->log($e->__toString()); } } -- cgit v1.2.3 From 9f00e734ed28f9c359fa52cfc4694ead5e4cf84e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 08:26:14 -0700 Subject: Added the button formatting to the other links on the Admin Maintenance page. --- modules/gallery/views/admin_maintenance.html.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index 501daa0b..cd1cc02e 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -29,7 +29,7 @@ callback?csrf=$csrf") ?>" - class="gDialogLink"> + class="gDialogLink gButtonLink ui-icon-left ui-state-default ui-corner-all"> @@ -94,11 +94,13 @@ state == "stalled"): ?> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>"> - id?csrf=$csrf") ?>"> + id?csrf=$csrf") ?>" + class="gButtonLink ui-icon-left ui-state-default ui-corner-all right"> -- cgit v1.2.3 From 43c63362575264f473e8bba3345524fa7e58afe1 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 08:37:40 -0700 Subject: Add Task logging to the Extract EXIF data task --- modules/exif/helpers/exif_task.php | 65 ++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php index 375503e3..649ad092 100644 --- a/modules/exif/helpers/exif_task.php +++ b/modules/exif/helpers/exif_task.php @@ -38,37 +38,48 @@ class exif_task_Core { } static function update_index($task) { - $completed = $task->get("completed", 0); + try { + $completed = $task->get("completed", 0); - $start = microtime(true); - foreach (ORM::factory("item") - ->join("exif_records", "items.id", "exif_records.item_id", "left") - ->where("type", "photo") - ->open_paren() - ->where("exif_records.item_id", null) - ->orwhere("exif_records.dirty", 1) - ->close_paren() - ->find_all() as $item) { - if (microtime(true) - $start > 1.5) { - break; - } + $start = microtime(true); + $message = array(); + foreach (ORM::factory("item") + ->join("exif_records", "items.id", "exif_records.item_id", "left") + ->where("type", "photo") + ->open_paren() + ->where("exif_records.item_id", null) + ->orwhere("exif_records.dirty", 1) + ->close_paren() + ->find_all() as $item) { + if (microtime(true) - $start > 1.5) { + break; + } - $completed++; - exif::extract($item); - } + $completed++; + exif::extract($item); + $message[] = t("Updated Exif meta data for '%title'", + array("title" => p::purify($item->title))); + } - list ($remaining, $total, $percent) = exif::stats(); - $task->set("completed", $completed); - if ($remaining == 0 || !($remaining + $completed)) { + $task->log($message); + list ($remaining, $total, $percent) = exif::stats(); + $task->set("completed", $completed); + if ($remaining == 0 || !($remaining + $completed)) { + $task->done = true; + $task->state = "success"; + site_status::clear("exif_index_out_of_date"); + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + } + $task->status = t2("one record updated, index is %percent% up-to-date", + "%count records updated, index is %percent% up-to-date", + $completed, array("percent" => $percent)); + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - site_status::clear("exif_index_out_of_date"); - $task->percent_complete = 100; - } else { - $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + $task->state = "error"; + $task->status = $e->getMessage(); + $task->log($e->__toString()); } - $task->status = t2("one record updated, index is %percent% up-to-date", - "%count records updated, index is %percent% up-to-date", - $completed, array("percent" => $percent)); } } -- cgit v1.2.3 From ac797e609c8c319ca77f9b746a7cecad8dd69004 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 09:08:15 -0700 Subject: Add task logging to the Update translations --- modules/gallery/helpers/gallery_task.php | 150 ++++++++++++++++--------------- modules/gallery/helpers/l10n_client.php | 9 +- 2 files changed, 84 insertions(+), 75 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php index c673411d..9ce2c4a0 100644 --- a/modules/gallery/helpers/gallery_task.php +++ b/modules/gallery/helpers/gallery_task.php @@ -45,6 +45,7 @@ class gallery_task_Core { * @param Task_Model the task */ static function rebuild_dirty_images($task) { + $message = array(); try { $result = graphics::find_dirty_images_query(); $completed = $task->get("completed", 0); @@ -62,13 +63,12 @@ class gallery_task_Core { $success = graphics::generate($item); if (!$success) { $ignored[$item->id] = 1; - $message = t("Unable to rebuild images for '%title'", + $message[] = t("Unable to rebuild images for '%title'", array("title" => p::purify($item->title))); } else { - $message = t("Successfully rebuilt images for '%title'", + $message[] = t("Successfully rebuilt images for '%title'", array("title" => p::purify($item->title))); } - $task->log($message); } $completed++; @@ -101,88 +101,98 @@ class gallery_task_Core { $task->done = true; $task->state = "error"; $task->status = $e->getMessage(); - $task->log($e->__toString()); + $message[] = $e->__toString(); } + $task->log($message); } static function update_l10n(&$task) { - $start = microtime(true); - $dirs = $task->get("dirs"); - $files = $task->get("files"); - $cache = $task->get("cache", array()); - $i = 0; - - switch ($task->get("mode", "init")) { - case "init": // 0% - $dirs = array("gallery", "modules", "themes", "installer"); - $files = array(); - $task->set("mode", "find_files"); - $task->status = t("Finding files"); - break; - - case "find_files": // 0% - 10% - while (($dir = array_pop($dirs)) && microtime(true) - $start < 0.5) { - if (in_array(basename($dir), array("tests", "lib"))) { - continue; - } + $message = array(); + try { + $start = microtime(true); + $dirs = $task->get("dirs"); + $files = $task->get("files"); + $cache = $task->get("cache", array()); + $i = 0; - foreach (glob(DOCROOT . "$dir/*") as $path) { - $relative_path = str_replace(DOCROOT, "", $path); - if (is_dir($path)) { - $dirs[] = $relative_path; - } else { - $files[] = $relative_path; + switch ($task->get("mode", "init")) { + case "init": // 0% + $dirs = array("gallery", "modules", "themes", "installer"); + $files = array(); + $task->set("mode", "find_files"); + $task->status = t("Finding files"); + break; + + case "find_files": // 0% - 10% + while (($dir = array_pop($dirs)) && microtime(true) - $start < 0.5) { + if (in_array(basename($dir), array("tests", "lib"))) { + continue; } - } - } - $task->status = t2("Finding files: found 1 file", - "Finding files: found %count files", count($files)); + foreach (glob(DOCROOT . "$dir/*") as $path) { + $relative_path = str_replace(DOCROOT, "", $path); + if (is_dir($path)) { + $dirs[] = $relative_path; + } else { + $files[] = $relative_path; + } + } + } - if (!$dirs) { - $task->set("mode", "scan_files"); - $task->set("total_files", count($files)); - $task->status = t("Scanning files"); - $task->percent_complete = 10; - } - break; - - case "scan_files": // 10% - 90% - while (($file = array_pop($files)) && microtime(true) - $start < 0.5) { - $file = DOCROOT . $file; - switch (pathinfo($file, PATHINFO_EXTENSION)) { - case "php": - l10n_scanner::scan_php_file($file, $cache); - break; + $message[] = $task->status = t2("Finding files: found 1 file", + "Finding files: found %count files", count($files)); - case "info": - l10n_scanner::scan_info_file($file, $cache); - break; + if (!$dirs) { + $task->set("mode", "scan_files"); + $task->set("total_files", count($files)); + $task->status = t("Scanning files"); + $task->percent_complete = 10; + } + break; + + case "scan_files": // 10% - 90% + while (($file = array_pop($files)) && microtime(true) - $start < 0.5) { + $file = DOCROOT . $file; + switch (pathinfo($file, PATHINFO_EXTENSION)) { + case "php": + l10n_scanner::scan_php_file($file, $cache); + break; + + case "info": + l10n_scanner::scan_info_file($file, $cache); + break; + } } - } - $total_files = $task->get("total_files"); - $task->status = t2("Scanning files: scanned 1 file", - "Scanning files: scanned %count files", $total_files - count($files)); + $total_files = $task->get("total_files"); + $message[] = $task->status = t2("Scanning files: scanned 1 file", + "Scanning files: scanned %count files", $total_files - count($files)); - $task->percent_complete = 10 + 80 * ($total_files - count($files)) / $total_files; - if (empty($files)) { - $task->set("mode", "fetch_updates"); - $task->status = t("Fetching updates"); - $task->percent_complete = 90; + $task->percent_complete = 10 + 80 * ($total_files - count($files)) / $total_files; + if (empty($files)) { + $task->set("mode", "fetch_updates"); + $task->status = t("Fetching updates"); + $task->percent_complete = 90; + } + break; + + case "fetch_updates": // 90% - 100% + $message = array_merge($message, l10n_client::fetch_updates()); + $task->done = true; + $task->state = "success"; + $task->status = t("Translations installed/updated"); + $task->percent_complete = 100; } - break; - case "fetch_updates": // 90% - 100% - l10n_client::fetch_updates(); + $task->set("files", $files); + $task->set("dirs", $dirs); + $task->set("cache", $cache); + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - $task->status = t("Translations installed/updated"); - $task->percent_complete = 100; + $task->state = "error"; + $task->status = $e->getMessage(); + $message[] = $e->__toString(); } - - $task->set("files", $files); - $task->set("dirs", $dirs); - $task->set("cache", $cache); + $task->log($message); } } \ No newline at end of file diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index e153532c..5b14abec 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -101,8 +101,7 @@ class l10n_client_Core { throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED " . $response_status); } if (empty($response_data)) { - log::info("translations", "Translations fetch request resulted in an empty response"); - return; + return array(t("Translations fetch request resulted in an empty response")); } $response = json_decode($response_data); @@ -112,9 +111,8 @@ class l10n_client_Core { // {key:, ...} // ] $count = count($response); - log::info("translations", - t2("Installed 1 new / updated translation message", - "Installed %count new / updated translation messages", $count)); + $message[] = t2("Installed 1 new / updated translation message", + "Installed %count new / updated translation messages", $count); foreach ($response as $message_data) { // @todo Better input validation @@ -152,6 +150,7 @@ class l10n_client_Core { $entry->translation = $translation; $entry->save(); } + return $message; } static function submit_translations() { -- cgit v1.2.3 From 6ac5238b83d58824eb9327406a2ee50b7e603214 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 8 Jul 2009 09:27:37 -0700 Subject: Add task logging to the "Update Search Index" task --- modules/gallery/helpers/l10n_client.php | 3 ++ modules/search/helpers/search.php | 4 +++ modules/search/helpers/search_task.php | 56 +++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 24 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 5b14abec..6d4da0eb 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -67,6 +67,9 @@ class l10n_client_Core { return true; } + /** + * @return an array of messages that will be written to the task log + */ static function fetch_updates() { $request->locales = array(); $request->messages = new stdClass(); diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index ea8dad81..34eaecbd 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -50,6 +50,9 @@ class search_Core { return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } + /** + * @return string An error message suitable for inclusion in the task log + */ static function check_index() { list ($remaining) = search::stats(); if ($remaining) { @@ -76,6 +79,7 @@ class search_Core { $record->data = join(" ", $data); $record->dirty = 0; $record->save(); + return t("Search index updated for '%title'", array("title" => p::purify($item->title))); } static function stats() { diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 876661e4..395bcd98 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -39,34 +39,42 @@ class search_task_Core { } static function update_index($task) { - $completed = $task->get("completed", 0); + try { + $completed = $task->get("completed", 0); - $start = microtime(true); - foreach (ORM::factory("item") - ->join("search_records", "items.id", "search_records.item_id", "left") - ->where("search_records.item_id", null) - ->orwhere("search_records.dirty", 1) - ->find_all() as $item) { - if (microtime(true) - $start > 1.5) { - break; - } + $start = microtime(true); + foreach (ORM::factory("item") + ->join("search_records", "items.id", "search_records.item_id", "left") + ->where("search_records.item_id", null) + ->orwhere("search_records.dirty", 1) + ->find_all() as $item) { + if (microtime(true) - $start > 1.5) { + break; + } - search::update($item); - $completed++; - } + $message[] = search::update($item); + $completed++; + } - list ($remaining, $total, $percent) = search::stats(); - $task->set("completed", $completed); - if ($remaining == 0 || !($remaining + $completed)) { + list ($remaining, $total, $percent) = search::stats(); + $task->set("completed", $completed); + if ($remaining == 0 || !($remaining + $completed)) { + $task->done = true; + $task->state = "success"; + site_status::clear("search_index_out_of_date"); + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + } + $task->status = t2("one record updated, index is %percent% up-to-date", + "%count records updated, index is %percent% up-to-date", + $completed, array("percent" => $percent)); + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - site_status::clear("search_index_out_of_date"); - $task->percent_complete = 100; - } else { - $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + $task->state = "error"; + $task->status = $e->getMessage(); + $message[] = $e->__toString(); } - $task->status = t2("one record updated, index is %percent% up-to-date", - "%count records updated, index is %percent% up-to-date", - $completed, array("percent" => $percent)); + $task->log($message); } } -- cgit v1.2.3 From b1f9eb1d12fbb9acb97ece2333c21ab76d909101 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 19:37:03 +0800 Subject: ORM::Factory -> ORM::factory Signed-off-by: Tim Almdal --- modules/gallery/helpers/movie.php | 2 +- modules/gallery/helpers/photo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index fcf1cc54..54159294 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -82,7 +82,7 @@ class movie_Core { $movie->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::Factory("item") + while (ORM::factory("item") ->where("parent_id", $parent->id) ->where("name", $movie->name) ->find()->id) { diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index a4bc853b..e8a4f357 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -81,7 +81,7 @@ class photo_Core { $photo->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::Factory("item") + while (ORM::factory("item") ->where("parent_id", $parent->id) ->where("name", $photo->name) ->find()->id) { -- cgit v1.2.3 From 1a587fd01686cf603b2c7eefd406cf200c6e0ee1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 2 Jul 2009 20:11:03 +0800 Subject: Eliminate temporary variables by passing the $item into the view and making API calls on the item. Signed-off-by: Tim Almdal --- modules/server_add/controllers/server_add.php | 4 +--- modules/server_add/views/server_add_tree_dialog.html.php | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 05ea5058..b0c47660 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -27,9 +27,7 @@ class Server_Add_Controller extends Controller { $item = ORM::factory("item", $id); $view = new View("server_add_tree_dialog.html"); - $view->action = url::abs_site("__ARGS__/{$id}__TASK_ID__?csrf=" . access::csrf_token()); - $view->parents = $item->parents(); - $view->album_title = $item->title; + $view->item = $item; $tree = new View("server_add_tree.html"); $tree->data = array(); diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 8b296987..e2aa5d44 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -7,17 +7,17 @@ });
-

p::clean($album_title))) ?>

+

p::clean($item->title))) ?>

    - + parents() as $parent): ?>
  • title) ?>
  • -
  • +
  • title) ?>
- "post")) ?> + "post")) ?>
-- cgit v1.2.3 From 5118afc959650469874733a1060fbe22364d8c28 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 08:39:00 -0700 Subject: Revert "Add task logging to the "Update Search Index" task" This reverts commit 6ac5238b83d58824eb9327406a2ee50b7e603214. --- modules/gallery/helpers/l10n_client.php | 3 -- modules/search/helpers/search.php | 4 --- modules/search/helpers/search_task.php | 56 ++++++++++++++------------------- 3 files changed, 24 insertions(+), 39 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 6d4da0eb..5b14abec 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -67,9 +67,6 @@ class l10n_client_Core { return true; } - /** - * @return an array of messages that will be written to the task log - */ static function fetch_updates() { $request->locales = array(); $request->messages = new stdClass(); diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 34eaecbd..ea8dad81 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -50,9 +50,6 @@ class search_Core { return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } - /** - * @return string An error message suitable for inclusion in the task log - */ static function check_index() { list ($remaining) = search::stats(); if ($remaining) { @@ -79,7 +76,6 @@ class search_Core { $record->data = join(" ", $data); $record->dirty = 0; $record->save(); - return t("Search index updated for '%title'", array("title" => p::purify($item->title))); } static function stats() { diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 395bcd98..876661e4 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -39,42 +39,34 @@ class search_task_Core { } static function update_index($task) { - try { - $completed = $task->get("completed", 0); + $completed = $task->get("completed", 0); - $start = microtime(true); - foreach (ORM::factory("item") - ->join("search_records", "items.id", "search_records.item_id", "left") - ->where("search_records.item_id", null) - ->orwhere("search_records.dirty", 1) - ->find_all() as $item) { - if (microtime(true) - $start > 1.5) { - break; - } - - $message[] = search::update($item); - $completed++; + $start = microtime(true); + foreach (ORM::factory("item") + ->join("search_records", "items.id", "search_records.item_id", "left") + ->where("search_records.item_id", null) + ->orwhere("search_records.dirty", 1) + ->find_all() as $item) { + if (microtime(true) - $start > 1.5) { + break; } - list ($remaining, $total, $percent) = search::stats(); - $task->set("completed", $completed); - if ($remaining == 0 || !($remaining + $completed)) { - $task->done = true; - $task->state = "success"; - site_status::clear("search_index_out_of_date"); - $task->percent_complete = 100; - } else { - $task->percent_complete = round(100 * $completed / ($remaining + $completed)); - } - $task->status = t2("one record updated, index is %percent% up-to-date", - "%count records updated, index is %percent% up-to-date", - $completed, array("percent" => $percent)); - } catch (Exception $e) { + search::update($item); + $completed++; + } + + list ($remaining, $total, $percent) = search::stats(); + $task->set("completed", $completed); + if ($remaining == 0 || !($remaining + $completed)) { $task->done = true; - $task->state = "error"; - $task->status = $e->getMessage(); - $message[] = $e->__toString(); + $task->state = "success"; + site_status::clear("search_index_out_of_date"); + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / ($remaining + $completed)); } - $task->log($message); + $task->status = t2("one record updated, index is %percent% up-to-date", + "%count records updated, index is %percent% up-to-date", + $completed, array("percent" => $percent)); } } -- cgit v1.2.3 From 703d93a1eac6d6332361067ffd74b697149c1feb Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 08:42:32 -0700 Subject: Revert "ORM::Factory -> ORM::factory" This reverts commit b1f9eb1d12fbb9acb97ece2333c21ab76d909101. --- modules/gallery/helpers/movie.php | 2 +- modules/gallery/helpers/photo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 54159294..fcf1cc54 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -82,7 +82,7 @@ class movie_Core { $movie->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::factory("item") + while (ORM::Factory("item") ->where("parent_id", $parent->id) ->where("name", $movie->name) ->find()->id) { diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index e8a4f357..a4bc853b 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -81,7 +81,7 @@ class photo_Core { $photo->rand_key = ((float)mt_rand()) / (float)mt_getrandmax(); // Randomize the name if there's a conflict - while (ORM::factory("item") + while (ORM::Factory("item") ->where("parent_id", $parent->id) ->where("name", $photo->name) ->find()->id) { -- cgit v1.2.3 From 724d2af960c55b5a60b3c5e6bf68585426d46ab0 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 08:42:54 -0700 Subject: Revert "Eliminate temporary variables by passing the $item into the view and" This reverts commit 1a587fd01686cf603b2c7eefd406cf200c6e0ee1. --- modules/server_add/controllers/server_add.php | 4 +++- modules/server_add/views/server_add_tree_dialog.html.php | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index b0c47660..05ea5058 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -27,7 +27,9 @@ class Server_Add_Controller extends Controller { $item = ORM::factory("item", $id); $view = new View("server_add_tree_dialog.html"); - $view->item = $item; + $view->action = url::abs_site("__ARGS__/{$id}__TASK_ID__?csrf=" . access::csrf_token()); + $view->parents = $item->parents(); + $view->album_title = $item->title; $tree = new View("server_add_tree.html"); $tree->data = array(); diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index e2aa5d44..8b296987 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -7,17 +7,17 @@ });
-

p::clean($item->title))) ?>

+

p::clean($album_title))) ?>

    - parents() as $parent): ?> +
  • title) ?>
  • -
  • title) ?>
  • +
- "post")) ?> + "post")) ?>
-- cgit v1.2.3 From e7e2d99255259a708999727ae3a56777898a3426 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 9 Jul 2009 08:43:42 -0700 Subject: Revert "Revert "Add task logging to the "Update Search Index" task"" This reverts commit 5118afc959650469874733a1060fbe22364d8c28. --- modules/gallery/helpers/l10n_client.php | 3 ++ modules/search/helpers/search.php | 4 +++ modules/search/helpers/search_task.php | 56 +++++++++++++++++++-------------- 3 files changed, 39 insertions(+), 24 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 5b14abec..6d4da0eb 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -67,6 +67,9 @@ class l10n_client_Core { return true; } + /** + * @return an array of messages that will be written to the task log + */ static function fetch_updates() { $request->locales = array(); $request->messages = new stdClass(); diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index ea8dad81..34eaecbd 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -50,6 +50,9 @@ class search_Core { return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query))); } + /** + * @return string An error message suitable for inclusion in the task log + */ static function check_index() { list ($remaining) = search::stats(); if ($remaining) { @@ -76,6 +79,7 @@ class search_Core { $record->data = join(" ", $data); $record->dirty = 0; $record->save(); + return t("Search index updated for '%title'", array("title" => p::purify($item->title))); } static function stats() { diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 876661e4..395bcd98 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -39,34 +39,42 @@ class search_task_Core { } static function update_index($task) { - $completed = $task->get("completed", 0); + try { + $completed = $task->get("completed", 0); - $start = microtime(true); - foreach (ORM::factory("item") - ->join("search_records", "items.id", "search_records.item_id", "left") - ->where("search_records.item_id", null) - ->orwhere("search_records.dirty", 1) - ->find_all() as $item) { - if (microtime(true) - $start > 1.5) { - break; - } + $start = microtime(true); + foreach (ORM::factory("item") + ->join("search_records", "items.id", "search_records.item_id", "left") + ->where("search_records.item_id", null) + ->orwhere("search_records.dirty", 1) + ->find_all() as $item) { + if (microtime(true) - $start > 1.5) { + break; + } - search::update($item); - $completed++; - } + $message[] = search::update($item); + $completed++; + } - list ($remaining, $total, $percent) = search::stats(); - $task->set("completed", $completed); - if ($remaining == 0 || !($remaining + $completed)) { + list ($remaining, $total, $percent) = search::stats(); + $task->set("completed", $completed); + if ($remaining == 0 || !($remaining + $completed)) { + $task->done = true; + $task->state = "success"; + site_status::clear("search_index_out_of_date"); + $task->percent_complete = 100; + } else { + $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + } + $task->status = t2("one record updated, index is %percent% up-to-date", + "%count records updated, index is %percent% up-to-date", + $completed, array("percent" => $percent)); + } catch (Exception $e) { $task->done = true; - $task->state = "success"; - site_status::clear("search_index_out_of_date"); - $task->percent_complete = 100; - } else { - $task->percent_complete = round(100 * $completed / ($remaining + $completed)); + $task->state = "error"; + $task->status = $e->getMessage(); + $message[] = $e->__toString(); } - $task->status = t2("one record updated, index is %percent% up-to-date", - "%count records updated, index is %percent% up-to-date", - $completed, array("percent" => $percent)); + $task->log($message); } } -- cgit v1.2.3 From b0429797fc7db5464717deffebdccc9705ca7820 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Jul 2009 10:00:16 -0700 Subject: Use p::purify instead of p::clean --- modules/server_add/views/server_add_tree_dialog.html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 8b13001f..0d56df7b 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -5,17 +5,17 @@
-

p::clean($item->title))) ?>

+

p::purify($item->title))) ?>

    parents() as $parent): ?>
  • - title) ?> + title) ?>
  • - title) ?> + title) ?>
-- cgit v1.2.3 From 31ffb82382d76390f1206944329dde86c687349c Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 01:35:51 +0800 Subject: Remove the reference to organize.css is it is no longer used and is producing errors in the log. Signed-off-by: Tim Almdal --- modules/organize/helpers/organize_theme.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules') diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php index 02f1f589..1c75e819 100644 --- a/modules/organize/helpers/organize_theme.php +++ b/modules/organize/helpers/organize_theme.php @@ -22,6 +22,5 @@ class organize_theme { // @tdo remove the addition css and organize.js (just here to test) $theme->script("modules/organize/js/organize_init.js"); $theme->script("modules/organize/js/organize.js"); - $theme->css("modules/organize/css/organize.css"); } } -- cgit v1.2.3 From fad6c4783ebec8591e1b61bddcc7bd5f17d8cf0e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Jul 2009 10:46:27 -0700 Subject: Add status output to make it clearer what's happening when you add files. --- modules/server_add/controllers/server_add.php | 13 +++++++++++-- modules/server_add/js/server_add.js | 4 +++- modules/server_add/views/server_add_tree_dialog.html.php | 9 ++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 288e6342..638a4d63 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -86,6 +86,7 @@ class Server_Add_Controller extends Admin_Controller { print json_encode( array("result" => "started", + "status" => $task->status, "url" => url::site("server_add/run/$task->id?csrf=" . access::csrf_token()))); } @@ -99,6 +100,7 @@ class Server_Add_Controller extends Admin_Controller { $task = task::run($task_id); print json_encode(array("done" => $task->done, + "status" => $task->status, "percent_complete" => $task->percent_complete)); } @@ -117,6 +119,7 @@ class Server_Add_Controller extends Admin_Controller { case "init": $task->set("mode", "build-file-list"); $task->set("queue", array_keys($selections)); + $task->status = t("Starting up"); $task->percent_complete = 0; batch::start(); break; @@ -126,7 +129,6 @@ class Server_Add_Controller extends Admin_Controller { // Don't use an iterator here because we can't get enough control over it when we're dealing // with a deep hierarchy and we don't want to go over our time quota. $queue = $task->get("queue"); - Kohana::log("alert",print_r($queue,1)); while ($queue && microtime(true) - $start < 0.5) { $file = array_shift($queue); $entry = ORM::factory("server_add_file"); @@ -144,6 +146,10 @@ class Server_Add_Controller extends Admin_Controller { // over 10% in percent_complete. $task->set("queue", $queue); $task->percent_complete = min($task->percent_complete + 0.1, 10); + $task->status = t2("Found one file", "Found %count files", + Database::instance() + ->where("task_id", $task->id) + ->count_records("server_add_files")); if (!$queue) { $task->set("mode", "add-files"); @@ -202,6 +208,7 @@ class Server_Add_Controller extends Admin_Controller { } else if (in_array($extension, array("flv", "mp4"))) { movie::create($parent, $entry->file, $name, $title, null, user::active()->id); } else { + $task->log("Skipping unknown file type: $relative_path"); // Unsupported type // @todo: $task->log this } @@ -211,8 +218,10 @@ class Server_Add_Controller extends Admin_Controller { $entry->delete(); } $task->set("completed_files", $completed_files); + $task->status = t("Adding photos (%completed of %total)", + array("completed" => $completed_files, + "total" => $total_files)); $task->percent_complete = 10 + 100 * ($completed_files / $total_files); - Kohana::log("alert",print_r($task->as_array(),1)); break; case "done": diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index cba8c9ce..1a78d733 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -66,6 +66,7 @@ function start_add() { data: { "paths[]": paths }, dataType: "json", success: function(data, textStatus) { + $("#gStatus").html(data.status); $("#gServerAdd .gProgressBar").progressbar("value", data.percent_complete); setTimeout(function() { run_add(data.url); }, 0); } @@ -79,9 +80,10 @@ function run_add(url) { async: false, dataType: "json", success: function(data, textStatus) { + $("#gStatus").html(data.status); $("#gServerAdd .gProgressBar").progressbar("value", data.percent_complete); if (data.done) { - $("#gServerAdd .gProgressBar").slideUp(); + $("#gProgress").slideUp(); } else { setTimeout(function() { run_add(url); }, 0); } diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 0d56df7b..bbad4e69 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -25,7 +25,10 @@ - + -- cgit v1.2.3 From 6fbb1e2dafdaa51c1a8fd5479819ff787c758c59 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Jul 2009 14:03:07 -0700 Subject: Avoid blowing the task data column by only adding directories to the queue instead of directories and files. --- modules/server_add/controllers/server_add.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 638a4d63..cf7077a8 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -131,14 +131,21 @@ class Server_Add_Controller extends Admin_Controller { $queue = $task->get("queue"); while ($queue && microtime(true) - $start < 0.5) { $file = array_shift($queue); - $entry = ORM::factory("server_add_file"); - $entry->task_id = $task->id; - $entry->file = $file; - $entry->save(); - if (is_dir($file)) { - $queue = array_merge( - $queue, empty($selections[$file]) ? glob("$file/*") : $selections[$file]); + $children = empty($selections[$file]) ? glob("$file/*") : $selections[$file]; + } else { + $children = array($file); + } + + foreach ($children as $child) { + $entry = ORM::factory("server_add_file"); + $entry->task_id = $task->id; + $entry->file = $child; + $entry->save(); + + if (is_dir($child)) { + $queue[] = $child; + } } } // We have no idea how long this can take because we have no idea how deep the tree @@ -218,7 +225,7 @@ class Server_Add_Controller extends Admin_Controller { $entry->delete(); } $task->set("completed_files", $completed_files); - $task->status = t("Adding photos (%completed of %total)", + $task->status = t("Adding photos and albums (%completed of %total)", array("completed" => $completed_files, "total" => $total_files)); $task->percent_complete = 10 + 100 * ($completed_files / $total_files); -- cgit v1.2.3 From b1f93f358ab717ccd66ceadd51801fb0bc0db82f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 9 Jul 2009 16:18:39 -0700 Subject: Fix typo in p::purify() call. --- modules/notification/views/item_added.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/notification/views/item_added.html.php b/modules/notification/views/item_added.html.php index 87ea90fa..86724927 100644 --- a/modules/notification/views/item_added.html.php +++ b/modules/notification/views/item_added.html.php @@ -8,7 +8,7 @@ - + -- cgit v1.2.3 From 1475b772bd256238e7e5e8c0985daede9e18a16f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 08:18:58 +0800 Subject: Change the tag importer to convert spaces to a dot in multi word tags. Signed-off-by: Tim Almdal --- modules/g2_import/helpers/g2_import.php | 4 +++- 1 file changed, 3 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 d67d4c04..66787467 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -623,8 +623,10 @@ class g2_import_Core { } $tags = ""; + // Multiword tags have the space changed to dots.s foreach ($tag_names as $tag_name) { - $tags .= (strlen($tags) ? ", " : "") . tag::add($g3_item, $tag_name); + $tags .= (strlen($tags) ? ", " : "") . + tag::add($g3_item, preg_replace('/\s\s+/', '.', $tag_name)); } // Tag operations are idempotent so we don't need to map them. Which is good because we don't -- cgit v1.2.3 From 7862e8b02ddd41eb68e858278cd909c8ff371550 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 09:59:04 +0800 Subject: Created the dynamic albums module which provides a dynamic album containing either recent updates or most viewed images. Signed-off-by: Tim Almdal --- modules/dynamic/controllers/admin_dynamic.php | 79 ++++++++++++++++++++++ modules/dynamic/controllers/dynamic.php | 94 +++++++++++++++++++++++++++ modules/dynamic/helpers/dynamic_installer.php | 46 +++++++++++++ modules/dynamic/helpers/dynamic_menu.php | 27 ++++++++ modules/dynamic/helpers/dynamic_theme.php | 39 +++++++++++ modules/dynamic/module.info | 3 + modules/dynamic/views/admin_dynamic.html.php | 5 ++ modules/dynamic/views/dynamic_block.html.php | 10 +++ 8 files changed, 303 insertions(+) create mode 100644 modules/dynamic/controllers/admin_dynamic.php create mode 100644 modules/dynamic/controllers/dynamic.php create mode 100644 modules/dynamic/helpers/dynamic_installer.php create mode 100644 modules/dynamic/helpers/dynamic_menu.php create mode 100644 modules/dynamic/helpers/dynamic_theme.php create mode 100644 modules/dynamic/module.info create mode 100644 modules/dynamic/views/admin_dynamic.html.php create mode 100644 modules/dynamic/views/dynamic_block.html.php (limited to 'modules') diff --git a/modules/dynamic/controllers/admin_dynamic.php b/modules/dynamic/controllers/admin_dynamic.php new file mode 100644 index 00000000..f559e3d2 --- /dev/null +++ b/modules/dynamic/controllers/admin_dynamic.php @@ -0,0 +1,79 @@ +_get_view(); + } + + public function handler() { + access::verify_csrf(); + + $form = $this->_get_form(); + if ($form->validate()) { + foreach (array("updates", "popular") as $album) { + $album_defn = unserialize(module::get_var("dynamic", $album)); + $album_defn->enabled = $form->$album->enabled->value; + $album_defn->description = $form->$album->description->value; + $album_defn->limit = $form->$album->limit->value === "" ? null : $form->$album->limit->value; + module::set_var("dynamic", $album, serialize($album_defn)); + } + + message::success(t("Dynamic Albums Configured")); + + url::redirect("admin/dynamic"); + } + + print $this->_get_view($form); + } + + private function _get_view($form=null) { + $v = new Admin_View("admin.html"); + $v->content = new View("admin_dynamic.html"); + $v->content->form = empty($form) ? $this->_get_form() : $form; + return $v; + } + + private function _get_form() { + + $form = new Forge("admin/dynamic/handler", "", "post", + array("id" => "gAdminForm")); + + foreach (array("updates", "popular") as $album) { + $album_defn = unserialize(module::get_var("dynamic", $album)); + + $group = $form->group($album)->label(t($album_defn->title)); + $group->checkbox("enabled") + ->label(t("Enable")) + ->value(1) + ->checked($album_defn->enabled); + $group->input("limit") + ->label(t("Limit (leave empty for unlimited)")) + ->value(empty($updates->limit) ? "" : $updates->limit) + ->rules("valid_numeric"); + $group->textarea("description") + ->label(t("Description")) + ->rules("length[0,2048]") + ->value($album_defn->description); + } + + $form->submit("submit")->value(t("Submit")); + + return $form; + } +} \ No newline at end of file diff --git a/modules/dynamic/controllers/dynamic.php b/modules/dynamic/controllers/dynamic.php new file mode 100644 index 00000000..b1fde2ac --- /dev/null +++ b/modules/dynamic/controllers/dynamic.php @@ -0,0 +1,94 @@ +input->get("page", "1"); + + $children_count = ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->count_all(); + $offset = ($page-1) * $page_size; + print $children_count; + + $max_pages = ceil($children_count / $page_size); + print $max_pages; + + // Make sure that the page references a valid offset + if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) { + Kohana::show_404(); + } + + $template = new Theme_View("page.html", "dynamic"); + $template->set_global("page_size", $page_size); + $template->set_global("children", ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->orderby("created", "DESC") + ->find_all($page_size, $offset)); + $template->set_global("children_count", $children_count); + $template->content = new View("dynamic.html"); + $template->content->title = t("Recent Updates"); + + print $template; + print $this->_show("updates"); + } + + public function popular() { + print $this->_show("popular"); + } + + private function _show($album) { + $page_size = module::get_var("gallery", "page_size", 9); + $page = $this->input->get("page", "1"); + + $album_defn = unserialize(module::get_var("dynamic", $album)); + $children_count = $album_defn->limit; + if (empty($children_count)) { + $children_count = ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->count_all(); + } + + $offset = ($page-1) * $page_size; + + $max_pages = ceil($children_count / $page_size); + + // Make sure that the page references a valid offset + if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) { + Kohana::show_404(); + } + + $template = new Theme_View("page.html", "dynamic"); + $template->set_global("page_size", $page_size); + $template->set_global("children", ORM::factory("item") + ->viewable() + ->where("type !=", "album") + ->orderby($album_defn->key_field, "DESC") + ->find_all($page_size, $offset)); + $template->set_global("children_count", $children_count); + $template->content = new View("dynamic.html"); + $template->content->title = t($album_defn->title); + + print $template; + } + +} \ No newline at end of file diff --git a/modules/dynamic/helpers/dynamic_installer.php b/modules/dynamic/helpers/dynamic_installer.php new file mode 100644 index 00000000..8780864b --- /dev/null +++ b/modules/dynamic/helpers/dynamic_installer.php @@ -0,0 +1,46 @@ + false, + "limit" => null, + "description" => "", + "key_field" => "view_count", + "title" => t("Most Viewed")))); + module::set_var("dynamic", "updates", + serialize((object)array("enabled" => false, + "limit" => null, + "description" => "", + "key_field" => "created", + "title" => t("Recent Updates")))); + module::set_version("dynamic", 1); + } + } + + static function upgrade($version) { + } + + static function uninstall() { + /* @todo Put database table drops here */ + module::delete("dynamic"); + } +} diff --git a/modules/dynamic/helpers/dynamic_menu.php b/modules/dynamic/helpers/dynamic_menu.php new file mode 100644 index 00000000..b2c73d6f --- /dev/null +++ b/modules/dynamic/helpers/dynamic_menu.php @@ -0,0 +1,27 @@ +get("content_menu") + ->append(Menu::factory("link") + ->id("dynamic_menu") + ->label(t("Dynamic Albums")) + ->url(url::site("admin/dynamic"))); + } +} diff --git a/modules/dynamic/helpers/dynamic_theme.php b/modules/dynamic/helpers/dynamic_theme.php new file mode 100644 index 00000000..ba355098 --- /dev/null +++ b/modules/dynamic/helpers/dynamic_theme.php @@ -0,0 +1,39 @@ +enabled) { + $albums[$album] = $album_defn->title; + } + } + if (!empty($albums)) { + $block = new Block(); + $block->css_id = "gDynamic"; + $block->title = t("Dynamic Albums"); + $block->content = new View("dynamic_block.html"); + $block->content->albums = $albums; + return $block; + } + return ""; + } + +} diff --git a/modules/dynamic/module.info b/modules/dynamic/module.info new file mode 100644 index 00000000..4167df4b --- /dev/null +++ b/modules/dynamic/module.info @@ -0,0 +1,3 @@ +name = Dynamic +description = Dynamic album +version = 1 diff --git a/modules/dynamic/views/admin_dynamic.html.php b/modules/dynamic/views/admin_dynamic.html.php new file mode 100644 index 00000000..cd7ccfea --- /dev/null +++ b/modules/dynamic/views/admin_dynamic.html.php @@ -0,0 +1,5 @@ + +
+

+ +
diff --git a/modules/dynamic/views/dynamic_block.html.php b/modules/dynamic/views/dynamic_block.html.php new file mode 100644 index 00000000..d14c2900 --- /dev/null +++ b/modules/dynamic/views/dynamic_block.html.php @@ -0,0 +1,10 @@ + +
+
    + $text): ?> +
  • + "> +
  • + +
+
-- cgit v1.2.3 From 4b28f7f50e0901ee3abe864a3881ff11d08a73ce Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 10:15:14 +0800 Subject: A few minor changes to add to the dynamic albums module 1) cleanun the two displays of the recent changes page 2) change the name to recent changes. 3) Change the description in module.info Not quite ready for prime time, some issues with the limit to be resolved Signed-off-by: Tim Almdal --- modules/dynamic/controllers/dynamic.php | 30 --------------------------- modules/dynamic/helpers/dynamic_installer.php | 2 +- modules/dynamic/module.info | 2 +- 3 files changed, 2 insertions(+), 32 deletions(-) (limited to 'modules') diff --git a/modules/dynamic/controllers/dynamic.php b/modules/dynamic/controllers/dynamic.php index b1fde2ac..6b5f2915 100644 --- a/modules/dynamic/controllers/dynamic.php +++ b/modules/dynamic/controllers/dynamic.php @@ -18,36 +18,6 @@ */ class Dynamic_Controller extends Controller { public function updates() { - $page_size = module::get_var("gallery", "page_size", 9); - $page = $this->input->get("page", "1"); - - $children_count = ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->count_all(); - $offset = ($page-1) * $page_size; - print $children_count; - - $max_pages = ceil($children_count / $page_size); - print $max_pages; - - // Make sure that the page references a valid offset - if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) { - Kohana::show_404(); - } - - $template = new Theme_View("page.html", "dynamic"); - $template->set_global("page_size", $page_size); - $template->set_global("children", ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->orderby("created", "DESC") - ->find_all($page_size, $offset)); - $template->set_global("children_count", $children_count); - $template->content = new View("dynamic.html"); - $template->content->title = t("Recent Updates"); - - print $template; print $this->_show("updates"); } diff --git a/modules/dynamic/helpers/dynamic_installer.php b/modules/dynamic/helpers/dynamic_installer.php index 8780864b..66d6298d 100644 --- a/modules/dynamic/helpers/dynamic_installer.php +++ b/modules/dynamic/helpers/dynamic_installer.php @@ -31,7 +31,7 @@ class dynamic_installer { "limit" => null, "description" => "", "key_field" => "created", - "title" => t("Recent Updates")))); + "title" => t("Recent Changes")))); module::set_version("dynamic", 1); } } diff --git a/modules/dynamic/module.info b/modules/dynamic/module.info index 4167df4b..aa5e0432 100644 --- a/modules/dynamic/module.info +++ b/modules/dynamic/module.info @@ -1,3 +1,3 @@ name = Dynamic -description = Dynamic album +description = Adds the Recent Changes and Most Viewed dynamic albums version = 1 -- cgit v1.2.3 From e3e56827d5724c6ec5174d4186db99ab2c55e8f7 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 12:33:37 +0800 Subject: Corrected a problem where the number limit value was being set the same for both popular and recent changes. Signed-off-by: Tim Almdal --- modules/dynamic/controllers/admin_dynamic.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/dynamic/controllers/admin_dynamic.php b/modules/dynamic/controllers/admin_dynamic.php index f559e3d2..50dac459 100644 --- a/modules/dynamic/controllers/admin_dynamic.php +++ b/modules/dynamic/controllers/admin_dynamic.php @@ -28,9 +28,11 @@ class Admin_Dynamic_Controller extends Admin_Controller { if ($form->validate()) { foreach (array("updates", "popular") as $album) { $album_defn = unserialize(module::get_var("dynamic", $album)); - $album_defn->enabled = $form->$album->enabled->value; - $album_defn->description = $form->$album->description->value; - $album_defn->limit = $form->$album->limit->value === "" ? null : $form->$album->limit->value; + $group = $form->inputs[$album]; + $album_defn->enabled = $group->inputs["{$album}_enabled"]->value; + $album_defn->description = $group->inputs["{$album}_description"]->value; + $album_defn->limit = $group->inputs["{$album}_limit"] === "" ? null : + $group->inputs["{$album}_limit"]->value; module::set_var("dynamic", $album, serialize($album_defn)); } @@ -58,15 +60,15 @@ class Admin_Dynamic_Controller extends Admin_Controller { $album_defn = unserialize(module::get_var("dynamic", $album)); $group = $form->group($album)->label(t($album_defn->title)); - $group->checkbox("enabled") + $group->checkbox("{$album}_enabled") ->label(t("Enable")) ->value(1) ->checked($album_defn->enabled); - $group->input("limit") + $group->input("{$album}_limit") ->label(t("Limit (leave empty for unlimited)")) - ->value(empty($updates->limit) ? "" : $updates->limit) + ->value(empty($album_defn->limit) ? "" : $album_defn->limit) ->rules("valid_numeric"); - $group->textarea("description") + $group->textarea("{$album}_description") ->label(t("Description")) ->rules("length[0,2048]") ->value($album_defn->description); -- cgit v1.2.3 From f4f6dacf7dd6f96c47db0486ab56c3ab546ba4ac Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 12:41:59 +0800 Subject: Correct the pattern match to compress multiple spaces into a single dot. Signed-off-by: Tim Almdal --- modules/g2_import/helpers/g2_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 66787467..7dd799c8 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -626,7 +626,7 @@ class g2_import_Core { // Multiword tags have the space changed to dots.s foreach ($tag_names as $tag_name) { $tags .= (strlen($tags) ? ", " : "") . - tag::add($g3_item, preg_replace('/\s\s+/', '.', $tag_name)); + tag::add($g3_item, preg_replace('/\s+/', '.', $tag_name)); } // Tag operations are idempotent so we don't need to map them. Which is good because we don't -- cgit v1.2.3 From a059eff25d3e4975f39ad04181039d4544e47059 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 13:11:49 +0800 Subject: Make the tag event handle the iptc keywords consistently with other tag add mechanisms Signed-off-by: Tim Almdal --- modules/tag/helpers/tag_event.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 946326c0..7a170bf8 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -34,10 +34,13 @@ class tag_event_Core { if (!empty($iptc["2#025"])) { foreach($iptc["2#025"] as $tag) { $tag = str_replace("\0", "", $tag); - if (function_exists("mb_detect_encoding") && mb_detect_encoding($tag) != "UTF-8") { - $tag = utf8_encode($tag); + foreach (preg_split("/[,;]/", $tag) as $word) { + $word = preg_replace('/\s+/', '.', trim($word)); + if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") { + $word = utf8_encode($word); + } + $tags[$word] = 1; } - $tags[$tag] = 1; } } } -- cgit v1.2.3 From 5cf267cc4c4af79389276d786914cbb2b7a2ec25 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 10 Jul 2009 08:01:32 -0700 Subject: Fix a bug where we were not properly locating the parent album when adding a new album or photo. Simplify the data structure that we pass down to server_add_tree.html.php so that we just pass a file list and let it do whatever it wants with it. --- modules/server_add/controllers/server_add.php | 44 ++++++++++++++++------- modules/server_add/views/server_add_tree.html.php | 6 ++-- 2 files changed, 35 insertions(+), 15 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index cf7077a8..446c5074 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -21,7 +21,7 @@ class Server_Add_Controller extends Admin_Controller { public function browse($id) { $paths = unserialize(module::get_var("server_add", "authorized_paths")); foreach (array_keys($paths) as $path) { - $files[$path] = basename($path); + $files[] = $path; } $item = ORM::factory("item", $id); @@ -54,7 +54,7 @@ class Server_Add_Controller extends Admin_Controller { } } - $tree->files[$file] = basename($file); + $tree->files[] = $file; } print $tree; } @@ -119,8 +119,8 @@ class Server_Add_Controller extends Admin_Controller { case "init": $task->set("mode", "build-file-list"); $task->set("queue", array_keys($selections)); - $task->status = t("Starting up"); $task->percent_complete = 0; + $task->status = t("Starting up"); batch::start(); break; @@ -132,6 +132,11 @@ class Server_Add_Controller extends Admin_Controller { while ($queue && microtime(true) - $start < 0.5) { $file = array_shift($queue); if (is_dir($file)) { + $entry = ORM::factory("server_add_file"); + $entry->task_id = $task->id; + $entry->file = $file; + $entry->save(); + $children = empty($selections[$file]) ? glob("$file/*") : $selections[$file]; } else { $children = array($file); @@ -187,6 +192,7 @@ class Server_Add_Controller extends Admin_Controller { $item = model_cache::get("item", $item_id); foreach ($entries as $entry) { + Kohana::log("alert",print_r($albums,1)); if (microtime(true) - $start > 0.5) { break; } @@ -195,19 +201,33 @@ class Server_Add_Controller extends Admin_Controller { $name = basename($relative_path); $title = item::convert_filename_to_title($name); if (is_dir($entry->file)) { - if (isset($albums[$relative_path]) && $parent_id = $albums[$relative_path]) { + $parent_path = dirname($relative_path); + Kohana::log("alert",print_r("rp: $relative_path -> $parent_path",1)); + if (isset($albums[$parent_path]) && $parent_id = $albums[$parent_path]) { $parent = ORM::factory("item", $parent_id); - } else { - $album = album::create($item, $name, $title, null, user::active()->id); - $albums[$relative_path] = $album->id; - $task->set("albums", $albums); - } - } else { - if (strpos($relative_path, "/") !== false) { - $parent = ORM::factory("item", $albums[dirname($relative_path)]); } else { $parent = $item; } + $album = album::create($parent, $name, $title, null, user::active()->id); + $albums[$relative_path] = $album->id; + $task->set("albums", $albums); + } else { + // Find the nearest selected parent. We check to see if any of the candidate parents + // were selected in the UI and if so, we use that. Otherwise, we fall back to making + // the parent the current item. + $parent_path = $relative_path; + $parent = null; + do { + if (strpos($parent_path, "/") !== false) { + if (array_key_exists($parent_path, $albums)) { + $parent = ORM::factory("item", $albums[$parent_path]); + } else { + $parent_path = dirname($parent_path); + } + } else { + $parent = $item; + } + } while (!$parent); $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) { diff --git a/modules/server_add/views/server_add_tree.html.php b/modules/server_add/views/server_add_tree.html.php index f8205a8b..74bc40e0 100644 --- a/modules/server_add/views/server_add_tree.html.php +++ b/modules/server_add/views/server_add_tree.html.php @@ -1,13 +1,13 @@ - $name): ?> +
  • "> -- cgit v1.2.3 From b3785e176145b10c84b3b27850679b13ab54bc81 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 10 Jul 2009 08:04:37 -0700 Subject: Remove debug code. --- modules/server_add/controllers/server_add.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 446c5074..08e01858 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -192,7 +192,6 @@ class Server_Add_Controller extends Admin_Controller { $item = model_cache::get("item", $item_id); foreach ($entries as $entry) { - Kohana::log("alert",print_r($albums,1)); if (microtime(true) - $start > 0.5) { break; } @@ -202,7 +201,6 @@ class Server_Add_Controller extends Admin_Controller { $title = item::convert_filename_to_title($name); if (is_dir($entry->file)) { $parent_path = dirname($relative_path); - Kohana::log("alert",print_r("rp: $relative_path -> $parent_path",1)); if (isset($albums[$parent_path]) && $parent_id = $albums[$parent_path]) { $parent = ORM::factory("item", $parent_id); } else { -- cgit v1.2.3 From 12796ec2ca386895a713583c683348e7d02bc66b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 10 Jul 2009 08:20:00 -0700 Subject: Create a new [options] submenu under the thumb menu, and move the Digibug print button into it. Right now, it doesn't display properly. --- modules/digibug/helpers/digibug_menu.php | 13 +++++++------ modules/gallery/helpers/gallery_menu.php | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/digibug/helpers/digibug_menu.php b/modules/digibug/helpers/digibug_menu.php index f1d4fc1d..c95cada2 100644 --- a/modules/digibug/helpers/digibug_menu.php +++ b/modules/digibug/helpers/digibug_menu.php @@ -38,12 +38,13 @@ class digibug_menu { static function thumb($menu, $theme, $item) { if ($item->type == "photo" && access::can("view_full", $item)) { - $menu->append( - Menu::factory("link") - ->id("digibug") - ->label(t("Print with Digibug")) - ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) - ->css_id("gDigibugLink")); + $menu->get("options_menu") + ->append( + Menu::factory("link") + ->id("digibug") + ->label(t("Print with Digibug")) + ->url(url::site("digibug/print_photo/$item->id?csrf=$theme->csrf")) + ->css_id("gDigibugLink")); } } } diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index 1f1e1ce2..bffb7696 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -95,6 +95,9 @@ class gallery_menu_Core { } static function thumb($menu, $theme, $item) { + $menu->append(Menu::factory("submenu") + ->id("options_menu") + ->label(t("Options"))); } static function photo($menu, $theme) { -- cgit v1.2.3 From 7c993387dadeb721f4c74185fc5ee0e376c4300b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 23:01:53 +0800 Subject: Move the dynamic module to gallery3-contrib Signed-off-by: Tim Almdal --- modules/dynamic/controllers/admin_dynamic.php | 81 --------------------------- modules/dynamic/controllers/dynamic.php | 64 --------------------- modules/dynamic/helpers/dynamic_installer.php | 46 --------------- modules/dynamic/helpers/dynamic_menu.php | 27 --------- modules/dynamic/helpers/dynamic_theme.php | 39 ------------- modules/dynamic/module.info | 3 - modules/dynamic/views/admin_dynamic.html.php | 5 -- modules/dynamic/views/dynamic_block.html.php | 10 ---- 8 files changed, 275 deletions(-) delete mode 100644 modules/dynamic/controllers/admin_dynamic.php delete mode 100644 modules/dynamic/controllers/dynamic.php delete mode 100644 modules/dynamic/helpers/dynamic_installer.php delete mode 100644 modules/dynamic/helpers/dynamic_menu.php delete mode 100644 modules/dynamic/helpers/dynamic_theme.php delete mode 100644 modules/dynamic/module.info delete mode 100644 modules/dynamic/views/admin_dynamic.html.php delete mode 100644 modules/dynamic/views/dynamic_block.html.php (limited to 'modules') diff --git a/modules/dynamic/controllers/admin_dynamic.php b/modules/dynamic/controllers/admin_dynamic.php deleted file mode 100644 index 50dac459..00000000 --- a/modules/dynamic/controllers/admin_dynamic.php +++ /dev/null @@ -1,81 +0,0 @@ -_get_view(); - } - - public function handler() { - access::verify_csrf(); - - $form = $this->_get_form(); - if ($form->validate()) { - foreach (array("updates", "popular") as $album) { - $album_defn = unserialize(module::get_var("dynamic", $album)); - $group = $form->inputs[$album]; - $album_defn->enabled = $group->inputs["{$album}_enabled"]->value; - $album_defn->description = $group->inputs["{$album}_description"]->value; - $album_defn->limit = $group->inputs["{$album}_limit"] === "" ? null : - $group->inputs["{$album}_limit"]->value; - module::set_var("dynamic", $album, serialize($album_defn)); - } - - message::success(t("Dynamic Albums Configured")); - - url::redirect("admin/dynamic"); - } - - print $this->_get_view($form); - } - - private function _get_view($form=null) { - $v = new Admin_View("admin.html"); - $v->content = new View("admin_dynamic.html"); - $v->content->form = empty($form) ? $this->_get_form() : $form; - return $v; - } - - private function _get_form() { - - $form = new Forge("admin/dynamic/handler", "", "post", - array("id" => "gAdminForm")); - - foreach (array("updates", "popular") as $album) { - $album_defn = unserialize(module::get_var("dynamic", $album)); - - $group = $form->group($album)->label(t($album_defn->title)); - $group->checkbox("{$album}_enabled") - ->label(t("Enable")) - ->value(1) - ->checked($album_defn->enabled); - $group->input("{$album}_limit") - ->label(t("Limit (leave empty for unlimited)")) - ->value(empty($album_defn->limit) ? "" : $album_defn->limit) - ->rules("valid_numeric"); - $group->textarea("{$album}_description") - ->label(t("Description")) - ->rules("length[0,2048]") - ->value($album_defn->description); - } - - $form->submit("submit")->value(t("Submit")); - - return $form; - } -} \ No newline at end of file diff --git a/modules/dynamic/controllers/dynamic.php b/modules/dynamic/controllers/dynamic.php deleted file mode 100644 index 6b5f2915..00000000 --- a/modules/dynamic/controllers/dynamic.php +++ /dev/null @@ -1,64 +0,0 @@ -_show("updates"); - } - - public function popular() { - print $this->_show("popular"); - } - - private function _show($album) { - $page_size = module::get_var("gallery", "page_size", 9); - $page = $this->input->get("page", "1"); - - $album_defn = unserialize(module::get_var("dynamic", $album)); - $children_count = $album_defn->limit; - if (empty($children_count)) { - $children_count = ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->count_all(); - } - - $offset = ($page-1) * $page_size; - - $max_pages = ceil($children_count / $page_size); - - // Make sure that the page references a valid offset - if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) { - Kohana::show_404(); - } - - $template = new Theme_View("page.html", "dynamic"); - $template->set_global("page_size", $page_size); - $template->set_global("children", ORM::factory("item") - ->viewable() - ->where("type !=", "album") - ->orderby($album_defn->key_field, "DESC") - ->find_all($page_size, $offset)); - $template->set_global("children_count", $children_count); - $template->content = new View("dynamic.html"); - $template->content->title = t($album_defn->title); - - print $template; - } - -} \ No newline at end of file diff --git a/modules/dynamic/helpers/dynamic_installer.php b/modules/dynamic/helpers/dynamic_installer.php deleted file mode 100644 index 66d6298d..00000000 --- a/modules/dynamic/helpers/dynamic_installer.php +++ /dev/null @@ -1,46 +0,0 @@ - false, - "limit" => null, - "description" => "", - "key_field" => "view_count", - "title" => t("Most Viewed")))); - module::set_var("dynamic", "updates", - serialize((object)array("enabled" => false, - "limit" => null, - "description" => "", - "key_field" => "created", - "title" => t("Recent Changes")))); - module::set_version("dynamic", 1); - } - } - - static function upgrade($version) { - } - - static function uninstall() { - /* @todo Put database table drops here */ - module::delete("dynamic"); - } -} diff --git a/modules/dynamic/helpers/dynamic_menu.php b/modules/dynamic/helpers/dynamic_menu.php deleted file mode 100644 index b2c73d6f..00000000 --- a/modules/dynamic/helpers/dynamic_menu.php +++ /dev/null @@ -1,27 +0,0 @@ -get("content_menu") - ->append(Menu::factory("link") - ->id("dynamic_menu") - ->label(t("Dynamic Albums")) - ->url(url::site("admin/dynamic"))); - } -} diff --git a/modules/dynamic/helpers/dynamic_theme.php b/modules/dynamic/helpers/dynamic_theme.php deleted file mode 100644 index ba355098..00000000 --- a/modules/dynamic/helpers/dynamic_theme.php +++ /dev/null @@ -1,39 +0,0 @@ -enabled) { - $albums[$album] = $album_defn->title; - } - } - if (!empty($albums)) { - $block = new Block(); - $block->css_id = "gDynamic"; - $block->title = t("Dynamic Albums"); - $block->content = new View("dynamic_block.html"); - $block->content->albums = $albums; - return $block; - } - return ""; - } - -} diff --git a/modules/dynamic/module.info b/modules/dynamic/module.info deleted file mode 100644 index aa5e0432..00000000 --- a/modules/dynamic/module.info +++ /dev/null @@ -1,3 +0,0 @@ -name = Dynamic -description = Adds the Recent Changes and Most Viewed dynamic albums -version = 1 diff --git a/modules/dynamic/views/admin_dynamic.html.php b/modules/dynamic/views/admin_dynamic.html.php deleted file mode 100644 index cd7ccfea..00000000 --- a/modules/dynamic/views/admin_dynamic.html.php +++ /dev/null @@ -1,5 +0,0 @@ - -
    -

    - -
    diff --git a/modules/dynamic/views/dynamic_block.html.php b/modules/dynamic/views/dynamic_block.html.php deleted file mode 100644 index d14c2900..00000000 --- a/modules/dynamic/views/dynamic_block.html.php +++ /dev/null @@ -1,10 +0,0 @@ - -
    -
      - $text): ?> -
    • - "> -
    • - -
    -
    -- cgit v1.2.3 From 86a7b15d206d29387637864f63b7ac795fce981d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 10 Jul 2009 10:39:59 -0700 Subject: Compact all menus. This fixes the problem that the new [Options] thumb menu shows up when it has nothing in it. --- 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 898574d7..75138f25 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -127,6 +127,7 @@ class Theme_View_Core extends Gallery_View { } } + $menu->compact(); print $menu; } -- cgit v1.2.3 From 09c9b1a75561881a40ada71f02710355923602e2 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 11:35:28 -0700 Subject: Added the upload::required validation in order to insure that failed uploads are not treated as successful. Log any exceptions to the Kohana log and return the error message --- modules/gallery/controllers/simple_uploader.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index 713e30af..a059f986 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -1,3 +1,4 @@ + add_rules( - "Filedata", "upload::valid", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); + "Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]"); if ($file_validation->validate()) { // SimpleUploader.swf does not yet call /start directly, so simulate it here for now. if (!batch::in_progress()) { @@ -54,7 +55,7 @@ class Simple_Uploader_Controller extends Controller { try { $name = substr(basename($temp_filename), 10); // Skip unique identifier Kohana adds $title = item::convert_filename_to_title($name); - $path_info = pathinfo($temp_filename); + $path_info = @pathinfo($temp_filename); if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { $movie = movie::create($album, $temp_filename, $name, $title); @@ -66,12 +67,20 @@ class Simple_Uploader_Controller extends Controller { html::anchor("photos/$photo->id", t("view photo"))); } } catch (Exception $e) { - unlink($temp_filename); - throw $e; + Kohana::log("alert", $e->__toString()); + if (file_exists($temp_filename)) { + unlink($temp_filename); + } + header("HTTP/1.1 500 Internal Server Error"); + print "ERROR:" . $e->getMessage(); + return; } unlink($temp_filename); + print "FILEID: $photo->id"; + } else { + header("HTTP/1.1 400 Bad Request"); + print "ERROR: Invalid Upload"; } - print "File Received"; } public function finish() { -- cgit v1.2.3 From 863deab3d34359b2e33df718f3da4db1f97a7c7d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 12:54:25 -0700 Subject: Fix a bug where the task message was not being set --- modules/search/helpers/search_task.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/search/helpers/search_task.php b/modules/search/helpers/search_task.php index 395bcd98..df1dfe16 100644 --- a/modules/search/helpers/search_task.php +++ b/modules/search/helpers/search_task.php @@ -69,6 +69,7 @@ class search_task_Core { $task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent)); + $message[] = $task->status; } catch (Exception $e) { $task->done = true; $task->state = "error"; -- cgit v1.2.3 From 15bb52a7767d141ff10179f36ea8389f461df801 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 14:12:13 -0700 Subject: Change the word "Done" to "Close" to make translations easier --- modules/gallery/views/admin_maintenance_task.html.php | 2 +- modules/gallery/views/simple_uploader.html.php | 2 +- modules/organize/views/organize_button_pane.html.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php index d9aecc60..5c2c03a1 100644 --- a/modules/gallery/views/admin_maintenance_task.html.php +++ b/modules/gallery/views/admin_maintenance_task.html.php @@ -30,6 +30,6 @@
    - +
    diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 56b1c656..e1add7f7 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -51,7 +51,7 @@ diff --git a/modules/organize/views/organize_button_pane.html.php b/modules/organize/views/organize_button_pane.html.php index cd780d5e..c5839a44 100644 --- a/modules/organize/views/organize_button_pane.html.php +++ b/modules/organize/views/organize_button_pane.html.php @@ -46,5 +46,5 @@
    - +
    -- cgit v1.2.3 From f887fd32a46f4c5daa4c0adf8e6a297237c043c3 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 14:19:33 -0700 Subject: Forgot to add this file when change "Done"'s to "Close"'s --- modules/gallery/views/admin_maintenance.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php index cd1cc02e..450eb754 100644 --- a/modules/gallery/views/admin_maintenance.html.php +++ b/modules/gallery/views/admin_maintenance.html.php @@ -79,7 +79,7 @@ state == "cancelled"): ?> - + state == "stalled"): ?> -- cgit v1.2.3 From fabdde9bb97bc01c52de41069fed0d046717d3fe Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 17:46:33 -0700 Subject: Reference exif consistently as EXIF ticket #526. --- modules/exif/helpers/exif_task.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php index 649ad092..6929b797 100644 --- a/modules/exif/helpers/exif_task.php +++ b/modules/exif/helpers/exif_task.php @@ -57,7 +57,7 @@ class exif_task_Core { $completed++; exif::extract($item); - $message[] = t("Updated Exif meta data for '%title'", + $message[] = t("Updated EXIF meta data for '%title'", array("title" => p::purify($item->title))); } -- cgit v1.2.3 From fe6320ef4c976df037c259c85bab26c508659ba9 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 18:11:12 -0700 Subject: Fix for ticket #341. Change the wording for the sort order from "Default" to "Order Added" --- modules/gallery/helpers/album.php | 2 +- modules/organize/helpers/organize.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 362b93d0..1197f243 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -111,7 +111,7 @@ class album_Core { $sort_order->dropdown("column", array("id" => "gAlbumSortColumn")) ->label(t("Sort by")) - ->options(array("weight" => t("Default"), + ->options(array("weight" => t("Order Added"), "captured" => t("Capture Date"), "created" => t("Creation Date"), "title" => t("Title"), diff --git a/modules/organize/helpers/organize.php b/modules/organize/helpers/organize.php index 9bf4e986..25284771 100644 --- a/modules/organize/helpers/organize.php +++ b/modules/organize/helpers/organize.php @@ -43,7 +43,7 @@ class organize_Core { $sortPane->hidden("item[]")->value($item->id); $sortPane->dropdown("column", array("id" => "gAlbumSortColumn")) ->label(t("Sort by")) - ->options(array("weight" => t("Default"), + ->options(array("weight" => t("Order Added"), "captured" => t("Capture Date"), "created" => t("Creation Date"), "title" => t("Title"), -- cgit v1.2.3 From 6320babf78deb66f0916e569b36eaeb598603997 Mon Sep 17 00:00:00 2001 From: Shai Ben-Naphtali Date: Sat, 11 Jul 2009 13:56:43 +0800 Subject: Fixes ticket #526 Signed-off-by: Tim Almdal --- modules/exif/helpers/exif.php | 2 +- modules/exif/helpers/exif_task.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index b0e7e93f..20ecd0cb 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -163,7 +163,7 @@ class exif_Core { list ($remaining) = exif::stats(); if ($remaining) { site_status::warning( - t('Your EXIF index needs to be updated. Fix this now', + t('Your Exif index needs to be updated. Fix this now', array("url" => url::site("admin/maintenance/start/exif_task::update_index?csrf=__CSRF__"))), "exif_index_out_of_date"); } diff --git a/modules/exif/helpers/exif_task.php b/modules/exif/helpers/exif_task.php index 6929b797..f3e77975 100644 --- a/modules/exif/helpers/exif_task.php +++ b/modules/exif/helpers/exif_task.php @@ -28,12 +28,12 @@ class exif_task_Core { list ($remaining, $total, $percent) = exif::stats(); return array(Task_Definition::factory() ->callback("exif_task::update_index") - ->name(t("Extract EXIF data")) + ->name(t("Extract Exif data")) ->description($remaining ? t2("1 photo needs to be scanned", "%count (%percent%) of your photos need to be scanned", $remaining, array("percent" => (100 - $percent))) - : t("EXIF data is up-to-date")) + : t("Exif data is up-to-date")) ->severity($remaining ? log::WARNING : log::SUCCESS)); } @@ -57,7 +57,7 @@ class exif_task_Core { $completed++; exif::extract($item); - $message[] = t("Updated EXIF meta data for '%title'", + $message[] = t("Updated Exif meta data for '%title'", array("title" => p::purify($item->title))); } -- cgit v1.2.3 From e0e450d90fe67ac199d82d2b8e902cff5c8b6c7d Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sat, 11 Jul 2009 00:40:57 -0600 Subject: Position gItem and gPhoto relative, then position quick and thumb menus as absolute within them. Moved css from quick.js to quick.css. --- modules/gallery/css/quick.css | 12 ++++++++++++ modules/gallery/helpers/gallery_menu.php | 3 ++- modules/gallery/js/quick.js | 11 +---------- themes/default/css/screen.css | 18 +++++++++++++++++- themes/default/js/ui.init.js | 8 ++++++++ 5 files changed, 40 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/gallery/css/quick.css b/modules/gallery/css/quick.css index 02f9953e..0e45eac2 100644 --- a/modules/gallery/css/quick.css +++ b/modules/gallery/css/quick.css @@ -1,3 +1,12 @@ +#gQuickPane { + position: absolute; + top: 0; + left: 0; + text-align: center; + width: 100%; + height: auto; +} + .gItem:hover { background-color: #cfdeff; } @@ -12,6 +21,9 @@ background: #000; border-bottom: 1px solid #ccc; opacity: 0.9; + position: absolute; + top: 0; + left: 0; } #gQuickPane a { diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index bffb7696..b6f763b8 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -97,7 +97,8 @@ class gallery_menu_Core { static function thumb($menu, $theme, $item) { $menu->append(Menu::factory("submenu") ->id("options_menu") - ->label(t("Options"))); + ->label(t("Options")) + ->css_class("gThumbMenu")); } static function photo($menu, $theme) { diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 4ebdac47..32e34ef3 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -13,16 +13,7 @@ var show_quick = function() { var quick = $(this).find(".gQuick"); $("#gQuickPane").remove(); cont.append("
    "); - var img = cont.find(".gThumbnail,.gResize"); - var pos = cont.position(); - $("#gQuickPane").css({ - "position": "absolute", - "top": pos.top, - "left": pos.left, - "text-align": "center", - "width": cont.innerWidth() + 1, - "height": "auto" - }).hide(); + $("#gQuickPane").hide(); cont.hover(function() {}, hide_quick); $.get( quick.attr("href"), diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index 41e51623..d08ada17 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -460,6 +460,7 @@ form .gError, height: 240px; overflow: hidden; padding: 14px 8px; + position: relative; text-align: center; width: 213px; } @@ -487,7 +488,7 @@ form .gError, } #gContent #gPhoto { - + position: relative; } #gContent #gItem .gFullSizeLink img { @@ -581,6 +582,21 @@ form .gError, margin-bottom: 0; } +/* Thumb Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +.gItem .gMenu { + bottom: 0; + margin-bottom: -2px; + position: absolute; + right: 0; +} + +.gItem .gMenu li { + font-weight: normal !important; +} + +/* View Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + #gViewMenu { margin-bottom: 1em; } diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index 9d9d3079..29e04d5e 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -36,6 +36,14 @@ $(document).ready(function() { $(dialogLinks[i]).bind("click", handleDialogEvent); } + // gThumbMenu + if ($(".gItem .gMenu").length) { + $(".gItem .gMenu").removeClass("sf-menu"); + $(".gItem .gMenu span").removeClass("sf-sub-indicator"); + $(".gItem .gMenu span").addClass("ui-icon ui-icon-triangle-1-n"); + $(".gItem .gMenu li:first-child").addClass("ui-icon-right ui-corner-top ui-state-default"); + } + // Initialize view menu if ($("#gViewMenu").length) { $("#gViewMenu ul").removeClass("gMenu").removeClass("sf-menu"); -- cgit v1.2.3 From f1b2a14f4fe1bfd9419d4023b6b6223bc39c379b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 10 Jul 2009 23:45:29 -0700 Subject: Add a title attribute to the li of a menu --- modules/gallery/libraries/Menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 6d0881ce..9ede49b6 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -207,7 +207,7 @@ class Menu_Core extends Menu_Element { public function __toString() { $html = $this->is_root ? "
      " : - "
    • $this->label
        "; + "
      • label\">$this->label
          "; $html .= implode("\n", $this->elements); $html .= $this->is_root ? "
        " : "
    • "; return $html; -- cgit v1.2.3 From 954ab5a5051edb67eca8ae74283a80a226e39672 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:03:36 -0700 Subject: Further simplify server_add (and bump it to version 3). Now we don't have checkboxes, but instead we restrict you to selecting directories and albums from only one level in the hierarchy. This makes it easier for us to make sure that we properly create the hierarchy that you want and avoid confusion about what's going to wind up where. Modify Server_Add_File_Model to have a parent_id and item_id and then modify them as we go so that we can build up a tree structure there *before* we create any items. This makes it much easier to figure out where a new item is going to go and get rid of a bunch of probably buggy code in the main task. --- modules/server_add/controllers/server_add.php | 199 +++++++++------------ .../server_add/helpers/server_add_installer.php | 8 +- modules/server_add/js/server_add.js | 67 ++----- modules/server_add/module.info | 2 +- modules/server_add/views/server_add_tree.html.php | 56 ++++-- themes/default/css/screen.css | 20 +-- 6 files changed, 158 insertions(+), 194 deletions(-) (limited to 'modules') diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php index 08e01858..6056d7cd 100644 --- a/modules/server_add/controllers/server_add.php +++ b/modules/server_add/controllers/server_add.php @@ -29,51 +29,58 @@ class Server_Add_Controller extends Admin_Controller { $view->item = $item; $view->tree = new View("server_add_tree.html"); $view->tree->files = $files; + $view->tree->parents = array(); print $view; } public function children() { $path = $this->input->get("path"); - if (!server_add::is_valid_path($path)) { - throw new Exception("@todo BAD_PATH"); - } $tree = new View("server_add_tree.html"); $tree->files = array(); - $tree->tree_id = substr(md5($path), 10); + $tree->parents = array(); - foreach (glob("$path/*") as $file) { - if (!is_readable($file)) { - continue; + // Make a tree with the parents back up to the authorized path, and all the children under the + // current path. + if (server_add::is_valid_path($path)) { + $tree->parents[] = $path; + while (server_add::is_valid_path(dirname($tree->parents[0]))) { + array_unshift($tree->parents, dirname($tree->parents[0])); } - if (!is_dir($file)) { - $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); - if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { + foreach (glob("$path/*") as $file) { + if (!is_readable($file)) { continue; } - } + if (!is_dir($file)) { + $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); + if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { + continue; + } + } - $tree->files[] = $file; + $tree->files[] = $file; + } + } else { + // Missing or invalid path; print out the list of authorized path + $paths = unserialize(module::get_var("server_add", "authorized_paths")); + foreach (array_keys($paths) as $path) { + $tree->files[] = $path; + } } print $tree; } + /** + * Begin the task of adding photos. + */ public function start() { access::verify_csrf(); - $item = ORM::factory("item", Input::instance()->get("item_id")); - // We're an admin so this isn't necessary, but we'll eventually open this up to non-admins and - // this also verifies that the item was loaded properly. - access::required("edit", $item); - // Gather up all the paths and associate them by directory, so that we can locate any empty - // directories for the next round. foreach (Input::instance()->post("paths") as $path) { - if (is_dir($path)) { - $selections[$path] = array(); - } else if (is_file($path)) { - $selections[dirname($path)][] = $path; + if (server_add::is_valid_path($path)) { + $paths[] = array($path, null); } } @@ -81,8 +88,7 @@ class Server_Add_Controller extends Admin_Controller { ->callback("Server_Add_Controller::add") ->description(t("Add photos or movies from the local server")) ->name(t("Add from server")); - $task = task::create( - $task_def, array("item_id" => $item->id, "selections" => $selections)); + $task = task::create($task_def, array("item_id" => $item->id, "queue" => $paths)); print json_encode( array("result" => "started", @@ -90,6 +96,9 @@ class Server_Add_Controller extends Admin_Controller { "url" => url::site("server_add/run/$task->id?csrf=" . access::csrf_token()))); } + /** + * Run the task of adding photos + */ function run($task_id) { access::verify_csrf(); @@ -110,49 +119,48 @@ class Server_Add_Controller extends Admin_Controller { * them one at a time. */ static function add($task) { - $selections = $task->get("selections"); $mode = $task->get("mode", "init"); $start = microtime(true); - $item_id = $task->get("item_id"); switch ($mode) { case "init": $task->set("mode", "build-file-list"); - $task->set("queue", array_keys($selections)); $task->percent_complete = 0; $task->status = t("Starting up"); batch::start(); break; - case "build-file-list": /* 0% to 10% */ + case "build-file-list": // 0% to 10% // We can't fit an arbitrary number of paths in a task, so store them in a separate table. // Don't use an iterator here because we can't get enough control over it when we're dealing - // with a deep hierarchy and we don't want to go over our time quota. + // with a deep hierarchy and we don't want to go over our time quota. The queue is in the + // form [path, parent_id] where the parent_id refers to another Server_Add_File_Model. We + // have this extra level of abstraction because we don't know its Item_Model id yet. $queue = $task->get("queue"); while ($queue && microtime(true) - $start < 0.5) { - $file = array_shift($queue); - if (is_dir($file)) { - $entry = ORM::factory("server_add_file"); - $entry->task_id = $task->id; - $entry->file = $file; - $entry->save(); - - $children = empty($selections[$file]) ? glob("$file/*") : $selections[$file]; - } else { - $children = array($file); - } - - foreach ($children as $child) { - $entry = ORM::factory("server_add_file"); - $entry->task_id = $task->id; - $entry->file = $child; - $entry->save(); + list($file, $parent_entry_id) = array_shift($queue); + $entry = ORM::factory("server_add_file"); + $entry->task_id = $task->id; + $entry->file = $file; + $entry->parent_id = $parent_entry_id; + $entry->save(); + foreach (glob("$file/*") as $child) { if (is_dir($child)) { - $queue[] = $child; + $queue[] = array($child, $entry->id); + } else { + $ext = strtolower(pathinfo($child, PATHINFO_EXTENSION)); + if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { + $child_entry = ORM::factory("server_add_file"); + $child_entry->task_id = $task->id; + $child_entry->file = $child; + $child_entry->parent_id = $entry->id; + $child_entry->save(); + } } } } + // We have no idea how long this can take because we have no idea how deep the tree // hierarchy rabbit hole goes. Leave ourselves room here for 100 iterations and don't go // over 10% in percent_complete. @@ -168,79 +176,67 @@ class Server_Add_Controller extends Admin_Controller { $task->set( "total_files", database::instance()->count_records( "server_add_files", array("task_id" => $task->id))); - $task->set("albums", array()); - $task->set("completed", 0); $task->percent_complete = 10; } break; - case "add-files": /* 10% to 100% */ - $completed_files = $task->get("completed_files"); + case "add-files": // 10% to 100% + $completed_files = $task->get("completed_files", 0); $total_files = $task->get("total_files"); - $albums = $task->get("albums"); // Ordering by id ensures that we add them in the order that we created the entries, which - // will create albums first. + // will create albums first. Ignore entries which already have an Item_Model attached, + // they're done. $entries = ORM::factory("server_add_file") ->where("task_id", $task->id) + ->where("item_id", null) ->orderby("id", "ASC") ->limit(10) ->find_all(); if ($entries->count() == 0) { + // Out of entries, we're done. $task->set("mode", "done"); } - $item = model_cache::get("item", $item_id); + $owner_id = user::active()->id; foreach ($entries as $entry) { if (microtime(true) - $start > 0.5) { break; } - $relative_path = self::_relative_path($entry->file); - $name = basename($relative_path); + // Look up the parent item for this entry. By now it should exist, but if none was + // specified, then this belongs as a child of the current item. + $parent_entry = ORM::factory("server_add_file", $entry->parent_id); + if (!$parent_entry->loaded) { + $parent = ORM::factory("item", $task->get("item_id")); + } else { + $parent = ORM::factory("item", $parent_entry->item_id); + } + + $name = basename($entry->file); $title = item::convert_filename_to_title($name); if (is_dir($entry->file)) { - $parent_path = dirname($relative_path); - if (isset($albums[$parent_path]) && $parent_id = $albums[$parent_path]) { - $parent = ORM::factory("item", $parent_id); - } else { - $parent = $item; - } - $album = album::create($parent, $name, $title, null, user::active()->id); - $albums[$relative_path] = $album->id; - $task->set("albums", $albums); + $album = album::create($parent, $name, $title, null, $owner_id); + $entry->item_id = $album->id; } else { - // Find the nearest selected parent. We check to see if any of the candidate parents - // were selected in the UI and if so, we use that. Otherwise, we fall back to making - // the parent the current item. - $parent_path = $relative_path; - $parent = null; - do { - if (strpos($parent_path, "/") !== false) { - if (array_key_exists($parent_path, $albums)) { - $parent = ORM::factory("item", $albums[$parent_path]); - } else { - $parent_path = dirname($parent_path); - } - } else { - $parent = $item; - } - } while (!$parent); - $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) { - photo::create($parent, $entry->file, $name, $title, null, user::active()->id); + $photo = photo::create($parent, $entry->file, $name, $title, null, $owner_id); + $entry->item_id = $photo->id; } else if (in_array($extension, array("flv", "mp4"))) { - movie::create($parent, $entry->file, $name, $title, null, user::active()->id); + $movie = movie::create($parent, $entry->file, $name, $title, null, $owner_id); + $entry->item_id = $movie->id; } else { - $task->log("Skipping unknown file type: $relative_path"); - // Unsupported type - // @todo: $task->log this + // This should never happen, because we don't add stuff to the list that we can't + // process. But just in, case.. set this to a non-null value so that we skip this + // entry. + $entry->item_id = 0; + $task->log("Skipping unknown file type: $entry->file"); } } $completed_files++; - $entry->delete(); + $entry->save(); } $task->set("completed_files", $completed_files); $task->status = t("Adding photos and albums (%completed of %total)", @@ -254,33 +250,10 @@ class Server_Add_Controller extends Admin_Controller { $task->done = true; $task->state = "success"; $task->percent_complete = 100; + ORM::factory("server_add_file")->where("task_id", $task->id)->delete_all(); message::info(t2("Successfully added one photo", - "Successfully added %count photos", + "Successfully added %count photos and albums", $task->get("completed_files"))); } } - - /** - * Given a path that's somewhere in our authorized_paths list, return just the part that's - * relative to the nearest authorized path. - */ - static function _relative_path($path) { - static $authorized_paths; - // @todo this doesn't deal well with overlapping authorized paths, it'll just use the first one - // that matches. If we sort $authorized_paths by length in descending order, that should take - // care of the problem. - if (!$authorized_paths) { - $authorized_paths = - array_keys(unserialize(module::get_var("server_add", "authorized_paths"))); - } - - foreach ($authorized_paths as $candidate) { - $candidate = dirname($candidate); - if (strpos($path, $candidate) === 0) { - return substr($path, strlen($candidate) + 1); - } - } - - throw new Exception("@todo BAD_PATH"); - } } diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php index 6956a72c..4cc34207 100644 --- a/modules/server_add/helpers/server_add_installer.php +++ b/modules/server_add/helpers/server_add_installer.php @@ -22,8 +22,10 @@ class server_add_installer { $db = Database::instance(); $db->query("CREATE TABLE {server_add_files} ( `id` int(9) NOT NULL auto_increment, - `task_id` int(9) NOT NULL, `file` varchar(255) NOT NULL, + `item_id` int(9), + `parent_id` int(9), + `task_id` int(9) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("server_add", 2); @@ -40,6 +42,10 @@ class server_add_installer { PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("server_add", $version = 2); + } else if ($version == 2) { + $db->query("ALTER TABLE {server_add_files} ADD COLUMN `item_id` int(9)"); + $db->query("ALTER TABLE {server_add_files} ADD COLUMN `parent_id` int(9)"); + module::set_version("server_add", $version = 3); } } diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index 1a78d733..989555cc 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -1,51 +1,9 @@ /** - * We've clicked the + icon next to a directory. Load up children of this - * directory from the server and display them. + * Manage file selection state. */ -function open_close_branch(path, id) { - var parent = $("#file_" + id); - var children = $("#tree_" + id); - var icon = parent.find(".ui-icon:first"); - - if (!children.html()) { - parent.addClass("gLoadingSmall"); - $.ajax({ - url: GET_CHILDREN_URL.replace("__PATH__", path), - success: function(data, textStatus) { - children.html(data); - parent.removeClass("gLoadingSmall"); - - // Propagate checkbox value - children.find("input[type=checkbox]").attr( - "checked", parent.find("input[type=checkbox]:first").attr("checked")); - } - }); - } - - children.slideToggle("fast", function() { - if (children.is(":hidden")) { - icon.addClass("ui-icon-plus"); - icon.removeClass("ui-icon-minus"); - } else { - icon.addClass("ui-icon-minus"); - icon.removeClass("ui-icon-plus"); - parent.removeClass("gCollapsed"); - } - }); -} - -/** - * We've clicked a checkbox. Propagate the value downwards as necessary. - */ -function click_node(checkbox) { - var parent = $(checkbox).parents("li").get(0); - var checked = $(checkbox).attr("checked"); - $(parent).find("input[type=checkbox]").attr("checked", checked); - - // @todo if we uncheck all the children for a parent, we should uncheck the - // parent itself, otherwise in the code we'll add the entire parent since if - // we find an album as a leaf, we assume that it's never been expanded in the UI. - if ($("#gServerAddTree").find("input[type=checkbox]").is(":checked")) { +function select_file(li) { + $(li).toggleClass("selected"); + if ($("#gServerAdd span.selected").length) { $("#gServerAddAddButton").enable(true); $("#gServerAddAddButton").removeClass("ui-state-disabled"); } else { @@ -54,11 +12,24 @@ function click_node(checkbox) { } } +/** + * Load a new directory + */ +function open_dir(path) { + $.ajax({ + url: GET_CHILDREN_URL.replace("__PATH__", path), + success: function(data, textStatus) { + $("#gServerAddTree").html(data); + } + }); +} + function start_add() { var paths = []; - $.each($("#gServerAdd :checkbox[checked]"), function () { - paths.push(this.value); + $.each($("#gServerAdd span.selected"), function () { + paths.push($(this).attr("file")); }); + $.ajax({ url: START_URL, type: "POST", diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 1c99d280..295d3beb 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -1,3 +1,3 @@ name = Server Add description = Allows authorized users to load images directly from your web server -version = 2 +version = 3 diff --git a/modules/server_add/views/server_add_tree.html.php b/modules/server_add/views/server_add_tree.html.php index 74bc40e0..254a9da0 100644 --- a/modules/server_add/views/server_add_tree.html.php +++ b/modules/server_add/views/server_add_tree.html.php @@ -1,19 +1,41 @@ - - -
    • "> - - - - - - - +
    • + + + + +
        + + +
      • + + + + +
          + + + +
        • + "> + + ondblclick="open_dir($(this).attr('file'))" + + file="" + > + + +
        • + + +
        • + + + +
        +
      • + + +
    • - - -
    • - diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index 41e51623..842a1491 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -879,24 +879,20 @@ form .gError, /* Server Add */ -.gCheckboxTree input { - display: inline; +#gServerAddTree { + cursor: pointer; } -.gCheckboxTree li { +#gServerAddTree li { padding: 0; float: none; } -.gCheckboxTree .ui-icon { - cursor: pointer; +#gServerAddTree span.selected { + background: #ddd; } -.gFile { - padding-left: 2.5em; -} - -#gServerAdd #gServerAddTree { +#gServerAddTree { border: 1px solid #ccc; height: 25em; overflow: auto; @@ -909,10 +905,6 @@ form .gError, padding-left: 1.2em; } -#gServerAdd ul li .gFile { - padding-left: 2.5em; -} - #gServerAdd .gBreadcrumbs { font-size: 1em; padding: 0; -- cgit v1.2.3 From 4132d6c55ed91ca66607680bc44775c4ba650da6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 11 Jul 2009 15:47:04 -0700 Subject: Put quotes around the href param (href="#") --- modules/gallery/libraries/Menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 9ede49b6..d37be7d3 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -207,7 +207,7 @@ class Menu_Core extends Menu_Element { public function __toString() { $html = $this->is_root ? "
        " : - "
      • label\">$this->label
          "; + "
        • label\">$this->label
            "; $html .= implode("\n", $this->elements); $html .= $this->is_root ? "
          " : "
      • "; return $html; -- cgit v1.2.3 From 22fcb4c776d8034766c861847ead8e0f18518ed0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:14:02 -0700 Subject: Forgot to bump the version up to 3 --- modules/server_add/helpers/server_add_installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php index 4cc34207..67c7a377 100644 --- a/modules/server_add/helpers/server_add_installer.php +++ b/modules/server_add/helpers/server_add_installer.php @@ -28,7 +28,7 @@ class server_add_installer { `task_id` int(9) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - module::set_version("server_add", 2); + module::set_version("server_add", 3); server_add::check_config(); } -- cgit v1.2.3 From 6281ed03d54a010efdee3988a893cfcd7f3663b5 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:36:31 -0700 Subject: Turn off extended inserts when creating install.sql so that it's easier to see what's changed. --- installer/install.sql | 49 ++++++++++++++++++++++++++------ modules/gallery/controllers/packager.php | 4 +-- 2 files changed, 43 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index d719d49d..bda576d1 100755 --- a/installer/install.sql +++ b/installer/install.sql @@ -88,7 +88,8 @@ CREATE TABLE {graphics_rules} ( PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!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','resize',100,'thumb'),(2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:480;s:6:\"master\";i:2;}','gallery','resize',100,'resize'); +INSERT INTO {graphics_rules} VALUES (1,1,'a:3:{s:5:\"width\";i:200;s:6:\"height\";i:200;s:6:\"master\";i:2;}','gallery','resize',100,'thumb'); +INSERT INTO {graphics_rules} VALUES (2,1,'a:3:{s:5:\"width\";i:640;s:6:\"height\";i:480;s:6:\"master\";i:2;}','gallery','resize',100,'resize'); DROP TABLE IF EXISTS {groups}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -100,7 +101,8 @@ CREATE TABLE {groups} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {groups} VALUES (1,'Everybody',1),(2,'Registered Users',1); +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 */; @@ -111,7 +113,9 @@ CREATE TABLE {groups_users} ( UNIQUE KEY `user_id` (`user_id`,`group_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {groups_users} VALUES (1,1),(1,2),(2,2); +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 */; @@ -221,7 +225,15 @@ CREATE TABLE {modules} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {modules} VALUES (1,1,'gallery',6),(2,1,'user',1),(3,1,'comment',2),(4,1,'organize',1),(5,1,'info',1),(6,1,'rss',1),(7,1,'search',1),(8,1,'slideshow',1),(9,1,'tag',1); +INSERT INTO {modules} VALUES (1,1,'gallery',6); +INSERT INTO {modules} VALUES (2,1,'user',1); +INSERT INTO {modules} VALUES (3,1,'comment',2); +INSERT INTO {modules} VALUES (4,1,'organize',1); +INSERT INTO {modules} VALUES (5,1,'info',1); +INSERT INTO {modules} VALUES (6,1,'rss',1); +INSERT INTO {modules} VALUES (7,1,'search',1); +INSERT INTO {modules} VALUES (8,1,'slideshow',1); +INSERT INTO {modules} VALUES (9,1,'tag',1); DROP TABLE IF EXISTS {outgoing_translations}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -248,7 +260,10 @@ CREATE TABLE {permissions} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {permissions} VALUES (1,'View','view'),(2,'View Full Size','view_full'),(3,'Edit','edit'),(4,'Add','add'); +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 */; @@ -313,7 +328,8 @@ CREATE TABLE {themes} ( UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {themes} VALUES (1,'default',1),(2,'admin_default',1); +INSERT INTO {themes} VALUES (1,'default',1); +INSERT INTO {themes} VALUES (2,'admin_default',1); DROP TABLE IF EXISTS {users}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -335,7 +351,8 @@ CREATE TABLE {users} ( UNIQUE KEY `hash` (`hash`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {users} VALUES (1,'guest','Guest User','',0,0,NULL,0,1,NULL,NULL,NULL),(2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL,NULL); +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,NULL,1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -348,4 +365,20 @@ CREATE TABLE {vars} ( UNIQUE KEY `module_name` (`module_name`,`name`) ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'),(2,'gallery','active_admin_theme','admin_default'),(3,'gallery','page_size','9'),(4,'gallery','thumb_size','200'),(5,'gallery','resize_size','640'),(6,'gallery','default_locale','en_US'),(7,'gallery','image_quality','75'),(9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'),(14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(17,'gallery','version','3.0 pre beta 2 (git)'),(18,'gallery','choose_default_tookit','1'),(19,'gallery','date_format','Y-M-d'),(20,'gallery','date_time_format','Y-M-d H:i:s'),(21,'gallery','time_format','H:i:s'),(22,'gallery','show_credits','1'),(23,'gallery','credits','Powered by Gallery %version'),(25,'comment','spam_caught','0'); +INSERT INTO {vars} VALUES (1,'gallery','active_site_theme','default'); +INSERT INTO {vars} VALUES (2,'gallery','active_admin_theme','admin_default'); +INSERT INTO {vars} VALUES (3,'gallery','page_size','9'); +INSERT INTO {vars} VALUES (4,'gallery','thumb_size','200'); +INSERT INTO {vars} VALUES (5,'gallery','resize_size','640'); +INSERT INTO {vars} VALUES (6,'gallery','default_locale','en_US'); +INSERT INTO {vars} VALUES (7,'gallery','image_quality','75'); +INSERT INTO {vars} VALUES (9,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}'); +INSERT INTO {vars} VALUES (14,'gallery','blocks_dashboard_center','a:4:{i:6;a:2:{i:0;s:7:\"gallery\";i:1;s:7:\"welcome\";}i:7;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"photo_stream\";}i:8;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"log_entries\";}i:9;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'); +INSERT INTO {vars} VALUES (17,'gallery','version','3.0 pre beta 2 (git)'); +INSERT INTO {vars} VALUES (18,'gallery','choose_default_tookit','1'); +INSERT INTO {vars} VALUES (19,'gallery','date_format','Y-M-d'); +INSERT INTO {vars} VALUES (20,'gallery','date_time_format','Y-M-d H:i:s'); +INSERT INTO {vars} VALUES (21,'gallery','time_format','H:i:s'); +INSERT INTO {vars} VALUES (22,'gallery','show_credits','1'); +INSERT INTO {vars} VALUES (23,'gallery','credits','Powered by Gallery %version'); +INSERT INTO {vars} VALUES (25,'comment','spam_caught','0'); diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php index da0a7983..7b4d68f6 100644 --- a/modules/gallery/controllers/packager.php +++ b/modules/gallery/controllers/packager.php @@ -98,7 +98,7 @@ class Packager_Controller extends Controller { print "$sql_file is not writeable"; return; } - $command = "mysqldump --compact --add-drop-table -h{$conn['host']} " . + $command = "mysqldump --compact --skip-extended-insert --add-drop-table -h{$conn['host']} " . "-u{$conn['user']} $pass {$conn['database']} > $sql_file"; exec($command, $output, $status); if ($status) { @@ -153,7 +153,7 @@ class Packager_Controller extends Controller { $paths[] = "VARPATH . \"" . substr($name, strlen(VARPATH)) . "\""; } else { // @todo: serialize non-directories - print "Unknown file: $name"; + print "IGNORING FILE: $name\n"; return; } } -- cgit v1.2.3 From ecc7d881e3bad1dd8edf5cbd4382bda9a668fcb8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 05:52:50 -0700 Subject: Fix bug introduced in e0e450d90fe67ac199d82d2b8e902cff5c8b6c7d where it got rid of the 'img' var which is used when we set the click action on buttons. Partial fix for #528. --- modules/gallery/js/quick.js | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 32e34ef3..28ced3f6 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -11,6 +11,7 @@ $(document).ready(function() { var show_quick = function() { var cont = $(this); var quick = $(this).find(".gQuick"); + var img = cont.find(".gThumbnail,.gResize"); $("#gQuickPane").remove(); cont.append("
        "); $("#gQuickPane").hide(); -- cgit v1.2.3 From 6b013060aabc1d13545958fdb3c096faac2ba5a7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 06:15:44 -0700 Subject: Fix style: space after ) before {. --- modules/gallery/js/quick.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 28ced3f6..2dcb1c36 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -22,10 +22,10 @@ var show_quick = function() { function(data, textStatus) { $("#gQuickPane").html(data).slideDown("fast"); $(".ui-state-default").hover( - function(){ + function() { $(this).addClass("ui-state-hover"); }, - function(){ + function() { $(this).removeClass("ui-state-hover"); } ); -- cgit v1.2.3 From 4d0099e7165a4a1508eea58613cdc75e116464ff Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 06:24:10 -0700 Subject: Fix a bug where we're referring to $photo when we just uploaded a $movie, that causes the simpler uploader to throw an error for all movies. --- modules/gallery/controllers/simple_uploader.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index a059f986..75a7b810 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -58,13 +58,13 @@ class Simple_Uploader_Controller extends Controller { $path_info = @pathinfo($temp_filename); if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) { - $movie = movie::create($album, $temp_filename, $name, $title); + $item = movie::create($album, $temp_filename, $name, $title); log::success("content", t("Added a movie"), - html::anchor("movies/$movie->id", t("view movie"))); + html::anchor("movies/$item->id", t("view movie"))); } else { - $photo = photo::create($album, $temp_filename, $name, $title); + $item = photo::create($album, $temp_filename, $name, $title); log::success("content", t("Added a photo"), - html::anchor("photos/$photo->id", t("view photo"))); + html::anchor("photos/$item->id", t("view photo"))); } } catch (Exception $e) { Kohana::log("alert", $e->__toString()); @@ -76,7 +76,7 @@ class Simple_Uploader_Controller extends Controller { return; } unlink($temp_filename); - print "FILEID: $photo->id"; + print "FILEID: $item->id"; } else { header("HTTP/1.1 400 Bad Request"); print "ERROR: Invalid Upload"; -- cgit v1.2.3 From 214d977f4dc9ac78f4571a7cc89109fd95f5a2eb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 06:51:21 -0700 Subject: Don't close the dialog window after we successfully complete an action. The expectation is that we're going to reload the page (or redirect to a new url). If we close the dialog, then we can trigger the onhover for items we've just deleted causing errors. Simplify the API while we're at it by getting rid of the no-longer-used on_success argument to openDialog() This fixes #528. --- lib/gallery.dialog.js | 13 +++++-------- modules/gallery/js/quick.js | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'modules') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index fc66323e..74c2f20e 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -11,23 +11,20 @@ function handleDialogEvent(event) { event.preventDefault(); } -function ajaxify_dialog(on_success) { +function ajaxify_dialog() { $("#gDialog form").ajaxForm({ dataType: "json", success: function(data) { if (data.form) { $("#gDialog form").replaceWith(data.form); - ajaxify_dialog(on_success); + ajaxify_dialog(); on_form_loaded(); if (typeof data.reset == 'function') { eval(data.reset + '()'); } } if (data.result == "success") { - $("#gDialog").dialog("close"); - if (on_success) { - on_success(); - } else if (data.location) { + if (data.location) { window.location = data.location; } else { window.location.reload(); @@ -46,7 +43,7 @@ function ajaxify_dialog(on_success) { * @see handleDialogEvent() * @see showLoading() */ -function openDialog(element, on_success) { +function openDialog(element) { var sHref = $(element).attr("href"); var sTitle = $(element).attr("title"); var eDialog = '
        '; @@ -92,7 +89,7 @@ function openDialog(element, on_success) { $("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html()); } - ajaxify_dialog(on_success); + ajaxify_dialog(); }); return false; } diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 2dcb1c36..3ac97f8e 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -46,7 +46,7 @@ var quick_do = function(cont, pane, img) { return false; } if (pane.hasClass("gDialogLink")) { - openDialog(pane, function() { window.location.reload(); }); + openDialog(pane); } else { img.css("opacity", "0.1"); cont.addClass("gLoadingLarge"); -- cgit v1.2.3 From 245f4d39a731b60ac31a755ab4678bb83f211720 Mon Sep 17 00:00:00 2001 From: Shai Ben-Naphtali Date: Sun, 12 Jul 2009 01:37:20 +0800 Subject: This fixes ticket #513 Signed-off-by: Tim Almdal --- modules/gallery/views/simple_uploader.html.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index e1add7f7..8178ace2 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -182,8 +182,9 @@ if (num_files_selected > 0) { $("#gUploadCancel").show(); var stats = this.getStats(); - $("#gUploadQueueInfo").text("(completed " + stats.successful_uploads + - " of " + (stats.files_queued + stats.successful_uploads + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + $("#gUploadQueueInfo").text("( " + stats.successful_uploads + + " " + (stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); } // Auto start the upload @@ -254,8 +255,9 @@ function upload_complete(file) { var stats = this.getStats(); - $("#gUploadQueueInfo").text("(completed " + stats.successful_uploads + - " of " + (stats.files_queued + stats.successful_uploads + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + $("#gUploadQueueInfo").text("( " + stats.successful_uploads + + " " + (stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); } -- cgit v1.2.3 From 30346ec84214027e5e192020ce60608e48cb9530 Mon Sep 17 00:00:00 2001 From: Shai Ben-Naphtali Date: Sun, 12 Jul 2009 01:41:24 +0800 Subject: Fixed indentation of commit 2760e119bbfc3e2d436c404de194dbeea738a735 Signed-off-by: Tim Almdal --- modules/gallery/views/simple_uploader.html.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 8178ace2..92155434 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -183,8 +183,8 @@ $("#gUploadCancel").show(); var stats = this.getStats(); $("#gUploadQueueInfo").text("( " + stats.successful_uploads + - " " + (stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + " " + (stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); } // Auto start the upload @@ -256,8 +256,8 @@ function upload_complete(file) { var stats = this.getStats(); $("#gUploadQueueInfo").text("( " + stats.successful_uploads + - " " + (stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + " " + (stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); } -- cgit v1.2.3 From f2a3fa46f5a5cc31d251c1557f8b1cfbb6f46027 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:10:05 -0700 Subject: Change 'completed' status message to be a full sentence with javascript placeholders. --- modules/gallery/views/simple_uploader.html.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 92155434..bf3d7c57 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -255,9 +255,11 @@ function upload_complete(file) { var stats = this.getStats(); - $("#gUploadQueueInfo").text("( " + stats.successful_uploads + - " " + (stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + var msg = "()"; + msg = msg.replace("__COMPLETED__", stats.successful_uploads); + msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors; + $("#gUploadQueueInfo").text(msg); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); } -- cgit v1.2.3 From 8c6c3801bb6b9f9d4d68aef0cf808abcc667d342 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:12:29 -0700 Subject: Fix a typo in the last commit. I left off a closing paren. --- modules/gallery/views/simple_uploader.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index bf3d7c57..06a2eaff 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -258,7 +258,7 @@ var msg = "()"; msg = msg.replace("__COMPLETED__", stats.successful_uploads); msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors; + stats.upload_errors + stats.upload_cancelled + stats.queue_errors); $("#gUploadQueueInfo").text(msg); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); -- cgit v1.2.3 From 171522bf231e4fca13dd522e8f755e65a8d48b3b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:23:31 -0700 Subject: Add a "close" button. --- modules/server_add/views/server_add_tree_dialog.html.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules') diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index bbad4e69..8e9c1c01 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -46,4 +46,8 @@ }); }); + + -- cgit v1.2.3 From cbd80b5ff948e23a1fa8b0994291953d38f6a7bd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:37:49 -0700 Subject: Get rid of the form from server_add, we're not using it. Turn the cancel link into a themed close button which triggers a page reload. Add some padding to the left of the tree. --- .../server_add/views/server_add_tree_dialog.html.php | 17 +++++++++-------- themes/default/css/screen.css | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php index 8e9c1c01..21952849 100644 --- a/modules/server_add/views/server_add_tree_dialog.html.php +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -19,8 +19,6 @@
      - id"), array("method" => "post")) ?> -
      @@ -31,10 +29,16 @@ - "> + + + - + - diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index c4670a4d..0c65cd96 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -899,8 +899,14 @@ form .gError, /* Server Add */ +#gServerAdd button { + float: left; + margin-bottom: .5em; +} + #gServerAddTree { cursor: pointer; + padding-left: 4px; } #gServerAddTree li { -- cgit v1.2.3 From e2967aa1c1a0232e1a1f162db46e6f6db7154dac Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 07:45:41 -0700 Subject: Fix a problem in delete() where we were referencing $parent without saving its value before $item got deleted. Further fix for #528. --- modules/gallery/controllers/quick.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index 53af2ba6..de027c1b 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -127,6 +127,7 @@ class Quick_Controller extends Controller { $msg = t("Deleted photo %title", array("title" => p::purify($item->title))); } + $parent = $item->parent(); $item->delete(); message::success($msg); -- cgit v1.2.3 From b4c279ebb453459a37550b6413a830bed6c74b17 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 17:40:32 -0700 Subject: Fix whitespace typo. --- modules/gallery/libraries/Menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index d37be7d3..162cd3b0 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -136,7 +136,7 @@ class Menu_Core extends Menu_Element { return new Menu_Element_Dialog($type); case "root": - return new Menu("root"); + return new Menu("root"); case "submenu": return new Menu("submenu"); -- cgit v1.2.3 From 895fbfd95b5e7a42dd865f4a18401fd2e1491bc2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 17:59:55 -0700 Subject: Get the thumbnail menu working. 1) Stop changing the menu classes in JS, instead allow us to specify it in the Menu class itself and then set it to be gThumbMenu in Theme_View 2) Move the gThumbMenu init code to the bottom of the $(document).ready() block; something in there was interfering with it. --- modules/gallery/libraries/Menu.php | 9 ++++-- modules/gallery/libraries/Theme_View.php | 11 ++++---- themes/default/css/screen.css | 8 +++--- themes/default/js/ui.init.js | 47 ++++++++++++++++---------------- 4 files changed, 38 insertions(+), 37 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 162cd3b0..a39b59a5 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -136,7 +136,9 @@ class Menu_Core extends Menu_Element { return new Menu_Element_Dialog($type); case "root": - return new Menu("root"); + $menu = new Menu("root"); + $menu->css_class("gMenu"); + return $menu; case "submenu": return new Menu("submenu"); @@ -156,6 +158,7 @@ class Menu_Core extends Menu_Element { } } } + return $this; } public function __construct($type) { @@ -206,8 +209,8 @@ class Menu_Core extends Menu_Element { } public function __toString() { - $html = $this->is_root ? "
        " : - "
      • label\">$this->label
          "; + $html = $this->is_root ? "
            css_class\">" : + "
          • label\">$this->label
              "; $html .= implode("\n", $this->elements); $html .= $this->is_root ? "
            " : "
          "; return $html; diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 75138f25..fa45ec89 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -99,19 +99,19 @@ class Theme_View_Core extends Gallery_View { } public function album_menu() { - $this->_menu("album"); + print $this->_menu("album"); } public function tag_menu() { - $this->_menu("tag"); + print $this->_menu("tag"); } public function photo_menu() { - $this->_menu("photo"); + print $this->_menu("photo"); } public function thumb_menu($item) { - $this->_menu("thumb", $item); + print $this->_menu("thumb", $item)->css_class("gThumbMenu"); } private function _menu($type, $item=null) { @@ -127,8 +127,7 @@ class Theme_View_Core extends Gallery_View { } } - $menu->compact(); - print $menu; + return $menu->compact(); } public function pager() { diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index 93b68e68..c0954690 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -582,21 +582,21 @@ form .gError, margin-bottom: 0; } -/* Photo Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* Thumb Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#gContent .gPhotoMenu { +#gContent .gThumbMenu { bottom: 0; left: 0; position: absolute; width: 100%; } -#gContent .gPhotoMenu li { +#gContent .gThumbMenu li { border-left: none; border-right: none; } -#gContent .gPhotoMenu a:hover { +#gContent .gThumbMenu a:hover { text-decoration: none; } diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index 37261727..ac7ef8d2 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -15,8 +15,6 @@ $(document).ready(function() { // Remove .gMenu from thumb menu's before initializing Superfish // @todo gallery_menu should only apply gMenu to top-level menus, submenus should be gSubMenu-N - $("#gContent .gItem .gMenu").removeClass("gMenu"); - $("#gContent .gQuick + ul").addClass("gPhotoMenu"); // Initialize Superfish menus $("ul.gMenu").addClass("sf-menu"); @@ -41,28 +39,6 @@ $(document).ready(function() { $(dialogLinks[i]).bind("click", handleDialogEvent); } - // Initialize photo menus - if ($("#gContent .gPhotoMenu").length) { - $("#gContent .gPhotoMenu li").addClass("ui-state-default"); - $("#gContent .gPhotoMenu li a") - .not('[class]') - .addClass("gButtonLink ui-icon") - .css({ - "height":"10px", - "margin":"0", - "padding":"0" - }); - //$(".gPhotoMenu ul").hide(); - $(".gPhotoMenu").hover( - function(){ - $(this + " ul").show(); - }, - function(){ - $(this + " ul").hide(); - } - ); - } - // Initialize view menu if ($("#gViewMenu").length) { $("#gViewMenu ul").removeClass("gMenu").removeClass("sf-menu"); @@ -118,6 +94,29 @@ $(document).ready(function() { } ); + // Initialize thumbnail menus + if ($("#gContent .gThumbMenu").length) { + $("#gContent .gThumbMenu li").addClass("ui-state-default"); + $("#gContent .gThumbMenu li a") + .not('[class]') + .addClass("gButtonLink ui-icon") + .css({ + height: "10px", + margin: "0", + padding: "0" + }); + + $(".gThumbMenu ul").hide(); + $(".gThumbMenu").hover( + function() { + $(this).find("ul").slideDown("fast"); + }, + function() { + $(this).find("ul").slideUp("slow"); + } + ); + } + }); /** -- cgit v1.2.3 From 980923839930fde45120872dcadd437abfbbc09d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 19:17:12 -0700 Subject: Unescape ' also (single quote) --- modules/gallery/controllers/file_proxy.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 0d64bcd9..03303d66 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -32,8 +32,9 @@ class File_Proxy_Controller extends Controller { $request_uri = $this->input->server("REQUEST_URI"); $request_uri = preg_replace("/\?.*/", "", $request_uri); - // Unescape %7E ("~") and %20 (" ") - $request_uri = str_replace(array("%7E", "%20"), array("~", " "), $request_uri); + // Unescape %7E (~), %20 ( ) and ' (') + // @todo: figure out why we have to do this and unescape everything appropriate + $request_uri = str_replace(array("%7E", "%20", "'"), array("~", " ", "'"), $request_uri); // var_uri: http://example.com/gallery3/var/ $var_uri = url::file("var/"); -- cgit v1.2.3 From ac181d6227f77cfa33585704fdbc1b041a129e6a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 11 Jul 2009 20:12:32 -0700 Subject: Whitespace fixes. --- modules/gallery/helpers/MY_remote.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/MY_remote.php b/modules/gallery/helpers/MY_remote.php index 4abf5bf1..af2a05d8 100644 --- a/modules/gallery/helpers/MY_remote.php +++ b/modules/gallery/helpers/MY_remote.php @@ -21,11 +21,11 @@ class remote extends remote_Core { static function post($url, $post_data_array, $extra_headers=array()) { $post_data_raw = self::_encode_post_data($post_data_array, $extra_headers); - + /* Read the web page into a buffer */ list ($response_status, $response_headers, $response_body) = self::do_request($url, 'POST', $extra_headers, $post_data_raw); - + return array($response_body, $response_status, $response_headers); } @@ -49,22 +49,23 @@ class remote extends remote_Core { } $post_data_raw .= urlencode($key) . '=' . urlencode($value); } - + $extra_headers['Content-Type'] = 'application/x-www-form-urlencoded'; $extra_headers['Content-Length'] = strlen($post_data_raw); - + return $post_data_raw; } /** * A single request, without following redirects * - * @todo: Handle redirects? If so, only for GET (i.e. not for POST), and use G2's WebHelper_simple::_parseLocation logic. + * @todo: Handle redirects? If so, only for GET (i.e. not for POST), and use G2's + * WebHelper_simple::_parseLocation logic. */ static function do_request($url, $method='GET', $headers=array(), $body='') { /* Convert illegal characters */ $url = str_replace(' ', '%20', $url); - + $url_components = self::_parse_url_for_fsockopen($url); $handle = fsockopen( $url_components['fsockhost'], $url_components['port'], $errno, $errstr, 5); @@ -72,12 +73,12 @@ class remote extends remote_Core { // log "Error $errno: '$errstr' requesting $url"; return array(null, null, null); } - + $header_lines = array('Host: ' . $url_components['host']); foreach ($headers as $key => $value) { $header_lines[] = $key . ': ' . $value; } - + $success = fwrite($handle, sprintf("%s %s HTTP/1.0\r\n%s\r\n\r\n%s", $method, $url_components['uri'], @@ -89,7 +90,7 @@ class remote extends remote_Core { return array(null, null, null); } fflush($handle); - + /* * Read the status line. fgets stops after newlines. The first line is the protocol * version followed by a numeric status code and its associated textual phrase. @@ -99,7 +100,7 @@ class remote extends remote_Core { // 'Empty http response code, maybe timeout' return array(null, null, null); } - + /* Read the headers */ $response_headers = array(); while (!feof($handle)) { @@ -107,10 +108,10 @@ class remote extends remote_Core { if (empty($line)) { break; } - + /* Normalize the line endings */ $line = str_replace("\r", '', $line); - + list ($key, $value) = explode(':', $line, 2); if (isset($response_headers[$key])) { if (!is_array($response_headers[$key])) { @@ -121,7 +122,7 @@ class remote extends remote_Core { $response_headers[$key] = trim($value); } } - + /* Read the body */ $response_body = ''; while (!feof($handle)) { -- cgit v1.2.3 From 9588e8604d46e548dc4ac8788589f9f89b1992ab Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 12 Jul 2009 20:08:02 -0700 Subject: Use %27 instead of ' (the latter is the wrong form of escaping for urls). --- modules/gallery/controllers/file_proxy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index 03303d66..c5b34033 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -32,9 +32,9 @@ class File_Proxy_Controller extends Controller { $request_uri = $this->input->server("REQUEST_URI"); $request_uri = preg_replace("/\?.*/", "", $request_uri); - // Unescape %7E (~), %20 ( ) and ' (') + // Unescape %7E (~), %20 ( ) and %27 (') // @todo: figure out why we have to do this and unescape everything appropriate - $request_uri = str_replace(array("%7E", "%20", "'"), array("~", " ", "'"), $request_uri); + $request_uri = str_replace(array("%7E", "%20", "%27"), array("~", " ", "'"), $request_uri); // var_uri: http://example.com/gallery3/var/ $var_uri = url::file("var/"); -- cgit v1.2.3 From ff0b66a1a4ed189c3e02a8ad50a63f4d65b3bfa7 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 12 Jul 2009 22:53:47 -0600 Subject: Put owner's url into user link. Seems better than displaying email until we have something like a user profile page. --- modules/info/helpers/info_theme.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/info/helpers/info_theme.php b/modules/info/helpers/info_theme.php index 863317a8..51378e54 100644 --- a/modules/info/helpers/info_theme.php +++ b/modules/info/helpers/info_theme.php @@ -37,7 +37,11 @@ class info_theme_Core { } if ($item->owner) { $results .= "
        • "; - $results .= t("By: %owner_name", array("owner_name" => "{$item->owner->full_name}")); + if ($item->owner->url) { + $results .= t("By: %owner_name", array("owner_name" => "owner->url}\">{$item->owner->full_name}")); + } else { + $results .= t("By: %owner_name", array("owner_name" => "{$item->owner->full_name}")); + } $results .= "
        • "; } return $results; -- cgit v1.2.3 From a944bf4259a6ff31ac647a3d8336bd5175c3640a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 13 Jul 2009 06:43:44 -0700 Subject: Avoid using the bare word "on" in a value; it breaks PHP 5.3. Fixes ticket #540. --- modules/comment/module.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/comment/module.info b/modules/comment/module.info index 946f1d39..55997317 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. +description = "Allows users and guests to leave comments on photos and albums." version = 2 -- cgit v1.2.3 From e2a9a1d28459b96e412004df4d4ec010fb9b30e2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 13 Jul 2009 10:36:55 -0700 Subject: Add quotes around all values that contain spaces in them, and add a test to make sure that we continue to do so. This makes sure that we don't have problems with 5.3 which treats the literal "on" as a boolean. --- modules/akismet/module.info | 2 +- modules/comment/module.info | 2 +- modules/digibug/module.info | 4 +-- modules/exif/module.info | 2 +- modules/g2_import/module.info | 4 +-- modules/gallery/module.info | 4 +-- modules/gallery/tests/File_Structure_Test.php | 37 +++++++++++++++++++++++++++ modules/image_block/module.info | 4 +-- modules/info/module.info | 4 +-- modules/notification/module.info | 2 +- modules/organize/module.info | 4 +-- modules/recaptcha/module.info | 2 +- 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_default/theme.info | 6 ++--- themes/default/theme.info | 6 ++--- 21 files changed, 74 insertions(+), 37 deletions(-) (limited to 'modules') diff --git a/modules/akismet/module.info b/modules/akismet/module.info index d45d8a7b..b61ed107 100644 --- a/modules/akismet/module.info +++ b/modules/akismet/module.info @@ -1,3 +1,3 @@ -name = Akismet +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 diff --git a/modules/comment/module.info b/modules/comment/module.info index 55997317..c371cf27 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,3 @@ -name = Comments +name = "Comments" description = "Allows users and guests to leave comments on photos and albums." version = 2 diff --git a/modules/digibug/module.info b/modules/digibug/module.info index c25a2454..be4e880a 100644 --- a/modules/digibug/module.info +++ b/modules/digibug/module.info @@ -1,3 +1,3 @@ -name = Digibug -description = Digibug Photo Printing Module +name = "Digibug" +description = "Digibug Photo Printing Module" version = 2 diff --git a/modules/exif/module.info b/modules/exif/module.info index 1e16a5ff..c8ae688e 100644 --- a/modules/exif/module.info +++ b/modules/exif/module.info @@ -1,3 +1,3 @@ -name = Exif Data +name = "Exif Data" description = "Extract Exif data and display it on photo pages." version = 1 diff --git a/modules/g2_import/module.info b/modules/g2_import/module.info index 9e04f49b..554cf33b 100644 --- a/modules/g2_import/module.info +++ b/modules/g2_import/module.info @@ -1,3 +1,3 @@ -name = Gallery2 Import -description = Import your Gallery 2 content into Gallery 3 +name = "Gallery2 Import" +description = "Import your Gallery 2 content into Gallery 3" version = 1 diff --git a/modules/gallery/module.info b/modules/gallery/module.info index c184aba7..64a30b1f 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ -name = Gallery 3 -description = Gallery core application +name = "Gallery 3" +description = "Gallery core application" version = 6 diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 06f456ff..8a97e00b 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -213,6 +213,43 @@ class File_Structure_Test extends Unit_Test_Case { } } } + + public function module_info_is_well_formed_test() { + $info_files = array_merge( + glob("modules/*/module.info"), + glob("themes/*/module.info")); + + $errors = array(); + foreach ($info_files as $file) { + foreach (file($file) as $line) { + $parts = explode("=", $line, 2); + $values[trim($parts[0])] = trim($parts[1]); + } + + $module = dirname($file); + // Certain keys must exist + foreach (array("name", "description", "version") as $key) { + if (!array_key_exists($key, $values)) { + $errors[] = "$module: missing key $key"; + } + } + + // Any values containing spaces must be quoted + foreach ($values as $key => $value) { + if (strpos($value, " ") !== false && !preg_match('/^".*"$/', $value)) { + $errors[] = "$module: value for $key must be quoted"; + } + } + + // The file must parse + if (!is_array(parse_ini_file($file))) { + $errors[] = "$module: info file is not parseable"; + } + } + if ($errors) { + $this->assert_true(false, $errors); + } + } } class PhpCodeFilterIterator extends FilterIterator { diff --git a/modules/image_block/module.info b/modules/image_block/module.info index 8852d33c..e6d85048 100644 --- a/modules/image_block/module.info +++ b/modules/image_block/module.info @@ -1,3 +1,3 @@ -name = Image Block -description = Display a random image in the sidebar +name = "Image Block" +description = "Display a random image in the sidebar" version = 1 diff --git a/modules/info/module.info b/modules/info/module.info index ce03473e..e352213c 100644 --- a/modules/info/module.info +++ b/modules/info/module.info @@ -1,3 +1,3 @@ -name = Info -description = Display extra information about photos and albums +name = "Info" +description = "Display extra information about photos and albums" version = 1 diff --git a/modules/notification/module.info b/modules/notification/module.info index d4dc34e0..31684ccf 100644 --- a/modules/notification/module.info +++ b/modules/notification/module.info @@ -1,3 +1,3 @@ -name = Notification +name = "Notification" description = "Send notifications to users when changes are made to watched albums." version = 1 diff --git a/modules/organize/module.info b/modules/organize/module.info index b3ae94a3..5c6b1de0 100644 --- a/modules/organize/module.info +++ b/modules/organize/module.info @@ -1,3 +1,3 @@ -name = Organize -description = Organize your gallery by apply tags or moving images +name = "Organize" +description = "Organize your gallery by apply tags or moving images" version = 1 diff --git a/modules/recaptcha/module.info b/modules/recaptcha/module.info index 9f44648a..cfa1bf7a 100644 --- a/modules/recaptcha/module.info +++ b/modules/recaptcha/module.info @@ -1,3 +1,3 @@ -name = reCAPTCHA +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 diff --git a/modules/rss/module.info b/modules/rss/module.info index ffd26192..81ee7848 100644 --- a/modules/rss/module.info +++ b/modules/rss/module.info @@ -1,3 +1,3 @@ -name = RSS -description = Provide a RSS feeds +name = "RSS" +description = "Provide a RSS feeds" version = 1 diff --git a/modules/search/module.info b/modules/search/module.info index b286ab6c..f417c4fa 100644 --- a/modules/search/module.info +++ b/modules/search/module.info @@ -1,3 +1,3 @@ -name = Search -description = Allows users to search their Gallery +name = "Search" +description = "Allows users to search their Gallery" version = 1 diff --git a/modules/server_add/module.info b/modules/server_add/module.info index 295d3beb..23acab94 100644 --- a/modules/server_add/module.info +++ b/modules/server_add/module.info @@ -1,3 +1,3 @@ -name = Server Add -description = Allows authorized users to load images directly from your web server +name = "Server Add" +description = "Allows authorized users to load images directly from your web server" version = 3 diff --git a/modules/slideshow/module.info b/modules/slideshow/module.info index 5eb69ce3..6841199a 100644 --- a/modules/slideshow/module.info +++ b/modules/slideshow/module.info @@ -1,3 +1,3 @@ -name = Slideshow -description = Allows users to view a slideshow of photos +name = "Slideshow" +description = "Allows users to view a slideshow of photos" version = 1 diff --git a/modules/tag/module.info b/modules/tag/module.info index 562d5c32..e505dd81 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 +name = "Tags" +description = "Allows users to tag photos and albums" version = 1 diff --git a/modules/user/module.info b/modules/user/module.info index 2dba517d..8a9af407 100644 --- a/modules/user/module.info +++ b/modules/user/module.info @@ -1,3 +1,3 @@ -name = Users and Groups -description = Provides user and group management +name = "Users and Groups" +description = "Provides user and group management" version = 1 diff --git a/modules/watermark/module.info b/modules/watermark/module.info index 7f866695..abd4a3cf 100644 --- a/modules/watermark/module.info +++ b/modules/watermark/module.info @@ -1,3 +1,3 @@ -name = Watermarks -description = Allows users to watermark their photos +name = "Watermarks" +description = "Allows users to watermark their photos" version = 1 diff --git a/themes/admin_default/theme.info b/themes/admin_default/theme.info index d21b0ff5..b3d9741d 100644 --- a/themes/admin_default/theme.info +++ b/themes/admin_default/theme.info @@ -1,6 +1,6 @@ -name = Gallery Default -description = A crisp Site Administration theme with soft colors and drop down menus. +name = "Gallery Default" +description = "A crisp Site Administration theme with soft colors and drop down menus." version = 1 -author = Gallery Team +author = "Gallery Team" admin = 1 site = 0 diff --git a/themes/default/theme.info b/themes/default/theme.info index 71e8a740..5f19d0d7 100644 --- a/themes/default/theme.info +++ b/themes/default/theme.info @@ -1,6 +1,6 @@ -name = Gallery Default -description = A crisp and distinctive theme that uses large fonts and icons for easy navigation and an enjoyable browsing experience. +name = "Gallery Default" +description = "A crisp and distinctive theme that uses large fonts and icons for easy navigation and an enjoyable browsing experience." version = 1 -author = Gallery Team +author = "Gallery Team" site = 1 admin = 0 -- cgit v1.2.3 From 2a40f48d659c5b0ac3ab90e25aaaef12dce99c39 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 06:36:48 -0700 Subject: Add /opt/bin as a binary path. --- modules/gallery/helpers/graphics.php | 2 +- modules/gallery/helpers/movie.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index bbae0602..db9b2ef5 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -331,7 +331,7 @@ class graphics_Core { if (!isset($gd["GD Version"])) { $gd["GD Version"] = false; } - putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin"); + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin"); return array("gd" => $gd, "imagemagick" => $exec ? dirname(exec("which convert")) : false, "graphicsmagick" => $exec ? dirname(exec("which gm")) : false); diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 54159294..d62ead76 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -145,7 +145,7 @@ class movie_Core { static function find_ffmpeg() { if (!$ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) { - putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin"); + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin"); if (function_exists("exec")) { $ffmpeg_path = exec("which ffmpeg"); } -- cgit v1.2.3 From 94e33c821f28601b60d51581c632ba1e10288298 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 14 Jul 2009 06:42:50 -0700 Subject: Removed unnecessary contructor from the HTMLPurifier.php library class --- modules/gallery/libraries/HtmlPurifier.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/HtmlPurifier.php b/modules/gallery/libraries/HtmlPurifier.php index f9d5353b..daa5896e 100644 --- a/modules/gallery/libraries/HtmlPurifier.php +++ b/modules/gallery/libraries/HtmlPurifier.php @@ -20,11 +20,6 @@ class HtmlPurifier_Core { private static $_instance; - public function __construct($name = NULL, $data = NULL, $type = NULL) { - parent::__construct($name, $data, $type); - $this->set_global("csrf", access::csrf_token()); - } - static function instance($config=null) { require_once(dirname(__file__) . "/HTMLPurifier/HTMLPurifier.auto.php"); if (self::$_instance == NULL) { -- cgit v1.2.3 From cc05d279ea9c7317f6393b0336df724dbb4a898f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 14 Jul 2009 07:55:30 -0700 Subject: Update HTMLPurifier to version 4.4.0 --- modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php | 2 +- modules/gallery/lib/HTMLPurifier/HTMLPurifier.php | 6 +++--- modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php | 2 +- modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php | 2 +- modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php | 4 ++++ 5 files changed, 10 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php index 6ea32f72..e57f2ab3 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.includes.php @@ -7,7 +7,7 @@ * primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS * FILE, changes will be overwritten the next time the script is run. * - * @version 3.3.0 + * @version 4.0.0 * * @warning * You must *not* include any other HTML Purifier files before this file, diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php index 0b53d1b4..71e90632 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier.php @@ -19,7 +19,7 @@ */ /* - HTML Purifier 3.3.0 - Standards Compliant HTML Filtering + HTML Purifier 4.0.0 - Standards Compliant HTML Filtering Copyright (C) 2006-2008 Edward Z. Yang This library is free software; you can redistribute it and/or @@ -55,10 +55,10 @@ class HTMLPurifier { /** Version of HTML Purifier */ - public $version = '3.3.0'; + public $version = '4.0.0'; /** Constant with version of HTML Purifier */ - const VERSION = '3.3.0'; + const VERSION = '4.0.0'; /** Global configuration object */ public $config; diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php index 5b2592b5..28529e7f 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Config.php @@ -20,7 +20,7 @@ class HTMLPurifier_Config /** * HTML Purifier's version */ - public $version = '3.3.0'; + public $version = '4.0.0'; /** * Bool indicator whether or not to automatically finalize diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php index 3d8010f4..9f20a412 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer.php @@ -285,7 +285,7 @@ class HTMLPurifier_Lexer */ public function extractBody($html) { $matches = array(); - $result = preg_match('!]*>(.+?)!is', $html, $matches); + $result = preg_match('!]*>(.*)!is', $html, $matches); if ($result) { return $matches[1]; } else { diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php index 19676e51..16969bed 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/URIFilter/Munge.php @@ -23,6 +23,10 @@ class HTMLPurifier_URIFilter_Munge extends HTMLPurifier_URIFilter if (is_null($uri->host) || empty($scheme_obj->browsable)) { return true; } + // don't redirect if target host is our host + if ($uri->host === $config->getDefinition('URI')->host) { + return true; + } $this->makeReplace($uri, $config, $context); $this->replace = array_map('rawurlencode', $this->replace); -- cgit v1.2.3 From c3f93957d7af6c6058582fcb1acbe5b8374a70ed Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 10:56:10 -0700 Subject: Move the gallery version out of a module variable and into a constant in the gallery helper. This will let us bump the version without having to bump the gallery module number. --- modules/gallery/helpers/gallery.php | 2 ++ modules/gallery/helpers/gallery_installer.php | 9 ++++++--- modules/gallery/helpers/gallery_theme.php | 3 +-- modules/gallery/module.info | 2 +- modules/gallery/views/admin_block_stats.html.php | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index e22cc17f..a32ac484 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class gallery_Core { + const VERSION = "3.0 beta 2"; + /** * If Gallery is in maintenance mode, then force all non-admins to get routed to a "This site is * down for maintenance" page. diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 0e5d29b9..28c1990f 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -251,7 +251,6 @@ class gallery_installer { block_manager::add("dashboard_center", "gallery", "photo_stream"); block_manager::add("dashboard_center", "gallery", "log_entries"); - module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); module::set_var("gallery", "choose_default_tookit", 1); module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); @@ -259,7 +258,7 @@ class gallery_installer { module::set_var("gallery", "show_credits", 1); // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by Gallery %version"); - module::set_version("gallery", 6); + module::set_version("gallery", 7); } static function upgrade($version) { @@ -268,7 +267,6 @@ class gallery_installer { module::set_var("gallery", "date_format", "Y-M-d"); module::set_var("gallery", "date_time_format", "Y-M-d H:i:s"); module::set_var("gallery", "time_format", "H:i:s"); - module::set_var("gallery", "version", "3.0 pre beta 2 (git)"); module::set_version("gallery", $version = 2); } @@ -302,6 +300,11 @@ class gallery_installer { $db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY"); module::set_version("gallery", $version = 6); } + + if ($version == 6) { + module::clear_var("gallery", "version"); + module::set_version("gallery", $version = 7); + } } static function uninstall() { diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 0e3150bc..226b8a42 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -116,8 +116,7 @@ class gallery_theme_Core { static function credits() { return "
        • " . t(module::get_var("gallery", "credits"), - array("url" => "http://gallery.menalto.com", - "version" => module::get_var("gallery", "version"))) . + array("url" => "http://gallery.menalto.com", "version" => gallery::VERSION)) . "
        • "; } diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 64a30b1f..cefcaa08 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 6 +version = 7 diff --git a/modules/gallery/views/admin_block_stats.html.php b/modules/gallery/views/admin_block_stats.html.php index 395ed71d..1dec8ccd 100644 --- a/modules/gallery/views/admin_block_stats.html.php +++ b/modules/gallery/views/admin_block_stats.html.php @@ -1,7 +1,7 @@
          • - module::get_var("gallery", "version"))) ?> + gallery::VERSION)) ?>
          • $album_count)) ?> -- cgit v1.2.3 From 8cfb0677091a6bc7e666338fc15f2e23d8934f7c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 12:03:31 -0700 Subject: Revert "Remove the reference to organize.css is it is no longer used and is" This reverts commit 31ffb82382d76390f1206944329dde86c687349c. --- modules/organize/helpers/organize_theme.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php index 1c75e819..02f1f589 100644 --- a/modules/organize/helpers/organize_theme.php +++ b/modules/organize/helpers/organize_theme.php @@ -22,5 +22,6 @@ class organize_theme { // @tdo remove the addition css and organize.js (just here to test) $theme->script("modules/organize/js/organize_init.js"); $theme->script("modules/organize/js/organize.js"); + $theme->css("modules/organize/css/organize.css"); } } -- cgit v1.2.3 From 768a1485e19021f4a4b3b0b529f3df36167a7881 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 12:07:29 -0700 Subject: Remove references to missing organize_edit_drawer.png --- modules/organize/css/organize.css | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules') diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css index 1e608beb..e58cd5a5 100644 --- a/modules/organize/css/organize.css +++ b/modules/organize/css/organize.css @@ -163,7 +163,6 @@ } #gOrganizeEditHandleLeft { - background-image: url(organize_edit_drawer.png); background-color: #FFF; float: left; height: 30px; @@ -200,7 +199,6 @@ #gOrganizeEditHandleRight { background-color: #FFF; - background-image: url(organize_edit_drawer.png); background-position: -15px 0; float: right; height: 30px; -- cgit v1.2.3 From c4a30930112e9ab14678fe96f21741f1832c20f7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 12:36:57 -0700 Subject: 3rd attempt to fix localization messages. Last time around I didn't dig deep enough, but now we form the complete message using t() style semantics to replace % placeholders with __ style JS placeholders. Also, stop appending the (completed) text to existing messages.. roll it together. --- modules/gallery/views/simple_uploader.html.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/modules/gallery/views/simple_uploader.html.php b/modules/gallery/views/simple_uploader.html.php index 06a2eaff..38ac518c 100644 --- a/modules/gallery/views/simple_uploader.html.php +++ b/modules/gallery/views/simple_uploader.html.php @@ -32,8 +32,9 @@

          - - + + + " onclick="swfu.cancelQueue();">

          @@ -181,10 +182,7 @@ function file_dialog_complete(num_files_selected, num_files_queued) { if (num_files_selected > 0) { $("#gUploadCancel").show(); - var stats = this.getStats(); - $("#gUploadQueueInfo").text("( " + stats.successful_uploads + - " " + (stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors) + ")"); + $("#gUploadQueueInfo").text(get_completed_status_msg(this.getStats())); } // Auto start the upload @@ -255,16 +253,20 @@ function upload_complete(file) { var stats = this.getStats(); - var msg = "()"; - msg = msg.replace("__COMPLETED__", stats.successful_uploads); - msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + - stats.upload_errors + stats.upload_cancelled + stats.queue_errors); - $("#gUploadQueueInfo").text(msg); + $("#gUploadQueueInfo").text(get_completed_status_msg(stats)); if (stats.files_queued === 0) { $("#gUploadCancel").hide(); } } + function get_completed_status_msg(stats) { + var msg = " "__COMPLETED__", "total" => "__TOTAL__")) ?>"; + msg = msg.replace("__COMPLETED__", stats.successful_uploads); + msg = msg.replace("__TOTAL__", stats.files_queued + stats.successful_uploads + + stats.upload_errors + stats.upload_cancelled + stats.queue_errors); + return msg; + } + // This event comes from the Queue Plugin function queue_complete(num_files_uploaded) { var status_msg = ""; -- cgit v1.2.3 From 4720e456418f5b3933a6fdfc9e3b88372792dab1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 12:55:03 -0700 Subject: Don't use "else" clauses in upgrade() -- it prevents multiple version bumps at once. --- modules/server_add/helpers/server_add_installer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php index 67c7a377..cd278eb7 100644 --- a/modules/server_add/helpers/server_add_installer.php +++ b/modules/server_add/helpers/server_add_installer.php @@ -42,7 +42,9 @@ class server_add_installer { PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("server_add", $version = 2); - } else if ($version == 2) { + } + + if ($version == 2) { $db->query("ALTER TABLE {server_add_files} ADD COLUMN `item_id` int(9)"); $db->query("ALTER TABLE {server_add_files} ADD COLUMN `parent_id` int(9)"); module::set_version("server_add", $version = 3); -- cgit v1.2.3 From 7de339a676f32ed445f3e4215c994a5fe16c1188 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 14 Jul 2009 16:10:37 -0700 Subject: Remove extra debug statements. --- modules/g2_import/helpers/g2_import.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 7dd799c8..8b4169dd 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -471,8 +471,6 @@ class g2_import_Core { $corrupt = 1; } try { - Kohana::log("error", "description: " . self::extract_description($g2_item)); - Kohana::log("error", "title: " . $g2_item->getTitle()); $item = photo::create( $parent, $g2_path, -- cgit v1.2.3 From 2cba5d93956ce38f6d08ca350124d9bd21270be6 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 15 Jul 2009 07:56:52 +0800 Subject: Fix 542 by changing the wording from you to your, thanks Floridave Signed-off-by: Tim Almdal --- modules/gallery/controllers/admin_languages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php index 4639de89..d1b805da 100644 --- a/modules/gallery/controllers/admin_languages.php +++ b/modules/gallery/controllers/admin_languages.php @@ -119,7 +119,7 @@ class Admin_Languages_Controller extends Admin_Controller { private function _share_translations_form() { $form = new Forge("admin/languages/share", "", "post", array("id" => "gShareTranslationsForm")); $group = $form->group("sharing") - ->label(t("Sharing you own translations with the Gallery community is easy. Please do!")); + ->label(t("Sharing your own translations with the Gallery community is easy. Please do!")); $api_key = l10n_client::api_key(); $server_link = l10n_client::server_api_key_url(); $group->input("api_key") -- cgit v1.2.3 From c4fce2cc680c3257cf6ea7844b8ee9e61c02db09 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 15 Jul 2009 20:32:53 -0700 Subject: Remove a completed @todo. --- modules/gallery/controllers/albums.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index d141d157..e6d01b90 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -181,10 +181,6 @@ class Albums_Controller extends Items_Controller { } } - // @todo - // @todo we need to make sure that filename / dirname components can't contain a / - // @todo - if ($valid) { $orig = clone $album; $album->title = $form->edit_album->title->value; -- cgit v1.2.3 From 5cb2f42628bdfa66a1a0821efb5f9d8e78f06626 Mon Sep 17 00:00:00 2001 From: Kevin Nehls Date: Wed, 15 Jul 2009 11:41:10 +0800 Subject: Fix backslashes in relative URLs of combined css files. Signed-off-by: Bharat Mediratta --- modules/gallery/libraries/Gallery_View.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 8a0be7f2..4715be09 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -135,6 +135,7 @@ class Gallery_View_Core extends View { $relative = substr(realpath(dirname($css_file) . "/$match[1]"), $docroot_length); if (!empty($relative)) { $search[] = $match[0]; + $relative = str_replace(DIRECTORY_SEPARATOR, "/", $relative); $replace[] = "url('" . url::abs_file($relative) . "')"; } else { Kohana::log("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'"); -- cgit v1.2.3 From 85b0f580291e375a2c5ec21b8210e59023ee24c2 Mon Sep 17 00:00:00 2001 From: Kevin Nehls Date: Thu, 16 Jul 2009 12:28:00 +0800 Subject: move fix for backslashes on windows outside of loop per bharat's suggestion Signed-off-by: Bharat Mediratta --- modules/gallery/libraries/Gallery_View.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 4715be09..133066d7 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -135,12 +135,12 @@ class Gallery_View_Core extends View { $relative = substr(realpath(dirname($css_file) . "/$match[1]"), $docroot_length); if (!empty($relative)) { $search[] = $match[0]; - $relative = str_replace(DIRECTORY_SEPARATOR, "/", $relative); $replace[] = "url('" . url::abs_file($relative) . "')"; } else { Kohana::log("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'"); } } + $replace = str_replace(DIRECTORY_SEPARATOR, "/", $replace); $css = str_replace($search, $replace, $css); } $imports = preg_match_all("#@import\s*['|\"]{0,1}(.*?)['|\"]{0,1};#", -- cgit v1.2.3 From b46998e392bbf52fadc9c8e13271d911dff01cbe Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Jul 2009 10:24:10 -0700 Subject: Update Xss_Security_Test to know about p::purify() and checkpoint the golden file. --- modules/gallery/tests/Xss_Security_Test.php | 2 +- modules/gallery/tests/xss_data.txt | 93 ++++++++++++++++------------- 2 files changed, 51 insertions(+), 44 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php index e179482c..9bde11dc 100644 --- a/modules/gallery/tests/Xss_Security_Test.php +++ b/modules/gallery/tests/Xss_Security_Test.php @@ -36,7 +36,7 @@ class Xss_Security_Test extends Unit_Test_Case { // If we find a "(" after a "p::clean" then start counting levels of parens and assume // that we're inside a p::clean() call until we find the matching close paren. - if ($token[0] == "(" && $str == "p::clean") { + if ($token[0] == "(" && ($str == "p::clean" || $str == "p::purify")) { $in_p_clean = 1; } else if ($token[0] == "(" && $in_p_clean) { $in_p_clean++; diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 982343f6..d1167555 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -141,22 +141,28 @@ modules/gallery/views/admin_maintenance.html.php 75 DIRTY $task->na modules/gallery/views/admin_maintenance.html.php 86 DIRTY $task->percent_complete modules/gallery/views/admin_maintenance.html.php 90 DIRTY $task->status modules/gallery/views/admin_maintenance.html.php 93 $task->owner()->name -modules/gallery/views/admin_maintenance.html.php 97 DIRTY $task->id -modules/gallery/views/admin_maintenance.html.php 97 DIRTY $csrf -modules/gallery/views/admin_maintenance.html.php 101 DIRTY $task->id -modules/gallery/views/admin_maintenance.html.php 101 DIRTY $csrf -modules/gallery/views/admin_maintenance.html.php 113 DIRTY $csrf -modules/gallery/views/admin_maintenance.html.php 140 DIRTY $task->state -modules/gallery/views/admin_maintenance.html.php 142 DIRTY $task->updated -modules/gallery/views/admin_maintenance.html.php 145 DIRTY $task->name -modules/gallery/views/admin_maintenance.html.php 157 DIRTY $task->status -modules/gallery/views/admin_maintenance.html.php 160 DIRTY $task->owner()->name -modules/gallery/views/admin_maintenance.html.php 164 DIRTY $task->id -modules/gallery/views/admin_maintenance.html.php 164 DIRTY $csrf -modules/gallery/views/admin_maintenance.html.php 168 DIRTY $task->id -modules/gallery/views/admin_maintenance.html.php 168 DIRTY $csrf -modules/gallery/views/admin_maintenance.html.php 171 DIRTY $task->id -modules/gallery/views/admin_maintenance.html.php 171 DIRTY $csrf +modules/gallery/views/admin_maintenance.html.php 98 DIRTY $task->id +modules/gallery/views/admin_maintenance.html.php 98 DIRTY $csrf +modules/gallery/views/admin_maintenance.html.php 102 DIRTY $task->id +modules/gallery/views/admin_maintenance.html.php 102 DIRTY $csrf +modules/gallery/views/admin_maintenance.html.php 115 DIRTY $csrf +modules/gallery/views/admin_maintenance.html.php 142 DIRTY $task->state +modules/gallery/views/admin_maintenance.html.php 144 DIRTY $task->updated +modules/gallery/views/admin_maintenance.html.php 147 DIRTY $task->name +modules/gallery/views/admin_maintenance.html.php 159 DIRTY $task->status +modules/gallery/views/admin_maintenance.html.php 162 DIRTY $task->owner()->name +modules/gallery/views/admin_maintenance.html.php 166 DIRTY $task->id +modules/gallery/views/admin_maintenance.html.php 166 DIRTY $csrf +modules/gallery/views/admin_maintenance.html.php 170 DIRTY $task->id +modules/gallery/views/admin_maintenance.html.php 170 DIRTY $csrf +modules/gallery/views/admin_maintenance.html.php 175 DIRTY $task->id +modules/gallery/views/admin_maintenance.html.php 175 DIRTY $csrf +modules/gallery/views/admin_maintenance.html.php 178 DIRTY $task->id +modules/gallery/views/admin_maintenance.html.php 178 DIRTY $csrf +modules/gallery/views/admin_maintenance_show_log.html.php 8 DIRTY $task->id +modules/gallery/views/admin_maintenance_show_log.html.php 8 DIRTY $csrf +modules/gallery/views/admin_maintenance_show_log.html.php 13 DIRTY $task->name +modules/gallery/views/admin_maintenance_show_log.html.php 15 $task->get_log() modules/gallery/views/admin_maintenance_task.html.php 5 DIRTY $task->id modules/gallery/views/admin_maintenance_task.html.php 5 DIRTY $csrf modules/gallery/views/admin_maintenance_task.html.php 26 DIRTY $task->name @@ -201,10 +207,10 @@ modules/gallery/views/admin_themes_preview.html.php 4 DIRTY $info->na modules/gallery/views/admin_themes_preview.html.php 7 DIRTY $url modules/gallery/views/after_install.html.php 11 $user->name modules/gallery/views/after_install.html.php 15 DIRTY $user->id -modules/gallery/views/kohana_error_page.php 98 DIRTY $message -modules/gallery/views/kohana_error_page.php 100 DIRTY $file -modules/gallery/views/kohana_error_page.php 100 DIRTY $line -modules/gallery/views/kohana_error_page.php 112 DIRTY $trace +modules/gallery/views/kohana_error_page.php 102 DIRTY $message +modules/gallery/views/kohana_error_page.php 104 DIRTY $file +modules/gallery/views/kohana_error_page.php 104 DIRTY $line +modules/gallery/views/kohana_error_page.php 116 DIRTY $trace modules/gallery/views/kohana_profiler.php 32 DIRTY $profile->render() modules/gallery/views/kohana_profiler.php 34 DIRTY $execution_time modules/gallery/views/l10n_client.html.php 17 DIRTY $string @@ -212,8 +218,8 @@ modules/gallery/views/l10n_client.html.php 19 DIRTY $string modules/gallery/views/l10n_client.html.php 20 DIRTY $string modules/gallery/views/l10n_client.html.php 22 DIRTY $string modules/gallery/views/l10n_client.html.php 28 DIRTY $l10n_search_form -modules/gallery/views/l10n_client.html.php 72 DIRTY $string_list -modules/gallery/views/l10n_client.html.php 73 DIRTY $plural_forms +modules/gallery/views/l10n_client.html.php 74 DIRTY $string_list +modules/gallery/views/l10n_client.html.php 75 DIRTY $plural_forms modules/gallery/views/move_browse.html.php 4 DIRTY $source->id modules/gallery/views/move_browse.html.php 39 DIRTY $tree modules/gallery/views/move_browse.html.php 42 DIRTY $source->id @@ -280,8 +286,8 @@ modules/gallery/views/simple_uploader.html.php 7 DIRTY $csrf modules/gallery/views/simple_uploader.html.php 9 $item->title modules/gallery/views/simple_uploader.html.php 29 $parent->title modules/gallery/views/simple_uploader.html.php 31 $item->title -modules/gallery/views/simple_uploader.html.php 85 DIRTY $item->id -modules/gallery/views/simple_uploader.html.php 89 DIRTY $csrf +modules/gallery/views/simple_uploader.html.php 86 DIRTY $item->id +modules/gallery/views/simple_uploader.html.php 90 DIRTY $csrf modules/gallery/views/upgrader.html.php 44 DIRTY $module->version modules/gallery/views/upgrader.html.php 44 DIRTY $module->code_version modules/gallery/views/upgrader.html.php 45 DIRTY $id @@ -417,16 +423,17 @@ modules/server_add/views/admin_server_add.html.php 14 DIRTY $csrf modules/server_add/views/admin_server_add.html.php 15 DIRTY $id modules/server_add/views/admin_server_add.html.php 19 DIRTY $path modules/server_add/views/admin_server_add.html.php 24 DIRTY $form -modules/server_add/views/server_add_tree.html.php 4 DIRTY $tree_id -modules/server_add/views/server_add_tree.html.php 6 DIRTY $file_info -modules/server_add/views/server_add_tree.html.php 10 $file_info -modules/server_add/views/server_add_tree.html.php 10 DIRTY $checked -modules/server_add/views/server_add_tree.html.php 10 $file -modules/server_add/views/server_add_tree_dialog.html.php 10 $album_title -modules/server_add/views/server_add_tree_dialog.html.php 15 $parent->title -modules/server_add/views/server_add_tree_dialog.html.php 17 $album_title -modules/server_add/views/server_add_tree_dialog.html.php 20 DIRTY $action -modules/server_add/views/server_add_tree_dialog.html.php 22 DIRTY $tree +modules/server_add/views/server_add_tree.html.php 12 DIRTY $dir +modules/server_add/views/server_add_tree.html.php 13 DIRTY $dir +modules/server_add/views/server_add_tree.html.php 20 DIRTY $file +modules/server_add/views/server_add_tree.html.php 25 DIRTY $file +modules/server_add/views/server_add_tree.html.php 27 $file +modules/server_add/views/server_add_tree_dialog.html.php 4 DIRTY $item->id +modules/server_add/views/server_add_tree_dialog.html.php 4 DIRTY $csrf +modules/server_add/views/server_add_tree_dialog.html.php 8 $item->title +modules/server_add/views/server_add_tree_dialog.html.php 14 $parent->title +modules/server_add/views/server_add_tree_dialog.html.php 18 $item->title +modules/server_add/views/server_add_tree_dialog.html.php 23 DIRTY $tree modules/tag/views/admin_tags.html.php 13 DIRTY $csrf modules/tag/views/admin_tags.html.php 27 DIRTY $tags->count() modules/tag/views/admin_tags.html.php 35 DIRTY $current_letter @@ -501,14 +508,14 @@ themes/admin_default/views/admin.html.php 37 DIRTY $theme->a themes/admin_default/views/admin.html.php 43 DIRTY $theme->site_status() themes/admin_default/views/admin.html.php 45 DIRTY $theme->admin_header_top() themes/admin_default/views/admin.html.php 48 DIRTY $csrf -themes/admin_default/views/admin.html.php 52 DIRTY $theme->admin_menu() -themes/admin_default/views/admin.html.php 54 DIRTY $theme->admin_header_bottom() -themes/admin_default/views/admin.html.php 60 DIRTY $theme->messages() -themes/admin_default/views/admin.html.php 61 DIRTY $content -themes/admin_default/views/admin.html.php 67 DIRTY $sidebar -themes/admin_default/views/admin.html.php 72 DIRTY $theme->admin_footer() -themes/admin_default/views/admin.html.php 74 DIRTY $theme->admin_credits() -themes/admin_default/views/admin.html.php 78 DIRTY $theme->admin_page_bottom() +themes/admin_default/views/admin.html.php 54 DIRTY $theme->admin_menu() +themes/admin_default/views/admin.html.php 56 DIRTY $theme->admin_header_bottom() +themes/admin_default/views/admin.html.php 62 DIRTY $theme->messages() +themes/admin_default/views/admin.html.php 63 DIRTY $content +themes/admin_default/views/admin.html.php 69 DIRTY $sidebar +themes/admin_default/views/admin.html.php 74 DIRTY $theme->admin_footer() +themes/admin_default/views/admin.html.php 76 DIRTY $theme->admin_credits() +themes/admin_default/views/admin.html.php 80 DIRTY $theme->admin_page_bottom() themes/admin_default/views/block.html.php 2 DIRTY $id themes/admin_default/views/block.html.php 2 DIRTY $css_id themes/admin_default/views/block.html.php 5 DIRTY $id @@ -544,7 +551,7 @@ themes/default/views/block.html.php 3 DIRTY $css_id themes/default/views/block.html.php 4 DIRTY $title themes/default/views/block.html.php 6 DIRTY $content themes/default/views/dynamic.html.php 4 DIRTY $theme->dynamic_top() -themes/default/views/dynamic.html.php 6 $tag->name +themes/default/views/dynamic.html.php 6 $title themes/default/views/dynamic.html.php 11 DIRTY $child->is_album() themes/default/views/dynamic.html.php 12 DIRTY $theme->thumb_top($child) themes/default/views/dynamic.html.php 13 DIRTY $child->url() -- cgit v1.2.3 From d9f3e0bc0e6e7e21025f65ec34c83717af47ba9b Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Jul 2009 10:27:18 -0700 Subject: Remove spurious blank line at the top of the file introduced in 09c9b1a75561881a40ada71f02710355923602e2 --- modules/gallery/controllers/simple_uploader.php | 1 - 1 file changed, 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/controllers/simple_uploader.php b/modules/gallery/controllers/simple_uploader.php index 75a7b810..e7c0bd6f 100644 --- a/modules/gallery/controllers/simple_uploader.php +++ b/modules/gallery/controllers/simple_uploader.php @@ -1,4 +1,3 @@ - Date: Thu, 16 Jul 2009 10:32:18 -0700 Subject: Remove trailing ?>. --- .../lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'modules') diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php index 731c3171..81305bcf 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php @@ -3,7 +3,7 @@ /** * Experimental HTML5-based parser using Jeroen van der Meer's PH5P library. * Occupies space in the HTML5 pseudo-namespace, which may cause conflicts. - * + * * @note * Recent changes to PHP's DOM extension have resulted in some fatal * error conditions with the original version of PH5P. Pending changes, @@ -11,7 +11,7 @@ */ class HTMLPurifier_Lexer_PH5P extends HTMLPurifier_Lexer_DOMLex { - + public function tokenizeHTML($html, $config, $context) { $new_html = $this->normalize($html, $config, $context); $new_html = $this->wrapHTML($new_html, $config, $context); @@ -32,31 +32,31 @@ class HTMLPurifier_Lexer_PH5P extends HTMLPurifier_Lexer_DOMLex { , $tokens); return $tokens; } - + } /* -Copyright 2007 Jeroen van der Meer +Copyright 2007 Jeroen van der Meer -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ @@ -1075,7 +1075,7 @@ class HTML5 { // used when parsing entities in text and in attributes. // The behaviour depends on the identity of the next character (the - // one immediately after the U+0026 AMPERSAND character): + // one immediately after the U+0026 AMPERSAND character): switch($this->character($this->char + 1)) { // U+0023 NUMBER SIGN (#) @@ -2231,7 +2231,7 @@ class HTML5TreeConstructer { if($this->elementInScope($token['name'])) { $this->generateImpliedEndTags(); - } + } if(end($this->stack)->nodeName !== $token['name']) { /* Now, if the current node is not an element with the @@ -2610,7 +2610,7 @@ class HTML5TreeConstructer { for($x = count($this->stack) - $n; $x >= $n; $x--) { array_pop($this->stack); } - + } else { $category = $this->getElementCategory($node); @@ -3546,7 +3546,7 @@ class HTML5TreeConstructer { // In theory, this should ever be needed, but just in case if ($token['name'] === '') $token['name'] = 'span'; // arbitrary generic choice } - + $el = $this->dom->createElement($token['name']); foreach($token['attr'] as $attr) { @@ -3903,4 +3903,4 @@ class HTML5TreeConstructer { return $this->dom; } } -?> + -- cgit v1.2.3 From 2cd0d6389c39badc1c3c7963e03f80097eaac3c2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Jul 2009 10:44:23 -0700 Subject: Revert "Remove trailing ?>." This reverts commit a333e01bd1c8cb3ad08cd0ad16023e3fcdfc4181. --- .../lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'modules') diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php index 81305bcf..731c3171 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php @@ -3,7 +3,7 @@ /** * Experimental HTML5-based parser using Jeroen van der Meer's PH5P library. * Occupies space in the HTML5 pseudo-namespace, which may cause conflicts. - * + * * @note * Recent changes to PHP's DOM extension have resulted in some fatal * error conditions with the original version of PH5P. Pending changes, @@ -11,7 +11,7 @@ */ class HTMLPurifier_Lexer_PH5P extends HTMLPurifier_Lexer_DOMLex { - + public function tokenizeHTML($html, $config, $context) { $new_html = $this->normalize($html, $config, $context); $new_html = $this->wrapHTML($new_html, $config, $context); @@ -32,31 +32,31 @@ class HTMLPurifier_Lexer_PH5P extends HTMLPurifier_Lexer_DOMLex { , $tokens); return $tokens; } - + } /* -Copyright 2007 Jeroen van der Meer +Copyright 2007 Jeroen van der Meer -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ @@ -1075,7 +1075,7 @@ class HTML5 { // used when parsing entities in text and in attributes. // The behaviour depends on the identity of the next character (the - // one immediately after the U+0026 AMPERSAND character): + // one immediately after the U+0026 AMPERSAND character): switch($this->character($this->char + 1)) { // U+0023 NUMBER SIGN (#) @@ -2231,7 +2231,7 @@ class HTML5TreeConstructer { if($this->elementInScope($token['name'])) { $this->generateImpliedEndTags(); - } + } if(end($this->stack)->nodeName !== $token['name']) { /* Now, if the current node is not an element with the @@ -2610,7 +2610,7 @@ class HTML5TreeConstructer { for($x = count($this->stack) - $n; $x >= $n; $x--) { array_pop($this->stack); } - + } else { $category = $this->getElementCategory($node); @@ -3546,7 +3546,7 @@ class HTML5TreeConstructer { // In theory, this should ever be needed, but just in case if ($token['name'] === '') $token['name'] = 'span'; // arbitrary generic choice } - + $el = $this->dom->createElement($token['name']); foreach($token['attr'] as $attr) { @@ -3903,4 +3903,4 @@ class HTML5TreeConstructer { return $this->dom; } } - +?> -- cgit v1.2.3 From ec634c91a6824185485f9349cfe15d6e759bb23e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Jul 2009 10:45:06 -0700 Subject: Stripped the trailing ?> without changing whitespace. --- modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php index 731c3171..0d20c0ce 100644 --- a/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php +++ b/modules/gallery/lib/HTMLPurifier/HTMLPurifier/Lexer/PH5P.php @@ -3903,4 +3903,4 @@ class HTML5TreeConstructer { return $this->dom; } } -?> + -- cgit v1.2.3 From 2864aceb8117d0644b264ceca4d0f84fd028538f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Jul 2009 10:58:42 -0700 Subject: Add missing ) dropped in 8f9a943f. --- modules/user/controllers/password.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php index ed3b9736..2af1b879 100644 --- a/modules/user/controllers/password.php +++ b/modules/user/controllers/password.php @@ -74,7 +74,7 @@ class Password_Controller extends Controller { log::success( "user", - t("Password reset email sent for user %name", array("name" => p::clean($user->name))); + t("Password reset email sent for user %name", array("name" => p::clean($user->name)))); } else { // Don't include the username here until you're sure that it's XSS safe log::warning( -- cgit v1.2.3 From 5b3b675b6d8a1cd9a5f2b9455c551791e18d88ff Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Jul 2009 11:19:34 -0700 Subject: Non-trivial changes to the event handling code: 1) The item_updated event no longer takes the old and new items. Instead we overload ORM to track the original data and make that available via the item. This will allow us to move event publishing down into the API methods which in turn will give us more stability since we won't require each controller to remember to do it. 2) ORM class now tracks the original values. It doesn't track the original relationships (no need for that, yet) 3) Added new events: item_deleted group_deleted user_deleted --- modules/akismet/helpers/akismet_event.php | 6 ++--- modules/comment/controllers/admin_comments.php | 4 ++-- modules/comment/helpers/comment_event.php | 2 +- modules/exif/helpers/exif_event.php | 2 +- modules/g2_import/helpers/g2_import_event.php | 2 +- modules/gallery/controllers/albums.php | 2 +- modules/gallery/controllers/movies.php | 2 +- modules/gallery/controllers/photos.php | 2 +- modules/gallery/helpers/gallery_event.php | 4 ++-- modules/gallery/libraries/MY_ORM.php | 27 +++++++++++++++++++++- modules/gallery/models/item.php | 3 +++ modules/gallery/tests/Item_Model_Test.php | 16 +++++++++++++ modules/notification/helpers/notification.php | 19 ++++++++------- .../notification/helpers/notification_event.php | 10 ++++---- modules/notification/helpers/notification_menu.php | 2 +- modules/notification/views/item_updated.html.php | 16 ++++++------- modules/organize/controllers/organize.php | 4 ++-- modules/search/helpers/search_event.php | 6 ++--- modules/tag/helpers/tag_event.php | 2 +- modules/user/models/group.php | 2 ++ modules/user/models/user.php | 2 ++ 21 files changed, 91 insertions(+), 44 deletions(-) (limited to 'modules') diff --git a/modules/akismet/helpers/akismet_event.php b/modules/akismet/helpers/akismet_event.php index 80fe0127..bffc0fd7 100644 --- a/modules/akismet/helpers/akismet_event.php +++ b/modules/akismet/helpers/akismet_event.php @@ -40,14 +40,14 @@ class akismet_event_Core { $comment->save(); } - static function comment_updated($old, $new) { + static function comment_updated($comment) { if (!module::get_var("akismet", "api_key")) { return; } - if ($old->state != "spam" && $new->state == "spam") { + if ($comment->original("state") != "spam" && $comment->state == "spam") { akismet::submit_spam($new); - } else if ($old->state == "spam" && $new->state != "spam") { + } else if ($comment->original("state") == "spam" && $comment->state != "spam") { akismet::submit_ham($new); } } diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php index 3e8d3c46..ea76b188 100644 --- a/modules/comment/controllers/admin_comments.php +++ b/modules/comment/controllers/admin_comments.php @@ -113,8 +113,8 @@ class Admin_Comments_Controller extends Admin_Controller { if ($comment->loaded) { $comment->state = $state; $comment->save(); - module::event("comment_updated", $orig, $comment); - if ($orig->state == "published" || $comment->state == "published") { + module::event("comment_updated", $comment); + if ($comment->original("state") == "published" || $comment->state == "published") { module::event("item_related_update", $comment->item()); } } diff --git a/modules/comment/helpers/comment_event.php b/modules/comment/helpers/comment_event.php index a3beb27a..3850a001 100644 --- a/modules/comment/helpers/comment_event.php +++ b/modules/comment/helpers/comment_event.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class comment_event_Core { - static function item_before_delete($item) { + static function item_deleted($item) { Database::instance()->delete("comments", array("item_id" => $item->id)); } } diff --git a/modules/exif/helpers/exif_event.php b/modules/exif/helpers/exif_event.php index f5677653..24243f4d 100644 --- a/modules/exif/helpers/exif_event.php +++ b/modules/exif/helpers/exif_event.php @@ -22,7 +22,7 @@ class exif_event_Core { exif::extract($item); } - static function item_before_delete($item) { + static function item_deleted($item) { Database::instance()->delete("exif_records", array("item_id" => $item->id)); } } diff --git a/modules/g2_import/helpers/g2_import_event.php b/modules/g2_import/helpers/g2_import_event.php index 13f5b1a0..77b489a7 100644 --- a/modules/g2_import/helpers/g2_import_event.php +++ b/modules/g2_import/helpers/g2_import_event.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class g2_import_event_Core { - static function item_before_delete($item) { + static function item_deleted($item) { Database::instance()->delete("g2_maps", array("g3_id" => $item->id)); } diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index e6d01b90..c378e3ce 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -192,7 +192,7 @@ class Albums_Controller extends Items_Controller { } $album->save(); - module::event("item_updated", $orig, $album); + module::event("item_updated", $album); log::success("content", "Updated album", "id\">view"); message::success( diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 30a5d78c..fc511082 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -91,7 +91,7 @@ class Movies_Controller extends Items_Controller { $photo->rename($form->edit_photo->filename->value); $photo->save(); - module::event("item_updated", $orig, $photo); + module::event("item_updated", $photo); log::success("content", "Updated photo", "id\">view"); message::success( diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 6a62e859..77627009 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -84,7 +84,7 @@ class Photos_Controller extends Items_Controller { $photo->rename($form->edit_photo->filename->value); $photo->save(); - module::event("item_updated", $orig, $photo); + module::event("item_updated", $photo); log::success("content", "Updated photo", "id\">view"); message::success( diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index aa11b7c0..2f3a64d3 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -23,7 +23,7 @@ class gallery_event_Core { access::add_group($group); } - static function group_before_delete($group) { + static function group_deleted($group) { access::delete_group($group); } @@ -31,7 +31,7 @@ class gallery_event_Core { access::add_item($item); } - static function item_before_delete($item) { + static function item_deleted($item) { access::delete_item($item); } diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php index 2bd9b4eb..319cbe09 100644 --- a/modules/gallery/libraries/MY_ORM.php +++ b/modules/gallery/libraries/MY_ORM.php @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class ORM extends ORM_Core { + // Track the original value of this ORM instance so that we can look it up in ORM::original() + protected $original = null; + public function open_paren() { $this->db->open_paren(); return $this; @@ -30,7 +33,29 @@ class ORM extends ORM_Core { public function save() { model_cache::clear($this->object_name, $this->{$this->primary_key}, $this->primary_key); - return parent::save(); + $result = parent::save(); + $this->original = $this->object; + return $result; + } + + public function __set($column, $value) { + if (!isset($this->original)) { + $this->original = $this->object; + } + + return parent::__set($column, $value); + } + + public function __unset($column) { + if (!isset($this->original)) { + $this->original = $this->object; + } + + return parent::__unset($column); + } + + public function original($column) { + return $this->original[$column]; } } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 51037073..80f19d26 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -93,6 +93,7 @@ class Item_Model extends ORM_MPTT { } public function delete() { + $old = clone $this; module::event("item_before_delete", $this); $parent = $this->parent(); @@ -114,6 +115,8 @@ class Item_Model extends ORM_MPTT { @unlink($resize_path); @unlink($thumb_path); } + + module::event("item_deleted", $old); } /** diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 615b8997..a21cdc13 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -140,4 +140,20 @@ class Item_Model_Test extends Unit_Test_Case { } $this->assert_false(true, "Item_Model::rename should not accept / characters"); } + + public function save_original_values_test() { + print "START\n"; + $item = $this->create_random_item(); + $item->title = "ORIGINAL_VALUE"; + $item->save(); + + print "CHANGE\n"; + $item->title = "NEW_VALUE"; + + //printf("
          %s
          ",print_r($item,1));flush(); + + print "COMPARE\n"; + $this->assert_same("ORIGINAL_VALUE", $item->original("title")); + $this->assert_same("NEW_VALUE", $item->title); + } } diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php index 8ee0c6ba..e246af2c 100644 --- a/modules/notification/helpers/notification.php +++ b/modules/notification/helpers/notification.php @@ -82,17 +82,16 @@ class notification { return $subscribers; } - static function send_item_updated($old, $new) { + static function send_item_updated($item) { $v = new View("item_updated.html"); - $v->old = $old; - $v->new = $new; - $v->subject = $old->is_album() ? - t("Album %title updated", array("title" => $old->title)) : - ($old->is_photo() ? - t("Photo %title updated", array("title" => $old->title)) - : t("Movie %title updated", array("title" => $old->title))); - - self::_notify_subscribers($old, $v->render(), $v->subject); + $v->item = $item; + $v->subject = $item->is_album() ? + t("Album %title updated", array("title" => $item->original("title"))) : + ($item->is_photo() ? + t("Photo %title updated", array("title" => $item->original("title"))) + : t("Movie %title updated", array("title" => $item->original("title")))); + + self::_notify_subscribers($item, $v->render(), $v->subject); } static function send_item_add($item) { diff --git a/modules/notification/helpers/notification_event.php b/modules/notification/helpers/notification_event.php index 1cf9ff58..536557c6 100644 --- a/modules/notification/helpers/notification_event.php +++ b/modules/notification/helpers/notification_event.php @@ -18,15 +18,15 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class notification_event_Core { - static function item_updated($old, $new) { - notification::send_item_updated($old, $new); + static function item_updated($item) { + notification::send_item_updated($item); } static function item_created($item) { notification::send_item_add($item); } - static function item_before_delete($item) { + static function item_deleted($item) { notification::send_item_deleted($item); if (notification::is_watching($item)) { @@ -40,8 +40,8 @@ class notification_event_Core { } } - static function comment_updated($old, $new) { - if ($new->state == "published" && $old->state != "published") { + static function comment_updated($item) { + if ($item->state == "published" && $item->original("state") != "published") { notification::send_comment_published($new); } } diff --git a/modules/notification/helpers/notification_menu.php b/modules/notification/helpers/notification_menu.php index 696aad62..87478b8a 100644 --- a/modules/notification/helpers/notification_menu.php +++ b/modules/notification/helpers/notification_menu.php @@ -21,7 +21,7 @@ class notification_menu_Core { static function site($menu, $theme) { if (!user::active()->guest) { $item = $theme->item(); - + if ($item && $item->is_album()) { $watching = notification::is_watching($item); diff --git a/modules/notification/views/item_updated.html.php b/modules/notification/views/item_updated.html.php index 0620c50c..39f9113b 100644 --- a/modules/notification/views/item_updated.html.php +++ b/modules/notification/views/item_updated.html.php @@ -7,27 +7,27 @@

  • title) ?>title) ?>
    - title != $new->title): ?> + original("title") != $item->title): ?> - + - + - + - description != $new->description): ?> + original("description") != $item->description): ?> - + - description)): ?> + description)): ?> - +
    title) ?>title) ?> title) ?>title) ?>
    url(array(), true) ?>url(array(), true) ?>
    description) ?>description) ?>
    description) ?>description) ?>
    diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 6792573d..54e04071 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -279,7 +279,7 @@ class Organize_Controller extends Controller { $item->rename($form->dirname->value); $item->save(); - module::event("item_updated", $orig, $item); + module::event("item_updated", $item); if ($item->is_album()) { log::success("content", "Updated album", "id\">view"); @@ -322,7 +322,7 @@ class Organize_Controller extends Controller { $item->sort_order = $form->direction->value; $item->save(); - module::event("item_updated", $orig, $item); + module::event("item_updated", $item); log::success("content", "Updated album", "id\">view"); $message = t("Saved album %album_title", array("album_title" => p::purify($item->title))); diff --git a/modules/search/helpers/search_event.php b/modules/search/helpers/search_event.php index b9657395..764fdd18 100644 --- a/modules/search/helpers/search_event.php +++ b/modules/search/helpers/search_event.php @@ -22,11 +22,11 @@ class search_event_Core { search::update($item); } - static function item_updated($old_item, $new_item) { - search::update($new_item); + static function item_updated($item) { + search::update($item); } - static function item_before_delete($item) { + static function item_deleted($item) { ORM::factory("search_record") ->where("item_id", $item->id) ->delete_all(); diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php index 7a170bf8..0164f556 100644 --- a/modules/tag/helpers/tag_event.php +++ b/modules/tag/helpers/tag_event.php @@ -59,7 +59,7 @@ class tag_event_Core { return; } - static function item_before_delete($item) { + static function item_deleted($item) { $db = Database::instance(); $db->query("UPDATE {tags} SET `count` = `count` - 1 WHERE `count` > 0 " . "AND `id` IN (SELECT `tag_id` from {items_tags} WHERE `item_id` = $item->id)"); diff --git a/modules/user/models/group.php b/modules/user/models/group.php index 45948887..e0724e30 100644 --- a/modules/user/models/group.php +++ b/modules/user/models/group.php @@ -27,7 +27,9 @@ class Group_Model extends ORM { * @see ORM::delete() */ public function delete($id=null) { + $old = clone $this; module::event("group_before_delete", $this); parent::delete($id); + module::event("group_deleted", $old); } } \ No newline at end of file diff --git a/modules/user/models/user.php b/modules/user/models/user.php index b447892e..e3260270 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -44,8 +44,10 @@ class User_Model extends ORM { * @see ORM::delete() */ public function delete($id=null) { + $old = clone $this; module::event("user_before_delete", $this); parent::delete($id); + module::event("user_deleted", $old); } /** -- cgit v1.2.3 From 43324fd12a23b35707300ff110f207552c3811f1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Jul 2009 12:29:01 -0700 Subject: Update golden file to match recent changes in event code. --- modules/gallery/tests/xss_data.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index d1167555..e6f3721b 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -326,12 +326,12 @@ modules/notification/views/item_deleted.html.php 18 DIRTY $item->pa modules/notification/views/item_deleted.html.php 19 DIRTY $item->parent()->url(array(), true) modules/notification/views/item_updated.html.php 4 $subject modules/notification/views/item_updated.html.php 7 $subject -modules/notification/views/item_updated.html.php 12 $new->title -modules/notification/views/item_updated.html.php 15 $new->title -modules/notification/views/item_updated.html.php 20 DIRTY $new->url(array(), true) -modules/notification/views/item_updated.html.php 20 DIRTY $new->url(array(), true) -modules/notification/views/item_updated.html.php 25 $new->description -modules/notification/views/item_updated.html.php 30 $new->description +modules/notification/views/item_updated.html.php 12 $item->title +modules/notification/views/item_updated.html.php 15 $item->title +modules/notification/views/item_updated.html.php 20 DIRTY $item->url(array(), true) +modules/notification/views/item_updated.html.php 20 DIRTY $item->url(array(), true) +modules/notification/views/item_updated.html.php 25 $item->description +modules/notification/views/item_updated.html.php 30 $item->description modules/organize/views/organize.html.php 10 DIRTY $item->id modules/organize/views/organize.html.php 12 DIRTY $csrf modules/organize/views/organize.html.php 13 DIRTY $csrf -- cgit v1.2.3 From 0f766b149d0cee7af664f2321fddc6f04cda70ac Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Jul 2009 12:29:16 -0700 Subject: Second non-trivial change to the event code. We now publish model related events from within the model handling code. The only exception to this currently is item_created which is challenging because we have to save the item using ORM_MPTT::add_to_parent() before the object itself is fully set up. When we get that down to one call to save() we can publish that event from within the model also. --- modules/comment/controllers/admin_comments.php | 4 ---- modules/comment/controllers/comments.php | 1 - modules/comment/helpers/comment.php | 5 ----- modules/comment/models/comment.php | 17 ++++++++++++++++- modules/exif/helpers/exif_event.php | 4 +++- modules/gallery/controllers/albums.php | 3 --- modules/gallery/controllers/movies.php | 3 --- modules/gallery/controllers/photos.php | 3 --- modules/gallery/helpers/album.php | 2 ++ modules/gallery/helpers/movie.php | 2 ++ modules/gallery/helpers/photo.php | 2 ++ modules/gallery/models/item.php | 7 ++++++- modules/organize/controllers/organize.php | 4 ---- modules/user/helpers/group.php | 1 - modules/user/helpers/user.php | 1 - modules/user/models/group.php | 13 +++++++++++++ modules/user/models/user.php | 13 +++++++++++++ 17 files changed, 57 insertions(+), 28 deletions(-) (limited to 'modules') diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php index ea76b188..a164f79f 100644 --- a/modules/comment/controllers/admin_comments.php +++ b/modules/comment/controllers/admin_comments.php @@ -113,10 +113,6 @@ class Admin_Comments_Controller extends Admin_Controller { if ($comment->loaded) { $comment->state = $state; $comment->save(); - module::event("comment_updated", $comment); - if ($comment->original("state") == "published" || $comment->state == "published") { - module::event("item_related_update", $comment->item()); - } } } diff --git a/modules/comment/controllers/comments.php b/modules/comment/controllers/comments.php index 02c38491..9fb4796e 100644 --- a/modules/comment/controllers/comments.php +++ b/modules/comment/controllers/comments.php @@ -152,7 +152,6 @@ class Comments_Controller extends REST_Controller { $comment->url = $form->edit_comment->url->value; $comment->text = $form->edit_comment->text->value; $comment->save(); - module::event("comment_updated", $comment); print json_encode( array("result" => "success", diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php index 08cba096..3d743325 100644 --- a/modules/comment/helpers/comment.php +++ b/modules/comment/helpers/comment.php @@ -61,11 +61,6 @@ class comment_Core { $comment->server_remote_port = substr($input->server("REMOTE_PORT"), 0, 16); $comment->save(); - module::event("comment_created", $comment); - if ($comment->state == "published") { - module::event("item_related_update", $comment->item()); - } - return $comment; } diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index 22c465df..551fb245 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -61,8 +61,23 @@ class Comment_Model extends ORM { $this->updated = time(); if (!$this->loaded && empty($this->created)) { $this->created = $this->updated; + $created = true; } } - return parent::save(); + parent::save(); + + if (isset($created)) { + module::event("comment_created", $this); + } else { + module::event("comment_updated", $this); + } + + // We only notify on the related items if we're making a visible change, which means moving in + // or out of a published state + if ($this->original("state") == "published" || $this->state == "published") { + module::event("item_related_update", $this->item()); + } + + return $this; } } diff --git a/modules/exif/helpers/exif_event.php b/modules/exif/helpers/exif_event.php index 24243f4d..826ec959 100644 --- a/modules/exif/helpers/exif_event.php +++ b/modules/exif/helpers/exif_event.php @@ -19,7 +19,9 @@ */ class exif_event_Core { static function item_created($item) { - exif::extract($item); + if (!$item->is_album()) { + exif::extract($item); + } } static function item_deleted($item) { diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index c378e3ce..9980b676 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -182,7 +182,6 @@ class Albums_Controller extends Items_Controller { } if ($valid) { - $orig = clone $album; $album->title = $form->edit_album->title->value; $album->description = $form->edit_album->description->value; $album->sort_column = $form->edit_album->sort_order->column->value; @@ -192,8 +191,6 @@ class Albums_Controller extends Items_Controller { } $album->save(); - module::event("item_updated", $album); - log::success("content", "Updated album", "id\">view"); message::success( t("Saved album %album_title", array("album_title" => p::clean($album->title)))); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index fc511082..d954ad8d 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -85,14 +85,11 @@ class Movies_Controller extends Items_Controller { } if ($valid) { - $orig = clone $photo; $photo->title = $form->edit_photo->title->value; $photo->description = $form->edit_photo->description->value; $photo->rename($form->edit_photo->filename->value); $photo->save(); - module::event("item_updated", $photo); - log::success("content", "Updated photo", "id\">view"); message::success( t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title)))); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 77627009..9ce6ed23 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -78,14 +78,11 @@ class Photos_Controller extends Items_Controller { } if ($valid) { - $orig = clone $photo; $photo->title = $form->edit_photo->title->value; $photo->description = $form->edit_photo->description->value; $photo->rename($form->edit_photo->filename->value); $photo->save(); - module::event("item_updated", $photo); - log::success("content", "Updated photo", "id\">view"); message::success( t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title)))); diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php index 1197f243..f1a6c060 100644 --- a/modules/gallery/helpers/album.php +++ b/modules/gallery/helpers/album.php @@ -71,6 +71,8 @@ class album_Core { mkdir(dirname($album->thumb_path())); mkdir(dirname($album->resize_path())); + // @todo: publish this from inside Item_Model::save() when we refactor to the point where + // there's only one save() happening here. module::event("item_created", $album); return $album; diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index d62ead76..4f4169d5 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -102,6 +102,8 @@ class movie_Core { copy($filename, $movie->file_path()); + // @todo: publish this from inside Item_Model::save() when we refactor to the point where + // there's only one save() happening here. module::event("item_created", $movie); // Build our thumbnail diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php index e8a4f357..ce964c14 100644 --- a/modules/gallery/helpers/photo.php +++ b/modules/gallery/helpers/photo.php @@ -105,6 +105,8 @@ class photo_Core { copy($filename, $photo->file_path()); + // @todo: publish this from inside Item_Model::save() when we refactor to the point where + // there's only one save() happening here. module::event("item_created", $photo); // Build our thumbnail/resizes diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 80f19d26..94e2fcf7 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -350,9 +350,14 @@ class Item_Model extends ORM_MPTT { $this->created = $this->updated; $r = ORM::factory("item")->select("MAX(weight) as max_weight")->find(); $this->weight = $r->max_weight + 1; + $created = 1; } } - return parent::save(); + parent::save(); + if (!isset($created)) { + module::event("item_updated", $this); + } + return $this; } /** diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php index 54e04071..27852904 100644 --- a/modules/organize/controllers/organize.php +++ b/modules/organize/controllers/organize.php @@ -279,8 +279,6 @@ class Organize_Controller extends Controller { $item->rename($form->dirname->value); $item->save(); - module::event("item_updated", $item); - if ($item->is_album()) { log::success("content", "Updated album", "id\">view"); $message = t("Saved album %album_title", array("album_title" => p::purify($item->title))); @@ -322,8 +320,6 @@ class Organize_Controller extends Controller { $item->sort_order = $form->direction->value; $item->save(); - module::event("item_updated", $item); - log::success("content", "Updated album", "id\">view"); $message = t("Saved album %album_title", array("album_title" => p::purify($item->title))); print json_encode(array("form" => $form->__toString(), "message" => $message)); diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php index 1dace840..04e6efd6 100644 --- a/modules/user/helpers/group.php +++ b/modules/user/helpers/group.php @@ -39,7 +39,6 @@ class group_Core { $group->name = $name; $group->save(); - module::event("group_created", $group); return $group; } diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php index a59588f8..4105d745 100644 --- a/modules/user/helpers/user.php +++ b/modules/user/helpers/user.php @@ -202,7 +202,6 @@ class user_Core { $user->add(group::registered_users()); $user->save(); - module::event("user_created", $user); return $user; } diff --git a/modules/user/models/group.php b/modules/user/models/group.php index e0724e30..bb3fb58b 100644 --- a/modules/user/models/group.php +++ b/modules/user/models/group.php @@ -32,4 +32,17 @@ class Group_Model extends ORM { parent::delete($id); module::event("group_deleted", $old); } + + public function save() { + if (!$this->loaded) { + $created = 1; + } + parent::save(); + if (isset($created)) { + module::event("group_created", $this); + } else { + module::event("group_updated", $this); + } + return $this; + } } \ No newline at end of file diff --git a/modules/user/models/user.php b/modules/user/models/user.php index e3260270..0234f186 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -59,4 +59,17 @@ class User_Model extends ORM { return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s", md5($this->email), $size, $default ? "&d=" . urlencode($default) : ""); } + + public function save() { + if (!$this->loaded) { + $created = 1; + } + parent::save(); + if (isset($created)) { + module::event("user_created", $this); + } else { + module::event("user_updated", $this); + } + return $this; + } } \ No newline at end of file -- cgit v1.2.3 From 8a6556b30bc34d69284df6246f4010a8835f3bc2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 08:14:08 -0700 Subject: Fix a bug where moved items don't properly inherit permissions from their new target. After each move, recalculate the permissions for the new parent's hierarchy. Fixes ticket #552 --- modules/gallery/helpers/access.php | 15 ++++++++++++ modules/gallery/helpers/gallery_event.php | 4 ++++ modules/gallery/models/item.php | 6 +++-- modules/gallery/tests/Access_Helper_Test.php | 36 ++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index c48f0b79..5dd1e465 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -243,6 +243,21 @@ class access_Core { self::_set($group, $perm_name, $item, null); } + /** + * Recalculate the permissions for a given item and its hierarchy. $item must be an album. + */ + static function recalculate_permissions($item) { + foreach (self::_get_all_groups() as $group) { + foreach (ORM::factory("permission")->find_all() as $perm) { + if ($perm->name == "view") { + self::_update_access_view_cache($group, $item); + } else { + self::_update_access_non_view_cache($group, $perm->name, $item); + } + } + } + } + /** * Register a permission so that modules can use it. * diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index 2f3a64d3..1cd96372 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -35,6 +35,10 @@ class gallery_event_Core { access::delete_item($item); } + static function item_moved($item, $old_parent) { + access::recalculate_permissions($item->parent()); + } + static function user_login($user) { // If this user is an admin, check to see if there are any post-install tasks that we need // to run and take care of those now. diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 94e2fcf7..6512e9e5 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -122,8 +122,8 @@ class Item_Model extends ORM_MPTT { /** * Move this item to the specified target. * @chainable - * @param Item_Model $target Target item (must be an album - * @return ORM_MTPP + * @param Item_Model $target Target item (must be an album) + * @return ORM_MPTT */ function move_to($target) { if (!$target->is_album()) { @@ -137,6 +137,7 @@ class Item_Model extends ORM_MPTT { $original_path = $this->file_path(); $original_resize_path = $this->resize_path(); $original_thumb_path = $this->thumb_path(); + $original_parent = $this->parent(); parent::move_to($target, true); $this->relative_path_cache = null; @@ -154,6 +155,7 @@ class Item_Model extends ORM_MPTT { @rename($original_thumb_path, $this->thumb_path()); } + module::event("item_moved", $this, $original_parent); return $this; } diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php index d71bf971..1352b493 100644 --- a/modules/gallery/tests/Access_Helper_Test.php +++ b/modules/gallery/tests/Access_Helper_Test.php @@ -324,4 +324,40 @@ class Access_Helper_Test extends Unit_Test_Case { $this->assert_false(file_exists($album->resize_path() . "/.htaccess")); $this->assert_false(file_exists($album->thumb_path() . "/.htaccess")); } + + public function moved_items_inherit_new_permissions_test() { + user::set_active(user::lookup_by_name("admin")); + + $root = ORM::factory("item", 1); + $public_album = album::create($root, rand(), "public album"); + $public_photo = photo::create($public_album, MODPATH . "gallery/images/gallery.png", "", ""); + access::allow(group::everybody(), "view", $public_album); + + $root->reload(); // Account for MPTT changes + + $private_album = album::create($root, rand(), "private album"); + access::deny(group::everybody(), "view", $private_album); + $private_photo = photo::create($private_album, MODPATH . "gallery/images/gallery.png", "", ""); + + // Make sure that we now have a public photo and private photo. + $this->assert_true(access::group_can(group::everybody(), "view", $public_photo)); + $this->assert_false(access::group_can(group::everybody(), "view", $private_photo)); + + // Swap the photos + item::move($public_photo, $private_album); + $private_album->reload(); // Reload to get new MPTT pointers and cached perms. + $public_album->reload(); + $private_photo->reload(); + $public_photo->reload(); + + item::move($private_photo, $public_album); + $private_album->reload(); // Reload to get new MPTT pointers and cached perms. + $public_album->reload(); + $private_photo->reload(); + $public_photo->reload(); + + // Make sure that the public_photo is now private, and the private_photo is now public. + $this->assert_false(access::group_can(group::everybody(), "view", $public_photo)); + $this->assert_true(access::group_can(group::everybody(), "view", $private_photo)); + } } -- cgit v1.2.3 From cd907c2b42f8b50ebe6d490aab42365e16deb258 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 12:51:27 -0700 Subject: Change model_cache::clear() API to clear everything. This prevents old ORM relationships from hanging around, which was causing problems when doing MPTT manipulations (resulting in incorrect permission propagation-- very bad!) --- modules/gallery/helpers/access.php | 4 ++++ modules/gallery/helpers/item.php | 4 ++-- modules/gallery/helpers/model_cache.php | 6 ++---- modules/gallery/libraries/MY_ORM.php | 2 +- modules/gallery/libraries/ORM_MPTT.php | 1 + modules/gallery/models/item.php | 1 + 6 files changed, 11 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php index 5dd1e465..63324e5d 100644 --- a/modules/gallery/helpers/access.php +++ b/modules/gallery/helpers/access.php @@ -205,6 +205,7 @@ class access_Core { } self::_update_htaccess_files($album, $group, $perm_name, $value); + model_cache::clear(); } /** @@ -256,6 +257,7 @@ class access_Core { } } } + model_cache::clear(); } /** @@ -426,6 +428,7 @@ class access_Core { $cache_table = $perm_name == "view" ? "items" : "access_caches"; $db->query("ALTER TABLE {{$cache_table}} DROP `$field`"); $db->query("ALTER TABLE {access_intents} DROP `$field`"); + model_cache::clear(); ORM::factory("access_intent")->clear_cache(); } @@ -443,6 +446,7 @@ class access_Core { $db->query("ALTER TABLE {{$cache_table}} ADD `$field` SMALLINT NOT NULL DEFAULT 0"); $db->query("ALTER TABLE {access_intents} ADD `$field` BOOLEAN DEFAULT NULL"); $db->update("access_intents", array($field => 0), array("item_id" => 1)); + model_cache::clear(); ORM::factory("access_intent")->clear_cache(); } diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index f40b5c97..80c25862 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -53,7 +53,7 @@ class item_Core { access::required("view", $parent); access::required("edit", $parent); - model_cache::clear("item", $parent->album_cover_item_id); + model_cache::clear(); $parent->album_cover_item_id = $item->is_album() ? $item->album_cover_item_id : $item->id; $parent->thumb_dirty = 1; $parent->save(); @@ -69,7 +69,7 @@ class item_Core { access::required("edit", $album); @unlink($album->thumb_path()); - model_cache::clear("item", $album->album_cover_item_id) ; + model_cache::clear(); $album->album_cover_item_id = null; $album->thumb_width = 0; $album->thumb_height = 0; diff --git a/modules/gallery/helpers/model_cache.php b/modules/gallery/helpers/model_cache.php index 2649fdbd..a3e09862 100644 --- a/modules/gallery/helpers/model_cache.php +++ b/modules/gallery/helpers/model_cache.php @@ -32,10 +32,8 @@ class model_cache_Core { return self::$cache->$model_name->$field_name->$id; } - static function clear($model_name, $id, $field_name="id") { - if (!empty(self::$cache->$model_name->$field_name->$id)) { - unset(self::$cache->$model_name->$field_name->$id); - } + static function clear() { + self::$cache = new stdClass(); } static function set($model) { diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php index 319cbe09..1d3c1ef3 100644 --- a/modules/gallery/libraries/MY_ORM.php +++ b/modules/gallery/libraries/MY_ORM.php @@ -32,7 +32,7 @@ class ORM extends ORM_Core { } public function save() { - model_cache::clear($this->object_name, $this->{$this->primary_key}, $this->primary_key); + model_cache::clear(); $result = parent::save(); $this->original = $this->object; return $result; diff --git a/modules/gallery/libraries/ORM_MPTT.php b/modules/gallery/libraries/ORM_MPTT.php index 46280d95..e371f159 100644 --- a/modules/gallery/libraries/ORM_MPTT.php +++ b/modules/gallery/libraries/ORM_MPTT.php @@ -285,6 +285,7 @@ class ORM_MPTT_Core extends ORM { // Lets reload to get the changes. $this->reload(); + $target->reload(); return $this; } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 6512e9e5..05c4e656 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -140,6 +140,7 @@ class Item_Model extends ORM_MPTT { $original_parent = $this->parent(); parent::move_to($target, true); + model_cache::clear(); $this->relative_path_cache = null; rename($original_path, $this->file_path()); -- cgit v1.2.3 From e7c6861507ea7ca01d3d4ed7b4189c030c8d07b3 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 16:58:00 -0700 Subject: Don't send back the gzipped version if we're using zlib.output_compression in PHP, since that means that the stream is already compressed. Fixes ticket 555. --- modules/gallery/controllers/combined.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php index 925d052d..9a790fdf 100644 --- a/modules/gallery/controllers/combined.php +++ b/modules/gallery/controllers/combined.php @@ -60,14 +60,15 @@ class Combined_Controller extends Controller { $cache = Cache::instance(); $use_gzip = function_exists("gzencode") && - (strpos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false); + stripos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false && + (int) ini_get("zlib.output_compression") === 0; + if ($use_gzip && $content = $cache->get("{$key}_gz")) { header("Content-Encoding: gzip"); } else { // Fall back to non-gzipped if we have to $content = $cache->get($key); } - if (empty($content)) { Kohana::show_404(); } -- cgit v1.2.3 From 6200955003844ba9a196db72f068650f8056acda Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 18:19:43 -0700 Subject: Don't bother making gzencoded version of combined CSS/JS if zlib.output_compression=On --- modules/gallery/libraries/Gallery_View.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 133066d7..4b85f2f0 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -104,7 +104,10 @@ class Gallery_View_Core extends View { } $cache->set($key, $contents, array($type), 30 * 84600); - if (function_exists("gzencode")) { + + $use_gzip = function_exists("gzencode") && + (int) ini_get("zlib.output_compression") === 0; + if ($use_gzip) { $cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP), array($type, "gzip"), 30 * 84600); } -- cgit v1.2.3 From d692002bcfca1cc630ddd0e55b693744ef7fa924 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 18:24:31 -0700 Subject: Don't show the combined CSS/JS elements if we didn't combine anything. Fixes ticket #554. --- modules/gallery/libraries/Gallery_View.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules') diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 4b85f2f0..31231ca6 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -73,6 +73,10 @@ class Gallery_View_Core extends View { protected function combine_files($files, $type) { $links = array(); + if (empty($files)) { + return; + } + // Include the url in the cache key so that if the Gallery moves, we don't use old cached // entries. $key = array(url::abs_file("")); -- cgit v1.2.3 From df22832a5b7e7c1962940becab1c90aaec3392f9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 17 Jul 2009 18:35:06 -0700 Subject: Rename "locale" helper to "locales" to avoid conflicting with PHP 5.3. Fixes ticket #194 --- modules/gallery/controllers/admin_languages.php | 6 +- modules/gallery/helpers/l10n_client.php | 2 +- modules/gallery/helpers/locale.php | 124 ------------------------ modules/gallery/helpers/locales.php | 124 ++++++++++++++++++++++++ modules/gallery/libraries/MY_View.php | 2 +- modules/gallery/views/l10n_client.html.php | 2 +- modules/user/helpers/user.php | 2 +- 7 files changed, 131 insertions(+), 131 deletions(-) delete mode 100644 modules/gallery/helpers/locale.php create mode 100644 modules/gallery/helpers/locales.php (limited to 'modules') diff --git a/modules/gallery/controllers/admin_languages.php b/modules/gallery/controllers/admin_languages.php index d1b805da..ae90ad07 100644 --- a/modules/gallery/controllers/admin_languages.php +++ b/modules/gallery/controllers/admin_languages.php @@ -36,7 +36,7 @@ class Admin_Languages_Controller extends Admin_Controller { $form = $this->_languages_form(); if ($form->validate()) { module::set_var("gallery", "default_locale", $form->choose_language->locale->value); - locale::update_installed($form->choose_language->installed_locales->value); + locales::update_installed($form->choose_language->installed_locales->value); message::success(t("Settings saved")); } url::redirect("admin/languages"); @@ -89,8 +89,8 @@ class Admin_Languages_Controller extends Admin_Controller { } private function _languages_form() { - $all_locales = locale::available(); - $installed_locales = locale::installed(); + $all_locales = locales::available(); + $installed_locales = locales::installed(); $form = new Forge("admin/languages/save", "", "post", array("id" => "gLanguageSettingsForm")); $group = $form->group("choose_language") ->label(t("Language settings")); diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index 6d4da0eb..b576b4e1 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -74,7 +74,7 @@ class l10n_client_Core { $request->locales = array(); $request->messages = new stdClass(); - $locales = locale::installed(); + $locales = locales::installed(); foreach ($locales as $locale => $locale_data) { $request->locales[] = $locale; } diff --git a/modules/gallery/helpers/locale.php b/modules/gallery/helpers/locale.php deleted file mode 100644 index 41b78834..00000000 --- a/modules/gallery/helpers/locale.php +++ /dev/null @@ -1,124 +0,0 @@ -$code)) { - $installed[$code] = $available[$code]; - } - } - return $installed; - } - - static function update_installed($locales) { - // Ensure that the default is included... - $default = module::get_var("gallery", "default_locale"); - $locales = in_array($default, $locales) - ? $locales - : array_merge($locales, array($default)); - - module::set_var("gallery", "installed_locales", join("|", $locales)); - } - - // @todo Might want to add a localizable language name as well. - private static function _init_language_data() { - $l["af_ZA"] = "Afrikaans"; // Afrikaans - $l["ar_SA"] = "العربية"; // Arabic - $l["be_BY"] = "Беларускі"; // Belarusian - $l["bg_BG"] = "Български"; // Bulgarian - $l["ca_ES"] = "Catalan"; // Catalan - $l["cs_CZ"] = "Česky"; // Czech - $l["da_DK"] = "Dansk"; // Danish - $l["de_DE"] = "Deutsch"; // German - $l["el_GR"] = "Greek"; // Greek - $l["en_GB"] = "English (UK)"; // English (UK) - $l["en_US"] = "English (US)"; // English (US) - $l["es_AR"] = "Español (AR)"; // Spanish (AR) - $l["es_ES"] = "Español"; // Spanish (ES) - $l["es_MX"] = "Español (MX)"; // Spanish (MX) - $l["et_EE"] = "Eesti"; // Estonian - $l["eu_ES"] = "Euskara"; // Basque - $l["fa_IR"] = "فارسي"; // Farsi - $l["fi_FI"] = "Suomi"; // Finnish - $l["fr_FR"] = "Français"; // French - $l["ga_IE"] = "Gaeilge"; // Irish - $l["he_IL"] = "עברית"; // Hebrew - $l["hu_HU"] = "Magyar"; // Hungarian - $l["is_IS"] = "Icelandic"; // Icelandic - $l["it_IT"] = "Italiano"; // Italian - $l["ja_JP"] = "日本語"; // Japanese - $l["ko_KR"] = "한국말"; // Korean - $l["lt_LT"] = "Lietuvių"; // Lithuanian - $l["lv_LV"] = "Latviešu"; // Latvian - $l["nl_NL"] = "Nederlands"; // Dutch - $l["no_NO"] = "Norsk bokmål"; // Norwegian - $l["pl_PL"] = "Polski"; // Polish - $l["pt_BR"] = "Português Brasileiro"; // Portuguese (BR) - $l["pt_PT"] = "Português"; // Portuguese (PT) - $l["ro_RO"] = "Română"; // Romanian - $l["ru_RU"] = "Русский"; // Russian - $l["sk_SK"] = "Slovenčina"; // Slovak - $l["sl_SI"] = "Slovenščina"; // Slovenian - $l["sr_CS"] = "Srpski"; // Serbian - $l["sv_SE"] = "Svenska"; // Swedish - $l["tr_TR"] = "Türkçe"; // Turkish - $l["uk_UA"] = "Українська"; // Ukrainian - $l["vi_VN"] = "Tiếng Việt"; // Vietnamese - $l["zh_CN"] = "简体中文"; // Chinese (CN) - $l["zh_TW"] = "繁體中文"; // Chinese (TW) - asort($l, SORT_LOCALE_STRING); - self::$locales = $l; - } - - static function display_name($locale=null) { - if (empty(self::$locales)) { - self::_init_language_data(); - } - $locale or $locale = I18n::instance()->locale(); - - return self::$locales["$locale"]; - } - - static function is_rtl($locale=null) { - $locale or $locale = I18n::instance()->locale(); - list ($language, $territory) = explode('_', $locale . "_"); - return in_array($language, array("he", "fa", "ar")); - } -} \ No newline at end of file diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php new file mode 100644 index 00000000..3762b97b --- /dev/null +++ b/modules/gallery/helpers/locales.php @@ -0,0 +1,124 @@ +$code)) { + $installed[$code] = $available[$code]; + } + } + return $installed; + } + + static function update_installed($locales) { + // Ensure that the default is included... + $default = module::get_var("gallery", "default_locale"); + $locales = in_array($default, $locales) + ? $locales + : array_merge($locales, array($default)); + + module::set_var("gallery", "installed_locales", join("|", $locales)); + } + + // @todo Might want to add a localizable language name as well. + private static function _init_language_data() { + $l["af_ZA"] = "Afrikaans"; // Afrikaans + $l["ar_SA"] = "العربية"; // Arabic + $l["be_BY"] = "Беларускі"; // Belarusian + $l["bg_BG"] = "Български"; // Bulgarian + $l["ca_ES"] = "Catalan"; // Catalan + $l["cs_CZ"] = "Česky"; // Czech + $l["da_DK"] = "Dansk"; // Danish + $l["de_DE"] = "Deutsch"; // German + $l["el_GR"] = "Greek"; // Greek + $l["en_GB"] = "English (UK)"; // English (UK) + $l["en_US"] = "English (US)"; // English (US) + $l["es_AR"] = "Español (AR)"; // Spanish (AR) + $l["es_ES"] = "Español"; // Spanish (ES) + $l["es_MX"] = "Español (MX)"; // Spanish (MX) + $l["et_EE"] = "Eesti"; // Estonian + $l["eu_ES"] = "Euskara"; // Basque + $l["fa_IR"] = "فارسي"; // Farsi + $l["fi_FI"] = "Suomi"; // Finnish + $l["fr_FR"] = "Français"; // French + $l["ga_IE"] = "Gaeilge"; // Irish + $l["he_IL"] = "עברית"; // Hebrew + $l["hu_HU"] = "Magyar"; // Hungarian + $l["is_IS"] = "Icelandic"; // Icelandic + $l["it_IT"] = "Italiano"; // Italian + $l["ja_JP"] = "日本語"; // Japanese + $l["ko_KR"] = "한국말"; // Korean + $l["lt_LT"] = "Lietuvių"; // Lithuanian + $l["lv_LV"] = "Latviešu"; // Latvian + $l["nl_NL"] = "Nederlands"; // Dutch + $l["no_NO"] = "Norsk bokmål"; // Norwegian + $l["pl_PL"] = "Polski"; // Polish + $l["pt_BR"] = "Português Brasileiro"; // Portuguese (BR) + $l["pt_PT"] = "Português"; // Portuguese (PT) + $l["ro_RO"] = "Română"; // Romanian + $l["ru_RU"] = "Русский"; // Russian + $l["sk_SK"] = "Slovenčina"; // Slovak + $l["sl_SI"] = "Slovenščina"; // Slovenian + $l["sr_CS"] = "Srpski"; // Serbian + $l["sv_SE"] = "Svenska"; // Swedish + $l["tr_TR"] = "Türkçe"; // Turkish + $l["uk_UA"] = "Українська"; // Ukrainian + $l["vi_VN"] = "Tiếng Việt"; // Vietnamese + $l["zh_CN"] = "简体中文"; // Chinese (CN) + $l["zh_TW"] = "繁體中文"; // Chinese (TW) + asort($l, SORT_LOCALE_STRING); + self::$locales = $l; + } + + static function display_name($locale=null) { + if (empty(self::$locales)) { + self::_init_language_data(); + } + $locale or $locale = I18n::instance()->locale(); + + return self::$locales["$locale"]; + } + + static function is_rtl($locale=null) { + $locale or $locale = I18n::instance()->locale(); + list ($language, $territory) = explode('_', $locale . "_"); + return in_array($language, array("he", "fa", "ar")); + } +} \ No newline at end of file diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php index 96dcc71b..84ee0892 100644 --- a/modules/gallery/libraries/MY_View.php +++ b/modules/gallery/libraries/MY_View.php @@ -45,7 +45,7 @@ class View extends View_Core { } public function body_attributes() { - if (locale::is_rtl()) { + if (locales::is_rtl()) { return 'class="rtl"'; } return ''; diff --git a/modules/gallery/views/l10n_client.html.php b/modules/gallery/views/l10n_client.html.php index c0cbbfa2..c73719ca 100644 --- a/modules/gallery/views/l10n_client.html.php +++ b/modules/gallery/views/l10n_client.html.php @@ -9,7 +9,7 @@

    locale::display_name())) ?>

    + array("language" => locales::display_name())) ?>
  • - +
  • -- cgit v1.2.3 From 050c82cf80b06a555252efaf701434b0cfd59bed Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 21 Jul 2009 11:09:23 -0700 Subject: Escape bare & symbols so that we use valid entities. Fixes ticket #577. --- modules/organize/views/organize.html.php | 2 +- modules/server_add/views/admin_server_add.html.php | 2 +- modules/server_add/views/server_add_tree_dialog.html.php | 2 +- modules/user/views/login.html.php | 2 +- themes/admin_default/views/admin.html.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/organize/views/organize.html.php b/modules/organize/views/organize.html.php index 65d67d04..1686d255 100644 --- a/modules/organize/views/organize.html.php +++ b/modules/organize/views/organize.html.php @@ -33,7 +33,7 @@ var CONFIRM_DELETE = "
    "> + ref="">
      diff --git a/modules/server_add/views/admin_server_add.html.php b/modules/server_add/views/admin_server_add.html.php index 588a9fca..30ab3536 100644 --- a/modules/server_add/views/admin_server_add.html.php +++ b/modules/server_add/views/admin_server_add.html.php @@ -11,7 +11,7 @@