From c2fa42cf6cf6a2742b2a40ef7fc46f95f7a734f3 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 21 Feb 2009 02:28:19 +0000 Subject: Implementation of local import module. Still need work on better status messages. --- modules/local_import/helpers/local_import.php | 42 +++++++++++++++++++++ .../local_import/helpers/local_import_block.php | 30 +++++++++++++++ .../helpers/local_import_installer.php | 43 +++++++++++++++++++++ modules/local_import/helpers/local_import_menu.php | 42 +++++++++++++++++++++ .../local_import/helpers/local_import_theme.php | 44 ++++++++++++++++++++++ 5 files changed, 201 insertions(+) create mode 100644 modules/local_import/helpers/local_import.php create mode 100644 modules/local_import/helpers/local_import_block.php create mode 100644 modules/local_import/helpers/local_import_installer.php create mode 100644 modules/local_import/helpers/local_import_menu.php create mode 100644 modules/local_import/helpers/local_import_theme.php (limited to 'modules/local_import/helpers') diff --git a/modules/local_import/helpers/local_import.php b/modules/local_import/helpers/local_import.php new file mode 100644 index 00000000..ca7d01e4 --- /dev/null +++ b/modules/local_import/helpers/local_import.php @@ -0,0 +1,42 @@ +paths = array_keys($paths); + $template->path_list = $path_list->render(); + $template->add_form = self::get_admin_form()->render(); + + return $template; + } + + public 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/helpers/local_import_block.php b/modules/local_import/helpers/local_import_block.php new file mode 100644 index 00000000..c337af41 --- /dev/null +++ b/modules/local_import/helpers/local_import_block.php @@ -0,0 +1,30 @@ +"; + + return implode("\n", $head); + } +} diff --git a/modules/local_import/helpers/local_import_installer.php b/modules/local_import/helpers/local_import_installer.php new file mode 100644 index 00000000..0af35669 --- /dev/null +++ b/modules/local_import/helpers/local_import_installer.php @@ -0,0 +1,43 @@ +delete("vars", array("module_name" => $module->name)); + + module::delete("local_import"); + } +} diff --git a/modules/local_import/helpers/local_import_menu.php b/modules/local_import/helpers/local_import_menu.php new file mode 100644 index 00000000..cb3029a2 --- /dev/null +++ b/modules/local_import/helpers/local_import_menu.php @@ -0,0 +1,42 @@ +get("content_menu") + ->append(Menu::factory("link") + ->id("local_import") + ->label(t("Local Import")) + ->url(url::site("admin/local_import"))); + } + + static function site($menu, $theme) { + $item = $theme->item(); + + $paths = unserialize(module::get_var("local_import", "authorized_paths")); + + if ($item && access::can("local_import", $item) && $item->is_album() &&!empty($paths)) { + $menu->get("options_menu") + ->append(Menu::factory("dialog") + ->id("local_import") + ->label(t("Import from server")) + ->url(url::site("local_import/index/$item->id"))); + } + } +} diff --git a/modules/local_import/helpers/local_import_theme.php b/modules/local_import/helpers/local_import_theme.php new file mode 100644 index 00000000..d37b8ad3 --- /dev/null +++ b/modules/local_import/helpers/local_import_theme.php @@ -0,0 +1,44 @@ +"; + $head[] = ""; + $base = url::base(true); + $csrf = access::csrf_token(); + $head[] = ""; + + $head[] = html::script("modules/local_import/js/jquery.autocomplete.pack.js"); + $head[] = html::script("modules/local_import/js/admin.js"); + + return implode("\n", $head); + } + + static function head($theme) { + $head[] = ""; + + $head[] = html::script("modules/local_import/js/local_import.js"); + + return implode("\n", $head); + } +} \ No newline at end of file -- cgit v1.2.3