diff options
Diffstat (limited to 'modules/local_import')
-rw-r--r-- | modules/local_import/controllers/local_import_admin.php | 56 | ||||
-rw-r--r-- | modules/local_import/helpers/local_import.php | 49 | ||||
-rw-r--r-- | modules/local_import/helpers/local_import_block.php | 30 | ||||
-rw-r--r-- | modules/local_import/helpers/local_import_installer.php | 41 | ||||
-rw-r--r-- | modules/local_import/images/bin_closed.png | bin | 0 -> 363 bytes | |||
-rw-r--r-- | modules/local_import/js/local_import.js | 67 | ||||
-rw-r--r-- | modules/local_import/views/local_import_admin.html.php | 31 | ||||
-rw-r--r-- | modules/local_import/views/local_import_dir_list.html.php | 28 |
8 files changed, 302 insertions, 0 deletions
diff --git a/modules/local_import/controllers/local_import_admin.php b/modules/local_import/controllers/local_import_admin.php new file mode 100644 index 00000000..18733c22 --- /dev/null +++ b/modules/local_import/controllers/local_import_admin.php @@ -0,0 +1,56 @@ +<?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_Admin_Controller extends Controller { + public function add_path() { + $form = local_import::get_admin_form(); + $paths = unserialize(module::get_var("local_import", "authorized_paths")); + if ($form->validate()) { + $paths[$form->path->value] = 1; + module::set_var("local_import", "authorized_paths", serialize($paths)); + } + $view = new View("local_import_dir_list.html"); + $view->paths = array_keys($paths); + + print $view; + } + + public function remove() { + $path = $this->input->post("path"); + $paths = unserialize(module::get_var("local_import", "authorized_paths")); + unset($paths[$path]); + module::set_var("local_import", "authorized_paths", serialize($paths)); + + $view = new View("local_import_dir_list.html"); + $view->paths = array_keys($paths); + + print $view; + } + + public function autocomplete() { + $files = array(); + + $path_prefix = $this->input->get("q"); + foreach (glob("{$path_prefix}*") as $file) { + $files[] = $file; + } + + print implode("\n", $files); + } +}
\ No newline at end of file diff --git a/modules/local_import/helpers/local_import.php b/modules/local_import/helpers/local_import.php new file mode 100644 index 00000000..045201c7 --- /dev/null +++ b/modules/local_import/helpers/local_import.php @@ -0,0 +1,49 @@ +<?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 { + public static function get_admin_page() { +// @todo check for admin permission +// if (!$user->admin) { +// throw new Exception("@todo ACCESS DENIED"); +// } + + $template = new View("local_import_admin.html"); + + $paths = unserialize(module::get_var("local_import", "authorized_paths")); + if (!empty($paths)) { + $template->dir_list = new View("local_import_dir_list.html"); + $template->dir_list->paths = array_keys($paths); + } else { + $template->dir_list = ""; + } + + $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")); + $form->input("path")->label(true); + $form->submit(_("Add")); + + 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 @@ +<?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_block_Core { + public static function head($theme) { + $head[] = html::script("modules/local_import/js/local_import.js"); + + $url = url::file("modules/local_import/css/local_import.css"); + $head[] = "<link rel=\"stylesheet\" type=\"text/css\" href=\"$url\" " . + "media=\"screen,print,projection\" />"; + + 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..72f42c97 --- /dev/null +++ b/modules/local_import/helpers/local_import_installer.php @@ -0,0 +1,41 @@ +<?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_installer { + public static function install() { + $db = Database::instance(); + $version = module::get_version("local_import"); + if ($version == 0) { +// access::register_permission("local_import"); + + module::set_version("local_import", 1); + module::set_var("local_import", "authorized_paths", serialize(array())); + } + } + + public static function uninstall() { +// access::delete_permission("local_import"); + $module = module::get("local_import"); + + $db = Database::instance(); + $db->query("DELETE FROM `vars` WHERE `module_id` = {$module->id};"); + + module::delete("local_import"); + } +} diff --git a/modules/local_import/images/bin_closed.png b/modules/local_import/images/bin_closed.png Binary files differnew file mode 100644 index 00000000..afe22ba9 --- /dev/null +++ b/modules/local_import/images/bin_closed.png diff --git a/modules/local_import/js/local_import.js b/modules/local_import/js/local_import.js new file mode 100644 index 00000000..3ad01ce8 --- /dev/null +++ b/modules/local_import/js/local_import.js @@ -0,0 +1,67 @@ +/** + * Set up autocomplete on the server path list + * + */ +$("document").ready(function() { + var previous_search = ""; + $("#gLocalImportAdmin input").autocomplete({ + url: base_url + "admin/local_import/autocomplete", + mustMatch: true, + }); + ajaxify_form({ + form: "#gLocalImportAdmin form", + url: "admin/local_import/", + returnCode: 200, + callback: function(xhr, statusText) { + $("#gImportLocalDirList").html(xhr.responseText); + setDroppable("#gImportLocalDirList #gRemoveDir"); + setDraggable("#gImportLocalDirList li"); + } + }); + + setDroppable("#gImportLocalDirList #gRemoveDir"); + setDraggable("#gImportLocalDirList li"); +}); + +function setDraggable(selector) { + $(selector).draggable({ + helper: 'clone', +// containment: "#gImportLocalDirList", + opacity: .6, + revert: "invalid" + }); +} + +function setDroppable(selector) { + $(selector).droppable({ + accept: "#gImportLocalDirList li", + drop: function(ev, ui) { + var element = ui.draggable[0]; + + if (confirm("Do you really want to remove " + element.textContent)) { + $.ajax({ + data: "path=" + element.textContent, + url: base_url + "admin/local_import/remove", + success: function(data, textStatus) { + $("#gImportLocalDirList").html(data); + setDroppable("#gImportLocalDirList #gRemoveDir"); + setDraggable("#gImportLocalDirList li"); + }, + error: function(xhr, textStatus, errorThrown) { + alert("Text Status: " + textStatus + " Http Error Code: " + xhr.status); + }, + type: "POST" + }); + } + } + }); +} + +function ajaxify_form(options) { + $(options.form).ajaxForm({ + complete:function(xhr, statusText) { + options.callback(xhr, statusText); + $(options.form).clearForm(); + } + }); +} diff --git a/modules/local_import/views/local_import_admin.html.php b/modules/local_import/views/local_import_admin.html.php new file mode 100644 index 00000000..58daeab6 --- /dev/null +++ b/modules/local_import/views/local_import_admin.html.php @@ -0,0 +1,31 @@ +<? 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. + */ +?> +<script> + var base_url = "<?= url::base(true) ?>"; +</script> +<div id="gLocalImportAdmin"> + <div id="gImportLocalDirList"> + <?= $dir_list ?> + </div> + <div> + <?= $add_form ?> + </div> +</div> diff --git a/modules/local_import/views/local_import_dir_list.html.php b/modules/local_import/views/local_import_dir_list.html.php new file mode 100644 index 00000000..db34d1bf --- /dev/null +++ b/modules/local_import/views/local_import_dir_list.html.php @@ -0,0 +1,28 @@ +<? 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. + */ +?> +<? if (!empty($paths)): ?> +<span id="gRemoveDir">Remove</span> +<ul id="gPathList"> + <? foreach ($paths as $id => $path): ?> + <li id="<?= $id ?>"><?= $path ?></li> + <? endforeach ?> +</ul> +<? endif ?> |