CMS MADE SIMPLE FORGE

Gallery

 

[#7081] use $config vars instead of hardcoded pathes

avatar
Created By: Georg Busch (nan)
Date Submitted: 2011-11-02 17:18

Assigned To: Jos (josvd)
Resolution: None
State: Open
Summary:
use $config vars instead of hardcoded pathes
Detailed Description:
Hello Jos,

in Gallery.module.php constants are defined:

define('DEFAULT_GALLERY_PATH', "uploads/images/Gallery/");
define('DEFAULT_GALLERYTHUMBS_PATH', "uploads/images/GalleryThumbs/");

I think this is wrong, since the uploads dir is not always named "uploads".
IMHO This would be the better way:

$config = cmsms()->GetConfig();
define('DEFAULT_GALLERY_PATH', $config['image_uploads_path'] . "/Gallery/");
define('DEFAULT_GALLERYTHUMBS_PATH', $config['image_uploads_path'] .
"/GalleryThumbs/");

But therefore you also need 

define('DEFAULT_GALLERY_URL', $config['image_uploads_url'] . "/Gallery/");
define('DEFAULT_GALLERYTHUMBS_URL', $config['image_uploads_url'] .
"/GalleryThumbs/");

because you don't differentiate between URL and PATH. But both may differ.
So when images are displayed use the the URL.
When looking for files at the server use the PATH.

I ran into this issue when creating an xajax-Plugin for frontend that excutes
modules from the plugins dir.
The Gallery module tells me that my Galleries don't exists (wich is wrong). But
obviously it is looking for /plugins/uploads/images/Gallery/ (wich indeed does
not exists). This could be avoided if you use absolue pathes and urls from the
config file.

Just my two cents.
Kind regards
NaN

History

Comments
avatar
Date: 2013-05-25 18:26
Posted By: Richard (greatscottpc)

I second this motion....   I was just installing the Gallery Module and had
already specified different directory for uploads.   The install faile and so I
had to change the hardcoding to even install module....  Please use $config
values....

Thanks,