/** * postDispatch - auto render a view * * Override Zend_Controller_Action_Helper_ViewRenderer::postDispatch() * @return void */ public function postDispatch() { /** * Get module name, controller name, action name */ $request = $this->getRequest(); $module = $request->getModuleName(); if (null === $module) { $module = $this->getFrontController()->getDispatcher()->getDefaultModule(); } $controller = $request->getControllerName(); if (null === $controller) { $controller = $this->getFrontController()->getDispatcher()->getDefaultControllerName(); } $action = $request->getActionName(); if (null == $action) { $action = $this->getFrontController()->getDispatcher()->getDefaultAction(); } /** * Set cacheId for Smarty's caching */ $langCode = Vi_Registry::get('langCode'); $this->view->cacheId = Vi_Registry::getAppName() . '|' . $langCode . '|module|' . $module . '_' . $controller . '_' . $action . ($this->view->cacheId ? '_' . $this->view->cacheId : ''); /** * Call parent's postDispatch() function */ $result = parent::postDispatch(); /** * Revive Vi_Language::$currentType and Vi_Language::$currentName */ Vi_Language::$currentType = Vi_Registry::get('controllerCurrentType'); Vi_Language::$currentName = Vi_Registry::get('controllerCurrentName'); return $result; }
protected function _initAcl() { $isRedirect = false; if (!parent::_initAcl()) { $isRedirect = true; } else { $username = $this->auth->getUsername(); $this->aclAdmin = new Vi_Acl($username); Vi_Registry::set('aclAdmin', $this->aclAdmin); // echo '<pre>';print_r($this->aclAdmin);die; $isRedirect = !$this->aclAdmin->checkPermission('access', 'application::' . Vi_Registry::getAppName()); } if ($isRedirect && Vi_Registry::getModuleName() != 'access') { $url = ""; $module = Vi_Registry::getModuleName(); $controller = Vi_Registry::getControllerName(); $action = Vi_Registry::getActionName(); $params = $this->_request->getParams(); $url .= $module . '/' . $controller . '/' . $action . '/'; unset($params[Vi_Registry::getModuleKey()]); unset($params[Vi_Registry::getControllerKey()]); unset($params[Vi_Registry::getActionKey()]); // echo "<pre>";print_r($params);die; foreach ($params as $key => $param) { $url .= @urlencode($key) . '/' . @urlencode($param); } $this->_setCallBackUrl($url); if (null != $this->auth->getUsername()) { $this->session->accessMessage = Vi_Language::translate("You don't have permission to access this application"); } $this->_redirect("access/admin/login"); } return true; }
/** * Init configuration */ public function init() { /** * Notify module type to translator */ $this->_currentType = Vi_Language::$currentType; $this->_currentName = Vi_Language::$currentName; Vi_Language::$currentType = Vi_Language::TYPE_MODULE; Vi_Language::$currentName = $this->_request->getModuleName(); /** * Add include path for controller */ set_include_path(get_include_path() . PATH_SEPARATOR . 'modules/' . Vi_Registry::getModuleName()); /** * start session for system */ $this->session = new Zend_Session_Namespace(Vi_Constant::SESSION_NAMESPACE . "_" . Vi_Registry::getAppName()); Vi_Registry::set('session', $this->session); /** * Load module config */ $this->_config = Vi_Registry::get('config'); $configFile = 'modules/' . $this->_request->getModuleName() . '/config.php'; if (is_file($configFile)) { $moduleConfig = (include $configFile); /** * Unset config item have values as default system */ $this->_unsetConfig($moduleConfig); /** * Merge with system config */ $this->_config = array_merge($this->_config, $moduleConfig); Vi_Registry::set('config', $this->_config); } /** * Load module constant */ $constantFile = 'modules/' . $this->_request->getModuleName() . '/Constant.php'; if (is_file($constantFile)) { include_once $constantFile; } /** * start up the auth */ $this->auth = Vi_Auth::getInstance(); $authStorage = new Vi_Auth_Storage(); $this->auth->setStorage($authStorage); Vi_Registry::set('auth', $this->auth); /** * Only ADMIN application need following function * * Don't remove comment if you need change. * In Vi_Controller_Action_Admin, this function is always loaded */ // $this->_initAcl();//Don't load permission as default }
public function __construct() { parent::__construct(Vi_Constant::SESSION_NAMESPACE . "_" . Vi_Registry::getAppName(), 'user'); }
/** * Processes a template and returns the output. * * @param string $name The template to process. * @return string. */ public function render($name = '') { if ($name == '') { $name = $this->_templateDir . $this->_name . '/' . $this->_name . '.tpl'; if ($this->_sampleMode) { $name = $this->_templateDir . $this->_name . '/' . $this->_name . '-sample.tpl'; } } $this->_data .= $this->view->render($name, Vi_Registry::getAppName() . '|' . $this->_langCode . '|sticker|' . $this->_name); }