57,16 → 57,31 |
return $ids_enfants; |
} |
|
public function insererParChemin($mot_cle, $chemin_parent, $id_utilisateur) { |
public function insererParCheminSiInexistant($mot_cle, $chemin_parent, $id_utilisateur) { |
$chemin_mot_cle = self::getCheminHarmonise($chemin_parent, $mot_cle); |
$requete_mot_cle_existe = "SELECT id_mot_cle FROM ".$this->table_mots_cles." ". |
"WHERE chemin = ".Cel::db()->proteger($chemin_mot_cle)." AND ". |
"id_utilisateur = ".Cel::db()->proteger($id_utilisateur); |
|
$requete = "INSERT IGNORE INTO ".$this->table_mots_cles." (chemin, id_utilisateur, tag) ". |
$infos_mot_cle = Cel::db()->executerRequete($requete_mot_cle_existe.' -- '.__FILE__.':'.__LINE__); |
|
if(!empty($infos_mot_cle)) { |
$id_mot_cle = $infos_mot_cle[0]['id_mot_cle']; |
} else { |
$id_mot_cle = $this->insererParChemin($mot_cle, $chemin_parent, $id_utilisateur); |
} |
return $id_mot_cle; |
} |
|
public function insererParChemin($mot_cle, $chemin_parent, $id_utilisateur) { |
$chemin_mot_cle = self::getCheminHarmonise($chemin_parent, $mot_cle); |
$requete = "INSERT INTO ".$this->table_mots_cles." (chemin, id_utilisateur, mot_cle) ". |
"VALUES (". |
Cel::db()->proteger($chemin_mot_cle).", ". |
Cel::db()->proteger($id_utilisateur).", ". |
Cel::db()->proteger($mot_cle)." ". |
")"; |
|
") "; |
|
$insertion = Cel::db()->executer($requete.' -- '.__FILE__.':'.__LINE__); |
$resultat = false; |
if($insertion !== false) { |
151,7 → 166,7 |
implode(',', $combinaisons).' '. |
"ON DUPLICATE KEY UPDATE id_element_lie = id_element_lie "; |
$liaison = Cel::db()->executer($requete.' -- '.__FILE__.':'.__LINE__); |
|
|
return $liaison; |
} |
|
348,6 → 363,19 |
|
} |
|
public function obtenirIdsMotClesPourMotsCles($mots_cles, $id_utilisateur) { |
$mots_cles_p = array(); |
foreach($mots_cles as $mot_cle) { |
$mots_cles_p[] = Cel::db()->proteger($mot_cle); |
} |
|
$requete = "SELECT id_mot_cle, mot_cle FROM ".$this->table_mots_cles." ". |
"WHERE mot_cle IN (".implode(',', $mots_cles_p).") ". |
"AND id_utilisateur = ".Cel::db()->proteger($id_utilisateur); |
|
return Cel::db()->executer($requete.' -- '.__FILE__.':'.__LINE__); |
} |
|
public function obtenirIdElementsLiesPourChemins($chemins, $id_utilisateur) { |
foreach($chemins as &$chemin) { |
$chemin = Cel::db()->proteger(self::harmoniserChemin($chemin)); |
450,27 → 478,6 |
static public function simplifier($text) |
{ |
return trim(str_replace(array('\\','/'), '', $text)); |
// replace non letter or digits by - |
$text = preg_replace('~[^\\pL\d]+~u', '-', $text); |
|
// trim |
$text = trim($text, '-'); |
|
// transliterate |
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); |
|
// lowercase |
$text = strtolower($text); |
|
// remove unwanted characters |
$text = preg_replace('~[^-\w]+~', '', $text); |
|
if (empty($text)) |
{ |
return 'n-a'; |
} |
|
return $text; |
} |
|
static public function startsWith($haystack, $needle) { |