本文整理汇总了PHP中eZTemplateNodeTool::extractFunctionNodeChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP eZTemplateNodeTool::extractFunctionNodeChildren方法的具体用法?PHP eZTemplateNodeTool::extractFunctionNodeChildren怎么用?PHP eZTemplateNodeTool::extractFunctionNodeChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZTemplateNodeTool
的用法示例。
在下文中一共展示了eZTemplateNodeTool::extractFunctionNodeChildren方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: templateNodeTransformation
function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
{
$ini = eZINI::instance();
$children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
if ($ini->variable('TemplateSettings', 'TemplateCache') != 'enabled') {
return $children;
}
$functionPlacement = eZTemplateNodeTool::extractFunctionNodePlacement($node);
$placementKeyString = eZTemplateCacheBlock::placementString($functionPlacement);
$newNodes = array();
$ignoreContentExpiry = false;
if (isset($parameters['expiry'])) {
if (eZTemplateNodeTool::isConstantElement($parameters['expiry'])) {
$expiryValue = eZTemplateNodeTool::elementConstantValue($parameters['expiry']);
$ttlCode = $expiryValue > 0 ? eZPHPCreator::variableText($expiryValue, 0, 0, false) : 'null';
} else {
$newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['expiry'], false, array(), 'localExpiry');
$ttlCode = "( \$localExpiry > 0 ? \$localExpiry : null )";
}
} else {
$ttlCode = eZPHPCreator::variableText(self::DEFAULT_TTL, 0, 0, false);
}
if (isset($parameters['ignore_content_expiry'])) {
$ignoreContentExpiry = eZTemplateNodeTool::elementConstantValue($parameters['ignore_content_expiry']);
}
$keysData = false;
$hasKeys = false;
$subtreeExpiryData = null;
$subtreeValue = null;
if (isset($parameters['keys'])) {
$keysData = $parameters['keys'];
$hasKeys = true;
}
if (isset($parameters['subtree_expiry'])) {
$subtreeExpiryData = $parameters['subtree_expiry'];
if (!eZTemplateNodeTool::isConstantElement($subtreeExpiryData)) {
$hasKeys = true;
} else {
$subtreeValue = eZTemplateNodeTool::elementConstantValue($subtreeExpiryData);
}
$ignoreContentExpiry = true;
}
$accessName = false;
if (isset($GLOBALS['eZCurrentAccess']['name'])) {
$accessName = $GLOBALS['eZCurrentAccess']['name'];
}
if ($hasKeys) {
$placementKeyStringText = eZPHPCreator::variableText($placementKeyString, 0, 0, false);
$accessNameText = eZPHPCreator::variableText($accessName, 0, 0, false);
$newNodes[] = eZTemplateNodeTool::createVariableNode(false, $keysData, false, array(), 'cacheKeys');
$newNodes[] = eZTemplateNodeTool::createVariableNode(false, $subtreeExpiryData, false, array(), 'subtreeExpiry');
$code = "\$cacheKeys = array( \$cacheKeys, {$placementKeyStringText}, {$accessNameText} );\n";
$cachePathText = "\$cachePath";
} else {
$nodeID = $subtreeValue ? eZTemplateCacheBlock::decodeNodeID($subtreeValue) : false;
$cachePath = eZTemplateCacheBlock::cachePath(eZTemplateCacheBlock::keyString(array($placementKeyString, $accessName)), $nodeID);
$code = "";
$cachePathText = eZPHPCreator::variableText($cachePath, 0, 0, false);
}
$newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
$code = '';
$codePlacementHash = md5($placementKeyString);
if ($hasKeys) {
$code .= "list(\$cacheHandler_{$codePlacementHash}, \$contentData) =\n eZTemplateCacheBlock::retrieve( \$cacheKeys, \$subtreeExpiry, {$ttlCode}, " . ($ignoreContentExpiry ? "false" : "true") . " );\n";
} else {
$nodeIDText = var_export($nodeID, true);
$code .= "list(\$cacheHandler_{$codePlacementHash}, \$contentData) =\n eZTemplateCacheBlock::handle( {$cachePathText}, {$nodeIDText}, {$ttlCode}, " . ($ignoreContentExpiry ? "false" : "true") . " );\n";
}
$code .= "if ( !( \$contentData instanceof eZClusterFileFailure ) )\n" . "{\n";
$newNodes[] = eZTemplateNodeTool::createCodePieceNode($code, array('spacing' => 0));
$newNodes[] = eZTemplateNodeTool::createWriteToOutputVariableNode('contentData', array('spacing' => 4));
$newNodes[] = eZTemplateNodeTool::createCodePieceNode(" unset( \$contentData );\n" . "}\n" . "else\n" . "{\n" . " unset( \$contentData );");
$newNodes[] = eZTemplateNodeTool::createOutputVariableIncreaseNode(array('spacing' => 4));
$newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode(4);
$newNodes = array_merge($newNodes, $children);
$newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode(4);
$newNodes[] = eZTemplateNodeTool::createAssignFromOutputVariableNode('cachedText', array('spacing' => 4));
$code = "\$cacheHandler_{$codePlacementHash}->storeCache( array( 'scope' => 'template-block', 'binarydata' => \$cachedText ) );\n";
$newNodes[] = eZTemplateNodeTool::createCodePieceNode($code, array('spacing' => 4));
$newNodes[] = eZTemplateNodeTool::createOutputVariableDecreaseNode(array('spacing' => 4));
$newNodes[] = eZTemplateNodeTool::createWriteToOutputVariableNode('cachedText', array('spacing' => 4));
$newNodes[] = eZTemplateNodeTool::createCodePieceNode(" unset( \$cachedText, \$cacheHandler_{$codePlacementHash} );\n}\n");
return $newNodes;
}
示例3: deflateFunctionNode
static function deflateFunctionNode(&$node, $preHook, $postHook)
{
$newNodes = array();
$children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
eZTemplateNodeTool::removeFunctionNodeChildren($node);
$preNode = $node;
$preHookParameters = array();
if (isset($preHook['parameters'])) {
$preHookParameters = $preHook['parameters'];
}
$preHookFunction = false;
if (isset($preHook['function'])) {
$preHookFunction = $preHook['function'];
}
eZTemplateNodeTool::createFunctionNodeHook($preNode, $preHook['name'], $preHookParameters, $preHookFunction);
if (isset($preHook['use-parameters']) and !$preHook['use-parameters']) {
eZTemplateNodeTool::removeFunctionNodeParameters($preNode);
}
$newNodes[] = $preNode;
$newNodes = array_merge($newNodes, $children);
$postNode = $node;
$postHookParameters = array();
if (isset($postHook['parameters'])) {
$postHookParameters = $postHook['parameters'];
}
$postHookFunction = false;
if (isset($postHook['function'])) {
$postHookFunction = $postHook['function'];
}
eZTemplateNodeTool::createFunctionNodeHook($postNode, $postHook['name'], $postHookParameters, $postHookFunction);
if (isset($postHook['use-parameters']) and !$postHook['use-parameters']) {
eZTemplateNodeTool::removeFunctionNodeParameters($postNode);
}
$newNodes[] = $postNode;
return $newNodes;
}
示例4: templateNodeTransformation
function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
{
if ($functionName == $this->TimingPointName) {
$id = false;
if (isset($parameters['id'])) {
if (!eZTemplateNodeTool::isConstantElement($parameters['id'])) {
return false;
}
$id = eZTemplateNodeTool::elementConstantValue($parameters['id']);
}
$newNodes = array();
$startDescription = "debug-timing-point START: {$id}";
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("eZDebug::addTimingPoint( " . var_export($startDescription, true) . " );");
$children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
$newNodes = array_merge($newNodes, $children);
$endDescription = "debug-timing-point END: {$id}";
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("eZDebug::addTimingPoint( " . var_export($endDescription, true) . " );");
return $newNodes;
} else {
if ($functionName == $this->AccumulatorName) {
$id = false;
if (isset($parameters['id'])) {
if (!eZTemplateNodeTool::isConstantElement($parameters['id'])) {
return false;
}
$id = eZTemplateNodeTool::elementConstantValue($parameters['id']);
}
$name = false;
if (isset($parameters['name'])) {
if (!eZTemplateNodeTool::isConstantElement($parameters['name'])) {
return false;
}
$name = eZTemplateNodeTool::elementConstantValue($parameters['name']);
}
// Assign a name (as $functionName) which will be used in the debug output.
$name = ($name === false and $id === false) ? $functionName : $name;
// To uniquely identify this accumulator.
$id = $id === false ? uniqID($functionName . '_') : $id;
$newNodes = array();
if ($name) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("eZDebug::accumulatorStart( " . var_export($id, true) . ", 'Debug-Accumulator', " . var_export($name, true) . " );");
} else {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("eZDebug::accumulatorStart( " . var_export($id, true) . ", 'Debug-Accumulator' );");
}
$children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
$newNodes = array_merge($newNodes, $children);
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("eZDebug::accumulatorStop( " . var_export($id, true) . " );");
return $newNodes;
} else {
if ($functionName == $this->LogName) {
$nodePlacement = eZTemplateNodeTool::extractFunctionNodePlacement($node);
$newNodes = array();
$varIsSet = $msgIsSet = false;
if (isset($parameters['var'])) {
$varIsSet = true;
$var = $parameters['var'];
}
if (isset($parameters['msg'])) {
$msgIsSet = true;
$msg = $parameters['msg'];
}
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("// debug-log starts\n");
if ($varIsSet) {
$newNodes[] = eZTemplateNodeTool::createVariableNode(false, $var, $nodePlacement, array('treat-value-as-non-object' => true), 'debug_log_var');
}
if ($msgIsSet) {
$newNodes[] = eZTemplateNodeTool::createVariableNode(false, $msg, $nodePlacement, array('treat-value-as-non-object' => true), 'debug_log_msg');
}
if ($varIsSet && $msgIsSet) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("eZDebug::writeDebug( \$debug_log_var, \$debug_log_msg );\n");
} elseif ($msgIsSet) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("eZDebug::writeDebug( \$debug_log_msg );\n");
} elseif ($varIsSet) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("eZDebug::writeDebug( \$debug_log_var );\n");
}
if ($varIsSet) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("unset( \$debug_log_var );");
}
if ($msgIsSet) {
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("unset( \$debug_log_msg );");
}
$newNodes[] = eZTemplateNodeTool::createCodePieceNode("// debug-log ends\n");
return $newNodes;
} else {
if ($functionName == $this->TraceName) {
$id = false;
if (isset($parameters['id'])) {
if (!eZTemplateNodeTool::isConstantElement($parameters['id'])) {
return false;
}
$id = eZTemplateNodeTool::elementConstantValue($parameters['id']);
}
if (!$id) {
$id = 'template-debug';
}
$newNodes = array();
$code = "if ( extension_loaded( 'xdebug' ) )\n" . "{\n" . "if ( file_exists( " . var_export($id . '.xt', true) . " ) )\n" . "{\n" . "\$fd = fopen( " . var_export($id . '.xt', true) . ", 'w' ); fclose( \$fd ); unset( \$fd );\n" . "}\n" . "xdebug_start_trace( " . var_export($id, true) . " );\n" . "}\n";
$newNodes[] = eZTemplateNodeTool::createCodePieceNode($code);
$children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
$newNodes = array_merge($newNodes, $children);
//.........这里部分代码省略.........
示例5: 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;
}
示例6: 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;
}
//.........这里部分代码省略.........
示例7: 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');
//.........这里部分代码省略.........
示例8: 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
//.........这里部分代码省略.........