public function exec() { // Download binary file if ($this->_binary_file) { // Send headers $this->_sendHeaders(); // Send file readfile($this->_binary_file); exit; } // 404? (without template) if (!$this->_template || !Template::exists($this->_template) && $this->_template != '_404') { $this->setData('cache.excluded', true); $this->_template = '_404'; } // Output timer('start', 'template_parse'); ob_start(); Template::parse($this->_template, $this->_data); $content = ob_get_clean(); $content = Event::filter('content', $content); timer('end', 'template_parse'); // If not excluding cache, then save cache if (!$this->getData('cache.excluded')) { Cache::factory()->save($this->_headers, $content, $this->getData('page_ttl')); } // Send headers $this->_sendHeaders(); // Send content echo Event::filter('cache', $content); }
function template($name, $params = array()) { \LandingPages\Template::parse($name, $params); }
public function getHtml() { if ($this->hasCache()) { $this->_content = file_get_contents($this->getCacheFile()); } else { ob_start(); Template::parse($this->_template, $this->_data); $this->_content = Event::filter('content', ob_get_clean()); if ($this->isCacheEnabled()) { @mkdir(dirname($this->getCacheFile()), 0777, true); file_put_contents($this->getCacheFile(), $this->_content); if ($ttl = $this->getData('ttl')) { file_put_contents($this->getCacheFile() . '.expire', "{$ttl}"); } else { @unlink($this->getCacheFile() . '.expire'); } } } return $this->_content; }