1,10 → 1,26 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Service fournissant permettant de visualiser ou télécharger des images du CEL. |
* |
* @internal Mininum PHP version : 5.2 |
* @category CEL |
* @package Services |
* @subpackage Images |
* @version 0.1 |
* @author Mathias CHOUET <mathias@tela-botanica.org> |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @author Aurelien PERONNET <aurelien@tela-botanica.org> |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt> |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt> |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org> |
*/ |
class CelImageFormat { |
|
private $config; |
private $formats = array('CRX2S','CRXS','CXS','CS','CRS','XS','S','M','L','XL','X2L','X3L','O'); |
const METHODE_TELECHARGEMENT = "telecharger"; |
const METHODE_AFFICHAGE = "afficher"; |
const METHODE_TELECHARGEMENT = 'telecharger'; |
const METHODE_AFFICHAGE = 'afficher'; |
|
// Pas besoin d'étendre Cel ici, surtout que le constructeur |
// de la classe Cel instancie toujours une connexion à la bdd |
23,7 → 39,6 |
* Méthode appelée avec une requête de type GET. |
*/ |
public function getElement($params) { |
|
// suppression des 0 non significatifs à gauche |
$id = ltrim($params[0],'0'); |
$format = isset($_GET['format']) ? $_GET['format'] : 'M'; |
66,12 → 81,10 |
header("HTTP/1.0 400 Bad Request"); |
echo $message; |
} |
|
return $ok; |
} |
|
private function envoyerImage($id, $image_binaire, $format, $methode) { |
|
if($methode == self::METHODE_AFFICHAGE) { |
header('Content-Type: image/jpeg'); |
} else { |
79,11 → 92,10 |
} |
|
echo $image_binaire; |
exit; |
exit(); |
} |
|
private function envoyerHeadersTelechargement($id, $image_binaire, $format) { |
|
if (function_exists('mb_strlen')) { |
$taille = mb_strlen($image_binaire, '8bit'); |
} else { |
109,9 → 121,10 |
private function obtenirDescriptionService() { |
$retour = array('description' => 'Ce service peut être appelé afin de visualiser ou bien télécharger les images du cel', |
'formats' => $this->formats, |
'utilisation' => "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."/{id} où {id} est l'identifiant numérique de l'image désirée", |
'parametres' => array("methode" => "Valeurs : afficher, telecharger. Permet de préciser si l'image doit être affichée ou téléchargée", |
"format" => "Valeurs : voir la liste ci dessous. Permet de demander un format précis de l'image parmi ceux disponibles ") |
'utilisation' => 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."/{id} où {id} est l'identifiant numérique de l'image désirée", |
'parametres' => array( |
'methode' => "Valeurs : afficher, telecharger. Permet de préciser si l'image doit être affichée ou téléchargée", |
'format' => "Valeurs : voir la liste ci dessous. Permet de demander un format précis de l'image parmi ceux disponibles ") |
); |
|
// ^^ c'est marrant non ? |