2006-03-29
B-root
After a non-image media, the css class of the link to the media in media.php stay the same.
It is due to a small bug in the file inc/template.php and the function tpl_mediafilelist() :
The original code is :
----------- [search] --------------
foreach($data as $item){
if(!$item['isimg']){
// add file icons
list($ext,$mime) = mimetype($item['file']);
$class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
$class = ' class="mediafile mf_'.$class.'"';
}
ptln('<li><div class="li">',4);
ptln('<a href="javascript:mediaSelect(':'.$item['id'].'')"'.$class.'>'.
utf8_decodeFN($item['file']).
'</a>',6);
------------------------------
The variable which cause the problem is $class. As you can see in the if statement, it could be initialized to a value if the media is not an image.
But then, it is not reseted. As it's a part of a foreach statement, the next media will become the same class (which is the css class in fact).
I suggest to modify the if statement the following way :
-------------------------
if(!$item['isimg']){
// add file icons
list($ext,$mime) = mimetype($item['file']);
$class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
$class = ' class="mediafile mf_'.$class.'"';
} else {
$class = '';
}
-------------------------
It works fine on my web site.