| // +---------------------------------------------------------------------------+ require_once 'Savant2.php'; class SGL_Savant2 extends Savant2 { /** * Constructor. * @access public * @param string $theme The theme name * @param string $moduleName The module name * @return void */ function SGL_Savant2($theme = 'default', $moduleName = 'default') { $options = array( 'template_path' => SGL_WEB_ROOT . '/savant/default/default' . PATH_SEPARATOR . SGL_WEB_ROOT . '/savant/' . $theme . '/default' . PATH_SEPARATOR . SGL_WEB_ROOT . '/savant/default/' . $moduleName. PATH_SEPARATOR . SGL_WEB_ROOT . '/savant/' . $theme . '/' . $moduleName, 'resource_path' => SGL_MOD_DIR . '/' . $moduleName . '/classes', ); $this->Savant2($options); } /** * Returns a singleton Savant2 instance. * * example usage: * $savant2 = & SGL_Savant2::singleton($theme, $moduleName); * warning: in order to work correctly, the cache * singleton must be instantiated statically and * by reference * * @access public * @static * @param string $theme The theme name * @param string $moduleName The module name * @return mixed reference to SGL_Savant2 object */ function &singleton($theme = 'default', $moduleName = 'default') { static $instance; if (!isset($instance)) { $class = __CLASS__; $instance = new $class($theme, $moduleName); } return $instance; } } class SGL_HtmlRenderer_Savant2Strategy extends SGL_OutputRendererStrategy { /** * Director for html Savant2 renderer. * * @param SGL_View $view * @return string rendered html output */ function render( /*SGL_View*/ &$view) { // invoke html view specific post-process tasks $view->postProcess($view); // prepare Savant2 object $moduleName = isset($view->data->moduleName) ? $view->data->moduleName : 'default'; $savant2 = &SGL_Savant2::singleton($view->data->theme, $moduleName); // suppress error notices in templates SGL::setNoticeBehaviour(SGL_NOTICES_DISABLED); $savant2->assign('result', $view->data); $data = $savant2->fetch($view->data->masterTemplate); SGL::setNoticeBehaviour(SGL_NOTICES_ENABLED); return $data; } } ?>