Example #1
0
 /**
  * 初始化
  */
 public function init()
 {
     $this->_bootstrap = $this->getInvokeArg('bootstrap');
     $this->_multidb = $this->_bootstrap->getResource('multidb');
     $this->_options = $this->_bootstrap->getOptions();
     $this->_helper->viewRenderer->view->setBasePath(APPLICATION_PATH . '/modules/foreign/views');
     $this->_helper->viewRenderer->setViewScriptPathSpec(':module#:controller#:action.:suffix');
     $this->_tsId = $this->_request->getParam('ts');
     $tuduId = $this->_request->getParam('tid');
     $unId = $this->_request->getParam('fid');
     if (!$this->_tsId || !$tuduId || !$unId) {
         $this->getResponse()->setHttpResponseCode(404);
         $this->getResponse()->sendResponse();
         return;
     }
     Tudu_Dao_Manager::setDbs(array(Tudu_Dao_Manager::DB_TS => $this->getTsDb($this->_tsId)));
     $this->_manager = Tudu_Tudu_Manager::getInstance();
     $this->_deliver = new Tudu_Deliver($this->getTsDb($this->_tsId));
     $this->_tudu = $this->_manager->getTuduById($tuduId, $unId);
     $this->_user = $this->_manager->getUser($tuduId, $unId);
     if (null !== $this->_user) {
         // 用户请求语言
         $language = $this->_request->getHeader('ACCEPT_LANGUAGE');
         if (strpos($language, 'zh') !== false) {
             if (strpos($language, 'hk') !== false || strpos($language, 'tw') !== false) {
                 $language = 'zh_TW';
             } else {
                 $language = 'zh_CN';
             }
         } else {
             $language = 'en_US';
         }
         $this->_user['option'] = array('language' => $language);
         if (null !== $this->_tudu) {
             $this->_session = new Zend_Session_Namespace(self::SESSION_NAMESPACE, true);
             $this->_sessionId = Zend_Session::getId();
             //
             /*if (isset($this->_session->foreign['uniqueid']) && $this->_session->foreign['uniqueid'] != $this->_user['uniqueid']) {
                   $this->_destroySession();
               }*/
             $this->_session->foreign['uniqueid'] = $this->_user['uniqueid'];
             $this->_session->foreign['address'] = $this->_user['email'] ? $this->_user['email'] : $this->_user['uniqueid'];
             $this->_session->foreign['truename'] = $this->_user['truename'];
             $this->_session->foreign['logintime'] = time();
             $this->_session->foreign['orgid'] = $this->_tudu->orgId;
             $this->_session->foreign['tsid'] = $this->_tsId;
             $this->_session->foreign['lasttime'] = time();
             if (empty($this->_session->auth)) {
                 $this->_session->auth = array('uniqueid' => $this->_user['uniqueid'], 'address' => $this->_session->foreign['address'], 'logintime' => $this->_session->foreign['logintime']);
             }
         }
         $this->_timestamp = time();
         $this->view->options = $this->_options;
         $this->view->tsid = $this->_tsId;
         $this->view->user = $this->_user;
     }
 }
 /**
  * This method will returns a resource identified by a key.
  * It will ask to all {@link __ResourceDictionary} instances if any of them has the resource, and will return it if it's found.
  *
  * @param string The resource's key
  * 
  * @return __ResourceBase The requested resource or null if it's not found.
  * 
  */
 public function getResource($resource_key, $language_iso_code = null)
 {
     $return_value = null;
     if ($language_iso_code == null) {
         $language_iso_code = __I18n::getInstance()->getLocale()->getLanguageIsoCode();
     }
     if ($this->_resource_table->hasLanguage($language_iso_code) == false) {
         $this->loadResources($language_iso_code);
     }
     return $this->_resource_table->getResource($resource_key, $language_iso_code);
 }
Example #3
0
 /**
  * 初始化
  */
 public function init()
 {
     $this->_helper->viewRenderer->setNeverRender();
     $this->_bootstrap = $this->getInvokeArg('bootstrap');
     $this->_multidb = $this->_bootstrap->getResource('multidb');
 }