32,7 → 32,57 |
$this->table_mots_cles = 'cel_arbre_mots_cles_images'; |
} |
} |
|
public function construireRequeteOr($mots_cles) { |
return $this->construireRequete($mots_cles, 'OR'); |
} |
|
public function construireRequeteCheminOr($mots_cles) { |
return $this->construireRequeteChemin($mots_cles, 'OR'); |
} |
|
public function construireRequeteAnd($mots_cles) { |
return $this->construireRequete($mots_cles, 'AND'); |
} |
|
public function construireRequeteCheminAnd($mots_cles) { |
return $this->construireRequeteChemin($mots_cles, 'AND'); |
} |
|
public function construireRequete($mots_cles, $operateur = 'AND') { |
$criteres = array(); |
$premier = array_pop($mots_cles); |
$requete = "SELECT * FROM ".$this->table_liaison." lmc ". |
"INNER JOIN ".$this->table_mots_cles." mc ". |
"ON mc.tag = ".Cel::db()->proteger($premier)." AND lmc.id_mot_cle = mc.id_mot_cle "; |
foreach ($mots_cles as $mot_cle) { |
$requete .= " ".$operateur." id_element_lie IN (SELECT id_element_lie FROM ".$this->table_liaison." lmc ". |
"INNER JOIN ".$this->table_mots_cles." mc ". |
"ON mc.tag = ".Cel::db()->proteger($mot_cle)." AND lmc.id_mot_cle = mc.id_mot_cle ". |
") "; |
} |
|
$images = Cel::db()->requeter($requete); |
return $images; |
} |
|
private function construireRequeteChemin($mots_cles, $operateur = 'AND') { |
$criteres = array(); |
$premier = array_pop($mots_cles); |
$requete = "SELECT * FROM ".$this->table_liaison." lmc ". |
"INNER JOIN ".$this->table_mots_cles." mc ". |
"ON mc.chemin LIKE ".Cel::db()->proteger('%'.$premier.'%')." AND lmc.id_mot_cle = mc.id_mot_cle "; |
foreach ($mots_cles as $mot_cle) { |
$requete .= " ".$operateur." id_element_lie IN (SELECT id_element_lie FROM ".$this->table_liaison." lmc ". |
"INNER JOIN ".$this->table_mots_cles." mc ". |
"ON mc.chemin LIKE ".Cel::db()->proteger('%'.$mot_cle.'%')." AND lmc.id_mot_cle = mc.id_mot_cle ". |
") "; |
} |
|
$images = Cel::db()->requeter($requete); |
return $images; |
} |
|
public function obtenirArbre($id_utilisateur, $chemin = "/") { |
$requete = "SELECT * FROM ".$this->table_mots_cles." ". |
"WHERE id_utilisateur = ".Cel::db()->proteger($id_utilisateur)." AND ". |
203,22 → 253,6 |
return $suppression; |
} |
|
public function supprimerLiaisonPourMotCleEtIdElementLie($mot_cle, $id_element_lie, $id_utilisateur) { |
// supprime toutes les laisons pour un utilisateur et un mot clé (au sens textuel) donnés |
$requete = "DELETE FROM ".$this->table_liaison." ". |
"WHERE id_element_lie = ".Cel::db()->proteger($id_element_lie)." ". |
"AND id_mot_cle IN (". |
"SELECT id_mot_cle FROM ".$this->table_mots_cles." ". |
"WHERE mot_cle = ".Cel::db()->proteger($mot_cle)." ". |
"AND id_utilisateur = ".Cel::db()->proteger($id_utilisateur)." ". |
")"; |
|
$suppression_liaison = Cel::db()->executerRequeteSimple($requete.' -- '.__FILE__.':'.__LINE__); |
$suppression_liaison = ($suppression_liaison !== false); |
|
return $suppression_liaison; |
} |
|
public function renommerMotCle($id_mot_cle, $nouveau_nom) { |
|
$requete_ancien_chemin = 'SELECT chemin, id_utilisateur FROM '.$this->table_mots_cles.' '. |
348,7 → 382,7 |
|
} |
|
public function obtenirIdElementsLiesPourChemins($chemins, $id_utilisateur) { |
public function obtenirIdElementsLiesPourChemins($chemins) { |
foreach($chemins as &$chemin) { |
$chemin = Cel::db()->proteger(self::harmoniserChemin($chemin)); |
} |
355,8 → 389,7 |
|
$requete = 'SELECT id_element_lie FROM '.$this->table_liaison.' cl '. |
'INNER JOIN '.$this->table_mots_cles.' cm '. |
'ON cm.id_mot_cle = cl.id_mot_cle AND chemin IN ('.implode(',', $chemin).') '. |
' AND cm.id_utilisateur = '.Cel::db()->proteger($id_utilisateur); |
'ON cm.id_mot_cle = cl.id_mot_cle AND chemin IN ('.implode(',', $chemin).')'; |
|
$ids_pour_chemin = Cel::db()->executer($requete.' -- '.__FILE__.':'.__LINE__); |
|