Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 898 Rev 947
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;
47
		$pas = 800;
48
		if(count($idsNoms) >= $pas) {
48
		if(count($idsNoms) >= $pas) {
49
			$images = array();
49
			$images = array();
50
			$idsPartages = array_chunk($idsNoms, $pas);
50
			$idsPartages = array_chunk($idsNoms, $pas);
51
			foreach ($idsPartages as $sousEnsembleIdsNoms) {
51
			foreach ($idsPartages as $sousEnsembleIdsNoms) {
52
				$url = $this->getUrlImagesParIdsNoms($sousEnsembleIdsNoms);
52
				$url = $this->getUrlImagesParIdsNoms($sousEnsembleIdsNoms);
53
				$donnees = $this->chargerDonnees($url);
53
				$donnees = $this->chargerDonnees($url);
54
				$resultats = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
54
				$resultats = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
55
				$images += $resultats;
55
				$images += $resultats;
56
			}
56
			}
57
		} else {
57
		} else {
58
			$url = $this->getUrlImagesParIdsNoms($idsNoms);
58
			$url = $this->getUrlImagesParIdsNoms($idsNoms);
59
			$donnees = $this->chargerDonnees($url);
59
			$donnees = $this->chargerDonnees($url);
60
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
60
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
61
		}
61
		}
62
		return $images;
62
		return $images;
63
	}
63
	}
64
 
64
 
65
	public function getInfosImageParIdImage($id_image) {
65
	public function getInfosImageParIdImage($id_image) {
66
		$tpl = Config::get('imagesPopupTpl');
66
		$tpl = Config::get('imagesPopupTpl');
67
		$url = $this->formaterUrl($tpl, array('id' => $id_image));
67
		$url = $this->formaterUrl($tpl, array('id' => $id_image, 'referentiel' => Registre::get('parametres.referentiel')));
68
		return $this->chargerDonnees($url);
68
		return $this->chargerDonnees($url);
69
	}
69
	}
70
	
70
	
71
	public function getInfosImages() {
71
	public function getInfosImages() {
72
		$url = $this->getUrlImages();
72
		$url = $this->getUrlImages();
73
		$donnees = $this->chargerDonnees($url); 
73
		$donnees = $this->chargerDonnees($url); 
74
		$images = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
74
		$images = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
75
		return $images;
75
		return $images;
76
	}
76
	}
77
 
77
 
78
	public function getInfosImagesTaxons() {
78
	public function getInfosImagesTaxons() {
79
		$pas = 800;
79
		$pas = 800;
80
		$idsTaxons = explode(',', $this->nntaxon);
80
		$idsTaxons = explode(',', $this->nntaxon);
81
		if(count($idsTaxons) >= $pas) {
81
		if(count($idsTaxons) >= $pas) {
82
			$images = array();
82
			$images = array();
83
			$idsPartages = array_chunk($idsTaxons, $pas);
83
			$idsPartages = array_chunk($idsTaxons, $pas);
84
			foreach ($idsPartages as $sousEnsembleIdsTaxons) {
84
			foreach ($idsPartages as $sousEnsembleIdsTaxons) {
85
				$url = $this->getUrlImagesTaxons(implode(',',$sousEnsembleIdsTaxons));
85
				$url = $this->getUrlImagesTaxons(implode(',',$sousEnsembleIdsTaxons));
86
				$donnees = $this->chargerDonnees($url);
86
				$donnees = $this->chargerDonnees($url);
87
				$resultats = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
87
				$resultats = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
88
				$images += $resultats;
88
				$images += $resultats;
89
			}
89
			}
90
		} else {
90
		} else {
91
			$url = $this->getUrlImagesTaxons($idsTaxons);
91
			$url = $this->getUrlImagesTaxons($idsTaxons);
92
			$donnees = $this->chargerDonnees($url);
92
			$donnees = $this->chargerDonnees($url);
93
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
93
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
94
		}
94
		}
95
		return $images;
95
		return $images;
96
	}
96
	}
97
	
97
	
98
	private function getUrlImagesParIdsNoms($idsNoms) {
98
	private function getUrlImagesParIdsNoms($idsNoms) {
99
		$tpl = Config::get('imagesResultatsDeterminationTpl');
99
		$tpl = Config::get('imagesResultatsDeterminationTpl');
100
		$params = array('idsNoms' => implode(',', $idsNoms));
100
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'));
101
		$url = $this->formaterUrl($tpl, $params);
101
		$url = $this->formaterUrl($tpl, $params);
102
		return $url;
102
		return $url;
103
	}
103
	}
104
 
104
 
105
	public function getUrlPremiereImageParIdsNoms($idsNoms) {
105
	public function getUrlPremiereImageParIdsNoms($idsNoms) {
106
		$tpl = Config::get('imagesPremiereTpl');
106
		$tpl = Config::get('imagesPremiereTpl');
107
		$params = array('idsNoms' => implode(',', $idsNoms));
107
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'));
108
		$url = $this->formaterUrl($tpl, $params);
108
		$url = $this->formaterUrl($tpl, $params);
109
		$donnees = $this->chargerDonnees($url);
109
		$donnees = $this->chargerDonnees($url);
110
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
110
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
111
		return $images;
111
		return $images;
112
	}
112
	}
113
	
113
	
114
	private function getUrlImages() {
114
	private function getUrlImages() {
115
		$tpl = Config::get('imagesTpl');
115
		$tpl = Config::get('imagesTpl');
116
		$params = array('projet' => $this->getProjet(), 'limite' => $this->limite, 'depart' => $this->depart);
116
		$params = array('projet' => $this->getProjet(), 'limite' => $this->limite, 'depart' => $this->depart, 'referentiel' => Registre::get('parametres.referentiel'));
117
		$url = $this->formaterUrl($tpl, $params);
117
		$url = $this->formaterUrl($tpl, $params);
118
		return $url;
118
		return $url;
119
	}
119
	}
120
	
120
	
121
	private function getUrlImagesTaxons($idsTaxons) {
121
	private function getUrlImagesTaxons($idsTaxons) {
122
		$tpl = Config::get('imagesTaxonsTpl');
122
		$tpl = Config::get('imagesTaxonsTpl');
123
		$params = array('projet' => $this->getProjet(),'nntaxon'=> $idsTaxons);
123
		$params = array('projet' => $this->getProjet(),'nntaxon'=> $idsTaxons, 'referentiel' => Registre::get('parametres.referentiel'));
124
		$url = $this->formaterUrl($tpl, $params);
124
		$url = $this->formaterUrl($tpl, $params);
125
		return $url;
125
		return $url;
126
	}
126
	}
127
}
127
}
128
?>
128
?>