/**
  * Gets raw template content
  *
  * @param template PHPSTLTemplate
  * @return string
  */
 public function getContent(PHPSTLTemplate $template)
 {
     assert(is_a($template->getProvider(), get_class($this)));
     $file = $template->providerData;
     assert(file_exists($file));
     ob_start();
     $content = file_get_contents($file);
     if ($content === false) {
         $mess = ob_get_clean();
         throw new RuntimeException("Failed to read {$file}: {$mess}");
     }
     ob_end_clean();
     return $content;
 }
Exemplo n.º 2
0
 /**
  * Restores the application path after template is rendered.
  */
 protected function renderCleanup()
 {
     parent::renderCleanup();
     if (isset($this->currentPath)) {
         CurrentPath::set($this->oldAppPath);
     }
 }
Exemplo n.º 3
0
 public function __construct(PHPSTLTemplateProvider $provider, $resource, $identifier)
 {
     parent::__construct($provider, $resource, $identifier);
     $this->path = new StupidPath(Site::Site()->url);
     if (substr($identifier, 0, 7) == 'file://') {
         $path = dirname(substr($identifier, 7));
         $pl = strlen($path);
         foreach (array(Loader::$FrameworkPath . '/', Loader::$Base . '/') as $p) {
             $l = strlen($p);
             if ($pl > $l && substr($path, 0, $l) == $p) {
                 $this->path = $this->path->down(substr($path, $l));
                 break;
             }
         }
     }
 }
Exemplo n.º 4
0
 public static function RenderTemplate(PHPSTLTemplate $template, $resource, $args)
 {
     assert(is_array($args));
     $sub = $template->getProvider()->getPHPSTL()->load($resource);
     print $sub->render($args);
 }
Exemplo n.º 5
0
 /**
  * Renders a template with special argument semantics
  *
  * The template is rendered with arguments set from the $data field merged
  * with array('page' => $this)
  *
  * @return array
  */
 protected function renderTemplate(PHPSTLTemplate &$template)
 {
     $prefix = $this->site->modules->getModulePrefix('PageSystem');
     return $template->render(array_merge($this->data, array('pageSystemPrefix' => $prefix, 'page' => $this)));
 }
 /**
  * Gets raw template content
  *
  * @param template PHPSTLTemplate
  * @return string
  */
 public function getContent(PHPSTLTemplate $template)
 {
     assert(is_a($template->getProvider(), get_class($this)));
     $node = $template->providerData;
     assert($node instanceof CMSNode);
     return $node->getContent();
 }