From fd27d17d241ee90ba85644f3a70b7c62915d8e0a Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 15 Sep 2012 22:49:38 +0200 Subject: [PATCH] added expand/collapse feature to webui folders --- webui/config.php | 3 ++ webui/controller/search/folder.php | 2 + webui/model/folder/folder.php | 38 +++++++++++++++ webui/view/javascript/piler.js | 38 +++++++++++++-- webui/view/theme/default/images/1x1.gif | Bin 0 -> 44 bytes webui/view/theme/default/images/minus.gif | Bin 0 -> 73 bytes webui/view/theme/default/images/plus.gif | Bin 0 -> 76 bytes .../theme/default/templates/search/folder.tpl | 45 +++++++++++++++--- 8 files changed, 114 insertions(+), 12 deletions(-) create mode 100644 webui/view/theme/default/images/1x1.gif create mode 100644 webui/view/theme/default/images/minus.gif create mode 100644 webui/view/theme/default/images/plus.gif diff --git a/webui/config.php b/webui/config.php index 6a459fda..1f635a16 100644 --- a/webui/config.php +++ b/webui/config.php @@ -25,6 +25,9 @@ define('ICON_GREEN_OK', '/view/theme/default/images/green_ok.png'); define('ICON_RED_X', '/view/theme/default/images/red_x.png'); define('ICON_DOWNLOAD', '/view/theme/default/images/download_icon.jpg'); define('ICON_NOTES', '/view/theme/default/images/notes.png'); +define('ICON_PLUS', '/view/theme/default/images/plus.gif'); +define('ICON_MINUS', '/view/theme/default/images/minus.gif'); +define('ICON_EMPTY', '/view/theme/default/images/1x1.gif'); define('MAX_CGI_FROM_SUBJ_LEN', 45); define('PAGE_LEN', 20); diff --git a/webui/controller/search/folder.php b/webui/controller/search/folder.php index 3caef4ad..4ec4190e 100644 --- a/webui/controller/search/folder.php +++ b/webui/controller/search/folder.php @@ -16,6 +16,8 @@ class ControllerSearchFolder extends Controller { $this->data['folders'] = $this->model_folder_folder->get_folders_for_user(); $this->data['extra_folders'] = $this->model_folder_folder->get_extra_folders_for_user(); + $this->data['folders_by_hier'] = $this->model_folder_folder->get_all_folder_ids_hier($_SESSION['uid']); + $this->render(); } diff --git a/webui/model/folder/folder.php b/webui/model/folder/folder.php index c60ceb4a..4e49a00a 100644 --- a/webui/model/folder/folder.php +++ b/webui/model/folder/folder.php @@ -95,6 +95,24 @@ class ModelFolderFolder extends Model { } + public function get_all_folder_ids_hier($uid = 0) { + $arr = array(); + $a = array(); + + $query = $this->db->query("SELECT " . TABLE_FOLDER_USER . ".id AS id, " . TABLE_FOLDER . ".name AS name FROM " . TABLE_FOLDER_USER . ", " . TABLE_FOLDER . " WHERE uid=? AND " . TABLE_FOLDER_USER . ".id=" . TABLE_FOLDER . ".id", array($uid)); + + if(isset($query->rows)) { + foreach ($query->rows as $q) { + $a = array('id' => $q['id'], 'name' => $q['name'], 'children' => array()); + $a['children'] = $this->get_sub_folders_hier($q['id']); + array_push($arr, $a); + } + } + + return $arr; + } + + public function get_all_extra_folder_ids($uid = 0) { $arr = array(); @@ -122,6 +140,26 @@ class ModelFolderFolder extends Model { } + + private function get_sub_folders_hier($id = 0) { + $arr = array(); + + $query = $this->db->query("SELECT id, name FROM `" . TABLE_FOLDER . "` WHERE parent_id=?", array($id)); + + if($query->num_rows > 0) { + + foreach ($query->rows as $q) { + $a = array('id'=> $q['id'], 'name'=>$q['name'], 'children'=>array()); + $a['children'] = $this->get_sub_folders_hier($q['id']); + array_push($arr, $a); + } + + } + + return $arr; + } + + public function get_folders_by_string($s = '') { if(strlen($s) < 2) { return array(); } diff --git a/webui/view/javascript/piler.js b/webui/view/javascript/piler.js index 0c5639f1..4972736e 100644 --- a/webui/view/javascript/piler.js +++ b/webui/view/javascript/piler.js @@ -268,10 +268,10 @@ function assemble_search_term(n, prefix) { e = document.getElementById(prefix + 'order'); if(e && e.value) { data = data + "&order=" + e.value; } - var a = document.getElementById('folders'); - if(a) { - for(i=0; iSw0 literal 0 HcmV?d00001 diff --git a/webui/view/theme/default/templates/search/folder.tpl b/webui/view/theme/default/templates/search/folder.tpl index f83ba82c..b505a4f6 100644 --- a/webui/view/theme/default/templates/search/folder.tpl +++ b/webui/view/theme/default/templates/search/folder.tpl @@ -2,16 +2,47 @@
- -
- - -
+
+ +
+ + +
+ + + 0) { ?> + + + +
+ + + +
+ + + + +
- -