Beispiel #1
0
         $edmod4 = "selected='selected'";
         break;
     default:
         $edmod1 = "selected='selected'";
         break;
 }
 $cssummary = "<div class='formheader'>" . "<strong>" . $clang->gT("Your personal settings") . "</strong>\n" . "</div>\n" . "<div>\n" . "<form action='{$scriptname}' id='personalsettings' method='post'>" . "<ul>\n";
 $sSavedLanguage = $connect->GetOne("select lang from " . db_table_name('users') . " where uid={$_SESSION['loginID']}");
 // Current language
 $cssummary .= "<li>\n" . "<label for='lang'>" . $clang->gT("Interface language") . ":</label>\n" . "<select id='lang' name='lang'>\n";
 $cssummary .= "<option value='auto'";
 if ($sSavedLanguage == 'auto') {
     $cssummary .= " selected='selected'";
 }
 $cssummary .= ">" . $clang->gT("(Autodetect)") . "</option>\n";
 foreach (getlanguagedata(true) as $langkey => $languagekind) {
     $cssummary .= "<option value='{$langkey}'";
     if ($langkey == $sSavedLanguage) {
         $cssummary .= " selected='selected'";
     }
     $cssummary .= ">" . $languagekind['nativedescription'] . " - " . $languagekind['description'] . "</option>\n";
 }
 $cssummary .= "</select>\n" . "</li>\n";
 // Current htmleditormode
 $cssummary .= "<li>\n" . "<label for='htmleditormode'>" . $clang->gT("HTML editor mode") . ":</label>\n" . "<select id='htmleditormode' name='htmleditormode'>\n" . "<option value='default' {$edmod1}>" . $clang->gT("Default") . "</option>\n" . "<option value='inline' {$edmod3}>" . $clang->gT("Inline HTML editor") . "</option>\n" . "<option value='popup' {$edmod4}>" . $clang->gT("Popup HTML editor") . "</option>\n" . "<option value='none' {$edmod2}>" . $clang->gT("No HTML editor") . "</option>\n";
 $cssummary .= "</select>\n" . "</li>\n";
 // Date format
 $cssummary .= "<li>\n" . "<label for='dateformat'>" . $clang->gT("Date format") . ":</label>\n" . "<select name='dateformat' id='dateformat'>\n";
 foreach (getDateFormatData() as $index => $dateformatdata) {
     $cssummary .= "<option value='{$index}'";
     if ($index == $_SESSION['dateformat']) {
Beispiel #2
0
function makelanguagechanger()
{
    global $relativeurl;
    if (!isset($surveyid)) {
        $surveyid = returnglobal('sid');
    }
    if (isset($surveyid)) {
        $slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
        $sBaseLanguage = GetBaseLanguageFromSurveyID($surveyid);
    }
    $token = sanitize_token(returnglobal('token'));
    if ($token != '') {
        $tokenparam = "&token={$token}";
    } else {
        $tokenparam = "";
    }
    $previewgrp = false;
    if (isset($_REQUEST['action'])) {
        if ($_REQUEST['action'] == 'previewgroup') {
            $previewgrp = true;
        }
    }
    if (!empty($slangs)) {
        if (isset($_SESSION['s_lang']) && $_SESSION['s_lang'] != '') {
            $lang = sanitize_languagecode($_SESSION['s_lang']);
        } else {
            if (isset($_POST['lang']) && $_POST['lang'] != '') {
                $lang = sanitize_languagecode($_POST['lang']);
            } else {
                if (isset($_GET['lang']) && $_GET['lang'] != '') {
                    $lang = sanitize_languagecode($_GET['lang']);
                } else {
                    $lang = $sBaseLanguage;
                }
            }
        }
        $slangs[] = $sBaseLanguage;
        $aAllLanguages = getLanguageData();
        $slangs = array_keys(array_intersect_key($aAllLanguages, array_flip($slangs)));
        // Sort languages by their locale name
        $htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
        $sAddToURL = "";
        $sTargetURL = "{$relativeurl}/index.php";
        if ($previewgrp) {
            $sAddToURL = "&amp;action=previewgroup&amp;gid={$_REQUEST['gid']}";
            $sTargetURL = "";
        }
        foreach ($slangs as $otherlang) {
            $htmlcode .= "\t<option value=\"{$sTargetURL}?sid=" . $surveyid . "&amp;lang=" . $otherlang . "{$tokenparam}{$sAddToURL}\" ";
            if ($otherlang == $lang) {
                $htmlcode .= " selected=\"selected\" ";
            }
            $htmlcode .= ">" . getLanguageNameFromCode($otherlang, false) . "</option>\n";
        }
        $htmlcode .= "</select>\n";
        //    . "</form>";
        return $htmlcode;
    } elseif (!isset($surveyid)) {
        global $defaultlang, $baselang;
        $htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
        $htmlcode .= "<option value=\"{$relativeurl}/index.php?lang=" . $defaultlang . "{$tokenparam}\">" . getLanguageNameFromCode($defaultlang, false) . "</option>\n";
        foreach (getlanguagedata() as $key => $val) {
            $htmlcode .= "\t<option value=\"{$relativeurl}/index.php?lang=" . $key . "{$tokenparam}\" ";
            $htmlcode .= ">" . getLanguageNameFromCode($key, false) . "</option>\n";
        }
        $htmlcode .= "</select>\n";
        return $htmlcode;
    }
}
Beispiel #3
0
function makelanguagechanger()
{
    global $relativeurl;
    if (!isset($surveyid)) {
        $surveyid = returnglobal('sid');
    }
    if (isset($surveyid)) {
        $slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
    }
    $token = sanitize_token(returnglobal('token'));
    if ($token != '') {
        $tokenparam = "&token={$token}";
    } else {
        $tokenparam = "";
    }
    if (!empty($slangs)) {
        if (isset($_SESSION['s_lang']) && $_SESSION['s_lang'] != '') {
            $lang = sanitize_languagecode($_SESSION['s_lang']);
        } else {
            if (isset($_POST['lang']) && $_POST['lang'] != '') {
                $lang = sanitize_languagecode($_POST['lang']);
            } else {
                if (isset($_GET['lang']) && $_GET['lang'] != '') {
                    $lang = sanitize_languagecode($_GET['lang']);
                } else {
                    $lang = GetBaseLanguageFromSurveyID($surveyid);
                }
            }
        }
        $htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
        $htmlcode .= "<option value=\"{$relativeurl}/index.php?sid=" . $surveyid . "&amp;lang=" . $lang . "{$tokenparam}\">" . getLanguageNameFromCode($lang, false) . "</option>\n";
        foreach ($slangs as $otherlang) {
            if ($otherlang != $lang) {
                $htmlcode .= "\t<option value=\"{$relativeurl}/index.php?sid=" . $surveyid . "&amp;lang=" . $otherlang . "{$tokenparam}\" >" . getLanguageNameFromCode($otherlang, false) . "</option>\n";
            }
        }
        if ($lang != GetBaseLanguageFromSurveyID($surveyid)) {
            $htmlcode .= "<option value=\"{$relativeurl}/index.php?sid=" . $surveyid . "&amp;lang=" . GetBaseLanguageFromSurveyID($surveyid) . "{$tokenparam}\">" . getLanguageNameFromCode(GetBaseLanguageFromSurveyID($surveyid), false) . "</option>\n";
        }
        $htmlcode .= "</select>\n";
        //    . "</form>";
        return $htmlcode;
    } elseif (!isset($surveyid)) {
        global $defaultlang, $baselang;
        $htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
        $htmlcode .= "<option value=\"{$relativeurl}/index.php?lang=" . $defaultlang . "{$tokenparam}\">" . getLanguageNameFromCode($defaultlang, false) . "</option>\n";
        foreach (getlanguagedata() as $key => $val) {
            $htmlcode .= "\t<option value=\"{$relativeurl}/index.php?lang=" . $key . "{$tokenparam}\" ";
            if ($key == $baselang) {
                $htmlcode .= " selected=\"selected\" ";
            }
            $htmlcode .= ">" . getLanguageNameFromCode($key, false) . "</option>\n";
        }
        $htmlcode .= "</select>\n";
        return $htmlcode;
    }
}
Beispiel #4
0
function makelanguagechanger()
{
    global $relativeurl;
    if (!isset($surveyid)) {
        $surveyid = returnglobal('sid');
    }
    if (isset($surveyid)) {
        $slangs = GetAdditionalLanguagesFromSurveyID($surveyid);
        $sBaseLanguage = GetBaseLanguageFromSurveyID($surveyid);
    }
    // TODO - When is this needed?
    $token = sanitize_token(returnglobal('token'));
    if ($token != '') {
        $tokenparam = "&token={$token}";
    } else {
        $tokenparam = "";
    }
    $previewgrp = false;
    if (isset($_REQUEST['action'])) {
        if ($_REQUEST['action'] == 'previewgroup') {
            $previewgrp = true;
        }
    }
    if (!empty($slangs)) {
        if (isset($_SESSION['s_lang']) && $_SESSION['s_lang'] != '') {
            $lang = sanitize_languagecode($_SESSION['s_lang']);
        } else {
            if (isset($_POST['lang']) && $_POST['lang'] != '') {
                $lang = sanitize_languagecode($_POST['lang']);
            } else {
                if (isset($_GET['lang']) && $_GET['lang'] != '') {
                    $lang = sanitize_languagecode($_GET['lang']);
                } else {
                    $lang = $sBaseLanguage;
                }
            }
        }
        $slangs[] = $sBaseLanguage;
        $aAllLanguages = getLanguageData();
        $slangs = array_keys(array_intersect_key($aAllLanguages, array_flip($slangs)));
        // Sort languages by their locale name
        // Changed how language changer works so that posts any currently set values.  This also ensures that token (and other) parmeters are also posted.
        //        $htmlcode ="<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
        $htmlcode = "<select name=\"select\" class='languagechanger' " . " onchange=\"javascript:\$('[name=move]').val('changelang_'+ this.value);\$('#limesurvey').submit();\">\n";
        $sAddToURL = "";
        $sTargetURL = "{$relativeurl}/index.php";
        if ($previewgrp) {
            $sAddToURL = "&amp;action=previewgroup&amp;gid={$_REQUEST['gid']}";
            $sTargetURL = "";
        }
        foreach ($slangs as $otherlang) {
            //            $htmlcode .= "\t<option value=\"$sTargetURL?sid=". $surveyid ."&amp;lang=". $otherlang ."$tokenparam$sAddToURL\" ";
            $htmlcode .= "\t<option value=\"" . $otherlang . "\" ";
            if ($otherlang == $lang) {
                $htmlcode .= " selected=\"selected\" ";
            }
            $htmlcode .= ">" . $aAllLanguages[$otherlang]['nativedescription'] . "</option>\n";
        }
        $htmlcode .= "</select>\n";
        //    . "</form>";
        return $htmlcode;
    } elseif (!isset($surveyid)) {
        global $defaultlang, $baselang;
        $htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
        $htmlcode .= "<option value=\"{$relativeurl}/index.php?lang=" . $defaultlang . "{$tokenparam}\">" . getLanguageNameFromCode($defaultlang, false) . "</option>\n";
        foreach (getlanguagedata() as $key => $val) {
            $htmlcode .= "\t<option value=\"{$relativeurl}/index.php?lang=" . $key . "{$tokenparam}\" ";
            $htmlcode .= ">" . getLanguageNameFromCode($key, false) . "</option>\n";
        }
        $htmlcode .= "</select>\n";
        return $htmlcode;
    }
}