Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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