/** * Retreives the admin interface of this object. Anything that overrides * this method should call the parent method with it's output at the END of * processing. * @param string $subclass_admin_interface HTML content of the interface * element of a children. * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE * pour voir toutes les chaînes, LARGE pour * avoir un textarea. * @return string The HTML fragment for this interface. */ public function getAdminUI($subclass_admin_interface = null, $title = null, $type_interface = "LARGE") { // Init values. $html = ''; $html .= $subclass_admin_interface; $result = ""; //$variantsCounter = 0; //$_hideNewContent = false; if (!empty($this->allowed_html_tags)) { $html .= "<div class='admin_section_hint'>" . _("Only these HTML tags are allowed : ") . htmlentities($this->allowed_html_tags) . "</div>"; } $html .= "<ul class='admin_element_list'>\n"; $sql = "SELECT * FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '{$this->id}' ORDER BY locales_id"; $this->mBd->execSql($sql, $result, false); //echo "type_interface: $type_interface\n"; $exclude_array = array(); if ($result != null) { while (list($key, $value) = each($result)) { $exclude_array[$value['locales_id']] = $value['locales_id']; // The next lines are a preview of a new suggested input mode // ========================================================== // // // Increase variants counter // $variantsCounter++; // // // Hide new content input // $_hideNewContent = true; // // $html .= "<li class='admin_element_item_container'>\n"; // $html .= "<div class='admin_element_data'>\n"; // // if ($type_interface == 'LARGE') { // $html .= "<textarea name='langstrings_".$this->id."_substring_$value[langstring_entries_id]_string' cols='60' rows='3'>".htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8')."</textarea>\n"; // } else { // $html .= "<input type='text' name='langstrings_".$this->id."_substring_$value[langstring_entries_id]_string' size='44' value='".htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8')."'>\n"; // } // // $html .= "<div class='admin_element_data' id='langstrings_".$this->id."_substring_$value[langstring_entries_id]_language_section' style='display: none;'>\n"; // $html .= LocaleList::GenererFormSelect("$value[locales_id]", "langstrings_".$this->id."_substring_$value[langstring_entries_id]_language", null, TRUE); // $html .= "</div>\n"; // // $html .= "</div>\n"; // $html .= "<div class='admin_element_tools'>\n"; // $name = "langstrings_".$this->id."_substring_$value[langstring_entries_id]_erase"; // // // Choose language button // $html .= "<a href='javascript:showHideView(\"langstrings_".$this->id."_substring_$value[langstring_entries_id]_language_section\", \"langstrings_".$this->id."_substring_$value[langstring_entries_id]_language_section_image\");'><img src='" . BASE_SSL_PATH . "images/icons/language.gif' id='langstrings_".$this->id."_substring_$value[langstring_entries_id]_language_section_image' class='admin_section_button' alt='"._("Choose language")."' title='"._("Choose language")."'></a>"; // // // Add string button // if (count($result) == $variantsCounter) { // // This is the last string variant - show "add string" button. // $html .= "<a href='javascript:showHideView(\"langstrings_".$this->id."_add_new_entry_view\", \"langstrings_".$this->id."_add_new_entry_image\");'><img src='" . BASE_SSL_PATH . "images/icons/add.gif' id='langstrings_".$this->id."_add_new_entry_image' class='admin_section_button' alt='"._("Add new string")."' title='"._("Add new string")."'></a>"; // } else { // $html .= "<img src='" . BASE_SSL_PATH . "images/icons/add.gif' id='langstrings_".$this->id."_add_new_entry_image' class='admin_section_button_disabled' alt='"._("Add new string")."' title='"._("Add new string")."'>"; // } // // // Delete string button // $html .= "<input type='image' name='$name' class='admin_section_button' src='" . BASE_SSL_PATH . "images/icons/delete.gif' alt='"._("Delete string")."' title='"._("Delete string")."'>"; // // $html .= "</div>\n"; // $html .= "</li>\n"; $html .= "<li class='admin_element_item_container'>\n"; $html .= "<div class='admin_element_data'>\n"; $html .= _("Language") . ": " . LocaleList::GenererFormSelect("{$value['locales_id']}", "langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_language", null, TRUE); if ($type_interface == 'LARGE') { $html .= "<textarea name='langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_string' class='textarea' cols='60' rows='3'>" . htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8') . "</textarea>\n"; } else { $html .= "<input type='text' size='80' class='input_text' name='langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_string' value='" . htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8') . "'>\n"; } $html .= "</div>\n"; $html .= "<div class='admin_element_tools'>\n"; $name = "langstrings_" . $this->id . "_substring_{$value['langstring_entries_id']}_erase"; $html .= "<input type='submit' class='submit' name='{$name}' value='" . _("Delete string") . "'>"; $html .= "</div>\n"; $html .= "</li>\n"; } } // The next lines are a preview of a new suggested input mode // ========================================================== // // //Nouvelles chaîne // $locale = LocaleList :: GetDefault(); // // $html .= "<li class='admin_element_item_container' id='langstrings_".$this->id."_add_new_entry_view'" . ($_hideNewContent ? " style='display: none;'" : "") . ">\n"; // $html .= "<div class='admin_element_data'>\n"; // // $new_substring_name = "langstrings_".$this->id."_substring_new_string"; // // if ($type_interface == 'LARGE') { // $html .= "<textarea name='$new_substring_name' cols='60' rows='3'></textarea>\n"; // } else { // $html .= "<input type='text' name='$new_substring_name' size='44' value=''>\n"; // } // // $html .= "<div class='admin_element_data' id='langstrings_".$this->id."_substring_new_language_section'>\n"; // $html .= "<img src='" . BASE_SSL_PATH . "images/icons/language.gif' id='langstrings_".$this->id."_substring_new_language_section_image' class='admin_section_button' alt='"._("Choose language")."' title='"._("Choose language")."'>"; // $html .= LocaleList::GenererFormSelect($locale, "langstrings_".$this->id."_substring_new_language", null, TRUE); // $html .= "</div>\n"; // // $html .= "</div>\n"; // $html .= "<div class='admin_element_tools'>\n"; // // $new_substring_submit_name = "langstrings_".$this->id."_add_new_entry"; // // // Add string button // $html .= "<input type='image' name='$new_substring_submit_name' class='admin_section_button' src='" . BASE_SSL_PATH . "images/icons/add.gif' alt='"._("Add new string")."' title='"._("Add new string")."'>"; // // $html .= "</div>\n"; // $html .= "</li>\n"; // // $html .= "</ul>\n"; // $html .= "</div>\n"; //Nouvelles chaîne $html .= "<li class='admin_element_item_container'>\n"; $userData['excludeArray'] = $exclude_array; $userData['typeInterface'] = $type_interface; $html .= self::getNewUI($this->id, $userData); $html .= "</li>\n"; $html .= "</ul>\n"; return parent::getAdminUI($html, $title); }
/** 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; }
</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 {
/** * Retreives the admin interface of this object. Anything that overrides * this method should call the parent method with it's output at the END of * processing. * @param string $subclass_admin_interface HTML content of the interface * element of a children. * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE * pour voir toutes les chaînes, LARGE pour * avoir un textarea. * @return string The HTML fragment for this interface. */ public function getAdminUI($subclass_admin_interface = null, $title = null, $type_interface = "LARGE") { if ($this->_FCKeditorAvailable) { // Init values $_result = null; $html = ''; $html .= $subclass_admin_interface; $html .= "<ul class='admin_element_list'>\n"; $html .= "<li class='admin_element_item_container content_html_editor'>\n"; $html .= "<ul class='admin_element_list'>\n"; $sql = "SELECT * FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '{$this->id}' ORDER BY locales_id"; $this->mBd->execSql($sql, $_result, FALSE); // Show existing content if ($_result != null) { while (list($_key, $_value) = each($_result)) { $html .= "<li class='admin_element_item_container'>\n"; $html .= "<div class='admin_element_data'>\n"; $html .= _("Language") . ": " . LocaleList::GenererFormSelect($_value["locales_id"], "langstrings_" . $this->id . "_substring_" . $_value["langstring_entries_id"] . "_language", null, TRUE); $_FCKeditor = new FCKeditor('langstrings_' . $this->id . '_substring_' . $_value["langstring_entries_id"] . '_string'); $_FCKeditor->BasePath = SYSTEM_PATH . "lib/FCKeditor/"; $_FCKeditor->Config["CustomConfigurationsPath"] = BASE_URL_PATH . "js/HTMLeditor.js"; $_FCKeditor->Config["AutoDetectLanguage"] = false; $_FCKeditor->Config["DefaultLanguage"] = substr(Locale::getCurrentLocale()->getId(), 0, 2); $_FCKeditor->Config["StylesXmlPath"] = BASE_URL_PATH . "templates/HTMLeditor/css/" . substr(Locale::getCurrentLocale()->getId(), 0, 2) . ".xml"; $_FCKeditor->Config["TemplatesXmlPath"] = BASE_URL_PATH . "templates/HTMLeditor/templates/" . substr(Locale::getCurrentLocale()->getId(), 0, 2) . ".xml"; $_FCKeditor->ToolbarSet = "WiFiDOG"; $_FCKeditor->Value = $_value['value']; if ($type_interface == 'LARGE') { $_FCKeditor->Height = 400; } else { $_FCKeditor->Height = 200; } $_FCKeditor->Width = 386; $html .= $_FCKeditor->CreateHtml(); $html .= "</div>\n"; $html .= "<div class='admin_element_tools'>\n"; $_name = "langstrings_" . $this->id . "_substring_" . $_value["langstring_entries_id"] . "_erase"; $html .= "<input type='submit' class='submit' name='{$_name}' value='" . _("Delete string") . "'>"; $html .= "</div>\n"; $html .= "</li>\n"; } } // Editor for new content $html .= "<li class='admin_element_item_container'>\n"; $userData['typeInterface'] = $type_interface; $html .= self::getNewUI($this->id, $userData); $html .= "</li>\n"; $html .= "</ul>\n"; $html .= "</li>\n"; $html .= "</ul>\n"; } else { $html = ''; $html .= _("FCKeditor is not installed"); } return Content::getAdminUI($html, $title); }
/** * 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; }