Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 978 Rev 1014
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 obtenirDonnees() {
34
	public function obtenirDonnees() {
35
		$this->donnees['nt'] = $this->nomCourant->getNt();
35
		$this->donnees['nt'] = $this->nomCourant->getNt();
36
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
36
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
37
		$this->getPhotos();
37
		$this->getPhotos();
38
		$this->getDessin();
38
		$this->getDessin();
39
		return $this->donnees;
39
		return $this->donnees;
40
	}
40
	}
41
	
41
	
42
	public function obtenirDonneesExport() {
42
	public function obtenirDonneesExport() {
43
		$this->donnees['nt'] = $this->nomCourant->getNt();
43
		$this->donnees['nt'] = $this->nomCourant->getNt();
44
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
44
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
45
		$this->donnees['cel'] = $this->getCelExport();
45
		$this->donnees['cel'] = $this->getCelExport();
-
 
46
		$this->donnees['coste'] = $this->getCoste();
46
		return $this->donnees;
47
		return $this->donnees;
47
	}
48
	}
48
 
49
 
49
	public function getBloc() {
50
	public function getBloc() {
50
		$this->donnees = $this->getPhoto('cel');
51
		$this->donnees = $this->getPhoto('cel');
51
		if (empty($this->donnees)) {
52
		if (empty($this->donnees)) {
52
			$infos_image = $this->getDessin();
53
			$infos_image = $this->getDessin();
53
			if (empty($infos_image) == false ){
54
			if (empty($infos_image) == false ){
54
				$this->donnees['imageUrl'] =  array_shift($infos_image['images']);
55
				$this->donnees['imageUrl'] =  array_shift($infos_image['images']);
55
			}
56
			}
56
		}
57
		}
57
		if (empty($this->donnees)) {
58
		if (empty($this->donnees)) {
58
			$this->donnees = $this->getPhoto('photoflora');
59
			$this->donnees = $this->getPhoto('photoflora');
59
		}
60
		}
60
		return $this->donnees;
61
		return $this->donnees;
61
	}
62
	}
62
	
63
	
63
	
64
	
64
	public function getPhoto($source) {
65
	public function getPhoto($source) {
65
		$donnees = array();
66
		$donnees = array();
66
		$this->images->setProjet($source);
67
		$this->images->setProjet($source);
67
		$nnr = $this->nomCourant->getNnr();
68
		$nnr = $this->nomCourant->getNnr();
68
		$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
69
		$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
69
		if ($infos_image != array()) {
70
		if ($infos_image != array()) {
70
			$image = array_shift($infos_image);
71
			$image = array_shift($infos_image);
71
			$donnees['imageUrl'] =  $image['binaire.href'];
72
			$donnees['imageUrl'] =  $image['binaire.href'];
72
		}
73
		}
73
		return $donnees;
74
		return $donnees;
74
	}
75
	}
-
 
76
 
-
 
77
	public function getCoste() {
-
 
78
		$coste = array();
-
 
79
		$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
-
 
80
		$this->images->setProjet('coste');
-
 
81
		$this->images->setNnTaxon($tax);
-
 
82
		$costeImg = $this->images->getInfosImagesTaxons();
-
 
83
		foreach ($costeImg as $infos) {
-
 
84
			$coste['images'][] = $infos['binaire.href'];
-
 
85
		}
-
 
86
		$this->meta->setProjet('coste');
-
 
87
		$meta = $this->meta->getMetaDonnees();
-
 
88
		$coste['meta']['titre']= $meta[0]['titre'];
-
 
89
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
-
 
90
		return $coste;
-
 
91
	}
75
 
92
 
76
	public function getDessin() {
93
	public function getDessin() {
77
		$projet = Config::get($this->referentiel.'.baseDessins');
94
		$projet = Config::get($this->referentiel.'.baseDessins');
78
		if ($projet != "") {
95
		if ($projet != "") {
79
			$dessin = array();
96
			$dessin = array();
80
			$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
97
			$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
81
			$this->images->setProjet($projet);
98
			$this->images->setProjet($projet);
82
			$this->images->setNnTaxon($tax);
99
			$this->images->setNnTaxon($tax);
83
			$costeImg = $this->images->getInfosImagesTaxons();
100
			$costeImg = $this->images->getInfosImagesTaxons();
84
				foreach ($costeImg as $infos) {
101
				foreach ($costeImg as $infos) {
85
					$dessin['images'][] = $infos['binaire.href'];
102
					$dessin['images'][] = $infos['binaire.href'];
86
				}
103
				}
87
			$this->meta->setProjet('coste');
104
			$this->meta->setProjet('coste');
88
			$meta = $this->meta->getMetaDonnees();
105
			$meta = $this->meta->getMetaDonnees();
89
			$dessin['meta']['titre']= $meta[0]['titre'];
106
			$dessin['meta']['titre']= $meta[0]['titre'];
90
			$dessin['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
107
			$dessin['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
91
			$this->donnees['coste'] = $dessin;
108
			$this->donnees['coste'] = $dessin;
92
		}
109
		}
93
	}
110
	}
94
	
111
	
95
	public function getPhotos() {
112
	public function getPhotos() {
96
		$projets[] = Config::get($this->referentiel.'.baseImages');
113
		$projets[] = Config::get($this->referentiel.'.baseImages');
97
		$projets[] = Config::get($this->referentiel.'.baseImagesSupp');
114
		$projets[] = Config::get($this->referentiel.'.baseImagesSupp');
98
		foreach ($projets as $projet) {
115
		foreach ($projets as $projet) {
99
			if ($projet != "") {
116
			if ($projet != "") {
100
				$images = $this->initialiserPhotos($projet);
117
				$images = $this->initialiserPhotos($projet);
101
				$this->formaterListePhotos($projet, $images);
118
				$this->formaterListePhotos($projet, $images);
102
				$this->formaterMetaPhotos($projet);
119
				$this->formaterMetaPhotos($projet);
103
			}
120
			}
104
		}
121
		}
105
	}
122
	}
106
	
123
	
107
	private function initialiserPhotos($projet) {
124
	private function initialiserPhotos($projet) {
108
		$this->images->setProjet($projet);
125
		$this->images->setProjet($projet);
109
		$nnr = $this->nomCourant->getNnr();
126
		$nnr = $this->nomCourant->getNnr();
110
		return $this->images->getInfosImagesParIdsNoms(array($nnr));
127
		return $this->images->getInfosImagesParIdsNoms(array($nnr));
111
	}
128
	}
112
	
129
	
113
	private function formaterListePhotos($projet, $images) {
130
	private function formaterListePhotos($projet, $images) {
114
		foreach ($images as $idImg => $img) {
131
		foreach ($images as $idImg => $img) {
115
			$infosImg = array();
132
			$infosImg = array();
116
			$infosImg['src'] = $img['binaire.href'];
133
			$infosImg['src'] = $img['binaire.href'];
117
			$infosImg['nomSci'] = $img['determination.nom_sci'];
134
			$infosImg['nomSci'] = $img['determination.nom_sci'];
118
			$infosImg['station'] = $img['station.libelle'];
135
			$infosImg['station'] = $img['station.libelle'];
119
			$infosImg['date'] = $this->formaterDateImg($img['date']);
136
			$infosImg['date'] = $this->formaterDateImg($img['date']);
120
			$infosImg['auteur'] = $img['auteur.libelle'];
137
			$infosImg['auteur'] = $img['auteur.libelle'];
121
		
138
		
122
			if ($projet == "cel") {
139
			if ($projet == "cel") {
123
				$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
140
				$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
124
				$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
141
				$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
125
			}
142
			}
126
			$this->donnees[$projet]['images'][$idImg] = $infosImg;
143
			$this->donnees[$projet]['images'][$idImg] = $infosImg;
127
		}
144
		}
128
	}
145
	}
129
	
146
	
130
	private function formaterMetaPhotos($projet) {
147
	private function formaterMetaPhotos($projet) {
131
		$this->meta->setProjet($projet);
148
		$this->meta->setProjet($projet);
132
		$meta = $this->meta->getMetaDonnees();
149
		$meta = $this->meta->getMetaDonnees();
133
		$titreMeta = $meta[0]['titre'];
150
		$titreMeta = $meta[0]['titre'];
134
		$this->donnees[$projet]['meta']['titre'] = $titreMeta;
151
		$this->donnees[$projet]['meta']['titre'] = $titreMeta;
135
		$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
152
		$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
136
	}
153
	}
137
	
154
	
138
	
155
	
139
	
156
	
140
	public function getCelExport() {
157
	public function getCelExport() {
141
		$cel = array();
158
		$cel = array();
142
		$this->images->setProjet('cel');
159
		$this->images->setProjet('cel');
143
		$nnr = $this->nomCourant->getNnr();
160
		$nnr = $this->nomCourant->getNnr();
144
		$img = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
161
		$img = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
145
		if($img) {
162
		if($img) {
146
			$img = array_values($img);
163
			$img = array_values($img);
147
			$cel['images']['src'] = $img[0]['binaire.href'];
164
			$cel['images']['src'] = $img[0]['binaire.href'];
148
			$cel['images']['nomSci'] = $img[0]['determination.nom_sci'];
165
			$cel['images']['nomSci'] = $img[0]['determination.nom_sci'];
149
			$cel['images']['station'] = $img[0]['station.libelle'];
166
			$cel['images']['station'] = $img[0]['station.libelle'];
150
			$cel['images']['date'] = $this->formaterDateImg($img[0]['date']);
167
			$cel['images']['date'] = $this->formaterDateImg($img[0]['date']);
151
			$cel['images']['auteur'] = $img[0]['auteur.libelle'];
168
			$cel['images']['auteur'] = $img[0]['auteur.libelle'];
152
			$this->meta->setProjet('cel');
169
			$this->meta->setProjet('cel');
153
			$meta = $this->meta->getMetaDonnees();
170
			$meta = $this->meta->getMetaDonnees();
154
			$titreMeta = $meta[0]['titre'];
171
			$titreMeta = $meta[0]['titre'];
155
			$cel['meta']['titre'] = $titreMeta;
172
			$cel['meta']['titre'] = $titreMeta;
156
			$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
173
			$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
157
		}
174
		}
158
		return $cel;
175
		return $cel;
159
	}
176
	}
160
 
177
 
161
	private function formaterDateImg($date) {
178
	private function formaterDateImg($date) {
162
		$dateFmt = $date;
179
		$dateFmt = $date;
163
		if ($date == '' || $date == null || $date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
180
		if ($date == '' || $date == null || $date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
164
			$dateFmt = 'inconnue';
181
			$dateFmt = 'inconnue';
165
		} else {
182
		} else {
166
			$dateFmt = strftime('%e %B %Y', strtotime($date));
183
			$dateFmt = strftime('%e %B %Y', strtotime($date));
167
		}
184
		}
168
		return $dateFmt;
185
		return $dateFmt;
169
	}
186
	}
170
 
187
 
171
	private function formaterNomSci($nom) {
188
	private function formaterNomSci($nom) {
172
		$nomFmt = $nom;
189
		$nomFmt = $nom;
173
		if (is_null($nom) || $nom == '') {
190
		if (is_null($nom) || $nom == '') {
174
			$nomFmt = 'inconnu';
191
			$nomFmt = 'inconnu';
175
		}
192
		}
176
		return $nomFmt;
193
		return $nomFmt;
177
	}
194
	}
178
}
195
}
179
?>
196
?>