Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 698 | Rev 947 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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