29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-27 07:33:41 +00:00

# [#23649] Langfilter home page and user site language. Thanks Christophe.

git-svn-id: http://joomlacode.org/svn/joomla/development/trunk@19773 6f6e1ebd-4c2b-0410-823f-f34bde69bce9
This commit is contained in:
Jean-Marie Simonet 2010-12-04 15:59:53 +00:00
parent 6f9ee5c157
commit 8b55658100
5 changed files with 94 additions and 13 deletions

View File

@ -99,4 +99,26 @@ class JMenuSite extends JMenu
}
return parent::getItems($attributes, $values, $firstonly);
}
/**
* Get menu item by id
*
* @param string $language The language code.
*
* @return object The item object
* @since 1.5
*/
function getDefault($language='*')
{
if (array_key_exists($language, $this->_default) && JFactory::getApplication()->getLanguageFilter()) {
return $this->_items[$this->_default[$language]];
}
else if (array_key_exists('*', $this->_default)) {
return $this->_items[$this->_default['*']];
}
else {
return 0;
}
}
}

View File

@ -35,6 +35,7 @@ $ -> Language fix or change
$ Adding missing ini string
#$ Adding Phnom Penh in time zones. Updating xx-XX.ini(s)
# Missing file in [#23016] breaks global config when debug on
# [#23649] Langfilter home page and user site language. Thanks Christophe.
03-Dec-2010 Ian MacLennan
# [#23016] Use minified/uncompressed files for more Scripts (Rouven Weßling)

View File

@ -14,11 +14,12 @@ class modLoginHelper
{
static function getReturnURL($params, $type)
{
$app = JFactory::getApplication();
$router = $app->getRouter();
$url = null;
if ($itemid = $params->get($type))
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$query = $db->getQuery(true);
$query->select($db->nameQuote('link'));
@ -28,12 +29,11 @@ class modLoginHelper
$db->setQuery($query);
if ($link = $db->loadResult()) {
$router = JSite::getRouter();
if ($router->getMode() == JROUTER_MODE_SEF) {
$url = JRoute::_('index.php?Itemid='.$itemid, false);
$url = 'index.php?Itemid='.$itemid;
}
else {
$url = JRoute::_($link.'&Itemid='.$itemid, false);
$url = $link.'&Itemid='.$itemid;
}
}
}
@ -41,7 +41,32 @@ class modLoginHelper
{
// stay on the same page
$uri = JFactory::getURI();
$url = $uri->toString(array('path', 'query', 'fragment'));
$vars = $router->parse($uri);
unset($vars['lang']);
if ($router->getMode() == JROUTER_MODE_SEF)
{
if (isset($vars['Itemid']))
{
$itemid = $vars['Itemid'];
$menu = $app->getMenu();
$item = $menu->getItem($itemid);
unset($vars['Itemid']);
if ($vars == $item->query) {
$url = 'index.php?Itemid='.$itemid;
}
else {
$url = 'index.php?'.JURI::buildQuery($vars).'&Itemid='.$itemid;
}
}
else
{
$url = 'index.php?'.JURI::buildQuery($vars);
}
}
else
{
$url = 'index.php?'.JURI::buildQuery($vars);
}
}
return base64_encode($url);

View File

@ -67,6 +67,12 @@ class plgAuthenticationJoomla extends JPlugin
$user = JUser::getInstance($result->id); // Bring this in line with the rest of the system
$response->email = $user->email;
$response->fullname = $user->name;
if (JFactory::getApplication()->isAdmin()) {
$response->language = $user->getParam('admin_language');
}
else {
$response->language = $user->getParam('language');
}
$response->status = JAUTHENTICATE_STATUS_SUCCESS;
$response->error_message = '';
} else {

View File

@ -57,8 +57,9 @@ class plgSystemLanguageFilter extends JPlugin
$parts = explode('/', $path);
// The language segment is always at the beginning of the route path if it exists.
$sef = '';
if (!empty($parts)) {
$sef = $uri->getVar('lang');
if (!empty($parts) && empty($sef)) {
$sef = reset($parts);
}
}
@ -244,14 +245,40 @@ class plgSystemLanguageFilter extends JPlugin
{
$app->setUserState('com_users.edit.profile.redirect','index.php?Itemid='.$app->getMenu()->getDefault($lang_code)->id.'&lang='.$lang_codes[$lang_code]->sef);
self::$tag = $lang_code;
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);
}
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);
}
}
}
/**
* This method should handle any login logic and report back to the subject
*
* @param array $user Holds the user data
* @param array $options Array holding options (remember, autoregister, group)
*
* @return boolean True on success
* @since 1.5
*/
public function onUserLogin($user, $options = array())
{
$app = JFactory::getApplication();
if ($app->isSite())
{
$lang_code = $user['language'];
if (empty($lang_code)) {
$lang_code = self::$default_lang;
}
self::$tag = $lang_code;
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);
}
}
}