Subversion Repositories eFlore/Applications.cel

Rev

Rev 2458 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
661 aurelien 1
<?php
2458 jpm 2
// declare(encoding='UTF-8');
880 aurelien 3
/**
2458 jpm 4
 * Service fournissant des images au format demandé ou bien aux dimensions demandées.
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>
880 aurelien 17
 */
903 aurelien 18
class ImageProvider extends Cel {
2458 jpm 19
 
20
	public function getElement($uid){
21
		if (!isset($uid[0])) {
661 aurelien 22
			return;
23
		}
24
		$id_image = $uid[0];
2458 jpm 25
 
661 aurelien 26
		$format = 'temp';
2458 jpm 27
		if (isset($_GET['format'])) {
661 aurelien 28
			$format = $_GET['format'];
29
		}
2458 jpm 30
 
31
		if (isset($_GET['dimensions'])) {
661 aurelien 32
			$dimensions = $_GET['dimensions'];
2458 jpm 33
		} else if (isset($this->config['cel']['format_'.$format])) {
34
			$dimensions = $this->config['cel']['format_'.$format];
661 aurelien 35
		}
1392 aurelien 36
		$this->config['cel']['format_'.$format] = $dimensions;
2458 jpm 37
 
661 aurelien 38
		$generateur_image = new ImageRecreation($this->config);
39
		$infos_image = $generateur_image->obtenirImageEtInfosPourId($id_image);
2458 jpm 40
		if (!$infos_image) {
661 aurelien 41
			header('HTTP/1.0 404 Not Found');
2458 jpm 42
			exit();
43
		} else {
44
			$image_generee = $generateur_image->creerMiniatureImageSelonFormat($infos_image, $format);
45
			header('Content-type: image/jpeg');
46
			imagejpeg($image_generee);
47
			exit();
661 aurelien 48
		}
49
	}
2458 jpm 50
}