Subversion Repositories eFlore/Applications.cel

Rev

Rev 3836 | Rev 3992 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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;
3928 delphine 46
		$criteres['num_nom'] = isset($_GET['nn']) ? $_GET['nn'] : null;
3836 delphine 47
		$criteres['referentiel'] = isset($_GET['referentiel']) ? $_GET['referentiel'] : 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;
3928 delphine 54
		$criteres['projet'] = isset($_GET['projet']) ? $_GET['projet'] : null;
3817 delphine 55
		$criteres['mots_cles'] = isset($_GET['tag']) ? $_GET['tag'] : null;
56
		$criteres['famille'] = isset($_GET['famille']) ? $_GET['famille'] : null;
57
		$criteres['standard'] = isset($_GET['standard']) ? $_GET['standard'] : 1;
58
		$criteres['tri'] = isset($_GET['tri']) ? $_GET['tri'] : self::tri_defaut;
59
		$criteres['dir'] = isset($_GET['dir']) ? $_GET['dir'] : self::dir_defaut;
60
 
61
		$chercheur_images = new RechercheImage($this->config);
3928 delphine 62
		$total = 10; //$chercheur_images->compterImages(null, $criteres);
3817 delphine 63
		$images = $chercheur_images->rechercherImagesJoinObservation(null, $criteres, $this->start, $this->limit);
3836 delphine 64
        $images = $this->mettreEnForme($images);
3818 delphine 65
 
3817 delphine 66
		$resultat = array('total' => $total,'images' => $images);
67
		$images_json = json_encode($resultat);
68
		$images_json = str_replace('\u0000','',$images_json);
69
 
70
		header("content-type: application/json");
71
		print $images_json;
72
		exit();
73
	}
3818 delphine 74
	public function mettreEnForme($images) {
3836 delphine 75
	    $retour = array();
76
	    foreach ($images as $id => $image) {
77
	       $retour[$id]['id_photo'] = $image['id_photo'];
78
	       unset($image['id_photo']);
79
	       $retour[$id]['guid'] = $image['guid'];
80
	       unset($image['guid']);
81
	       $retour[$id]['nom_original'] = $image['nom_original'];
82
	       unset($image['nom_original']);
83
	       $retour[$id]['date_photo'] = $image['date_photo'];
84
	       unset($image['date_photo']);
85
	       $retour[$id]['licence'] = $image['licence'];
86
	       unset($image['licence']);
87
	       $retour[$id]['attribution'] = $image['attribution'];
88
	       unset($image['attribution']);
89
	       $retour[$id]['url_photo'] = $image['url_photo'];
90
	       unset($image['url_photo']);
91
	       $retour[$id]['tags_photo'] = $image['tags_photo'];
92
	       unset($image['tags_photo']);
93
 
94
	       $retour[$id]["utilisateur"]['id_utilisateur'] = $image['id_utilisateur'];
95
	       unset($image['id_utilisateur']);
96
	       $retour[$id]["utilisateur"]['mail_utilisateur'] = $image['mail_utilisateur'];
97
	       unset($image['mail_utilisateur']);
98
	       $retour[$id]["utilisateur"]['nom_utilisateur'] = $image['nom_utilisateur'];
99
	       unset($image['nom_utilisateur']);
100
 
101
	       $retour[$id]['obs'] = $image;
102
	    }
103
	    return $retour;
3818 delphine 104
	}
3817 delphine 105
}