0byt3m1n1
Path:
/
data
/
applications
/
aps
/
gallery
/
2.2-08
/
htdocs
/
modules
/
thumbnail
/
classes
/
[
Home
]
File: ThumbnailToolkit.class
<?php /* * Gallery - a web based photo album viewer and editor * Copyright (C) 2000-2007 Bharat Mediratta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ GalleryCoreApi::requireOnce('modules/core/classes/GalleryToolkit.class'); /** * A version of GalleryToolkit to supply default thumbnail images for non-image mime types. * @package Thumbnail * @subpackage Classes * @author Alan Harder <alan.harder@sun.com> * @version $Revision: 15513 $ */ class ThumbnailToolkit extends GalleryToolkit { /** * @see GalleryToolkit::getProperty */ function getProperty($mimeType, $propertyName, $sourceFilename) { return array(GalleryCoreApi::error(ERROR_UNIMPLEMENTED), null); } /** * @see GalleryToolkit::performOperation */ function performOperation($mimeType, $operationName, $sourceFilename, $destFilename, $parameters, $context=array()) { GalleryCoreApi::requireOnce('modules/thumbnail/classes/ThumbnailHelper.class'); global $gallery; $platform =& $gallery->getPlatform(); list ($ret, $mimeTypeMap) = ThumbnailHelper::fetchMimeTypeMap(); if ($ret) { return array($ret, null, null); } if (!isset($mimeTypeMap[$mimeType]) || $operationName != 'thumbnail') { return array(GalleryCoreApi::error(ERROR_UNSUPPORTED_OPERATION, __FILE__, __LINE__, "$operationName $mimeType"), null, null); } list ($ret, $thumbImage) = GalleryCoreApi::loadEntitiesById($mimeTypeMap[$mimeType]); if ($ret) { return array($ret, null, null); } list ($ret, $thumbPath) = $thumbImage->fetchPath(); if ($ret) { return array($ret, null, null); } $mimeType = 'image/jpeg'; $success = $platform->copy($thumbPath, $destFilename); if (!$success) { return array(GalleryCoreApi::error(ERROR_PLATFORM_FAILURE, __FILE__, __LINE__, "Failed copying $thumbPath -> $destFilename"), null, null); } $context['width'] = $thumbImage->getWidth(); $context['height'] = $thumbImage->getHeight(); /* Now get toolkit to resize image to thumbnail size */ list ($ret, $toolkit) = GalleryCoreApi::getToolkitByOperation($mimeType, 'thumbnail'); if ($ret) { return array($ret, null, null); } if (!isset($toolkit) || get_class($toolkit) == get_class($this)) { return array(GalleryCoreApi::error(ERROR_UNSUPPORTED_OPERATION, __FILE__, __LINE__, "thumbnail $mimeType"), null, null); } list ($ret, $mimeType, $context) = $toolkit->performOperation($mimeType, 'thumbnail', $destFilename, $destFilename, $parameters, $context); if ($ret) { return array($ret, null, null); } return array(null, $mimeType, $context); } } ?>