Ejemplo n.º 1
0
function shGuessLanguageAndRedirect($queryString)
{
    if (!sh404SEF_DE_ACTIVATE_LANG_AUTO_REDIRECT && shIsMultilingual() == 'joomfish') {
        $cookieLang = shGetCookieLanguage();
        $sessionExists = shLookupSession();
        $reqLang = shGetUrlVar($queryString, 'lang', '');
        $targetLang = '';
        if (empty($cookieLang)) {
            // this is really first visit (or visitor does not accept cookie)
            $discoveredLang = shGetParamUserLanguage();
            if ($discoveredLang != $reqLang) {
                $targetLang = $discoveredLang;
            }
        }
        if (!empty($targetLang)) {
            // 303 redirect to same URL in preferred language
            $queryString = shSetURLVar('index.php?' . $queryString, 'lang', $targetLang);
            $target = JRoute::_($queryString);
            _log('Redirecting (303) to user language |cookie = ' . $cookieLang . '|session=' . $sessionExists . '|req=' . $reqLang . '|target=' . $targetLang);
            shRedirect($target, '', 303);
        }
    }
}
Ejemplo n.º 2
0
function shGuessLanguageAndRedirect($queryString)
{
    if (!sh404SEF_DE_ACTIVATE_LANG_AUTO_REDIRECT && shIsMultilingual() == 'joomfish') {
        $cookieLang = shGetCookieLanguage();
        $sessionExists = shLookupSession();
        $reqLang = JRequest::getVar('lang', '');
        $targetLang = '';
        if (!$sessionExists) {
            // no session and not coming from self
            if (empty($cookieLang)) {
                // this is really first visit (or visitor does not accept cookie)
                $discoveredLang = shGetParamUserLanguage();
                if ($discoveredLang != $reqLang) {
                    $targetLang = $discoveredLang;
                }
            } else {
                // returning visitor, with only a cookie set
                if ($cookieLang != $reqLang) {
                    $targetLang = $cookieLang;
                }
            }
        }
        if (!empty($targetLang)) {
            // 303 redirect to same URL in preferred language
            $queryString = shSetURLVar('index.php?' . $queryString, 'lang', $targetLang);
            _log('Redirecting (303) to user language |cookie = ' . $cookieLang . '|session=' . $sessionExists . '|req=' . $reqLang . '|target=' . $targetLang);
            shRedirect($GLOBALS['shConfigLiveSite'] . '/' . $queryString, '', 303);
        }
    }
}