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


PHP eZTemplateNodeTool类代码示例

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


在下文中一共展示了eZTemplateNodeTool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $newNodes = array();
     if ($functionName == $this->LName) {
         $newNodes = array(eZTemplateNodeTool::createTextNode($tpl->leftDelimiter()));
     } else {
         $newNodes = array(eZTemplateNodeTool::createTextNode($tpl->rightDelimiter()));
     }
     return $newNodes;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:10,代码来源:eztemplatedelimitfunction.php

示例2: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, &$resourceData, $parameters, $namespaceValue)
 {
     if ($this->Name != 'file') {
         return false;
     }
     $file = $resourceData['template-name'];
     if (!file_exists($file)) {
         return false;
     }
     $newNodes = array();
     $newNodes[] = eZTemplateNodeTool::createResourceAcquisitionNode($resourceData['resource'], $file, $file, eZTemplate::RESOURCE_FETCH, false, $node[4], array(), $namespaceValue);
     return $newNodes;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:13,代码来源:eztemplatefileresource.php

示例3: nl2brTransformation

 function nl2brTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     $values = array();
     $function = $operatorName;
     if (count($parameters) != 1) {
         return false;
     }
     $newElements = array();
     $values[] = $parameters[0];
     $code = "%output% = nl2br( %1% );\n";
     $newElements[] = eZTemplateNodeTool::createCodePieceElement($code, $values);
     return $newElements;
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:13,代码来源:eztemplatenl2broperator.php

示例4: phpOperatorTransformation

 function phpOperatorTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     $values = array();
     $function = $operatorName;
     if (!isset($parameters[0])) {
         return false;
     }
     $newElements = array();
     $phpname = $this->PHPNames[$operatorName];
     $values[] = $parameters[0];
     $code = "%output% = {$phpname}( %1% );\n";
     $newElements[] = eZTemplateNodeTool::createCodePieceElement($code, $values);
     return $newElements;
 }
开发者ID:legende91,项目名称:ez,代码行数:14,代码来源:eztemplatephpoperator.php

示例5: preferencesTransformation

 function preferencesTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     if (count($parameters[0]) == 0) {
         return false;
     }
     $values = array();
     if (eZTemplateNodeTool::isConstantElement($parameters[0])) {
         $name = eZTemplateNodeTool::elementConstantValue($parameters[0]);
         $nameText = eZPHPCreator::variableText($name, 0, 0, false);
     } else {
         $nameText = '%1%';
         $values[] = $parameters[0];
     }
     return array(eZTemplateNodeTool::createCodePieceElement("%output% = eZPreferences::value( {$nameText} );\n", $values));
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:15,代码来源:ezkerneloperator.php

示例6: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, &$parameters, $privateData)
 {
     // {while <condition> [sequence <sequence_array> as $<sequence_var>]}
     $tpl->WhileCounter++;
     $newNodes = array();
     $nodePlacement = eZTemplateNodeTool::extractFunctionNodePlacement($node);
     $uniqid = md5($nodePlacement[2]) . "_" . $tpl->WhileCounter;
     $loop = new eZTemplateCompiledLoop(eZTemplateWhileFunction::FUNCTION_NAME, $newNodes, $parameters, $nodePlacement, $uniqid, $node, $tpl, $privateData);
     $loop->initVars();
     // loop header
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("while ( 1 ) // while\n{");
     $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['condition'], $nodePlacement, array('treat-value-as-non-object' => true), "while_cond");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( ! \$while_cond ) break;\n");
     $loop->processBody();
     // loop footer
     $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("} // end of while\n");
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode('while_cond');
     $loop->cleanup();
     return $newNodes;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:22,代码来源:eztemplatewhilefunction.php

示例7: hashTransformation

 function hashTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     if (count($parameters) != 1) {
         return false;
     }
     $code = '';
     $function = '';
     $newElements = array();
     $values = array($parameters[0]);
     switch ($operatorName) {
         case 'crc32':
             $function = "eZSys::ezcrc32";
             break;
         case 'rot13':
             $function = 'str_rot13';
             break;
         default:
             $function = $operatorName;
             break;
     }
     $code .= "%output% = {$function}( %1% );\n";
     $newElements[] = eZTemplateNodeTool::createCodePieceElement($code, $values);
     return $newElements;
 }
开发者ID:netbliss,项目名称:ezpublish,代码行数:24,代码来源:eztemplatedigestoperator.php

示例8: applyQuotes

 function applyQuotes($text, &$parameter, $onlyQuote = false)
 {
     $quote = "\"";
     if ($parameter != null) {
         $val = eZTemplateNodeTool::elementStaticValue($parameter);
         if ($val == 'single') {
             $quote = "'";
         } else {
             if ($val == 'no') {
                 $quote = false;
             }
         }
     }
     if ($onlyQuote) {
         return $quote;
     }
     $http = eZHTTPTool::instance();
     if (isset($http->UseFullUrl) and $http->UseFullUrl and strncasecmp($text, '/', 1) === 0) {
         $text = $http->createRedirectUrl($text, array('pre_url' => false));
     }
     if ($quote !== false) {
         return $quote . $text . $quote;
     }
     return $text;
 }
开发者ID:stevoland,项目名称:ez_patch,代码行数:25,代码来源:ezurloperator.php

示例9: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     $newNodes = array();
     $namespaceValue = false;
     $varName = 'match';
     if (!isset($parameters['name'])) {
         return false;
     }
     if (!eZTemplateNodeTool::isStaticElement($parameters['name'])) {
         return false;
     }
     $nameData = $parameters['name'];
     $nameValue = eZTemplateNodeTool::elementStaticValue($nameData);
     $nameSpaceNode = eZTemplateNodeTool::createCodePieceNode("\$namespace = \$rootNamespace;\nif ( \$namespace == '' )\n    \$namespace = \"{$nameValue}\";\nelse\n    \$namespace .= ':{$nameValue}';\n");
     if (isset($parameters['loop'])) {
         $loopData = $parameters['loop'];
         if (!eZTemplateNodeTool::isStaticElement($loopData)) {
             return false;
         }
         $loopValue = eZTemplateNodeTool::elementStaticValue($loopData);
         $newNodes = $this->templateNodeSequenceCreate($node, $tpl, $parameters, $nameValue, $loopValue);
     } else {
         $newNodes = $this->templateNodeSequenceIterate($node, $tpl, $parameters, $nameValue);
     }
     $retNodes = array_merge(array($nameSpaceNode), $newNodes);
     return $retNodes;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:27,代码来源:eztemplatesequencefunction.php

示例10: 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);
//.........这里部分代码省略.........
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:101,代码来源:eztemplatedebugfunction.php

示例11: operatorTransform

 function operatorTransform($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     if (!eZTemplateNodeTool::isConstantElement($parameters[1]) || count($parameters) > 2 && !eZTemplateNodeTool::isConstantElement($parameters[2])) {
         return false;
     }
     // We do not support non-static values for decimal_count, decimal_symbol and thousands_separator
     if (count($parameters) > 3 and !eZTemplateNodeTool::isConstantElement($parameters[3])) {
         return false;
     }
     if (count($parameters) > 4 and !eZTemplateNodeTool::isConstantElement($parameters[4])) {
         return false;
     }
     if (count($parameters) > 5 and !eZTemplateNodeTool::isConstantElement($parameters[5])) {
         return false;
     }
     $locale = eZLocale::instance();
     $decimalCount = $locale->decimalCount();
     $decimalSymbol = $locale->decimalSymbol();
     $decimalThousandsSeparator = $locale->thousandsSeparator();
     if (count($parameters) > 2) {
         $prefix = eZTemplateNodeTool::elementConstantValue($parameters[2]);
     } else {
         $prefix = 'auto';
     }
     if (count($parameters) > 3) {
         $decimalCount = eZTemplateNodeTool::elementConstantValue($parameters[3]);
     } elseif ($prefix == 'none') {
         $decimalCount = 0;
     }
     if (count($parameters) > 4) {
         $decimalSymbol = eZTemplateNodeTool::elementConstantValue($parameters[4]);
     }
     if (count($parameters) > 5) {
         $decimalThousandsSeparator = eZTemplateNodeTool::elementConstantValue($parameters[5]);
     }
     $decimalSymbolText = eZPHPCreator::variableText($decimalSymbol, 0, 0, false);
     $decimalThousandsSeparatorText = eZPHPCreator::variableText($decimalThousandsSeparator, 0, 0, false);
     $unit = eZTemplateNodeTool::elementConstantValue($parameters[1]);
     $ini = eZINI::instance();
     if ($prefix == "auto") {
         $prefixes = $ini->variableArray("UnitSettings", "BinaryUnits");
         if (in_array($unit, $prefixes)) {
             $prefix = "binary";
         } else {
             $prefix = "decimal";
         }
     }
     $unit_ini = eZINI::instance("units.ini");
     $use_si = $ini->variable("UnitSettings", "UseSIUnits") == "true";
     $fake = $use_si ? "" : "Fake";
     if ($unit_ini->hasVariable("Base", $unit)) {
         $base = $unit_ini->variable("Base", $unit);
     }
     $hasInput = false;
     $output = false;
     if (eZTemplateNodeTool::isConstantElement($parameters[0])) {
         $output = eZTemplateNodeTool::elementConstantValue($parameters[0]);
         $hasInput = true;
     }
     $prefix_var = "";
     if ($prefix == "decimal") {
         $prefixes = $unit_ini->group("DecimalPrefixes");
         $prefix_group = $unit_ini->group("DecimalPrefixes");
         $prefixes = array();
         foreach ($prefix_group as $prefix_item) {
             $prefixes[] = explode(";", $prefix_item);
         }
         usort($prefixes, "eZTemplateUnitCompareFactor");
         $prefix_var = "";
         if ($hasInput) {
             if ($output >= 0 and $output < 10) {
                 $prefix_var = '';
             } else {
                 foreach ($prefixes as $prefix) {
                     $val = pow(10, (int) $prefix[0]);
                     if ($val <= $output) {
                         $prefix_var = $prefix[1];
                         $output = number_format($output / $val, $decimalCount, $decimalSymbol, $decimalThousandsSeparator);
                         break;
                     }
                 }
             }
         } else {
             $values = array();
             $values[] = $parameters[0];
             $values[] = array(eZTemplateNodeTool::createArrayElement($prefixes));
             $values[] = array(eZTemplateNodeTool::createStringElement($base));
             $code = 'if ( %1% >= 0 and %1% < 10 )' . "\n" . '{' . "\n" . '    %tmp3% = \'\';' . "\n" . '}' . "\n" . 'else' . "\n" . '{' . "\n" . '    %tmp3% = "";' . "\n" . '    foreach ( %2% as %tmp1% )' . "\n" . '    {' . "\n" . '        %tmp2% = pow( 10, (int)%tmp1%[0] );' . "\n" . '        if ( %tmp2% <= %1% )' . "\n" . '        {' . "\n" . '            %tmp3% = %tmp1%[1];' . "\n" . '            %1% = number_format( %1% / %tmp2%, ' . $decimalCount . ', ' . $decimalSymbolText . ', ' . $decimalThousandsSeparatorText . ' );' . "\n" . '            break;' . "\n" . '        }' . "\n" . '    }' . "\n" . '}' . "\n" . '%output% = %1% . \' \' . %tmp3% . %3%;';
             return array(eZTemplateNodeTool::createCodePieceElement($code, $values, false, 3));
         }
     } else {
         if ($prefix == "binary") {
             $prefix_group = $unit_ini->group($fake . "BinaryPrefixes");
             $prefixes = array();
             foreach ($prefix_group as $prefix_item) {
                 $prefixes[] = explode(";", $prefix_item);
             }
             usort($prefixes, "eZTemplateUnitCompareFactor");
             $prefix_var = "";
             if ($hasInput) {
//.........这里部分代码省略.........
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:101,代码来源:eztemplateunitoperator.php

示例12: 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

示例13: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     /*
     {foreach <array> as [$keyVar =>] $itemVar
              [sequence <array> as $sequenceVar]
              [offset <offset>]
              [max <max>]
              [reverse]
     }
     */
     $tpl->ForeachCounter++;
     $newNodes = array();
     $nodePlacement = eZTemplateNodeTool::extractFunctionNodePlacement($node);
     $uniqid = md5($nodePlacement[2]) . "_" . $tpl->ForeachCounter;
     $loop = new eZTemplateCompiledLoop(eZTemplateForeachFunction::FUNCTION_NAME, $newNodes, $parameters, $nodePlacement, $uniqid, $node, $tpl, $privateData);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("// foreach begins");
     $loop->initVars();
     $array = "fe_array_{$uniqid}";
     $arrayKeys = "fe_array_keys_{$uniqid}";
     $nItems = "fe_n_items_{$uniqid}";
     $nItemsProcessed = "fe_n_items_processed_{$uniqid}";
     $i = "fe_i_{$uniqid}";
     $key = "fe_key_{$uniqid}";
     $val = "fe_val_{$uniqid}";
     $offset = "fe_offset_{$uniqid}";
     $max = "fe_max_{$uniqid}";
     $reverse = "fe_reverse_{$uniqid}";
     $firstVal = "fe_first_val_{$uniqid}";
     $lastVal = "fe_last_val_{$uniqid}";
     $variableStack = "fe_variable_stack_{$uniqid}";
     $namesArray = array($array, $arrayKeys, $nItems, $nItemsProcessed, $i, $key, $val, $offset, $max, $reverse, $firstVal, $lastVal);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( !isset( \${$variableStack} ) ) \${$variableStack} = array();");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\$" . $variableStack . "[] = compact( '" . implode("', '", $namesArray) . "' );");
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['array'], $nodePlacement, array('text-result' => false), $array);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$arrayKeys} = is_array( \${$array} ) ? array_keys( \${$array} ) : array();");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$nItems} = count( \${$arrayKeys} );");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$nItemsProcessed} = 0;");
     // process offset, max and reverse parameters
     if (isset($parameters['offset'])) {
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['offset'], $nodePlacement, array('text-result' => false), $offset);
     } else {
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$offset} = 0;");
     }
     if (isset($parameters['max'])) {
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['max'], $nodePlacement, array('text-result' => false), $max);
     } else {
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$max} = \${$nItems} - \${$offset};");
     }
     if (isset($parameters['reverse'])) {
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameters['reverse'], $nodePlacement, array('text-result' => false), $reverse);
     } else {
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$reverse} = false;");
     }
     // fix definitely incorrect offset
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \${$offset} < 0 || \${$offset} >= \${$nItems} )\n{\n" . "    \${$offset} = ( \${$offset} < 0 ) ? 0 : \${$nItems};\n" . "    if ( \${$nItems} || \${$offset} < 0 )\n {\n" . "        eZDebug::writeWarning(\"Invalid 'offset' parameter specified: '\${$offset}'. Array count: \${$nItems}\");   \n}\n}");
     // fix definitely incorrect max
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \${$max} < 0 || \${$offset} + \${$max} > \${$nItems} )\n{\n" . "    if ( \${$max} < 0 )\n eZDebug::writeWarning(\"Invalid 'max' parameter specified: \${$max}\");\n" . "    \${$max} = \${$nItems} - \${$offset};\n}");
     // initialize first and last indexes to iterate between them
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( \${$reverse} )\n" . "{\n" . "    \${$firstVal} = \${$nItems} - 1 - \${$offset};\n" . "    \${$lastVal}  = 0;\n" . "}\n" . "else\n" . "{\n" . "    \${$firstVal} = \${$offset};\n" . "    \${$lastVal}  = \${$nItems} - 1;\n" . "}");
     // generate loop header
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("// foreach");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("for ( \${$i} = \${$firstVal}; " . "\${$nItemsProcessed} < \${$max} && ( \${$reverse} ? \${$i} >= \${$lastVal} : \${$i} <= \${$lastVal} ); " . "\${$reverse} ? \${$i}-- : \${$i}++ )\n" . "{");
     $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$key} = \${$arrayKeys}[\${$i}];");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$val} = \${$array}[\${$key}];");
     // export $itemVar
     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, "{$val}", $nodePlacement, array(), $parameters['item_var'][0][1], false, true, true);
     // export $keyVar (if specified)
     if (isset($parameters['key_var'])) {
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, "{$key}", $nodePlacement, array(), $parameters['key_var'][0][1], false, true, true);
     }
     $loop->processBody();
     // generate loop footer
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\${$nItemsProcessed}++;");
     $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("} // foreach");
     $loop->cleanup();
     // unset the loop variables
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( count( \${$variableStack} ) ) extract( array_pop( \${$variableStack} ) );\n");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("else\n{\n");
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($array);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($arrayKeys);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($nItems);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($nItemsProcessed);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($i);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($key);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($val);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($offset);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($max);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($reverse);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($firstVal);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($lastVal);
     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode($variableStack);
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("}\n");
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("// foreach ends");
     return $newNodes;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:97,代码来源:eztemplateforeachfunction.php

示例14: concatTransformation

 function concatTransformation($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     $values = array();
     $function = $operatorName;
     if (count($parameters) < 1) {
         return false;
     }
     if (count($parameters) == 1 and eZTemplateNodeTool::isConstantElement($parameters[0])) {
         return array(eZTemplateNodeTool::createConstantElement(eZTemplateNodeTool::elementConstantValue($parameters[0])));
     }
     $newElements = array();
     $counter = 1;
     $code = "%output% = ( ";
     foreach ($parameters as $parameter) {
         $values[] = $parameter;
         if ($counter > 1) {
             $code .= ' . ';
         }
         $code .= "%{$counter}%";
         $counter++;
     }
     $code .= " );\n";
     $newElements[] = eZTemplateNodeTool::createCodePieceElement($code, $values);
     return $newElements;
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:25,代码来源:eztemplatetextoperator.php

示例15: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     if ($functionName != $this->IncludeName) {
         return false;
     }
     $parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
     if (!isset($parameters['uri'])) {
         return false;
     }
     $uriData = $parameters['uri'];
     if (!eZTemplateNodeTool::isConstantElement($uriData)) {
         return false;
     }
     $namespaceValue = false;
     $namespaceName = '$currentNamespace';
     if (isset($parameters['name'])) {
         $nameData = $parameters['name'];
         if (!eZTemplateNodeTool::isConstantElement($nameData)) {
             return false;
         }
         $namespaceValue = eZTemplateNodeTool::elementConstantValue($nameData);
         $namespaceName = '$namespace';
     }
     $uriString = eZTemplateNodeTool::elementConstantValue($uriData);
     $resourceName = "";
     $templateName = "";
     $resource = $tpl->resourceFor($uriString, $resourceName, $templateName);
     $resourceData = $tpl->resourceData($resource, $uriString, $resourceName, $templateName);
     $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled();
     $includeNodes = $resource->templateNodeTransformation($functionName, $node, $tpl, $resourceData, $parameters, $namespaceValue);
     if ($includeNodes === false) {
         return false;
     }
     $newNodes = array();
     $variableList = array();
     $uniqID = md5(uniqid('inc'));
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\$oldRestoreIncludeArray" . "_{$uniqID} = isset( \$restoreIncludeArray ) ? \$restoreIncludeArray : array();\n" . "\$restoreIncludeArray = array();\n");
     foreach (array_keys($parameters) as $parameterName) {
         if ($parameterName == 'uri' or $parameterName == 'name') {
             continue;
         }
         $parameterData =& $parameters[$parameterName];
         $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( isset( {$namespaceName} ) and isset( \$vars[{$namespaceName}]['{$parameterName}'] ) )\n" . "    \$restoreIncludeArray[] = array( {$namespaceName}, '{$parameterName}', \$vars[{$namespaceName}]['{$parameterName}'] );\n" . "elseif ( !isset( \$vars[( isset( {$namespaceName} ) ? {$namespaceName} : '' )]['{$parameterName}'] ) ) \n" . "    \$restoreIncludeArray[] = array( ( isset( {$namespaceName} ) ? {$namespaceName} : '' ), '{$parameterName}', 'unset' );\n");
         $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameterData, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName));
         $variableList[] = $parameterName;
     }
     $newNodes = array_merge($newNodes, $includeNodes);
     // Restore previous variables, before including
     $newNodes[] = eZTemplateNodeTool::createCodePieceNode("foreach ( \$restoreIncludeArray as \$element )\n" . "{\n" . "    if ( \$element[2] === 'unset' )\n" . "    {\n" . "        unset( \$vars[\$element[0]][\$element[1]] );\n" . "        continue;\n" . "    }\n" . "    \$vars[\$element[0]][\$element[1]] = \$element[2];\n" . "}\n" . "\$restoreIncludeArray = \$oldRestoreIncludeArray" . "_{$uniqID};\n");
     return $newNodes;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:51,代码来源:eztemplateincludefunction.php


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