101 $this->leafStyle =
"tree_node_leaf";
102 $this->onDemand =
"";
103 $this->disabled =
false;
116 $c = count($this->children);
120 $title =
"<a href='{$this->link}' target='{$this->target}'>{$this->title}</a>{$this->extras}";
124 $title =
"<a href='#' onclick='";
128 $title .=
"{$_activeTree->onSelect}(\"{$this->value}\");";
132 $title .=
"new DOMEvent(event).stop(); Tree.toggleCheckbox(this, \"{$_activeTree->id}\", \"{$_activeTree->selectMode}\")";
134 $title .=
"; return false'";
138 $title .=
" oncontextmenu='Tree.selectCheckbox(this, \"{$_activeTree->id}\", \"{$_activeTree->selectOnRightClickMode}\");'";
141 $title .=
">{$this->title}</a>{$this->extras}";
144 if ($c == 0 && !$this->onDemand)
147 echo
"<div id='{$this->id}' class='{$this->leafStyle}'>";
149 if (isset($this->value) && $this->value !==
"" &&
$_activeTree->selectMode !=
'navigation')
152 <input type=
"checkbox" class=
"checkbox" name=
"<? echo $this->id?>" value=
"<? echo $this->value?>"<?
153 if ($this->checked) echo
" checked";
154 if ($this->disabled) echo
" disabled";
157 echo
" onclick=\"Tree.clearCheckBoxes('{$_activeTree->id}', this);";
160 echo
" {$_activeTree->onSelect}('{$this->value}');";
166 echo
" onclick=\"{$_activeTree->onSelect}('{$this->value}');\"";
189 $cmd =
"Tree.loadOnDemand('{$this->id}', '{$this->onDemand}');";
194 <script type=
"text/javascript">
195 window.addEvent(
'domready',
function() {Tree.loadOnDemand(
'<?echo $this->id?>',
'<?echo $this->onDemand?>');});
205 $cmd .=
"Tree.toggleFolder('{$this->id}', '{$this->openStyle}', '{$this->closedStyle}');";
207 <div
id=
'<?echo $this->id?>' class=
'<?echo $style?>' onclick=
"<?echo $cmd ?>">
209 if (isset($this->value) && $this->value !==
"" &&
$_activeTree->selectMode !=
'navigation')
212 <input type=
"checkbox" class=
"checkbox" name=
"<? echo $this->id?>" value=
"<? echo $this->value?>" <?
213 if ($this->checked) echo
" checked";
214 if ($this->disabled) echo
" disabled";
217 echo
" onclick=\"Tree.clearCheckBoxes('{$_activeTree->id}', this);";
220 echo
" {$_activeTree->onSelect}('{$this->value}');";
226 echo
" onclick=\"{$_activeTree->onSelect}('{$this->value}');\"";
233 <div
id=
'<?echo $this->id?>_contents' style=
'padding-left: <?echo $_activeTree->indent ?>; display: <? echo $display?>'>
236 for($i = 0; $i < $c; ++$i)
238 $this->children[$i]->writeHTML();
255 for($i = 0; $i < count($n); ++$i)
257 $this->children[] = $n[$i];
262 $this->children[] = $n;
273 if ($this->open)
return true;
280 $c = count($this->children);
282 for($i = 0; $i < $c; ++$i)
299 $this->checked =
false;
301 else if ($this->value ==
$value)
303 $this->checked =
true;
306 $c = count($this->children);
308 for($i = 0; $i < $c; ++$i)
310 $this->children[$i]->selectByValue(
$value);
375 $width = is_numeric($this->width) ?
"{$this->width}px" :
$this->width;
378 if ($this->selectMode ==
"single")
381 <input type=
'hidden' name=
'<?echo $this->id ?>' id=
'<?echo $this->id?>' value=
'<?echo $this->value ?>'/>
384 ?><table
id=
"<?echo $this->id?>_table" class=
"<? echo $this->style?>" cellpadding=
"0" cellspacing=
"0" <?
if ($this->width) echo
"style='width:{$width}'"; ?>>
390 <th><? echo $this->title?></th>
399 <div style=
"padding: 0; margin: 0; width: <? echo $w?>;<? if ($this->height > 0) { ?> height: <?echo $this->height?>px;<? } ?><?if ($this->scroll) echo "overflow:
auto"?>">
414 $c = count($this->children);
416 for($i = 0; $i < $c; ++$i)
418 $this->children[$i]->selectByValue(
$value);
424 $c = count($this->children);
426 for($i = 0; $i < $c; ++$i)
428 $this->children[$i]->calculateOpenState();
429 $this->children[$i]->writeHTML();
442 for($i = 0; $i < count($n); ++$i)
444 $this->children[] = $n[$i];
449 $this->children[] = $n;
The TreeControl provides a class that can be used to generate dynamic tree controls for use in PHP fo...
add($n)
Adds a child TreeNode (or an array of children)
writeHTML()
Outputs the TreeControl as HTML to the current output buffer.
TreeControl($id, $title="", $style="tree", $scroll=true, $width=500, $height=400)
Create a new TreeControl.
TreeNode represents a node in the tree.
add($n)
Add a child TreeNode (or an array of children)
$extras
Extra data/controls to be shown with this tree node.
writeHTML()
Write the node out as HTML to the output buffer.
TreeNode($id, $title, $value="", $checked=false, $closedStyle="tree_node_closed", $openStyle="tree_node_open", $link=null, $target="")
Create a new TreeNode.
calculateOpenState()
Recursively determine whether the branch of the tree of which this node is the root should be display...
$_writtenTreeControlScript
This file provides a class-based API for generating expanding tree controls.
$_activeTree
Global reference to currently drawing tree instance.