mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 20:00:12 +01:00
added expand/collapse feature to webui folders
This commit is contained in:
parent
b03ca2effb
commit
fd27d17d24
@ -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_RED_X', '/view/theme/default/images/red_x.png');
|
||||||
define('ICON_DOWNLOAD', '/view/theme/default/images/download_icon.jpg');
|
define('ICON_DOWNLOAD', '/view/theme/default/images/download_icon.jpg');
|
||||||
define('ICON_NOTES', '/view/theme/default/images/notes.png');
|
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('MAX_CGI_FROM_SUBJ_LEN', 45);
|
||||||
define('PAGE_LEN', 20);
|
define('PAGE_LEN', 20);
|
||||||
|
@ -16,6 +16,8 @@ class ControllerSearchFolder extends Controller {
|
|||||||
$this->data['folders'] = $this->model_folder_folder->get_folders_for_user();
|
$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['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();
|
$this->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
public function get_all_extra_folder_ids($uid = 0) {
|
||||||
$arr = array();
|
$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 = '') {
|
public function get_folders_by_string($s = '') {
|
||||||
if(strlen($s) < 2) { return array(); }
|
if(strlen($s) < 2) { return array(); }
|
||||||
|
|
||||||
|
@ -268,10 +268,10 @@ function assemble_search_term(n, prefix) {
|
|||||||
e = document.getElementById(prefix + 'order');
|
e = document.getElementById(prefix + 'order');
|
||||||
if(e && e.value) { data = data + "&order=" + e.value; }
|
if(e && e.value) { data = data + "&order=" + e.value; }
|
||||||
|
|
||||||
var a = document.getElementById('folders');
|
var childNodeArray = document.getElementById('folders').getElementsByTagName('*');
|
||||||
if(a) {
|
if(childNodeArray) {
|
||||||
for(i=0; i<a.childNodes.length; i++) {
|
for(i=0; i<childNodeArray.length; i++) {
|
||||||
b = a.childNodes[i];
|
b = childNodeArray[i];
|
||||||
if(b.name && b.name.substring(0, 7) == 'folder_' && b.checked) {
|
if(b.name && b.name.substring(0, 7) == 'folder_' && b.checked) {
|
||||||
folders = folders + "+" + b.name.substring(7);
|
folders = folders + "+" + b.name.substring(7);
|
||||||
}
|
}
|
||||||
@ -697,7 +697,6 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -776,3 +775,32 @@ function copy_message_to_folder(folder_id, id, copied) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function open_folder(id) {
|
||||||
|
var a;
|
||||||
|
|
||||||
|
a = document.getElementById('fldr_' + id);
|
||||||
|
a.style.display = '';
|
||||||
|
|
||||||
|
a = document.getElementById('fldr_collapse_' + id);
|
||||||
|
a.style.display = '';
|
||||||
|
|
||||||
|
a = document.getElementById('fldr_open_' + id);
|
||||||
|
a.style.display = 'none';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function close_folder(id) {
|
||||||
|
var a;
|
||||||
|
|
||||||
|
a = document.getElementById('fldr_' + id);
|
||||||
|
a.style.display = 'none';
|
||||||
|
|
||||||
|
a = document.getElementById('fldr_collapse_' + id);
|
||||||
|
a.style.display = 'none';
|
||||||
|
|
||||||
|
a = document.getElementById('fldr_open_' + id);
|
||||||
|
a.style.display = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BIN
webui/view/theme/default/images/1x1.gif
Normal file
BIN
webui/view/theme/default/images/1x1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 B |
BIN
webui/view/theme/default/images/minus.gif
Normal file
BIN
webui/view/theme/default/images/minus.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 B |
BIN
webui/view/theme/default/images/plus.gif
Normal file
BIN
webui/view/theme/default/images/plus.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 76 B |
@ -2,16 +2,47 @@
|
|||||||
|
|
||||||
<div id="folders" style="text-align:left;">
|
<div id="folders" style="text-align:left;">
|
||||||
|
|
||||||
<?php foreach ($folders as $folder) { ?>
|
|
||||||
<input type="checkbox" id="folder_<?php print $folder['id']; ?>" name="folder_<?php print $folder['id']; ?>" /> <?php print $folder['name']; ?><br />
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?php foreach ($extra_folders as $folder) { ?>
|
<?php foreach ($extra_folders as $folder) { ?>
|
||||||
<input type="checkbox" id="extra_folder_<?php print $folder['id']; ?>" name="extra_folder_<?php print $folder['id']; ?>" /> <span style="color: blue; font-weight: bold;" onmouseover="javascript: copy_message_to_folder('<?php print $folder['id']; ?>', current_message_id, '<?php print $text_copied; ?>'); return false;"><?php print $folder['name']; ?></span><br />
|
<blockquote style="border: 0px solid red; margin: 0 0 5px 10px;">
|
||||||
|
<img src="<?php print ICON_EMPTY; ?>" width="12" height="12" alt="" /> <input type="checkbox" id="extra_folder_<?php print $folder['id']; ?>" name="extra_folder_<?php print $folder['id']; ?>" /> <span style="color: blue; font-weight: bold;" onmouseover="javascript: copy_message_to_folder('<?php print $folder['id']; ?>', current_message_id); return false;"><?php print $folder['name']; ?>
|
||||||
|
</blockquote>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function display_folders($arr = array(), &$i) {
|
||||||
|
|
||||||
|
?>
|
||||||
|
<blockquote id="fldr_<?php print $i; ?>" style="border: 0px solid red; margin: 0 0 5px 10px;">
|
||||||
|
<?php
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
foreach($arr as $a) {
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php if(count($a['children']) > 0) { ?>
|
||||||
|
<a id="fldr_collapse_<?php print $i; ?>" href="#" onclick="javascript:close_folder(<?php print $i; ?>); return false;"><img src="<?php print ICON_MINUS; ?>" alt="" /></a>
|
||||||
|
<a id="fldr_open_<?php print $i; ?>" href="#" onclick="javascript: open_folder(<?php print $i; ?>); return false;" style="display:none;"><img src="<?php print ICON_PLUS; ?>" alt="" /></a>
|
||||||
|
<?php } else { ?> <img src="<?php print ICON_EMPTY; ?>" width="12" height="12" alt="" /> <?php } ?>
|
||||||
|
<input type="checkbox" id="folder_<?php print $a['id']; ?>" name="folder_<?php print $a['id']; ?>" /> <?php print $a['name']; ?><br />
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if(count($a['children'])) { display_folders($a['children'], $i); }
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</blockquote>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$i = 0;
|
||||||
|
display_folders($folders_by_hier, $i);
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user