eZPublishCommunityProject(LegacyStack)  2013.9
eZTemplateAttributeOperator Class Reference

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

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. More...
 

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)}

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.

Referenced by modify().

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

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

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

Display the variable.

eZTemplateAttributeOperator::namedParameterList ( )
eZTemplateAttributeOperator::namedParameterPerOperator ( )
Returns
true to tell the template engine that the parameter list exists per operator type.
eZTemplateAttributeOperator::operatorList ( )

Returns the template operators.

eZTemplateAttributeOperator::operatorTemplateHints ( )

Member Data Documentation

eZTemplateAttributeOperator::$Operators

The array of operators, used for registering operators.

Referenced by operatorList().


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