• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP eZTemplateCompiler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: prime

 function prime( &$tr )
 {
     $tpl = eZTemplate::factory();
     $tpl->setIsCachingAllowed( true );
     eZTemplateCompiler::setSettings( array( 'compile' => true,
                                             'comments' => false,
                                             'accumulators' => false,
                                             'timingpoints' => false,
                                             'fallbackresource' => false,
                                             'nodeplacement' => false,
                                             'execution' => true,
                                             'generate' => true,
                                             'compilation-directory' => 'benchmarks/eztemplate/compilation' ) );
     $expected = $tpl->fetch( 'benchmarks/eztemplate/mark.tpl' );
     eZTemplateCompiler::setSettings( array( 'compile' => true,
                                             'comments' => false,
                                             'accumulators' => false,
                                             'timingpoints' => false,
                                             'fallbackresource' => false,
                                             'nodeplacement' => false,
                                             'execution' => true,
                                             'generate' => false,
                                             'compilation-directory' => 'benchmarks/eztemplate/compilation' ) );
     $tpl->reset();
     $this->TPL = $tpl;
 }
开发者ID:nottavi,项目名称:ezpublish,代码行数:26,代码来源:ezmarktemplatecompiler.php


示例2: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     if ($functionName != $this->BlockName) {
         return false;
     }
     $parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
     if (!isset($parameters['name'])) {
         return false;
     }
     $namespaceValue = false;
     $newNodes = array();
     if (isset($parameters["name"])) {
         $menuIni = eZINI::instance("menu.ini");
         $nameData = $parameters["name"];
         if (!eZTemplateNodeTool::isConstantElement($nameData)) {
             return false;
         }
         $menuName = eZTemplateNodeTool::elementConstantValue($nameData);
         if ($menuIni->hasVariable('SelectedMenu', $menuName)) {
             $menuTemplate = $menuIni->variable("SelectedMenu", $menuName);
             if ($menuTemplate != null) {
                 $uriString = "design:menu/{$menuTemplate}.tpl";
                 $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;
                 }
                 $variableList = array();
                 foreach (array_keys($parameters) as $parameterName) {
                     if ($parameterName == 'name') {
                         continue;
                     }
                     $parameterData =& $parameters[$parameterName];
                     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameterData, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName));
                     $variableList[] = $parameterName;
                 }
                 $newNodes = array_merge($newNodes, $includeNodes);
                 foreach ($variableList as $variableName) {
                     $newNodes[] = eZTemplateNodeTool::createVariableUnsetNode(array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $variableName));
                 }
             } else {
                 // to do: not use this function to generate empty code.
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("");
             }
         } else {
             // to do: not use this function to generate empty code.
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("");
         }
     }
     return $newNodes;
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:55,代码来源:eztemplatemenufunction.php


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


示例4: generateVariableDataCode

    static function generateVariableDataCode($php, $tpl, $variableData, &$knownTypes, $dataInspection, &$persistence, $parameters, &$resourceData)
    {
        $staticTypeMap = array(eZTemplate::TYPE_STRING => 'string', eZTemplate::TYPE_NUMERIC => 'numeric', eZTemplate::TYPE_IDENTIFIER => 'string', eZTemplate::TYPE_ARRAY => 'array', eZTemplate::TYPE_BOOLEAN => 'boolean');
        $variableAssignmentName = $parameters['variable'];
        $variableAssignmentCounter = $parameters['counter'];
        $spacing = 0;
        $optimizeNode = false;
        if (isset($parameters['spacing'])) {
            $spacing = $parameters['spacing'];
        }
        if ($variableAssignmentCounter > 0) {
            $variableAssignmentName .= $variableAssignmentCounter;
        }
        // We need to unset the assignment variable before any elements are processed
        // This ensures that we don't work on existing variables
        $php->addCodePiece("unset( \${$variableAssignmentName} );\n", array('spacing' => $spacing));
        if (is_array($variableData)) {
            foreach ($variableData as $index => $variableDataItem) {
                $variableDataType = $variableDataItem[0];
                if ($variableDataType == eZTemplate::TYPE_STRING or $variableDataType == eZTemplate::TYPE_NUMERIC or $variableDataType == eZTemplate::TYPE_IDENTIFIER or $variableDataType == eZTemplate::TYPE_ARRAY or $variableDataType == eZTemplate::TYPE_BOOLEAN) {
                    $knownTypes = array_unique(array_merge($knownTypes, array($staticTypeMap[$variableDataType])));
                    $dataValue = $variableDataItem[1];
                    $dataText = $php->thisVariableText($dataValue, 0, 0, false);
                    $php->addCodePiece("\${$variableAssignmentName} = {$dataText};\n", array('spacing' => $spacing));
                } else {
                    if ($variableDataType == eZTemplate::TYPE_OPTIMIZED_NODE) {
                        $optimizeNode = true;
                        if (!isset($resourceData['node-object-cached'])) {
                            $tpl->error("eZTemplateCompiler" . ($resourceData['use-comments'] ? ":" . __LINE__ : ""), "Attribute node-object-cached of variable \$resourceData was not found but variable node eZTemplate::TYPE_OPTIMIZED_NODE is still present. This should not happen");
                        }
                        $php->addCodePiece("\${$variableAssignmentName} = \$nod_{$resourceData['uniqid']};\n");
                        // If optimized node is not set, use unoptimized code.
                        $php->addCodePiece("if ( !\${$variableAssignmentName} )\n{\n");
                    } else {
                        if ($variableDataType == eZTemplate::TYPE_OPTIMIZED_ARRAY_LOOKUP) {
                            $code = $resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/\n" : "";
                            // This code is used a lot so we create a variable for it
                            $phpVar = "\${$variableAssignmentName}";
                            $indexName = "'{$variableDataItem[1][0][1]}'";
                            // Add sanity checking
                            $code .= "if ( !isset( {$phpVar}[{$indexName}] ) )\n" . "{\n" . "    \$tpl->error( 'eZTemplateCompiler" . ($resourceData['use-comments'] ? ":" . __LINE__ : "") . "', \"PHP variable \\{$phpVar}" . "[{$indexName}] does not exist, cannot fetch the value.\" );\n" . "    {$phpVar} = null;\n" . "}\n" . "else\n    ";
                            // Add the actual code
                            $code .= "{$phpVar} = {$phpVar}[{$indexName}];\n";
                            $php->addCodePiece($code);
                        } else {
                            if ($variableDataType == eZTemplate::TYPE_OPTIMIZED_ATTRIBUTE_LOOKUP) {
                                $code = $resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/\n" : "";
                                $code .= <<<END
if ( !is_object( \${$variableAssignmentName} ) )
{
    \${$variableAssignmentName} = null;
}
else if ( \${$variableAssignmentName}->hasAttribute( "{$variableDataItem[1][0][1]}" ) )
{
    \${$variableAssignmentName} = \${$variableAssignmentName}->attribute( "{$variableDataItem[1][0][1]}" );
}

END;
                                $php->addCodePiece($code);
                            } else {
                                if ($variableDataType == eZTemplate::TYPE_OPTIMIZED_CONTENT_CALL) {
                                    // Line number comment
                                    $code = $resourceData['use-comments'] ? "/*TC:" . __LINE__ . "*/\n" : "";
                                    // This code is used a lot so we create a variable for it
                                    $phpVar = "\${$variableAssignmentName}";
                                    // Add sanity checking
                                    $code .= "if ( !is_object( {$phpVar} ) )\n" . "{\n" . "    \$tpl->error( 'eZTemplateCompiler" . ($resourceData['use-comments'] ? ":" . __LINE__ : "") . "', \"PHP variable \\{$phpVar} is not an object, cannot fetch content()\" );\n" . "    {$phpVar} = null;\n" . "}\n" . "else\n" . "{\n";
                                    // Add the actual code
                                    $code .= "     {$phpVar}Tmp = {$phpVar}->content();\n" . "     unset( {$phpVar} );\n" . "     {$phpVar} = {$phpVar}Tmp;\n" . "     unset( {$phpVar}Tmp );\n}\n";
                                    $php->addCodePiece($code);
                                } else {
                                    if ($variableDataType == eZTemplate::TYPE_PHP_VARIABLE) {
                                        $knownTypes = array();
                                        $phpVariableName = $variableDataItem[1];
                                        $php->addCodePiece("\${$variableAssignmentName} = \${$phpVariableName};\n", array('spacing' => $spacing));
                                    } else {
                                        if ($variableDataType == eZTemplate::TYPE_VARIABLE) {
                                            $knownTypes = array();
                                            $namespace = $variableDataItem[1][0];
                                            $namespaceScope = $variableDataItem[1][1];
                                            $variableName = $variableDataItem[1][2];
                                            $namespaceText = eZTemplateCompiler::generateMergeNamespaceCode($php, $tpl, $namespace, $namespaceScope, array('spacing' => $spacing), true);
                                            if (!is_string($namespaceText)) {
                                                $namespaceText = "\$namespace";
                                            }
                                            $variableNameText = $php->thisVariableText($variableName, 0, 0, false);
                                            $code = "unset( \${$variableAssignmentName} );\n";
                                            $code .= "\${$variableAssignmentName} = ( array_key_exists( {$namespaceText}, \$vars ) and array_key_exists( {$variableNameText}, \$vars[{$namespaceText}] ) ) ? \$vars[{$namespaceText}][{$variableNameText}] : null;\n";
                                            $php->addCodePiece($code, array('spacing' => $spacing));
                                        } else {
                                            if ($variableDataType == eZTemplate::TYPE_ATTRIBUTE) {
                                                $knownTypes = array();
                                                $newParameters = $parameters;
                                                $newParameters['counter'] += 1;
                                                $tmpVariableAssignmentName = $newParameters['variable'];
                                                $tmpVariableAssignmentCounter = $newParameters['counter'];
                                                if ($tmpVariableAssignmentCounter > 0) {
                                                    $tmpVariableAssignmentName .= $tmpVariableAssignmentCounter;
                                                }
                                                if (eZTemplateNodeTool::isStaticElement($variableDataItem[1])) {
//.........这里部分代码省略.........
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:eztemplatecompiler.php


示例5: 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;
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:55,代码来源:eztemplateiffunction.php


示例6: templateNodeCaseTransformation

 function templateNodeCaseTransformation($tpl, &$newNodes, &$caseNodes, &$caseCounter, &$node, $privateData)
 {
     if ($node[2] == 'case') {
         if (is_array($node[3]) && count($node[3])) {
             if (isset($node[3]['match'])) {
                 $match = $node[3]['match'];
                 $match = eZTemplateCompiler::processElementTransformationList($tpl, $node, $match, $privateData);
                 $dynamicCase = false;
                 if (eZTemplateNodeTool::isConstantElement($match)) {
                     $matchValue = eZTemplateNodeTool::elementConstantValue($match);
                     $caseText = eZPHPCreator::variableText($matchValue, 0, 0, false);
                 } else {
                     $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $match, false, array(), 'case' . $caseCounter);
                     $caseText = "\$case" . $caseCounter;
                     ++$caseCounter;
                     $dynamicCase = true;
                 }
                 $caseNodes[] = eZTemplateNodeTool::createCodePieceNode("    case {$caseText}:\n    {");
                 if ($dynamicCase) {
                     $caseNodes[] = eZTemplateNodeTool::createCodePieceNode("        unset( {$caseText} );");
                 }
             } else {
                 if (isset($node[3]['in'])) {
                     return false;
                 }
             }
         } else {
             $caseNodes[] = eZTemplateNodeTool::createCodePieceNode("    default:\n    {");
         }
         $children = eZTemplateNodeTool::extractFunctionNodeChildren($node);
         if ($children === false) {
             $children = array();
         } else {
             $children = eZTemplateCompiler::processNodeTransformationNodes($tpl, $node, $children, $privateData);
         }
         $caseNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode(8);
         $caseNodes = array_merge($caseNodes, $children);
         $caseNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode(8);
         $caseNodes[] = eZTemplateNodeTool::createCodePieceNode("    } break;");
     }
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:41,代码来源:eztemplateswitchfunction.php


示例7: canCompileTemplate

 function canCompileTemplate($tpl, &$resourceData, &$extraParameters)
 {
     return eZTemplateCompiler::isCompilationEnabled();
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:4,代码来源:eztemplatefileresource.php


示例8: templateNodeTransformation

 function templateNodeTransformation($functionName, &$node, $tpl, $parameters, $privateData)
 {
     if ($functionName != $this->BlockName) {
         return false;
     }
     $parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
     if (!isset($parameters['name'])) {
         return false;
     }
     // Read ini file
     $toolbarIni = eZINI::instance("toolbar.ini");
     if (isset($parameters["view"])) {
         $viewData = $parameters["view"];
         $viewMode = eZTemplateNodeTool::elementConstantValue($viewData);
     } else {
         $viewMode = "full";
     }
     $params = $parameters;
     $namespaceValue = false;
     if (isset($parameters["name"])) {
         $nameData = $parameters["name"];
         if (!eZTemplateNodeTool::isConstantElement($nameData)) {
             return false;
         }
         $nameValue = eZTemplateNodeTool::elementConstantValue($nameData);
         $toolbarPosition = $nameValue;
         $toolbarName = "Toolbar_" . $toolbarPosition;
         $toolArray = $toolbarIni->variable($toolbarName, 'Tool');
         if (!is_array($toolArray)) {
             $toolArray = array();
         }
         $newNodes = array();
         foreach (array_keys($toolArray) as $toolKey) {
             $tool = $toolArray[$toolKey];
             $placement = $toolKey + 1;
             $uriString = "design:toolbar/{$viewMode}/{$tool}.tpl";
             $placementValue = "";
             $firstValue = false;
             $lastValue = false;
             if ($placement == 1) {
                 if ($placement == count($toolArray)) {
                     $firstValue = true;
                     $lastValue = true;
                     $placementValue = "last";
                 } else {
                     $firstValue = true;
                     $placementValue = "first";
                 }
             } else {
                 if ($placement == count($toolArray)) {
                     $lastValue = true;
                     $placementValue = "last";
                 }
             }
             $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;
             }
             $uniqID = md5(uniqid('inc'));
             $newNodes[] = eZTemplateNodeTool::createCodePieceNode("\$oldRestoreIncludeArray" . "_{$uniqID} = isset( \$restoreIncludeArray ) ? \$restoreIncludeArray : array();\n" . "\$restoreIncludeArray = array();\n");
             $variableList = array();
             foreach (array_keys($parameters) as $parameterName) {
                 if ($parameterName == 'name' or $parameterName == 'view') {
                     continue;
                 }
                 $parameterData =& $parameters[$parameterName];
                 $newNodes[] = eZTemplateNodeTool::createCodePieceNode("if ( isset( \$vars['']['{$parameterName}'] ) )\n" . "    \$restoreIncludeArray[] = array( '', '{$parameterName}', \$vars['']['{$parameterName}'] );\n" . "elseif ( !isset( \$vars['']['{$parameterName}'] ) ) \n" . "    \$restoreIncludeArray[] = array( '', '{$parameterName}', 'unset' );\n");
                 $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $parameterData, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $parameterName));
                 $variableList[] = $parameterName;
             }
             $actionParameters = array();
             if ($toolbarIni->hasGroup("Tool_" . $tool)) {
                 $actionParameters = $toolbarIni->group("Tool_" . $tool);
             }
             if ($toolbarIni->hasGroup("Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement)) {
                 $actionParameters = array_merge($actionParameters, $toolbarIni->group("Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement));
             }
             foreach (array_keys($actionParameters) as $key) {
                 $itemValue = $actionParameters[$key];
                 $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $itemValue, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, $key));
                 $variableList[] = $key;
             }
             // Add parameter tool_id and offset
             $toolIDValue = "Tool_" . $toolbarPosition . "_" . $tool . "_" . $placement;
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $toolIDValue, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, "tool_id"));
             $variableList[] = "tool_id";
             $toolOffset = $placement;
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $toolOffset, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, "offset"));
             $variableList[] = "offset";
             // Add parameter first, last and placement
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $firstValue, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, "first"));
             $variableList[] = "first";
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $lastValue, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, "last"));
             $variableList[] = "last";
             $newNodes[] = eZTemplateNodeTool::createVariableNode(false, $placementValue, false, array(), array($namespaceValue, eZTemplate::NAMESPACE_SCOPE_RELATIVE, "placement"));
//.........这里部分代码省略.........
开发者ID:legende91,项目名称:ez,代码行数:101,代码来源:eztemplatetoolbarfunction.php


示例9: 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');
//.........这里部分代码省略.........
开发者ID:legende91,项目名称:ez,代码行数:101,代码来源:eztemplatesectionfunction.php


示例10: 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
//.........这里部分代码省略.........
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:101,代码来源:eztemplatecompiledloop.php


示例11: clearTemplateCompileCache

 /**
  * Clear Template Compile cache
  */
 static function clearTemplateCompileCache()
 {
     eZDir::recursiveDelete(eZTemplateCompiler::compilationDirectory());
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:7,代码来源:ezcache.php


示例12: functionTemplateStatistics

 function functionTemplateStatistics($functionName, &$node, $tpl, $resourceData, $namespace, &$stats)
 {
     $newNamespace = $namespace;
     $parameters = eZTemplateNodeTool::extractFunctionNodeParameters($node);
     if ($functionName == $this->SetName or $functionName == $this->LetName or $functionName == $this->DefaultName) {
         if (isset($parameters['-name'])) {
             $nameData = $parameters['-name'];
             $nameDataInspection = eZTemplateCompiler::inspectVariableData($tpl, $nameData, false, $resourceData);
             if ($nameDataInspection['is-constant'] and !$nameDataInspection['has-operators'] and !$nameDataInspection['has-attributes']) {
                 $parameterNamespace = $nameDataInspection['new-data'][0][1];
                 $newNamespace = $tpl->mergeNamespace($namespace, $parameterNamespace);
             }
         }
     }
     if ($functionName == $this->SetName) {
         foreach (array_keys($parameters) as $name) {
             if ($name == '-name') {
                 continue;
             }
             $parameter =& $parameters[$name];
             eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $name, array('is_modified' => true));
             eZTemplateCompiler::calculateVariableNodeStatistics($tpl, $parameter, false, $resourceData, $namespace, $stats);
         }
     } else {
         if ($functionName == $this->LetName) {
             foreach (array_keys($parameters) as $name) {
                 if ($name == '-name') {
                     continue;
                 }
                 $parameter =& $parameters[$name];
                 eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $name, array('is_created' => true, 'is_removed' => true));
                 eZTemplateCompiler::calculateVariableNodeStatistics($tpl, $parameter, false, $resourceData, $namespace, $stats);
             }
         } else {
             if ($functionName == $this->DefaultName) {
                 foreach (array_keys($parameters) as $name) {
                     if ($name == '-name') {
                         continue;
                     }
                     $parameter =& $parameters[$name];
                     eZTemplateCompiler::setVariableStatistics($stats, $newNamespace, $name, array());
                     eZTemplateCompiler::calculateVariableNodeStatistics($tpl, $parameter, false, $resourceData, $namespace, $stats);
                 }
             }
         }
     }
     if ($functionName == $this->LetName or $functionName == $this->DefaultName) {
         $functionChildren = eZTemplateNodeTool::extractFunctionNodeChildren($node);
         if (is_array($functionChildren)) {
             eZTemplateCompiler::calculateVariableStatisticsChildren($tpl, $functionChildren, $resourceData, $newNamespace, $stats);
         }
     }
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:53,代码来源:eztemplatesetfunction.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP eZTemplateDesignResource类代码示例发布时间:2022-05-23
下一篇:
PHP eZTemplate类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap