/** * 初始化 * * @return void */ public function init() { //request和response对象获取 $this->request = $this->getRequest(); $this->response = $this->getResponse(); $this->modKey = $this->request->getModuleKey(); $this->modName = $this->request->getModuleName(); $this->ctlKey = $this->request->getControllerKey(); $this->ctlName = $this->request->getControllerName(); $this->actKey = $this->request->getActionKey(); $this->actName = $this->request->getActionName(); //smarty模板设置 $this->view = Common_View::getInstance(); //重新设置模板目录 $_viewBaseDir = implode(DS, array(APP_NOPUBLIC_MODULES_PATH, $this->modName, 'views')); $params = array('template_dir' => $_viewBaseDir . DS . 'html', 'compile_dir' => $_viewBaseDir . DS . 'compile', 'cache_dir' => $_viewBaseDir . DS . 'cache'); $this->view->setViewParams($params); unset($_viewBaseDir); }
protected function _initView() { $resources = $this->getOption('resources'); $options = array(); if (isset($resources['view'])) { $options = $resources['view']; } $this->bootstrap('cache'); $cache = $this->getResource('cache'); if (!is_null($cache)) { if (($view = $cache->load(self::CACHE_KEY_VIEW)) === false) { $view = new Common_View($options); $cache->save($view, self::CACHE_KEY_VIEW); } } else { $view = new Common_View($options); } if (isset($options['doctype'])) { $view->doctype()->setDoctype(strtoupper($options['doctype'])); if (isset($options['charset']) && $view->doctype()->isHtml5()) { $view->headMeta()->setCharset($options['charset']); } } if (isset($options['contentType'])) { $view->headMeta()->appendHttpEquiv('Content-Type', $options['contentType']); } $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer(); $viewRenderer->setView($view); Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); return $view; }