Exemple #1
0
 /**
  * Execute output html using a layout template
  *
  * @return string
  */
 protected function renderTemplateWithLayout()
 {
     ob_start();
     extract($this->_vars);
     $dir = PathManager::getViewTemplateDirectory();
     $ext = NameManager::getTemplateExtension();
     $templatePath = sprintf('%s/%s.%s', $dir, $this->_template, $ext);
     if (!file_exists($templatePath)) {
         throw new FileNotExistException($templatePath);
     }
     require_once $templatePath;
     $inner_contents = ob_get_contents();
     ob_clean();
     $dir = PathManager::getViewLayoutDirectory();
     $layoutPath = sprintf('%s/%s.%s', $dir, $this->_layout, $ext);
     if (!file_exists($layoutPath)) {
         throw new FileNotExistException($layoutPath);
     }
     require_once $layoutPath;
     return ob_get_clean();
 }
Exemple #2
0
 /**
  * Execute output html using a layout template
  *
  * @return string
  */
 protected function renderTemplateWithLayout()
 {
     foreach ($this->_vars as $key => $val) {
         $this->_smarty->assign($key, $val);
     }
     $ext = NameManager::getTemplateExtension();
     $templateDir = PathManager::getViewTemplateDirectory();
     $template = $this->_template . '.' . $ext;
     $templatePath = $templateDir . '/' . $template;
     if (!file_exists($templatePath)) {
         throw new FileNotExistException($templatePath);
     }
     $layoutDir = PathManager::getViewLayoutDirectory();
     $layout = $this->_layout . '.' . $ext;
     $layoutPath = $layoutDir . '/' . $layout;
     if (!file_exists($layoutPath)) {
         throw new FileNotExistException($layoutPath);
     }
     $this->_smarty->template_dir = $templateDir;
     $contents = $this->_smarty->fetch($template);
     $this->_smarty->assign('inner_contents', $contents);
     $this->_smarty->template_dir = $layoutDir;
     $rendered = $this->_smarty->fetch($layout);
     return $rendered;
 }
 /**
  * Process when not found exception occurs 
  *
  * @return void
  */
 public function notFound()
 {
     $dir = PathManager::getViewTemplateDirectory();
     $ext = NameManager::getTemplateExtension();
     $exists = file_exists(sprintf('%s/error/not_found.%s', $dir, $ext));
     if ($this->view instanceof ViewAbstract && $exists) {
         $this->view->setTemplate('not_found', 'error');
         $this->view->enableLayout(false);
         $this->view->render();
     } else {
         echo '404 Not Found';
     }
 }
Exemple #4
0
 /**
  * Get whether exists view template.
  *
  * @return boolean
  */
 public function existsTemplate()
 {
     $ext = NameManager::getTemplateExtension();
     $templateDir = PathManager::getViewTemplateDirectory();
     $template = $this->_template . '.' . $ext;
     $templatePath = $templateDir . '/' . $template;
     $exists = file_exists($templatePath);
     return $exists;
 }