Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eztemplatedofunction.php
Go to the documentation of this file.
1 <?php
34 class eZTemplateDoFunction
35 {
36 const FUNCTION_NAME = 'do';
37
41 function functionList()
42 {
43 $functionList = array( eZTemplateDoFunction::FUNCTION_NAME );
44 return $functionList;
45 }
46
52 function attributeList()
53 {
54 return array( 'delimiter' => true,
55 'break' => false,
56 'continue' => false,
57 'skip' => false );
58 }
59
60
64 function functionTemplateHints()
65 {
66 return array( eZTemplateDoFunction::FUNCTION_NAME => array( 'parameters' => true,
67 'static' => false,
68 'transform-parameters' => true,
69 'tree-transformation' => true ) );
70 }
71
75 function templateNodeTransformation( $functionName, &$node,
76 $tpl, $parameters, $privateData )
77 {
78 // {/do while <condition> [sequence <sequence_array> as $<sequence_var>]}
79
80 $tpl->DoCounter++;
81 $newNodes = array();
82 $nodePlacement = eZTemplateNodeTool::extractFunctionNodePlacement( $node );
83 $uniqid = md5( $nodePlacement[2] ) . "_" . $tpl->DoCounter;
84
85 // initialize loop
86 $loop = new eZTemplateCompiledLoop( eZTemplateDoFunction::FUNCTION_NAME,
87 $newNodes, $parameters, $nodePlacement, $uniqid,
88 $node, $tpl, $privateData );
89
90 $loop->initVars();
91
92 // loop header
93 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "while ( 1 ) // do..while\n{" );
94 $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
95
96 $loop->processBody();
97
98 // loop footer
99 $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameters['condition'], $nodePlacement, array( 'treat-value-as-non-object' => true ), 'do_cond' );
100 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if ( ! \$do_cond ) break;" );
101 $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
102 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "} // do..while" );
103 $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode( 'do_cond' );
104
105 $loop->cleanup();
106
107 return $newNodes;
108 }
109
113 function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
114 {
115 $loop = new eZTemplateLoop( eZTemplateDoFunction::FUNCTION_NAME,
116 $functionParameters, $functionChildren, $functionPlacement,
117 $tpl, $textElements, $rootNamespace, $currentNamespace );
118
119 if ( !$loop->initialized() )
120 return;
121
122 if ( !isset( $functionParameters['condition'] ) )
123 {
124 eZDebug::writeError( "Not enough arguments passed to 'do' function" );
125 return;
126 }
127
128 do
129 {
130 $loop->setSequenceVar(); // set sequence variable (if specified)
131 $loop->processDelimiter();
132 $loop->resetIteration();
133
134 if ( $loop->processChildren() )
135 break;
136
137 $loop->incrementSequence();
138 } while ( $tpl->elementValue( $functionParameters['condition'], $rootNamespace, $currentNamespace, $functionPlacement ) );
139
140 $loop->cleanup();
141 }
142
146 function hasChildren()
147 {
148 return true;
149 }
150 }
151
152 ?>
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZTemplateCompiledLoop
Common code for compiling the loop functions.
Definition: eztemplatecompiledloop.php:17
eZTemplateDoFunction
DO..WHILE loop.
Definition: eztemplatedofunction.php:35
eZTemplateDoFunction\functionList
functionList()
Definition: eztemplatedofunction.php:41
eZTemplateDoFunction\FUNCTION_NAME
const FUNCTION_NAME
Definition: eztemplatedofunction.php:36
eZTemplateDoFunction\process
process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace)
Definition: eztemplatedofunction.php:113
eZTemplateDoFunction\attributeList
attributeList()
Definition: eztemplatedofunction.php:52
eZTemplateDoFunction\functionTemplateHints
functionTemplateHints()
Definition: eztemplatedofunction.php:64
eZTemplateDoFunction\templateNodeTransformation
templateNodeTransformation( $functionName, &$node, $tpl, $parameters, $privateData)
Definition: eztemplatedofunction.php:75
eZTemplateDoFunction\hasChildren
hasChildren()
Definition: eztemplatedofunction.php:146
eZTemplateLoop
Code common for the loop functions in processed mode.
Definition: eztemplateloop.php:49
eZTemplateNodeTool\createVariableNode
static createVariableNode( $originalNode=false, $variableData=false, $variablePlacement=false, $parameters=array(), $variableAssignmentName=false, $onlyExisting=false, $overWrite=true, $assignFromVariable=false, $rememberSet=false)
Definition: eztemplatenodetool.php:395
eZTemplateNodeTool\createSpacingDecreaseNode
static createSpacingDecreaseNode( $spacing=4, $parameters=array())
Definition: eztemplatenodetool.php:508
eZTemplateNodeTool\createVariableUnsetNode
static createVariableUnsetNode( $variableName, $parameters=array())
Definition: eztemplatenodetool.php:462
eZTemplateNodeTool\createCodePieceNode
static createCodePieceNode( $codePiece, $parameters=array())
Definition: eztemplatenodetool.php:457
eZTemplateNodeTool\createSpacingIncreaseNode
static createSpacingIncreaseNode( $spacing=4, $parameters=array())
Definition: eztemplatenodetool.php:503
eZTemplateNodeTool\extractFunctionNodePlacement
static extractFunctionNodePlacement(&$node)
Definition: eztemplatenodetool.php:660
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.