Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev Author Line No. Line
130 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Classe gérant les images.
5
 *
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
14
 */
15
class Images extends Eflore {
624 mathilde 16
 
17
	private $nntaxon;
18
	private $limite;
19
	private $depart;
495 jpm 20
 
624 mathilde 21
	public function setNnTaxon($nntax) {
22
		$this->nntaxon = $nntax;
23
	}
24
 
25
	public function setLimite($limite) {
26
		$this->limite = $limite;
27
	}
28
 
29
	public function setDepart($depart) {
30
		$this->depart = $depart;
31
	}
32
 
339 aurelien 33
	//TODO: créer des fonctions spécifiques cel et photoflora pour plus de clarté ?
130 jpm 34
	public function getUrlsImagesParIdsNoms(Array $idsNoms) {
35
		$infosImages = $this->getInfosImagesParIdsNoms($idsNoms);
36
		$urls = array();
509 jpm 37
		if (count($infosImages) > 0) {
38
			foreach ($infosImages as $img) {
39
				$id = $img['determination.nom_sci.code'];
40
				$urls[$id][] = $img['binaire.href'];
41
			}
130 jpm 42
		}
43
		return $urls;
44
	}
45
 
46
	public function getInfosImagesParIdsNoms(Array $idsNoms) {
898 aurelien 47
		$pas = 800;
48
		if(count($idsNoms) >= $pas) {
49
			$images = array();
50
			$idsPartages = array_chunk($idsNoms, $pas);
51
			foreach ($idsPartages as $sousEnsembleIdsNoms) {
52
				$url = $this->getUrlImagesParIdsNoms($sousEnsembleIdsNoms);
53
				$donnees = $this->chargerDonnees($url);
54
				$resultats = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
55
				$images += $resultats;
56
			}
57
		} else {
58
			$url = $this->getUrlImagesParIdsNoms($idsNoms);
59
			$donnees = $this->chargerDonnees($url);
60
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
61
		}
495 jpm 62
		return $images;
130 jpm 63
	}
495 jpm 64
 
475 delphine 65
	public function getInfosImageParIdImage($id_image) {
66
		$tpl = Config::get('imagesPopupTpl');
495 jpm 67
		$url = $this->formaterUrl($tpl, array('id' => $id_image));
475 delphine 68
		return $this->chargerDonnees($url);
69
	}
624 mathilde 70
 
71
	public function getInfosImages() {
72
		$url = $this->getUrlImages();
73
		$donnees = $this->chargerDonnees($url);
74
		$images = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
75
		return $images;
76
	}
898 aurelien 77
 
624 mathilde 78
	public function getInfosImagesTaxons() {
898 aurelien 79
		$pas = 800;
80
		$idsTaxons = explode(',', $this->nntaxon);
81
		if(count($idsTaxons) >= $pas) {
82
			$images = array();
83
			$idsPartages = array_chunk($idsTaxons, $pas);
84
			foreach ($idsPartages as $sousEnsembleIdsTaxons) {
85
				$url = $this->getUrlImagesTaxons(implode(',',$sousEnsembleIdsTaxons));
86
				$donnees = $this->chargerDonnees($url);
87
				$resultats = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
88
				$images += $resultats;
89
			}
90
		} else {
91
			$url = $this->getUrlImagesTaxons($idsTaxons);
92
			$donnees = $this->chargerDonnees($url);
93
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
94
		}
624 mathilde 95
		return $images;
96
	}
898 aurelien 97
 
130 jpm 98
	private function getUrlImagesParIdsNoms($idsNoms) {
99
		$tpl = Config::get('imagesResultatsDeterminationTpl');
100
		$params = array('idsNoms' => implode(',', $idsNoms));
101
		$url = $this->formaterUrl($tpl, $params);
102
		return $url;
103
	}
495 jpm 104
 
414 delphine 105
	public function getUrlPremiereImageParIdsNoms($idsNoms) {
698 mathilde 106
		$tpl = Config::get('imagesPremiereTpl');
414 delphine 107
		$params = array('idsNoms' => implode(',', $idsNoms));
108
		$url = $this->formaterUrl($tpl, $params);
698 mathilde 109
		$donnees = $this->chargerDonnees($url);
110
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
111
		return $images;
414 delphine 112
	}
624 mathilde 113
 
114
	private function getUrlImages() {
115
		$tpl = Config::get('imagesTpl');
116
		$params = array('projet' => $this->getProjet(), 'limite' => $this->limite, 'depart' => $this->depart);
117
		$url = $this->formaterUrl($tpl, $params);
118
		return $url;
119
	}
120
 
898 aurelien 121
	private function getUrlImagesTaxons($idsTaxons) {
624 mathilde 122
		$tpl = Config::get('imagesTaxonsTpl');
898 aurelien 123
		$params = array('projet' => $this->getProjet(),'nntaxon'=> $idsTaxons);
624 mathilde 124
		$url = $this->formaterUrl($tpl, $params);
125
		return $url;
126
	}
130 jpm 127
}
128
?>