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


PHP eZTemplateNodeTool::createNamespaceRestoreNode方法代码示例

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


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

示例1: templateNodeTransformation

    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;
        }

//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:eztemplatesetfunction.php

示例2: templateNodeTransformation

 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;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:53,代码来源:eztemplateswitchfunction.php

示例3: templateNodeTransformation


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


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