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


PHP eZTemplateCompiler::isCommentsEnabled方法代码示例

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


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

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

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

示例3: generatePHPCodeChildren


//.........这里部分代码省略.........
                                                                     * template is included; it does not work if we are using
                                                                     * something from the ezobjectforwarder which makes the
                                                                     * uriMap an array */
                                                                    $useFallbackCode = true;
                                                                    $uriMap = $node[2];
                                                                    if (is_string($uriMap)) {
                                                                        $uriMap = array($uriMap);
                                                                    } else {
                                                                        $useFallbackCode = false;
                                                                    }
                                                                    $resourceMap = array();
                                                                    $hasCompiledCode = false;
                                                                    if (is_array($uriMap)) {
                                                                        foreach ($uriMap as $uriKey => $originalURI) {
                                                                            $uri = $originalURI;
                                                                            if ($resource) {
                                                                                $uri = $resource . ':' . $uri;
                                                                            }
                                                                            unset($tmpResourceData);
                                                                            $tmpResourceData = $tpl->resourceData($resourceObject, $uri, $node[1], $originalURI);
                                                                            $uriText = $php->thisVariableText($uri, 0, 0, false);
                                                                            $resourceCanCache = true;
                                                                            if (!$resourceObject->servesStaticData()) {
                                                                                $resourceCanCache = false;
                                                                            }
                                                                            if (!$tpl->isCachingAllowed()) {
                                                                                $resourceCanCache = false;
                                                                            }
                                                                            $tmpResourceData['text'] = null;
                                                                            $tmpResourceData['root-node'] = null;
                                                                            $tmpResourceData['compiled-template'] = false;
                                                                            $tmpResourceData['time-stamp'] = null;
                                                                            $tmpResourceData['key-data'] = null;
                                                                            $tmpResourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled();
                                                                            $subSpacing = 0;
                                                                            $hasResourceData = false;
                                                                            $savedLocale = setlocale(LC_CTYPE, null);
                                                                            if (isset($GLOBALS['eZTemplateCompilerResourceCache'][$tmpResourceData['template-filename']])) {
                                                                                $tmpFileName = $tmpResourceData['template-filename'];
                                                                                unset($tmpResourceData);
                                                                                $tmpResourceData = $GLOBALS['eZTemplateCompilerResourceCache'][$tmpFileName];
                                                                                $tmpResourceData['compiled-template'] = true;
                                                                                $tmpResourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled();
                                                                                $hasResourceData = true;
                                                                                $hasCompiledCode = true;
                                                                            } else {
                                                                                if ($useFallbackCode) {
                                                                                    // If we can use fallback code we don't need to compile the templates in advance
                                                                                    // Simply fake that it has been compiled by setting some variables
                                                                                    // Note: Yes this is a hack, but rewriting this code is not an easy task
                                                                                    if ($resourceObject->handleResource($tpl, $tmpResourceData, $node[4], $node[5])) {
                                                                                        $tmpResourceData['compiled-template'] = true;
                                                                                        $hasResourceData = true;
                                                                                        $hasCompiledCode = true;
                                                                                    }
                                                                                } else {
                                                                                    if ($resourceObject->handleResource($tpl, $tmpResourceData, $node[4], $node[5])) {
                                                                                        if (!$tmpResourceData['compiled-template'] and $tmpResourceData['root-node'] === null) {
                                                                                            $root =& $tmpResourceData['root-node'];
                                                                                            $root = array(eZTemplate::NODE_ROOT, false);
                                                                                            $templateText =& $tmpResourceData["text"];
                                                                                            $keyData = $tmpResourceData['key-data'];
                                                                                            $rootNamespace = '';
                                                                                            $tpl->parse($templateText, $root, $rootNamespace, $tmpResourceData);
                                                                                            $hasResourceData = false;
                                                                                        }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:67,代码来源:eztemplatecompiler.php

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


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