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;
|
3992 |
delphine |
46 |
$criteres['num_nom'] = isset($_GET['num_nom']) ? $_GET['num_nom'] : null;
|
3994 |
delphine |
47 |
$criteres['num_nom'] = isset($_GET['num_taxon']) ? $_GET['num_taxon'] : null; //à faire
|
3836 |
delphine |
48 |
$criteres['referentiel'] = isset($_GET['referentiel']) ? $_GET['referentiel'] : null;
|
3994 |
delphine |
49 |
$criteres['date'] = isset($_GET['date']) ? $_GET['date'] : null;
|
|
|
50 |
$criteres['date_deb'] = isset($_GET['date_deb']) ? $_GET['date_deb'] : null;
|
|
|
51 |
$criteres['date_fin'] = isset($_GET['date_fin']) ? $_GET['date_fin'] : null;
|
|
|
52 |
$criteres['annee'] = isset($_GET['annee']) ? $_GET['annee'] : null;
|
3836 |
delphine |
53 |
// date debut - fin
|
|
|
54 |
$criteres['zone_geo'] = isset($_GET['commune']) ? $_GET['commune'] : null;
|
3992 |
delphine |
55 |
$criteres['dept'] = isset($_GET['dept']) ? $_GET['dept'] : null; // separe par ,
|
3836 |
delphine |
56 |
$criteres['pays'] = isset($_GET['pays']) ? $_GET['pays'] : null;
|
|
|
57 |
$criteres['auteur'] = isset($_GET['auteur']) ? $_GET['auteur'] : null;
|
|
|
58 |
$criteres['programme'] = isset($_GET['programme']) ? $_GET['programme'] : null;
|
3928 |
delphine |
59 |
$criteres['projet'] = isset($_GET['projet']) ? $_GET['projet'] : null;
|
3817 |
delphine |
60 |
$criteres['mots_cles'] = isset($_GET['tag']) ? $_GET['tag'] : null;
|
3994 |
delphine |
61 |
$criteres['mots_cles'] = isset($_GET['mots_cles']) ? $_GET['mots_cles'] : null;
|
3817 |
delphine |
62 |
$criteres['famille'] = isset($_GET['famille']) ? $_GET['famille'] : null;
|
|
|
63 |
$criteres['standard'] = isset($_GET['standard']) ? $_GET['standard'] : 1;
|
3994 |
delphine |
64 |
$criteres['transmission'] = 1;
|
3817 |
delphine |
65 |
$criteres['tri'] = isset($_GET['tri']) ? $_GET['tri'] : self::tri_defaut;
|
|
|
66 |
$criteres['dir'] = isset($_GET['dir']) ? $_GET['dir'] : self::dir_defaut;
|
|
|
67 |
|
|
|
68 |
$chercheur_images = new RechercheImage($this->config);
|
3992 |
delphine |
69 |
$total = $chercheur_images->compterImages(null, $criteres);
|
3817 |
delphine |
70 |
$images = $chercheur_images->rechercherImagesJoinObservation(null, $criteres, $this->start, $this->limit);
|
3836 |
delphine |
71 |
$images = $this->mettreEnForme($images);
|
3818 |
delphine |
72 |
|
3817 |
delphine |
73 |
$resultat = array('total' => $total,'images' => $images);
|
|
|
74 |
$images_json = json_encode($resultat);
|
|
|
75 |
$images_json = str_replace('\u0000','',$images_json);
|
|
|
76 |
|
|
|
77 |
header("content-type: application/json");
|
|
|
78 |
print $images_json;
|
|
|
79 |
exit();
|
|
|
80 |
}
|
3818 |
delphine |
81 |
public function mettreEnForme($images) {
|
3836 |
delphine |
82 |
$retour = array();
|
|
|
83 |
foreach ($images as $id => $image) {
|
|
|
84 |
$retour[$id]['id_photo'] = $image['id_photo'];
|
|
|
85 |
unset($image['id_photo']);
|
|
|
86 |
$retour[$id]['guid'] = $image['guid'];
|
|
|
87 |
unset($image['guid']);
|
|
|
88 |
$retour[$id]['nom_original'] = $image['nom_original'];
|
|
|
89 |
unset($image['nom_original']);
|
|
|
90 |
$retour[$id]['date_photo'] = $image['date_photo'];
|
|
|
91 |
unset($image['date_photo']);
|
|
|
92 |
$retour[$id]['licence'] = $image['licence'];
|
|
|
93 |
unset($image['licence']);
|
|
|
94 |
$retour[$id]['attribution'] = $image['attribution'];
|
|
|
95 |
unset($image['attribution']);
|
|
|
96 |
$retour[$id]['url_photo'] = $image['url_photo'];
|
|
|
97 |
unset($image['url_photo']);
|
|
|
98 |
$retour[$id]['tags_photo'] = $image['tags_photo'];
|
|
|
99 |
unset($image['tags_photo']);
|
|
|
100 |
|
|
|
101 |
$retour[$id]["utilisateur"]['id_utilisateur'] = $image['id_utilisateur'];
|
|
|
102 |
unset($image['id_utilisateur']);
|
|
|
103 |
$retour[$id]["utilisateur"]['mail_utilisateur'] = $image['mail_utilisateur'];
|
|
|
104 |
unset($image['mail_utilisateur']);
|
|
|
105 |
$retour[$id]["utilisateur"]['nom_utilisateur'] = $image['nom_utilisateur'];
|
|
|
106 |
unset($image['nom_utilisateur']);
|
|
|
107 |
|
|
|
108 |
$retour[$id]['obs'] = $image;
|
|
|
109 |
}
|
|
|
110 |
return $retour;
|
3818 |
delphine |
111 |
}
|
3817 |
delphine |
112 |
}
|