eZ Publish  [trunk]
eZTemplateAttributeOperator Class Reference

Display of variable attributes using operator "attribute" or dumps a variable using the operator "dump". More...

List of all members.

Public Member Functions

 eZTemplateAttributeOperator ($attributeName= 'attribute', $dumpName= 'dump')
 modify ($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
 namedParameterList ()
 namedParameterPerOperator ()
 operatorList ()
 operatorTemplateHints ()

Public Attributes

 $Operators
 The array of operators, used for registering operators.

Private Member Functions

 displayVariable (&$value, ezpAttributeOperatorFormatterInterface $formatter, $showValues, $max, $level, &$outputString)

Detailed Description

Display of variable attributes using operator "attribute" or dumps a variable using the operator "dump".

This class allows for displaying template variable attributes. The display is recursive and the number of levels can be maximized.

The "attribute" operator can take three parameters. The first is whether to show variable values or not, default is to not show. The second is the maximum number of levels to recurse, if blank or omitted the maxium level is 2. The third is the type of display, if set to "text" the output is as pure text otherwise as html. The default output is configured in template.ini.

The "dump" operator does exactly what the "attribute" operator does with following exceptions:

  • The default maximum number of levels to recurse is 1
  • By default, it shows the values of arrays and object properties
  • it can handle primitive variables and NULL values
// Example template code for operator 'attribute'

// Display attributes of $myvar
{$myvar|attribute}
// Display 2 levels of $tree
{$tree|attribute(show,2)}
// Display attributes and values of $item
{$item|attribute(show)}


// Example template code for operator 'dump'

// Dumps out $myvar - can handle primitive variables, arrays and objects.
// By default it shows array values or object properties.
{$myvar|dump()}

// Show 2 levels of $tree (default is 1)
{$tree|dump(show, 2)}

Definition at line 55 of file eztemplateattributeoperator.php.


Member Function Documentation

eZTemplateAttributeOperator::displayVariable ( &$  value,
ezpAttributeOperatorFormatterInterface formatter,
showValues,
max,
level,
&$  outputString 
) [private]

Helper function for recursive display of attributes. $value is the current variable, $as_html is true if display as html, $max is the maximum number of levels, $cur_level the current level and $outputString is the output text which the function adds to.

Definition at line 152 of file eztemplateattributeoperator.php.

Referenced by modify().

eZTemplateAttributeOperator::eZTemplateAttributeOperator ( attributeName = 'attribute',
dumpName = 'dump' 
)

Initializes the object with the name $attributeName, default is "attribute" and $dumpName, default is 'dump'

Definition at line 60 of file eztemplateattributeoperator.php.

eZTemplateAttributeOperator::modify ( tpl,
operatorName,
operatorParameters,
rootNamespace,
currentNamespace,
&$  operatorValue,
namedParameters,
placement 
)

Display the variable.

Definition at line 122 of file eztemplateattributeoperator.php.

Returns:
true to tell the template engine that the parameter list exists per operator type.

Definition at line 114 of file eztemplateattributeoperator.php.

Returns the template operators.

Definition at line 71 of file eztemplateattributeoperator.php.


Member Data Documentation

eZTemplateAttributeOperator::$Operators

The array of operators, used for registering operators.

Definition at line 184 of file eztemplateattributeoperator.php.


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