| Line 21... |
Line 21... |
| 21 |
public function getElement($param = array()) {
|
21 |
public function getElement($param = array()) {
|
| 22 |
// Initialisation des variables
|
22 |
// Initialisation des variables
|
| 23 |
$info = array();
|
23 |
$info = array();
|
| Line 24... |
Line 24... |
| 24 |
|
24 |
|
| 25 |
// Pré traitement des paramêtres
|
25 |
// Pré traitement des paramêtres
|
| Line 26... |
Line 26... |
| 26 |
$p = $this->traiterParametresUrl(array('id_projet', 'id_commentaire', 'titre'), $param);
|
26 |
$p = $this->traiterParametresUrl(array('id_projet', 'id_commentaire', 'recherche'), $param);
|
| 27 |
|
27 |
|
| 28 |
// Construction de la requête
|
28 |
// Construction de la requête
|
| 29 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ccm.*, '.
|
29 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ccm.*, '.
|
| Line 34... |
Line 34... |
| 34 |
' LEFT JOIN coel_collection_a_commentaire AS ccac ON (ccm_id_commentaire = ccac_id_commentaire) '.
|
34 |
' LEFT JOIN coel_collection_a_commentaire AS ccac ON (ccm_id_commentaire = ccac_id_commentaire) '.
|
| 35 |
' LEFT JOIN coel_collection ON (ccac_id_collection = cc_id_collection) '.
|
35 |
' LEFT JOIN coel_collection ON (ccac_id_collection = cc_id_collection) '.
|
| 36 |
((count($p) != 0) ? 'WHERE ' : '').
|
36 |
((count($p) != 0) ? 'WHERE ' : '').
|
| 37 |
(isset($p['id_projet']) ? "AND ccm_ce_projet = {$p['id_projet']} " : '').
|
37 |
(isset($p['id_projet']) ? "AND ccm_ce_projet = {$p['id_projet']} " : '').
|
| 38 |
(isset($p['id_commentaire']) ? "AND ccm_id_commentaire = {$p['id_commentaire']} " : '').
|
38 |
(isset($p['id_commentaire']) ? "AND ccm_id_commentaire = {$p['id_commentaire']} " : '').
|
| 39 |
(isset($p['titre']) ? "AND ccm_titre LIKE {$p['titre']} " : '').
|
39 |
(isset($p['recherche']) ? $this->construireWhereRecherche($p['recherche']) : '').
|
| 40 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'ccm_id_commentaire ASC').' ';
|
40 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'ccm_id_commentaire ASC').' ';
|
| 41 |
$requete = str_replace('WHERE AND', 'WHERE', $requete);
|
41 |
$requete = str_replace('WHERE AND', 'WHERE', $requete);
|
| 42 |
$requeteCount = $requete;
|
42 |
$requeteCount = $requete;
|
| 43 |
$requete .= "LIMIT $this->start, $this->limit ";
|
43 |
$requete .= "LIMIT $this->start, $this->limit ";
|
| Line 61... |
Line 61... |
| 61 |
}
|
61 |
}
|
| Line 62... |
Line 62... |
| 62 |
|
62 |
|
| 63 |
// Envoie sur la sortie standard
|
63 |
// Envoie sur la sortie standard
|
| 64 |
$this->envoyer($info);
|
64 |
$this->envoyer($info);
|
| - |
|
65 |
}
|
| - |
|
66 |
|
| - |
|
67 |
private function construireWhereRecherche($recherche) {
|
| - |
|
68 |
$recherche_public = null;
|
| - |
|
69 |
if(strstr(strtolower($recherche),'public')) {
|
| - |
|
70 |
$recherche_public = 1;
|
| - |
|
71 |
}
|
| - |
|
72 |
if(strstr(strtolower($recherche),'prive') || strstr(strtolower($recherche),'privé')) {
|
| - |
|
73 |
$recherche_public = 0;
|
| - |
|
74 |
}
|
| - |
|
75 |
|
| - |
|
76 |
$sous_requete_type = 'SELECT cmlv_id_valeur '.
|
| - |
|
77 |
'FROM coel_meta_liste_valeur '.
|
| - |
|
78 |
'WHERE cmlv_nom LIKE '.$recherche.' '.
|
| - |
|
79 |
'AND cmlv_ce_parent = 1068';
|
| - |
|
80 |
$types = $this->bdd->query($sous_requete_type)->fetchAll(PDO::FETCH_ASSOC);
|
| - |
|
81 |
$str_types = "";
|
| - |
|
82 |
foreach($types as $type) {
|
| - |
|
83 |
$str_types .= "ccac_truk_type LIKE ".$this->bdd->quote("%".$type['cmlv_id_valeur'].'%')." OR ";
|
| - |
|
84 |
}
|
| - |
|
85 |
|
| - |
|
86 |
$recherche = "AND ".
|
| - |
|
87 |
"(".
|
| - |
|
88 |
$str_types.
|
| - |
|
89 |
"ccm_titre LIKE {$recherche} OR ".
|
| - |
|
90 |
"ccm_ponderation LIKE {$recherche} ".
|
| - |
|
91 |
($recherche_public !== null ? ("OR ccm_mark_public LIKE {$recherche_public} ") : "").
|
| - |
|
92 |
")";
|
| - |
|
93 |
return $recherche;
|
| Line 65... |
Line 94... |
| 65 |
}
|
94 |
}
|
| 66 |
|
95 |
|
| 67 |
/**
|
96 |
/**
|
| 68 |
* Méthode appelée pour ajouter un élément.
|
97 |
* Méthode appelée pour ajouter un élément.
|