/** * Method for singleton mode * Return Hush_View instance such as Hush_View_Smarty * @static * @param string $engine * @param array $configs Configurations used by Hush_View subclass * @return Hush_View */ public static function getInstance($engine, $configs) { if (!$engine) { require_once 'Hush/Exception.php'; throw new Hush_Exception('View & Template Engine can not be empty'); } if (!self::$engine) { $file_name = 'Hush/View/' . ucfirst($engine) . '.php'; $class_name = 'Hush_View_' . ucfirst($engine); require_once $file_name; self::$engine = new $class_name($configs); } return self::$engine; }
/** * Assign prepared data into template and display * Could be called by some class which need do page process manually * @see Hush_App_Dispatcher * @param string $tpl_name Passed template name * @return unknown */ public function __display($tpl_name = null) { // display setted template if ($this->getTemplate()) { $tpl_name = $this->getTemplate(); } // display passed template // TODO : Smarty 3 bug in caching if ($tpl_name && $this->view->templateExists($tpl_name)) { $this->view->display($tpl_name); } // page execute time if (Hush_Debug::showDebug('time')) { $this->end_time = microtime(true); $this->debug(__TPL_ENGINE . '_' . $this->view->getVersion(), '<span style="color:red">Template Engine Version >>></span>', Hush_Debug::INFO); $this->debug($this->end_time - $this->start_time, '<span style="color:red">Page Execute Time >>></span>', Hush_Debug::INFO); $this->debug($this->view->isCached($tpl_name), '<span style="color:red">Page Cached >>></span>', Hush_Debug::INFO); } // print debug msg $this->_debug->write(); }