本文整理汇总了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;
}
示例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);
}
}
示例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();
}
}
}
示例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');
}
}
示例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();
}
示例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');
}
}
示例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);
}
示例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];
}