[pLog-svn] r4392 - in plog/trunk: class/action class/file class/gallery/dao class/gallery/resizers class/net class/view templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Dec 17 17:28:20 GMT 2006


Author: oscar
Date: 2006-12-17 17:28:19 +0000 (Sun, 17 Dec 2006)
New Revision: 4392

Removed:
   plog/trunk/class/view/resourceserverview.class.php
Modified:
   plog/trunk/class/action/resourceserveraction.class.php
   plog/trunk/class/file/fileupload.class.php
   plog/trunk/class/gallery/dao/galleryresource.class.php
   plog/trunk/class/gallery/dao/galleryresources.class.php
   plog/trunk/class/gallery/dao/galleryresourcestorage.class.php
   plog/trunk/class/gallery/resizers/gallerythumbnailgenerator.class.php
   plog/trunk/class/net/baserequestgenerator.class.php
   plog/trunk/class/net/customrequestgenerator.class.php
   plog/trunk/class/net/prettyrequestgenerator.class.php
   plog/trunk/class/net/rawrequestgenerator.class.php
   plog/trunk/class/view/redirectview.class.php
   plog/trunk/templates/admin/globalsettings_url.template
Log:
merging all the work from the lifetype-1.2-resource-test branch, so that I can get some help testing it...


Modified: plog/trunk/class/action/resourceserveraction.class.php
===================================================================
--- plog/trunk/class/action/resourceserveraction.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/action/resourceserveraction.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -1,13 +1,17 @@
 <?php
 
+	// the three different modes that a resource can be requested
+	define( 'RESOURCE_VIEW_MODE_DEFAULT', '' );
+	define( 'RESOURCE_VIEW_MODE_PREVIEW', 'preview' );
+	define( 'RESOURCE_VIEW_MODE_MEDIUM', 'medium' );
+
     lt_include( PLOG_CLASS_PATH."class/action/action.class.php" );
     lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/view/resourceserverview.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/view/redirectview.class.php" );
     lt_include( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
     lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
     lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );	
     lt_include( PLOG_CLASS_PATH."class/security/pipeline.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );	
 	lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
 	lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );	
 
@@ -45,7 +49,7 @@
 			
 			// since this class does not return HTML code but files, we cannot
 			// return HTML so let's return 404 status code with a custom error message
-			$view = new ResourceServerView();
+			$view = new View();
 			$view->addHeaderResponse( "HTTP/1.1 404 Not Found" );
 			$view->addHeaderResponse( "Status: 404 Not Found" );
 			$view->addHeaderResponse( "X-LifeType-Error: Invalid parameters" );
@@ -127,7 +131,7 @@
 			$this->_getBlogInfo();
 			if( $this->_blogInfo == false ) {
 				// return 404 not found because the blog id is not correct!
-				$this->_view = new ResourceServerView();
+				$this->_view = new View();
 				$this->_view->addHeaderResponse( "HTTP/1.1 404 Not Found" );
 				$this->_view->addHeaderResponse( "Status: 404 Not Found" );
 				$this->_view->addHeaderResponse( "X-LifeType-Error: Blog $resId is not correct" );
@@ -135,28 +139,6 @@
 				return false;			
 			}
 
-			//
-            // security stuff
-			//
-			// :KLUDGE: the problem with the security Pipeline and the PluginManager in this
-			// action is that we need to reimplement the whole stuff because... this action does not
-			// inherit from BlogAction and therefore nobody is doing these things for us! I don't really
-			// like to do it like this but while I think of a better way, let's leave like it
-			//
-            $pipeline = new Pipeline( $this->_request, $this->_blogInfo );
-            $result = $pipeline->process();
-			
-            // if the pipeline blocked the request, then we have to let the user know and quit
-			// processing
-            if( !$result->isValid()) {
-				$this->_view = new ResourceServerView();
-				$this->_view->addHeaderResponse( "HTTP/1.1 403 Forbidden" );
-				$this->_view->addHeaderResponse( "Status: 403 Forbidden" );
-				$this->_view->addHeaderResponse( "X-LifeType-Error: Access is blocked" );
-			
-				return false;
-            }
-						
 			// now if the blog id was correct, then we can proceed to get the rest of the parameters
 			$this->_resName = $this->_request->getValue( "resource" );
 			$this->_resId = $this->_request->getValue( "resId" );
@@ -172,7 +154,7 @@
 					$albums = new GalleryAlbums();
 					$album = $albums->getAlbumByName( $this->_albumName );
 					if( !$album ) {
-						$this->_view = new ResourceServerView();
+						$this->_view = new View();
 						$this->_view->addHeaderResponse( "HTTP/1.1 404 Not Found" );
 						$this->_view->addHeaderResponse( "Status: 404 Not Found" );
 						$this->_view->addHeaderResponse( "X-LifeType-Error: Album $albumId not found" );
@@ -185,29 +167,8 @@
 			return true;
 		}
 		
-		/**
-		 * notifies of events using the plugin manager. It also adds a couple of useful parameters!
-		 *
-		 * @see PluginManager
-		 */
-		function notifyEvent( $eventType, $params = Array())
-		{
-			$params[ 'from' ] = $this->_actionInfo->getActionParamValue();
-			$params[ 'request' ] = $this->_request;
-					
-			return $this->_pm->notifyEvent( $eventType, $params );
-		}		
-		
 		function perform()
 		{
-			// initialize the plugin manager, needed to inform plugins of the EVENT_RESOURCE_LOADED
-			// event, in case any of them is waiting for it! This obviously slows things down but
-			// hey, what can I do? Users ask and I deliver...
-            $this->_pm =& PluginManager::getPluginManager();
-            $this->_pm->setBlogInfo( $this->_blogInfo );
-			$this->_userInfo = $this->_blogInfo->getOwnerInfo();
-            $this->_pm->setUserInfo( $this->_userInfo );
-
 			// and fetch the resource
 			$resources = new GalleryResources();
 			if( $this->_resName ) {
@@ -219,7 +180,7 @@
 
 			if( !$resource ) {
 				// return 404 not found because the resource wasn't found
-				$this->_view = new ResourceServerView();
+				$this->_view = new View();
 				$this->_view->addHeaderResponse( "HTTP/1.1 404 Not Found" );
 				$this->_view->addHeaderResponse( "Status: 404 Not Found" );
 				$this->_view->addHeaderResponse( "X-LifeType-Error: Resource $this->_resId not found" );		
@@ -227,11 +188,21 @@
 				return false;
 			}
 			
-			// we need to let plugins know that we have successfully loaded a resource
-			$this->notifyEvent( EVENT_RESOURCE_LOADED, Array( "resource" => &$resource ));
+			$url = $this->_blogInfo->getBlogRequestGenerator();
+			switch( $this->_mode ) {
+				case RESOURCE_VIEW_MODE_PREVIEW:
+					$redirectUrl = $url->resourcePreviewLink( $resource );
+					break;
+				case RESOURCE_VIEW_MODE_MEDIUM:
+					$redirectUrl = $url->resourceMediumSizePreviewLink( $resource );
+					break;
+				default:
+					$redirectUrl = $url->resourceDownloadLink( $resource );
+					break;
+			}
 			
 			// generate the correct view with the resource data...			
-			$this->_view = new ResourceServerView( $resource, $this->_mode );
+			$this->_view = new RedirectView( $redirectUrl, $this->_mode );
 			
 			return true;
 		}

Modified: plog/trunk/class/file/fileupload.class.php
===================================================================
--- plog/trunk/class/file/fileupload.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/file/fileupload.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -41,6 +41,11 @@
         	return $this->_name;
         }
 
+		function setFileName( $fileName ) 
+		{
+			$this->_name = $fileName;
+		}
+
 		/**
 		 * returns the MIME type of the file
 		 *

Modified: plog/trunk/class/gallery/dao/galleryresource.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresource.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/gallery/dao/galleryresource.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -241,68 +241,6 @@
         }
 
 		/**
-		 * returns an stream of bytes with the contents of the file
-		 *
-		 * @return an string with all the bytes or false otherwise
-		 */
-        function getData()
-        {    
-        	lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );        
-        
-        	$fileParts = explode( ".", $this->getFileName());
-            $fileExt = $fileParts[count($fileParts)-1];
-
-			$resourceStorageFolder = GalleryResourceStorage::getResourcesStorageFolder();
-            $fileName = $resourceStorageFolder.$this->getOwnerId()."/".$this->getOwnerId()."-".$this->getId().".".$fileExt;
-
-			return $this->_getData( $fileName );
-        }
-        
-		/**
-		 * returns a buffer of bytes limited to $chunkSize in bytes from
-		 * the file descriptor provided
-		 *
-		 * @return a buffer of bytes from the file or false if empty or error
-		 * @private
-		 */
-		function _getDataChunk(&$filedesc,$chunkSize)
-		{
-			if (feof($filedesc) || !$filedesc) {
-				/* finished reading file */
-				if (feof($filedesc))
-					fclose($filedesc);
-		
-				return false;
-			}
-			else {
-				/* return $chunksize of bytes */
-				return fread($filedesc,$chunkSize);
-			}
-		}
-		
-		/**
-		 * @private
-		 */
-		function getDataChunk($chunksize)
-		{
-			if (!$this->_fileDescriptor) {
-				lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );			
-				$fileParts = explode(".",$this->getFileName());
-				$fileExt = $fileParts[count($fileParts)-1];
-				$resourceStorageFolder = GalleryResourceStorage::getResourcesStorageFolder();
-				$fileName = $resourceStorageFolder.$this->getOwnerId()."/".$this->getOwnerId()."-".$this->getId().".".$fileExt;
-				
-				/* store this for use again */
-				$this->_fileDescriptor = @fopen($fileName,"rb");
-				
-				/* open failed... we'll just say empty file */
-				if (!$this->_fileDescriptor)
-					return false;
-			}
-			return $this->_getDataChunk($this->_fileDescriptor,$chunksize);
-		}        
-
-		/**
 		 * Sets the album id. You should normally not need to use this method
 		 *
 		 * @param albumId The id of the album
@@ -436,36 +374,15 @@
     		lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );		
 		
 			if( $this->getThumbnailFormat() == THUMBNAIL_OUTPUT_FORMAT_SAME_AS_IMAGE ) {
-				$fileParts = explode( ".", $this->getFileName());
-				$fileExt = $fileParts[count($fileParts)-1];
-				
-				$fileName = $this->getOwnerId()."-".$this->getId().".".strtolower($fileExt);
-				$previewFile = GalleryResourceStorage::getPreviewsFolder( $this->getOwnerId()).$fileName;
+				$previewFile = GalleryResourceStorage::getPreviewsFolder( $this->getOwnerId()).$this->getFileName();
 			}
 			else {
-				$previewType = $this->getThumbnailFormat();
-				$fileName = $this->getOwnerId()."-".$this->getId().".".strtolower($previewType);
-				$previewFile = GalleryResourceStorage::getPreviewsFolder( $this->getOwnerId()).$fileName;				
+				throw( new Exception( "TODO: this case has not been implemented yet!" ));
 			}
 
 			return $previewFile;
 		}
 
-        /**
-         * Returns the binary data corresponding to the preview.
-         *
-         * @return A string of binary data.
-         */
-        function getPreview()
-        {
-        	if( !$this->hasPreview())
-            	return false;
-				
-			$previewFile = $this->getPreviewFileName();
-			
-			return $this->_getData( $previewFile );
-        }
-
 		/**
 		 * returns the full path to the file with the medium-sized preview
 		 *
@@ -476,64 +393,15 @@
 			lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );		
 		
 			if( $this->getThumbnailFormat() == THUMBNAIL_OUTPUT_FORMAT_SAME_AS_IMAGE ) {
-				$fileParts = explode( ".", $this->getFileName());
-				$fileExt = $fileParts[count($fileParts)-1];
-				
-				$fileName = $this->getOwnerId()."-".$this->getId().".".strtolower($fileExt);
-				$previewFile = GalleryResourceStorage::getMediumSizePreviewsFolder( $this->getOwnerId()).$fileName;
+				$previewFile = GalleryResourceStorage::getMediumSizePreviewsFolder( $this->getOwnerId()).$this->getFileName();
 			}
 			else {
-				$previewType = $this->getThumbnailFormat();
-				$fileName = $this->getOwnerId()."-".$this->getId().".".strtolower($previewType);
-				$previewFile = GalleryResourceStorage::getMediumSizePreviewsFolder( $this->getOwnerId()).$fileName;				
+				throw( new Exception( "TODO: this case has not been implemented yet!" ));				
 			}
 
 			return $previewFile;
 		}
 		
-        /**
-         * Returns the binary data corresponding to the preview.
-         *
-         * @return A string of binary data.
-         */
-        function getMediumSizePreview()
-        {
-        	if( !$this->hasPreview())
-            	return false;
-				
-			// get the file name of the medium size preview
-			$previewFile = $this->getMediumSizePreviewFileName();
-
-			// if there is no medium size file, then return the big one... for compatibility reasons
-			$data = $this->_getData( $previewFile );
-			if( !$data )
-				return $this->getData();
-			else
-				return $data;
-        }
-		
-		/**
-		 * returns an stream of data with the contents of the file. This method is used by 
-		 * getData(), getPreviewData and getMediumSizePreviewData()
-		 *
-		 * @return The contents of the given file or nothing if empty or if it can't be read
-		 * @private
-		 */
-		function _getData( $file )
-		{
-			if( File::isReadable ( $file )) {
-				$file = new File( $file );
-				$file->open( "rb" );
-
-				$size = $file->getSize();
-
-				return $file->read( $size );	
-			}
-			else {
-				return false;
-			}
-		}
-		
 		function getNormalizedDescription()
 		{
 			lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );

Modified: plog/trunk/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresources.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/gallery/dao/galleryresources.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -106,7 +106,7 @@
 			$id = $resource->getId();
 			$query = "SELECT id, owner_id, album_id, description,
         	                 date, flags, resource_type, file_path, file_name,
-        	                 metadata, thumbnail_format, properties
+        	                 metadata, thumbnail_format, properties, file_size
         	          FROM {$prefix}gallery_resources 
 			          WHERE album_id = '$albumId' AND date >= '$date' AND id > $id
 					  ORDER BY date ASC,id ASC LIMIT 1";
@@ -146,7 +146,7 @@
 			$id = $resource->getId();
 			$query = "SELECT id, owner_id, album_id, description,
         	                 date, flags, resource_type, file_path, file_name,
-        	                 metadata, thumbnail_format, properties
+        	                 metadata, thumbnail_format, properties, file_size
         	          FROM {$prefix}gallery_resources 
 			          WHERE album_id = '$albumId' AND date <= '$date' AND id < $id
 					  ORDER BY date DESC,id DESC LIMIT 1";
@@ -189,6 +189,7 @@
                                    $page = DEFAULT_PAGING_ENABLED, 
                                    $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
         {
+
 		$resources = Array();
 		$query = "SELECT id FROM ".$this->getPrefix()."gallery_resources WHERE "; 
 		if( $ownerId != -1 )
@@ -209,10 +210,10 @@
 		if( !$result )
 			return $resources;
 
-		while( $row = $result->FetchRow()) {
-			// use the primary key to retrieve the items via the cache
-			$resources[] = $resource = $this->get( "id", $row["id"], CACHE_RESOURCES );
-		}
+			while( $row = $result->FetchRow()) {
+				// use the primary key to retrieve the items via the cache
+				$resources[] = $resource = $this->get( "id", $row["id"], CACHE_RESOURCES );
+			}
 
             return $resources;
         }
@@ -310,6 +311,9 @@
 			$tf = new Textfilter();
 			$normalizedDescription = $tf->normalizeText( $description );
 			$properties = serialize( array() );
+			
+			// check if there already is a file with the same name stored
+			$duplicated = $this->isDuplicatedFileName( $fileName );
 
 			// finally put the query together and execute it
 			$query = "INSERT INTO ".$this->getPrefix()."gallery_resources(
@@ -335,13 +339,12 @@
 			// if that's the case, then we should rename the one we just
 			// added with some random prefix, to make it different from the
 			// other one...
-			if( $this->isDuplicatedFilename( $fileName )) {
+			if( $duplicated ) {
 				$query = "UPDATE ".$this->getPrefix()."gallery_resources
 						  SET file_name = '$resourceId-$fileName'
 						  WHERE id = $resourceId";
 
 				$this->Execute( $query );
-
 			}
 			
 			lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );			
@@ -447,10 +450,15 @@
       		
             // add the record to the database
             $fileName = $upload->getFileName();
+			$duplicated = $this->isDuplicatedFilename( $fileName );
 			$filePath = "";
 			$resourceId = $this->addResourceToDatabase( $ownerId, $albumId, $description, $flags, $resourceType, $filePath, $fileName, $info );
 			if( !$resourceId )
 				return false;
+								
+			if( $duplicated ) {
+				$upload->setFileName( $resourceId."-".$upload->getFileName());
+			}
 			
             // and finally move the file to the right place in disk
             // move the file to disk
@@ -563,7 +571,7 @@
 				if( isset( $metadata["jpg"] )) {
 					$info["jpg"]["exif"]["FILE"] = $metadata["jpg"]["exif"]["FILE"];
 					$info["jpg"]["exif"]["COMPUTED"] = $metadata["jpg"]["exif"]["COMPUTED"];
-					$info["jpg"]["exif"]["IFD0"] = $metadata["jpg"]["exif"]["IFD0"];
+					if(isset( $metadata["jpg"]["exif"]["IFD0"] )) $info["jpg"]["exif"]["IFD0"] = $metadata["jpg"]["exif"]["IFD0"];
 					$metadata["jpg"]["exif"]["EXIF"]["MakerNote"] = "";
 					$info["jpg"]["exif"]["EXIF"] = $metadata["jpg"]["exif"]["EXIF"];
 				}
@@ -819,11 +827,13 @@
             $result = $this->Execute( $query );
 
             $row = $result->FetchRow();
-            $result->Close();
-            if( $row["total"] == 0 || $row["total"] == 1 )
-            	return false;
+
+            if( $row["total"] == 0 )
+            	$result = false;
             else
-            	return true;
+            	$result = true;
+
+			return( $result );
         }
 		
 		/**
@@ -851,9 +861,10 @@
 										$row["thumbnail_format"],
 										unserialize($row["properties"]),
                                         $row["id"] );
+
 			$res->setFileSize( $row["file_size"] );
 
              return $res;
         }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/gallery/dao/galleryresourcestorage.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresourcestorage.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/gallery/dao/galleryresourcestorage.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -253,6 +253,7 @@
 //codes below are copy and modify from method storeFile
 			// first of all, check if the file is readable and if not, quit	
 			if( !File::isReadable($origFile)) {
+				print("dest file = ".$destFile." - orig file = ".$origFile."<br/>");
 				return false;
 			}
 
@@ -323,11 +324,8 @@
         {
         	if( $resource ) {
 				// first of all, remove the resource file itself
-        		$fileParts = explode( ".", $resource->getFileName());
-                $fileExt = $fileParts[count($fileParts)-1];
-                $fileName = $resource->getOwnerId()."-".$resource->getId().".".$fileExt;
                 $filePath = $this->getUserFolder( $resource->getOwnerId());
-				$fullName = $filePath.$fileName;
+				$fullName = $filePath.$resource->getFileName();
 
 				if( File::isReadable( $fullName)) {
 					$result = File::delete( $fullName );
@@ -362,12 +360,7 @@
 		 */
 		function getResourcePath( $resource )
 		{
-			$fileParts = explode( ".", $resource->getFileName());
-			$fileExt = $fileParts[count($fileParts)-1];		
-			$filePath = $this->getUserFolder( $resource->getOwnerId());
-			$fileName = $resource->getOwnerId()."-".$resource->getId().".".$fileExt;
-			
-			return $filePath.$fileName;
+			return( $this->getUserFolder( $resource->getOwnerId()).$resource->getFileName());
 		}
     }
 ?>

Modified: plog/trunk/class/gallery/resizers/gallerythumbnailgenerator.class.php
===================================================================
--- plog/trunk/class/gallery/resizers/gallerythumbnailgenerator.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/gallery/resizers/gallerythumbnailgenerator.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -28,7 +28,7 @@
 			$resizer = new GalleryResizer( $resFile );
 			lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );			
 			GalleryResourceStorage::checkPreviewsStorageFolder( $ownerId );
-			$outFile = GalleryResourceStorage::getPreviewsFolder( $ownerId ).$resFile;
+			$outFile = GalleryResourceStorage::getPreviewsFolder( $ownerId ).basename($resFile);
 			
 			// and finally, we can generate the preview!
 			$result = $resizer->generate( $outFile, $previewHeight, $previewWidth, $previewKeepAspectRatio );
@@ -61,7 +61,7 @@
 			$resizer = new GalleryResizer( $resFile );
 		    lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );			
 			GalleryResourceStorage::checkMediumSizePreviewsStorageFolder( $ownerId );
-			$outFile = GalleryResourceStorage::getMediumSizePreviewsFolder( $ownerId ).$resFile;
+			$outFile = GalleryResourceStorage::getMediumSizePreviewsFolder( $ownerId ).basename( $resFile );
 			
 			// and finally, we can generate the preview!
 			$result = $resizer->generate( $outFile, $previewWidth, $previewHeight, $previewKeepAspectRatio );
@@ -96,7 +96,7 @@
 			$resizer = new GalleryResizer( $resFile );
 		    lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );			
 			GalleryResourceStorage::checkUserStorageFolder( $ownerId );
-			$outFile = GalleryResourceStorage::getUserFolder( $ownerId ).$resFile;
+			$outFile = GalleryResourceStorage::getUserFolder( $ownerId ).basename( $resFile );
 			
 			// and finally, we can generate the preview!
 			$result = $resizer->generate( $outFile, $previewWidth, $previewHeight, $previewKeepAspectRatio );

Modified: plog/trunk/class/net/baserequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/baserequestgenerator.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/net/baserequestgenerator.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -483,35 +483,42 @@
         	throw( new Exception( "This function must be implemented by child classes." ));
         }
 
+
         /**
-         * Returns the link to a resource preview. Must be implemented by child classes to generate a valid URL.
+         * Returns the link to a resource preview
          *
          * @param album Generates the correct link to fetch a resource preview
          */
         function resourcePreviewLink( $resource )
         {
-        	throw( new Exception( "This function must be implemented by child classes." ));
+            $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());            
+			$resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/previews/".$resource->getFileName();            
+            return $resourceLink;
         }
-        
+		
         /**
-         * Returns the link to a resource preview. Must be implemented by child classes to generate a valid URL.
+         * Returns the link to a resource preview
          *
          * @param album Generates the correct link to fetch a resource preview
          */
         function resourceMediumSizePreviewLink( $resource )
         {
-	        throw( new Exception( "This function must be implemented by child classes." ));
+            $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());            
+			$resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/previews-med/".$resource->getFileName();
+            return $resourceLink;
 		}
 
         /**
-         * Returns the link to a resource. Must be implemented by child classes to generate a valid URL.
+         * Returns the link to a resource
          *
          * @param resource Generates the correct link to fetch a resource
          */
         function resourceDownloadLink( $resource )
         {
-	        throw( new Exception( "This function must be implemented by child classes." ));
-        }        
+            $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());            
+			$resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/".$resource->getFileName();
+            return $resourceLink;
+        }
 		
 		/**
 		 * whether we should generate valid xhtml requests or not

Modified: plog/trunk/class/net/customrequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/customrequestgenerator.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/net/customrequestgenerator.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -386,48 +386,6 @@
 			return $resourceLink;
         }
 
-        /**
-         * Returns the link to a resource preview
-         *
-         * @param album Generates the correct link to fetch a resource preview
-         */
-        function resourcePreviewLink( $resource )
-        {
-            $resourcePreviewFormat = $this->_config->getValue( "resource_preview_link_format" );
-			$params = $this->_fillResourceParameters( $resource );			
-			$resourcePreviewLink = $this->getBaseUrl().$this->_replaceTags( $resourcePreviewFormat, $params );
-			
-			return $resourcePreviewLink;
-        }
-		
-        /**
-         * Returns the link to a resource preview
-         *
-         * @param album Generates the correct link to fetch a resource preview
-         */
-        function resourceMediumSizePreviewLink( $resource )
-        {
-            $resourcePreviewFormat = $this->_config->getValue( "resource_medium_size_preview_link_format" );
-			$params = $this->_fillResourceParameters( $resource );			
-			$resourcePreviewLink = $this->getBaseUrl().$this->_replaceTags( $resourcePreviewFormat, $params );
-			
-			return $resourcePreviewLink;
-        }		
-		
-        /**
-         * Returns the link to a resource
-         *
-         * @param resource Generates the correct link to fetch a resource
-         */
-        function resourceDownloadLink( $resource )
-        {
-            $resourceDownloadFormat = $this->_config->getValue( "resource_download_link_format" );
-			$params = $this->_fillResourceParameters( $resource );
-			$resourceDownloadLink = $this->getBaseUrl().$this->_replaceTags( $resourceDownloadFormat, $params );
-			
-			return $resourceDownloadLink;
-        }
-		
 		/**
 		 * @private
 		 */

Modified: plog/trunk/class/net/prettyrequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/prettyrequestgenerator.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/net/prettyrequestgenerator.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -312,43 +312,6 @@
         }
 
         /**
-         * Returns the link to a resource preview
-         *
-         * @param album Generates the correct link to fetch a resource preview
-         */
-        function resourcePreviewLink( $resource )
-        {
-			$blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
-        	
-        	return $resourceLink = $this->getBaseUrl()."/resserver.php?blogId=".$blogId."&amp;resource=".rawurlencode($resource->getFileName())."&amp;mode=preview";
-        }
-		
-        /**
-         * Returns the link to a resource preview
-         *
-         * @param album Generates the correct link to fetch a resource preview
-         */
-        function resourceMediumSizePreviewLink( $resource )
-        {
-			$blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
-
-        	return $resourceLink = $this->getBaseUrl()."/resserver.php?blogId=".$blogId."&amp;resource=".rawurlencode($resource->getFileName())."&amp;mode=medium";
-        }		
-
-        /**
-         * Returns the link to a resource
-         *
-         * @param resource Generates the correct link to fetch a resource
-         */
-        function resourceDownloadLink( $resource )
-        {
-        	$blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
-        	
-        	return $resourceLink = $this->getBaseUrl()."/get/".$blogId."/".rawurlencode($resource->getFileName());
-        }
-
-
-        /**
          * Returns a string representing the request
          *
          * @return A String object representing the request

Modified: plog/trunk/class/net/rawrequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/rawrequestgenerator.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/net/rawrequestgenerator.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -379,59 +379,6 @@
         }
 
         /**
-         * Returns the link to a resource preview
-         *
-         * @param album Generates the correct link to fetch a resource preview
-         */
-        function resourcePreviewLink( $resource )
-        {
-            $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
-            
-            $this->addParameter( "blogId", $blogId);
-            $this->addParameter( "resource", $resource->getFileName());
-            $this->addParameter( "mode", "preview" );
-
-            $resourceLink = $this->getResourceServerUrl().$this->getRequest( false );
-            
-            return $resourceLink;
-        }
-		
-        /**
-         * Returns the link to a resource preview
-         *
-         * @param album Generates the correct link to fetch a resource preview
-         */
-        function resourceMediumSizePreviewLink( $resource )
-        {
-            $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
-            
-            $this->addParameter( "blogId", $blogId);
-            $this->addParameter( "resource", $resource->getFileName());
-            $this->addParameter( "mode", "medium" );
-
-            $resourceLink = $this->getResourceServerUrl().$this->getRequest( false );
-
-            return $resourceLink;
-		}
-
-        /**
-         * Returns the link to a resource
-         *
-         * @param resource Generates the correct link to fetch a resource
-         */
-        function resourceDownloadLink( $resource )
-        {
-            $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());
-            
-            $this->addParameter( "blogId", $blogId);
-            $this->addParameter( "resource", $resource->getFileName());
-
-            $resourceLink = $this->getResourceServerUrl().$this->getRequest( false );
-
-            return $resourceLink;
-        }
-
-        /**
          * Returns a string representing the request
          *
          * @return A String object representing the request

Modified: plog/trunk/class/view/redirectview.class.php
===================================================================
--- plog/trunk/class/view/redirectview.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/view/redirectview.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -1,5 +1,7 @@
 <?php
 
+	include_once( PLOG_CLASS_PATH."class/view/view.class.php" );
+
     /**
      * This view returns no content, it just sends a
      * "Location:" header to the browser so that the browser itself takes care

Deleted: plog/trunk/class/view/resourceserverview.class.php
===================================================================
--- plog/trunk/class/view/resourceserverview.class.php	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/class/view/resourceserverview.class.php	2006-12-17 17:28:19 UTC (rev 4392)
@@ -1,108 +0,0 @@
-<?php
-
-	lt_include( PLOG_CLASS_PATH.'class/view/view.class.php' );
-
-	// the three different modes that a resource can be requested
-	define( 'RESOURCE_VIEW_MODE_DEFAULT', '' );
-	define( 'RESOURCE_VIEW_MODE_PREVIEW', 'preview' );
-	define( 'RESOURCE_VIEW_MODE_MEDIUM', 'medium' );
-    define( 'DEFAULT_HTTP_CACHE_LIFETIME', '86400');
-    define( 'RESOURCE_DEFAULT_CHUNK_SIZE', '32768' );
-
-    /**
-     * \ingroup View
-     * @private
-     */	
-	class ResourceServerView extends View
-	{
-	
-		var $_resource;
-		var $_mode;
-	
-		function ResourceServerView( $resource = null, $mode = RESOURCE_VIEW_MODE_DEFAULT )
-		{
-			$this->View();
-			
-			$this->_resource = $resource;
-			$this->_mode = $mode;
-			
-			if( $this->_resource != null )
-				$this->_initResponse();
-		}
-		
-		/**
-		 * @private
-		 * Initializes the mime type needed for this resource and the headers, if any is needed
-		 */
-		function _initResponse()
-		{
-			$this->addHeaderResponse( 'Pragma: public' );
-			$this->addHeaderResponse( 'Accept-Ranges: bytes' );
-			$this->addHeaderResponse( 'Content-Disposition: inline; filename='.rawurlencode($this->_resource->getFileName()));
-
-			// depending on what we're sending, the content of the headers will vary...
-			if( $this->_mode == RESOURCE_VIEW_MODE_PREVIEW )
-				$this->addHeaderResponse( 'Content-Type: '.$this->_resource->getThumbnailMimeType());
-			elseif( $this->_mode == RESOURCE_VIEW_MODE_MEDIUM )
-				$this->addHeaderResponse( 'Content-Type: '.$this->_resource->getThumbnailMimeType());
-			else {
-				$data = $this->_resource->getMetadataReader();
-				$this->addHeaderResponse( 'Content-Type: '.$this->_resource->getMimeType());
-				$this->addHeaderResponse( 'Content-Length: '.$data->getFileSize());
-			}				
-			
-			return true;
-		}
-		
-		/**
-		 * we need to overwrite this method or else the View class will be sending the wrong
-		 * content type and character encoding... We overwrite it to do nothing, since we have
-		 * already sent the content type in _initResponse()
-		 *
-		 * @see View::sendContentType()		  
-		 */
-		function sendContentType()
-		{
-			return( true );	
-		}		
-		
-		function render()
-		{
-			// call the render method in the main view class... it will take care of sending the headers
-			// for us and so on...
-			parent::render();
-			
-			// if there is no resource to send... then we can quit right away!
-			if( $this->_resource == null )
-				return;
-			
-			// let's see if we really need to send some data or not...
-			// send also some headers that will help caching, if configured to do so
-			$config =& Config::getConfig();
-			$useCaching = $config->getValue( 'resource_server_http_cache_enabled' );
-			if( $useCaching ) {
-				// send the "Last-Modified" header
-				$resDate = $this->_resource->getTimestamp();
-				$lastModified = $resDate->getDate( DATE_FORMAT_UNIXTIME );
-				$cacheLifetime = $config->getValue( 'resource_server_http_cache_lifetime', DEFAULT_HTTP_CACHE_LIFETIME );
-				
-				// check if we have to resent the data and if not, then we're done!
-				lt_include( PLOG_CLASS_PATH.'class/net/http/httpcache.class.php' );				
-				if( HttpCache::httpConditional( $lastModified, $cacheLifetime ))
-					exit();
-			}
-			
-			// if we need to send something, then let's do it now and finish
-			if( $this->_mode == RESOURCE_VIEW_MODE_PREVIEW )
-				print( $this->_resource->getPreview());
-			elseif( $this->_mode == RESOURCE_VIEW_MODE_MEDIUM )
-				print( $this->_resource->getMediumSizePreview());
-			else {
-				while($chunk =& $this->_resource->getDataChunk( RESOURCE_DEFAULT_CHUNK_SIZE ))
-					echo( $chunk );				
-			}
-			
-			return true;
-		}
-	}
-?>
\ No newline at end of file

Modified: plog/trunk/templates/admin/globalsettings_url.template
===================================================================
--- plog/trunk/templates/admin/globalsettings_url.template	2006-12-16 18:11:49 UTC (rev 4391)
+++ plog/trunk/templates/admin/globalsettings_url.template	2006-12-17 17:28:19 UTC (rev 4392)
@@ -81,19 +81,19 @@
    <div class="field">
     <label for="config[resource_preview_link_format]">resource_preview_link_format</label>
     <div class="formHelp">{$locale->tr("help_resource_preview_link_format")}</div>	
-    <input style="width:100%" type="text" id="config[resource_preview_link_format]" name="config[resource_preview_link_format]" value="{$resource_preview_link_format}"/>
+    <input disabled="disabled" style="width:100%" type="text" id="config[resource_preview_link_format]" name="config[resource_preview_link_format]" value="{$resource_preview_link_format}"/>
    </div>
    <!-- resource_preview_link_format -->
    <div class="field">
     <label for="config[resource_medium_size_preview_link_format]">resource_medium_size_preview_link_format</label>
     <div class="formHelp">{$locale->tr("help_resource_medium_size_preview_link_format")}</div>	
-    <input style="width:100%" type="text" id="config[resource_medium_size_preview_link_format]" name="config[resource_medium_size_preview_link_format]" value="{$resource_medium_size_preview_link_format}"/>    
+    <input disabled="disabled" style="width:100%" type="text" id="config[resource_medium_size_preview_link_format]" name="config[resource_medium_size_preview_link_format]" value="{$resource_medium_size_preview_link_format}"/>    
    </div>   
    <!-- resource_download_link_format -->
    <div class="field">
     <label for="config[resource_download_link_format]">resource_download_link_format</label>
     <div class="formHelp">{$locale->tr("help_resource_download_link_format")}</div>	
-    <input style="width:100%" type="text" id="config[resource_download_link_format]" name="config[resource_download_link_format]" value="{$resource_download_link_format}"/>
+    <input disabled="disabled" style="width:100%" type="text" id="config[resource_download_link_format]" name="config[resource_download_link_format]" value="{$resource_download_link_format}"/>
    </div>
    <!-- page_suffix_format -->
    <div class="field">



More information about the pLog-svn mailing list