function testCreate() { // attempt to create non-existing locale $locale = Locale::getInstance('enz'); //$this->assertFalse($locale); // create existing locale $locale = Locale::getInstance('en'); $this->assertTrue($locale instanceof Locale); // set as current locale Locale::setCurrentLocale('en'); $current = Locale::getCurrentLocale(); $this->assertSame($current, $locale); }
/** * 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); }
/** * Returns the first available string in the user's language, faling that in the * same major language (first part of the locale), failing that the first available * string * @param bool verbose : Should the function be verbose when a string is empty ? * @return UTF-8 string */ public function getString($verbose = true) { // Init values $retval = null; $row = null; $_useCache = false; $_cachedData = null; // Create new cache objects $_cacheLanguage = new Cache('langstrings_' . $this->id . '_substring_' . substr(Locale::getCurrentLocale()->getId(), 0, 2) . '_string', $this->id); $_cache = new Cache('langstrings_' . $this->id . '_substring__string', $this->id); // Check if caching has been enabled. if ($_cacheLanguage->isCachingEnabled) { $_cachedData = $_cacheLanguage->getCachedData(); if ($_cachedData) { // Return cached data. $_useCache = true; $retval = $_cachedData; } else { // Language specific cached data has not been found. // Try to get language independent cached data. if ($_cachedData = $_cache->getCachedData()) { // Return cached data. $_useCache = true; $retval = $_cachedData; } } } if (!$_useCache) { //Get user's prefered language $sql = "SELECT value, locales_id, \n"; $sql .= Locale::getSqlCaseStringSelect(Locale::getCurrentLocale()->getId()); $sql .= " as score FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '{$this->id}' AND value!='' ORDER BY score LIMIT 1"; $this->mBd->execSqlUniqueRes($sql, $row, false); if ($row == null) { if ($verbose == true) { $retval = sprintf(_("(Empty %s)"), get_class($this)); } else { $retval = ""; } } else { $retval = $row['value']; // Check if caching has been enabled. if ($_cache->isCachingEnabled) { // Save data into cache, because it wasn't saved into cache before. $_cache->saveCachedData($retval); } } } 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; }
* @version Subversion $Id$ * @link http://www.wifidog.org/ */ /** * Load required files */ require_once 'classes/Locale.php'; if (!empty($_REQUEST['wifidog_language'])) { $session = Session::getObject(); //echo "Setting to $_REQUEST[wifidog_language]<br/>"; $AVAIL_LOCALE_ARRAY = LocaleList::getAvailableLanguageArray(); /* Try to guess the lang */ if (!empty($AVAIL_LOCALE_ARRAY[$_REQUEST['wifidog_language']])) { $session->set(SESS_LANGUAGE_VAR, $_REQUEST['wifidog_language']); } else { throw new Exception(htmlspecialchars($_REQUEST['wifidog_language']) . " is not a valid locale"); } } $locale = Locale::getCurrentLocale(); Locale::setCurrentLocale($locale); $locale_id = $locale->getId(); if (isset($smarty)) { $smarty->assign("lang_id", $locale_id); } /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */