本文整理汇总了PHP中getBrowserLanguage函数的典型用法代码示例。如果您正苦于以下问题:PHP getBrowserLanguage函数的具体用法?PHP getBrowserLanguage怎么用?PHP getBrowserLanguage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getBrowserLanguage函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _sessioncontrol
/**
* Load and set session vars
*
* @access protected
* @return void
*/
protected function _sessioncontrol()
{
Yii::import('application.libraries.Limesurvey_lang');
// From personal settings
if (Yii::app()->request->getPost('action') == 'savepersonalsettings') {
if (Yii::app()->request->getPost('lang') == 'auto') {
$sLanguage = getBrowserLanguage();
} else {
$sLanguage = Yii::app()->request->getPost('lang');
}
Yii::app()->session['adminlang'] = $sLanguage;
}
if (empty(Yii::app()->session['adminlang'])) {
Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang");
}
global $clang;
// Needed so EM can localize equation hints until a better solution is found
$this->lang = $clang = new Limesurvey_lang(Yii::app()->session['adminlang']);
Yii::app()->setLang($this->lang);
if (!empty($this->user_id)) {
$this->_GetSessionUserRights($this->user_id);
}
}
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:29,代码来源:CronController.php
示例2: personalsettings
/**
* Manage user personal settings
*/
function personalsettings()
{
// Save Data
if (Yii::app()->request->getPost("action")) {
$aData = array('lang' => Yii::app()->request->getPost('lang'), 'dateformat' => Yii::app()->request->getPost('dateformat'), 'htmleditormode' => Yii::app()->request->getPost('htmleditormode'), 'questionselectormode' => Yii::app()->request->getPost('questionselectormode'), 'templateeditormode' => Yii::app()->request->getPost('templateeditormode'));
$uresult = User::model()->updateByPk(Yii::app()->session['loginID'], $aData);
if (Yii::app()->request->getPost('lang') == 'auto') {
$sLanguage = getBrowserLanguage();
} else {
$sLanguage = Yii::app()->request->getPost('lang');
}
Yii::app()->session['adminlang'] = $sLanguage;
Yii::app()->lang = new limesurvey_lang($sLanguage);
$clang = Yii::app()->lang;
Yii::app()->session['htmleditormode'] = Yii::app()->request->getPost('htmleditormode');
Yii::app()->session['questionselectormode'] = Yii::app()->request->getPost('questionselectormode');
Yii::app()->session['templateeditormode'] = Yii::app()->request->getPost('templateeditormode');
Yii::app()->session['dateformat'] = Yii::app()->request->getPost('dateformat');
Yii::app()->session['flashmessage'] = $clang->gT("Your personal settings were successfully saved.");
}
// Get user lang
$user = User::model()->findByPk(Yii::app()->session['loginID']);
$aData['sSavedLanguage'] = $user->lang;
// Render personal settings view
$this->_renderWrappedTemplate('user', 'personalsettings', $aData);
}
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:29,代码来源:useraction.php
示例3: postLogin
protected function postLogin()
{
$user = $this->getUser();
App()->user->login($this);
// Check for default password
if ($this->password === 'password') {
Yii::app()->setFlashMessage(gT("Warning: You are still using the default password ('password'). Please change your password and re-login again."), 'warning');
}
if ((int) App()->request->getPost('width', '1280') < 1280) {
Yii::app()->setFlashMessage(gT("Your browser screen size is too small to use the administration properly. The minimum size required is 1280*1024 px."), 'error');
}
// Do session setup
Yii::app()->session['loginID'] = (int) $user->uid;
Yii::app()->session['user'] = $user->users_name;
Yii::app()->session['full_name'] = $user->full_name;
Yii::app()->session['htmleditormode'] = $user->htmleditormode;
Yii::app()->session['templateeditormode'] = $user->templateeditormode;
Yii::app()->session['questionselectormode'] = $user->questionselectormode;
Yii::app()->session['dateformat'] = $user->dateformat;
Yii::app()->session['session_hash'] = hash('sha256', getGlobalSetting('SessionName') . $user->users_name . $user->uid);
// Perform language settings
if (App()->request->getPost('loginlang', 'default') != 'default') {
$user->lang = sanitize_languagecode(App()->request->getPost('loginlang'));
$user->save();
$sLanguage = $user->lang;
} else {
if ($user->lang == 'auto' || $user->lang == '') {
$sLanguage = getBrowserLanguage();
} else {
$sLanguage = $user->lang;
}
}
Yii::app()->session['adminlang'] = $sLanguage;
App()->setLanguage($sLanguage);
}
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:35,代码来源:LSUserIdentity.php
示例4: postLogin
protected function postLogin()
{
$user = $this->getUser();
App()->user->login($this);
// Check for default password
if ($this->password === 'password') {
App()->user->setFlash('pwdnotify', gT('Warning: You are still using the default password (\'password\'). Please change your password and re-login again.'));
}
// Do session setup
Yii::app()->session['loginID'] = (int) $user->uid;
Yii::app()->session['user'] = $user->users_name;
Yii::app()->session['useremail'] = $user->email;
Yii::app()->session['full_name'] = $user->full_name;
Yii::app()->session['htmleditormode'] = $user->htmleditormode;
Yii::app()->session['templateeditormode'] = $user->templateeditormode;
Yii::app()->session['questionselectormode'] = $user->questionselectormode;
Yii::app()->session['dateformat'] = $user->dateformat;
Yii::app()->session['session_hash'] = hash('sha256', getGlobalSetting('SessionName') . $user->users_name . $user->uid);
// Perform language settings
if (App()->request->getPost('loginlang', 'default') != 'default') {
$user->lang = sanitize_languagecode(App()->request->getPost('loginlang'));
$user->save();
$sLanguage = $user->lang;
} else {
if ($user->lang == 'auto' || $user->lang == '') {
$sLanguage = getBrowserLanguage();
} else {
$sLanguage = $user->lang;
}
}
Yii::app()->session['adminlang'] = $sLanguage;
$lang = new limesurvey_lang($sLanguage);
App()->lang = $lang;
App()->getController()->lang = $lang;
}
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:35,代码来源:LSUserIdentity.php
示例5: _setLanguageSettings
/**
* Sets the language settings for the user
* @param CActiveRecord $user
*/
private function _setLanguageSettings($user)
{
if (Yii::app()->request->getPost('loginlang', 'default') != 'default') {
$user->lang = sanitize_languagecode(Yii::app()->request->getPost('loginlang'));
$user->save();
$sLanguage = $user->lang;
} else {
if ($user->lang == 'auto' || $user->lang == '') {
$sLanguage = getBrowserLanguage();
} else {
$sLanguage = $user->lang;
}
}
Yii::app()->session['adminlang'] = $sLanguage;
$this->getController()->lang = new limesurvey_lang($sLanguage);
}
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:20,代码来源:authentication.php
示例6: _sessioncontrol
/**
* Load and set session vars
*
* @access protected
* @return void
*/
protected function _sessioncontrol()
{
// From personal settings
if (Yii::app()->request->getPost('action') == 'savepersonalsettings') {
if (Yii::app()->request->getPost('lang') == 'auto') {
$sLanguage = getBrowserLanguage();
} else {
$sLanguage = sanitize_languagecode(Yii::app()->request->getPost('lang'));
}
Yii::app()->session['adminlang'] = $sLanguage;
}
if (empty(Yii::app()->session['adminlang'])) {
Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang");
}
Yii::app()->setLanguage(Yii::app()->session["adminlang"]);
if (!empty($this->user_id)) {
$this->_GetSessionUserRights($this->user_id);
}
}
开发者ID:sickpig,项目名称:LimeSurvey,代码行数:25,代码来源:AdminController.php
示例7: personalsettings
/**
* Manage user personal settings
*/
public function personalsettings()
{
// Save Data
if (Yii::app()->request->getPost("action")) {
$aData = array('lang' => Yii::app()->request->getPost('lang'), 'dateformat' => Yii::app()->request->getPost('dateformat'), 'htmleditormode' => Yii::app()->request->getPost('htmleditormode'), 'questionselectormode' => Yii::app()->request->getPost('questionselectormode'), 'templateeditormode' => Yii::app()->request->getPost('templateeditormode'));
$uresult = User::model()->updateByPk(Yii::app()->session['loginID'], $aData);
if (Yii::app()->request->getPost('lang') == 'auto') {
$sLanguage = getBrowserLanguage();
} else {
$sLanguage = Yii::app()->request->getPost('lang');
}
Yii::app()->session['adminlang'] = $sLanguage;
Yii::app()->setLanguage($sLanguage);
Yii::app()->session['htmleditormode'] = Yii::app()->request->getPost('htmleditormode');
Yii::app()->session['questionselectormode'] = Yii::app()->request->getPost('questionselectormode');
Yii::app()->session['templateeditormode'] = Yii::app()->request->getPost('templateeditormode');
Yii::app()->session['dateformat'] = Yii::app()->request->getPost('dateformat');
Yii::app()->session['flashmessage'] = gT("Your personal settings were successfully saved.");
if (Yii::app()->request->getPost("saveandclose")) {
$this->getController()->redirect(array("admin/survey/sa/index"));
}
} else {
$aData = array();
}
// Get user lang
$user = User::model()->findByPk(Yii::app()->session['loginID']);
$aData['sSavedLanguage'] = $user->lang;
$aData['fullpagebar']['savebutton']['form'] = 'personalsettings';
$aData['fullpagebar']['saveandclosebutton']['form'] = 'personalsettings';
$aData['fullpagebar']['closebutton']['url'] = 'admin/survey/sa/index';
// Close button
// Render personal settings view
if (isset($_POST['saveandclose'])) {
$this->getController()->redirect(array("admin/user/sa/index"));
} else {
$this->_renderWrappedTemplate('user', 'personalsettings', $aData);
}
}
开发者ID:sickpig,项目名称:LimeSurvey,代码行数:41,代码来源:useraction.php
示例8: getBrowserLanguage
function getBrowserLanguage()
{
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
$acceptLanguage = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
global $LANGUAGES;
$parts = split(";", $acceptLanguage);
foreach (split(",", $parts[0]) as $langRegion) {
$lang = split("-", $langRegion);
if (in_array($lang[0], $LANGUAGES)) {
return $lang[0];
}
}
}
return "en";
}
$LANGUAGE = getBrowserLanguage();
function loadTranslations($filepattern)
{
global $LANGUAGE;
require_once sprintf($filepattern, "en");
include_once sprintf($filepattern, $LANGUAGE);
}
// Echo a translated message or log an error.
function MSG($message)
{
global $MESSAGES;
global $LANGUAGE;
global $HTTP_ACCEPT_LANGUAGE;
$translation = $MESSAGES[$LANGUAGE][$message];
if (!isset($translation)) {
$translation = $MESSAGES["en"][$message];
开发者ID:rec,项目名称:radio,代码行数:31,代码来源:messages.php
示例9: personalsettings
/**
* Manage user personal settings
*/
public function personalsettings()
{
// Save Data
if (Yii::app()->request->getPost("action")) {
$aData = array('lang' => Yii::app()->request->getPost('lang'), 'dateformat' => Yii::app()->request->getPost('dateformat'), 'htmleditormode' => Yii::app()->request->getPost('htmleditormode'), 'questionselectormode' => Yii::app()->request->getPost('questionselectormode'), 'templateeditormode' => Yii::app()->request->getPost('templateeditormode'), 'full_name' => Yii::app()->request->getPost('fullname'), 'email' => Yii::app()->request->getPost('email'));
if (Yii::app()->request->getPost('password') != '' && !Yii::app()->getConfig('demoMode')) {
if (Yii::app()->request->getPost('password') == Yii::app()->request->getPost('repeatpassword')) {
$aData['password'] = hash("sha256", Yii::app()->request->getPost('password'));
} else {
Yii::app()->setFlashMessage(gT("Your new password was not saved because the passwords did not match."), 'error');
}
}
$uresult = User::model()->updateByPk(Yii::app()->session['loginID'], $aData);
if (Yii::app()->request->getPost('lang') == 'auto') {
$sLanguage = getBrowserLanguage();
} else {
$sLanguage = Yii::app()->request->getPost('lang');
}
Yii::app()->session['adminlang'] = $sLanguage;
Yii::app()->setLanguage($sLanguage);
Yii::app()->session['htmleditormode'] = Yii::app()->request->getPost('htmleditormode');
Yii::app()->session['questionselectormode'] = Yii::app()->request->getPost('questionselectormode');
Yii::app()->session['templateeditormode'] = Yii::app()->request->getPost('templateeditormode');
Yii::app()->session['dateformat'] = Yii::app()->request->getPost('dateformat');
Yii::app()->setFlashMessage(gT("Your personal settings were successfully saved."));
if (Yii::app()->request->getPost("saveandclose")) {
$this->getController()->redirect(array("admin/survey/sa/index"));
}
} else {
$aData = array();
}
// Get user lang
$user = User::model()->findByPk(Yii::app()->session['loginID']);
$aLanguageData = array('auto' => gT("(Autodetect)"));
foreach (getLanguageData(true, Yii::app()->session['adminlang']) as $langkey => $languagekind) {
$aLanguageData[$langkey] = html_entity_decode($languagekind['nativedescription'] . ' - ' . $languagekind['description'], ENT_COMPAT, 'utf-8');
}
$aData['aLanguageData'] = $aLanguageData;
$aData['sSavedLanguage'] = $user->lang;
$aData['sUsername'] = $user->users_name;
$aData['sFullname'] = $user->full_name;
$aData['sEmailAdress'] = $user->email;
$aData['fullpagebar']['savebutton']['form'] = 'personalsettings';
$aData['fullpagebar']['saveandclosebutton']['form'] = 'personalsettings';
$aData['fullpagebar']['closebutton']['url_keep'] = true;
$aData['fullpagebar']['closebutton']['url'] = Yii::app()->request->getUrlReferrer(Yii::app()->createUrl("admin/user/sa/index"));
// Render personal settings view
if (isset($_POST['saveandclose'])) {
$this->getController()->redirect(array("admin/user/sa/index"));
} else {
$this->_renderWrappedTemplate('user', 'personalsettings', $aData);
}
}
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:56,代码来源:useraction.php
示例10: elseif
return false;
} elseif (strlen($letter) > 1) {
return false;
} elseif ($letter == $exception) {
return true;
} elseif (!preg_match("/[A-Z\\s_]/i", $letter) > 0) {
return false;
} else {
return true;
}
}
$LangUI = new LangUI();
// handles translations
global $g_browser_lang;
// give global access to this information
$g_browser_lang = getBrowserLanguage();
// preg_match for letters, numbers, underscore, and hyphen. Reject anything else
$g_browser_lang = preg_match('/^(\\w|\\-)+$/', $g_browser_lang) ? $g_browser_lang : null;
// Load the language file based on config or logged in user
if ($SMObj->getUserID() != NULL) {
$userID = $SMObj->getUserID();
$details = $SMObj->getUserDetails($userID);
include "lang/" . $details['language'] . ".php";
} else {
if (isset($g_browser_lang)) {
//we found a browser match load it if it exists
if (file_exists('lang/' . $g_browser_lang . '.php')) {
include "lang/" . $g_browser_lang . ".php";
} else {
include "lang/" . $g_rb_language . ".php";
}
开发者ID:pjflameboy,项目名称:phprecipebook,代码行数:31,代码来源:index.php
注:本文中的getBrowserLanguage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论