/** * this function adds a preview bar to the top of content, so that users won't be confused that their preview differs from the live content * * @param string $buffer_contents * @return void * @author Sheldon */ public function add_preview_bar($buffer_contents, $template = false) { WaxTemplate::remove_response_filter("layout", "cms-preview-bar"); $preview_bar = partial("../../plugins/cms/view/shared/_preview_bar", $template, "html"); $buffer_contents = preg_replace("/(<\\/head>)/", '<link type="text/css" href="/stylesheets/cms/preview-bar.css" rel="stylesheet" />$1', $buffer_contents); $buffer_contents = preg_replace("/(<body.*?>)/", "\$1" . $preview_bar, $buffer_contents); return $buffer_contents; }
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); }
/** * Returns a layout as a string. * @return string */ protected function render_layout() { if (!$this->use_layout) { return false; } if (Config::get('page_cache') && !substr_count($this->controller, "admin")) { $sess = $_SESSION[Session::get_hash()]; unset($sess['referrer']); $fname = $_SERVER['HTTP_HOST'] . md5($_SERVER['REQUEST_URI'] . serialize($_GET) . serialize($sess)) . '.layout'; $cache = new WaxCache($fname); if (count($_POST)) { $cache->expire(); } else { if ($cache->valid()) { return $cache->get(); } } } $layout = new WaxTemplate($this); $layout->add_path(VIEW_DIR . "layouts/" . $this->use_layout); $layout->add_path(PLUGIN_DIR . $this->use_plugin . "/view/layouts/" . $this->use_layout); $layout->add_path(PLUGIN_DIR . $this->share_plugin . "/view/layouts/" . $this->use_layout); ob_end_clean(); $layout = $layout->parse(); if (Config::get('page_cache') && !substr_count($this->controller, "admin")) { $cache->set($layout); } return $layout; }