Subversion Repositories eFlore/Applications.cel

Rev

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

<?php
// declare(encoding='UTF-8');
/**
 * Service fournissant des images au format demandé ou bien aux dimensions demandées.
 *
 * @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 ImageProvider extends Cel {

        public function getElement($uid){
                if (!isset($uid[0])) {
                        return;
                }
                $id_image = $uid[0];

                $format = 'temp';
                if (isset($_GET['format'])) {
                        $format = $_GET['format'];
                }

                if (isset($_GET['dimensions'])) {
                        $dimensions = $_GET['dimensions'];
                } else if (isset($this->config['cel']['format_'.$format])) {
                        $dimensions = $this->config['cel']['format_'.$format];
                }
                $this->config['cel']['format_'.$format] = $dimensions;

                $generateur_image = new ImageRecreation($this->config);
                $infos_image = $generateur_image->obtenirImageEtInfosPourId($id_image);
                if (!$infos_image) {
                        header('HTTP/1.0 404 Not Found');
                        exit();
                } else {
                        $image_generee = $generateur_image->creerMiniatureImageSelonFormat($infos_image, $format);
                        header('Content-type: image/jpeg');
                        imagejpeg($image_generee);
                        exit();
                }
        }
}