Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 801 | Rev 978 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 801 Rev 955
Line 17... Line 17...
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();
Line 22... Line 24...
22
 
24
 
23
	public function __construct(Conteneur $conteneur) {
25
	public function __construct(Conteneur $conteneur) {
24
		$this->conteneur = $conteneur;
26
		$this->conteneur = $conteneur;
-
 
27
		$this->nomCourant = $this->conteneur->getNomCourant();
25
		$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();
Line 29... Line 32...
29
	}
32
	}
30
 
-
 
31
	public function obtenirDonnees() {
33
 
32
		$donnees = array();
34
	public function obtenirDonnees() {
33
		$donnees['nt'] = $this->nomCourant->getNt();
35
		$this->donnees['nt'] = $this->nomCourant->getNt();
34
		$donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
-
 
35
		$donnees['cel'] = $this->getCel();
36
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
36
		$donnees['photoflora'] = $this->getPhotoFlora();
37
		$this->getPhotos();
37
		$donnees['coste'] = $this->getCoste();
38
		$this->getDessin();
Line 38... Line 39...
38
		return $donnees;
39
		return $this->donnees;
39
	}
-
 
40
	
40
	}
41
	public function obtenirDonneesExport() {
41
	
42
		$donnees = array();
42
	public function obtenirDonneesExport() {
43
		$donnees['nt'] = $this->nomCourant->getNt();
-
 
44
		$donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
43
		$this->donnees['nt'] = $this->nomCourant->getNt();
45
		$donnees['cel'] = $this->getCelExport();
44
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
Line 46... Line 45...
46
		$donnees['coste'] = $this->getCoste();
45
		$this->donnees['cel'] = $this->getCelExport();
47
		return $donnees;
-
 
48
	}
46
		return $this->donnees;
49
 
47
	}
50
	public function getBloc() {
48
 
51
		$donnees = array();
49
	public function getBloc() {
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)) {
Line 60... Line 58...
60
			$donnees = $this->getPhoto('photoflora');
58
			$this->donnees = $this->getPhoto('photoflora');
61
		}
59
		}
Line 73... Line 71...
73
			$donnees['imageUrl'] =  $image['binaire.href'];
71
			$donnees['imageUrl'] =  $image['binaire.href'];
74
		}
72
		}
75
		return $donnees;
73
		return $donnees;
76
	}
74
	}
Line 77... Line 75...
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
		}
Line 92... Line 105...
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;
Line -... Line 135...
-
 
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();
Line 138... Line 156...
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
	}
Line 142... Line -...
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;
Line 179... Line 169...
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
}