eZ Publish  [4.2]
eZTemplate Class Reference

The main manager for templates. More...

List of all members.

Public Member Functions

 appendDebugNodes (&$root, &$resourceData)
 appendElement (&$text, $item, $nspace, $name)
 appendElementText (&$textElements, $item, $nspace, $name)
 appendTemplateFetch ($actualTemplateName)
 attributeValue (&$data, $nspace)
 autoload ()
 autoloadPathList ()
 canCompileTemplate ($resourceData, &$extraParameters)
 compileTemplate (&$resourceData, &$extraParameters)
 compileTemplateFile ($file, $returnResourceData=false)
 createLocalVariablesList ()
 destroyLocalVariablesList ()
 display ($template=false, $extraParameters=false)
 doFunction ($name, $func_obj, $nspace, $current_nspace)
 doOperator ($element, &$namespace, &$current_nspace, &$value, $operatorName, $operatorParameters, &$named_params)
 elementValue (&$dataElements, $rootNamespace, $currentNamespace, $placement=false, $checkExistance=false, $checkForProxy=false)
 emptyVariable ()
 error ($name, $txt, $placement=false)
 errorCount ()
 errorLog ()
 executeCompiledTemplate (&$resourceData, &$textElements, $rootNamespace, $currentNamespace, &$extraParameters)
 expandAttributes ($attributeList, $chooseText, $maxThreshold, $minThreshold=1)
 extraParameters ($name, $count, $maxCount)
 eZTemplate ()
 fetch ($template=false, $extraParameters=false, $returnResourceData=false)
 fetchFunctionObject ($functionName)
 hasChildren (&$function, $functionName)
 hasErrors ()
 hasLocalVariable ($varName, $rootNamespace)
 hasVariable ($var, $namespace="", $attrs=array())
 hasWarnings ()
 ini ()
 isCachingAllowed ()
 leftDelimiter ()
 load ($uri, $extraParameters=false, $returnResourceData=false)
 loadAndRegisterFunctions ($functionDefinition)
 loadAndRegisterOperators ($operatorDefinition)
 loadURIData ($resourceObject, $uri, $resourceName, $template, &$extraParameters, $displayErrors=true)
 loadURIRoot ($uri, $displayErrors=true, &$extraParameters)
 missingParameter ($name, $param)
 operatorInputSupported ($operatorName)
 operatorParameterList ($name)
 parse ($sourceText, &$rootElement, $rootNamespace, &$resourceData)
 placementText ($placement=false)
 process ($root, &$text, $rootNamespace, $currentNamespace)
 processFunction ($functionName, &$textElements, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace)
 processNode ($node, &$textElements, $rootNamespace, $currentNamespace)
 processOperator ($operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$valueData, $placement=false, $checkExistance=false)
 processURI ($uri, $displayErrors=true, &$extraParameters, &$textElements, $rootNamespace, $currentNamespace)
 processVariable (&$textElements, $variableData, $variablePlacement, $rootNamespace, $currentNamespace)
 registerAutoloadFunctions ($functionDefinition)
 registerAutoloadOperators ($operatorDefinition)
 registerFilter ()
 registerFunction ($func_name, $func_obj)
 registerFunctions (&$functionObject)
 registerLiteral ($func_name)
 registerOperator ($op_name, $op_obj)
 registerOperators (&$operatorObject)
 registerOperatorsInternal ($operatorObject, $debug=false)
 registerResource ($res)
 reset ()
 resetElements ()
 resetErrorLog ()
 resetVariables ()
 resourceFor ($uri, &$res, &$template)
 resourceHandler ($resourceName)
 rightDelimiter ()
 setAutoloadPathList ($pathList)
 setCompileTest ($val)
 setIncludeOutput ($uri, $output)
 setIncludeText ($uri, $text)
 setIsCachingAllowed ($allowed)
 setLeftDelimiter ($delim)
 setLocalVariable ($varName, $varValue, $rootNamespace)
 setRightDelimiter ($delim)
 setShowDetails ($show)
 setVariable ($var, $val, $namespace="")
 setVariableRef ($var, $val, $namespace="")
 templateFetchList ()
 testCompile ()
 undefinedFunction ($func_name)
 undefinedVariable ($name, $var)
 unregisterLiteral ($func_name)
 unregisterOperator ($op_name)
 unregisterResource ($res_name)
 unsetLocalVariable ($varName, $rootNamespace)
 unsetLocalVariables ()
 unsetVariable ($var, $namespace="")
 validateTemplateFile ($file, $returnResourceData=false)
 variable ($var, $namespace="", $attrs=array())
 variableAttribute ($var, $attrs)
 variableText ($var, $namespace="", $attrs=array())
 warning ($name, $txt, $placement=false)
 warningCount ()
 warningLog ()

Static Public Member Functions

 appendTemplateToStatistics ($templateName, $templateFileName)
 appendTemplateToStatisticsIfNeeded (&$templateName, &$templateFileName)
static instance ()
 Returns a shared instance of the eZTemplate class.
static isDebugEnabled ()
static isMethodDebugEnabled ()
static isTemplatesUsageStatisticsEnabled ()
static isXHTMLCodeIncluded ()
 mergeNamespace ($rootNamespace, $additionalNamespace)
 resourceData ($resourceObject, $uri, $resourceName, $templateName)
static setIsDebugEnabled ($debug)
 setIsTemplatesUsageStatisticsEnabled ($enabled)
static templatesUsageStatistics ()

Public Attributes

 $AutoloadPathList
 $CurrentLocalVariablesNames
 $DefaultResource
 Reference to the default resource object.
 $DoCounter
 $ElseifCounter
 $ErrorLog
 Array containing all errors occured during a fetch.
 $ForCounter
 $ForeachCounter
 $FunctionAttributes
 An associative array of function attributes.
 $Functions
 An associative array of functions.
 $IncludeOutput
 Included outputs, usually performed by custom functions.
 $IncludeText
 Included texts, usually performed by custom functions.
 $IsCachingAllowed
 true if caching is allowed
 $LDelim
 The left delimiter used for parsing.
 $Level = 0
 include level
 $Literals
 An associative array of literal tags.
 $LocalVariablesNamesStack
 $MaxLevel = 40
 $Operators
 An associative array of operators.
 $RDelim
 The right delimiter used for parsing.
 $Resources
 Associative array of resource objects.
 $ShowDetails = false
 True if output details is to be shown.
 $TemplatesUsageStatistics
 A list of templates used by a rendered page.
 $TestCompile
 $Text
 The original template text.
 $TimeStamp
 The timestamp of the template when it was last modified.
 $Tree
 The resulting object tree of the template.
 $Variables
 An associative array of template variables.
 $WarningLog
 Array containing all warnings occured during a fetch.
 $WhileCounter
const DEBUG_INTERNALS = false
const ELEMENT_COMMENT = 6
const ELEMENT_END_TAG = 4
const ELEMENT_NORMAL_TAG = 3
const ELEMENT_SINGLE_TAG = 2
const ELEMENT_TEXT = 1
const ELEMENT_VARIABLE = 5
const FILE_ERRORS = 1
const NAMESPACE_SCOPE_GLOBAL = 1
const NAMESPACE_SCOPE_LOCAL = 2
const NAMESPACE_SCOPE_RELATIVE = 3
const NODE_FUNCTION = 4
const NODE_INTERNAL = 100
const NODE_INTERNAL_CODE_PIECE = 101
const NODE_INTERNAL_ERROR = 121
const NODE_INTERNAL_NAMESPACE_CHANGE = 103
const NODE_INTERNAL_NAMESPACE_RESTORE = 104
const NODE_INTERNAL_OUTPUT_ASSIGN = 150
const NODE_INTERNAL_OUTPUT_DECREASE = 153
const NODE_INTERNAL_OUTPUT_INCREASE = 152
const NODE_INTERNAL_OUTPUT_READ = 151
const NODE_INTERNAL_OUTPUT_SPACING_INCREASE = 160
const NODE_INTERNAL_RESOURCE_ACQUISITION = 140
const NODE_INTERNAL_SPACING_DECREASE = 161
const NODE_INTERNAL_VARIABLE_SET = 105
const NODE_INTERNAL_VARIABLE_UNSET = 102
const NODE_INTERNAL_WARNING = 120
const NODE_OPERATOR = 5
const NODE_OPTIMIZED_INIT = 201
const NODE_OPTIMIZED_RESOURCE_ACQUISITION = 141
const NODE_ROOT = 1
const NODE_TEXT = 2
const NODE_USER_CUSTOM = 1000
const NODE_VARIABLE = 3
const RESOURCE_FETCH = 1
const RESOURCE_QUERY = 2
const TYPE_ALL = 63
const TYPE_ARRAY = 8
const TYPE_ATTRIBUTE = 5
const TYPE_ATTRIBUTE_BIT = 16
const TYPE_BASIC = 47
const TYPE_BOOLEAN = 7
const TYPE_DYNAMIC_ARRAY = 9
const TYPE_IDENTIFIER = 3
const TYPE_IDENTIFIER_BIT = 4
const TYPE_INTERNAL = 100
const TYPE_INTERNAL_CODE_PIECE = 101
const TYPE_INTERNAL_STOP = 999
const TYPE_MODIFIER_MASK = 48
const TYPE_NONE = 0
const TYPE_NUMERIC = 2
const TYPE_NUMERIC_BIT = 2
const TYPE_OPERATOR = 6
const TYPE_OPERATOR_BIT = 32
const TYPE_OPTIMIZED_ARRAY_LOOKUP = 202
const TYPE_OPTIMIZED_ATTRIBUTE_LOOKUP = 204
const TYPE_OPTIMIZED_CONTENT_CALL = 203
const TYPE_OPTIMIZED_NODE = 201
const TYPE_PHP_VARIABLE = 102
const TYPE_STRING = 1
const TYPE_STRING_BIT = 1
const TYPE_VARIABLE = 4
const TYPE_VARIABLE_BIT = 8
const TYPE_VOID = 0

Private Member Functions

 registerFunctionsInternal ($functionObject, $debug=false)

Detailed Description

The main manager for templates.

The template systems allows for separation of code and layout by moving the layout part into template files. These template files are parsed and processed with template variables set by the PHP code.

The template system in itself is does not do much, it parses template files according to a rule set sets up a tree hierarchy and process the data using functions and operators. The standard template system comes with only a few functions and no operators, it is meant for these functions and operators to be specified by the users of the template system. But for simplicity a few help classes is available which can be easily enabled.

The classes are:

To enable these functions and operator use registerFunction and registerOperator.

In keeping with the spirit of being simple the template system does not know how to get the template files itself. Instead it relies on resource handlers, these handlers fetches the template files using different kind of transport mechanism. For simplicity a default resource class is available, eZTemplateFileResource fetches templates from the filesystem.

The parser process consists of three passes, each pass adds a new level of complexity. The first pass strips text from template blocks which starts with a left delimiter and ends with a right delimiter (default is { and } ), and places them in an array. The second pass iterates the text and block elements and removes newlines from text before function blocks and text after function blocks. The third pass builds the tree according the function rules.

Processing is done by iterating over the root of the tree, if a text block is found the text is appended to the result text. If a variable or contant is it's data is extracted and any operators found are run on it before fetching the result and appending it to the result text. If a function is found the function is called with the parameters and it's up to the function handle children if any.

Constants and template variables will usually be called variables since there's little difference. A template variable expression will start with a $ and consists of a namespace (optional) a name and attribues(optional). The variable expression

$root:var.attr1 

exists in the "root" namespace, has the name "var" and uses the attribute "attr1". Some functions will create variables on demand, to avoid name conflicts namespaces were introduced, each function will place the new variables in a namespace specified in the template file. Attribues are used for fetching parts of the variable, for instance an element in an array or data in an object. Since the syntax is the same for arrays and objects the PHP code can use simple arrays when speed is required, the template code will not care. A different syntax is also available when you want to access an attribute using a variable. For instance

$root:var[$attr_var] 

, if the variable $attr_var contains "attr1" it would access the same attribute as in the first example.

The syntax for operators is a | and a name, optionally parameters can be specified with ( and ) delimited with ,. Valid operators are

|upcase, |l10n(date) 

.

Functions look a lot like HTML/XML tags. The function consists of a name and parameters which are assigned using the param=value syntax. Some parameters may be required while others may be optionally, the exact behaviour is specified by each function. Valid functions are

"section name=abc loop=4" 

Example of usage:

// Init template
$tpl = eZTemplate::instance();

$tpl->registerOperators( new eZTemplatePHPOperator( array( "upcase" => "strtoupper",
                                                           "reverse" => "strrev" ) ) );
$tpl->registerOperators( new eZTemplateLocaleOperator() );
$tpl->registerFunction( "section", new eZTemplateSectionFunction( "section" ) );
$tpl->registerFunctions( new eZTemplateDelimitFunction() );

$tpl->setVariable( "my_var", "{this value set by variable}", "test" );
$tpl->setVariable( "my_arr", array( "1st", "2nd", "third", "fjerde" ) );
$tpl->setVariable( "multidim", array( array( "a", "b" ),
                                      array( "c", "d" ),
                                      array( "e", "f" ),
                                      array( "g", "h" ) ) );

class mytest
{
    function mytest( $n, $s )
    {
        $this->n = $n;
        $this->s = $s;
    }

    function hasAttribute( $attr )
    {
        return ( $attr == "name" || $attr == "size" );
    }

    function attribute( $attr )
    {
        switch ( $attr )
        {
            case "name";
                return $this->n;
            case "size";
                return $this->s;
            default:
                $retAttr = null;
                return $retAttr;
        }
    }

};

$tpl->setVariable( "multidim_obj", array( new mytest( "jan", 200 ),
                                          new mytest( "feb", 200 ),
                                          new mytest( "john", 200 ),
                                          new mytest( "doe", 50 ) ) );
$tpl->setVariable( "curdate", time() );

$tpl->display( "lib/eztemplate/example/test.tpl" );

// test.tpl

{section name=outer loop=4}
123
{delimit}::{/delimit}
{/section}

{literal test=1} This is some {blah arg1="" arg2="abc" /} {/literal}

<title>This is a test</title>
<table border="1">
<tr><th>{$test:my_var}
{"some text!!!"|upcase|reverse}</th></tr>
{section name=abc loop=$my_arr}
<tr><td>{$abc:item}</td></tr>
{/section}
</table>

<table border="1">
{section name=outer loop=$multidim}
<tr>
{section name=inner loop=$outer:item}
<td>{$inner:item}</td>
{/section}
</tr>
{/section}
</table>

<table border="1">
{section name=outer loop=$multidim_obj}
<tr>
<td>{$outer:item.name}</td>
<td>{$outer:item.size}</td>
</tr>
{/section}
</table>

{section name=outer loop=$nonexistingvar}
<b><i>Dette skal ikke vises</b></i>
{section-else}
<b><i>This is shown when the {ldelim}$loop{rdelim} variable is non-existant</b></i>
{/section}


Denne koster {1.4|l10n(currency)}<br>
{-123456789|l10n(number)}<br>
{$curdate|l10n(date)}<br>
{$curdate|l10n(shortdate)}<br>
{$curdate|l10n(time)}<br>
{$curdate|l10n(shorttime)}<br>
{include file="test2.tpl"/}

Definition at line 222 of file eztemplate.php.


Member Function Documentation

eZTemplate::appendDebugNodes ( &$  root,
&$  resourceData 
)

Creates some text nodes before and after the children of $root. It will extract the current filename and uri and create some XHTML comments and inline text.

See also:
isXHTMLCodeIncluded

Definition at line 1726 of file eztemplate.php.

Referenced by compileTemplateFile(), loadURIRoot(), and validateTemplateFile().

eZTemplate::appendElement ( &$  text,
item,
nspace,
name 
)

Definition at line 1674 of file eztemplate.php.

eZTemplate::appendElementText ( &$  textElements,
item,
nspace,
name 
)

Definition at line 1680 of file eztemplate.php.

Referenced by appendElement(), and processVariable().

eZTemplate::appendTemplateFetch ( actualTemplateName)

Appends template info for current fetch.

Definition at line 2498 of file eztemplate.php.

Referenced by loadURIRoot().

eZTemplate::appendTemplateToStatistics ( templateName,
templateFileName 
) [static]

Appends template info to stats.

Definition at line 2464 of file eztemplate.php.

Referenced by appendTemplateToStatisticsIfNeeded().

eZTemplate::appendTemplateToStatisticsIfNeeded ( &$  templateName,
&$  templateFileName 
) [static]

Checks settings and if 'ShowUsedTemplates' is enabled appends template info to stats.

Definition at line 2454 of file eztemplate.php.

Referenced by loadURIRoot().

eZTemplate::attributeValue ( &$  data,
nspace 
)

Return the identifier used for attribute lookup.

Definition at line 1390 of file eztemplate.php.

eZTemplate::autoload ( )

Looks trough the pathes specified in autoloadPathList() and fetches autoload definition files used for autoloading functions and operators.

Definition at line 2191 of file eztemplate.php.

eZTemplate::autoloadPathList ( )
Returns:
the path list which is used for autoloading functions and operators.

Definition at line 2174 of file eztemplate.php.

Referenced by autoload().

eZTemplate::canCompileTemplate ( resourceData,
&$  extraParameters 
)

Definition at line 880 of file eztemplate.php.

Referenced by loadURIRoot().

eZTemplate::compileTemplate ( &$  resourceData,
&$  extraParameters 
)

Definition at line 988 of file eztemplate.php.

Referenced by compileTemplateFile(), and loadURIRoot().

eZTemplate::compileTemplateFile ( file,
returnResourceData = false 
)

Compiles the template file $file and returns true if the compilation was OK.

Parameters:
$returnResourceDataIf true then the returned value will be the resourcedata structure
See also:
validateTemplateFile(), fetch()

Definition at line 942 of file eztemplate.php.

eZTemplate::createLocalVariablesList ( )

Initialize list of local variables for the current template. The list contains only names of variables.

Definition at line 452 of file eztemplate.php.

Referenced by process().

eZTemplate::destroyLocalVariablesList ( )

Destroy list of local variables defined in the current (innermost) template.

Definition at line 503 of file eztemplate.php.

Referenced by process().

eZTemplate::display ( template = false,
extraParameters = false 
)

Fetches the result of the template file and displays it. If $template is supplied it will load this template file first.

Definition at line 408 of file eztemplate.php.

eZTemplate::doFunction ( name,
func_obj,
nspace,
current_nspace 
)

Tries to run the function object $func_obj

Definition at line 1482 of file eztemplate.php.

eZTemplate::doOperator ( element,
&$  namespace,
&$  current_nspace,
&$  value,
operatorName,
operatorParameters,
&$  named_params 
)

Tries to run the operator $operatorName with parameters $operatorParameters on the value $value.

Definition at line 1464 of file eztemplate.php.

eZTemplate::elementValue ( &$  dataElements,
rootNamespace,
currentNamespace,
placement = false,
checkExistance = false,
checkForProxy = false 
)

Returns the actual value of a template type or null if an unknown type.

Definition at line 1091 of file eztemplate.php.

Referenced by attributeValue(), processOperator(), and processVariable().

eZTemplate::emptyVariable ( )

Returns the empty variable type.

Definition at line 1070 of file eztemplate.php.

eZTemplate::error ( name,
txt,
placement = false 
)

Displays an error for the function/operator $name and text $txt.

Definition at line 2117 of file eztemplate.php.

Referenced by attributeValue(), elementValue(), processOperator(), registerAutoloadFunctions(), registerAutoloadOperators(), and undefinedFunction().

eZTemplate::errorCount ( )
Returns:
The number of errors that occured with the last fetch
See also:
hasErrors()

Definition at line 2274 of file eztemplate.php.

Referenced by hasErrors().

eZTemplate::errorLog ( )
Returns:
error log.
See also:
errorCount()

Definition at line 2292 of file eztemplate.php.

eZTemplate::executeCompiledTemplate ( &$  resourceData,
&$  textElements,
rootNamespace,
currentNamespace,
&$  extraParameters 
)

Definition at line 1000 of file eztemplate.php.

Referenced by fetch(), and processURI().

eZTemplate::expandAttributes ( attributeList,
chooseText,
maxThreshold,
minThreshold = 1 
)

Definition at line 1294 of file eztemplate.php.

Referenced by elementValue().

eZTemplate::extraParameters ( name,
count,
maxCount 
)

Outputs a warning about the parameter count being to high for function/operator $name.

Definition at line 2044 of file eztemplate.php.

eZTemplate::eZTemplate ( )

Intializes the template with left and right delimiters being { and }, and a file resource. The literal tag "literal" is also registered.

Definition at line 320 of file eztemplate.php.

Referenced by instance().

eZTemplate::fetch ( template = false,
extraParameters = false,
returnResourceData = false 
)

Tries to fetch the result of the template file and returns it. If $template is supplied it will load this template file first.

Definition at line 517 of file eztemplate.php.

Referenced by display().

eZTemplate::fetchFunctionObject ( functionName)

Definition at line 684 of file eztemplate.php.

eZTemplate::hasChildren ( &$  function,
functionName 
)

Definition at line 1058 of file eztemplate.php.

eZTemplate::hasErrors ( )
Returns:
\ true if errors occured with the last fetch.
See also:
errorCount()

Definition at line 2283 of file eztemplate.php.

Referenced by validateTemplateFile().

eZTemplate::hasLocalVariable ( varName,
rootNamespace 
)

Check if the given local variable exists.

Definition at line 461 of file eztemplate.php.

Referenced by unsetLocalVariable().

eZTemplate::hasVariable ( var,
namespace = "",
attrs = array() 
)

Returns true if the variable $var is set in namespace $namespace, if $attrs is supplied alle attributes must exist for the function to return true.

Definition at line 1543 of file eztemplate.php.

Referenced by elementValue().

eZTemplate::hasWarnings ( )
Returns:
\ true if warnings occured with the last fetch.
See also:
warningCount()

Definition at line 2310 of file eztemplate.php.

Referenced by validateTemplateFile().

eZTemplate::ini ( )

Returns the INI object for the template.ini file.

Definition at line 2342 of file eztemplate.php.

Referenced by error().

static eZTemplate::instance ( ) [static]
eZTemplate::isCachingAllowed ( )
Returns:
true if caching is allowed (default) or false otherwise. This also affects template compiling.
See also:
setIsCachingAllowed

Definition at line 2404 of file eztemplate.php.

Referenced by loadURIRoot().

static eZTemplate::isDebugEnabled ( ) [static]
Returns:
true if debugging of internals is enabled, this will display which files are loaded and when cache files are created. Set the option with setIsDebugEnabled().

Definition at line 2383 of file eztemplate.php.

Referenced by compileTemplateFile(), fetch(), eZTemplateFileResource\handleResourceData(), loadURIRoot(), processURI(), resourceFor(), and validateTemplateFile().

static eZTemplate::isMethodDebugEnabled ( ) [static]
Returns:
true if debug output of template functions and operators should be enabled.

Definition at line 2367 of file eztemplate.php.

Referenced by processFunction(), and processOperator().

static eZTemplate::isTemplatesUsageStatisticsEnabled ( ) [static]
Returns:
true if templates usage statistics should be enabled.

Definition at line 2425 of file eztemplate.php.

Referenced by appendTemplateToStatisticsIfNeeded(), and eZTemplatesStatisticsReporter\generateStatistics().

static eZTemplate::isXHTMLCodeIncluded ( ) [static]
Returns:
true if special XHTML code should be included before the included template file. This code will display the template filename in the browser but will eventually break the design.

Definition at line 2353 of file eztemplate.php.

Referenced by appendDebugNodes().

eZTemplate::leftDelimiter ( )

Returns the left delimiter being used.

Definition at line 375 of file eztemplate.php.

eZTemplate::load ( uri,
extraParameters = false,
returnResourceData = false 
)

Loads the template using the URI $uri and parses it.

Returns:
The root node of the tree if $returnResourceData is false, if true the entire resource data structure.

Definition at line 700 of file eztemplate.php.

eZTemplate::loadAndRegisterFunctions ( functionDefinition)

Definition at line 1789 of file eztemplate.php.

Referenced by doFunction(), fetchFunctionObject(), and processFunction().

eZTemplate::loadAndRegisterOperators ( operatorDefinition)

Definition at line 1908 of file eztemplate.php.

Referenced by doOperator(), operatorParameterList(), and processOperator().

eZTemplate::loadURIData ( resourceObject,
uri,
resourceName,
template,
&$  extraParameters,
displayErrors = true 
)

Definition at line 719 of file eztemplate.php.

Referenced by loadURIRoot().

eZTemplate::loadURIRoot ( uri,
displayErrors = true,
&$  extraParameters 
)

Loads the template using the URI $uri and returns a structure with the text and timestamp, false otherwise. The structure keys are:

  • "text", the text.
  • "time-stamp", the timestamp.

Definition at line 766 of file eztemplate.php.

Referenced by fetch(), load(), and processURI().

eZTemplate::mergeNamespace ( rootNamespace,
additionalNamespace 
) [static]

Definition at line 1078 of file eztemplate.php.

Referenced by elementValue().

eZTemplate::missingParameter ( name,
param 
)

Outputs a warning about the parameter $param missing for function/operator $name.

Definition at line 2036 of file eztemplate.php.

eZTemplate::operatorInputSupported ( operatorName)

Definition at line 2151 of file eztemplate.php.

eZTemplate::operatorParameterList ( name)

Returns the named parameter list for the operator $name.

Definition at line 1431 of file eztemplate.php.

Referenced by processOperator().

eZTemplate::parse ( sourceText,
&$  rootElement,
rootNamespace,
&$  resourceData 
)

Definition at line 713 of file eztemplate.php.

Referenced by compileTemplateFile(), loadURIRoot(), and validateTemplateFile().

eZTemplate::placementText ( placement = false)

Creates a string for the placement information and returns it.

Note:
The placement information can either be in indexed or associative

Definition at line 2069 of file eztemplate.php.

Referenced by error(), and warning().

eZTemplate::process ( root,
&$  text,
rootNamespace,
currentNamespace 
)

Definition at line 591 of file eztemplate.php.

Referenced by fetch(), and processURI().

eZTemplate::processFunction ( functionName,
&$  textElements,
functionChildren,
functionParameters,
functionPlacement,
rootNamespace,
currentNamespace 
)

Definition at line 658 of file eztemplate.php.

Referenced by processNode().

eZTemplate::processNode ( node,
&$  textElements,
rootNamespace,
currentNamespace 
)

Definition at line 606 of file eztemplate.php.

Referenced by process().

eZTemplate::processOperator ( operatorName,
operatorParameters,
rootNamespace,
currentNamespace,
&$  valueData,
placement = false,
checkExistance = false 
)

Definition at line 1326 of file eztemplate.php.

Referenced by elementValue().

eZTemplate::processURI ( uri,
displayErrors = true,
&$  extraParameters,
&$  textElements,
rootNamespace,
currentNamespace 
)

Definition at line 824 of file eztemplate.php.

eZTemplate::processVariable ( &$  textElements,
variableData,
variablePlacement,
rootNamespace,
currentNamespace 
)

Definition at line 652 of file eztemplate.php.

Referenced by processNode().

eZTemplate::registerAutoloadFunctions ( functionDefinition)

Definition at line 1753 of file eztemplate.php.

Referenced by autoload().

eZTemplate::registerAutoloadOperators ( operatorDefinition)

Definition at line 1879 of file eztemplate.php.

Referenced by autoload().

eZTemplate::registerFilter ( )

Not implemented yet.

Definition at line 1989 of file eztemplate.php.

eZTemplate::registerFunction ( func_name,
func_obj 
)

Registers the function $func_name to be bound to object $func_obj. If the object has a function called attributeList() it is used for registering function attributes. The function returns an associative array with each key being the name of the function and the value being a boolean. If the boolean is true the function will have children.

Definition at line 1849 of file eztemplate.php.

eZTemplate::registerFunctions ( &$  functionObject)

Registers the functions supplied by the object $functionObject. The object must have a function called functionList() which returns an array of functions this object handles. If the object has a function called attributeList() it is used for registering function attributes. The function returns an associative array with each key being the name of the function and the value being a boolean. If the boolean is true the function will have children.

Definition at line 1748 of file eztemplate.php.

eZTemplate::registerFunctionsInternal ( functionObject,
debug = false 
) [private]

Definition at line 1821 of file eztemplate.php.

Referenced by loadAndRegisterFunctions(), and registerFunctions().

eZTemplate::registerLiteral ( func_name)

Registers a new literal tag in which the tag will be transformed into a text element.

Definition at line 1866 of file eztemplate.php.

Referenced by eZTemplate().

eZTemplate::registerOperator ( op_name,
op_obj 
)

Registers the operator $op_name to use the object $op_obj.

Definition at line 1963 of file eztemplate.php.

eZTemplate::registerOperators ( &$  operatorObject)

Registers the operators supplied by the object $operatorObject. The function operatorList() must return an array of operator names.

Definition at line 1944 of file eztemplate.php.

eZTemplate::registerOperatorsInternal ( operatorObject,
debug = false 
)

Definition at line 1949 of file eztemplate.php.

Referenced by loadAndRegisterOperators(), and registerOperators().

eZTemplate::registerResource ( res)

Registers a new resource object $res. The resource object take care of fetching templates using an URI.

Definition at line 1997 of file eztemplate.php.

Referenced by eZTemplate().

eZTemplate::reset ( )

Resets all template variables, functions, operators and error counts.

Definition at line 2258 of file eztemplate.php.

Referenced by display().

eZTemplate::resetElements ( )

Resets all template functions and operators by calling the resetFunction and resetOperator on all elements that supports it.

Definition at line 2234 of file eztemplate.php.

Referenced by reset().

eZTemplate::resetErrorLog ( )

Reset error and warning logs

Definition at line 2507 of file eztemplate.php.

Referenced by compileTemplateFile(), eZTemplate(), fetch(), reset(), and validateTemplateFile().

eZTemplate::resetVariables ( )

Resets all template variables.

Definition at line 2225 of file eztemplate.php.

Referenced by reset().

eZTemplate::resourceData ( resourceObject,
uri,
resourceName,
templateName 
) [static]

Creates a resource data structure of the parameters and returns it. This structure is passed to various parts of the template system.

Note:
If you only have the URI you should call resourceFor() first to figure out the resource handler.

Definition at line 747 of file eztemplate.php.

Referenced by compileTemplateFile(), loadURIData(), and validateTemplateFile().

eZTemplate::resourceFor ( uri,
&$  res,
&$  template 
)

Returns the resource object for URI $uri. If a resource type is specified in the URI it is extracted and set in $res. The template name is set in $template without any resource specifier. To specify a resource the name and a ":" is prepended to the URI, for instance file:my.tpl. If no resource type is found the URI the default resource handler is used.

Definition at line 1023 of file eztemplate.php.

Referenced by compileTemplateFile(), loadURIRoot(), and validateTemplateFile().

eZTemplate::resourceHandler ( resourceName)
Returns:
The resource handler object for resource name $resourceName.
See also:
resourceFor

Definition at line 1048 of file eztemplate.php.

eZTemplate::rightDelimiter ( )

Returns the right delimiter being used.

Definition at line 383 of file eztemplate.php.

eZTemplate::setAutoloadPathList ( pathList)

Sets the path list for autoloading.

Definition at line 2182 of file eztemplate.php.

eZTemplate::setCompileTest ( val)

Set template compilation test mode.

Parameters:
true,willset template compilation in test mode ( no disc writes ). false, will compile templates to disc

Definition at line 2537 of file eztemplate.php.

eZTemplate::setIncludeOutput ( uri,
output 
)

Sets the output for uri $uri to $output.

Definition at line 2166 of file eztemplate.php.

Referenced by processURI().

eZTemplate::setIncludeText ( uri,
text 
)

Sets the original text for uri $uri to $text.

Definition at line 2158 of file eztemplate.php.

Referenced by loadURIRoot().

eZTemplate::setIsCachingAllowed ( allowed)

Sets whether caching/compiling is allowed or not. This is useful if you need to make sure templates are parsed and processed without any caching mechanisms.

Note:
The default is to allow caching.
See also:
isCachingAllowed

Definition at line 2416 of file eztemplate.php.

static eZTemplate::setIsDebugEnabled ( debug) [static]

Sets whether internal debugging is enabled or not.

Definition at line 2394 of file eztemplate.php.

Referenced by templateInit().

eZTemplate::setIsTemplatesUsageStatisticsEnabled ( enabled) [static]

Sets whether templates usage statistics enabled or not.

Returns:
true if templates usage statistics was enabled, otherwise false.

Definition at line 2440 of file eztemplate.php.

eZTemplate::setLeftDelimiter ( delim)

Sets the left delimiter.

Definition at line 391 of file eztemplate.php.

eZTemplate::setLocalVariable ( varName,
varValue,
rootNamespace 
)

Create a local variable.

Definition at line 470 of file eztemplate.php.

eZTemplate::setRightDelimiter ( delim)

Sets the right delimiter.

Definition at line 399 of file eztemplate.php.

eZTemplate::setShowDetails ( show)

Sets whether detail output is used or not. Detail output is useful for debug output where you want to examine the template and the output text.

Definition at line 2028 of file eztemplate.php.

eZTemplate::setVariable ( var,
val,
namespace = "" 
)

Sets the template variable $var to the value $val.

See also:
setVariableRef

Definition at line 1506 of file eztemplate.php.

Referenced by setLocalVariable().

eZTemplate::setVariableRef ( var,
val,
namespace = "" 
)

Sets the template variable $var to the value $val.

Note:
This sets the variable using reference
See also:
setVariable

Definition at line 1519 of file eztemplate.php.

Referenced by appendElementText().

eZTemplate::templateFetchList ( )

Returns template list for the last fetch.

Definition at line 2526 of file eztemplate.php.

static eZTemplate::templatesUsageStatistics ( ) [static]

Returns template usage statistics

Definition at line 2517 of file eztemplate.php.

Referenced by eZTemplatesStatisticsReporter\generateStatistics().

eZTemplate::testCompile ( )

Get if template session is test compile

Definition at line 2545 of file eztemplate.php.

eZTemplate::undefinedFunction ( func_name)

Outputs an error about the template function $func_name being undefined.

Definition at line 2060 of file eztemplate.php.

eZTemplate::undefinedVariable ( name,
var 
)

Outputs a warning about the variable $var being undefined.

Definition at line 2052 of file eztemplate.php.

eZTemplate::unregisterLiteral ( func_name)

Removes the literal tag $func_name.

Definition at line 1874 of file eztemplate.php.

eZTemplate::unregisterOperator ( op_name)

Unregisters the operator $op_name.

Definition at line 1971 of file eztemplate.php.

eZTemplate::unregisterResource ( res_name)

Unregisters the resource $res_name.

Definition at line 2008 of file eztemplate.php.

eZTemplate::unsetLocalVariable ( varName,
rootNamespace 
)

Destroy a local variable.

Definition at line 479 of file eztemplate.php.

Referenced by unsetLocalVariables().

eZTemplate::unsetLocalVariables ( )

Destroy all local variables defined in the current template.

Definition at line 491 of file eztemplate.php.

Referenced by process().

eZTemplate::unsetVariable ( var,
namespace = "" 
)

Removes the template variable $var. If the variable does not exist an error is output.

Definition at line 1530 of file eztemplate.php.

Referenced by unsetLocalVariable().

eZTemplate::validateTemplateFile ( file,
returnResourceData = false 
)

Validates the template file $file and returns true if the file has correct syntax.

Parameters:
$returnResourceDataIf true then the returned value will be the resourcedata structure
See also:
compileTemplateFile(), fetch()

Definition at line 894 of file eztemplate.php.

eZTemplate::variable ( var,
namespace = "",
attrs = array() 
)

Returns the content of the variable $var using namespace $namespace, if $attrs is supplied the result of the attributes is returned.

Definition at line 1582 of file eztemplate.php.

Referenced by elementValue().

eZTemplate::variableAttribute ( var,
attrs 
)

Returns the attribute(s) of the template variable $var, $attrs is an array of attribute names to use iteratively for each new variable returned.

Definition at line 1635 of file eztemplate.php.

eZTemplate::variableText ( var,
namespace = "",
attrs = array() 
)

Helper function for creating a displayable text for a variable.

Definition at line 1417 of file eztemplate.php.

eZTemplate::warning ( name,
txt,
placement = false 
)
eZTemplate::warningCount ( )
Returns:
The number of warnings that occured with the last fetch
See also:
hasWarnings()

Definition at line 2301 of file eztemplate.php.

Referenced by hasWarnings().

eZTemplate::warningLog ( )
Returns:
waring log.
See also:
warningCount()

Definition at line 2319 of file eztemplate.php.


Member Data Documentation

eZTemplate::$AutoloadPathList

Definition at line 2598 of file eztemplate.php.

eZTemplate::$CurrentLocalVariablesNames

Definition at line 2579 of file eztemplate.php.

eZTemplate::$DefaultResource

Reference to the default resource object.

Definition at line 2554 of file eztemplate.php.

eZTemplate::$DoCounter

Definition at line 2610 of file eztemplate.php.

eZTemplate::$ElseifCounter

Definition at line 2611 of file eztemplate.php.

eZTemplate::$ErrorLog

Array containing all errors occured during a fetch.

Definition at line 2594 of file eztemplate.php.

eZTemplate::$ForCounter

Definition at line 2608 of file eztemplate.php.

eZTemplate::$ForeachCounter

Definition at line 2607 of file eztemplate.php.

eZTemplate::$FunctionAttributes

An associative array of function attributes.

Definition at line 2585 of file eztemplate.php.

eZTemplate::$Functions

An associative array of functions.

Definition at line 2583 of file eztemplate.php.

eZTemplate::$IncludeOutput

Included outputs, usually performed by custom functions.

Definition at line 2560 of file eztemplate.php.

eZTemplate::$IncludeText

Included texts, usually performed by custom functions.

Definition at line 2558 of file eztemplate.php.

eZTemplate::$IsCachingAllowed

true if caching is allowed

Definition at line 2591 of file eztemplate.php.

eZTemplate::$LDelim

The left delimiter used for parsing.

Definition at line 2564 of file eztemplate.php.

eZTemplate::$Level = 0

include level

Definition at line 2600 of file eztemplate.php.

eZTemplate::$Literals

An associative array of literal tags.

Definition at line 2587 of file eztemplate.php.

eZTemplate::$LocalVariablesNamesStack

Last element of this stack contains names of all variables created in the innermost template, for them to be destroyed after the template execution finishes.

Definition at line 2577 of file eztemplate.php.

eZTemplate::$MaxLevel = 40

Definition at line 2601 of file eztemplate.php.

eZTemplate::$Operators

An associative array of operators.

Definition at line 2581 of file eztemplate.php.

eZTemplate::$RDelim

The right delimiter used for parsing.

Definition at line 2566 of file eztemplate.php.

eZTemplate::$Resources

Associative array of resource objects.

Definition at line 2552 of file eztemplate.php.

eZTemplate::$ShowDetails = false

True if output details is to be shown.

Definition at line 2589 of file eztemplate.php.

eZTemplate::$TemplatesUsageStatistics

A list of templates used by a rendered page.

Definition at line 2604 of file eztemplate.php.

eZTemplate::$TestCompile

Definition at line 2614 of file eztemplate.php.

eZTemplate::$Text

The original template text.

Definition at line 2556 of file eztemplate.php.

eZTemplate::$TimeStamp

The timestamp of the template when it was last modified.

Definition at line 2562 of file eztemplate.php.

eZTemplate::$Tree

The resulting object tree of the template.

Definition at line 2569 of file eztemplate.php.

eZTemplate::$Variables

An associative array of template variables.

Definition at line 2571 of file eztemplate.php.

eZTemplate::$WarningLog

Array containing all warnings occured during a fetch.

Definition at line 2596 of file eztemplate.php.

eZTemplate::$WhileCounter

Definition at line 2609 of file eztemplate.php.

Definition at line 312 of file eztemplate.php.

Referenced by isDebugEnabled().

Definition at line 314 of file eztemplate.php.

Referenced by error().

Definition at line 241 of file eztemplate.php.

Referenced by eZTemplateCompiler\generatePHPCodeChildren().

Definition at line 264 of file eztemplate.php.

Referenced by eZTemplateOptimizer\optimize().

Definition at line 267 of file eztemplate.php.

Referenced by eZTemplateCompiler\generatePHPCodeChildren().

Definition at line 225 of file eztemplate.php.

Referenced by eZTemplateFileResource\handleResourceData().

Definition at line 302 of file eztemplate.php.

Definition at line 304 of file eztemplate.php.

Referenced by eZTemplateElementParser\parseVariableTag().

Definition at line 281 of file eztemplate.php.

Referenced by eZTemplateCompiler\inspectVariableData().

Definition at line 290 of file eztemplate.php.

Referenced by eZTemplateCompiler\inspectVariableData().

Definition at line 300 of file eztemplate.php.

Referenced by eZTemplateElementParser\parseVariableTag().

Definition at line 294 of file eztemplate.php.

Referenced by eZTemplateElementParser\parseVariableTag().

Definition at line 298 of file eztemplate.php.

Referenced by eZTemplateElementParser\parseVariableTag().

Definition at line 293 of file eztemplate.php.

Referenced by eZTemplateElementParser\parseVariableTag().


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