Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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