3817 |
delphine |
1 |
<?php
|
|
|
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Service recherche d'images publique a partir de divers critères.
|
|
|
5 |
*
|
|
|
6 |
* @internal Mininum PHP version : 5.2
|
|
|
7 |
* @category CEL
|
|
|
8 |
* @package Services
|
|
|
9 |
* @subpackage Images
|
|
|
10 |
* @version 0.1
|
|
|
11 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
|
|
12 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
13 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
|
|
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>
|
|
|
16 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
|
|
17 |
*/
|
|
|
18 |
class CelWidgetImage extends Cel {
|
|
|
19 |
|
|
|
20 |
const start_defaut = 0;
|
|
|
21 |
const limit_defaut = 100;
|
|
|
22 |
const tri_defaut = 'ci.date_creation';
|
|
|
23 |
const dir_defaut = 'DESC';
|
|
|
24 |
|
|
|
25 |
public function getRessource() {
|
|
|
26 |
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
public function getElement($uid) {
|
|
|
30 |
// restriction aux observations publiques
|
|
|
31 |
$criteres = array('transmission' => '1');
|
|
|
32 |
|
|
|
33 |
if ($uid[0] != '*' && empty($_GET)) {
|
|
|
34 |
header("content-type: application/json");
|
|
|
35 |
$images_json = json_encode(array());
|
|
|
36 |
print $images_json;
|
|
|
37 |
exit();
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
$this->start = isset($_GET['start']) ? $_GET['start'] : self::start_defaut;
|
|
|
41 |
$this->limit = isset($_GET['limit']) ? $_GET['limit'] : self::limit_defaut;
|
|
|
42 |
|
3836 |
delphine |
43 |
|
|
|
44 |
$criteres['recherche'] = isset($_GET['recherche']) ? $_GET['recherche'] : null;
|
|
|
45 |
$criteres['taxon'] = isset($_GET['taxon']) ? $_GET['taxon'] : null;
|
|
|
46 |
$criteres['referentiel'] = isset($_GET['referentiel']) ? $_GET['referentiel'] : null;
|
|
|
47 |
$criteres['taxon'] = isset($_GET['taxon']) ? $_GET['taxon'] : null;
|
|
|
48 |
// date debut - fin
|
|
|
49 |
$criteres['zone_geo'] = isset($_GET['commune']) ? $_GET['commune'] : null;
|
|
|
50 |
$criteres['ce_zone_geo'] = isset($_GET['dept']) ? $_GET['dept'] : null; // separe par ,
|
|
|
51 |
$criteres['pays'] = isset($_GET['pays']) ? $_GET['pays'] : null;
|
|
|
52 |
$criteres['auteur'] = isset($_GET['auteur']) ? $_GET['auteur'] : null;
|
|
|
53 |
$criteres['programme'] = isset($_GET['programme']) ? $_GET['programme'] : null;
|
3817 |
delphine |
54 |
$criteres['mots_cles'] = isset($_GET['tag']) ? $_GET['tag'] : null;
|
|
|
55 |
$criteres['famille'] = isset($_GET['famille']) ? $_GET['famille'] : null;
|
|
|
56 |
$criteres['standard'] = isset($_GET['standard']) ? $_GET['standard'] : 1;
|
|
|
57 |
$criteres['tri'] = isset($_GET['tri']) ? $_GET['tri'] : self::tri_defaut;
|
|
|
58 |
$criteres['dir'] = isset($_GET['dir']) ? $_GET['dir'] : self::dir_defaut;
|
|
|
59 |
|
|
|
60 |
$chercheur_images = new RechercheImage($this->config);
|
|
|
61 |
$total = $chercheur_images->compterImages(null, $criteres);
|
|
|
62 |
$images = $chercheur_images->rechercherImagesJoinObservation(null, $criteres, $this->start, $this->limit);
|
3836 |
delphine |
63 |
$images = $this->mettreEnForme($images);
|
3818 |
delphine |
64 |
|
3817 |
delphine |
65 |
$resultat = array('total' => $total,'images' => $images);
|
|
|
66 |
$images_json = json_encode($resultat);
|
|
|
67 |
$images_json = str_replace('\u0000','',$images_json);
|
|
|
68 |
|
|
|
69 |
header("content-type: application/json");
|
|
|
70 |
print $images_json;
|
|
|
71 |
exit();
|
|
|
72 |
}
|
3818 |
delphine |
73 |
public function mettreEnForme($images) {
|
3836 |
delphine |
74 |
$retour = array();
|
|
|
75 |
foreach ($images as $id => $image) {
|
|
|
76 |
$retour[$id]['id_photo'] = $image['id_photo'];
|
|
|
77 |
unset($image['id_photo']);
|
|
|
78 |
$retour[$id]['guid'] = $image['guid'];
|
|
|
79 |
unset($image['guid']);
|
|
|
80 |
$retour[$id]['nom_original'] = $image['nom_original'];
|
|
|
81 |
unset($image['nom_original']);
|
|
|
82 |
$retour[$id]['date_photo'] = $image['date_photo'];
|
|
|
83 |
unset($image['date_photo']);
|
|
|
84 |
$retour[$id]['licence'] = $image['licence'];
|
|
|
85 |
unset($image['licence']);
|
|
|
86 |
$retour[$id]['attribution'] = $image['attribution'];
|
|
|
87 |
unset($image['attribution']);
|
|
|
88 |
$retour[$id]['url_photo'] = $image['url_photo'];
|
|
|
89 |
unset($image['url_photo']);
|
|
|
90 |
$retour[$id]['tags_photo'] = $image['tags_photo'];
|
|
|
91 |
unset($image['tags_photo']);
|
|
|
92 |
|
|
|
93 |
$retour[$id]["utilisateur"]['id_utilisateur'] = $image['id_utilisateur'];
|
|
|
94 |
unset($image['id_utilisateur']);
|
|
|
95 |
$retour[$id]["utilisateur"]['mail_utilisateur'] = $image['mail_utilisateur'];
|
|
|
96 |
unset($image['mail_utilisateur']);
|
|
|
97 |
$retour[$id]["utilisateur"]['nom_utilisateur'] = $image['nom_utilisateur'];
|
|
|
98 |
unset($image['nom_utilisateur']);
|
|
|
99 |
|
|
|
100 |
$retour[$id]['obs'] = $image;
|
|
|
101 |
}
|
|
|
102 |
return $retour;
|
3818 |
delphine |
103 |
}
|
3817 |
delphine |
104 |
}
|