public function setTemplate(\Template $template) { if (!is_file($template->getFile())) { throw new \Exception(t('Could not find template file: %t', $template->getFile())); } $this->template = $template; }
<?php namespace w34u\ssp; error_reporting(E_ALL); require 'sspadmin/includeheader.php'; $SSP_Config = Configuration::getConfiguration(); $session = new Protect(); $content["title"] = "SSP Demo site"; $content["pathAdmin"] = "sspadmin/"; $menu = new MenuGen(); $menu->add($SSP_Config->adminDir, "Administration"); $content["menu"] = $menu->cMenu(); $page = new Template($content, "sspgeneraltemplate.tpl"); $page->getFile("content", "index.tpl"); echo $page->output();
protected function loadTemplateContents(Template $template, $globals) { $file = $template->getFile(); $xml = file_get_contents($file); if (preg_match("/xbuilder\\=\"(c:)?([^\"]+)\"/si", $xml, $m)) { $parserClass = $m[2]; } else { throw new Exception('XModule [' . $template->getName() . '] failed to specify XBuilder class'); } $builder = $this->ApplicationContext->object($parserClass); if (!$builder instanceof XBuilderInterface) { throw new TemplateEngineException('XBuilder class does not implement XBuilderInterface: ' . get_class($builder)); } // TODO: cache module contents into a file and parse as usual $contents = $builder->handleBuild($xml, $file, $template, array_merge($globals, $this->getConstants())); // remove comments $contents = preg_replace("/{%\\s+\\/\\*.*\\*\\/\\s+%}/sU", '', $contents); if (empty($contents)) { throw new TemplateEngineException("Template empty: " . $template->getName()); } $template->setContents($contents); return $template; }
protected function loadTemplateContents(Template $template, $globals) { if ($this->benchmarkRendering) { $this->Benchmark->start('load-template-contents-' . $template->getName()); } $file = $template->getFile(); if (!($contents = $this->FileCache->getFileContents($file))) { $contents = file_get_contents($file); } // remove comments $contents = preg_replace("/{%\\s+\\/\\*.*\\*\\/\\s+%}/sU", '', $contents); // if (empty($contents)) // throw new TemplateEngineException("Template empty: " .$template->getName()); // $this->Logger->debug("Found contents:\n".$contents); $template->setContents($contents); if ($this->benchmarkRendering) { $this->Benchmark->end('load-template-contents-' . $template->getName()); } return $contents; }