Path

ez components / documentation / api reference / 2008.2.1 / tree


eZ Components 2008.2.1

Tree: ezcTreeVisitorXHTML

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcTreeVisitorXHTML

An implementation of the ezcTreeVisitor interface that generates an XHTML representatation of a tree structure. [source]

Implemented Interfaces

1.  <?php
2.      $options new ezcTreeVisitorXHTMLOptions;
3.      $options->xmlId 'menu_tree';
4.      $visitor new ezcTreeVisitorXHTML$options );
5.      $tree->accept$visitor );
6.      echo (string) $visitor// print the plot
7.   ?>
Shows (something like):

Member Variables

protected array(string=>array(string)) $edges = array()
Holds all the edges of the graph.
public ezcTreeVisitorXHTMLOptions $options
Holds the options for this class
protected string $root = null
Holds the root ID.

Method Summary

public ezcTreeVisitorXHTML __construct( [$options = null] )
Constructs a new ezcTreeVisitorXHTML visualizer.
protected string doChildren( $id, [$level = 0], [$levelLast = array()], $levelLast )
Loops over the children of the node with ID $id.
protected string formatData( $data, $highlight )
Formats a node's data.
public bool visit( $visitable )
Visits the node and sets the the member variables according to the node type and contents.

Methods

__construct

ezcTreeVisitorXHTML __construct( [ezcTreeVisitorXHTMLOptions $options = null] )
Constructs a new ezcTreeVisitorXHTML visualizer.

Parameters

Name Type Description
$options ezcTreeVisitorXHTMLOptions  

doChildren

string doChildren( string $id, [int $level = 0], [ $levelLast = array()], array(int=>bool) $levelLast )
Loops over the children of the node with ID $id.
This methods loops over all the node's children and adds the correct layout for each node depending on the state that is collected in the $level and $levelLast variables.

Parameters

Name Type Description
$id string  
$level int  
$levelLast array(int=>bool)  
$levelLast  

formatData

string formatData( mixed $data, bool $highlight )
Formats a node's data.
It is just a simple method, that provide an easy way to change the way on how data is formatted when this class is extended. The data is passed in the $data argument, and whether the node should be highlighted is passed in the $highlight argument.

Parameters

Name Type Description
$data mixed  
$highlight bool  

visit

bool visit( ezcTreeVisitable $visitable )
Visits the node and sets the the member variables according to the node type and contents.

Parameters

Name Type Description
$visitable ezcTreeVisitable  

Last updated: Mon, 09 Feb 2009