[pLog-svn] r4385 - in plog/branches/lifetype-1.2-resource-test: class/action class/file class/gallery/dao class/gallery/resizers class/net class/view templates/admin

Jon Daley plogworld at jon.limedaley.com
Tue Dec 12 01:56:16 GMT 2006


 	It appears to have worked on my system, but my terminal program 
doesn't know how to display the filename.
Can you see it here:
http://jon.limedaley.com/test/

All I see are '?'s but when tab completing, they are completed as 
different characters, and not all the same.

On Tue, 12 Dec 2006, Oscar Renalias wrote:

> Hmmm... It might be an OS X problem when using the HFS+ filesystem.
>
> Can anybody try the following script?
>
> <?php
> 	copy( "./newfile.txt", "./tmp/áéíóú.txt" );
> ?>
>
> Create a file called "newfile.txt" with whatever contents, place the script 
> above in the LT root folder (for example), run it, and check whether the file 
> tmp/áéíóú.txt exists or you got an error like "Warning: copy(./tmp/áéíóú.txt) 
> [function.copy]: failed to open stream: Invalid argument". I just tried in a 
> Linux system and it seemed to work, but not in OS X.
>
> On 12 Dec 2006, at 00:44, Oscar Renalias wrote:
>
>> I think merging this into a 1.1.x should be pretty straightforward, as all 
>> the changes are pretty much self-contained.
>> 
>> Just bear in mind the issue I'm currently having with file names that use 
>> non-latin characters such as umlauts and accent, as they are not working. 
>> For what it's worth, they don't work at wordpress.com either using their 
>> upload system (not that it makes me happy that they are having problems 
>> too, but at least we're not the only ones...)
>> 
>> On 12 Dec 2006, at 00:40, Jon Daley wrote:
>>
>>> 	That sounds good.  What do you think the chances are of this patch 
>>> applying correctly to a 1.1.3 install?
>>> 
>>> On Mon, 11 Dec 2006, oscar at devel.lifetype.net wrote:
>>> 
>>>> Author: oscar
>>>> Date: 2006-12-11 21:52:47 +0000 (Mon, 11 Dec 2006)
>>>> New Revision: 4385
>>>> 
>>>> Removed:
>>>>  plog/branches/lifetype-1.2-resource-test/class/view/resourceserverview.class.php
>>>> Modified:
>>>>  plog/branches/lifetype-1.2-resource-test/class/action/resourceserveraction.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/file/fileupload.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresource.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresources.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresourcestorage.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/gallery/resizers/gallerythumbnailgenerator.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/net/baserequestgenerator.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/net/customrequestgenerator.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/net/prettyrequestgenerator.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/net/rawrequestgenerator.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/class/view/redirectview.class.php
>>>>  plog/branches/lifetype-1.2-resource-test/templates/admin/globalsettings_url.template
>>>> Log:
>>>> Just finished implementing experimental support for resources, so that 
>>>> files are now uploaded with their "real" name to the gallery/X/ folder 
>>>> and accessed directly via the resource server.
>>>> 
>>>> URLs to files and previews now look like 
>>>> http://www.host.com/gallery/X/file.jpg, 
>>>> http://www.host.com/gallery/X/preview/file.jpg and so on. Albums remain 
>>>> for organizational purposes but their structure is not mapped to folders 
>>>> in disk.
>>>> 
>>>> Backward compatibility with older URLs is achieved by means of an HTTP 
>>>> redirect from for example resserver.php?blogId=1&resource=file.jpg to the 
>>>> new URL format. This should ensure a smooth transition from the old 
>>>> system to the new one as long as things like resource_download_link are 
>>>> not modified (they are marked as non-editable in "general 
>>>> settings"->"URL")
>>>> 
>>>> This feature needs a bit more testing specially regarding files with 
>>>> non-latin characters, but otherwise it works pretty well. Letting the web 
>>>> server serve these files is obviously a lot faster than doing it via 
>>>> resserver.php, so this should eliminate all the complaints regarding 
>>>> resserver's hunger for server resources... I'd like to hear your opinion, 
>>>> specially from those of you running bigger servers.
>>>> 
>>>> 
>>>> Modified: 
>>>> plog/branches/lifetype-1.2-resource-test/class/action/resourceserveraction.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/action/resourceserveraction.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/action/resourceserveraction.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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/branches/lifetype-1.2-resource-test/class/file/fileupload.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/file/fileupload.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/file/fileupload.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -41,6 +41,11 @@
>>>>        	return $this->_name;
>>>>        }
>>>> 
>>>> +		function setFileName( $fileName )
>>>> +		{
>>>> +			$this->_name = $fileName;
>>>> +		}
>>>> +
>>>> 		/**
>>>> 		 * returns the MIME type of the file
>>>> 		 *
>>>> 
>>>> Modified: 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresource.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresource.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresource.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -33,6 +33,7 @@
>>>>        var $_album;
>>>> 		var $_thumbnailFormat;
>>>> 		var $_fileDescriptor;
>>>> +		var $_fileSize;
>>>>
>>>> 		/**
>>>> 		 * Constructor.
>>>> @@ -70,6 +71,7 @@
>>>>            $this->_resourceType = $resourceType;
>>>>            $this->_filePath = $filePath;
>>>>            $this->_fileName = $fileName;
>>>> +			$this->_fileSize = 0;
>>>>            $this->_metadata = $metadata;
>>>>            $this->_date = $date;
>>>> 			$this->_thumbnailFormat = $thumbnailFormat;
>>>> @@ -239,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
>>>> @@ -368,9 +308,13 @@
>>>> 		 */
>>>> 		function getFileSize()
>>>> 		{
>>>> -			$reader = $this->getMetadataReader();
>>>> -			return $reader->getFileSize();
>>>> +			return( $this->_fileSize );
>>>> 		}
>>>> +
>>>> +		function setFileSize( $size )
>>>> +		{
>>>> +			$this->_fileSize = $size;
>>>> +		}
>>>>
>>>> 		/**
>>>> 		 * returns an object that will allow to access the metadata 
>>>> of this resource
>>>> @@ -430,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
>>>> 		 *
>>>> @@ -470,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/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresources.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresources.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresources.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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,23 +189,23 @@
>>>>                                   $page = DEFAULT_PAGING_ENABLED,
>>>>                                   $itemsPerPage = DEFAULT_ITEMS_PER_PAGE 
>>>> )
>>>>        {
>>>> -		$resources = Array();
>>>> -		$query = "SELECT id FROM 
>>>> ".$this->getPrefix()."gallery_resources WHERE owner_id = 
>>>> '".Db::qstr($ownerId)."'";
>>>> -		if( $albumId != GALLERY_NO_ALBUM )
>>>> -			$query .= " AND album_id = '".Db::qstr($albumId)."'";
>>>> -		if( $resourceType != GALLERY_RESOURCE_ANY )
>>>> -			$query .= " AND resource_type = 
>>>> '".Db::qstr($resourceType)."'";
>>>> -		if( $searchTerms != "" )
>>>> -			$query .= " AND (".$this->getSearchConditions( 
>>>> $searchTerms ).")";
>>>> +			$resources = Array();
>>>> +			$query = "SELECT id FROM 
>>>> ".$this->getPrefix()."gallery_resources WHERE owner_id = 
>>>> '".Db::qstr($ownerId)."'";
>>>> +			if( $albumId != GALLERY_NO_ALBUM )
>>>> +				$query .= " AND album_id = 
>>>> '".Db::qstr($albumId)."'";
>>>> +			if( $resourceType != GALLERY_RESOURCE_ANY )
>>>> +				$query .= " AND resource_type = 
>>>> '".Db::qstr($resourceType)."'";
>>>> +			if( $searchTerms != "" )
>>>> +				$query .= " AND 
>>>> (".$this->getSearchConditions( $searchTerms ).")";
>>>> 
>>>> -		$result = $this->Execute( $query, $page, $itemsPerPage );
>>>> -		if( !$result )
>>>> -			return $resources;
>>>> +			$result = $this->Execute( $query, $page, 
>>>> $itemsPerPage );
>>>> +			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;
>>>>        }
>>>> @@ -303,6 +303,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(
>>>> @@ -328,13 +331,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" );
>>>> @@ -427,8 +429,8 @@
>>>>            $getId3 = new GetID3();
>>>>            $metadata = $getId3->analyze( $upload->getTmpName());
>>>>            // nifty helper method from the getid3 package
>>>> -            getid3_lib::CopyTagsToComments($metadata);
>>>> -
>>>> +            getid3_lib::CopyTagsToComments($metadata);
>>>> +
>>>>            $resourceType = $this->_getResourceType( 
>>>> $upload->getFileName(), $metadata );
>>>>
>>>>            // set the flags
>>>> @@ -440,10 +442,17 @@
>>>>
>>>>            // add the record to the database
>>>>            $fileName = $upload->getFileName();
>>>> +			print("file name = $fileName<br/>" );
>>>> +			$duplicated = $this->isDuplicatedFilename( $fileName 
>>>> );
>>>> 			$filePath = "";
>>>> 			$resourceId = $this->addResourceToDatabase( $ownerId, 
>>>> $albumId, $description, $flags, $resourceType, $filePath, $fileName, 
>>>> $info );
>>>> 			if( !$resourceId )
>>>> 				return false;
>>>> +
>>>> +			if( $duplicated ) {
>>>> +				print("duplicated!!!<br/>");
>>>> +				$upload->setFileName( 
>>>> $resourceId."-".$upload->getFileName());
>>>> +			}
>>>>
>>>>            // and finally move the file to the right place in disk
>>>>            // move the file to disk
>>>> @@ -467,7 +476,7 @@
>>>>            	lt_include( 
>>>> PLOG_CLASS_PATH."class/gallery/resizers/gallerythumbnailgenerator.class.php" 
>>>> );
>>>>
>>>> 				lt_include( 
>>>> PLOG_CLASS_PATH."class/config/config.class.php" );
>>>> -				$config =& Config::getConfig();
>>>> +				$config =& Config::getConfig();
>>>>
>>>>            	$imgWidth = $info["video"]["resolution_x"];
>>>>            	$imgHeight = $info["video"]["resolution_y"];
>>>> @@ -556,7 +565,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"];
>>>> 				}
>>>> @@ -809,14 +818,22 @@
>>>>        	$query = "SELECT COUNT(id) AS total FROM 
>>>> ".$this->getPrefix()."gallery_resources
>>>>                      WHERE file_name = '$fileName'";
>>>> 
>>>> +			print($query."<br/>");
>>>> +
>>>>            $result = $this->Execute( $query );
>>>>
>>>>            $row = $result->FetchRow();
>>>> -            $result->Close();
>>>> -            if( $row["total"] == 0 || $row["total"] == 1 )
>>>> -            	return false;
>>>> +
>>>> +			print_r($row);
>>>> +
>>>> +            if( $row["total"] == 0 )
>>>> +            	$result = false;
>>>>            else
>>>> -            	return true;
>>>> +            	$result = true;
>>>> +
>>>> +			$result == true ? print("duplicated<br/>") : 
>>>> print("not duplicated<br/>");
>>>> +
>>>> +			return( $result );
>>>>        }
>>>>
>>>> 		/**
>>>> @@ -844,6 +861,7 @@
>>>> 										$row["thumbnail_format"],
>>>> 										unserialize($row["properties"]),
>>>>                                        $row["id"] );
>>>> + 
>>>> $res->setFileSize( $row["file_size"] );
>>>>
>>>>             return $res;
>>>>        }
>>>> 
>>>> Modified: 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresourcestorage.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresourcestorage.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/dao/galleryresourcestorage.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -225,9 +225,6 @@
>>>> 				return false;
>>>>
>>>>            // new name for the file
>>>> -            $fileParts = explode( ".", $upload->getFileName());
>>>> -            $fileExt = $fileParts[count($fileParts)-1];
>>>> -            $fileName = "$ownerId-$resourceId.$fileExt";
>>>>            $filePath = $this->getUserFolder( $ownerId );
>>>>
>>>>            // move the file to the temporaray folder first
>>>> @@ -248,11 +245,15 @@
>>>> 			//do not use storeFile method because I have change 
>>>> filename in $tmpFolder.
>>>> 			//$destFile = $this->storeFile( $resourceId, 
>>>> $ownerId, $origFile, RESOURCE_STORAGE_STORE_MOVE );
>>>> 			//$destFile use $filePath and $fileName generated 
>>>> above.
>>>> -			$destFile = $filePath.$fileName;
>>>> +
>>>> +			//$destFile = $filePath.$fileName;
>>>> +			$destFile = $filePath.$upload->getFileName();
>>>> +
>>>> //=========================================
>>>> //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/branches/lifetype-1.2-resource-test/class/gallery/resizers/gallerythumbnailgenerator.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/resizers/gallerythumbnailgenerator.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/gallery/resizers/gallerythumbnailgenerator.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -23,18 +23,14 @@
>>>> 			$config =& Config::getConfig();
>>>> 			$previewKeepAspectRatio = $config->getValue( 
>>>> "thumbnails_keep_aspect_ratio" );
>>>> 
>>>> -			// get the file extension
>>>> -			$fileParts = explode( ".", $resFile );
>>>> -			$fileExt = 
>>>> strtolower($fileParts[count($fileParts)-1]);
>>>> -			$fileName = $ownerId."-".$resourceId.".".$fileExt;
>>>> -
>>>> 			// and start the resizing process
>>>> 			lt_include( 
>>>> PLOG_CLASS_PATH."class/gallery/resizers/galleryresizer.class.php" );
>>>> 			$resizer = new GalleryResizer( $resFile );
>>>> 			lt_include( 
>>>> PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );
>>>> 			GalleryResourceStorage::checkPreviewsStorageFolder( 
>>>> $ownerId );
>>>> -			$outFile = GalleryResourceStorage::getPreviewsFolder( 
>>>> $ownerId ).$fileName;
>>>> 
>>>> +			$outFile = GalleryResourceStorage::getPreviewsFolder( 
>>>> $ownerId ).basename($resFile);
>>>> +
>>>> 			// and finally, we can generate the preview!
>>>> 			$result = $resizer->generate( $outFile, 
>>>> $previewHeight, $previewWidth, $previewKeepAspectRatio );
>>>> 
>>>> @@ -61,17 +57,12 @@
>>>> 			$config =& Config::getConfig();
>>>> 			$previewKeepAspectRatio = $config->getValue( 
>>>> "thumbnails_keep_aspect_ratio" );
>>>> 
>>>> -			// get the file extension
>>>> -			$fileParts = explode( ".", $resFile );
>>>> -			$fileExt = 
>>>> strtolower($fileParts[count($fileParts)-1]);
>>>> -			$fileName = $ownerId."-".$resourceId.".".$fileExt;
>>>> -
>>>> 			// and start the resizing process
>>>> 		    lt_include( 
>>>> PLOG_CLASS_PATH."class/gallery/resizers/galleryresizer.class.php" );
>>>> 			$resizer = new GalleryResizer( $resFile );
>>>> 		    lt_include( 
>>>> PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );
>>>> 			GalleryResourceStorage::checkMediumSizePreviewsStorageFolder( 
>>>> $ownerId );
>>>> -			$outFile = 
>>>> GalleryResourceStorage::getMediumSizePreviewsFolder( $ownerId 
>>>> ).$fileName;
>>>> +			$outFile = 
>>>> GalleryResourceStorage::getMediumSizePreviewsFolder( $ownerId ).basename( 
>>>> $resFile );
>>>>
>>>> 			// and finally, we can generate the preview!
>>>> 			$result = $resizer->generate( $outFile, 
>>>> $previewWidth, $previewHeight, $previewKeepAspectRatio );
>>>> @@ -100,18 +91,13 @@
>>>> 			lt_include( 
>>>> PLOG_CLASS_PATH."class/config/config.class.php" );
>>>> 			$config =& Config::getConfig();
>>>> 			$previewKeepAspectRatio = $config->getValue( 
>>>> "thumbnails_keep_aspect_ratio" );
>>>> -
>>>> -			// get the file extension
>>>> -			$fileParts = explode( ".", $resFile );
>>>> -			$fileExt = $fileParts[count($fileParts)-1];
>>>> -			$fileName = $ownerId."-".$resourceId.".".$fileExt;
>>>> -
>>>> +
>>>> 			// and start the resizing process
>>>> 		    lt_include( 
>>>> PLOG_CLASS_PATH."class/gallery/resizers/galleryresizer.class.php" );
>>>> 			$resizer = new GalleryResizer( $resFile );
>>>> 		    lt_include( 
>>>> PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );
>>>> 			GalleryResourceStorage::checkUserStorageFolder( 
>>>> $ownerId );
>>>> -			$outFile = GalleryResourceStorage::getUserFolder( 
>>>> $ownerId ).$fileName;
>>>> +			$outFile = GalleryResourceStorage::getUserFolder( 
>>>> $ownerId ).basename( $resFile );
>>>>
>>>> 			// and finally, we can generate the preview!
>>>> 			$result = $resizer->generate( $outFile, 
>>>> $previewWidth, $previewHeight, $previewKeepAspectRatio );
>>>> 
>>>> Modified: 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/baserequestgenerator.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/baserequestgenerator.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/baserequestgenerator.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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/branches/lifetype-1.2-resource-test/class/net/customrequestgenerator.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/customrequestgenerator.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/customrequestgenerator.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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/branches/lifetype-1.2-resource-test/class/net/prettyrequestgenerator.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/prettyrequestgenerator.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/prettyrequestgenerator.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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/branches/lifetype-1.2-resource-test/class/net/rawrequestgenerator.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/rawrequestgenerator.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/net/rawrequestgenerator.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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/branches/lifetype-1.2-resource-test/class/view/redirectview.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/view/redirectview.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/view/redirectview.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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/branches/lifetype-1.2-resource-test/class/view/resourceserverview.class.php
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/class/view/resourceserverview.class.php 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/class/view/resourceserverview.class.php 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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/branches/lifetype-1.2-resource-test/templates/admin/globalsettings_url.template
>>>> ===================================================================
>>>> --- 
>>>> plog/branches/lifetype-1.2-resource-test/templates/admin/globalsettings_url.template 
>>>> 2006-12-11 21:50:45 UTC (rev 4384)
>>>> +++ 
>>>> plog/branches/lifetype-1.2-resource-test/templates/admin/globalsettings_url.template 
>>>> 2006-12-11 21:52:47 UTC (rev 4385)
>>>> @@ -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">
>>>> 
>>>> _______________________________________________
>>>> pLog-svn mailing list
>>>> pLog-svn at devel.lifetype.net
>>>> http://devel.lifetype.net/mailman/listinfo/plog-svn
>>>> 
>>> 
>>> -- 
>>> Jon Daley
>>> http://jon.limedaley.com/
>>> 
>>> The shortest distance between two points is under construction.
>>> -- Altito
>>> _______________________________________________
>>> pLog-svn mailing list
>>> pLog-svn at devel.lifetype.net
>>> http://devel.lifetype.net/mailman/listinfo/plog-svn
>>> 
>> 
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://devel.lifetype.net/mailman/listinfo/plog-svn
>> 
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn

-- 
Jon Daley
http://jon.limedaley.com/

Sympathy is never wasted except when you give it to yourself.
-- John W. Draper


More information about the pLog-svn mailing list