Guidance needed to write a module to multilingualize URLs

gopu
gopu's picture

Joined: 2009-08-28
Posts: 137
Posted: Thu, 2009-12-03 12:39

Hello,

I would like to develop (or enhance the existing multilang) module that will enable user to have multilingual URLs for items, with rewrite module enabled.
For example for a "beautiful rose" photo under rose album, I would like to have following URLs for english and spanish respectively:

Can somebody please give me some pointer to go about to implement it?

Any vague idea also will help me...

thanks

-------------
my wings of love - work, experince, learnings, open source, technologies on my way to God

 
gopu
gopu's picture

Joined: 2009-08-28
Posts: 137
Posted: Thu, 2009-12-10 13:12

Hello,

Finally, I could enhance the multilang module to implement the above feature.
Check out:

But I needed some very minor changes in Rewrite and Core module. See point (2) and (6) below...
May be its possible to avoid theses changes in these module... I would need help in doing so.

This is what I did to implement it:
1. Added one column pathComponent to the MultiLangItemMap table
2. Made changes in RewriteSimpleHelper::loadItemIdFromPath to get the ID from path using MultilangExtHelper::fetchItemIdByPath instead of GalleryCoreApi::fetchItemIdByPath
3. MultilangExtHelper::fetchItemIdByPath is same as GalleryCoreApi::fetchItemIdByPath, except that it uses MultilangExtHelper::fetchChildIdByPathComponent to get the ID when GalleryCoreApi::fetchChildIdByPathComponent fails as below:

Quote:
foreach (preg_split('|/|', $path, -1, PREG_SPLIT_NO_EMPTY) as $pathComponent) {
$curId = $currentId;
list ($ret, $currentId) =
GalleryCoreApi::fetchChildIdByPathComponent($currentId, $pathComponent);
if ($ret)
{
$currentId = $curId;
list ($ret, $currentId) =
MultilangExtHelper::fetchChildIdByPathComponent($currentId, $pathComponent);
if ($ret) {
return array($ret, null);
}
}
}

MultilangExtHelper::fetchChildIdByPathComponent fetches the ID from the[ b]MultiLangItemMap[/b] table
4. Changed multilang GalleryOnLoadHandler handler to set the pathComponent, besides title, summary and description when the view is not core.DownloadItem
5. Corresponding UI changes
6. Needed to comment out the following code in DownloadItemView::renderImmediate

Quote:
$fileName = GalleryUtilities::getRequestVariables('fileName');
if (!empty($fileName) && $fileName != $pseudoFileName) {
return GalleryCoreApi::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__, 'malicious url');
}

This is because the filename in request variable and the filename that we get through multilang is different for different languages.
If you have thorough knowledge of gallery2 I request please let me know if these changes can be avoided in rewrite and core module, if yes how?

---------------------------------------------
my wings of love - work, experince, learnings, open source, technologies on my way to God