mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-06-27 07:33:41 +00:00
Fixed [#20543] Site language changing does not work
git-svn-id: http://joomlacode.org/svn/joomla/development/trunk@17205 6f6e1ebd-4c2b-0410-823f-f34bde69bce9
This commit is contained in:
parent
452f735f8e
commit
ddc5cf776b
|
@ -163,22 +163,4 @@ class UsersControllerProfile extends UsersController
|
|||
// Flush the data from the session.
|
||||
$app->setUserState('com_users.edit.profile.data', null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to change the user language
|
||||
*
|
||||
* @return void
|
||||
* @since 1.6
|
||||
*/
|
||||
public function language()
|
||||
{
|
||||
// Initialise variables
|
||||
$tag = JRequest::getCmd('language','default');
|
||||
$redirect = JRequest::getVar('redirect');
|
||||
$model = $this->getModel('Profile', 'UsersModel', array('ignore_request' => true));
|
||||
|
||||
$model->setState('language', $tag=='default' ? '' : $tag);
|
||||
$model->language();
|
||||
$this->setRedirect(JRoute::_(base64_decode($redirect),false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,32 +247,4 @@ class UsersModelProfile extends JModelForm
|
|||
|
||||
return $user->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to change the user language
|
||||
*
|
||||
* @return mixed JException on error|true
|
||||
* @since 1.6
|
||||
*/
|
||||
public function language()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$tag = $this->getState('language');
|
||||
$params = JComponentHelper::getParams('com_users');
|
||||
|
||||
if ($user->id && $params->get('autosave_language') == 1) {
|
||||
$user->setParam('language', $tag);
|
||||
// Save the user to the database.
|
||||
if (!$user->save(true)) {
|
||||
return new JException(JText::sprintf('USERS_USER_SAVE_FAILED', $user->getError()), 500);
|
||||
}
|
||||
}
|
||||
|
||||
$config = JFactory::getConfig();
|
||||
$cookie_domain = $config->get('config.cookie_domain', '');
|
||||
$cookie_path = $config->get('config.cookie_path', '/');
|
||||
setcookie(JUtility::getHash('language'), $tag, time() + 365 * 86400, $cookie_path, $cookie_domain);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,11 @@ final class JSite extends JApplication
|
|||
*/
|
||||
private $_language_filter = false;
|
||||
|
||||
/**
|
||||
* Option to detect language by the browser
|
||||
*/
|
||||
private $_detect_browser = false;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
|
@ -73,8 +78,7 @@ final class JSite extends JApplication
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($options['language'])) {
|
||||
if ($this->_language_filter && empty($options['language'])) {
|
||||
// Detect cookie language
|
||||
jimport('joomla.utilities.utility');
|
||||
$lang = JRequest::getString(JUtility::getHash('language'), null ,'cookie');
|
||||
|
@ -94,7 +98,7 @@ final class JSite extends JApplication
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($options['language'])) {
|
||||
if ($this->_detect_browser && empty($options['language'])) {
|
||||
// Detect browser language
|
||||
$lang = JLanguageHelper::detectLanguage();
|
||||
// Make sure that the user's language exists
|
||||
|
@ -505,4 +509,27 @@ final class JSite extends JApplication
|
|||
$this->_language_filter=$state;
|
||||
return $old;
|
||||
}
|
||||
/**
|
||||
* Return the current state of the detect browser option.
|
||||
*
|
||||
* @return boolean
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getDetectBrowser()
|
||||
{
|
||||
return $this->_detect_browser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current state of the detect browser option.
|
||||
*
|
||||
* @return boolean The old state
|
||||
* @since 1.6
|
||||
*/
|
||||
public function setDetectBrowser($state=false)
|
||||
{
|
||||
$old = $this->_detect_browser;
|
||||
$this->_detect_browser=$state;
|
||||
return $old;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ $ -> Language fix or change
|
|||
- -> Removed
|
||||
! -> Note
|
||||
|
||||
20-May-2010 Christophe Demko
|
||||
# Fixed [#20543] Site language changing does not work
|
||||
|
||||
20-May-2010 Jean-Marie Simonet
|
||||
# Fixed accidentally deleted com_users in sql jos_extensions
|
||||
+ Implementing auto language metadata [20284]
|
||||
|
|
|
@ -15,21 +15,6 @@ jimport('joomla.utilities.utility');
|
|||
|
||||
abstract class modLanguagesHelper
|
||||
{
|
||||
/**
|
||||
* Get the language from
|
||||
* - the cookie session if the user is not logged in or
|
||||
* - the user preference
|
||||
*/
|
||||
public static function getTag(&$params)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$tag = JRequest::getString(JUtility::getHash('language'), null ,'cookie');
|
||||
if (empty($tag) && $user->id) {
|
||||
$tag = $user->getParam('language');
|
||||
}
|
||||
return $tag;
|
||||
}
|
||||
|
||||
public static function getList(&$params)
|
||||
{
|
||||
$languages = JLanguageHelper::getLanguages();
|
||||
|
|
|
@ -17,5 +17,4 @@ $headerText = JString::trim($params->get('header_text'));
|
|||
$footerText = JString::trim($params->get('footer_text'));
|
||||
|
||||
$list = modLanguagesHelper::getList($params);
|
||||
$tag = modLanguagesHelper::getTag($params);
|
||||
require JModuleHelper::getLayoutPath('mod_languages', $params->get('layout', 'default'));
|
||||
require JModuleHelper::getLayoutPath('mod_languages', $params->get('layout', 'default'));
|
||||
|
|
Loading…
Reference in New Issue
Block a user