[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/view/admin/admineditresourceview.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/gallery/resizers/galleryresizer.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" ); 10 11 /** 12 * \ingroup Action 13 * @private 14 */ 15 class AdminRegeneratePreviewAction extends AdminAction 16 { 17 18 var $_resourceId; 19 20 function AdminRegeneratePreviewAction( $actionInfo, $request ){ 21 $this->AdminAction( $actionInfo, $request ); 22 23 $this->registerFieldValidator( "resourceId", new IntegerValidator()); 24 $view = new AdminResourcesListView( $this->_blogInfo ); 25 $view->setErrorMessage( $this->_locale->tr("error_loading_resource")); 26 $this->setValidationErrorView( $view ); 27 } 28 29 function perform(){ 30 // first of all, fetch the resource 31 $this->_resourceId = $this->_request->getValue( "resourceId" ); 32 $resources = new GalleryResources(); 33 $resource = $resources->getResource( $this->_resourceId, $this->_blogInfo->getId()); 34 35 // check if it was loaded ok 36 if( !$resource ) { 37 $this->_view = new AdminResourcesListView( $this->_blogInfo ); 38 $this->_view->setErrorMessage( $this->_locale->tr("error_loading_resource")); 39 $this->setCommonData(); 40 41 return false; 42 } 43 44 // if so, continue... first by checking if the resource is an image or not 45 // because if not, then there is no point in generating a thumbnail of it! 46 if( !$resource->isImage()) { 47 $this->_view = new AdminResourcesListView( $this->_blogInfo ); 48 $this->_view->setErrorMessage( $this->_locale->tr("error_resource_is_not_an_image" )); 49 } 50 51 52 $previewHeight = $this->_config->getValue( "thumbnail_height" ); 53 $previewWidth = $this->_config->getValue( "thumbnail_width" ); 54 $previewKeepAspectRatio = $this->_config->getValue( "thumbnails_keep_aspect_ratio" ); 55 56 // build the filename 57 $fileNameParts = explode( ".", $resource->getFileName()); 58 $fileExt = strtolower($fileNameParts[count($fileNameParts)-1]); 59 $fileName = $resource->getOwnerId()."-".$resource->getId().".".$fileExt; 60 61 // and start the resizing process 62 $resourceStorage = new GalleryResourceStorage(); 63 $resizer = new GalleryResizer( $resourceStorage->getResourcePath( $resource )); 64 $resourceStorage->checkPreviewsStorageFolder( $resource->getOwnerId()); 65 $outFile = $resourceStorage->getPreviewsFolder( $resource->getOwnerId()).$fileName; 66 67 // and finally, we can generate the preview! 68 $result = $resizer->generate( $outFile, $previewHeight, $previewWidth, $previewKeepAspectRatio ); 69 70 $previewFormat = $resizer->getThumbnailFormat(); 71 $resource->setThumbnailFormat( $previewFormat ); 72 $resources->updateResource( $resource ); 73 74 if( !$result ) { 75 $this->_view = new AdminResourcesListView( $this->_blogInfo ); 76 $this->_view->setErrorMessage( $this->_locale->tr("error_generating_resource_preview" )); 77 } 78 else { 79 $previewHeight = $this->_config->getValue( "medium_size_thumbnail_height" ); 80 $previewWidth = $this->_config->getValue( "medium_size_thumbnail_width" ); 81 82 // and start the resizing process 83 $resourceStorage = new GalleryResourceStorage(); 84 $resizer = new GalleryResizer( $resourceStorage->getResourcePath( $resource )); 85 $resourceStorage->checkMediumSizePreviewsStorageFolder( $resource->getOwnerId()); 86 $outFile = $resourceStorage->getMediumSizePreviewsFolder( $resource->getOwnerId()).$fileName; 87 88 // and finally, we can generate the preview! 89 $result = $resizer->generate( $outFile, $previewHeight, $previewWidth, $previewKeepAspectRatio ); 90 91 $previewFormat = $resizer->getThumbnailFormat(); 92 $resource->setThumbnailFormat( $previewFormat ); 93 $resources->updateResource( $resource ); 94 95 if( !$result ) { 96 $this->_view = new AdminResourcesListView( $this->_blogInfo ); 97 $this->_view->setErrorMessage( $this->_locale->tr("error_generating_resource_medium" )); 98 } 99 else { 100 $this->_view = new AdminEditResourceView( $this->_blogInfo ); 101 $this->_view->setSuccessMessage( $message = $this->_locale->tr("resource_preview_generated_ok" )); 102 $this->_view->setValue( "resourceDescription", $resource->getDescription()); 103 $this->_view->setValue( "albumId", $resource->getAlbumId()); 104 $this->_view->setValue( "resource", $resource ); 105 } 106 } 107 $this->setCommonData(); 108 109 return true; 110 } 111 } 112 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |