[pLog-svn] r559 - plog/trunk/class/action/admin

oscar at devel.plogworld.net oscar at devel.plogworld.net
Wed Dec 22 14:40:01 GMT 2004


Author: oscar
Date: 2004-12-22 14:40:00 +0000 (Wed, 22 Dec 2004)
New Revision: 559

Modified:
   plog/trunk/class/action/admin/adminregeneratepreviewaction.class.php
Log:
ported this feature too..


Modified: plog/trunk/class/action/admin/adminregeneratepreviewaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminregeneratepreviewaction.class.php	2004-12-22 14:09:13 UTC (rev 558)
+++ plog/trunk/class/action/admin/adminregeneratepreviewaction.class.php	2004-12-22 14:40:00 UTC (rev 559)
@@ -6,8 +6,8 @@
 
 
 	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
-	include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );
-	include_once( PLOG_CLASS_PATH."class/view/admin/adminmessageview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/admineditresourceview.class.php" );
 	include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
 	include_once( PLOG_CLASS_PATH."class/gallery/resizers/galleryresizer.class.php" );
 	include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
@@ -21,34 +21,24 @@
 		function AdminRegeneratePreviewAction( $actionInfo, $request )
         {
         	$this->AdminAction( $actionInfo, $request );
+
+		$this->registerFieldValidator( "resourceId", new IntegerValidator());
+		$view = new AdminResourcesListView( $this->_blogInfo );
+		$view->setErrorMessage( $this->_locale->tr("error_loading_resource"));
+		$this->setValidationErrorView( $view );
         }
 		
-		function validate()
-		{
-			$this->_resourceId = $this->_request->getValue( "resourceId" );
-			
-			$val = new IntegerValidator();
-			if( !$val->validate( $this->_resourceId )) {
-				$this->_view = new AdminErrorView( $this->_blogInfo );
-				$this->_view->setMessage( $this->_locale->tr("error_loading_resource" ));
-				$this->setCommonData();
-				
-				return false;
-			}
-			
-			return true;
-		}
-		
 		function perform()
 		{
 			// first of all, fetch the resource
+			$this->_resourceId = $this->_request->getValue( "resourceId" );
 			$resources = new GalleryResources();
 			$resource = $resources->getResource( $this->_resourceId, $this->_blogInfo->getId());
 			
 			// check if it was loaded ok
 			if( !$resource ) {
-				$this->_view = new AdminErrorView( $this->_blogInfo );
-				$this->_view->setMessage( $this->_locale->tr("error_loading_resource"));
+				$this->_view = new AdminResourcesListView( $this->_blogInfo );
+				$this->_view->setErrorMessage( $this->_locale->tr("error_loading_resource"));
 				$this->setCommonData();
 				
 				return false;
@@ -57,8 +47,8 @@
 			// if so, continue... first by checking if the resource is an image or not
 			// because if not, then there is no point in generating a thumbnail of it!
 			if( !$resource->isImage()) {
-				$this->_view = new AdminErrorView( $this->_blogInfo );
-				$this->_view->setMessage( $this->_locale->tr("error_resource_is_not_an_image" ));
+				$this->_view = new AdminResourcesListView( $this->_blogInfo );
+				$this->_view->setErrorMessage( $this->_locale->tr("error_resource_is_not_an_image" ));
 			}
 			
 			
@@ -71,31 +61,31 @@
 			$fileExt = strtolower($fileNameParts[count($fileNameParts)-1]);
 			$fileName = $resource->getOwnerId()."-".$resource->getId().".".$fileExt;
 
-            // and start the resizing process
+	            // and start the resizing process
 			$resourceStorage = new GalleryResourceStorage();
-            $resizer = new GalleryResizer( $resourceStorage->getResourcePath( $resource ));
-            $resourceStorage->checkPreviewsStorageFolder( $resource->getOwnerId());
-            $outFile = $resourceStorage->getPreviewsFolder( $resource->getOwnerId()).$fileName;
+        	    $resizer = new GalleryResizer( $resourceStorage->getResourcePath( $resource ));
+	            $resourceStorage->checkPreviewsStorageFolder( $resource->getOwnerId());
+        	    $outFile = $resourceStorage->getPreviewsFolder( $resource->getOwnerId()).$fileName;
 			
-            // and finally, we can generate the preview!
-            $result = $resizer->generate( $outFile, $previewHeight, $previewWidth, $previewKeepAspectRatio );
+	            // and finally, we can generate the preview!
+	            $result = $resizer->generate( $outFile, $previewHeight, $previewWidth, $previewKeepAspectRatio );
 			
 			$previewFormat = $resizer->getThumbnailFormat();
 			$resource->setThumbnailFormat( $previewFormat );
 			$resources->updateResource( $resource );
 			
 			if( !$result ) {
-				$this->_view = new AdminErrorView( $this->_blogInfo );
-				$message = $this->_locale->tr("error_generating_resource_preview");
-				$message .= "<br/><br/><a href=\"javascript:history.go(-1);\">".$this->_locale->tr("back")."</a>";
+				$this->_view = new AdminResourcesListView( $this->_blogInfo );
+				$this->_view->setErrorMessage( $this->_locale->tr("error_generating_resource_preview" ));
 			}
 			else {
-				$this->_view = new AdminMessageView( $this->_blogInfo );
-				$message = $this->_locale->tr("resource_preview_generated_ok");
-				$message .= "<br/><br/><a href=\"admin.php?op=resources&amp;albumId=".$resource->getAlbumId()."\">".$this->_locale->tr("view")."</a>";			
+				$this->_view = new AdminEditResourceView( $this->_blogInfo );
+				$this->_view->setSuccessMessage( $message = $this->_locale->tr("resource_preview_generated_ok" ));
+				$this->_view->setValue( "resourceDescription", $resource->getDescription());
+				$this->_view->setValue( "albumId", $resource->getAlbumId());
+				$this->_view->setValue( "resource", $resource );
 			}
 			
-			$this->_view->setMessage( $message );
 			$this->setCommonData();
 			
 			return true;




More information about the pLog-svn mailing list