Subversion Repositories eFlore/Applications.cel

Rev

Rev 1395 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
456 aurelien 1
<?php
2458 jpm 2
// declare(encoding='UTF-8');
932 aurelien 3
/**
2458 jpm 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
 */
874 aurelien 18
class InventoryImageListPublic extends Cel {
2458 jpm 19
 
932 aurelien 20
	const start_defaut = 0;
21
	const limit_defaut = 100;
1395 aurelien 22
	const tri_defaut = 'ci.date_creation';
23
	const dir_defaut = 'DESC';
456 aurelien 24
 
2458 jpm 25
	public function getRessource() {
26
 
456 aurelien 27
	}
28
 
2458 jpm 29
	public function getElement($uid) {
30
		// restriction aux observations publiques
31
		$criteres = array('transmission' => '1');
32
 
33
		if ($uid[0] != '*' && empty($_GET)) {
932 aurelien 34
			header("content-type: application/json");
35
			$images_json = json_encode(array());
36
			print $images_json;
2458 jpm 37
			exit();
456 aurelien 38
		}
2458 jpm 39
 
932 aurelien 40
		$this->start = isset($_GET['start']) ? $_GET['start'] : self::start_defaut;
2458 jpm 41
		$this->limit = isset($_GET['limit']) ? $_GET['limit'] : self::limit_defaut;
42
 
932 aurelien 43
		$criteres['mots_cles'] = isset($_GET['tag']) ? $_GET['tag'] : null;
1279 aurelien 44
		$criteres['auteur'] = isset($_GET['auteur']) ? $_GET['auteur'] : null;
932 aurelien 45
		$criteres['zone_geo'] = isset($_GET['commune']) ? $_GET['commune'] : null;
46
		$criteres['taxon'] = isset($_GET['taxon']) ? $_GET['taxon'] : null;
47
		$criteres['ce_zone_geo'] = isset($_GET['dept']) ? $_GET['dept'] : null;
1363 aurelien 48
		$criteres['famille'] = isset($_GET['famille']) ? $_GET['famille'] : null;
1279 aurelien 49
		$criteres['recherche'] = isset($_GET['recherche']) ? $_GET['recherche'] : null;
1395 aurelien 50
		$criteres['tri'] = isset($_GET['tri']) ? $_GET['tri'] : self::tri_defaut;
51
		$criteres['dir'] = isset($_GET['dir']) ? $_GET['dir'] : self::dir_defaut;
2458 jpm 52
 
932 aurelien 53
		$chercheur_images = new RechercheImage($this->config);
1279 aurelien 54
		$total = $chercheur_images->compterImages(null, $criteres);
55
		$images = $chercheur_images->rechercherImages(null, $criteres, $this->start, $this->limit);
456 aurelien 56
 
2458 jpm 57
		$resultat = array('total' => $total,'images' => $images);
58
		$images_json = json_encode($resultat);
761 aurelien 59
		$images_json = str_replace('\u0000','',$images_json);
456 aurelien 60
 
2458 jpm 61
		header("content-type: application/json");
62
		print $images_json;
63
		exit();
605 aurelien 64
	}
2458 jpm 65
}