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


PHP eZPHPCreator::addInclude方法代码示例

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


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

示例1: compileTemplate

 static function compileTemplate($tpl, $key, &$resourceData)
 {
     if (!eZTemplateCompiler::isCompilationEnabled()) {
         return false;
     }
     $resourceData['use-comments'] = eZTemplateCompiler::isCommentsEnabled();
     $cacheFileName = eZTemplateCompiler::compilationFilename($key, $resourceData);
     $resourceData['uniqid'] = md5($resourceData['template-filename'] . uniqid("ezp" . getmypid(), true));
     // Time limit #1:
     // We reset the time limit to 30 seconds to ensure that templates
     // have enough time to compile
     // However if time limit is unlimited (0) we leave it be
     // Time limit will also be reset after subtemplates are compiled
     $maxExecutionTime = ini_get('max_execution_time');
     if ($maxExecutionTime != 0 && $maxExecutionTime < 30) {
         @set_time_limit(30);
     }
     $rootNode =& $resourceData['root-node'];
     if (!$rootNode) {
         return false;
     }
     $GLOBALS['eZTemplateCompilerResourceCache'][$resourceData['template-filename']] =& $resourceData;
     $useComments = eZTemplateCompiler::isCommentsEnabled();
     if (!$resourceData['test-compile']) {
         eZTemplateCompiler::createCommonCompileTemplate();
     }
     /* Check if we need to disable the generation of spacing for the compiled templates */
     $ini = eZINI::instance();
     $spacing = 'disabled';
     if ($ini->variable('TemplateSettings', 'UseFormatting') == 'enabled') {
         $spacing = 'enabled';
     }
     $php = new eZPHPCreator(eZTemplateCompiler::compilationDirectory(), $cacheFileName, eZTemplateCompiler::TemplatePrefix(), array('spacing' => $spacing));
     $php->addComment('URI:       ' . $resourceData['uri']);
     $php->addComment('Filename:  ' . $resourceData['template-filename']);
     $php->addComment('Timestamp: ' . $resourceData['time-stamp'] . ' (' . date('D M j G:i:s T Y', $resourceData['time-stamp']) . ')');
     $php->addCodePiece("\$oldSetArray_{$resourceData['uniqid']} = isset( \$setArray ) ? \$setArray : array();\n" . "\$setArray = array();\n");
     // Code to decrement include level of the templates
     $php->addCodePiece("\$tpl->Level++;\n");
     $php->addCodePiece("if ( \$tpl->Level > {$tpl->MaxLevel} )\n" . "{\n" . "\$text = \$tpl->MaxLevelWarning;" . "\$tpl->Level--;\n" . "return;\n" . "}\n");
     if ($resourceData['locales'] && count($resourceData['locales'])) {
         $php->addComment('Locales:   ' . join(', ', $resourceData['locales']));
         $php->addCodePiece('$locales = array( "' . join('", "', $resourceData['locales']) . "\" );\n" . '$oldLocale_' . $resourceData['uniqid'] . ' = setlocale( LC_CTYPE, null );' . "\n" . '$currentLocale_' . $resourceData['uniqid'] . ' = setlocale( LC_CTYPE, $locales );' . "\n");
     }
     //         $php->addCodePiece( "print( \"" . $resourceData['template-filename'] . " ($cacheFileName)<br/>\n\" );" );
     if ($useComments) {
         $templateFilename = $resourceData['template-filename'];
         if (file_exists($templateFilename)) {
             $fd = fopen($templateFilename, 'rb');
             if ($fd) {
                 $templateText = fread($fd, filesize($templateFilename));
                 $php->addComment("Original code:\n" . $templateText);
                 fclose($fd);
             }
         }
     }
     $php->addVariable('eZTemplateCompilerCodeDate', eZTemplateCompiler::CODE_DATE);
     $php->addCodePiece("if ( !defined( 'EZ_TEMPLATE_COMPILER_COMMON_CODE' ) )\n");
     $php->addInclude(eZTemplateCompiler::compilationDirectory() . '/common.php', eZPHPCreator::INCLUDE_ONCE_STATEMENT, array('spacing' => 4));
     $php->addSpace();
     if (eZTemplateCompiler::isAccumulatorsEnabled()) {
         $php->addCodePiece("eZDebug::accumulatorStart( 'template_compiled_execution', 'template_total', 'Template compiled execution', true );\n");
     }
     if (eZTemplateCompiler::isTimingPointsEnabled()) {
         $php->addCodePiece("eZDebug::addTimingPoint( 'Script start {$cacheFileName}' );\n");
     }
     //         $php->addCodePiece( "if ( !isset( \$vars ) )\n    \$vars =& \$tpl->Variables;\n" );
     //         $php->addSpace();
     $parameters = array();
     $textName = eZTemplateCompiler::currentTextName($parameters);
     //         $php->addCodePiece( "if ( !isset( \$$textName ) )\n    \$$textName = '';\n" );
     //         $php->addSpace();
     //         $variableStats = array();
     //         eZTemplateCompiler::prepareVariableStatistics( $tpl, $resourceData, $variableStats );
     //         eZTemplateCompiler::calculateVariableStatistics( $tpl, $rootNode, $resourceData, $variableStats );
     //         print_r( $variableStats );
     $transformedTree = array();
     eZTemplateCompiler::processNodeTransformation($useComments, $php, $tpl, $rootNode, $resourceData, $transformedTree);
     if ($ini->variable('TemplateSettings', 'TemplateOptimization') == 'enabled') {
         /* Retrieve class information for the attribute lookup table */
         if (isset($resourceData['handler']->Keys) and isset($resourceData['handler']->Keys['class'])) {
             $resourceData['class-info'] = eZTemplateOptimizer::fetchClassDeclaration($resourceData['handler']->Keys['class']);
         }
         /* Run the optimizations */
         eZTemplateOptimizer::optimize($useComments, $php, $tpl, $transformedTree, $resourceData);
     }
     $staticTree = array();
     eZTemplateCompiler::processStaticOptimizations($useComments, $php, $tpl, $transformedTree, $resourceData, $staticTree);
     $combinedTree = array();
     eZTemplateCompiler::processNodeCombining($useComments, $php, $tpl, $staticTree, $resourceData, $combinedTree);
     $finalTree = $combinedTree;
     if (!eZTemplateCompiler::isNodePlacementEnabled()) {
         eZTemplateCompiler::processRemoveNodePlacement($finalTree);
     }
     eZTemplateCompiler::generatePHPCode($useComments, $php, $tpl, $finalTree, $resourceData);
     if (eZTemplateCompiler::isTreeEnabled('final')) {
         $php->addVariable('finalTree', $finalTree, eZPHPCreator::VARIABLE_ASSIGNMENT, array('full-tree' => true));
     }
     if (eZTemplateCompiler::isTreeEnabled('combined')) {
         $php->addVariable('combinedTree', $combinedTree, eZPHPCreator::VARIABLE_ASSIGNMENT, array('full-tree' => true));
//.........这里部分代码省略.........
开发者ID:runelangseid,项目名称:ezpublish,代码行数:101,代码来源:eztemplatecompiler.php


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