CMS MADE SIMPLE FORGE

Gallery

 

[#7743] Gallery does not work with pretty urls / mod_rewrite

avatar
Created By: Georg Wallisch (alcibiades)
Date Submitted: Mon Mar 26 12:33:30 -0400 2012

Assigned To: Jos (josvd)
Version: 1.5.3
CMSMS Version: None
Severity: None
Resolution: Awaiting Response
State: Closed
Summary:
Gallery does not work with pretty urls / mod_rewrite
Detailed Description:
Hi Jos,

I found that Gallery doesn't show images when using pretty urls (internal or
mod_rewrite) because Gallery mixes up paths and URLs. (and also ignores the
paths and URLs from config as described in feature request #7081).

As a solution I introduced a couple of new class functions to Gallery_utils,
which build a full path or URL from a given relative path and the config data.

	public static $galleryPath = null;
	public static $galleryURL = null;
	public static $galleryThumbPath = null;
	public static $galleryThumbURL = null;
	public static $galleryPathSetup = null;
	
	public static function GetGalleryPath($path = '')
	{
		self::SetupGalleryPath();	
		return self::$galleryPath.'/'.$path;
	}
	
	public static function GetGalleryURL($path = '')
	{
		self::SetupGalleryPath();	
		return self::$galleryURL.'/'.$path;
	}
	
	public static function GetGalleryThumbPath($path = '')
	{
		self::SetupGalleryPath();	
		return self::$galleryThumbPath.'/'.$path;
	}	
	
	public static function GetGalleryThumbURL($path = '')
	{
		self::SetupGalleryPath();	
		return self::$galleryThumbURL.'/'.$path;
	}
	
	public static function SetupGalleryPath()
	{
		if(!is_null(self::$galleryPathSetup)) {
			return;
		}
		
		global $gCms;
		$config = &$gCms->GetConfig();
		
self::$galleryPath =
realpath($config['image_uploads_path'].'/'.DEFAULT_GALLERY);
		self::$galleryURL = $config['image_uploads_url'].'/'.DEFAULT_GALLERY;
self::$galleryThumbPath =
realpath($config['image_uploads_path'].'/'.DEFAULT_GALLERYTHUMBS);
self::$galleryThumbURL =
$config['image_uploads_url'].'/'.DEFAULT_GALLERYTHUMBS;
		
		self::$galleryPathSetup = true;
	}

Therefore two new constants are defined in the main module file additionally:

define('DEFAULT_GALLERY', "Gallery");
define('DEFAULT_GALLERYTHUMBS', "GalleryThumbs");

Now I modified action.default and sort out, where a path or a URL was needed.
All other methods and files need be changed too. But for now Gallery works with
pretty urls.

Finally the templates needed to be adjusted:
- Removed escaping of slashes by smarty.
- Added a preceding slash to javascript urls.

Do you want me to commit the changed action.default?




History

Comments
avatar
Date: 2012-04-19 13:45
Posted By: Ronny Krijt (ronnyk)

Check if your template has 

<base href="{root_url}" />

inside the <head> area. That might help to determine the basepath
automatically...
      
Updates

Updated: 2014-08-08 14:34
cmsms_version_id: 29495 => -1
state: Open => Closed

Updated: 2012-05-31 23:34
resolution_id: => 10
severity_id: 2 => 12