From: Alan H. <min...@us...> - 2004-04-05 19:27:58
|
Update of /cvsroot/gallery/gallery2/modules/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26073/modules/core Modified Files: module.inc ItemEditAlbum.inc ItemEditPhotoSizes.inc ItemEditRotateAndScalePhoto.inc Log Message: Refactor how derivatives are instantiated. - Use newFactoryInstanceByHint passing source entityType as hint. - Change newFactoryInstanceByHint to accept single hint or array of hints and fallback to hint='*' if none match. Add new unit tests for api change. - Register GalleryDerivativeImage with hint '*' - Register PanoramaDerivativeImage with hint 'PanoramaPhotoItem' - Change newItemByMimeType to work with new hint mechanism instead of performing the fallbacks itself. - Update all newFactoryInstance() calls that create derivatives to use newFactoryInstanceByHint. Index: ItemEditRotateAndScalePhoto.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/ItemEditRotateAndScalePhoto.inc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ItemEditRotateAndScalePhoto.inc 5 Apr 2004 08:26:11 -0000 1.3 +++ ItemEditRotateAndScalePhoto.inc 5 Apr 2004 19:14:27 -0000 1.4 @@ -189,7 +189,7 @@ /* If we have no preferred, then create one */ if (empty($preferred)) { list ($ret, $preferred) = - GalleryCoreApi::newFactoryInstance('GalleryEntity', 'GalleryDerivativeImage'); + GalleryCoreApi::newFactoryInstanceByHint('GalleryDerivative', $item->getEntityType()); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } Index: ItemEditAlbum.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/ItemEditAlbum.inc,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- ItemEditAlbum.inc 5 Apr 2004 08:26:10 -0000 1.36 +++ ItemEditAlbum.inc 5 Apr 2004 19:14:27 -0000 1.37 @@ -164,7 +164,7 @@ } list ($ret, $thumbnail) = - GalleryCoreApi::newFactoryInstance('GalleryEntity', 'GalleryDerivativeImage'); + GalleryCoreApi::newFactoryInstanceByHint('GalleryDerivative', $source->getEntityType()); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } @@ -255,7 +255,8 @@ } list ($ret, $derivative) = - GalleryCoreApi::newFactoryInstance('GalleryEntity', 'GalleryDerivativeImage'); + GalleryCoreApi::newFactoryInstanceByHint('GalleryDerivative', + $source->getEntityType()); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } Index: module.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/module.inc,v retrieving revision 1.100 retrieving revision 1.101 diff -u -d -r1.100 -r1.101 --- module.inc 5 Apr 2004 08:26:11 -0000 1.100 +++ module.inc 5 Apr 2004 19:14:25 -0000 1.101 @@ -130,10 +130,11 @@ 'GalleryDerivative', $classDir . 'GalleryDerivative.class'); - GalleryCoreApi::registerFactoryImplementation('GalleryEntity', + GalleryCoreApi::registerFactoryImplementation('GalleryDerivative', 'GalleryDerivativeImage', 'GalleryDerivativeImage', - $classDir . 'GalleryDerivativeImage.class'); + $classDir . 'GalleryDerivativeImage.class', + array('*')); GalleryCoreApi::registerFactoryImplementation('GalleryEntity', 'GalleryMovieItem', Index: ItemEditPhotoSizes.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/ItemEditPhotoSizes.inc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ItemEditPhotoSizes.inc 5 Apr 2004 08:26:11 -0000 1.3 +++ ItemEditPhotoSizes.inc 5 Apr 2004 19:14:27 -0000 1.4 @@ -110,7 +110,7 @@ if (isset($toolkit)) { list ($ret, $thumbnail) = - GalleryCoreApi::newFactoryInstance('GalleryEntity', 'GalleryDerivativeImage'); + GalleryCoreApi::newFactoryInstanceByHint('GalleryDerivative', $source->getEntityType()); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } @@ -174,7 +174,7 @@ } list ($ret, $derivative) = - GalleryCoreApi::newFactoryInstance('GalleryEntity', 'GalleryDerivativeImage'); + GalleryCoreApi::newFactoryInstanceByHint('GalleryDerivative', $source->getEntityType()); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null, null); } |