Exemple #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;
 }