Ejemplo n.º 1
0
 /**
  * Ajoute une chaîne de caractère au Langstring
  *
  * @param string $string             La chaîne de caractère à ajouter.  Si la chaîne
  *                                   est vide ('') ou null, la fonction retourne sans
  *                                   toucher à la base de donnée
  * @param string $locale             La langue régionale de la chaîne ajoutée, exemple:
  *                                   'fr_CA', peut être NULL
  * @param bool   $allow_empty_string Allow to store an empty string
  *
  * @return bool True si une chaîne a été ajoutée à la base de donnée,
  * false autrement.
  */
 public function addString($string, $locale = null, $allow_empty_string = false)
 {
     // Init values
     $retval = false;
     $id = 'NULL';
     $idSQL = $id;
     if ($locale) {
         $language = new WifiDogLocale($locale);
         $id = $language->GetId();
         $idSQL = "'" . $id . "'";
     }
     if ($allow_empty_string || $string != null && $string != '') {
         $string = $this->mBd->escapeString($string);
         $this->mBd->execSqlUpdate("INSERT INTO content_langstring_entries (langstring_entries_id, langstrings_id, locales_id, value) VALUES ('" . get_guid() . "', '{$this->id}', {$idSQL} , '{$string}')", FALSE);
         // Create new cache object.
         $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $id . '_string', $this->id);
         // Check if caching has been enabled.
         if ($_cache->isCachingEnabled) {
             // Remove old cached data.
             $_cache->eraseCachedData();
             // Save data into cache.
             $_cache->saveCachedData($string);
         }
         $retval = true;
     }
     return $retval;
 }
Ejemplo n.º 2
0
 /**
  * Used by Langstring::GetString() (and other functions) to help select the
  * best langstring_entry to display to the user.
  * @return A sql fragment
  */
 public static function getSqlCaseStringSelect($locale_id)
 {
     $decomposed_locale = WifiDogLocale::decomposeLocaleId($locale_id);
     // The case will rate locales and choose the best one.
     $sql = " (CASE\n";
     // Look for part of the string or the full-length locale
     $sql .= " WHEN locales_id='{$decomposed_locale['0']}' THEN 1\n";
     // Look for a string or the language part of the locale (match generic language first)
     $sql .= " WHEN locales_id='{$decomposed_locale[1]}' THEN 2\n";
     // Look for the full string or any possible combination
     $sql .= " WHEN locales_id LIKE '{$decomposed_locale[1]}%' THEN 3\n";
     // Look for a string matching the language or the country of the user
     if (!empty($decomposed_locale[2])) {
         $sql .= " WHEN locales_id LIKE '%{$decomposed_locale[2]}' THEN 4\n";
     }
     // Look for a string with no locale associated, it's more likely to be readable than a random string
     $sql .= " WHEN locales_id IS NULL THEN 5\n";
     $sql .= "      ELSE 20 ";
     $sql .= "  END)\n";
     return $sql;
 }
Ejemplo n.º 3
0
 /**
  * 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 (WifiDogLocale::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;
 }
Ejemplo n.º 4
0
 * @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 = WifiDogLocale::getCurrentLocale();
WifiDogLocale::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:
 */
Ejemplo n.º 5
0
 /**
  * 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(WifiDogLocale::getCurrentLocale()->getId(), 0, 2);
                 $_FCKeditor->Config["StylesXmlPath"] = BASE_URL_PATH . "templates/HTMLeditor/css/" . substr(WifiDogLocale::getCurrentLocale()->getId(), 0, 2) . ".xml";
                 $_FCKeditor->Config["TemplatesXmlPath"] = BASE_URL_PATH . "templates/HTMLeditor/templates/" . substr(WifiDogLocale::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);
 }