Framework  3.9
TreeControl Class Reference

The TreeControl provides a class that can be used to generate dynamic tree controls for use in PHP forms (or pages). More...

Public Member Functions

 TreeControl ($id, $title="", $style="tree", $scroll=true, $width=500, $height=400)
 Create a new TreeControl. More...
 
 writeScript ()
 
 writeHTML ()
 Outputs the TreeControl as HTML to the current output buffer. More...
 
 setValue ($value)
 
 writeNodes ()
 
 add ($n)
 Adds a child TreeNode (or an array of children) More...
 

Public Attributes

 $id
 
 $title
 
 $style
 
 $scroll
 
 $width
 
 $height
 
 $selectMode = "multi"
 
 $value
 
 $indent = "16px"
 
 $children
 
 $selectOnRightClick = false
 
 $selectOnRightClickMode = "context"
 

Detailed Description

The TreeControl provides a class that can be used to generate dynamic tree controls for use in PHP forms (or pages).

Definition at line 321 of file tree.inc.

Member Function Documentation

◆ add()

TreeControl::add (   $n)

Adds a child TreeNode (or an array of children)

Parameters
mixed$nthe child or children to add

Definition at line 438 of file tree.inc.

439  {
440  if (is_array($n))
441  {
442  for($i = 0; $i < count($n); ++$i)
443  {
444  $this->children[] = $n[$i];
445  }
446  }
447  else
448  {
449  $this->children[] = $n;
450  }
451  }

◆ setValue()

TreeControl::setValue (   $value)

Definition at line 411 of file tree.inc.

412  {
413  $this->value = $value;
414  $c = count($this->children);
415 
416  for($i = 0; $i < $c; ++$i)
417  {
418  $this->children[$i]->selectByValue($value);
419  }
420  }

◆ TreeControl()

TreeControl::TreeControl (   $id,
  $title = "",
  $style = "tree",
  $scroll = true,
  $width = 500,
  $height = 400 
)

Create a new TreeControl.

Parameters
string$idthe ID for the control
string$titlethe title text for the control
string$stylethe base CSS class for the tree
boolean$scrollflag indicating whether the control should display scrollbars when the contents overflow a fixed width or height.
integer$widthwidth of the control in pixels
integer$heightheight of the control in pixels

Definition at line 347 of file tree.inc.

348  {
349  $this->id = $id;
350  $this->title = $title;
351  $this->style = $style;
352  $this->scroll = $scroll;
353  $this->width = $width;
354  $this->height = $height;
355  }

◆ writeHTML()

TreeControl::writeHTML ( )

Outputs the TreeControl as HTML to the current output buffer.

Definition at line 368 of file tree.inc.

369  {
370  global $_activeTree;
371 
372  $_activeTree= $this;
373 
374  $this->writeScript();
375  $width = is_numeric($this->width) ? "{$this->width}px" : $this->width;
376  $height = is_numeric($this->height) ? "{$this->height}px" : $this->height;
377 
378  if ($this->selectMode == "single")
379  {
380 ?>
381 <input type='hidden' name='<?echo $this->id ?>' id='<?echo $this->id?>' value='<?echo $this->value ?>'/>
382 <?
383  }
384 ?><table id="<?echo $this->id?>_table" class="<? echo $this->style?>" cellpadding="0" cellspacing="0" <? if ($this->width) echo "style='width:{$width}'"; ?>>
385  <?
386  if ($this->title)
387  {
388  ?>
389  <tr>
390  <th><? echo $this->title?></th>
391  </tr>
392  <?
393  }
394 
395  $w = $width ? $width : "100%";
396  ?>
397  <tr>
398  <td>
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"?>">
400 <?
401  $this->writeNodes();
402 ?>
403  </div>
404  </td>
405  </tr>
406  </table>
407 <?
408  $_activeTree = null;
409  }
writeScript()
Definition: tree.inc:361
writeNodes()
Definition: tree.inc:422
$_activeTree
Global reference to currently drawing tree instance.
Definition: tree.inc:53

◆ writeNodes()

TreeControl::writeNodes ( )

Definition at line 422 of file tree.inc.

423  {
424  $c = count($this->children);
425 
426  for($i = 0; $i < $c; ++$i)
427  {
428  $this->children[$i]->calculateOpenState();
429  $this->children[$i]->writeHTML();
430  }
431  }

◆ writeScript()

TreeControl::writeScript ( )
Deprecated:
include the /fakoli/js/tree.js support file instead.

Writes the JavaScript support functions for the tree.

Definition at line 361 of file tree.inc.

362  {
363  }

Member Data Documentation

◆ $children

TreeControl::$children

Definition at line 332 of file tree.inc.

◆ $height

TreeControl::$height

Definition at line 328 of file tree.inc.

◆ $id

TreeControl::$id

Definition at line 323 of file tree.inc.

◆ $indent

TreeControl::$indent = "16px"

Definition at line 331 of file tree.inc.

◆ $scroll

TreeControl::$scroll

Definition at line 326 of file tree.inc.

◆ $selectMode

TreeControl::$selectMode = "multi"

Definition at line 329 of file tree.inc.

◆ $selectOnRightClick

TreeControl::$selectOnRightClick = false

Definition at line 333 of file tree.inc.

◆ $selectOnRightClickMode

TreeControl::$selectOnRightClickMode = "context"

Definition at line 334 of file tree.inc.

◆ $style

TreeControl::$style

Definition at line 325 of file tree.inc.

◆ $title

TreeControl::$title

Definition at line 324 of file tree.inc.

◆ $value

TreeControl::$value

Definition at line 330 of file tree.inc.

◆ $width

TreeControl::$width

Definition at line 327 of file tree.inc.


The documentation for this class was generated from the following file: