Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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