Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 138 Rev 140
Line 23... Line 23...
23
	const CODE_REFTAX_DEFAUT = 'bdtfx';
23
	const CODE_REFTAX_DEFAUT = 'bdtfx';
24
	const TPL_URL_IMG = 'http://www.tela-botanica.org/appli:cel-img:%s.jpg';
24
	const TPL_URL_IMG = 'http://www.tela-botanica.org/appli:cel-img:%s.jpg';
25
	const TAILLE_IMG_DEFAUT = 'M';
25
	const TAILLE_IMG_DEFAUT = 'M';
26
	const MIME_JPEG = 'image/jpeg';
26
	const MIME_JPEG = 'image/jpeg';
27
	const MIME_JSON = 'application/json';
27
	const MIME_JSON = 'application/json';
-
 
28
 
-
 
29
	private $config = array();
-
 
30
	private $cheminImagesBase = '';
28
	private $formats_supportes = array(self::MIME_JPEG, self::MIME_JSON);
31
	private $formats_supportes = array(self::MIME_JPEG, self::MIME_JSON);
29
	private $ref_tax_demande = array();
32
	private $ref_tax_demande = array();
30
	private $infosImages = array();
33
	private $infosImages = array();
31
	private $nbreImages = 0;
34
	private $nbreImages = 0;
32
	private $Utilisateurs = null;
35
	private $Utilisateurs = null;
33
	private $intitulesAuteurs = array();
36
	private $intitulesAuteurs = array();
-
 
37
	private $UrlNavigation = null;
Line 34... Line 38...
34
 
38
 
-
 
39
	public function __construct(Bdd $bdd = null, Array $config = null, Utilisateurs $utilisateurs = null, Url $url = null) {
35
	public function __construct(Bdd $bdd = null, Utilisateurs $utilisateurs = null) {
40
		$this->config = is_null($config) ? Config::get('Images') : $config;
36
		$this->Bdd = is_null($bdd) ? new Bdd() : $bdd;
41
		$this->Bdd = is_null($bdd) ? new Bdd() : $bdd;
-
 
42
		$this->Utilisateurs = is_null($utilisateurs) ? new Utilisateurs() : $utilisateurs;
-
 
43
		$this->UrlNavigation = is_null($url) ? new Url($this->config['urlService']) : $url;
37
		$this->Utilisateurs = is_null($utilisateurs) ? new Utilisateurs() : $utilisateurs;
44
		$this->cheminImagesBase = $this->config['chemin'];
Line 38... Line 45...
38
	}
45
	}
-
 
46
 
39
 
47
	public function consulter($ressources, $parametres) {
40
	public function consulter($ressources, $parametres) {
48
		//$tpsDebut = microtime(true);
Line 41... Line 49...
41
		$this->parametres = $parametres;
49
		$this->parametres = $parametres;
42
		$this->ressources = $ressources;
50
		$this->ressources = $ressources;
Line 51... Line 59...
51
			$resultat->corps = $this->recupererImageBinaire($id_image_a_renvoyer);
59
			$resultat->corps = $this->recupererImageBinaire($id_image_a_renvoyer);
52
		} else if ($this->parametres['retour'] == self::MIME_JSON) {
60
		} else if ($this->parametres['retour'] == self::MIME_JSON) {
53
			$this->chargerListeImages();
61
			$this->chargerListeImages();
54
			$this->chargerNbreImagesTotal();
62
			$this->chargerNbreImagesTotal();
55
			$resultat->corps = $infos = $this->formaterListeImages();
63
			$resultat->corps = $infos = $this->formaterListeImages();
-
 
64
			//$tpsFin = microtime(true);
-
 
65
			//$resultat->corps['entete']['execution.tps'] = $tpsFin - $tpsDebut;
56
		}
66
		}
57
		$resultat->mime = $this->parametres['retour'];
67
		$resultat->mime = $this->parametres['retour'];
Line 58... Line 68...
58
 
68
 
59
		return $resultat;
69
		return $resultat;
Line 164... Line 174...
164
		return $ok;
174
		return $ok;
165
	}
175
	}
Line 166... Line 176...
166
 
176
 
167
	private function analyserMasqueNn() {
177
	private function analyserMasqueNn() {
168
		$nn = $this->parametres['masque.nn'];
178
		$nn = $this->parametres['masque.nn'];
169
		if (is_numeric($nn)) {
179
		if (is_int($nn)) {
170
			$this->ref_tax_demande['bdtfx'] = $nn;
180
			$this->ref_tax_demande[self::CODE_REFTAX_DEFAUT] = $nn;
171
		} else {
181
		} else {
172
			// ceci contient potentiellement des formes ref_tax1:nn1,nn2;ref_tax2:nn3,nn4
182
			// ceci contient potentiellement des formes ref_tax1:nn1,nn2;ref_tax2:nn3,nn4
173
			$projetsListeEtNumNoms = explode(';', $nn);
183
			$projetsListeEtNumNoms = explode(';', $nn);
174
			if (count($projetsListeEtNumNoms) > 0) {
184
			if (count($projetsListeEtNumNoms) > 0) {
175
				foreach ($projetsListeEtNumNoms as $projetEtNumNoms) {
185
				foreach ($projetsListeEtNumNoms as $projetEtNumNoms) {
176
					$projetEtNumNoms = (strpos($projetEtNumNoms, ':')) ? $projetEtNumNoms : 'bdtfx:'.$projetEtNumNoms;
186
					$projetEtNumNoms = (strpos($projetEtNumNoms, ':')) ? $projetEtNumNoms : self::CODE_REFTAX_DEFAUT.':'.$projetEtNumNoms;
177
					list($projet, $numNoms) = explode(':', $projetEtNumNoms);
187
					list($projet, $numNoms) = explode(':', $projetEtNumNoms);
178
					$this->ref_tax_demande[$projet] = explode(',', $numNoms);
188
					$this->ref_tax_demande[$projet] = explode(',', $numNoms);
179
				}
189
				}
180
			}
190
			}
Line 231... Line 241...
231
	}
241
	}
Line 232... Line 242...
232
 
242
 
233
	private function convertirIdImageVersChemin($idImage) {
243
	private function convertirIdImageVersChemin($idImage) {
234
		$codeImage = $this->construireCodeImage($idImage);
244
		$codeImage = $this->construireCodeImage($idImage);
235
		list($dossierNiveau1, $dossierNiveau2, $idFichier, $format) = explode('_', $codeImage);
-
 
236
		$chemin_base = Config::get('Images.chemin');
245
		list($dossierNiveau1, $dossierNiveau2, $idFichier, $format) = explode('_', $codeImage);
237
		$chemin_sur_serveur = $chemin_base.'/'.$dossierNiveau1.'/'.$dossierNiveau2.'/'.$format;
246
		$chemin_sur_serveur = $this->cheminImagesBase.'/'.$dossierNiveau1.'/'.$dossierNiveau2.'/'.$format;
238
		return $chemin_sur_serveur;
247
		return $chemin_sur_serveur;
Line 239... Line 248...
239
	}
248
	}
240
 
249
 
Line 332... Line 341...
332
		}
341
		}
333
		return $url;
342
		return $url;
334
	}
343
	}
Line 335... Line 344...
335
 
344
 
336
	private function obtenirUrlNavigation($depart, $limite) {
-
 
337
		$urlNavigation = new Url(Config::get('serviceImageUrl'));
345
	private function obtenirUrlNavigation($depart, $limite) {
338
		$parametres = array(
346
		$parametres = array(
339
			'navigation.depart' => $depart,
347
			'navigation.depart' => $depart,
340
			'navigation.limite' => $limite);
348
			'navigation.limite' => $limite);
341
		if (isset($this->parametres['masque.nn'])) {
349
		if (isset($this->parametres['masque.nn'])) {
342
			$parametres['masque.nn'] = $this->parametres['masque.nn'];
350
			$parametres['masque.nn'] = $this->parametres['masque.nn'];
343
		}
351
		}
344
		$urlNavigation->setRequete($parametres);
352
		$this->UrlNavigation->setRequete($parametres);
345
		$url = $urlNavigation->getURL();
353
		$url = $this->UrlNavigation->getURL();
346
		return $url;
354
		return $url;
Line 347... Line 355...
347
	}
355
	}
348
 
356