61 $icon_image = $this->_tree->getIcon($this->title);
62 $class = ($this->value == $this->_tree->selectedValue) ?
"selected" :
"file";
64 <div><img src=
"<?echo $this->_tree->images['toggle_blank']?>" align=
"absmiddle"><img src=
"<?echo $icon_image?>" align=
"absmiddle"><a
id=
"<?echo $this->id?>_link" class=
"<?echo $class?>" href=
"javascript:DirectoryTree.selectItem('<?echo $this->_tree->id?>', '<?echo $this->id?>', '<?echo jsSafe($this->value)?>')" ondblclick=
"<?echo $this->_tree->id?>_onDoubleClick()"><?echo $this->title?></a></div>
90 $this->leafStyle = $leafStyle;
96 ksort($this->children);
98 $c = count($this->children);
102 echo
"<div class=\"{$this->leafStyle}\"><img src=\"{$this->_tree->images['toggle_blank']}\" align=\"absmiddle\"><img src=\"{$this->_tree->images['folder_closed']}\" align=\"absbottom\">";
106 if ($this->_tree->selectMode ==
"folder" || $this->_tree->selectMode =
"both")
108 if ($this->_tree->multiSelect)
111 <input type=
"checkbox" class=
"checkbox" name=
"<? echo $this->id?>" value=
"<? echo $this->value?>"<?
if ($this->checked) echo
" checked";?>> <?echo $this->title?>
116 $class = ($this->value == $this->_tree->selectedValue) ?
"selected" :
"folder";
118 <a
id=
"<?echo $this->id?>_link" class=
"<? echo $class?>" href=
"javascript:DirectoryTree.selectItem('<?echo $this->_tree->id?>', '<?echo $this->id?>', '<?echo jsSafe($this->value)?>')"><?echo $this->title?></a>
125 <a
id=
"<?echo $this->id?>_link" class=
"folder" href=
"" onclick=
"return false;"><?echo $this->title?></a>
137 $toggle = $this->_tree->images[
'toggle_open'];
138 $folder = $this->_tree->images[
'folder_open'];
143 $toggle = $this->_tree->images[
'toggle_closed'];
144 $folder = $this->_tree->images[
'folder_closed'];
148 <div
id=
'<?echo $this->id?>'><img
id=
"<?echo $this->id?>_toggle" src=
"<?echo $toggle?>" align=
"absmiddle" onclick=
"DirectoryTree.toggleDirectoryFolder('<?echo $this->id?>')"><img
id=
"<?echo $this->id?>_folder" align=
"absmiddle" src=
"<?echo $folder?>" onclick=
"DirectoryTree.toggleDirectoryFolder('<?echo $this->id?>')">
152 if ($this->_tree->selectMode ==
"folder" || $this->_tree->selectMode ==
"both")
154 if ($this->_tree->multiSelect)
157 <input type=
"checkbox" class=
"checkbox" name=
"<? echo $this->id?>" value=
"<? echo $this->value?>"<?
if ($this->checked) echo
" checked";?>> <?echo $this->title?>
162 $class = ($this->value == $this->_tree->selectedValue) ?
"selected" :
"folder";
164 <a
id=
"<?echo $this->id?>_link" class=
"folder" href=
"javascript:DirectoryTree.selectItem('<?echo $this->_tree->id?>', '<?echo $this->id?>', '<?echo jsSafe($this->value)?>')"><?echo $this->title?></a>
171 <a
id=
"<?echo $this->id?>_link" class=
"folder" href=
"javascript:DirectoryTree.toggleDirectoryFolder('<?echo $this->id?>')"><?echo $this->title?></a>
176 <div
id=
'<?echo $this->id?>_contents' style=
'padding-left: 16px; display: <? echo $display?>'>
179 foreach($this->children as $key => $child)
181 $child->_tree =& $this->_tree;
194 trace($this->
id.
" adding ".$n->id, 3);
197 for($i = 0; $i < count($n); ++$i)
199 $this->children[$n[$i]->title] = $n[$i];
204 $this->children[$n->title] = $n;
210 if ($this->open)
return true;
217 $c = count($this->children);
219 foreach($this->children as $key => $child)
221 if ($child->calculateOpenState())
248 var
$images = array(
"toggle_open" =>
"/fakoli/images/toggle_open.png",
249 "toggle_closed" =>
"/fakoli/images/toggle_closed.png",
250 "toggle_blank" =>
"/fakoli/images/toggle_blank.png",
251 "folder_open" =>
"/fakoli/images/folder_open.png",
252 "folder_closed" =>
"/fakoli/images/folder_closed.png",
253 "generic_file" =>
"/fakoli/images/file.png");
255 var
$icons = array(
".doc" =>
"/fakoli/images/msword_icon.png",
256 ".docx" =>
"/fakoli/images/msword_icon.png",
257 ".xls" =>
"/fakoli/images/msexcel_icon.png",
258 ".xlsx" =>
"/fakoli/images/msexcel_icon.png",
259 ".pdf" =>
"/fakoli/images/pdf_icon.png",
260 ".ppt" =>
"/fakoli/images/ppt_icon.png",
261 ".pptx" =>
"/fakoli/images/ppt_icon.png",
262 ".gif" =>
"/fakoli/images/image_icon.png",
263 ".png" =>
"/fakoli/images/image_icon.png",
264 ".jpg" =>
"/fakoli/images/image_icon.png",
265 "default" =>
"/fakoli/images/file_icon.png");
282 trace(
"Building Folder Tree: $folder, $base", 3);
284 $this->children[$folder] = $root;
289 $f = $base . DIRECTORY_SEPARATOR . $folder;
290 trace(
"Directory tree: buildFolderTreeAux f $f", 3);
293 $id = $this->
id.
"_".str_replace(DIRECTORY_SEPARATOR,
"_", $folder);
294 if ($this->permissionCallback && !call_user_func($this->permissionCallback, $folder))
return null;
297 while( $directory = readdir($dir))
299 if ($directory ==
"." || $directory ==
"..")
continue;
301 if (is_dir($base . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $directory))
308 $this->folders[$folder] = $node;
315 $f = $base . DIRECTORY_SEPARATOR . $folder;
318 $id = str_replace(DIRECTORY_SEPARATOR,
"_", $folder);
319 if ($this->permissionCallback && !call_user_func($this->permissionCallback, $folder))
return null;
321 while( $file = readdir($dir))
323 if ($file ==
"." || $file ==
"..")
continue;
325 $f = $base . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $file;
328 $this->
addFiles($folder . DIRECTORY_SEPARATOR . $file, $base, $filter);
330 else if (is_file($f))
332 if ($filter && !call_user_func($filter, $f))
339 $node =
new FileNode(
$id .
"_" . str_replace(
".",
"_", $file), $file, $folder . DIRECTORY_SEPARATOR . $file);
349 <script type=
"text/javascript">
350 function <?echo $this->
id?>_onSelectItem(itemID, itemValue)
353 if ($this->onSelectionChanged)
356 <?echo $this->onSelectionChanged?>(itemID, itemValue);
362 function <?echo $this->
id?>_onClearSelection()
365 if ($this->onSelectionChanged)
368 <? echo $this->onSelectionChanged?>(
null,
null);
374 function <?echo $this->
id?>_onDoubleClick(itemID, itemValue)
377 if ($this->onDoubleClick)
380 <? echo $this->onDoubleClick?>(itemID, itemValue);
397 <input type=
"hidden" name=
"<?echo $this->id?>_value" id=
"<?echo $this->id?>_value" value=
"<?echo $this->selectedValue?>"/>
398 <input type=
"hidden" name=
"<?echo $this->id?>_node" id=
"<?echo $this->id?>_node" value=
""/>
399 <table
id=
"<?echo $this->id?>" class=
"<? echo $this->style?>" style=
"width: <? echo $width?>;height: <?echo $height?>" cellpadding=
"0" cellspacing=
"0">
405 <th><? echo $this->title?></th>
412 <div style=
"margin: 0; padding: 0;width: 100%;height: <?echo $height?>;<?if ($this->scroll) echo "overflow:
auto"?>">
414 $c = count($this->children);
415 foreach($this->children as $key => $child)
417 trace(
"Writing $key,{$child->title}", 3);
420 $child->_tree =& $this;
421 $child->calculateOpenState();
440 $ext = substr($file, strrpos($file,
"."));
441 $icon = $this->icons[$ext];
442 trace(
"getIcon($file) $ext $icon", 4);
446 $icon = $this->icons[
"default"];
454 trace($this->
id.
" adding ".$n->id, 3);
457 for($i = 0; $i < count($n); ++$i)
459 $this->children[$n[$i]->title] = &$n[$i];
464 $this->children[$n->title] =& $n;
470 return $this->folders[$path];
475 trace(
"DirectoryTree:findNode($path)", 4);
476 $elts = explode(DIRECTORY_SEPARATOR, $path);
480 foreach($elts as $elt)
484 if (isset($node->children[$elt]))
486 $node =& $node->children[$elt];
491 if ($node === $this) $node =
null;
493 trace(
"Found Node: {$node->id}", 3);
DirectoryTreeControl($id, $title="", $showFiles=true, $style="tree", $scroll=true, $width=500, $height=400)
_buildFolderTreeAux($folder, $base)
FolderNode($id, $title, $value="", $checked=false, $closedStyle="tree_node_closed", $openStyle="tree_node_open", $leafStyle="tree_node_plain")
addFiles($folder, $base, $filter=null)
buildFolderTree($folder, $base)
FileNode($id, $title, $value)
$_writtenDirectoryTreeControlScript
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.