Wow, very impressive... looks like you have worked out most of the details!
I was just wondering about a couple of little things:
1) 'constant' would only be needed to retrieve the value of a constant (e.g. constant($varPrefix . '_GREETING')), but won't by needed for the line:
$modversion['dirname'] = constant($pathparts[1]);
2) $ModuleUrlPath, $ModuleRootPath... do you define these inside all function(s) which need these? I don't think you would be able to use globals for these, unfortunately.
3) For $xoopsModule->getVar('dirname'), do you the global value $xoopsModule? I'll need to look through the XOOPS core again, but I wonder if this might fail for modules included as blocks (for example a 'recent links' block when viewing a forum page; in this case $xoopsModule would refer to 'newbb' so it might not give the correct prefix when loading the language files for 'mylinks'.) Not sure, I'll comment again about this once I know more.
4) Is there some way to use $varPrefix for generating function and class names too? This seems like the only obstacle to making a module which is trivially clonable. It looks like maybe 'create_function' would be useful:http://www.php.net/manual/en/function.create-function.php. It might be a little tricky to give the functions meaningful names (though one of the user-contributed-notes on the php.net site looks helpful), and also might be tricky to actually call the functions. There must be a better way. I'm not sure at the moment how to create classes with 'dynamic' names.
Anyway, let me just say again, very impressive - thanks for posting this!
Best regards,
Mike