From 08c47f28f25e5299142242bb15c872ac84fc702b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 3 Mar 2009 22:19:46 +0000 Subject: Inline the admin view creation that was in helpers/local_import.php and remove it. Cleanup unused variables. Rename the method remove() to remove_path() --- .../controllers/admin_local_import.php | 27 ++++++++++---- modules/local_import/helpers/local_import.php | 42 ---------------------- modules/local_import/js/admin.js | 2 +- 3 files changed, 21 insertions(+), 50 deletions(-) delete mode 100644 modules/local_import/helpers/local_import.php (limited to 'modules') diff --git a/modules/local_import/controllers/admin_local_import.php b/modules/local_import/controllers/admin_local_import.php index 5c78344b..0ff6ea83 100644 --- a/modules/local_import/controllers/admin_local_import.php +++ b/modules/local_import/controllers/admin_local_import.php @@ -20,7 +20,11 @@ class Admin_Local_Import_Controller extends Admin_Controller { public function index() { $view = new Admin_View("admin.html"); - $view->content = local_import::get_admin_page(); + $view->content = new View("local_import_admin.html"); + $view->content->add_form = $this->_get_admin_form()->render(); + $view->content->path_list = new View("local_import_dir_list.html"); + $paths = unserialize(module::get_var("local_import", "authorized_paths", "a:0:{}")); + $view->content->path_list->paths = array_keys($paths); print $view; } @@ -28,19 +32,18 @@ class Admin_Local_Import_Controller extends Admin_Controller { public function add_path() { access::verify_csrf(); - $form = local_import::get_admin_form(); + $form = $this->_get_admin_form(); $paths = unserialize(module::get_var("local_import", "authorized_paths", "a:0:{}")); if ($form->validate()) { if (is_readable($form->add_path->path->value)) { $paths[$form->add_path->path->value] = 1; module::set_var("local_import", "authorized_paths", serialize($paths)); - $path_count = count($paths) - 1; - $path_view = new View("local_import_dir_list.html"); - $path_view->paths = array_keys($paths); + $view = new View("local_import_dir_list.html"); + $view->paths = array_keys($paths); $form->add_path->inputs["path"]->value(""); print json_encode( array("result" => "success", - "paths" => $path_view->__toString(), + "paths" => $view->__toString(), "form" => $form->__toString())); } else { $form->add_path->inputs["path"]->error("not_readable"); @@ -52,7 +55,7 @@ class Admin_Local_Import_Controller extends Admin_Controller { } - public function remove() { + public function remove_path() { access::verify_csrf(); $path = $this->input->post("path"); @@ -79,4 +82,14 @@ class Admin_Local_Import_Controller extends Admin_Controller { print implode("\n", $directories); } + + private function _get_admin_form() { + $form = new Forge("admin/local_import/add_path", "", "post", array("id" => "gLocalImportAdminForm")); + $add_path = $form->group("add_path"); + $add_path->input("path")->label(t("Path"))->rules("required") + ->error_messages("not_readable", t("The directory is not readable by the webserver")); + $add_path->submit("add")->value(t("Add Path")); + + return $form; + } } \ No newline at end of file diff --git a/modules/local_import/helpers/local_import.php b/modules/local_import/helpers/local_import.php deleted file mode 100644 index d40b6016..00000000 --- a/modules/local_import/helpers/local_import.php +++ /dev/null @@ -1,42 +0,0 @@ -paths = array_keys($paths); - $template->path_list = $path_list->render(); - $template->add_form = self::get_admin_form()->render(); - - return $template; - } - - static function get_admin_form() { - $form = new Forge("admin/local_import/add_path", "", "post", array("id" => "gLocalImportAdminForm")); - $add_path = $form->group("add_path"); - $add_path->input("path")->label(t("Path"))->rules("required") - ->error_messages("not_readable", t("The directory is not readable by the webserver")); - $add_path->submit("add")->value(t("Add Path")); - - return $form; - } -} diff --git a/modules/local_import/js/admin.js b/modules/local_import/js/admin.js index e5ceb7cf..e7072127 100644 --- a/modules/local_import/js/admin.js +++ b/modules/local_import/js/admin.js @@ -36,7 +36,7 @@ function add_onclick() { $(".gRemoveDir").click(function() { var parent = $(this).parent(); $.post( - base_url + "admin/local_import/remove", + base_url + "admin/local_import/remove_path", {csrf: csrf, path: parent.text().replace(/^\s\s*/, "").replace(/\s\s*$/, "")}, function(data, textStatus) { -- cgit v1.2.3