Exemple #1
0
 /**
  * Init layout and create a layout 's ins
  */
 public static function startMvc($options = null)
 {
     if (null === self::$_mvcInstance) {
         self::$_mvcInstance = new self($options, true);
     } elseif (is_string($options)) {
         self::$_mvcInstance->setLayoutPath($options);
     } else {
         self::$_mvcInstance->setOptions($options);
     }
     return self::$_mvcInstance;
 }
Exemple #2
0
 public function __construct($params)
 {
     if (Vi_Registry::isRegistered('EDIT_LAYOUT_MODE')) {
         $this->_sampleMode = Vi_Registry::get('EDIT_LAYOUT_MODE');
     }
     $this->_name = $params['name'];
     if (isset($params['title'])) {
         $this->_title = $params['title'];
         $this->_holderId = $params['holder_id'];
     }
     $this->_params = $params;
     $view = Vi_Layout::getMvcInstance()->getView();
     $this->view = clone $view;
     $this->db = Vi_Registry::get('db');
     $this->session = Vi_Registry::getSession();
     $this->auth = Vi_Registry::getAuth();
     $this->aclFront = Vi_Registry::getAclFront();
     $this->aclAdmin = Vi_Registry::getAclAdmin();
     $this->view->setEngine(clone $view->getEngine());
     $this->_langCode = Vi_Language::getCurrentLangCode();
     $config = Vi_Registry::getConfig();
     $this->_compileDir = $config['viewConfig']['compile_dir'];
     $this->_cacheDir = $config['viewConfig']['cache_dir'];
     /*
     * set up dir for smarty
     * 'template_dir' => 'stickers/$stickerName',
     			'compile_dir' => 'tmp/compile/stickers/$stickerName/$langCode',
     			'cache_dir' => 'tmp/cache/stickers/$stickerName/$langCode',
     */
     $this->view->setScriptPath('./');
     $this->view->setCompilePath($config['viewConfig']['compile_dir']);
     $this->view->setCachePath($config['viewConfig']['cache_dir']);
     /*
      * call main funtion
      */
     $this->_saveInfo['currentType'] = Vi_Language::$currentType;
     $this->_saveInfo['currentName'] = Vi_Language::$currentName;
     Vi_Language::$currentType = Vi_Language::TYPE_STICKER;
     Vi_Language::$currentName = $this->_name;
     $this->view->STICKER_URL = Vi_Registry::getBaseUrl() . "stickers/{$this->_name}/";
     $this->view->HELPER_URL = $this->view->STICKER_URL . 'helpers/';
     $this->init();
     $this->run();
 }
 /**
  * Initialize view 
  * 
  * @return void
  */
 public function initView()
 {
     /**
      * Bootstrap views
      */
     $view = new Vi_View('modules/', Vi_Initializer::$_config['viewConfig']);
     /**
      * Register traslation register to translate language in template and layout
      */
     $view->helper->register(new Vi_View_Register_Translation());
     /**
      * Register sticker function to display sticker
      */
     $view->helper->register(new Vi_View_Register_Sticker());
     /**
      * Register holder function to display holder
      */
     $view->helper->register(new Vi_View_Register_Holder());
     /**
      * Register check permission function
      */
     $view->helper->register(new Vi_View_Register_Permission());
     /**
      * Register ViewRender helper
      */
     //        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
     $viewRenderer = new Vi_Controller_Action_Helper_ViewRenderer();
     $viewRenderer->setView($view)->setViewBasePathSpec($view->smarty->template_dir)->setViewScriptPathSpec(':module/views/:controller.:action.:suffix')->setViewScriptPathNoControllerSpec(':action.:suffix')->setViewSuffix(Vi_Constant::VIEW_SUFFIX);
     Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     /**
      * Bootstrap layouts 
      */
     $layout = Vi_Layout::startMvc(array('layoutPath' => $this->_root . 'layouts/' . Vi_Initializer::$_config['layoutCollection'], 'layout' => Vi_Initializer::$_config['defaultLayout'], 'view' => $view, 'contentKey' => Vi_Constant::VIEW_CONTENT_KEY, 'helperClass' => 'Vi_Layout_Controller_Action_Helper_Layout', 'pluginClass' => 'Vi_Layout_Controller_Plugin_Layout', 'viewSuffix' => Vi_Constant::VIEW_SUFFIX));
 }
Exemple #4
0
 /**
  * Modify postDispatch() function of Zend_Controller_Action.
  * This function will set variable for the View after Action executed
  */
 public function postDispatch()
 {
     $this->view->BASE_URL = Vi_Registry::get('BASE_URL');
     $this->view->APP_NAME = Vi_Registry::get('APP_NAME');
     $this->view->APP_BASE_URL = Vi_Registry::get('APP_BASE_URL');
     $this->view->HELPER_URL = $this->view->BASE_URL . 'modules/' . $this->getRequest()->getModuleName() . '/views/helpers/';
     $this->view->LAYOUT_NAME = Vi_Layout::getMvcInstance()->getLayout();
     $layoutCollectionDir = Vi_Layout::getMvcInstance()->getLayoutPath();
     $layoutCollectionUrl = substr($layoutCollectionDir, strlen(Vi_Registry::get('BASE_DIR')));
     $this->view->LAYOUT_URL = $this->view->BASE_URL . $layoutCollectionUrl . '/';
     $this->view->LAYOUT_HELPER_URL = $this->view->LAYOUT_URL . 'helpers/';
     if (Vi_Constant::PRODUCT_MODE != $this->_config['currentMode']) {
         $this->view->isProductMode = false;
     } else {
         $this->view->isProductMode = true;
     }
     $this->view->synchronize();
     /**
      * Registry two variables for using in Vi_Controller_Action_Helper_ViewRenderer::postDispatch()
      */
     Vi_Registry::set('controllerCurrentType', $this->_currentType);
     Vi_Registry::set('controllerCurrentName', $this->_currentName);
 }
 public static function getView()
 {
     return Vi_Layout::getMvcInstance()->getView();
 }