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