From f7d82ec52f533c620c94fe0327175747cc3d8877 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 4 Mar 2009 15:46:10 +0000 Subject: Rename local_import module to server_add --- .../controllers/admin_local_import.php | 94 --------------- modules/local_import/controllers/local_import.php | 128 -------------------- modules/local_import/css/admin.css | 29 ----- modules/local_import/css/jquery.autocomplete.css | 49 -------- modules/local_import/css/local_import.css | 60 --------- .../local_import/helpers/local_import_block.php | 30 ----- .../helpers/local_import_installer.php | 46 ------- modules/local_import/helpers/local_import_menu.php | 43 ------- .../local_import/helpers/local_import_theme.php | 38 ------ modules/local_import/js/admin.js | 47 -------- .../local_import/js/jquery.autocomplete.pack.js | 13 -- modules/local_import/js/local_import.js | 134 --------------------- modules/local_import/module.info | 3 - .../local_import/views/local_import_admin.html.php | 10 -- .../views/local_import_dir_list.html.php | 13 -- .../local_import/views/local_import_tree.html.php | 22 ---- .../views/local_import_tree_dialog.html.php | 26 ---- .../server_add/controllers/admin_server_add.php | 94 +++++++++++++++ modules/server_add/controllers/server_add.php | 128 ++++++++++++++++++++ modules/server_add/css/admin.css | 29 +++++ modules/server_add/css/jquery.autocomplete.css | 49 ++++++++ modules/server_add/css/server_add.css | 60 +++++++++ modules/server_add/helpers/server_add_block.php | 30 +++++ .../server_add/helpers/server_add_installer.php | 47 ++++++++ modules/server_add/helpers/server_add_menu.php | 43 +++++++ modules/server_add/helpers/server_add_theme.php | 38 ++++++ modules/server_add/js/admin.js | 47 ++++++++ modules/server_add/js/jquery.autocomplete.pack.js | 13 ++ modules/server_add/js/server_add.js | 131 ++++++++++++++++++++ modules/server_add/module.info | 3 + modules/server_add/views/server_add_admin.html.php | 10 ++ .../server_add/views/server_add_dir_list.html.php | 13 ++ modules/server_add/views/server_add_tree.html.php | 22 ++++ .../views/server_add_tree_dialog.html.php | 26 ++++ 34 files changed, 783 insertions(+), 785 deletions(-) delete mode 100644 modules/local_import/controllers/admin_local_import.php delete mode 100644 modules/local_import/controllers/local_import.php delete mode 100644 modules/local_import/css/admin.css delete mode 100644 modules/local_import/css/jquery.autocomplete.css delete mode 100644 modules/local_import/css/local_import.css delete mode 100644 modules/local_import/helpers/local_import_block.php delete mode 100644 modules/local_import/helpers/local_import_installer.php delete mode 100644 modules/local_import/helpers/local_import_menu.php delete mode 100644 modules/local_import/helpers/local_import_theme.php delete mode 100644 modules/local_import/js/admin.js delete mode 100644 modules/local_import/js/jquery.autocomplete.pack.js delete mode 100644 modules/local_import/js/local_import.js delete mode 100644 modules/local_import/module.info delete mode 100644 modules/local_import/views/local_import_admin.html.php delete mode 100644 modules/local_import/views/local_import_dir_list.html.php delete mode 100644 modules/local_import/views/local_import_tree.html.php delete mode 100644 modules/local_import/views/local_import_tree_dialog.html.php create mode 100644 modules/server_add/controllers/admin_server_add.php create mode 100644 modules/server_add/controllers/server_add.php create mode 100644 modules/server_add/css/admin.css create mode 100644 modules/server_add/css/jquery.autocomplete.css create mode 100644 modules/server_add/css/server_add.css create mode 100644 modules/server_add/helpers/server_add_block.php create mode 100644 modules/server_add/helpers/server_add_installer.php create mode 100644 modules/server_add/helpers/server_add_menu.php create mode 100644 modules/server_add/helpers/server_add_theme.php create mode 100644 modules/server_add/js/admin.js create mode 100644 modules/server_add/js/jquery.autocomplete.pack.js create mode 100644 modules/server_add/js/server_add.js create mode 100644 modules/server_add/module.info create mode 100644 modules/server_add/views/server_add_admin.html.php create mode 100644 modules/server_add/views/server_add_dir_list.html.php create mode 100644 modules/server_add/views/server_add_tree.html.php create mode 100644 modules/server_add/views/server_add_tree_dialog.html.php (limited to 'modules') diff --git a/modules/local_import/controllers/admin_local_import.php b/modules/local_import/controllers/admin_local_import.php deleted file mode 100644 index 5b556e13..00000000 --- a/modules/local_import/controllers/admin_local_import.php +++ /dev/null @@ -1,94 +0,0 @@ -content = new View("local_import_admin.html"); - $view->content->add_form = $this->_get_admin_form(); - $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; - } - - public function add_path() { - access::verify_csrf(); - - $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)); - $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" => $view->__toString(), - "form" => $form->__toString())); - } else { - $form->add_path->inputs["path"]->error("not_readable"); - print json_encode(array("result" => "error", "form" => $form->__toString())); - } - } else { - print json_encode(array("result" => "error", "form" => $form->__toString())); - } - - } - - public function remove_path() { - access::verify_csrf(); - - $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() { - $directories = array(); - $path_prefix = $this->input->get("q"); - foreach (glob("{$path_prefix}*") as $file) { - if (is_dir($file)) { - $directories[] = $file; - } - } - - 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/controllers/local_import.php b/modules/local_import/controllers/local_import.php deleted file mode 100644 index 8a6ee78a..00000000 --- a/modules/local_import/controllers/local_import.php +++ /dev/null @@ -1,128 +0,0 @@ -action = url::site("local_import/add_photo/$id"); - $view->hidden = array("csrf" => access::csrf_token(), "base_url" => url::base(true)); - $view->parents = $item->parents(); - $view->album_title = $item->title; - - $tree = new View("local_import_tree.html"); - $tree->data = array(); - $tree->uid = "tree_$id"; - foreach (array_keys($paths) as $path) { - $tree->data[$path] = array("path" => $path, "is_dir" => true); - } - $view->tree = $tree->__toString(); - print $view; - } - - public function children() { - $path = $this->input->post("path"); - $path = implode("/", $this->input->post("path")); - if (!is_readable($path)) { - kohana::show_404(); - } - - $tree = new View("local_import_tree.html"); - $tree->data = $this->_get_children($path); - $tree->uid = "tree_" . md5($path); - print $tree; - } - - function start() { - batch::start(); - } - - function add_photo($id) { - access::verify_csrf(); - - $parent = ORM::factory("item", $id); - access::required("local_import", $parent); - if (!$parent->is_album() && !$parent->loaded ) { - throw new Exception("@todo BAD_ALBUM"); - } - - $path = $this->input->post("path"); - - $paths = unserialize(module::get_var("local_import", "authorized_paths")); - if (empty($paths[$path[0]])) { - throw new Exception("@todo BAD_PATH"); - } - - $source_path = $path[0]; - // The first path corresponds to the source directory so we can just skip it. - for ($i = 1; $i < count($path); $i++) { - $source_path .= "/$path[$i]"; - $pathinfo = pathinfo($source_path); - set_time_limit(30); - if (is_dir($source_path)) { - $album = ORM::factory("item") - ->where("name", $path[$i]) - ->where("parent_id", $parent->id) - ->find(); - if (!$album->loaded) { - $album = album::create($parent, $path[$i], $path[$i], null, user::active()->id); - } - $parent = $album; - } else if (in_array($pathinfo["extension"], array("flv", "mp4"))) { - $movie = movie::create($parent, $source_path, basename($source_path), - basename($source_path), null, user::active()->id); - } else { - $photo = photo::create($parent, $source_path, basename($source_path), - basename($source_path), null, user::active()->id); - } - } - } - - public function finish() { - batch::stop(); - print json_encode(array("result" => "success")); - } - - private function _get_children($path) { - $file_list = array(); - $files = new DirectoryIterator($path); - foreach ($files as $file) { - if ($file->isDot()) { - continue; - } - $filename = $file->getFilename(); - if ($filename[0] != ".") { - if ($file->isDir()) { - $file_list[$filename] = array("path" => $file->getPathname(), "is_dir" => true); - } else { - $extension = strtolower(substr(strrchr($filename, '.'), 1)); - if ($file->isReadable() && - in_array($extension, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { - $file_list[$filename] = array("path" => $file->getPathname(), "is_dir" => false); - } - } - } - } - return $file_list; - } -} \ No newline at end of file diff --git a/modules/local_import/css/admin.css b/modules/local_import/css/admin.css deleted file mode 100644 index dd5a8ac3..00000000 --- a/modules/local_import/css/admin.css +++ /dev/null @@ -1,29 +0,0 @@ -#gLocalImportAdmin { - margin:auto; - text-align: left; -} - -#gLocalImportAdmin form fieldset { - border: medium none; -} - -#gLocalImportAdmin legend { - display: none; -} - -#gLocalImportAdmin .gWarning { - background-color: #FFFF99; -} - -#gAuthorizedPath { - margin: 0 !important; - padding: 0.3em 1.5em 0.3em 1em; -} - -#gLocalImportAdmin #path { - width: 80%; -} - -.gRemoveDir:hover { - cursor: pointer; -} diff --git a/modules/local_import/css/jquery.autocomplete.css b/modules/local_import/css/jquery.autocomplete.css deleted file mode 100644 index 4d50cf43..00000000 --- a/modules/local_import/css/jquery.autocomplete.css +++ /dev/null @@ -1,49 +0,0 @@ -.ac_results { - padding: 0px; - border: 1px solid black; - background-color: white; - overflow: hidden; - text-align: left; - z-index: 99999; -} - -.ac_results ul { - width: 100%; - list-style-position: outside; - list-style: none; - padding: 0; - margin: 0; -} - -.ac_results li { - margin: 0px; - padding: 2px 5px; - cursor: default; - display: block; - /* - if width will be 100% horizontal scrollbar will apear - when scroll mode will be used - */ - /*width: 100%;*/ - font: menu; - font-size: 12px; - /* - it is very important, if line-height not setted or setted - in relative units scroll will be broken in firefox - */ - line-height: 16px; - overflow: hidden; -} - -.ac_loading { - background: white url('indicator.gif') right center no-repeat; -} - -.ac_odd { - background-color: #eee; -} - -.ac_over { - background-color: #0A246A; - color: white; -} diff --git a/modules/local_import/css/local_import.css b/modules/local_import/css/local_import.css deleted file mode 100644 index 23c2449d..00000000 --- a/modules/local_import/css/local_import.css +++ /dev/null @@ -1,60 +0,0 @@ -.gCheckboxTree { - display: none; -} - -.gCheckboxTree input { - display: inline; -} - -.gCheckboxTree li { - padding: 0; - float: none; -} - -.gCheckboxTree .ui-icon { - cursor: pointer; -} - -.gFile { - padding-left: 2.5em; -} - -#gProgressBar { - visibility: hidden; - height: 1em; - width: 100%; - margin-top: 0.5em; - display: inline-block; -} - -#gLocalImport #gLocalImportTree { - border: 1px solid #CCCCCC; - height: 25em; - overflow: auto; - margin-bottom: .5em; - padding-top: .5em; - padding-bottom: .5em; -} - -#gLocalImport ul ul li { - padding-left: 1.2em; -} - -#gLocalImport ul li .gFile { - padding-left: 2.5em; -} - -#gLocalImport .gBreadcrumbs { - font-size: 1em; - padding: 0; - margin: 0; - border-top-width: 0px; -} - -#gLocalImport p { - margin: 0; -} - -#gLocalImport .gBreadcrumbs li { - padding: 10px 6px 10px 16px; -} diff --git a/modules/local_import/helpers/local_import_block.php b/modules/local_import/helpers/local_import_block.php deleted file mode 100644 index b412f338..00000000 --- a/modules/local_import/helpers/local_import_block.php +++ /dev/null @@ -1,30 +0,0 @@ -"; - - return implode("\n", $head); - } -} diff --git a/modules/local_import/helpers/local_import_installer.php b/modules/local_import/helpers/local_import_installer.php deleted file mode 100644 index df183a11..00000000 --- a/modules/local_import/helpers/local_import_installer.php +++ /dev/null @@ -1,46 +0,0 @@ -here to configure one", - array("url" => url::site("/admin/local_import")))); - } - } - - static function uninstall() { - access::delete_permission("local_import"); - $module = module::get("local_import"); - - $db = Database::instance(); - $db->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 deleted file mode 100644 index b940e01e..00000000 --- a/modules/local_import/helpers/local_import_menu.php +++ /dev/null @@ -1,43 +0,0 @@ -get("settings_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("edit", $item) && access::can("local_import", $item) && - $item->is_album() && !empty($paths)) { - $options_menu = $menu->get("options_menu") - ->append(Menu::factory("dialog") - ->id("local_import") - ->label(t("Add 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 deleted file mode 100644 index 69341c72..00000000 --- a/modules/local_import/helpers/local_import_theme.php +++ /dev/null @@ -1,38 +0,0 @@ -"; - $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); - } -} \ No newline at end of file diff --git a/modules/local_import/js/admin.js b/modules/local_import/js/admin.js deleted file mode 100644 index 4102a82b..00000000 --- a/modules/local_import/js/admin.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Set up autocomplete on the server path list - * - */ -$("document").ready(function() { - add_autocomplete(); - ajaxify_import_form(); - add_onclick(); -}); - -function add_autocomplete() { - $("#gLocalImportAdmin input:text").autocomplete(base_url + "admin/local_import/autocomplete", { - extraParams: {csrf: csrf}, - mustMatch: true, - max: 256}); -} -function ajaxify_import_form(options) { - $("#gLocalImportAdmin form").ajaxForm({ - dataType: "json", - success: function(data) { - if (data.form) { - $("#gLocalImportAdmin form").replaceWith(data.form); - ajaxify_import_form(); - add_autocomplete(); - } - if (data.result == "success") { - $("#gNoImportPaths").css("display", "none"); - $("#gAuthorizedPath").html(data.paths); - add_onclick(); - } - } - }); -} - -function add_onclick() { - $(".gRemoveDir").click(function() { - var parent = $(this).parent(); - $.post( - base_url + "admin/local_import/remove_path", - {csrf: csrf, - path: parent.text().replace(/^\s\s*/, "").replace(/\s\s*$/, "")}, - function(data, textStatus) { - $("#gAuthorizedPath").html(data); - add_onclick(); - }); - }); -} diff --git a/modules/local_import/js/jquery.autocomplete.pack.js b/modules/local_import/js/jquery.autocomplete.pack.js deleted file mode 100644 index 271014a2..00000000 --- a/modules/local_import/js/jquery.autocomplete.pack.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Autocomplete - jQuery plugin 1.0.2 - * - * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer - * - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - * Revision: $Id: jquery.autocomplete.js 5747 2008-06-25 18:30:55Z joern.zaefferer $ - * - */ -eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(3($){$.31.1o({12:3(b,d){5 c=Y b=="1w";d=$.1o({},$.D.1L,{11:c?b:14,w:c?14:b,1D:c?$.D.1L.1D:10,Z:d&&!d.1x?10:3U},d);d.1t=d.1t||3(a){6 a};d.1q=d.1q||d.1K;6 I.K(3(){1E $.D(I,d)})},M:3(a){6 I.X("M",a)},1y:3(a){6 I.15("1y",[a])},20:3(){6 I.15("20")},1Y:3(a){6 I.15("1Y",[a])},1X:3(){6 I.15("1X")}});$.D=3(o,r){5 t={2N:38,2I:40,2D:46,2x:9,2v:13,2q:27,2d:3x,2j:33,2o:34,2e:8};5 u=$(o).3f("12","3c").P(r.24);5 p;5 m="";5 n=$.D.2W(r);5 s=0;5 k;5 h={1z:B};5 l=$.D.2Q(r,o,1U,h);5 j;$.1T.2L&&$(o.2K).X("3S.12",3(){4(j){j=B;6 B}});u.X(($.1T.2L?"3Q":"3N")+".12",3(a){k=a.2F;3L(a.2F){Q t.2N:a.1d();4(l.L()){l.2y()}A{W(0,C)}N;Q t.2I:a.1d();4(l.L()){l.2u()}A{W(0,C)}N;Q t.2j:a.1d();4(l.L()){l.2t()}A{W(0,C)}N;Q t.2o:a.1d();4(l.L()){l.2s()}A{W(0,C)}N;Q r.19&&$.1p(r.R)==","&&t.2d:Q t.2x:Q t.2v:4(1U()){a.1d();j=C;6 B}N;Q t.2q:l.U();N;3A:1I(p);p=1H(W,r.1D);N}}).1G(3(){s++}).3v(3(){s=0;4(!h.1z){2k()}}).2i(3(){4(s++>1&&!l.L()){W(0,C)}}).X("1y",3(){5 c=(1n.7>1)?1n[1]:14;3 23(q,a){5 b;4(a&&a.7){16(5 i=0;i1){v=a.17(0,a.7-1).2Z(r.R)+r.R+v}v+=r.R}u.J(v);1l();u.15("M",[b.w,b.H]);6 C}3 W(b,c){4(k==t.2D){l.U();6}5 a=u.J();4(!c&&a==m)6;m=a;a=1k(a);4(a.7>=r.22){u.P(r.21);4(!r.1C)a=a.O();1R(a,2V,1l)}A{1B();l.U()}};3 1g(b){4(!b){6[""]}5 d=b.1Z(r.R);5 c=[];$.K(d,3(i,a){4($.1p(a))c[i]=$.1p(a)});6 c}3 1k(a){4(!r.19)6 a;5 b=1g(a);6 b[b.7-1]}3 1A(q,a){4(r.1A&&(1k(u.J()).O()==q.O())&&k!=t.2e){u.J(u.J()+a.48(1k(m).7));$.D.1N(o,m.7,m.7+a.7)}};3 2k(){1I(p);p=1H(1l,47)};3 1l(){5 c=l.L();l.U();1I(p);1B();4(r.2U){u.1y(3(a){4(!a){4(r.19){5 b=1g(u.J()).17(0,-1);u.J(b.2Z(r.R)+(b.7?r.R:""))}A u.J("")}})}4(c)$.D.1N(o,o.H.7,o.H.7)};3 2V(q,a){4(a&&a.7&&s){1B();l.2T(a,q);1A(q,a[0].H);l.1W()}A{1l()}};3 1R(f,d,g){4(!r.1C)f=f.O();5 e=n.2S(f);4(e&&e.7){d(f,e)}A 4((Y r.11=="1w")&&(r.11.7>0)){5 c={45:+1E 44()};$.K(r.2R,3(a,b){c[a]=Y b=="3"?b():b});$.43({42:"41",3Z:"12"+o.3Y,2M:r.2M,11:r.11,w:$.1o({q:1k(f),3X:r.Z},c),3W:3(a){5 b=r.1r&&r.1r(a)||1r(a);n.1h(f,b);d(f,b)}})}A{l.2J();g(f)}};3 1r(c){5 d=[];5 b=c.1Z("\\n");16(5 i=0;i]*)("+a.2C(/([\\^\\$\\(\\)\\[\\]\\{\\}\\*\\.\\+\\?\\|\\\\])/2A,"\\\\$1")+")(?![^<>]*>)(?![^&;]+;)","2A"),"<2z>$1")},1x:C,1s:3I};$.D.2W=3(g){5 h={};5 j=0;3 1a(s,a){4(!g.1C)s=s.O();5 i=s.3H(a);4(i==-1)6 B;6 i==0||g.1V};3 1h(q,a){4(j>g.1j){18()}4(!h[q]){j++}h[q]=a}3 1f(){4(!g.w)6 B;5 f={},2w=0;4(!g.11)g.1j=1;f[""]=[];16(5 i=0,30=g.w.7;i<30;i++){5 c=g.w[i];c=(Y c=="1w")?[c]:c;5 d=g.1q(c,i+1,g.w.7);4(d===B)1P;5 e=d.3G(0).O();4(!f[e])f[e]=[];5 b={H:d,w:c,M:g.1v&&g.1v(c)||d};f[e].1O(b);4(2w++0){5 c=h[k];$.K(c,3(i,x){4(1a(x.H,q)){a.1O(x)}})}}6 a}A 4(h[q]){6 h[q]}A 4(g.1a){16(5 i=q.7-1;i>=g.22;i--){5 c=h[q.3F(0,i)];4(c){5 a=[];$.K(c,3(i,x){4(1a(x.H,q)){a[a.7]=x}});6 a}}}6 14}}};$.D.2Q=3(e,g,f,k){5 h={G:"3E"};5 j,y=-1,w,1m="",1M=C,F,z;3 2r(){4(!1M)6;F=$("<3D/>").U().P(e.2H).T("3C","3B").1J(2p.2n);z=$("<3z/>").1J(F).3y(3(a){4(V(a).2m&&V(a).2m.3w()==\'2l\'){y=$("1F",z).1e(h.G).3u(V(a));$(V(a)).P(h.G)}}).2i(3(a){$(V(a)).P(h.G);f();g.1G();6 B}).3t(3(){k.1z=C}).3s(3(){k.1z=B});4(e.E>0)F.T("E",e.E);1M=B}3 V(a){5 b=a.V;3r(b&&b.3q!="2l")b=b.3p;4(!b)6[];6 b}3 S(b){j.17(y,y+1).1e(h.G);2h(b);5 a=j.17(y,y+1).P(h.G);4(e.1x){5 c=0;j.17(0,y).K(3(){c+=I.1i});4((c+a[0].1i-z.1c())>z[0].3o){z.1c(c+a[0].1i-z.3n())}A 4(c=j.1b()){y=0}}3 2g(a){6 e.Z&&e.Z").3m(e.1t(a,1m)).P(i%2==0?"3l":"3k").1J(z)[0];$.w(c,"2c",w[i])}j=z.3j("1F");4(e.1S){j.17(0,1).P(h.G);y=0}4($.31.2b)z.2b()}6{2T:3(d,q){2r();w=d;1m=q;2f()},2u:3(){S(1)},2y:3(){S(-1)},2t:3(){4(y!=0&&y-8<0){S(-y)}A{S(-8)}},2s:3(){4(y!=j.1b()-1&&y+8>j.1b()){S(j.1b()-1-y)}A{S(8)}},U:3(){F&&F.U();j&&j.1e(h.G);y=-1},L:3(){6 F&&F.3i(":L")},3h:3(){6 I.L()&&(j.2a("."+h.G)[0]||e.1S&&j[0])},1W:3(){5 a=$(g).3g();F.T({E:Y e.E=="1w"||e.E>0?e.E:$(g).E(),2E:a.2E+g.1i,1Q:a.1Q}).1W();4(e.1x){z.1c(0);z.T({29:e.1s,3e:\'3d\'});4($.1T.3b&&Y 2p.2n.3T.29==="3a"){5 c=0;j.K(3(){c+=I.1i});5 b=c>e.1s;z.T(\'3V\',b?e.1s:c);4(!b){j.E(z.E()-28(j.T("32-1Q"))-28(j.T("32-39")))}}}},26:3(){5 a=j&&j.2a("."+h.G).1e(h.G);6 a&&a.7&&$.w(a[0],"2c")},2J:3(){z&&z.2B()},1u:3(){F&&F.37()}}};$.D.1N=3(b,a,c){4(b.2O){5 d=b.2O();d.36(C);d.35("2P",a);d.4c("2P",c);d.4b()}A 4(b.2Y){b.2Y(a,c)}A{4(b.2X){b.2X=a;b.4a=c}}b.1G()}})(49);',62,261,'|||function|if|var|return|length|||||||||||||||||||||||||data||active|list|else|false|true|Autocompleter|width|element|ACTIVE|value|this|val|each|visible|result|break|toLowerCase|addClass|case|multipleSeparator|moveSelect|css|hide|target|onChange|bind|typeof|max||url|autocomplete||null|trigger|for|slice|flush|multiple|matchSubset|size|scrollTop|preventDefault|removeClass|populate|trimWords|add|offsetHeight|cacheLength|lastWord|hideResultsNow|term|arguments|extend|trim|formatMatch|parse|scrollHeight|highlight|unbind|formatResult|string|scroll|search|mouseDownOnSelect|autoFill|stopLoading|matchCase|delay|new|li|focus|setTimeout|clearTimeout|appendTo|formatItem|defaults|needsInit|Selection|push|continue|left|request|selectFirst|browser|selectCurrent|matchContains|show|unautocomplete|setOptions|split|flushCache|loadingClass|minChars|findValueCallback|inputClass||selected||parseInt|maxHeight|filter|bgiframe|ac_data|COMMA|BACKSPACE|fillList|limitNumberOfItems|movePosition|click|PAGEUP|hideResults|LI|nodeName|body|PAGEDOWN|document|ESC|init|pageDown|pageUp|next|RETURN|nullData|TAB|prev|strong|gi|empty|replace|DEL|top|keyCode|in|resultsClass|DOWN|emptyList|form|opera|dataType|UP|createTextRange|character|Select|extraParams|load|display|mustMatch|receiveData|Cache|selectionStart|setSelectionRange|join|ol|fn|padding|||moveStart|collapse|remove||right|undefined|msie|off|auto|overflow|attr|offset|current|is|find|ac_odd|ac_even|html|innerHeight|clientHeight|parentNode|tagName|while|mouseup|mousedown|index|blur|toUpperCase|188|mouseover|ul|default|absolute|position|div|ac_over|substr|charAt|indexOf|180|RegExp|100|switch|400|keydown|ac_loading|ac_results|keypress|ac_input|submit|style|150|height|success|limit|name|port||abort|mode|ajax|Date|timestamp||200|substring|jQuery|selectionEnd|select|moveEnd'.split('|'),0,{})) \ No newline at end of file diff --git a/modules/local_import/js/local_import.js b/modules/local_import/js/local_import.js deleted file mode 100644 index c9645bfc..00000000 --- a/modules/local_import/js/local_import.js +++ /dev/null @@ -1,134 +0,0 @@ -$("#gLocalImport").ready(function() { - $("#gLocalImport :submit").click(function(event) { - do_import(this, event); - }); - $("#gProgressBar").progressbar(); - $("#gLocalImport ul").css("display", "block"); -}); - -function open_close_branch(icon, event) { - var parent = icon.parentNode; - var children = $(parent).find(".gCheckboxTree"); - var closed = $(icon).hasClass("ui-icon-plus"); - - if (closed) { - if (children.length == 0) { - load_children(icon, function(data, textStatus) { - $(parent).append(data); - $(icon).addClass("ui-icon-minus"); - $(icon).removeClass("ui-icon-plus"); - var checkbox = $(parent).find(":checkbox")[0]; - checkbox_click(checkbox, null); - }); - } else { - $(icon).addClass("ui-icon-minus"); - $(icon).removeClass("ui-icon-plus"); - } - $(parent).children("ul").slideDown("fast"); - } else { - $(icon).addClass("ui-icon-plus"); - $(icon).removeClass("ui-icon-minus"); - $(parent).children("ul").slideUp("fast"); - } -} - -function checkbox_click(checkbox, event) { - var parents = $(checkbox).parents("li"); - var parent = parents.get(0); - $(parent).find(".gCheckboxTree :checkbox").attr("checked", checkbox.checked); - var checked = $("#gLocalImport :checkbox[checked]"); - $("#gLocalImport form :submit").attr("disabled", checked.length == 0); -} - -function load_children(icon, callback) { - var csrf = $("#gLocalImport form :hidden[name='csrf']")[0].value; - var base_url = $("#gLocalImport form :hidden[name='base_url']")[0].value; - var parms = "&csrf=" + csrf; - var parents = $(icon).parents("li"); - for (var i=parents.length - 1; i >= 0; i--) { - parms += "&path[]=" + $(parents[i]).children("span").attr("ref"); - } - $.ajax({async: false, - success: callback, - data: parms, - dataType: "html", - type: "POST", - url: base_url + "local_import/children" - }); -} - -var current = 0; -var process_length = 0; -function do_import(submit, event) { - event.preventDefault(); - $("#gProgressBar").progressbar("value", 0); - $("#gProgressBar").css("visibility", "visible"); - var check_list = $("#gLocalImport :checkbox[checked]"); - process_length = check_list.length; - current = 0; - var base_url = $("#gLocalImport form :hidden[name='base_url']")[0].value; - $.ajax({async: false, - success: function(data, textStatus) { - document.location.reload(); - }, - dataType: "json", - type: "POST", - url: base_url + "local_import/start" - }); - $.each(check_list, function () { - process_checkbox(this); - }); - $.ajax({async: false, - success: function(data, textStatus) { - document.location.reload(); - }, - dataType: "json", - type: "POST", - url: base_url + "local_import/finish" - }); - return false; -} - -function process_checkbox(checkbox) { - var parents = $(checkbox).parents("li"); - var csrf = $("#gLocalImport form :hidden[name='csrf']")[0].value; - var parms = "&csrf=" + csrf; - for (var i=parents.length - 1; i > 0; i--) { - parms += "&path[]=" + $(parents[i]).children("span").attr("ref"); - } - parms += "&path[]=" + $(checkbox).val(); - - var parent = parents[0]; - if ($(parent).hasClass("gFile")) { - process_file(parents[0], parms); - } else if ($(parent).hasClass("gDirectory") && $(parents[0]).find(".gCheckboxTree").length == 0) { - // If it is a directory and retrieve the children and process them - var icon = $(parent).children("span")[0]; - load_children(icon, function(data, textStatus) { - $(parent).append(data); - $(icon).addClass("ui-icon-plus"); - checkbox_click(checkbox, null); - var boxes = $(parent).find(".gCheckboxTree :checkbox[checked]"); - process_length += boxes.length; - $.each(boxes, function () { - process_checkbox(this); - }); - }); - current++; - $("#gProgressBar").progressbar("value", current / process_length * 100); - } -} - -function process_file(li_element, parms) { - $.ajax({async: false, - success: function(data, status) { - }, - data: parms, - dataType: "html", - type: "POST", - url: $("#gLocalImport form").attr("action") - }); - current++; - $("#gProgressBar").progressbar("value", current / process_length * 100); -} - diff --git a/modules/local_import/module.info b/modules/local_import/module.info deleted file mode 100644 index a2a3d66c..00000000 --- a/modules/local_import/module.info +++ /dev/null @@ -1,3 +0,0 @@ -name = Local Import -description = Allows authorized users to load images from the local server -version = 1 diff --git a/modules/local_import/views/local_import_admin.html.php b/modules/local_import/views/local_import_admin.html.php deleted file mode 100644 index f26f57ad..00000000 --- a/modules/local_import/views/local_import_admin.html.php +++ /dev/null @@ -1,10 +0,0 @@ - -
-

- -

-
- -
- -
diff --git a/modules/local_import/views/local_import_dir_list.html.php b/modules/local_import/views/local_import_dir_list.html.php deleted file mode 100644 index 7041fcc2..00000000 --- a/modules/local_import/views/local_import_dir_list.html.php +++ /dev/null @@ -1,13 +0,0 @@ - - -
    - $path): ?> -
  • - - -
  • - -
-
style="display:none"> - -
diff --git a/modules/local_import/views/local_import_tree.html.php b/modules/local_import/views/local_import_tree.html.php deleted file mode 100644 index b664c679..00000000 --- a/modules/local_import/views/local_import_tree.html.php +++ /dev/null @@ -1,22 +0,0 @@ - - -
    - $file_info): ?> -
  • "> - - - - -
  • - -
diff --git a/modules/local_import/views/local_import_tree_dialog.html.php b/modules/local_import/views/local_import_tree_dialog.html.php deleted file mode 100644 index 520a2af0..00000000 --- a/modules/local_import/views/local_import_tree_dialog.html.php +++ /dev/null @@ -1,26 +0,0 @@ - -" /> - - -
-

- -

-
    - -
  • title ?>
  • - -
  • -
- - "post"), $hidden) ?> -
- -
- - "gImportButton", "name" => "import", "disabled" => true, "class" => "submit"), t("Import")) ?> - - -
-
diff --git a/modules/server_add/controllers/admin_server_add.php b/modules/server_add/controllers/admin_server_add.php new file mode 100644 index 00000000..a340f61a --- /dev/null +++ b/modules/server_add/controllers/admin_server_add.php @@ -0,0 +1,94 @@ +content = new View("server_add_admin.html"); + $view->content->add_form = $this->_get_admin_form(); + $view->content->path_list = new View("server_add_dir_list.html"); + $paths = unserialize(module::get_var("server_add", "authorized_paths", "a:0:{}")); + $view->content->path_list->paths = array_keys($paths); + + print $view; + } + + public function add_path() { + access::verify_csrf(); + + $form = $this->_get_admin_form(); + $paths = unserialize(module::get_var("server_add", "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("server_add", "authorized_paths", serialize($paths)); + $view = new View("server_add_dir_list.html"); + $view->paths = array_keys($paths); + $form->add_path->inputs["path"]->value(""); + print json_encode( + array("result" => "success", + "paths" => $view->__toString(), + "form" => $form->__toString())); + } else { + $form->add_path->inputs["path"]->error("not_readable"); + print json_encode(array("result" => "error", "form" => $form->__toString())); + } + } else { + print json_encode(array("result" => "error", "form" => $form->__toString())); + } + + } + + public function remove_path() { + access::verify_csrf(); + + $path = $this->input->post("path"); + $paths = unserialize(module::get_var("server_add", "authorized_paths")); + unset($paths[$path]); + module::set_var("server_add", "authorized_paths", serialize($paths)); + + $view = new View("server_add_dir_list.html"); + $view->paths = array_keys($paths); + + print $view; + } + + public function autocomplete() { + $directories = array(); + $path_prefix = $this->input->get("q"); + foreach (glob("{$path_prefix}*") as $file) { + if (is_dir($file)) { + $directories[] = $file; + } + } + + print implode("\n", $directories); + } + + private function _get_admin_form() { + $form = new Forge("admin/server_add/add_path", "", "post", + array("id" => "gServerAddAdminForm")); + $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/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php new file mode 100644 index 00000000..f269e3f9 --- /dev/null +++ b/modules/server_add/controllers/server_add.php @@ -0,0 +1,128 @@ +action = url::site("server_add/add_photo/$id"); + $view->hidden = array("csrf" => access::csrf_token(), "base_url" => url::base(true)); + $view->parents = $item->parents(); + $view->album_title = $item->title; + + $tree = new View("server_add_tree.html"); + $tree->data = array(); + $tree->uid = "tree_$id"; + foreach (array_keys($paths) as $path) { + $tree->data[$path] = array("path" => $path, "is_dir" => true); + } + $view->tree = $tree->__toString(); + print $view; + } + + public function children() { + $path = $this->input->post("path"); + $path = implode("/", $this->input->post("path")); + if (!is_readable($path)) { + kohana::show_404(); + } + + $tree = new View("server_add_tree.html"); + $tree->data = $this->_get_children($path); + $tree->uid = "tree_" . md5($path); + print $tree; + } + + function start() { + batch::start(); + } + + function add_photo($id) { + access::verify_csrf(); + + $parent = ORM::factory("item", $id); + access::required("server_add", $parent); + if (!$parent->is_album() && !$parent->loaded ) { + throw new Exception("@todo BAD_ALBUM"); + } + + $path = $this->input->post("path"); + + $paths = unserialize(module::get_var("server_add", "authorized_paths")); + if (empty($paths[$path[0]])) { + throw new Exception("@todo BAD_PATH"); + } + + $source_path = $path[0]; + // The first path corresponds to the source directory so we can just skip it. + for ($i = 1; $i < count($path); $i++) { + $source_path .= "/$path[$i]"; + $pathinfo = pathinfo($source_path); + set_time_limit(30); + if (is_dir($source_path)) { + $album = ORM::factory("item") + ->where("name", $path[$i]) + ->where("parent_id", $parent->id) + ->find(); + if (!$album->loaded) { + $album = album::create($parent, $path[$i], $path[$i], null, user::active()->id); + } + $parent = $album; + } else if (in_array($pathinfo["extension"], array("flv", "mp4"))) { + $movie = movie::create($parent, $source_path, basename($source_path), + basename($source_path), null, user::active()->id); + } else { + $photo = photo::create($parent, $source_path, basename($source_path), + basename($source_path), null, user::active()->id); + } + } + } + + public function finish() { + batch::stop(); + print json_encode(array("result" => "success")); + } + + private function _get_children($path) { + $file_list = array(); + $files = new DirectoryIterator($path); + foreach ($files as $file) { + if ($file->isDot()) { + continue; + } + $filename = $file->getFilename(); + if ($filename[0] != ".") { + if ($file->isDir()) { + $file_list[$filename] = array("path" => $file->getPathname(), "is_dir" => true); + } else { + $extension = strtolower(substr(strrchr($filename, '.'), 1)); + if ($file->isReadable() && + in_array($extension, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) { + $file_list[$filename] = array("path" => $file->getPathname(), "is_dir" => false); + } + } + } + } + return $file_list; + } +} \ No newline at end of file diff --git a/modules/server_add/css/admin.css b/modules/server_add/css/admin.css new file mode 100644 index 00000000..b700919b --- /dev/null +++ b/modules/server_add/css/admin.css @@ -0,0 +1,29 @@ +#gServerAddAdmin { + margin:auto; + text-align: left; +} + +#gServerAddAdmin form fieldset { + border: medium none; +} + +#gServerAddAdmin legend { + display: none; +} + +#gServerAddAdmin .gWarning { + background-color: #FFFF99; +} + +#gAuthorizedPath { + margin: 0 !important; + padding: 0.3em 1.5em 0.3em 1em; +} + +#gServerAdd Admin #path { + width: 80%; +} + +.gRemoveDir:hover { + cursor: pointer; +} diff --git a/modules/server_add/css/jquery.autocomplete.css b/modules/server_add/css/jquery.autocomplete.css new file mode 100644 index 00000000..4d50cf43 --- /dev/null +++ b/modules/server_add/css/jquery.autocomplete.css @@ -0,0 +1,49 @@ +.ac_results { + padding: 0px; + border: 1px solid black; + background-color: white; + overflow: hidden; + text-align: left; + z-index: 99999; +} + +.ac_results ul { + width: 100%; + list-style-position: outside; + list-style: none; + padding: 0; + margin: 0; +} + +.ac_results li { + margin: 0px; + padding: 2px 5px; + cursor: default; + display: block; + /* + if width will be 100% horizontal scrollbar will apear + when scroll mode will be used + */ + /*width: 100%;*/ + font: menu; + font-size: 12px; + /* + it is very important, if line-height not setted or setted + in relative units scroll will be broken in firefox + */ + line-height: 16px; + overflow: hidden; +} + +.ac_loading { + background: white url('indicator.gif') right center no-repeat; +} + +.ac_odd { + background-color: #eee; +} + +.ac_over { + background-color: #0A246A; + color: white; +} diff --git a/modules/server_add/css/server_add.css b/modules/server_add/css/server_add.css new file mode 100644 index 00000000..16ccc539 --- /dev/null +++ b/modules/server_add/css/server_add.css @@ -0,0 +1,60 @@ +.gCheckboxTree { + display: none; +} + +.gCheckboxTree input { + display: inline; +} + +.gCheckboxTree li { + padding: 0; + float: none; +} + +.gCheckboxTree .ui-icon { + cursor: pointer; +} + +.gFile { + padding-left: 2.5em; +} + +#gProgressBar { + visibility: hidden; + height: 1em; + width: 100%; + margin-top: 0.5em; + display: inline-block; +} + +#gServerAdd #gServerAddTree { + border: 1px solid #CCCCCC; + height: 25em; + overflow: auto; + margin-bottom: .5em; + padding-top: .5em; + padding-bottom: .5em; +} + +#gServerAdd ul ul li { + padding-left: 1.2em; +} + +#gServerAdd ul li .gFile { + padding-left: 2.5em; +} + +#gServerAdd .gBreadcrumbs { + font-size: 1em; + padding: 0; + margin: 0; + border-top-width: 0px; +} + +#gServerAdd p { + margin: 0; +} + +#gServerAdd .gBreadcrumbs li { + padding: 10px 6px 10px 16px; +} diff --git a/modules/server_add/helpers/server_add_block.php b/modules/server_add/helpers/server_add_block.php new file mode 100644 index 00000000..c2a94e97 --- /dev/null +++ b/modules/server_add/helpers/server_add_block.php @@ -0,0 +1,30 @@ +"; + + return implode("\n", $head); + } +} diff --git a/modules/server_add/helpers/server_add_installer.php b/modules/server_add/helpers/server_add_installer.php new file mode 100644 index 00000000..8b1c4688 --- /dev/null +++ b/modules/server_add/helpers/server_add_installer.php @@ -0,0 +1,47 @@ +here to configure one", + array("url" => url::site("/admin/server_add")))); + } + } + + static function uninstall() { + access::delete_permission("server_add"); + $module = module::get("server_add"); + + $db = Database::instance(); + $db->delete("vars", array("module_name" => $module->name)); + + module::delete("local_import"); + module::delete("server_add"); + } +} diff --git a/modules/server_add/helpers/server_add_menu.php b/modules/server_add/helpers/server_add_menu.php new file mode 100644 index 00000000..fe27d6d2 --- /dev/null +++ b/modules/server_add/helpers/server_add_menu.php @@ -0,0 +1,43 @@ +get("settings_menu") + ->append(Menu::factory("link") + ->id("server_add") + ->label(t("Server Add")) + ->url(url::site("admin/server_add"))); + } + + static function site($menu, $theme) { + $item = $theme->item(); + + $paths = unserialize(module::get_var("server_add", "authorized_paths")); + + if ($item && access::can("edit", $item) && access::can("server_add", $item) && + $item->is_album() && !empty($paths)) { + $options_menu = $menu->get("options_menu") + ->append(Menu::factory("dialog") + ->id("server_add") + ->label(t("Add from server")) + ->url(url::site("server_add/index/$item->id"))); + } + } +} diff --git a/modules/server_add/helpers/server_add_theme.php b/modules/server_add/helpers/server_add_theme.php new file mode 100644 index 00000000..82c9a951 --- /dev/null +++ b/modules/server_add/helpers/server_add_theme.php @@ -0,0 +1,38 @@ +"; + $head[] = ""; + $base = url::base(true); + $csrf = access::csrf_token(); + $head[] = ""; + + $head[] = html::script("modules/server_add/js/jquery.autocomplete.pack.js"); + $head[] = html::script("modules/server_add/js/admin.js"); + } + + return implode("\n", $head); + } +} \ No newline at end of file diff --git a/modules/server_add/js/admin.js b/modules/server_add/js/admin.js new file mode 100644 index 00000000..dcd0dde0 --- /dev/null +++ b/modules/server_add/js/admin.js @@ -0,0 +1,47 @@ +/** + * Set up autocomplete on the server path list + * + */ +$("document").ready(function() { + add_autocomplete(); + ajaxify_add_form(); + add_onclick(); +}); + +function add_autocomplete() { + $("#gServerAddAdmin input:text").autocomplete(base_url + "admin/server_add/autocomplete", { + extraParams: {csrf: csrf}, + mustMatch: true, + max: 256}); +} +function ajaxify_add_form(options) { + $("#gServerAddAdmin form").ajaxForm({ + dataType: "json", + success: function(data) { + if (data.form) { + $("#gServerAddAdmin form").replaceWith(data.form); + ajaxify_add_form(); + add_autocomplete(); + } + if (data.result == "success") { + $("#gNoAuthorizedPaths").css("display", "none"); + $("#gAuthorizedPath").html(data.paths); + add_onclick(); + } + } + }); +} + +function add_onclick() { + $(".gRemoveDir").click(function() { + var parent = $(this).parent(); + $.post( + base_url + "admin/local_import/remove_path", + {csrf: csrf, + path: parent.text().replace(/^\s\s*/, "").replace(/\s\s*$/, "")}, + function(data, textStatus) { + $("#gAuthorizedPath").html(data); + add_onclick(); + }); + }); +} diff --git a/modules/server_add/js/jquery.autocomplete.pack.js b/modules/server_add/js/jquery.autocomplete.pack.js new file mode 100644 index 00000000..271014a2 --- /dev/null +++ b/modules/server_add/js/jquery.autocomplete.pack.js @@ -0,0 +1,13 @@ +/* + * Autocomplete - jQuery plugin 1.0.2 + * + * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Revision: $Id: jquery.autocomplete.js 5747 2008-06-25 18:30:55Z joern.zaefferer $ + * + */ +eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(3($){$.31.1o({12:3(b,d){5 c=Y b=="1w";d=$.1o({},$.D.1L,{11:c?b:14,w:c?14:b,1D:c?$.D.1L.1D:10,Z:d&&!d.1x?10:3U},d);d.1t=d.1t||3(a){6 a};d.1q=d.1q||d.1K;6 I.K(3(){1E $.D(I,d)})},M:3(a){6 I.X("M",a)},1y:3(a){6 I.15("1y",[a])},20:3(){6 I.15("20")},1Y:3(a){6 I.15("1Y",[a])},1X:3(){6 I.15("1X")}});$.D=3(o,r){5 t={2N:38,2I:40,2D:46,2x:9,2v:13,2q:27,2d:3x,2j:33,2o:34,2e:8};5 u=$(o).3f("12","3c").P(r.24);5 p;5 m="";5 n=$.D.2W(r);5 s=0;5 k;5 h={1z:B};5 l=$.D.2Q(r,o,1U,h);5 j;$.1T.2L&&$(o.2K).X("3S.12",3(){4(j){j=B;6 B}});u.X(($.1T.2L?"3Q":"3N")+".12",3(a){k=a.2F;3L(a.2F){Q t.2N:a.1d();4(l.L()){l.2y()}A{W(0,C)}N;Q t.2I:a.1d();4(l.L()){l.2u()}A{W(0,C)}N;Q t.2j:a.1d();4(l.L()){l.2t()}A{W(0,C)}N;Q t.2o:a.1d();4(l.L()){l.2s()}A{W(0,C)}N;Q r.19&&$.1p(r.R)==","&&t.2d:Q t.2x:Q t.2v:4(1U()){a.1d();j=C;6 B}N;Q t.2q:l.U();N;3A:1I(p);p=1H(W,r.1D);N}}).1G(3(){s++}).3v(3(){s=0;4(!h.1z){2k()}}).2i(3(){4(s++>1&&!l.L()){W(0,C)}}).X("1y",3(){5 c=(1n.7>1)?1n[1]:14;3 23(q,a){5 b;4(a&&a.7){16(5 i=0;i1){v=a.17(0,a.7-1).2Z(r.R)+r.R+v}v+=r.R}u.J(v);1l();u.15("M",[b.w,b.H]);6 C}3 W(b,c){4(k==t.2D){l.U();6}5 a=u.J();4(!c&&a==m)6;m=a;a=1k(a);4(a.7>=r.22){u.P(r.21);4(!r.1C)a=a.O();1R(a,2V,1l)}A{1B();l.U()}};3 1g(b){4(!b){6[""]}5 d=b.1Z(r.R);5 c=[];$.K(d,3(i,a){4($.1p(a))c[i]=$.1p(a)});6 c}3 1k(a){4(!r.19)6 a;5 b=1g(a);6 b[b.7-1]}3 1A(q,a){4(r.1A&&(1k(u.J()).O()==q.O())&&k!=t.2e){u.J(u.J()+a.48(1k(m).7));$.D.1N(o,m.7,m.7+a.7)}};3 2k(){1I(p);p=1H(1l,47)};3 1l(){5 c=l.L();l.U();1I(p);1B();4(r.2U){u.1y(3(a){4(!a){4(r.19){5 b=1g(u.J()).17(0,-1);u.J(b.2Z(r.R)+(b.7?r.R:""))}A u.J("")}})}4(c)$.D.1N(o,o.H.7,o.H.7)};3 2V(q,a){4(a&&a.7&&s){1B();l.2T(a,q);1A(q,a[0].H);l.1W()}A{1l()}};3 1R(f,d,g){4(!r.1C)f=f.O();5 e=n.2S(f);4(e&&e.7){d(f,e)}A 4((Y r.11=="1w")&&(r.11.7>0)){5 c={45:+1E 44()};$.K(r.2R,3(a,b){c[a]=Y b=="3"?b():b});$.43({42:"41",3Z:"12"+o.3Y,2M:r.2M,11:r.11,w:$.1o({q:1k(f),3X:r.Z},c),3W:3(a){5 b=r.1r&&r.1r(a)||1r(a);n.1h(f,b);d(f,b)}})}A{l.2J();g(f)}};3 1r(c){5 d=[];5 b=c.1Z("\\n");16(5 i=0;i]*)("+a.2C(/([\\^\\$\\(\\)\\[\\]\\{\\}\\*\\.\\+\\?\\|\\\\])/2A,"\\\\$1")+")(?![^<>]*>)(?![^&;]+;)","2A"),"<2z>$1")},1x:C,1s:3I};$.D.2W=3(g){5 h={};5 j=0;3 1a(s,a){4(!g.1C)s=s.O();5 i=s.3H(a);4(i==-1)6 B;6 i==0||g.1V};3 1h(q,a){4(j>g.1j){18()}4(!h[q]){j++}h[q]=a}3 1f(){4(!g.w)6 B;5 f={},2w=0;4(!g.11)g.1j=1;f[""]=[];16(5 i=0,30=g.w.7;i<30;i++){5 c=g.w[i];c=(Y c=="1w")?[c]:c;5 d=g.1q(c,i+1,g.w.7);4(d===B)1P;5 e=d.3G(0).O();4(!f[e])f[e]=[];5 b={H:d,w:c,M:g.1v&&g.1v(c)||d};f[e].1O(b);4(2w++0){5 c=h[k];$.K(c,3(i,x){4(1a(x.H,q)){a.1O(x)}})}}6 a}A 4(h[q]){6 h[q]}A 4(g.1a){16(5 i=q.7-1;i>=g.22;i--){5 c=h[q.3F(0,i)];4(c){5 a=[];$.K(c,3(i,x){4(1a(x.H,q)){a[a.7]=x}});6 a}}}6 14}}};$.D.2Q=3(e,g,f,k){5 h={G:"3E"};5 j,y=-1,w,1m="",1M=C,F,z;3 2r(){4(!1M)6;F=$("<3D/>").U().P(e.2H).T("3C","3B").1J(2p.2n);z=$("<3z/>").1J(F).3y(3(a){4(V(a).2m&&V(a).2m.3w()==\'2l\'){y=$("1F",z).1e(h.G).3u(V(a));$(V(a)).P(h.G)}}).2i(3(a){$(V(a)).P(h.G);f();g.1G();6 B}).3t(3(){k.1z=C}).3s(3(){k.1z=B});4(e.E>0)F.T("E",e.E);1M=B}3 V(a){5 b=a.V;3r(b&&b.3q!="2l")b=b.3p;4(!b)6[];6 b}3 S(b){j.17(y,y+1).1e(h.G);2h(b);5 a=j.17(y,y+1).P(h.G);4(e.1x){5 c=0;j.17(0,y).K(3(){c+=I.1i});4((c+a[0].1i-z.1c())>z[0].3o){z.1c(c+a[0].1i-z.3n())}A 4(c=j.1b()){y=0}}3 2g(a){6 e.Z&&e.Z").3m(e.1t(a,1m)).P(i%2==0?"3l":"3k").1J(z)[0];$.w(c,"2c",w[i])}j=z.3j("1F");4(e.1S){j.17(0,1).P(h.G);y=0}4($.31.2b)z.2b()}6{2T:3(d,q){2r();w=d;1m=q;2f()},2u:3(){S(1)},2y:3(){S(-1)},2t:3(){4(y!=0&&y-8<0){S(-y)}A{S(-8)}},2s:3(){4(y!=j.1b()-1&&y+8>j.1b()){S(j.1b()-1-y)}A{S(8)}},U:3(){F&&F.U();j&&j.1e(h.G);y=-1},L:3(){6 F&&F.3i(":L")},3h:3(){6 I.L()&&(j.2a("."+h.G)[0]||e.1S&&j[0])},1W:3(){5 a=$(g).3g();F.T({E:Y e.E=="1w"||e.E>0?e.E:$(g).E(),2E:a.2E+g.1i,1Q:a.1Q}).1W();4(e.1x){z.1c(0);z.T({29:e.1s,3e:\'3d\'});4($.1T.3b&&Y 2p.2n.3T.29==="3a"){5 c=0;j.K(3(){c+=I.1i});5 b=c>e.1s;z.T(\'3V\',b?e.1s:c);4(!b){j.E(z.E()-28(j.T("32-1Q"))-28(j.T("32-39")))}}}},26:3(){5 a=j&&j.2a("."+h.G).1e(h.G);6 a&&a.7&&$.w(a[0],"2c")},2J:3(){z&&z.2B()},1u:3(){F&&F.37()}}};$.D.1N=3(b,a,c){4(b.2O){5 d=b.2O();d.36(C);d.35("2P",a);d.4c("2P",c);d.4b()}A 4(b.2Y){b.2Y(a,c)}A{4(b.2X){b.2X=a;b.4a=c}}b.1G()}})(49);',62,261,'|||function|if|var|return|length|||||||||||||||||||||||||data||active|list|else|false|true|Autocompleter|width|element|ACTIVE|value|this|val|each|visible|result|break|toLowerCase|addClass|case|multipleSeparator|moveSelect|css|hide|target|onChange|bind|typeof|max||url|autocomplete||null|trigger|for|slice|flush|multiple|matchSubset|size|scrollTop|preventDefault|removeClass|populate|trimWords|add|offsetHeight|cacheLength|lastWord|hideResultsNow|term|arguments|extend|trim|formatMatch|parse|scrollHeight|highlight|unbind|formatResult|string|scroll|search|mouseDownOnSelect|autoFill|stopLoading|matchCase|delay|new|li|focus|setTimeout|clearTimeout|appendTo|formatItem|defaults|needsInit|Selection|push|continue|left|request|selectFirst|browser|selectCurrent|matchContains|show|unautocomplete|setOptions|split|flushCache|loadingClass|minChars|findValueCallback|inputClass||selected||parseInt|maxHeight|filter|bgiframe|ac_data|COMMA|BACKSPACE|fillList|limitNumberOfItems|movePosition|click|PAGEUP|hideResults|LI|nodeName|body|PAGEDOWN|document|ESC|init|pageDown|pageUp|next|RETURN|nullData|TAB|prev|strong|gi|empty|replace|DEL|top|keyCode|in|resultsClass|DOWN|emptyList|form|opera|dataType|UP|createTextRange|character|Select|extraParams|load|display|mustMatch|receiveData|Cache|selectionStart|setSelectionRange|join|ol|fn|padding|||moveStart|collapse|remove||right|undefined|msie|off|auto|overflow|attr|offset|current|is|find|ac_odd|ac_even|html|innerHeight|clientHeight|parentNode|tagName|while|mouseup|mousedown|index|blur|toUpperCase|188|mouseover|ul|default|absolute|position|div|ac_over|substr|charAt|indexOf|180|RegExp|100|switch|400|keydown|ac_loading|ac_results|keypress|ac_input|submit|style|150|height|success|limit|name|port||abort|mode|ajax|Date|timestamp||200|substring|jQuery|selectionEnd|select|moveEnd'.split('|'),0,{})) \ No newline at end of file diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js new file mode 100644 index 00000000..fe8c976a --- /dev/null +++ b/modules/server_add/js/server_add.js @@ -0,0 +1,131 @@ +$("#gServerAdd").ready(function() { + $("#gServerAdd :submit").click(function(event) { + do_add(this, event); + }); + $("#gProgressBar").progressbar(); + $("#gServerAdd ul").css("display", "block"); +}); + +function open_close_branch(icon, event) { + var parent = icon.parentNode; + var children = $(parent).find(".gCheckboxTree"); + var closed = $(icon).hasClass("ui-icon-plus"); + + if (closed) { + if (children.length == 0) { + load_children(icon, function(data, textStatus) { + $(parent).append(data); + $(icon).addClass("ui-icon-minus"); + $(icon).removeClass("ui-icon-plus"); + var checkbox = $(parent).find(":checkbox")[0]; + checkbox_click(checkbox, null); + }); + } else { + $(icon).addClass("ui-icon-minus"); + $(icon).removeClass("ui-icon-plus"); + } + $(parent).children("ul").slideDown("fast"); + } else { + $(icon).addClass("ui-icon-plus"); + $(icon).removeClass("ui-icon-minus"); + $(parent).children("ul").slideUp("fast"); + } +} + +function checkbox_click(checkbox, event) { + var parents = $(checkbox).parents("li"); + var parent = parents.get(0); + $(parent).find(".gCheckboxTree :checkbox").attr("checked", checkbox.checked); + var checked = $("#gServerAdd :checkbox[checked]"); + $("#gServerAdd form :submit").attr("disabled", checked.length == 0); +} + +function load_children(icon, callback) { + var csrf = $("#gServerAdd form :hidden[name='csrf']")[0].value; + var base_url = $("#gServerAdd form :hidden[name='base_url']")[0].value; + var parms = "&csrf=" + csrf; + var parents = $(icon).parents("li"); + for (var i=parents.length - 1; i >= 0; i--) { + parms += "&path[]=" + $(parents[i]).children("span").attr("ref"); + } + $.ajax({async: false, + success: callback, + data: parms, + dataType: "html", + type: "POST", + url: base_url + "server_add/children" + }); +} + +var current = 0; +var process_length = 0; +function do_add(submit, event) { + event.preventDefault(); + $("#gProgressBar").progressbar("value", 0); + $("#gProgressBar").css("visibility", "visible"); + var check_list = $("#gServerAdd :checkbox[checked]"); + process_length = check_list.length; + current = 0; + var base_url = $("#gServerAdd form :hidden[name='base_url']")[0].value; + $.ajax({async: false, + dataType: "json", + type: "POST", + url: base_url + "server_add/start" + }); + $.each(check_list, function () { + process_checkbox(this); + }); + $.ajax({async: false, + success: function(data, textStatus) { + document.location.reload(); + }, + dataType: "json", + type: "POST", + url: base_url + "server_add/finish" + }); + return false; +} + +function process_checkbox(checkbox) { + var parents = $(checkbox).parents("li"); + var csrf = $("#gServerAdd form :hidden[name='csrf']")[0].value; + var parms = "&csrf=" + csrf; + for (var i=parents.length - 1; i > 0; i--) { + parms += "&path[]=" + $(parents[i]).children("span").attr("ref"); + } + parms += "&path[]=" + $(checkbox).val(); + + var parent = parents[0]; + if ($(parent).hasClass("gFile")) { + process_file(parents[0], parms); + } else if ($(parent).hasClass("gDirectory") && $(parents[0]).find(".gCheckboxTree").length == 0) { + // If it is a directory and retrieve the children and process them + var icon = $(parent).children("span")[0]; + load_children(icon, function(data, textStatus) { + $(parent).append(data); + $(icon).addClass("ui-icon-plus"); + checkbox_click(checkbox, null); + var boxes = $(parent).find(".gCheckboxTree :checkbox[checked]"); + process_length += boxes.length; + $.each(boxes, function () { + process_checkbox(this); + }); + }); + current++; + $("#gProgressBar").progressbar("value", current / process_length * 100); + } +} + +function process_file(li_element, parms) { + $.ajax({async: false, + success: function(data, status) { + }, + data: parms, + dataType: "html", + type: "POST", + url: $("#gServerAdd form").attr("action") + }); + current++; + $("#gProgressBar").progressbar("value", current / process_length * 100); +} + diff --git a/modules/server_add/module.info b/modules/server_add/module.info new file mode 100644 index 00000000..3b0dce31 --- /dev/null +++ b/modules/server_add/module.info @@ -0,0 +1,3 @@ +name = Add from Server +description = Allows authorized users to load images from the local server +version = 1 diff --git a/modules/server_add/views/server_add_admin.html.php b/modules/server_add/views/server_add_admin.html.php new file mode 100644 index 00000000..765feeb9 --- /dev/null +++ b/modules/server_add/views/server_add_admin.html.php @@ -0,0 +1,10 @@ + +
+

+ +

+
+ +
+ +
diff --git a/modules/server_add/views/server_add_dir_list.html.php b/modules/server_add/views/server_add_dir_list.html.php new file mode 100644 index 00000000..762b1a4d --- /dev/null +++ b/modules/server_add/views/server_add_dir_list.html.php @@ -0,0 +1,13 @@ + + +
    + $path): ?> +
  • + + +
  • + +
+
style="display:none"> + +
diff --git a/modules/server_add/views/server_add_tree.html.php b/modules/server_add/views/server_add_tree.html.php new file mode 100644 index 00000000..b664c679 --- /dev/null +++ b/modules/server_add/views/server_add_tree.html.php @@ -0,0 +1,22 @@ + + +
    + $file_info): ?> +
  • "> + + + + +
  • + +
diff --git a/modules/server_add/views/server_add_tree_dialog.html.php b/modules/server_add/views/server_add_tree_dialog.html.php new file mode 100644 index 00000000..26286e05 --- /dev/null +++ b/modules/server_add/views/server_add_tree_dialog.html.php @@ -0,0 +1,26 @@ + +" /> + + +
+

+ +

+
    + +
  • title ?>
  • + +
  • +
+ + "post"), $hidden) ?> +
+ +
+ + "gServerAddButton", "name" => "add", "disabled" => true, "class" => "submit"), t("Add")) ?> + + +
+
-- cgit v1.2.3