Irmtfan, I don't use this kind of scheme as you suggest in xoops_version.php:
$modversion['icons16'] = 'Frameworks/moduleclasses/icons/16';
$modversion['icons32'] = 'Frameworks/moduleclasses/icons/32';
because it results later on in code that is harder to read:
$pathIcon32 = $module->getInfo('icons32');
$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/home.png';
I prefer to avoid the extra slashes in the code:
Quote:
$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/home.png';
I prefer to define the path only once, but with the correct location,
$modversion['icons16'] = '../../Frameworks/moduleclasses/icons/16';
$modversion['icons32'] = '../../Frameworks/moduleclasses/icons/32';
so later on I don't have to deal with extra "/":
$pathIcon32 = $module->getInfo('icons32');
$adminmenu[$i]["icon"] = $pathIcon32 . '/home.png';
This code above is much easier to read and less prone to break.
If the location of these icons changes, I just need to adjust it in only one location, and the code will still work.
In your case, if I change the level of icon folder, I'll need to add or remove slashes in several locations, otherwise it won't work.
I think, the rule is that we need to define path variables only in one location and then reuse consistently across the whole module.
For example, I like the idea of defining some common path constants in the /include/common.php that you've shown from Publisher:
Quote:
define("PUBLISHER_DIRNAME", basename(dirname(dirname(__FILE__))));
define("PUBLISHER_URL", XOOPS_URL . '/modules/' . PUBLISHER_DIRNAME);
define("PUBLISHER_IMAGES_URL", PUBLISHER_URL . '/images');
define("PUBLISHER_ADMIN_URL", PUBLISHER_URL . '/admin');
Although, I think that we should go away from hardcoded Uploads directories located in the /uploads:
Quote:
define("PUBLISHER_UPLOADS_URL", XOOPS_URL . '/uploads/' . PUBLISHER_DIRNAME);
define("PUBLISHER_UPLOADS_PATH", XOOPS_ROOT_PATH . '/uploads/' . PUBLISHER_DIRNAME);
and instead let the user decide where they want to save their files by having an option in Preferences. Of course, the above settings could be used as defaults for the option in xoops_version.org
This however opens another question: where should we place uploads as default?
Up to now the thinking from the Core Team was that it should be in the /uploads folder. But this makes copying of modules very difficult, because then I have to think about coping the module itself, and then go to /uploads folder and look for right folder to copy it as well.
Personally, I think, it's better to:
a) make Uploads folder location an option for the user that he can change in Preferences
b) as a default, set it up in the module itself.
The benefits of this:
a) the module is self-contained, and when we copy it to another server, nothing will be missed or lost
b) we don't have to deal with missing upload folders, or with placing in each folder a routine to create the /upload folders during installation.
What do you think?