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


PHP eZTemplateCompiler::processNodeTransformationNodes方法代码示例

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


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

示例1: templateNodeTransformation

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

示例2: 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:jordanmanning,项目名称:ezpublish,代码行数:41,代码来源:eztemplateswitchfunction.php

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