Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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