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


PHP SSViewer::topLevel方法代码示例

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


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

示例1: process

 /**
  * The process() method handles the "meat" of the template processing.
  */
 public function process($item)
 {
     SSViewer::$topLevel = $item;
     if (isset($this->chosenTemplates['main'])) {
         $template = $this->chosenTemplates['main'];
     } else {
         $template = $this->chosenTemplates[reset($dummy = array_keys($this->chosenTemplates))];
     }
     if (isset($_GET['debug_profile'])) {
         Profiler::mark("SSViewer::process", " for {$template}");
     }
     $cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\', '/', ':'), '.', realpath($template));
     $lastEdited = filemtime($template);
     if (!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
         if (isset($_GET['debug_profile'])) {
             Profiler::mark("SSViewer::process - compile", " for {$template}");
         }
         $content = file_get_contents($template);
         $content = SSViewer::parseTemplateContent($content, $template);
         $fh = fopen($cacheFile, 'w');
         fwrite($fh, $content);
         fclose($fh);
         if (isset($_GET['debug_profile'])) {
             Profiler::unmark("SSViewer::process - compile", " for {$template}");
         }
     }
     if (isset($_GET['showtemplate']) && !Director::isLive()) {
         $lines = file($cacheFile);
         echo "<h2>Template: {$cacheFile}</h2>";
         echo "<pre>";
         foreach ($lines as $num => $line) {
             echo str_pad($num + 1, 5) . htmlentities($line);
         }
         echo "</pre>";
     }
     foreach (array('Content', 'Layout') as $subtemplate) {
         if (isset($this->chosenTemplates[$subtemplate])) {
             $subtemplateViewer = new SSViewer($this->chosenTemplates[$subtemplate]);
             $item = $item->customise(array($subtemplate => $subtemplateViewer->process($item)));
         }
     }
     $itemStack = array();
     $val = "";
     include $cacheFile;
     $output = $val;
     $output = Requirements::includeInHTML($template, $output);
     SSViewer::$topLevel = null;
     if (isset($_GET['debug_profile'])) {
         Profiler::unmark("SSViewer::process", " for {$template}");
     }
     // If we have our crazy base tag, then fix # links referencing the current page.
     if (strpos($output, '<base') !== false) {
         $thisURLRelativeToBase = Director::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI']));
         $output = preg_replace('/(<a[^>+]href *= *")#/i', '\\1' . $thisURLRelativeToBase . '#', $output);
     }
     return $output;
 }
开发者ID:ramziammar,项目名称:websites,代码行数:60,代码来源:SSViewer.php

示例2: Top

 /**
  * Returns the top level ViewableData being rendered.
  * @return ViewableData
  */
 function Top()
 {
     return SSViewer::topLevel();
 }
开发者ID:ramziammar,项目名称:websites,代码行数:8,代码来源:ViewableData.php


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