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))) ?>

-- 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 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
  • title) ?>title) ?>