コード例 #1
0
ファイル: Email.php プロジェクト: phpwax/email
 public function render_layout()
 {
     if (!$this->use_layout) {
         return false;
     }
     $this->use_format = "html";
     $layout = new WaxTemplate($this);
     $layout->add_path(VIEW_DIR . "layouts/" . $this->use_layout);
     ob_end_clean();
     return $layout->parse($this->use_format);
 }
コード例 #2
0
ファイル: WaxController.php プロジェクト: phpwax/phpwax
 /**
  *  Returns a view as a string.
  *	@return string
  */
 protected function render_view()
 {
     if ($this->use_plugin) {
         WaxLog::log("info", "[DEPRECATION] use_plugin in controllers is deprecated, use the add_plugin method intead.");
         $this->plugins[] = $this->use_plugin;
     }
     if ($this->shared_plugin) {
         WaxLog::log("info", "[DEPRECATION] shared_plugin in controllers is deprecated, use the add_plugin method intead.");
         $this->plugins[] = $this->shared_plugin;
     }
     if (!$this->use_view) {
         return false;
     }
     if ($this->use_view == "none") {
         return false;
     }
     if ($this->use_view == "_default") {
         $this->use_view = $this->action;
     }
     if (Config::get('view_cache') && !substr_count($this->controller, "admin")) {
         $sess = $_SESSION[Session::get_hash()];
         unset($sess['referrer']);
         $cache = new WaxCache($_SERVER['HTTP_HOST'] . md5($_SERVER['REQUEST_URI'] . serialize($_GET) . serialize($sess)) . '.view');
         if (count($_POST)) {
             $cache->expire();
         } elseif ($cache->valid()) {
             return $cache->get();
         }
     }
     $view = new WaxTemplate($this);
     $view->add_path(VIEW_DIR . $this->use_view);
     $view->add_path(VIEW_DIR . $this->controller . "/" . $this->use_view);
     foreach ($this->plugins as $plugin) {
         $view->add_path(PLUGIN_DIR . $plugin . "/view/" . get_parent_class($this) . "/" . $this->use_view);
         $view->add_path(PLUGIN_DIR . $plugin . "/view/" . $this->plugin_share . "/" . $this->use_view);
     }
     ob_end_clean();
     if ($this->use_format) {
         $content = $view->parse($this->use_format, 'views');
     } else {
         $content = $view->parse('html', 'views');
     }
     if (Config::get('view_cache') && !substr_count($this->controller, "admin")) {
         $cache->set($content);
     }
     return $content;
 }