Example #1
0
 /**
  * (non-PHPdoc)
  * @see Simplify_ViewInterface::render()
  */
 public function render(\Simplify\RenderableInterface $object = null)
 {
     if (empty($object)) {
         $object = $this->object;
     }
     $template = $object->getTemplate();
     if ($template === false) {
         return '';
     }
     \Simplify::response()->header('Content-Type: text/html; charset=UTF-8');
     $output = $this->internalRender($object, $template);
     $layout = $object->getLayout();
     if ($layout !== false) {
         if (empty($layout)) {
             $layout = $this->getLayout();
         }
         $view = new self();
         $view->copyAll($object);
         $view->copyAll($this);
         $view->set('layout_content', $output);
         $view->setTemplate($layout);
         $view->setTemplatesPath($object->getLayoutsPath());
         $view->setLayout(false);
         $output = $view->render();
     }
     return $output;
 }
Example #2
0
 /**
  * (non-PHPdoc)
  * @see \Simplify\ViewInterface::render()
  */
 public function render(\Simplify\RenderableInterface $object = null)
 {
     if (empty($object)) {
         $object = $this->object;
     }
     $template = $object->getTemplate();
     if ($template === false) {
         return '';
     }
     if (sy_path_is_absolute($template)) {
         if (!file_exists($template)) {
             throw new \Exception("Template not found: <b>{$template}</b>");
         }
     } else {
         $filename = $template;
         $path = $object->getTemplatesPath();
         $template = array();
         do {
             $template[] = array_shift($path) . '/' . $filename . '.php';
         } while (count($path) && !file_exists(end($template)));
         if (!file_exists(end($template))) {
             throw new \Exception("Template not found: <b>{$filename}</b><br/><br/>Using path:<br/><b>" . implode('</b><br/><b>', $template) . "</b>");
         }
         $template = end($template);
     }
     $output = $this->internalRender($object, $template);
     $layout = $object->getLayout();
     if ($layout !== false) {
         if (empty($layout)) {
             $layout = $this->getLayout();
         }
         $view = new self();
         $view->copyAll($object);
         $view->copyAll($this);
         $view->set('layout_content', $output);
         $view->setTemplate($layout);
         $view->setTemplatesPath($object->getLayoutsPath());
         $view->setLayout(false);
         $output = $view->render();
     }
     return $output;
 }