Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 364 Rev 366
1
<?php
1
<?php
2
/**
2
/**
3
* Web service particulier pour photoflora, qui ne doitpas être installé sur tela botanica
3
* Web service particulier pour photoflora, qui ne doitpas être installé sur tela botanica
4
* mais sur photoflora.free.fr
4
* mais sur photoflora.free.fr
5
* Une redirection htaccess est à faire, redirigeant /service:eflore:0.1/photoflora/image 
5
* Une redirection htaccess est à faire, redirigeant /service:eflore:0.1/photoflora/image 
6
* vers le site photoflora à l'adresse ou seront installé les services web et le minimum
6
* vers le site photoflora à l'adresse ou seront installé les services web et le minimum
7
* nécessaire pour les faire fonctionner (framework + base de code eflore-projet ou peut-être moins) 
7
* nécessaire pour les faire fonctionner (framework + base de code eflore-projet ou peut-être moins) 
8
* 
8
* 
9
* La table des metadonnées est, elle, stockée sur Tela Botanica
9
* La table des metadonnées est, elle, stockée sur Tela Botanica
10
* Le service est dans le même dépot que les autres par souci de commodité
10
* Le service est dans le même dépot que les autres par souci de commodité
11
* 
11
* 
12
*/
12
*/
13
class Images {
13
class Images {
14
	
14
	
15
	const MIME_JPEG = 'image/jpeg';
15
	const MIME_JPEG = 'image/jpeg';
16
	const MIME_JSON = 'application/json';
16
	const MIME_JSON = 'application/json';
17
	const MIME_XML = 'text/xml';
17
	const MIME_XML = 'text/xml';
18
	
18
	
19
	//TODO déplacer ceci dans des parametres de config
19
	//TODO déplacer ceci dans des parametres de config
20
	const BDD_PF = 'photoflora';
20
	const BDD_PF = 'photoflora';
21
	private $efph_url_photo = 'http://photoflora.free.fr/photos/%s/max/%s';
21
	private $efph_url_photo = 'http://photoflora.free.fr/photos/%s/max/%s';
22
	private $efph_url_photo_bb = 'http://photoflorabb.free.fr/max/%s';
22
	private $efph_url_photo_bb = 'http://photoflorabb.free.fr/max/%s';
23
	private $efph_url_photo_jlt = 'http://photoflorajlt.free.fr/max/%s';
23
	private $efph_url_photo_jlt = 'http://photoflorajlt.free.fr/max/%s';
24
	
24
	
25
	private $efph_url_photo_min = 'http://photoflora.free.fr/photos/%s/min/%s';
25
	private $efph_url_photo_min = 'http://photoflora.free.fr/photos/%s/min/%s';
26
	private $efph_url_photo_bb_min = 'http://photoflora.free.fr/photos/bb/min/%s';
26
	private $efph_url_photo_bb_min = 'http://photoflora.free.fr/photos/bb/min/%s';
27
	private $efph_url_photo_jlt_min = 'http://photoflora.free.fr/photos/jlt/min/%s';
27
	private $efph_url_photo_jlt_min = 'http://photoflora.free.fr/photos/jlt/min/%s';
28
	
28
	
29
	private $parametres = array();
29
	private $parametres = array();
30
	private $ressources = array();
30
	private $ressources = array();
31
	private $Bdd;
31
	private $Bdd;
32
	
32
	
33
	private $format = 'min';
33
	private $format = 'min';
34
	private $retour_mime = 'application/json';
34
	private $retour_mime = 'application/json';
35
	private $nbreImages = '0';
35
	private $nbreImages = '0';
36
 
36
 
37
	public function __construct(Bdd $bdd = null, Array $config = null) {
37
	public function __construct(Bdd $bdd = null, Array $config = null) {
38
		$this->config = is_null($config) ? Config::get('Images') : $config;
38
		$this->config = is_null($config) ? Config::get('Images') : $config;
39
		$this->Bdd = is_null($bdd) ? new Bdd() : $bdd;
39
		$this->Bdd = is_null($bdd) ? new Bdd() : $bdd;
40
	}
40
	}
41
	
41
	
42
	public function consulter($ressources, $parametres) {
42
	public function consulter($ressources, $parametres) {
43
		
43
		
44
		$this->parametres = $parametres;
44
		$this->parametres = $parametres;
45
		$this->ressources = $ressources;
45
		$this->ressources = $ressources;
46
		
46
		
47
		$this->definirValeurParDefautDesParametres();
47
		$this->definirValeurParDefautDesParametres();
48
				
48
				
49
		$this->format = (isset($this->parametres['retour.format']) && $this->parametres['retour.format'] != '') ?  $this->parametres['retour.format'] : $this->format;
49
		$this->format = (isset($this->parametres['retour.format']) && $this->parametres['retour.format'] != '') ?  $this->parametres['retour.format'] : $this->format;
50
		$this->retour_mime = (isset($this->parametres['retour']) && $this->parametres['retour'] != '') ?  $this->parametres['retour'] : $this->retour_mime;
50
		$this->retour_mime = (isset($this->parametres['retour']) && $this->parametres['retour'] != '') ?  $this->parametres['retour'] : $this->retour_mime;
51
		// TODO: décommenter lors de la mise en prod
51
		// TODO: décommenter lors de la mise en prod
52
		//$photographies = $this->obtenirImages();
52
		//$photographies = $this->obtenirImages();
53
		//TODO commenter lors de la mise en prod
53
		//TODO commenter lors de la mise en prod
54
		$photographies = $this->getResultatTest();
54
		$photographies = $this->getResultatTest();
55
		$this->nbreImages = count($photographies);
55
		$this->nbreImages = count($photographies);
56
		
56
		
57
		if($this->retour_mime == self::MIME_JSON) {
57
		if($this->retour_mime == self::MIME_JSON) {
58
			$photographies_formatees = $this->formaterRetourJson($photographies);
58
			$photographies_formatees = $this->formaterRetourJson($photographies);
59
			$resultat = $photographies_formatees;
59
			$resultat = $photographies_formatees;
60
			$entete = $this->construireEntete();
60
			$entete = $this->construireEntete();
61
			return array('entete' => $entete, 'resultats' => $resultat);
61
			return array('entete' => $entete, 'resultats' => $resultat);
62
		} elseif ($this->retour_mime == self::MIME_XML) {
62
		} elseif ($this->retour_mime == self::MIME_XML) {
63
			$photographies_formatees = $this->formaterRetourXml($photographies);
63
			$photographies_formatees = $this->formaterRetourXml($photographies);
64
			header('Content-Type: '.self::MIME_XML);
64
			header('Content-Type: '.self::MIME_XML);
65
			echo $photographies_formatees;
65
			echo $photographies_formatees;
66
			exit;
66
			exit;
67
		}
67
		}
68
	}
68
	}
69
	
69
	
70
	private function construireEntete() {
70
	private function construireEntete() {
71
		$entete = array('masque' => '', 'depart' => 0, 'limite' => 100, 'total' => 0);
71
		$entete = array('masque' => '', 'depart' => 0, 'limite' => 100, 'total' => 0);
72
	
72
	
73
		$entete['masque'] = $this->recupererMasque();
73
		$entete['masque'] = $this->recupererMasque();
74
		$entete['depart'] = (int) $this->parametres['navigation.depart'];
74
		$entete['depart'] = (int) $this->parametres['navigation.depart'];
75
		$entete['limite'] = (int) $this->parametres['navigation.limite'];
75
		$entete['limite'] = (int) $this->parametres['navigation.limite'];
76
		$entete['total'] = $this->nbreImages;
76
		$entete['total'] = $this->nbreImages;
77
		
77
		
78
		return $entete;
78
		return $entete;
79
	}
79
	}
80
	
80
	
81
	private function recupererMasque() {
81
	private function recupererMasque() {
82
		$masqueEntete = '';
82
		$masqueEntete = '';
83
		foreach ($this->parametres as $param => $cle) {
83
		foreach ($this->parametres as $param => $cle) {
84
			if ($param == 'masque') {
84
			if ($param == 'masque') {
85
				$masqueEntete = 'masque='.$cle.',';
85
				$masqueEntete = 'masque='.$cle.',';
86
			} elseif (substr($param, 0, 7) == 'masque.') {
86
			} elseif (substr($param, 0, 7) == 'masque.') {
87
				$masqueEntete .= substr($param, 7).'='.$cle.',';
87
				$masqueEntete .= substr($param, 7).'='.$cle.',';
88
			}
88
			}
89
		}
89
		}
90
		$masqueEntete = rtrim($masqueEntete,',');
90
		$masqueEntete = rtrim($masqueEntete,',');
91
		return $masqueEntete;
91
		return $masqueEntete;
92
	}
92
	}
93
	
93
	
94
	private function definirValeurParDefautDesParametres() {
94
	private function definirValeurParDefautDesParametres() {
95
		if (isset($this->parametres['retour']) == false) {
95
		if (isset($this->parametres['retour']) == false) {
96
			$this->parametres['retour'] = self::MIME_JSON;
96
			$this->parametres['retour'] = self::MIME_JSON;
97
		}
97
		}
98
		if (isset($this->parametres['retour.format']) == false) {
98
		if (isset($this->parametres['retour.format']) == false) {
99
			$this->parametres['retour.format'] = 'min';
99
			$this->parametres['retour.format'] = 'min';
100
		}
100
		}
101
		if (isset($this->parametres['navigation.depart']) == false) {
101
		if (isset($this->parametres['navigation.depart']) == false) {
102
			$this->parametres['navigation.depart'] = 0;
102
			$this->parametres['navigation.depart'] = 0;
103
		}
103
		}
104
		if (isset($this->parametres['navigation.limite']) == false) {
104
		if (isset($this->parametres['navigation.limite']) == false) {
105
			$this->parametres['navigation.limite'] = 100;
105
			$this->parametres['navigation.limite'] = 100;
106
		}
106
		}
107
	}
107
	}
108
 
108
 
109
	public function obtenirImages() {
109
	public function obtenirImages() {
110
		$requete = 	'SELECT photos.*,taxons.NumTaxon, taxons.NumNomen, taxons.Combinaison, photographes.Nom, photographes.Prenom, photographes.Initiales, photographes.Mail '.
110
		$requete = 	'SELECT photos.*,taxons.NumTaxon, taxons.NumNomen, taxons.Combinaison, photographes.Nom, photographes.Prenom, photographes.Initiales, photographes.Mail '.
111
								'FROM '.self::BDD_PF.'.photos, '.self::BDD_PF.'.photographes, '.self::BDD_PF.'.taxons '.
111
								'FROM '.self::BDD_PF.'.photos, '.self::BDD_PF.'.photographes, '.self::BDD_PF.'.taxons '.
112
								'WHERE '.
112
								'WHERE '.
113
								'photos.Auteur = photographes.ID '.
113
								'photos.Auteur = photographes.ID '.
114
								'AND photos.NumTaxon = taxons.NumTaxon '.
114
								'AND photos.NumTaxon = taxons.NumTaxon '.
115
								$this->construireWhereNumNom().' '.
115
								$this->construireWhereNumNom().' '.
116
								$this->construireWhereNumTax().' '.
116
								$this->construireWhereNumTax().' '.
117
								$this->construireWhereNomSci().' '.
117
								$this->construireWhereNomSci().' '.
118
								$this->construireWhereAuteur().' '.								
118
								$this->construireWhereAuteur().' '.								
119
								'ORDER BY photos.support LIMIT '.$this->parametres['navigation.depart'].','.$this->parametres['navigation.limite'];
119
								'ORDER BY photos.support LIMIT '.$this->parametres['navigation.depart'].','.$this->parametres['navigation.limite'];
120
		$resultat = $this->Bdd->recupererTous($requete);		
120
		$resultat = $this->Bdd->recupererTous($requete);		
121
		return $resultat;
121
		return $resultat;
122
	}
122
	}
123
	
123
	
124
	private function construireWhereNumNom() {
124
	private function construireWhereNumNom() {
125
		return (isset($this->parametres['masque.nn'])) ? 'AND taxons.NumNomen = '.$this->Bdd->proteger($this->parametres['masque.nn']).' ' : '';
125
		return (isset($this->parametres['masque.nn'])) ? 'AND taxons.NumNomen = '.$this->Bdd->proteger($this->parametres['masque.nn']).' ' : '';
126
	}
126
	}
127
	
127
	
128
	private function construireWhereNumTax() {
128
	private function construireWhereNumTax() {
129
		return (isset($this->parametres['masque.nt'])) ? 'AND taxons.NumTaxon = '.$this->Bdd->proteger($this->parametres['masque.nt']).' ' : '';
129
		return (isset($this->parametres['masque.nt'])) ? 'AND taxons.NumTaxon = '.$this->Bdd->proteger($this->parametres['masque.nt']).' ' : '';
130
	}
130
	}
131
	
131
	
132
	private function construireWhereNomSci() {
132
	private function construireWhereNomSci() {
133
		return (isset($this->parametres['masque.ns'])) ? 'AND taxons.Combinaison LIKE '.$this->Bdd->proteger($this->parametres['masque.ns'].'%').' ' : '';
133
		return (isset($this->parametres['masque.ns'])) ? 'AND taxons.Combinaison LIKE '.$this->Bdd->proteger($this->parametres['masque.ns'].'%').' ' : '';
134
	}
134
	}
135
	
135
	
136
	private function construireWhereAuteur() {
136
	private function construireWhereAuteur() {
137
		$requete_auteur = '';
137
		$requete_auteur = '';
138
		if (isset($this->parametres['masque.auteur'])) {
138
		if (isset($this->parametres['masque.auteur'])) {
139
			$auteur_like = $this->Bdd->proteger($this->parametres['masque.auteur'].'%');
139
			$auteur_like = $this->Bdd->proteger($this->parametres['masque.auteur'].'%');
140
			$requete_auteur = 'AND photos.auteur = '.
140
			$requete_auteur = 'AND photos.auteur = '.
141
			                    '(SELECT id FROM '.self::BDD_PF.'.photographes '.
141
			                    '(SELECT id FROM '.self::BDD_PF.'.photographes '.
142
			                    'WHERE '.
142
			                    'WHERE '.
143
			                    'Nom LIKE '.$auteur_like.' OR '.
143
			                    'Nom LIKE '.$auteur_like.' OR '.
144
			                    'Prenom LIKE '.$auteur_like.' OR '.
144
			                    'Prenom LIKE '.$auteur_like.' OR '.
145
								'Initiales LIKE '.$auteur_like.' OR '.
145
								'Initiales LIKE '.$auteur_like.' OR '.
146
								'Mail LIKE '.$auteur_like.') ';	
146
								'Mail LIKE '.$auteur_like.') ';	
147
		}			 	 	
147
		}			 	 	
148
		return $requete_auteur;
148
		return $requete_auteur;
149
	}
149
	}
150
	
150
	
151
	private function formaterRetourJson($photographies) {	
151
	private function formaterRetourJson($photographies) {	
152
		$resultat = array();
152
		$resultat = array();
-
 
153
		if(is_array($photographies)) {
153
		foreach ($photographies as $photo) {
154
			foreach ($photographies as $photo) {
154
 
155
 
155
			$image = array();
156
				$image = array();
156
			$url = $this->getUrlPhotoPourInitiales($photo['Initiales'], $photo['NumPhoto'], $this->format);
157
				$url = $this->getUrlPhotoPourInitiales($photo['Initiales'], $photo['NumPhoto'], $this->format);
157
			$urlmax = $this->getUrlPhotoPourInitiales($photo['Initiales'], $photo['NumPhoto'], 'max');
158
				$urlmax = $this->getUrlPhotoPourInitiales($photo['Initiales'], $photo['NumPhoto'], 'max');
158
			$id = str_replace(array('.jpg','.jpeg'),'',$photo['NumPhoto']);
159
				$id = str_replace(array('.jpg','.jpeg'),'',$photo['NumPhoto']);
159
			// Post-traitement des valeurs
160
				// Post-traitement des valeurs
160
			$image['station'] = $this->formaterChaineEncodeeBddPhotoflora($photo['lieu']);
161
				$image['station'] = $this->formaterChaineEncodeeBddPhotoflora($photo['lieu']);
161
			$image['date'] = $this->donnerDate($this->formaterChaineEncodeeBddPhotoflora($photo['Date']));
162
				$image['date'] = $this->donnerDate($this->formaterChaineEncodeeBddPhotoflora($photo['Date']));
162
			$image['auteur'] = $this->formaterChaineEncodeeBddPhotoflora($photo['Prenom'].' '.$photo['Nom']);
163
				$image['auteur'] = $this->formaterChaineEncodeeBddPhotoflora($photo['Prenom'].' '.$photo['Nom']);
163
			$image['determination'] = $photo['Combinaison'].' ['.$photo['Prenom'].' '.$photo['Nom'].']';
164
				$image['determination'] = $photo['Combinaison'].' ['.$photo['Prenom'].' '.$photo['Nom'].']';
164
			$image['determination.nom_sci'] = $photo['Combinaison'];
165
				$image['determination.nom_sci'] = $photo['Combinaison'];
165
			$image['determination.nom_sci.code'] = "bdtfx.".$photo['NumNomen'];
166
				$image['determination.nom_sci.code'] = "bdtfx.".$photo['NumNomen'];
166
			$image['binaire.href'] = $url;
167
				$image['binaire.href'] = $url;
167
			$image['binaire.hrefmax'] = $urlmax;
168
				$image['binaire.hrefmax'] = $urlmax;
168
			
169
				
-
 
170
				$resultat[$id] = $image;
169
			$resultat[$id] = $image;
171
			}
170
		}
172
		}
171
		
173
		
172
		return $resultat;
174
		return $resultat;
173
	}
175
	}
174
	
176
	
175
	private function callBackReplace($m) {
177
	private function callBackReplace($m) {
176
		return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
178
		return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
177
	}
179
	}
178
	
180
	
179
	private function formaterChaineEncodeeBddPhotoflora($chaine) {
181
	private function formaterChaineEncodeeBddPhotoflora($chaine) {
180
		return $chaine = preg_replace_callback("/(&#[0-9]+;)/", array($this, 'callBackReplace')
182
		return $chaine = preg_replace_callback("/(&#[0-9]+;)/", array($this, 'callBackReplace')
181
		, $chaine);
183
		, $chaine);
182
	}
184
	}
183
	
185
	
184
	// TODO: garder ancien web service pour retour xml ou bien fusionner les deux ?
186
	// TODO: garder ancien web service pour retour xml ou bien fusionner les deux ?
185
	private function formaterRetourXml($photographies) {
187
	private function formaterRetourXml($photographies) {
186
		// Formatage du xml
188
		// Formatage du xml
187
		$xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
189
		$xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
188
		$xml .= '<rdf:RDF'."\n";
190
		$xml .= '<rdf:RDF'."\n";
189
		$xml .= '	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n";
191
		$xml .= '	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n";
190
		$xml .= '	xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n";
192
		$xml .= '	xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n";
191
		$xml .= '	xmlns:dcterms="http://purl.org/dc/terms">'."\n";
193
		$xml .= '	xmlns:dcterms="http://purl.org/dc/terms">'."\n";
192
		foreach ($photographies as $photo) {
194
		foreach ($photographies as $photo) {
193
			
195
			
194
			$url = $this->getUrlPhotoPourInitiales($photo['Initiales'], $photo['NumPhoto'], $this->format);
196
			$url = $this->getUrlPhotoPourInitiales($photo['Initiales'], $photo['NumPhoto'], $this->format);
195
		
197
		
196
			// Post-traitement des valeurs
198
			// Post-traitement des valeurs
197
			$photo['lieu'] = preg_replace('/^[ ]*:[ ]*/', '', $photo['lieu']);
199
			$photo['lieu'] = preg_replace('/^[ ]*:[ ]*/', '', $photo['lieu']);
198
		
200
		
199
			// Gestion du XML
201
			// Gestion du XML
200
			$xml .= '	<rdf:Description about="'.$url.'"'."\n";
202
			$xml .= '	<rdf:Description about="'.$url.'"'."\n";
201
			$xml .= '		dc:identifier="'.preg_replace('/\.\w+$/', '', $photo['NumPhoto']).'"'."\n";
203
			$xml .= '		dc:identifier="'.preg_replace('/\.\w+$/', '', $photo['NumPhoto']).'"'."\n";
202
			$xml .= '		dc:title="'.$photo['Combinaison'].'"'."\n";
204
			$xml .= '		dc:title="'.$photo['Combinaison'].'"'."\n";
203
			$xml .= '		dc:description="'.$photo['Objet'].'"'."\n";
205
			$xml .= '		dc:description="'.$photo['Objet'].'"'."\n";
204
			$xml .= '		dc:creator="'.$photo['Prenom'].' '.$photo['Nom'].'"'."\n";
206
			$xml .= '		dc:creator="'.$photo['Prenom'].' '.$photo['Nom'].'"'."\n";
205
			//	$xml .= '		dc:contributor="Daniel MATHIEU (Détermination)"'."\n";
207
			//	$xml .= '		dc:contributor="Daniel MATHIEU (Détermination)"'."\n";
206
			$xml .= '		dc:publisher="Photoflora"'."\n";
208
			$xml .= '		dc:publisher="Photoflora"'."\n";
207
			$xml .= '		dc:type="'.$this->donnerTxtSupport($photo['Support']).'"'."\n";
209
			$xml .= '		dc:type="'.$this->donnerTxtSupport($photo['Support']).'"'."\n";
208
			$xml .= '		dc:format="'.$this->donnerTypeMime($photo['NumPhoto']).'"'."\n";
210
			$xml .= '		dc:format="'.$this->donnerTypeMime($photo['NumPhoto']).'"'."\n";
209
			$xml .= '		dcterms:spatial="'.$photo['lieu'].'"'."\n";
211
			$xml .= '		dcterms:spatial="'.$photo['lieu'].'"'."\n";
210
			$xml .= '		dcterms:created="'.$photo['Date'].'"'."\n";
212
			$xml .= '		dcterms:created="'.$photo['Date'].'"'."\n";
211
			//	$xml .= '		dcterms:dateSubmitted="2006-10-18 08:32:00"'."\n";
213
			//	$xml .= '		dcterms:dateSubmitted="2006-10-18 08:32:00"'."\n";
212
			$xml .= '		dcterms:licence="Utilisation des photos non autorisée sans accord avec le gestionnaire du site et sous certaines conditions - Tous droits réservés - All rights reserved"/>'."\n";
214
			$xml .= '		dcterms:licence="Utilisation des photos non autorisée sans accord avec le gestionnaire du site et sous certaines conditions - Tous droits réservés - All rights reserved"/>'."\n";
213
		}
215
		}
214
		$xml .= '</rdf:RDF>'."\n";
216
		$xml .= '</rdf:RDF>'."\n";
215
		
217
		
216
		return $xml;
218
		return $xml;
217
	}
219
	}
218
	
220
	
219
	private function getUrlPhotoPourInitiales($initiales, $num_photo, $format) {
221
	private function getUrlPhotoPourInitiales($initiales, $num_photo, $format) {
220
		// Gestion des urls des photos
222
		// Gestion des urls des photos
221
		$url = '';
223
		$url = '';
222
		if ($initiales == 'bb') {
224
		if ($initiales == 'bb') {
223
			$base_url = ($format == 'max') ? $this->efph_url_photo_bb : $this->efph_url_photo_bb_min;
225
			$base_url = ($format == 'max') ? $this->efph_url_photo_bb : $this->efph_url_photo_bb_min;
224
			$url = sprintf($base_url, $num_photo);
226
			$url = sprintf($base_url, $num_photo);
225
		} else if ($initiales == 'jlt') {
227
		} else if ($initiales == 'jlt') {
226
			$base_url = ($format == 'max') ? $this->efph_url_photo_jlt : $this->efph_url_photo_jlt_min;
228
			$base_url = ($format == 'max') ? $this->efph_url_photo_jlt : $this->efph_url_photo_jlt_min;
227
			$url = sprintf($base_url, $num_photo);
229
			$url = sprintf($base_url, $num_photo);
228
		} else {
230
		} else {
229
			$base_url = ($format == 'max') ? $this->efph_url_photo : $this->efph_url_photo_min;
231
			$base_url = ($format == 'max') ? $this->efph_url_photo : $this->efph_url_photo_min;
230
			$url = sprintf($base_url, $initiales, $num_photo);
232
			$url = sprintf($base_url, $initiales, $num_photo);
231
		}
233
		}
232
		
234
		
233
		return $url;
235
		return $url;
234
	}
236
	}
235
	
237
	
236
	private function getResultatTest() {
238
	private function getResultatTest() {
237
		$photographies = array();
239
		$photographies = array();
238
		$photographies[] = array('Initiales' => 'bb',
240
		$photographies[] = array('Initiales' => 'bb',
239
				'NumPhoto' => 'bb047230.jpg', 
241
				'NumPhoto' => 'bb047230.jpg', 
240
				'NumNomen' => '182',
242
				'NumNomen' => '182',
241
				'lieu' => 'Ristolas - Hautes Alpes (05) [France]',
243
				'lieu' => 'Ristolas - Hautes Alpes (05) [France]',
242
				'Combinaison' => '',
244
				'Combinaison' => '',
243
				'Objet' => 'Vue générale, en fleur cv Musik - Canon EOS 350D DIGITAL - Expo : 1/160 sec. - Ouv. : f8 - ISO : 100 - flash : non - foc. : 60 - pix. : 8 Mp.',
245
				'Objet' => 'Vue générale, en fleur cv Musik - Canon EOS 350D DIGITAL - Expo : 1/160 sec. - Ouv. : f8 - ISO : 100 - flash : non - foc. : 60 - pix. : 8 Mp.',
244
				'Prenom' => 'Benoit',
246
				'Prenom' => 'Benoit',
245
				'Nom' => 'BOCK',
247
				'Nom' => 'BOCK',
246
				'Support' => 'Photographie numérique',
248
				'Support' => 'Photographie numérique',
247
				'Date' => 'Mai 2006');
249
				'Date' => 'Mai 2006');
248
		
250
		
249
		return $photographies;
251
		return $photographies;
250
	}
252
	}
251
		
253
		
252
	/**
254
	/**
253
	* Fonction remplaçant les caractères posant problème dans le xml
255
	* Fonction remplaçant les caractères posant problème dans le xml
254
	*
256
	*
255
	* @param string le texte à nettoyer
257
	* @param string le texte à nettoyer
256
	* @return string le texte nettoyé
258
	* @return string le texte nettoyé
257
	*/
259
	*/
258
	function nettoyerXml($xml) {
260
	function nettoyerXml($xml) {
259
		// Remplacement des esperluettes
261
		// Remplacement des esperluettes
260
		$xml = str_replace(' & ', ' &#38; ', $xml);
262
		$xml = str_replace(' & ', ' &#38; ', $xml);
261
		// Remplacement du caractère spécial de fin de ligne : VT
263
		// Remplacement du caractère spécial de fin de ligne : VT
262
		$xml = preg_replace('//', "\n", $xml);
264
		$xml = preg_replace('//', "\n", $xml);
263
		return $xml;
265
		return $xml;
264
	}
266
	}
265
	
267
	
266
	/**
268
	/**
267
	 * Fonction fournissant les intitulés des types de support des images
269
	 * Fonction fournissant les intitulés des types de support des images
268
	 *
270
	 *
269
	 * @param integer identifiant du support
271
	 * @param integer identifiant du support
270
	 * @return string le texte correspondant au type de support
272
	 * @return string le texte correspondant au type de support
271
	 */
273
	 */
272
	function donnerTxtSupport($support) {
274
	function donnerTxtSupport($support) {
273
		switch ($support) {
275
		switch ($support) {
274
			case '0':
276
			case '0':
275
				$support = 'Photographie num&#233;rique (6 mégapixels)';
277
				$support = 'Photographie num&#233;rique (6 mégapixels)';
276
				break;
278
				break;
277
			case '1':
279
			case '1':
278
				$support = 'Diapositive';
280
				$support = 'Diapositive';
279
				break;
281
				break;
280
			case '10':
282
			case '10':
281
				$support = 'Scan de la flore de Coste';
283
				$support = 'Scan de la flore de Coste';
282
				break;
284
				break;
283
			case '11':
285
			case '11':
284
				$support = 'Scan de plante fraiche';
286
				$support = 'Scan de plante fraiche';
285
				break;
287
				break;
286
			default:
288
			default:
287
				$support = 'Erreur code support : pr&#233;venir eflore_remarques@tela-botanica.org';
289
				$support = 'Erreur code support : pr&#233;venir eflore_remarques@tela-botanica.org';
288
		}
290
		}
289
		return $support;
291
		return $support;
290
	}
292
	}
291
	
293
	
292
	/**
294
	/**
293
	 * Fonction fournissant les types MIME des fichiers images
295
	 * Fonction fournissant les types MIME des fichiers images
294
	 *
296
	 *
295
	 * @param string le nom du fichier
297
	 * @param string le nom du fichier
296
	 * @return string le texte du type MIME du fichier
298
	 * @return string le texte du type MIME du fichier
297
	 */
299
	 */
298
	function donnerTypeMime($fichier) {
300
	function donnerTypeMime($fichier) {
299
		if (preg_match('/\.(\w+)$/', $fichier, $match)) {
301
		if (preg_match('/\.(\w+)$/', $fichier, $match)) {
300
			switch (strtolower($match[1])) {
302
			switch (strtolower($match[1])) {
301
				case 'jpeg':
303
				case 'jpeg':
302
				case 'jpg':
304
				case 'jpg':
303
					$type = 'image/jpeg';
305
					$type = 'image/jpeg';
304
					break;
306
					break;
305
				case 'png':
307
				case 'png':
306
					$type = 'image/png';
308
					$type = 'image/png';
307
					break;
309
					break;
308
				default:
310
				default:
309
					$type = 'Erreur Mime : prévenir eflore_remarques@tela-botanica.org';
311
					$type = 'Erreur Mime : prévenir eflore_remarques@tela-botanica.org';
310
			}
312
			}
311
		} else {
313
		} else {
312
			$type = 'Erreur Mime : prévenir eflore_remarques@tela-botanica.org';
314
			$type = 'Erreur Mime : prévenir eflore_remarques@tela-botanica.org';
313
		}
315
		}
314
		return $type;
316
		return $type;
315
	}
317
	}
316
	
318
	
317
	/**
319
	/**
318
	 * Fonction fournissant une date au format Mysql
320
	 * Fonction fournissant une date au format Mysql
319
	 *
321
	 *
320
	 * @param string la date composé du nom du mois en français et de l'année sous 4 chiffres
322
	 * @param string la date composé du nom du mois en français et de l'année sous 4 chiffres
321
	 * @return string la date dans le format Mysql
323
	 * @return string la date dans le format Mysql
322
	 */
324
	 */
323
	function donnerDate($chaine) {
325
	function donnerDate($chaine) {
324
		if (preg_match('/^(\w+) (\d{4})$/',$chaine, $match)) {
326
		if (preg_match('/^(\w+) (\d{4})$/',$chaine, $match)) {
325
			$mois = $match[1];
327
			$mois = $match[1];
326
			$annee = $match[2];
328
			$annee = $match[2];
327
			switch (strtolower($mois)) {
329
			switch (strtolower($mois)) {
328
				case 'janvier' :
330
				case 'janvier' :
329
					$mois_sortie = '01';
331
					$mois_sortie = '01';
330
					break;
332
					break;
331
				case 'février' :
333
				case 'février' :
332
					$mois_sortie = '02';
334
					$mois_sortie = '02';
333
					break;
335
					break;
334
				case 'mars' :
336
				case 'mars' :
335
					$mois_sortie = '03';
337
					$mois_sortie = '03';
336
					break;
338
					break;
337
				case 'avril' :
339
				case 'avril' :
338
					$mois_sortie = '04';
340
					$mois_sortie = '04';
339
					break;
341
					break;
340
				case 'mai' :
342
				case 'mai' :
341
					$mois_sortie = '05';
343
					$mois_sortie = '05';
342
					break;
344
					break;
343
				case 'juin' :
345
				case 'juin' :
344
					$mois_sortie = '06';
346
					$mois_sortie = '06';
345
					break;
347
					break;
346
				case 'juillet' :
348
				case 'juillet' :
347
					$mois_sortie = '07';
349
					$mois_sortie = '07';
348
					break;
350
					break;
349
				case 'aout' :
351
				case 'aout' :
350
				case 'août' :
352
				case 'août' :
351
					$mois_sortie = '08';
353
					$mois_sortie = '08';
352
					break;
354
					break;
353
				case 'septembre' :
355
				case 'septembre' :
354
					$mois_sortie = '09';
356
					$mois_sortie = '09';
355
					break;
357
					break;
356
				case 'octobre' :
358
				case 'octobre' :
357
					$mois_sortie = '10';
359
					$mois_sortie = '10';
358
					break;
360
					break;
359
				case 'novembre' :
361
				case 'novembre' :
360
					$mois_sortie = '11';
362
					$mois_sortie = '11';
361
					break;
363
					break;
362
				case 'decembre' :
364
				case 'decembre' :
363
					$mois_sortie = '12';
365
					$mois_sortie = '12';
364
					break;
366
					break;
365
			}
367
			}
366
			return $annee.'-'.$mois_sortie.'-01 01:01:01';
368
			return $annee.'-'.$mois_sortie.'-01 01:01:01';
367
		} else {
369
		} else {
368
			return '1970-01-01 01:01:01';
370
			return '1970-01-01 01:01:01';
369
		}
371
		}
370
	}
372
	}
371
}
373
}
372
?>
374
?>