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 | |
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')
-rw-r--r-- | modules/local_import/controllers/admin_local_import.php | 27 | ||||
-rw-r--r-- | modules/local_import/helpers/local_import.php | 42 | ||||
-rw-r--r-- | modules/local_import/js/admin.js | 2 |
3 files changed, 21 insertions, 50 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 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 @@ -<?php defined("SYSPATH") or die("No direct script access."); -/** - * Gallery - a web based photo album viewer and editor - * Copyright (C) 2000-2008 Bharat Mediratta - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. - */ -class local_import { - static function get_admin_page() { - $template = new View("local_import_admin.html"); - - $paths = unserialize(module::get_var("local_import", "authorized_paths", "a:0:{}")); - $path_list = new View("local_import_dir_list.html"); - $path_list->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) { |