本文整理汇总了PHP中eZTemplateNodeTool::createNamespaceChangeNode方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateNodeTool::createNamespaceChangeNode方法的具体用法?PHP eZTemplateNodeTool::createNamespaceChangeNode怎么用?PHP eZTemplateNodeTool::createNamespaceChangeNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateNodeTool
的用法示例。
在下文中一共展示了eZTemplateNodeTool::createNamespaceChangeNode方法的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;
}
//.........这里部分代码省略.........
示例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;
}
示例3: 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');
//.........这里部分代码省略.........