當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfWebRequest::getPreferredCulture方法代碼示例

本文整理匯總了PHP中sfWebRequest::getPreferredCulture方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfWebRequest::getPreferredCulture方法的具體用法?PHP sfWebRequest::getPreferredCulture怎麽用?PHP sfWebRequest::getPreferredCulture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sfWebRequest的用法示例。


在下文中一共展示了sfWebRequest::getPreferredCulture方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: executeIndex

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->getParameter('sf_culture')) {
         $ssaml = new SimpleSAML_Auth_Simple('default-sp');
         $attributes = $ssaml->getAttributes();
         if ($this->getUser()->isFirstRequest()) {
             if (array_key_exists('preferredLanguage', $attributes)) {
                 $culture = $attributes['preferredLanguage'];
                 if ($culture != 'hu' && $culture != 'en') {
                     $culture = $request->getPreferredCulture(array('en', 'hu'));
                 }
             } else {
                 $culture = $request->getPreferredCulture(array('en', 'hu'));
             }
             $this->getUser()->setCulture($culture);
             $this->getUser()->isFirstRequest(false);
         } else {
             $culture = $this->getUser()->getCulture();
         }
         $this->redirect('localized_homepage');
     }
     $p = Doctrine::getTable('Principal')->findOneByFedid($this->getUser()->getUsername());
     if ($p) {
         $oos = $p->getOrganization();
         $ros = $p->getRelatedOrganizations(TRUE);
     } else {
         $p = new Principal();
         $p->setFedid($this->getUser()->getUsername());
         $p->save();
     }
     $this->oos = $oos;
     $this->ros = $ros;
 }
開發者ID:br00k,項目名稱:yavom,代碼行數:38,代碼來源:actions.class.php

示例2: executeSwitch

 public function executeSwitch(sfWebRequest $request)
 {
     $referer = $request->getReferer();
     if ($request->hasParameter("lang")) {
         $lang = $request->getParameter('lang');
     } else {
         $lang = $request->getPreferredCulture(array('en', 'hu'));
     }
     if ($lang != 'en' && $lang != 'hu') {
         $lang = $request->getPreferredCulture(array('en', 'hu'));
     }
     $this->getUser()->setCulture($lang);
     $pos = strpos($referer, '/hu/');
     if ($pos === false) {
         $pos = strpos($referer, '/en/');
         if ($pos === false) {
             $whereto = false;
         } else {
             $eleje = substr($referer, 0, $pos);
             $whereto = substr($referer, $pos + 4);
         }
     } else {
         $eleje = substr($referer, 0, $pos);
         $whereto = substr($referer, $pos + 4);
     }
     if (!$whereto) {
         $this->redirect('localized_homepage');
     } else {
         $this->redirect($eleje . "/" . $lang . "/" . $whereto);
     }
 }
開發者ID:br00k,項目名稱:yavom,代碼行數:31,代碼來源:actions.class.php

示例3: executeIndex

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->getParameter('sf_culture')) {
         if ($this->getUser()->isFirstRequest()) {
             $culture = $request->getPreferredCulture(array('pt', 'en'));
             $this->getUser()->setCulture($culture);
             $this->getUser()->isFirstRequest(false);
         } else {
             $culture = $this->getUser()->getCulture();
         }
     }
 }
開發者ID:kidh0,項目名稱:hboaventura-home,代碼行數:17,代碼來源:actions.class.php

示例4: executeIndex

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->getParameter('sf_culture')) {
         if ($this->getUser()->isFirstRequest()) {
             $culture = $request->getPreferredCulture(array('en', 'es'));
             $this->getUser()->setCulture($culture);
             $this->getUser()->isFirstRequest(false);
         } else {
             $culture = $this->getUser()->getCulture();
         }
         $this->redirect('localized_homepage');
     }
 }
開發者ID:BGCX067,項目名稱:f2gsym-svn-to-git,代碼行數:18,代碼來源:actions.class.php

示例5: executeIndex

 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->getParameter('sf_culture')) {
         if ($this->getUser()->isFirstRequest()) {
             $culture = $request->getPreferredCulture(array('en', 'fr'));
             $this->getUser()->setCulture($culture);
             $this->getUser()->isFirstRequest(false);
         } else {
             $culture = $this->getUser()->getCulture();
         }
         $this->redirect('localized_homepage');
     }
     $this->categories = Doctrine_Core::getTable('JobeetCategory')->getWithJobs();
 }
開發者ID:yodacode,項目名稱:Jobeet,代碼行數:14,代碼來源:actions.class.php

示例6: executeIndex

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->getParameter('sf_culture')) {
         $ssaml = new SimpleSAML_Auth_Simple('default-sp');
         $attributes = $ssaml->getAttributes();
         //die(var_dump($attributes['preferredLanguage']));
         if ($this->getUser()->isFirstRequest()) {
             if (array_key_exists('preferredLanguage', $attributes)) {
                 $culture = $attributes['preferredLanguage'];
                 if ($culture != 'hu' && $culture != 'en') {
                     $culture = $request->getPreferredCulture(array('hu', 'en'));
                 }
             } else {
                 $culture = $request->getPreferredCulture(array('hu', 'en'));
             }
             $this->getUser()->setCulture($culture);
             $this->getUser()->isFirstRequest(false);
         } else {
             $culture = $this->getUser()->getCulture();
         }
         $this->redirect('localized_homepage');
     }
 }
開發者ID:br00k,項目名稱:yavom,代碼行數:28,代碼來源:actions.class.php

示例7: executeIndex

 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->getParameter('sf_culture')) {
         if ($this->getUser()->isFirstRequest()) {
             $culture = $request->getPreferredCulture(array('en', 'hr'));
             $this->getUser()->setCulture($culture);
             $this->getUser()->isFirstRequest(false);
         } else {
             $culture = $this->getUser()->getCulture();
         }
         $this->redirect('homepage');
     }
     $this->cities = Doctrine_Core::getTable('city')->TopCities(8);
     $this->apartments = Doctrine_Core::getTable('apartment')->LastAdded(9);
 }
開發者ID:alifst11,項目名稱:symfonybooking,代碼行數:15,代碼來源:actions.class.php

示例8: getPreferredCountry

 /**
  * Gets the preferred country of the user based on the browser request.
  *
  * @return string country
  **/
 public static function getPreferredCountry(sfWebRequest $request)
 {
     $culture = explode('_', $request->getPreferredCulture());
     return count($culture) > 1 ? $culture[1] : $culture[0];
 }
開發者ID:solutema,項目名稱:siwapp-sf1,代碼行數:10,代碼來源:CultureTools.class.php


注:本文中的sfWebRequest::getPreferredCulture方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。