예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * 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
 }
예제 #3
0
 /**
  * Modify parent constructor
  * 
  */
 public function __construct($options = null, $initMvc = false)
 {
     Vi_Language::$currentType = Vi_Language::TYPE_LAYOUT;
     //         Vi_Language::$currentName = &$this->_layout;
     return parent::__construct($options, $initMvc);
 }
예제 #4
0
 public function __destruct()
 {
     Vi_Language::$currentType = $this->_saveInfo['currentType'];
     Vi_Language::$currentName = $this->_saveInfo['currentName'];
 }