Exemplo n.º 1
0
    function templateNodeTransformation( $functionName, &$node,
                                         $tpl, $parameters, $privateData )
    {
        switch( $functionName )
        {
            case $this->SetName:
            case $this->DefaultName:
            case $this->LetName:
            {
                $scope = eZTemplate::NAMESPACE_SCOPE_RELATIVE;
                if ( isset( $parameters['-scope'] ) )
                {
                    if ( !eZTemplateNodeTool::isConstantElement( $parameters['-scope'] ) )
                        return false;
                    $scopeText = eZTemplateNodeTool::elementConstantValue( $parameters['-scope'] );
                    if ( $scopeText == 'relative' )
                        $scope = eZTemplate::NAMESPACE_SCOPE_RELATIVE;
                    else if ( $scopeText == 'root' )
                        $scope = eZTemplate::NAMESPACE_SCOPE_LOCAL;
                    else if ( $scopeText == 'global' )
                        $scope = eZTemplate::NAMESPACE_SCOPE_GLOBAL;
                }

                $parameters = eZTemplateNodeTool::extractFunctionNodeParameters( $node );
                $namespaceValue = false;
                if ( isset( $parameters['-name'] ) )
                {
                    if ( !eZTemplateNodeTool::isConstantElement( $parameters['-name'] ) )
                    {
                        return false;
                    }

                    $namespaceValue = eZTemplateNodeTool::elementConstantValue( $parameters['-name'] );
                }

                $variableList = array();
                $setVarNodes = array();
                foreach ( array_keys( $parameters ) as $parameterName )
                {
                    if ( $parameterName == '-name' or $parameterName == '-scope'  )
                    {
                        continue;
                    }

                    $parameterData =& $parameters[$parameterName];

                    $setVarNodes[] = eZTemplateNodeTool::createVariableNode(
                            false, $parameterData, eZTemplateNodeTool::extractFunctionNodePlacement( $node ),
                            array(), array( $namespaceValue, $scope, $parameterName ),
                            ( $functionName == $this->SetName ), ( $functionName != $this->DefaultName ),
                            false, ( $functionName == $this->DefaultName ) );

                    if ( $functionName == $this->LetName or $functionName == $this->DefaultName )
                    {
                        $variableList[] = $parameterName;
                    }
                }

                if ( ( $functionName == $this->LetName or $functionName == $this->DefaultName ) and
                     $namespaceValue )
                {
                    $setVarNodes[] = eZTemplateNodeTool::createNamespaceChangeNode( $namespaceValue );
                }

                if ( $functionName == $this->LetName or $functionName == $this->DefaultName )
                {
                    $childNodes = eZTemplateNodeTool::extractFunctionNodeChildren( $node );
                    if ( !is_array( $childNodes ) )
                    {
                        $childNodes = array();
                    }
                }
                else
                {
                    $childNodes = array();
                }

                $unsetVarNodes = array();

                if ( ( $functionName == $this->LetName or $functionName == $this->DefaultName ) and
                     $namespaceValue )
                {
                    $unsetVarNodes[] = eZTemplateNodeTool::createNamespaceRestoreNode();
                }

                if ( $functionName == $this->LetName or $functionName == $this->DefaultName )
                {
                    foreach( $variableList as $parameterName )
                    {
                        $unsetVarNodes[] = eZTemplateNodeTool::createVariableUnsetNode( array( $namespaceValue,
                                                                                               eZTemplate::NAMESPACE_SCOPE_RELATIVE,
                                                                                               $parameterName ),
                                                                                        array( 'remember_set' => $functionName == $this->DefaultName ) );
                    }
                }

                return array_merge( $setVarNodes, $childNodes, $unsetVarNodes );
            } break;
        }

    }
 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $newNodes = array();
     $namespaceValue = false;
     $varName = 'match';
     if (!isset($parameters['match'])) {
         return false;
     }
     if (isset($parameters['name'])) {
         $nameData = $parameters['name'];
         if (!eZTemplateNodeTool::isConstantElement($nameData)) {
             return false;
         }
         $namespaceValue = eZTemplateNodeTool::elementConstantValue($nameData);
     }
     if (isset($parameters['var'])) {
         $varData = $parameters['var'];
         if (!eZTemplateNodeTool::isConstantElement($varData)) {
             return false;
         }
         $varName = eZTemplateNodeTool::elementConstantValue($varData);
     }
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['match'], false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $varName));
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['match'], eZTemplateNodeTool::extractFunctionNodePlacement($node), array('variable-name' => 'match', 'text-result' => true), 'match');
     //                                                                       'text-result' => false ) );
     if (isset($parameters['name'])) {
         $newNodes[] = eZTemplateNodeTool::createNamespaceChangeNode($parameters['name']);
     }
     $tmpNodes = array();
     $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
     $caseNodes = array();
     $caseCounter = 1;
     if (is_array($children)) {
         foreach ($children as $child) {
             $childType = $child[0];
             if ($childType == eZTemplate::NODE_FUNCTION) {
                 if ($this->templateNodeCaseTransformation($tpl, $tmpNodes, $caseNodes, $caseCounter, $child, $privateData) === false) {
                     return false;
                 }
             }
         }
     }
     $newNodes = array_merge($newNodes, $tmpNodes);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("switch ( \$match )\n{");
     $newNodes = array_merge($newNodes, $caseNodes);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}");
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode('match');
     if (isset($parameters['name'])) {
         $newNodes[] = eZTemplateNodeTool::createNamespaceRestoreNode();
     }
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode(array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, 'match'));
     return $newNodes;
 }
Exemplo n.º 3
0
 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $useLastValue = false;
     if (isset($parameters['last-value']) and !eZTemplateNodeTool::isConstantElement($parameters['last-value'])) {
         return false;
     }
     if (isset($parameters['name']) and !eZTemplateNodeTool::isConstantElement($parameters['name'])) {
         return false;
     }
     if (isset($parameters['var']) and !eZTemplateNodeTool::isConstantElement($parameters['var'])) {
         return false;
     }
     if (isset($parameters['reverse']) and !eZTemplateNodeTool::isConstantElement($parameters['reverse'])) {
         return false;
     }
     $varName = false;
     if (isset($parameters['var'])) {
         $varName = eZTemplateNodeTool::elementConstantValue($parameters['var']);
     }
     if (isset($parameters['last-value'])) {
         $useLastValue = (bool) eZTemplateNodeTool::elementConstantValue($parameters['last-value']);
     }
     if (!$varName) {
         $useLastValue = false;
     }
     $reverseLoop = false;
     if (isset($parameters['reverse'])) {
         $reverseLoop = eZTemplateNodeTool::elementConstantValue($parameters['reverse']);
     }
     $useLoop = isset($parameters['loop']);
     $allowLoop = true;
     $newNodes = array();
     $maxText = "false";
     $useMax = false;
     $maxPopText = false;
     if (isset($parameters['max'])) {
         if (eZTemplateNodeTool::isConstantElement($parameters['max'])) {
             $maxValue = eZTemplateNodeTool::elementConstantValue($parameters['max']);
             if ($maxValue > 0) {
                 $maxText = eZPHPCreator::variableText($maxValue);
                 $useMax = true;
             } else {
                 return array(eZTemplateNodeTool::createTextNode(''));
             }
         } else {
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['max'], eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), 'max');
             $maxText = "\$max";
             $maxPopText = ", \$max";
             $useMax = true;
         }
     }
     // Controls whether the 'if' statement with brackets is added
     $useShow = false;
     // Controls whether main nodes are handled, also controls delimiter and filters
     $useMain = true;
     // Controls wether else nodes are handled
     $useElse = false;
     $spacing = 0;
     if (isset($parameters['show'])) {
         if (eZTemplateNodeTool::isConstantElement($parameters['show'])) {
             $showValue = eZTemplateNodeTool::elementConstantValue($parameters['show']);
             if ($showValue) {
                 $useMain = true;
                 $useElse = false;
                 $useShow = false;
             } else {
                 $useMain = false;
                 $useElse = true;
                 $useShow = false;
             }
             $newNodes[] = eZTemplateNodeTool::createTextNode('');
         } else {
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['show'], eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), 'show');
             $spacing = 4;
             $useElse = true;
             $useShow = true;
         }
     }
     $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
     if ($useShow) {
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \$show )\n{\n");
         $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode($spacing);
         $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode('show');
     }
     if (isset($parameters['name']) and !$useLoop) {
         $newNodes[] = eZTemplateNodeTool::createNamespaceChangeNode($parameters['name']);
     }
     $mainNodes = eZTemplateNodeTool::extractNodes($children, array('match' => array('type' => 'before', 'matches' => array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => 'section-else')), 'filter' => array(array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => array('delimiter', 'section-exclude', 'section-include')))))));
     $delimiterNodes = eZTemplateNodeTool::extractNodes($children, array('match' => array('type' => 'equal', 'matches' => array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => 'delimiter')))));
     $filterNodes = eZTemplateNodeTool::extractNodes($children, array('match' => array('type' => 'equal', 'matches' => array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => array('section-exclude', 'section-include'))))));
     $delimiterNode = false;
     if (count($delimiterNodes) > 0) {
         $delimiterNode = $delimiterNodes[0];
     }
     if ($useMain) {
         // Avoid transformation if the nodes will not be used, saves time
         $mainNodes = eZTemplateCompiler::processNodeTransformationNodes($tpl, $node, $mainNodes, $privateData);
     }
     if ($useLoop and $useMain) {
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['loop'], eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), 'loopItem');
         $hasSequence = false;
         if (isset($parameters['sequence'])) {
             $sequenceParameter = $parameters['sequence'];
             $hasSequence = true;
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $sequenceParameter, eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), 'sequence');
         }
         if (isset($parameters['name'])) {
             $newNodes[] = eZTemplateNodeTool::createNamespaceChangeNode($parameters['name']);
         }
         $code = "if ( !isset( \$sectionStack ) )\n" . "    \$sectionStack = array();\n";
         $variableValuePushText = '';
         $variableValuePopText = '';
         if ($varName) {
             $code .= "\$variableValue = new eZTemplateSectionIterator();\n" . "\$lastVariableValue = false;\n";
             $variableValuePushText = "&\$variableValue, ";
             $variableValuePopText = "\$variableValue, ";
         }
         $code .= "\$index = 0;\n" . "\$currentIndex = 1;\n";
         $arrayCode = '';
         $numericCode = '';
         $stringCode = '';
         $offsetText = '0';
         if (isset($parameters['offset'])) {
             $offsetParameter = $parameters['offset'];
             if (eZTemplateNodeTool::isConstantElement($offsetParameter)) {
                 $iterationValue = (int) eZTemplateNodeTool::elementConstantValue($offsetParameter);
                 if ($iterationValue > 0) {
                     $arrayCode = "    \$loopKeys = array_splice( \$loopKeys, {$iterationValue} );\n";
                 }
                 $offsetText = $iterationValue;
             } else {
                 $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $offsetParameter, eZTemplateNodeTool::extractFunctionNodePlacement($node), array(), 'offset');
                 $arrayCode = "    if ( \$offset > 0 )\n" . "        \$loopKeys = array_splice( \$loopKeys, \$offset );\n";
                 $offsetText = "\$offset";
             }
         }
         // Initialization for array
         $code .= "if ( is_array( \$loopItem ) )\n{\n" . "    \$loopKeys = array_keys( \$loopItem );\n";
         if ($reverseLoop) {
             $code .= "    \$loopKeys = array_reverse( \$loopKeys );\n";
         }
         $code .= $arrayCode;
         $code .= "    \$loopCount = count( \$loopKeys );\n";
         $code .= "}\n";
         // Initialization for numeric
         $code .= "else if ( is_numeric( \$loopItem ) )\n{\n" . "    \$loopKeys = false;\n" . $numericCode . "    if ( \$loopItem < 0 )\n" . "        \$loopCountValue = -\$loopItem;\n" . "    else\n" . "        \$loopCountValue = \$loopItem;\n" . "    \$loopCount = \$loopCountValue - {$offsetText};\n" . "}\n";
         // Initialization for string
         $code .= "else if ( is_string( \$loopItem ) )\n{\n" . "    \$loopKeys = false;\n" . $stringCode . "    \$loopCount = strlen( \$loopItem ) - {$offsetText};\n" . "}\n";
         // Fallback for no item
         $code .= "else\n{\n" . "    \$loopKeys = false;\n" . "    \$loopCount = 0;\n" . "}";
         // Initialization end
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
         $code = "while ( \$index < \$loopCount )\n" . "{\n";
         if ($useMax) {
             $code .= "    if ( \$currentIndex > {$maxText} )\n" . "        break;\n" . "    unset( \$item );\n";
         }
         // Iterator check for array
         $code .= "    if ( is_array( \$loopItem ) )\n" . "    {\n" . "        \$loopKey = \$loopKeys[\$index];\n" . "        unset( \$item );\n" . "        \$item = \$loopItem[\$loopKey];\n" . "    }\n";
         // Iterator check for numeric
         $code .= "    else if ( is_numeric( \$loopItem ) )\n" . "    {\n" . "        unset( \$item );\n";
         if ($reverseLoop) {
             $code .= "        \$item = \$loopCountValue - \$index - {$offsetText};\n";
         } else {
             $code .= "        \$item = \$index + {$offsetText} + 1;\n";
         }
         $code .= "        if ( \$loopItem < 0 )\n" . "            \$item = -\$item;\n";
         if ($reverseLoop) {
             $code .= "        \$loopKey = \$loopCountValue - \$index - {$offsetText} - 1;\n";
         } else {
             $code .= "        \$loopKey = \$index + {$offsetText};\n";
         }
         $code .= "    }\n";
         // Iterator check for string
         $code .= "    else if ( is_string( \$loopItem ) )\n" . "    {\n" . "        unset( \$item );\n";
         if ($reverseLoop) {
             $code .= "        \$loopKey = \$loopCount - \$index - {$offsetText} + 1;\n";
         } else {
             $code .= "        \$loopKey = \$index + {$offsetText};\n";
         }
         $code .= "        \$item = \$loopItem[\$loopKey];\n" . "    }\n";
         // Iterator check end
         $code .= "    unset( \$last );\n" . "    \$last = false;\n";
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
         $code = '';
         if ($useLastValue) {
             $code .= "    if ( \$currentIndex > 1 )\n" . "    {\n" . "        \$last = \$lastVariableValue;\n" . "        \$variableValue = new eZTemplateSectionIterator();\n" . "    }\n";
         }
         if ($varName) {
             $code .= "    \$variableValue->setIteratorValues( \$item, \$loopKey, \$currentIndex - 1, \$currentIndex, false, \$last );";
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'variableValue', eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => 4), array('', eZTemplate::NAMESPACE_SCOPE_RELATIVE, $varName), false, true, true);
         } else {
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'loopKey', eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => 4), array('', eZTemplate::NAMESPACE_SCOPE_RELATIVE, 'key'), false, true, true);
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'item', eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => 4), array('', eZTemplate::NAMESPACE_SCOPE_RELATIVE, 'item'), false, true, true);
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\$currentIndexInc = \$currentIndex - 1;\n");
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'currentIndexInc', eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => 4), array('', eZTemplate::NAMESPACE_SCOPE_RELATIVE, 'index'), false, true, true);
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'currentIndex', eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => 4), array('', eZTemplate::NAMESPACE_SCOPE_RELATIVE, 'number'), false, true, true);
         }
         $mainSpacing = 0;
         $hasFilter = false;
         if (count($filterNodes) > 0) {
             $newFilterNodes = array();
             $matchValue = true;
             $hasDynamicFilter = false;
             foreach ($filterNodes as $filterNode) {
                 $filterParameters = eZTemplateNodeTool::extractFunctionNodeParameters($filterNode);
                 if (!isset($filterParameters['match'])) {
                     continue;
                 }
                 $hasFilter = true;
                 $filterParameterMatch = $filterParameters['match'];
                 $filterParameterMatch = eZTemplateCompiler::processElementTransformationList($tpl, $filterNode, $filterParameterMatch, $privateData);
                 if (eZTemplateNodeTool::isConstantElement($filterParameterMatch)) {
                     $matchValue = eZTemplateNodeTool::elementConstantValue($filterParameterMatch);
                     if (eZTemplateNodeTool::extractFunctionNodeName($filterNode) == 'section-exclude') {
                         if ($matchValue) {
                             $matchValue = false;
                         }
                     } else {
                         if ($matchValue) {
                             $matchValue = true;
                         }
                     }
                     $newFilterNodes = array();
                     $hasDynamicFilter = false;
                 } else {
                     $newFilterNodes[] = eZTemplateNodeTool::createVariableNode(false, $filterParameterMatch, eZTemplateNodeTool::extractFunctionNodePlacement($filterNode), array('spacing' => 4), 'tmpMatchValue');
                     if (eZTemplateNodeTool::extractFunctionNodeName($filterNode) == 'section-exclude') {
                         $newFilterNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \$tmpMatchValue )\n    \$matchValue = false;", array('spacing' => 4));
                     } else {
                         $newFilterNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \$tmpMatchValue )\n    \$matchValue = true;", array('spacing' => 4));
                     }
                     $hasDynamicFilter = true;
                 }
             }
             if ($hasFilter) {
                 $mainSpacing += 4;
                 $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $matchValue, eZTemplateNodeTool::extractFunctionNodePlacement($filterNode), array('spacing' => 4), 'matchValue');
                 if ($hasDynamicFilter) {
                     $newNodes = array_merge($newNodes, $newFilterNodes);
                 }
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \$matchValue )\n{\n", array('spacing' => 4));
             }
         }
         $sequencePopText = '';
         if ($hasSequence) {
             $sequencePopText = ", \$sequence";
             if ($varName) {
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( is_array( \$sequence ) )\n" . "{\n" . "    \$sequenceValue = array_shift( \$sequence );\n" . "    \$variableValue->setSequence( \$sequenceValue );\n" . "    \$sequence[] = \$sequenceValue;\n" . "    unset( \$sequenceValue );\n" . "}", array('spacing' => $mainSpacing + 4));
                 $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'variableValue', eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => 4), array('', eZTemplate::NAMESPACE_SCOPE_RELATIVE, $varName), false, true, true);
             } else {
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( is_array( \$sequence ) )\n" . "{\n" . "    \$sequenceValue = array_shift( \$sequence );\n", array('spacing' => $mainSpacing + 4));
                 $newNodes[] = eZTemplateNodeTool::createVariableNode(false, 'sequenceValue', eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => $mainSpacing + 4), array('', eZTemplate::NAMESPACE_SCOPE_RELATIVE, 'sequence'), false, true, true);
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("    \$sequence[] = \$sequenceValue;\n" . "    unset( \$sequenceValue );\n" . "}", array('spacing' => $mainSpacing + 4));
             }
         }
         $code = "\$sectionStack[] = array( " . $variableValuePushText . "&\$loopItem, \$loopKeys, \$loopCount, \$currentIndex, \$index" . $sequencePopText . $maxPopText . " );\n" . "unset( \$loopItem, \$loopKeys );\n";
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code, array('spacing' => $mainSpacing + 4));
         $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode($mainSpacing + 4);
         if ($delimiterNode) {
             $delimiterChildren = eZTemplateNodeTool::extractFunctionNodeChildren($delimiterNode);
             $delimiterParameters = eZTemplateNodeTool::extractFunctionNodeParameters($delimiterNode);
             $delimiterChildren = eZTemplateCompiler::processNodeTransformationNodes($tpl, $node, $delimiterChildren, $privateData);
             $delimiterModulo = false;
             $matchCode = false;
             $useModulo = true;
             if (isset($delimiterParameters['match'])) {
                 $delimiterMatch = $delimiterParameters['match'];
                 $delimiterMatch = eZTemplateCompiler::processElementTransformationList($tpl, $delimiterNode, $delimiterMatch, $privateData);
                 if (eZTemplateNodeTool::isConstantElement($delimiterMatch)) {
                     $moduloValue = eZTemplateNodeTool::elementConstantValue($delimiterMatch);
                     $useModulo = false;
                 } else {
                     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $delimiterMatch, eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => 0), 'matchValue');
                     $matchCode = " and \$matchValue";
                 }
             } else {
                 if (isset($delimiterParameters['modulo'])) {
                     $delimiterModulo = $delimiterParameters['modulo'];
                     $delimiterModulo = eZTemplateCompiler::processElementTransformationList($tpl, $delimiterModulo, $delimiterModulo, $privateData);
                     if (eZTemplateNodeTool::isConstantElement($delimiterModulo)) {
                         $moduloValue = (int) eZTemplateNodeTool::elementConstantValue($delimiterModulo);
                         $matchCode = " and ( ( \$currentIndex - 1 ) % {$moduloValue} ) == 0";
                     } else {
                         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $delimiterModulo, eZTemplateNodeTool::extractFunctionNodePlacement($node), array('spacing' => 0), 'moduloValue');
                         $matchCode = " and ( ( \$currentIndex - 1 ) % \$moduloValue ) == 0";
                     }
                 }
             }
             if ($useModulo) {
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \$currentIndex > 1{$matchCode} )\n{");
                 $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode(4);
                 $newNodes = array_merge($newNodes, $delimiterChildren);
                 $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode(4);
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}\n");
             }
         }
         $newNodes = array_merge($newNodes, $mainNodes);
         $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode($mainSpacing + 4);
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("list( " . $variableValuePopText . "\$loopItem, \$loopKeys, \$loopCount, \$currentIndex, \$index" . $sequencePopText . $maxPopText . " ) = array_pop( \$sectionStack );", array('spacing' => $mainSpacing + 4));
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("++\$currentIndex;\n", array('spacing' => $mainSpacing + 4));
         if ($varName) {
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\$lastVariableValue = \$variableValue;", array('spacing' => $mainSpacing + 4));
         }
         if ($hasFilter) {
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("    }");
             $mainSpacing -= 4;
         }
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("++\$index;\n", array('spacing' => $mainSpacing + 4));
         $code = "}\n" . "unset( \$loopKeys, \$loopCount, \$index, \$last, \$loopIndex, \$loopItem";
         if ($hasSequence) {
             $code .= ", \$sequence";
         }
         $code .= " );";
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
     } else {
         if ($useMain) {
             $newNodes = array_merge($newNodes, $mainNodes);
         }
     }
     if (isset($parameters['name'])) {
         $newNodes[] = eZTemplateNodeTool::createNamespaceRestoreNode();
     }
     if ($useShow) {
         $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode($spacing);
     }
     if ($useElse) {
         $elseNodes = eZTemplateNodeTool::extractNodes($children, array('match' => array('type' => 'after', 'matches' => array(array('match-keys' => array(0), 'match-with' => eZTemplate::NODE_FUNCTION), array('match-keys' => array(2), 'match-with' => 'section-else')))));
         $elseNodes = eZTemplateCompiler::processNodeTransformationNodes($tpl, $node, $elseNodes, $privateData);
         if (count($elseNodes) > 0) {
             if ($useShow) {
                 // This is needed if a 'if ( $show )' was used earlier
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}\nelse\n{\n");
                 $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode($spacing);
                 $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode('show');
             }
             if (isset($parameters['name'])) {
                 $newNodes[] = eZTemplateNodeTool::createNamespaceChangeNode($parameters['name']);
             }
             $newNodes = array_merge($newNodes, $elseNodes);
             if (isset($parameters['name'])) {
                 $newNodes[] = eZTemplateNodeTool::createNamespaceRestoreNode();
             }
             if ($useShow) {
                 // This is needed if a 'if ( $show )' was used earlier
                 $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode($spacing);
             }
         }
         if ($useShow) {
             // This is needed if a 'if ( $show )' was used earlier
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}\n");
         }
     }
     return $newNodes;
 }