| Line 14... |
Line 14... |
| 14 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
14 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
| 15 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
15 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
| 16 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
16 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
| 17 |
*/
|
17 |
*/
|
| 18 |
class RechercheImage extends Cel {
|
18 |
class RechercheImage extends Cel {
|
| - |
|
19 |
|
| - |
|
20 |
public static $tris_possibles = array(
|
| - |
|
21 |
'ordre',
|
| - |
|
22 |
'taxon',
|
| - |
|
23 |
'transmission',
|
| - |
|
24 |
'zone_geo',
|
| - |
|
25 |
'date_prise_de_vue',
|
| - |
|
26 |
'appareil_fabriquant',
|
| - |
|
27 |
'note_qualite',
|
| - |
|
28 |
'nom_original'
|
| - |
|
29 |
);
|
| Line 19... |
Line 30... |
| 19 |
|
30 |
|
| 20 |
function rechercherImagesEtObservationAssociees($id_utilisateur = null, $criteres = array(), $debut = 0, $limite = 50) {
|
31 |
function rechercherImagesEtObservationAssociees($id_utilisateur = null, $criteres = array(), $debut = 0, $limite = 50) {
|
| Line 21... |
Line 32... |
| 21 |
$images_trouvees = $this->rechercherImages($id_utilisateur, $criteres, $debut, $limite);
|
32 |
$images_trouvees = $this->rechercherImages($id_utilisateur, $criteres, $debut, $limite);
|
| Line 35... |
Line 46... |
| 35 |
unset($criteres['dir']);
|
46 |
unset($criteres['dir']);
|
| Line 36... |
Line 47... |
| 36 |
|
47 |
|
| 37 |
$debut = ($debut < 0) ? 0 : $debut;
|
48 |
$debut = ($debut < 0) ? 0 : $debut;
|
| Line 38... |
Line 49... |
| 38 |
$requete_recherche_images = 'SELECT ci.* ';
|
49 |
$requete_recherche_images = 'SELECT ci.* ';
|
| 39 |
|
50 |
|
| 40 |
if ($this->doitJoindreTableObs($criteres)) {
|
51 |
if ($this->doitJoindreTableObs($criteres, $ordre)) {
|
| 41 |
$requete_recherche_images .= $this->fabriquerRequeteJointureObs();
|
52 |
$requete_recherche_images .= $this->fabriquerRequeteJointureObs();
|
| 42 |
$requete_recherche_images .= ($id_utilisateur != null) ? 'AND ci.ce_utilisateur = '.Cel::db()->proteger($id_utilisateur) : '';
|
53 |
$requete_recherche_images .= ($id_utilisateur != null) ? 'AND ci.ce_utilisateur = '.Cel::db()->proteger($id_utilisateur) : '';
|
| 43 |
} else {
|
54 |
} else {
|
| Line 82... |
Line 93... |
| 82 |
$nb_images = $resultat_requete_nombre_images[0]['nb_images'];
|
93 |
$nb_images = $resultat_requete_nombre_images[0]['nb_images'];
|
| 83 |
}
|
94 |
}
|
| 84 |
return $nb_images;
|
95 |
return $nb_images;
|
| 85 |
}
|
96 |
}
|
| Line 86... |
Line 97... |
| 86 |
|
97 |
|
| - |
|
98 |
private function doitJoindreTableObs($criteres = array(), $tri = "") {
|
| 87 |
private function doitJoindreTableObs($criteres = array()) {
|
99 |
$tris_obs = array('nom_sel','transmission','zone_geo');
|
| 88 |
$criteres_obs = array('zone_geo','ce_zone_geo','taxon','transmission','recherche');
|
100 |
$criteres_obs = array('zone_geo','ce_zone_geo','taxon','transmission','recherche');
|
| - |
|
101 |
return count(array_intersect(array_keys($criteres),$criteres_obs)) > 0 ||
|
| 89 |
return count(array_intersect(array_keys($criteres),$criteres_obs)) > 0;
|
102 |
(!empty($tri) && in_array($tri, $tris_obs));
|
| Line 90... |
Line 103... |
| 90 |
}
|
103 |
}
|
| 91 |
|
104 |
|
| 92 |
private function fabriquerRequeteJointureObs() {
|
105 |
private function fabriquerRequeteJointureObs() {
|