本文整理汇总了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;
}
示例2: Top
/**
* Returns the top level ViewableData being rendered.
* @return ViewableData
*/
function Top()
{
return SSViewer::topLevel();
}