diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-03 22:19:46 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-03 22:19:46 +0000 |
commit | 08c47f28f25e5299142242bb15c872ac84fc702b (patch) | |
tree | 3dc0b60c70d8c3e11eb73e73b0dabbc619d85274 /modules/local_import/controllers/admin_local_import.php | |
parent | 6596682c90f4df7f6edebea28246b80d762ce742 (diff) |
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()
Diffstat (limited to 'modules/local_import/controllers/admin_local_import.php')
-rw-r--r-- | modules/local_import/controllers/admin_local_import.php | 27 |
1 files changed, 20 insertions, 7 deletions
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 |