</script> EndHTML; navigation(array(array("title" => "Back", "page" => "dbinit"))); print <<<EndHTML <A HREF="#" ONCLICK="javascript: document.myform.page.value='languages'; submitOptionsValue(); document.myform.submit();" CLASS="submit">Next</A> EndHTML; break; ########################################### ########################################### case 'languages': require_once 'classes/LocaleList.php'; #check for current language code in config.php $CURRENT_LOCALE = $configArray['DEFAULT_LANG']; #pull a list of all available languages (codes and real friendly names) $AVAIL_LOCALE_ARRAY = LocaleList::getAvailableLanguageArray(); print "<h1>Languages Configuration</h1>"; print <<<EndHTML <p>Please select the Authentication Servers default language and locale</p> <div class="language"> <div>Default Server Locale: <select name="default_locale" onchange="newConfig('DEFAULT_LANG=' + this.options[this.selectedIndex].value);"> EndHTML; #for each language in the array get the language code and the friendly name foreach ($AVAIL_LOCALE_ARRAY as $_langIds => $_langNames) { #if the current local in config.php is the same as the current member of the array, select it as default if ($CURRENT_LOCALE == $_langIds) { $_selected = ' selected="selected"'; } else {
/** Initialise the system locale (gettext, setlocale, etc.) * @return boolean true on success, false on failure. */ public static function setCurrentLocale($locale) { $session = Session::getObject(); $AVAIL_LOCALE_ARRAY = LocaleList::getAvailableLanguageArray(); $retval = false; // Get new locale ID, assume default if null if ($locale != null) { $locale_id = $locale->getId(); $retval = true; $q = "parameter"; } else { $locale_id = DEFAULT_LANG; $retval = false; $q = "default"; } //pretty_print_r($locale); //echo sprintf("Debug in /classes/Locale.php setCurentLocale(): locale_id=%s", $locale_id)."<br/>"; if (GETTEXT_AVAILABLE) { $lang_only_locale_id = substr($locale_id, 0, 2); if (!isset($AVAIL_LOCALE_ARRAY[$locale_id]) && !isset($AVAIL_LOCALE_ARRAY[$lang_only_locale_id])) { echo sprintf("Warning in /classes/Locale.php setCurrentLocale: Neither %s or %s are available in AVAIL_LOCALE_ARRAY", $locale_id, $lang_only_locale_id) . "<br/>"; } // Try to set locale $candidate_locale_array[] = str_ireplace('.UTF8', '', $locale_id) . '.UTF-8'; $candidate_locale_array[] = str_ireplace('.UTF8', '', $locale_id); $candidate_locale_array[] = $lang_only_locale_id . '.UTF-8'; $candidate_locale_array[] = $lang_only_locale_id; $current_locale = setlocale(LC_ALL, $candidate_locale_array); //echo sprintf("Warning in /classes/Locale.php setCurentLocale: Unable to setlocale() to %s: %s. I tried %s, %s, %s, %s, and got return value: %s, current locale is: %s",$q, $locale_id, $candidate_locale_array[0], $candidate_locale_array[1], $candidate_locale_array[2], $candidate_locale_array[3], $current_locale, setlocale(LC_ALL, 0))."<br/>"; // Test it against current PHP locale if (substr($current_locale, 0, 2) != $lang_only_locale_id) { echo sprintf("Warning in /classes/Locale.php setCurrentLocale: Unable to setlocale() to %s: %s. I tried %s, %s, %s, %s, and got return value: %s, current locale is: %s", $q, $locale_id, $candidate_locale_array[0], $candidate_locale_array[1], $candidate_locale_array[2], $candidate_locale_array[3], $current_locale, setlocale(LC_ALL, 0)) . "<br/>"; $retval = false; } else { bindtextdomain('messages', WIFIDOG_ABS_FILE_PATH . 'locale'); bind_textdomain_codeset('messages', 'UTF-8'); textDomain('messages'); putenv("LC_ALL=" . $current_locale); putenv("LANGUAGE=" . $current_locale); $retval = true; } } return $retval; }
/** * Get the content to be displayed in the tool pane * * @return string HTML markup * * @access private */ private function getToolContent() { $session = Session::getObject(); $AVAIL_LOCALE_ARRAY = LocaleList::getAvailableLanguageArray(); // Init values $html = ""; $_gwId = null; $_gwAddress = null; $_gwPort = null; $_mac = null; $_selected = ""; $_languageChooser = array(); // Init ALL smarty SWITCH values $this->smarty->assign('sectionSTART', false); $this->smarty->assign('sectionLOGIN', false); // Set section of Smarty template $this->smarty->assign('sectionSTART', true); // Get information about user $_currentUser = User::getCurrentUser(); $_currentUser ? $this->smarty->assign('userListUI', $_currentUser->getListUI()) : $this->smarty->assign('userListUI', ""); $this->smarty->assign('logoutParameters', ""); $this->smarty->assign('loginParameters', ""); $this->smarty->assign('formAction', ""); $this->smarty->assign('toolContent', ""); $this->smarty->assign('accountInformation', ""); $this->smarty->assign('techSupportInformation', ""); $this->smarty->assign('shrinkLeftArea', $this->_shrinkLeftArea); /* * Provide Smarty information about the user's login/logout status */ if ($_currentUser != null) { // User is logged in // Detect gateway information $_gwId = $session->get(SESS_GW_ID_VAR); $_gwAddress = $session->get(SESS_GW_ADDRESS_VAR); $_gwPort = $session->get(SESS_GW_PORT_VAR); $_mac = $session->get(SESS_USER_MAC_VAR); // If gateway information could be detected tell them to Smarty if ($_gwId && $_gwAddress && $_gwPort) { $this->smarty->assign('logoutParameters', "&gw_id=" . $_gwId . "&gw_address=" . $_gwAddress . "&gw_port=" . $_gwPort . ($_mac ? "&mac=" . $_mac : "")); } } else { } /* * Provide Smarty information for the language chooser */ // Assign the action URL for the form $this->smarty->assign('formAction', htmlspecialchars($_SERVER['REQUEST_URI'])); foreach ($AVAIL_LOCALE_ARRAY as $_langIds => $_langNames) { if (Locale::getCurrentLocale()->getId() == $_langIds) { $_selected = ' selected="selected"'; } else { $_selected = ""; } $langName = "{$_langNames[0]}"; $_languageChooser[] = '<option value="' . $_langIds . '"' . $_selected . '>' . $langName . '</option>'; } // Provide Smarty all available languages $this->smarty->assign('languageChooser', $_languageChooser); // Compile HTML code $html = $this->smarty->fetch("templates/classes/MainUI_ToolContent.tpl"); return $html; }