Example #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;
 }
Example #2
0
 * @version    Subversion $Id: language.php 1433 2009-12-07 18:35:05Z benoitg $
 * @link       http://www.wifidog.org/
 */
/**
 * Load required files
 */
require_once 'classes/WifidogLocale.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:
 */
Example #3
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;
 }
Example #4
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', "&amp;gw_id=" . $_gwId . "&amp;gw_address=" . $_gwAddress . "&amp;gw_port=" . $_gwPort . ($_mac ? "&amp;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;
 }