*/ /** * This ItemEditOption will handle switching between Photo and Panorama types * * @package Panorama * @subpackage UserInterface * */ class PanoramaOption extends ItemEditOption { /** * @see ItemEditOption::isAppropriate */ function isAppropriate($item, $thumbnail) { if (!GalleryUtilities::isExactlyA($item, 'GalleryPhotoItem') && !GalleryUtilities::isExactlyA($item, 'PanoramaPhotoItem')) { return array(GalleryStatus::success(), false); } list ($ret, $param) = GalleryCoreApi::fetchAllPluginParameters('module', 'panorama'); if ($ret->isError() || !$param['itemType']) { return array(GalleryStatus::success(), false); } list ($ret, $preferred) = GalleryCoreApi::fetchPreferredsByItemIds(array($item->getId())); if ($ret->isError()) { return array(GalleryStatus::success(), false); } $width = empty($preferred) ? $item->getWidth() : $preferred[$item->getId()]->getWidth(); $mimeType = empty($preferred) ? $item->getMimeType() : $preferred[$item->getId()]->getMimeType(); return array(GalleryStatus::success(), $width > $param['width'] && ($mimeType == 'image/jpeg' || $mimeType == 'image/gif')); } /** * @see ItemEditOption::loadTemplate */ function loadTemplate(&$template, &$form, $item, $thumbnail) { list ($ret, $preferred) = GalleryCoreApi::fetchPreferredsByItemIds(array($item->getId())); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } $form['PanoramaOption']['isPanorama'] = empty($preferred) ? GalleryUtilities::isA($item, 'PanoramaPhotoItem') : GalleryUtilities::isA($preferred[$item->getId()], 'PanoramaDerivativeImage'); return array(GalleryStatus::success(), 'modules/panorama/templates/PanoramaOption.tpl', 'modules_panorama'); } /** * @see ItemEditOption::handleRequestAfterEdit */ function handleRequestAfterEdit($form, &$item, &$preferred) { GalleryCoreApi::relativeRequireOnce('modules/panorama/classes/PanoramaHelper.class'); $isPanorama = isset($form['PanoramaOption']['isPanorama']) && $form['PanoramaOption']['isPanorama']; $ret = PanoramaHelper::assignEntityType($item, $isPanorama); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } if (isset($preferred) && GalleryUtilities::isA($preferred, 'GalleryDerivativeImage')) { $ret = PanoramaHelper::assignEntityType($preferred, $isPanorama); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } } return array(GalleryStatus::success(), array(), array()); } } ?>