BUG in getAliasName? - Strange aliases
Posted: 19 Dec 2008, 15:36
Hello,
I've done a quick research of "alias" word in forum and do not found result connected with my problem.
I've found that aliases of images names generated by Phocagallery are very strange.
Examples:
all like that. Currently I cannot find the shema, but I've found that generated value depends on Name I've put and Filename. Additionaly when I clear the Alias field of "Phoca Gallery Image: [ Edit ]" -> Details I've got "l-_-_", but after entering again into image details and pressing Save (without changes) I've got "_-_". Generated value is independent (as far as I've tested) from Joomla backend language (originally I've worked with Polish, then I've selected English).
I've spend some time for research after writing above text and I've found function getAliasName in helpers/phocagallery.php. I've changed it to see whats happening:
Now:
So it looks like first preg_replace() do all that mess.
My PHP version is 5.2.3
I have also another server with PHP 5.2.6 and there everything was ok. I'm not sure if the problem is with PHP version or something else.
I've done a quick research of "alias" word in forum and do not found result connected with my problem.
I've found that aliases of images names generated by Phocagallery are very strange.
Examples:
Code: Select all
filename | name -> alias
news/1/ALPA_Dreamworlds_Holzherr.jpg | ALPA_Dreamworlds_Holzherr -> l-_-_
news/1/ALPA_Dreamworlds_Holzherr.jpg | ALPA_Dreamworlds -> _-_
news/1/ALPA_Dreamworlds_Holzherr.jpg | Mlotek -> l-_-_
news/1/ALPA_Dreamworlds_Holzherr.jpg | Ala ma kota i psa -> _-_
news/1/ALPA_Dreamworlds_Holzherr.jpg | Ala ma kota -> l-_-_
news/2/photokina.jpg | photokina -> p
I've spend some time for research after writing above text and I've found function getAliasName in helpers/phocagallery.php. I've changed it to see whats happening:
Code: Select all
function getAliasName($name) {
if (function_exists('iconv')) {
$test = $name;
$name = preg_replace('~[^\\pL0-9_.]+~u', '-', $name);
$test .= "|$name";
$name = trim($name, "-");
$test .= "|$name";
$name = iconv("utf-8", "us-ascii//TRANSLIT", $name);
$test .= "|$name";
$name = strtolower($name);
$test .= "|$name";
$name = preg_replace('~[^-a-z0-9_.]+~', '', $name);
$test .= "|$name";
} else {
$name = JFilterOutput::stringURLSafe($name);
if(trim(str_replace('-','',$name)) == '') {
$datenow =& JFactory::getDate();
$name = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}
}
return $test;
}
Code: Select all
Alias (initial value): ''
Filename: news/1/ALPA_Dreamworlds_Holzherr.jpg
Alias ($test value): ALPA_Dreamworlds_Holzherr|-L-_-_-|L-_-_|L-_-_|l-_-_|l-_-_
Alias (initial value): 'l-_-_'
Filename: news/1/ALPA_Dreamworlds_Holzherr.jpg
Alias ($test value): l-_-_|-_-_|_-_|_-_|_-_|_-_
Alias (initial value): ''
Filename: news/2/photokina.jpg
Alias ($test value): photokina|p-|p|p|p|p
My PHP version is 5.2.3
I have also another server with PHP 5.2.6 and there everything was ok. I'm not sure if the problem is with PHP version or something else.