Subversion Repositories eFlore/Applications.cel

Rev

Rev 2209 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2209 Rev 2461
Line 1... Line 1...
1
<?php
1
<?php
-
 
2
// declare(encoding='UTF-8');
-
 
3
/**
-
 
4
 * Service fournissant permettant de visualiser ou télécharger des images du CEL.
-
 
5
 *
-
 
6
 * @internal   Mininum PHP version : 5.2
-
 
7
 * @category   CEL
-
 
8
 * @package    Services
-
 
9
 * @subpackage Images
-
 
10
 * @version    0.1
-
 
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
-
 
12
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
-
 
13
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
-
 
14
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
-
 
15
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
-
 
16
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
-
 
17
 */
2
class CelImageFormat {
18
class CelImageFormat {
Line 3... Line 19...
3
	
19
 
4
	private $config;
20
	private $config;
5
	private $formats = array('CRX2S','CRXS','CXS','CS','CRS','XS','S','M','L','XL','X2L','X3L','O');
21
	private $formats = array('CRX2S', 'CRXS', 'CXS', 'CS', 'CRS', 'XS', 'S', 'M', 'L', 'XL', 'X2L', 'X3L', 'O');
6
	const METHODE_TELECHARGEMENT = "telecharger";
22
	const METHODE_TELECHARGEMENT = 'telecharger';
Line 7... Line 23...
7
	const METHODE_AFFICHAGE = "afficher";
23
	const METHODE_AFFICHAGE = 'afficher';
8
	
24
 
9
	// Pas besoin d'étendre Cel ici, surtout que le constructeur 
25
	// Pas besoin d'étendre Cel ici, surtout que le constructeur
10
	// de la classe Cel instancie toujours une connexion à la bdd
26
	// de la classe Cel instancie toujours une connexion à la bdd
Line 21... Line 37...
21
	
37
 
22
	/**
38
	/**
23
	* Méthode appelée avec une requête de type GET.
39
	* Méthode appelée avec une requête de type GET.
24
	*/
40
	*/
25
	public function getElement($params) {
-
 
26
		
41
	public function getElement($params) {
27
		// suppression des 0 non significatifs à gauche
42
		// suppression des 0 non significatifs à gauche
28
		$id = ltrim($params[0],'0');
43
		$id = ltrim($params[0], '0');
29
		$format = isset($_GET['format']) ? $_GET['format'] : 'M';	
44
		$format = isset($_GET['format']) ? $_GET['format'] : 'M';
Line 64... Line 79...
64
 
79
 
65
		if(!empty($message)) {
80
		if(!empty($message)) {
66
			header("HTTP/1.0 400 Bad Request");
81
			header("HTTP/1.0 400 Bad Request");
67
			echo $message;
82
			echo $message;
68
		}
-
 
69
 
83
		}
70
		return $ok;
84
		return $ok;
Line 71... Line 85...
71
	}
85
	}
72
	
-
 
73
	private function envoyerImage($id, $image_binaire, $format, $methode) {
86
 
74
		
87
	private function envoyerImage($id, $image_binaire, $format, $methode) {
75
		if($methode == self::METHODE_AFFICHAGE) {
88
		if ($methode == self::METHODE_AFFICHAGE) {
76
			header('Content-Type: image/jpeg');
89
			header('Content-Type: image/jpeg');
77
		} else {
90
		} else {
Line 78... Line 91...
78
			$this->envoyerHeadersTelechargement($id, $image_binaire, $format);	
91
			$this->envoyerHeadersTelechargement($id, $image_binaire, $format);
79
		}
92
		}
80
		
93
 
Line 81... Line 94...
81
		echo $image_binaire;
94
		echo $image_binaire;
82
		exit;
-
 
83
	}
95
		exit();
84
	
96
	}
85
	private function envoyerHeadersTelechargement($id, $image_binaire, $format) {
97
 
86
		
98
	private function envoyerHeadersTelechargement($id, $image_binaire, $format) {
87
		if (function_exists('mb_strlen')) {
99
		if (function_exists('mb_strlen')) {
Line 107... Line 119...
107
	}
119
	}
Line 108... Line 120...
108
	
120
 
109
	private function obtenirDescriptionService() {
121
	private function obtenirDescriptionService() {
110
		$retour = array('description' => 'Ce service peut être appelé afin de visualiser ou bien télécharger les images du cel',
122
		$retour = array('description' => 'Ce service peut être appelé afin de visualiser ou bien télécharger les images du cel',
111
				'formats' => $this->formats,
123
			'formats' => $this->formats,
-
 
124
			'utilisation' => 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."/{id} où {id} est l'identifiant numérique de l'image désirée",
112
				'utilisation' => "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."/{id} où {id} est l'identifiant numérique de l'image désirée",
125
			'parametres' => array(
113
				'parametres' => array("methode" => "Valeurs : afficher, telecharger. Permet de préciser si l'image doit être affichée ou téléchargée",
126
				'methode' => "Valeurs : afficher, telecharger. Permet de préciser si l'image doit être affichée ou téléchargée",
114
						"format" => "Valeurs : voir la liste ci dessous. Permet de demander un format précis de l'image parmi ceux disponibles ")
127
				'format' => "Valeurs : voir la liste ci dessous. Permet de demander un format précis de l'image parmi ceux disponibles ")
Line 115... Line 128...
115
		);
128
		);
116
		
129
 
117
		// ^^ c'est marrant non ?
130
		// ^^ c'est marrant non ?