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


PHP eZTemplateNodeTool::createOutputVariableIncreaseNode方法代码示例

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


在下文中一共展示了eZTemplateNodeTool::createOutputVariableIncreaseNode方法的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;
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:84,代码来源:eztemplatecachefunction.php


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