Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 990 Rev 1036
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module Liste.
4
 * Classe mère du module Liste.
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 Illustrations extends aControleur {
15
class Illustrations extends aControleur {
16
 
16
 
17
	private $conteneur = null;
17
	private $conteneur = null;
18
	private $nomCourant = null;
18
	private $nomCourant = null;
19
	private $images = null;
19
	private $images = null;
20
	private $appUrls = null;
20
	private $appUrls = null;
21
	private $meta = null;
21
	private $meta = null;
22
	private $referentiel = 'bdtfx';
22
	private $referentiel = 'bdtfx';
23
	private $donnees = array();
23
	private $donnees = array();
24
 
24
 
25
	public function __construct(Conteneur $conteneur) {
25
	public function __construct(Conteneur $conteneur) {
26
		$this->conteneur = $conteneur;
26
		$this->conteneur = $conteneur;
27
		$this->nomCourant = $this->conteneur->getNomCourant();
27
		$this->nomCourant = $this->conteneur->getNomCourant();
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
29
		$this->images = $this->conteneur->getApiImages();
29
		$this->images = $this->conteneur->getApiImages();
30
		$this->appUrls = $this->conteneur->getAppUrls();
30
		$this->appUrls = $this->conteneur->getAppUrls();
31
		$this->meta = $this->conteneur->getApiMetaDonnees();
31
		$this->meta = $this->conteneur->getApiMetaDonnees();
32
	}
32
	}
33
 
33
 
34
	public function getDonnees() {
34
	public function getDonnees() {
35
		$this->donnees = array();
35
		$this->donnees = array();
36
		$this->getPhotos();
36
		$this->getPhotos();
37
		$dessin = $this->addDessin();
37
		$dessin = $this->addDessin();
38
		if (!empty($dessin)) {
38
		if (!empty($dessin)) {
39
			array_push($this->donnees, $dessin);	
39
			array_push($this->donnees, $dessin);	
40
		}
40
		}
41
 
41
 
42
		return $this->donnees;
42
		return $this->donnees;
43
	}
43
	}
44
	
44
	
45
	public function getPhotos() {
45
	public function getPhotos() {
46
		$projets[] = Config::get($this->referentiel.'.baseImages');
46
		$url_picto = $this->obtenirUrlPicto();
47
		$projets[] = Config::get($this->referentiel.'.baseImagesSupp');
47
		$obj =  json_decode(file_get_contents($url_picto), true);
-
 
48
		
48
		foreach ($projets as $projet) {
49
		$arr = $obj['resultats'];
49
			if ($projet != "") {
50
		//echo '<pre>'.print_r($obj, true).'</pre>';
50
				$images = $this->initialiserPhotos($projet);
51
		foreach($arr as $index) {
51
				$this->formaterListePhotos($projet, $images);
52
			$this->formaterListePhotos($index);
52
			}
-
 
53
		}
53
		}
54
	}
54
	}
-
 
55
 
-
 
56
	
-
 
57
	public function obtenirUrlPicto() {
-
 
58
		$url_picto = "http://www.tela-botanica.org/eflore/del/services/0.1/images?navigation.depart=0"
-
 
59
					."&navigation.limite=4&masque.nn=".$this->nomCourant->getNnr()
-
 
60
					."&tri=votes&ordre=desc&protocole=1";
55
	
-
 
56
	private function initialiserPhotos($projet) {
-
 
57
		$this->images->setProjet($projet);
61
	
58
		$nnr = $this->nomCourant->getNnr();
-
 
59
		return $this->images->getInfosImagesParIdsNoms(array($nnr));
62
		return ($url_picto);
60
	}
63
	}
61
	
-
 
62
	private function formaterListePhotos($projet, $images) {
-
 
63
		$max = Config::get('pictures.number.max');
64
	
64
		foreach ($images as $idImg => $img) {
65
	private function formaterListePhotos($images) {
65
			$infosImg['src'] = htmlentities($img['binaire.href']);
66
		$infosImg['src'] = $images['binaire.href'];
66
		
-
 
67
			if ($img['auteur.libelle'] != '') {
-
 
68
				$infosImg['legende']['titre'] = htmlentities($img['auteur.libelle']);
-
 
69
			} else {
-
 
70
				$infosImg['legende']['titre'] = "Anonyme";
-
 
71
			}
67
	
72
			
68
		$obs = $images['observation'];
73
			if ($img['date'] != '') {
-
 
74
				$infosImg['legende']['titre'] .= ", le ".htmlentities($this->formaterDateImg($img['date']));
-
 
75
			}
69
		if ($obs['auteur.nom'] != '') {
76
			
-
 
77
			if ($img['station.libelle'] != '') {
-
 
78
				$infosImg['legende']['texte'] = htmlentities($img['station.libelle']);
70
			$infosImg['legende']['titre'] = $obs['auteur.nom'];
79
			} else {
71
			if ($obs['auteur.prenom'] != '') {
-
 
72
				$infosImg['legende']['titre'] .= ' '.$obs['auteur.prenom'];
-
 
73
			}
-
 
74
		} else {
80
				$infosImg['legende']['texte'] = "&nbsp;";
75
			$infosImg['legende']['titre'] = "Anonyme";
81
			}
76
		}
-
 
77
		
-
 
78
		if ($obs['date_observation'] != '') {
-
 
79
			$infosImg['legende']['titre'] .= ", le ".$this->formaterDateImg($obs['date_observation']);
82
			
80
		}
-
 
81
		
83
			array_push($this->donnees, $infosImg);
82
		if ($obs['zone_geo'] != '') {
-
 
83
			$infosImg['legende']['texte'] = $obs['zone_geo'];
84
			if (--$max <= 0) {
84
			if ($obs['lieudit'] != '') {
-
 
85
				$infosImg['legende']['texte'] .= ' ('.$obs['lieudit'].')';
-
 
86
			}
85
				return null;
87
		} else {
-
 
88
			$infosImg['legende']['texte'] = "&nbsp;";
-
 
89
		}
86
			}
90
		
87
		}
91
		array_push($this->donnees, $infosImg);
88
	}
92
	}
89
 
93
 
90
	private function formaterDateImg($date) {
94
	private function formaterDateImg($date) {
91
		$dateFmt = $date;
95
		$dateFmt = $date;
92
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
96
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
93
			$dateFmt = 'inconnue';
97
			$dateFmt = 'inconnue';
94
		} else {
98
		} else {
95
			$dateFmt = strftime('%e %B %Y', strtotime($date));
99
			$dateFmt = strftime('%e %B %Y', strtotime($date));
96
		}
100
		}
97
		return $dateFmt;
101
		return $dateFmt;
98
	}
102
	}
99
	
103
	
100
	public function addDessin() {
104
	public function addDessin() {
101
		$img = array();
105
		$img = array();
102
		$projet = Config::get($this->referentiel.'.baseDessins');
106
		$projet = Config::get($this->referentiel.'.baseDessins');
103
		if ($projet != "") {
107
		if ($projet != "") {
104
			$dessin = array();
108
			$dessin = array();
105
			$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
109
			$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
106
			$this->images->setProjet($projet);
110
			$this->images->setProjet($projet);
107
			$this->images->setNnTaxon($tax);
111
			$this->images->setNnTaxon($tax);
108
			$costeImg = $this->images->getInfosImagesTaxons();
112
			$costeImg = $this->images->getInfosImagesTaxons();
109
			
113
			
110
			if (count($costeImg) != 0) {
114
			if (count($costeImg) != 0) {
111
				$img['src'] = $costeImg[key($costeImg)]['binaire.href'];
115
				$img['src'] = $costeImg[key($costeImg)]['binaire.href'];
112
				$img['legende']['titre'] = "Illustration de Coste";
116
				$img['legende']['titre'] = "Illustration de Coste";
113
				$img['legende']['texte'] = "&nbsp;";
117
				$img['legende']['texte'] = "&nbsp;";
114
			}
118
			}
115
		}
119
		}
116
 
120
 
117
		return $img;
121
		return $img;
118
	}
122
	}
119
}
123
}
120
?>
124
?>