[pLog-svn] r5194 - plog/branches/lifetype-1.2/class/net

oscar at devel.lifetype.net oscar at devel.lifetype.net
Mon Mar 26 16:12:00 EDT 2007


Author: oscar
Date: 2007-03-26 16:12:00 -0400 (Mon, 26 Mar 2007)
New Revision: 5194

Modified:
   plog/branches/lifetype-1.2/class/net/baserequestgenerator.class.php
Log:
Fix for issue 1215 (http://bugs.lifetype.net/view.php?id=1215) -- /gallery/ is hardcoded in the path to resource files, but now links to resources are generated based on the value of the resources_folder parameter.

Modified: plog/branches/lifetype-1.2/class/net/baserequestgenerator.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/net/baserequestgenerator.class.php	2007-03-26 15:43:17 UTC (rev 5193)
+++ plog/branches/lifetype-1.2/class/net/baserequestgenerator.class.php	2007-03-26 20:12:00 UTC (rev 5194)
@@ -11,7 +11,12 @@
     
     define( "DEFAULT_SCRIPT_NAME", "index.php" );
 
+	/**
+	 * Default folder where resources are installed
+	 */
+	define( "DEFAULT_GALLERY_RESOURCES_FOLDER", "./gallery/" );
 
+
     /**
      * \ingroup Net
      *
@@ -205,6 +210,25 @@
             return $url;
         }
 
+		/**
+		 * Returns the base URL to resources
+		 */
+		function getResourcesBaseUrl()
+		{
+			lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
+			$config =& Config::getConfig();
+			// the default value for this setting is to use a relative path that starts with './' so we have to make sure that
+			// that bit is not included in the URL (it wouldn't have any harmful effect, but it'd look ugly)
+			$galleryFolder = str_replace( "./", "/", $config->getValue( "resources_folder", DEFAULT_GALLERY_RESOURCES_FOLDER ));
+			// make sure that the base URL ends with a forward slash
+			if( $galleryFolder[strlen($galleryFolder)-1] != "/" )
+				$galleryFolder .= "/";
+			
+			$url = $this->getBaseUrl().$galleryFolder;
+			
+			return( $url );
+		}
+
         /** 
          * @return Returns the URL pointing to the given parameter. This URL is built by querying the current
          * base URL and then appending the value of the $res parameter
@@ -481,7 +505,6 @@
         	throw( new Exception( "This function must be implemented by child classes." ));
         }
 
-
         /**
          * Returns the link to a resource preview
          *
@@ -490,7 +513,7 @@
         function resourcePreviewLink( $resource )
         {
             $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());            
-			$resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/previews/".rawurlencode($resource->getPreviewFileName());            
+			$resourceLink = $this->getResourcesBaseUrl().$blogId."/previews/".rawurlencode($resource->getPreviewFileName());            
             return $resourceLink;
         }
 		
@@ -502,7 +525,7 @@
         function resourceMediumSizePreviewLink( $resource )
         {
             $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());            
-			$resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/previews-med/".rawurlencode($resource->getMediumSizePreviewFileName());
+			$resourceLink = $this->getResourcesBaseUrl().$blogId."/previews-med/".rawurlencode($resource->getMediumSizePreviewFileName());
             return $resourceLink;
 		}
 
@@ -514,7 +537,7 @@
         function resourceDownloadLink( $resource )
         {
             $blogId = ($resource->getOwnerId() ? $resource->getOwnerId() : $this->_blogInfo->getId());            
-			$resourceLink = $this->getBaseUrl()."/gallery/".$blogId."/".rawurlencode($resource->getFileName());
+			$resourceLink = $this->getResourcesBaseUrl().$blogId."/".rawurlencode($resource->getFileName());
             return $resourceLink;
         }
 		



More information about the pLog-svn mailing list