当前位置: 首页>>代码示例>>PHP>>正文


PHP eZTemplateCompiler::processElementTransformationList方法代码示例

本文整理汇总了PHP中eZTemplateCompiler::processElementTransformationList方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateCompiler::processElementTransformationList方法的具体用法?PHP eZTemplateCompiler::processElementTransformationList怎么用?PHP eZTemplateCompiler::processElementTransformationList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZTemplateCompiler的用法示例。


在下文中一共展示了eZTemplateCompiler::processElementTransformationList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: templateNodeCaseTransformation

    function templateNodeCaseTransformation( $tpl, &$newNodes, &$caseNodes, &$caseCounter, &$node, $privateData )
    {
        if ( $node[2] == 'case' )
        {
            if ( is_array( $node[3] ) && count( $node[3] ) )
            {
                if ( isset( $node[3]['match'] ) )
                {
                    $match = $node[3]['match'];
                    $match = eZTemplateCompiler::processElementTransformationList( $tpl, $node, $match, $privateData );

                    $dynamicCase = false;
                    if ( eZTemplateNodeTool::isConstantElement( $match ) )
                    {
                        $matchValue = eZTemplateNodeTool::elementConstantValue( $match );
                        $caseText = eZPHPCreator::variableText( $matchValue, 0, 0, false );
                    }
                    else
                    {
                        $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $match, false, array(), 'case' . $caseCounter );
                        $caseText = "\$case" . $caseCounter;
                        ++$caseCounter;
                        $dynamicCase = true;
                    }

                    $caseNodes[] = eZTemplateNodeTool::createCodePieceNode( "    case $caseText:\n    {" );
                    if ( $dynamicCase )
                        $caseNodes[] = eZTemplateNodeTool::createCodePieceNode( "        unset( $caseText );" );
                }
                else if ( isset( $node[3]['in'] ) )
                {
                    return false;
                }
            }
            else
            {
                $caseNodes[] = eZTemplateNodeTool::createCodePieceNode( "    default:\n    {" );
            }

            $children = eZTemplateNodeTool::extractFunctionNodeChildren( $node );
            if ( $children === false )
            {
                $children = array();
            }
            else
            {
                $children = eZTemplateCompiler::processNodeTransformationNodes( $tpl, $node, $children, $privateData );
            }

            $caseNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode( 8 );

            $caseNodes = array_merge( $caseNodes, $children );
            $caseNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode( 8 );

            $caseNodes[] = eZTemplateNodeTool::createCodePieceNode( "    } break;" );
        }
    }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:57,代码来源:eztemplateswitchfunction.php

示例2: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $tpl->ElseifCounter++;
     $newNodes = array();
     $nodesToPrepend = array();
     $nodesToAppend = array();
     $nodePlacement = eZTemplateNodeTool::extractFunctionNodePlacement($node);
     $uniqid = md5($nodePlacement[2]) . "_" . $tpl->ElseifCounter;
     $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("// if begins");
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['condition'], $nodePlacement, array('treat-value-as-non-object' => true), 'if_cond');
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \$if_cond )\n{");
     $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
     if (is_array($children)) {
         foreach (array_keys($children) as $childKey) {
             $child =& $children[$childKey];
             if ($child[0] == eZTemplate::NODE_FUNCTION) {
                 $childFunctionName =& $child[2];
                 $childChildren = eZTemplateNodeTool::extractFunctionNodeChildren($child);
                 $childFunctionArgs =& $child[3];
                 if ($childFunctionName == 'elseif') {
                     $compiledElseifCondition = eZTemplateCompiler::processElementTransformationList($tpl, $child, $childFunctionArgs['condition'], $privateData);
                     $nodesToPrepend[] = eZTemplateNodeTool::createVariableNode(false, $compiledElseifCondition, $nodePlacement, array('text-result' => true), "elseif_cond_{$uniqid}");
                     $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
                     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}\nelseif ( \$elseif_cond_{$uniqid} )\n{");
                     $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
                     $nodesToAppend[] = eZTemplateNodeTool::createVariableUnsetNode("elseif_cond_{$uniqid}");
                     // increment unique elseif counter
                     $uniqid = md5($nodePlacement[2]) . "_" . ++$tpl->ElseifCounter;
                 } elseif ($childFunctionName == 'else') {
                     $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
                     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}\nelse\n{");
                     $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
                 } elseif ($childFunctionName == 'break') {
                     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("break;\n");
                 } elseif ($childFunctionName == 'continue') {
                     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("continue;\n");
                 } elseif ($childFunctionName == 'skip') {
                     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\$skipDelimiter = true;\ncontinue;\n");
                 }
                 // let other functions (ones not listed in the conditions above) be transformed
                 if (in_array($childFunctionName, array('elseif', 'else', 'break', 'continue', 'skip'))) {
                     continue;
                 }
             }
             $newNodes[] = $child;
         }
     }
     $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("unset( \$if_cond );");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("// if ends\n");
     $newNodes = array_merge($nodesToPrepend, $newNodes, $nodesToAppend);
     return $newNodes;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:55,代码来源:eztemplateiffunction.php

示例3: templateNodeTransformation


//.........这里部分代码省略.........
         }
         $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));
             }
         }
开发者ID:legende91,项目名称:ez,代码行数:67,代码来源:eztemplatesectionfunction.php

示例4: processChildren

    function processChildren()
    {
        // process the loop body
        $children            = eZTemplateNodeTool::extractFunctionNodeChildren( $this->Node );
        $transformedChildren = eZTemplateCompiler::processNodeTransformationNodes( $this->Tpl, $this->Node, $children, $this->PrivateData );

        $childrenNodes = array();
        $delimiter = null;

        if ( is_array( $transformedChildren ) )
        {
            foreach ( $transformedChildren as $child )
            {
                if ( $child[0] == eZTemplate::NODE_FUNCTION ) // check child type
                {
                    $childFunctionName = $child[2];
                    if ( $childFunctionName == 'delimiter' )
                    {
                        // save delimiter for it to be processed below
                        $delimiter = $child;
                        continue;
                    }
                    elseif ( $childFunctionName == 'break' )
                    {
                        $childrenNodes[] = eZTemplateNodeTool::createCodePieceNode( "break;\n" );
                        continue;
                    }
                    elseif ( $childFunctionName == 'continue' )
                    {
                        $childrenNodes[] = eZTemplateNodeTool::createCodePieceNode( "continue;\n" );
                        continue;
                    }
                    elseif ( $childFunctionName == 'skip' )
                    {
                        $childrenNodes[] = eZTemplateNodeTool::createCodePieceNode( "\$skipDelimiter = true;\ncontinue;\n" );
                        continue;
                    }
                }

                $childrenNodes[] = $child;
            }
        }

        if ( $delimiter ) // if delimiter is specified
        {
            $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' ) ) ) ) );
            $delimiterNode = false;
            if ( count( $delimiterNodes ) > 0 )
                $delimiterNode = $delimiterNodes[0];

            $delimiterChildren = eZTemplateNodeTool::extractFunctionNodeChildren( $delimiterNode );
            $delimiterParameters = eZTemplateNodeTool::extractFunctionNodeParameters( $delimiterNode );

            $checkModulo = array();
            $checkModuloEnd = array();
            $delemiterModuloValue = array();
            if ( isset( $delimiterParameters['modulo'] ) )
            {
                switch ( $this->Name )
                {
                    case 'foreach':
                    {
                        $delimiterModulo = $delimiterParameters['modulo'];
                        $delimiterModulo = eZTemplateCompiler::processElementTransformationList( $this->Tpl, $delimiterModulo, $delimiterModulo, $this->PrivateData );
                        // Get unique index
                        $currentIndex = "\$fe_i_$this->UniqID";

                        if ( eZTemplateNodeTool::isConstantElement( $delimiterModulo ) )
                        {
                            $moduloValue = (int)eZTemplateNodeTool::elementConstantValue( $delimiterModulo );
                            $matchCode = "( ( $currentIndex ) % $moduloValue ) == 0";
                        }
                        else
                        {
                            $delemiterModuloValue[] = eZTemplateNodeTool::createVariableNode( false, $delimiterModulo, eZTemplateNodeTool::extractFunctionNodePlacement( $this->Node ),
                                                                                        array( 'spacing' => 0 ), 'moduloValue' );
                            $matchCode = "( ( $currentIndex ) % \$moduloValue ) == 0";
                        }
                        $checkModulo[] = eZTemplateNodeTool::createCodePieceNode( "if ( $matchCode ) // Check modulo\n{" );
                        $checkModulo[] = eZTemplateNodeTool::createSpacingIncreaseNode( 4 );

                        $checkModuloEnd[] = eZTemplateNodeTool::createSpacingDecreaseNode( 4 );
                        $checkModuloEnd[] = eZTemplateNodeTool::createCodePieceNode( "}\n" );
                    }
                }
            }
            $delimiterNodes = array();
            $delimiterNodes[] = eZTemplateNodeTool::createCodePieceNode( "if ( \$skipDelimiter )\n" .
                                                                         "    \$skipDelimiter = false;\n" .
                                                                         "else\n" .
                                                                         "{ // delimiter begins" );
            $delimiterNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
            if ( is_array( $delimiter[1] ) ) // if delimiter has children
            {
                // If modulo is specified
//.........这里部分代码省略.........
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:101,代码来源:eztemplatecompiledloop.php


注:本文中的eZTemplateCompiler::processElementTransformationList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。