本文整理匯總了PHP中eZTemplateNodeTool::createOutputVariableDecreaseNode方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZTemplateNodeTool::createOutputVariableDecreaseNode方法的具體用法?PHP eZTemplateNodeTool::createOutputVariableDecreaseNode怎麽用?PHP eZTemplateNodeTool::createOutputVariableDecreaseNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZTemplateNodeTool
的用法示例。
在下文中一共展示了eZTemplateNodeTool::createOutputVariableDecreaseNode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}