"fixed not always displayed icons (eg. old nextmatch in translation-tools) and some more caching"

This commit is contained in:
Ralf Becker 2009-05-16 10:22:56 +00:00
parent 2408fbb0c9
commit 44ce028592

View File

@ -811,64 +811,64 @@ class common
$imagedir = '/'.$appname.'/templates/'.$GLOBALS['egw_info']['user']['preferences']['common']['template_set'].'/images';
$vfs_imagedir = $GLOBALS['egw_info']['server']['vfs_image_dir'];
if (!@is_array(self::$found_files[$appname]))
if (!isset(self::$found_files[$appname]))
{
$imagedir_olddefault = '/'.$appname.'/templates/default/images';
$imagedir_default = '/'.$appname.'/templates/idots/images';
if (@is_dir(EGW_INCLUDE_ROOT.$imagedir_olddefault))
if (file_exists(EGW_INCLUDE_ROOT.$imagedir_olddefault) && ($d = dir(EGW_INCLUDE_ROOT.$imagedir_olddefault)))
{
$d = dir(EGW_INCLUDE_ROOT.$imagedir_olddefault);
while (false != ($entry = $d->read()))
while (($entry = $d->read()))
{
if ($entry != '.' && $entry != '..')
if ($entry[0] != '.')
{
self::$found_files[$appname][$entry] = $imagedir_olddefault;
}
}
$d->close();
}
if (@is_dir(EGW_INCLUDE_ROOT.$imagedir_default))
if (file_exists(EGW_INCLUDE_ROOT.$imagedir_default) && ($d = dir(EGW_INCLUDE_ROOT.$imagedir_default)))
{
$d = dir(EGW_INCLUDE_ROOT.$imagedir_default);
while (false != ($entry = $d->read()))
while (($entry = $d->read()))
{
if ($entry != '.' && $entry != '..')
if ($entry[0] != '.')
{
self::$found_files[$appname][$entry] = $imagedir_default;
}
}
$d->close();
}
if (@is_dir(EGW_INCLUDE_ROOT.$imagedir))
if (file_exists(EGW_INCLUDE_ROOT.$imagedir) && ($d = dir(EGW_INCLUDE_ROOT.$imagedir)))
{
$d = dir(EGW_INCLUDE_ROOT.$imagedir);
while (false != ($entry = $d->read()))
while (($entry = $d->read()))
{
if ($entry != '.' && $entry != '..')
if ($entry[0] != '.')
{
self::$found_files[$appname][$entry] = $imagedir;
}
}
$d->close();
}
if (!isset(self::$found_files['vfs']) && egw_vfs::file_exists($vfs_imagedir) &&
//echo $appname; _debug_array(self::$found_files[$appname]);
}
if (!isset(self::$found_files['vfs']))
{
self::$found_files['vfs'] = array(); // so it get's scaned only once
if (egw_vfs::file_exists($vfs_imagedir) &&
egw_vfs::is_dir($vfs_imagedir) && ($d = egw_vfs::opendir($vfs_imagedir)))
{
while (($entry = readdir($d)) !== false)
{
if (!egw_vfs::is_dir($vfs_imagedir.'/'.$entry))
{
if (list($type,$subtype) = explode('/',egw_vfs::mime_content_type($vfs_imagedir.'/'.$entry)))// && $type == 'image')
if (list($type,$subtype) = explode('/',egw_vfs::mime_content_type($vfs_imagedir.'/'.$entry)) && $type == 'image')
{
if ($type == 'image' || $type == 'application') self::$found_files['vfs'][$entry] = $vfs_imagedir;
self::$found_files['vfs'][$entry] = $vfs_imagedir;
}
}
}
closedir($d);
//echo 'vfs'; _debug_array(self::$found_files['vfs']);
}
}
if (!$GLOBALS['egw_info']['server']['image_type'])
@ -892,7 +892,7 @@ class common
break;
}
// then look in the selected template dir
if(self::$found_files[$appname][$image.$type]==$imagedir)
if(self::$found_files[$appname][$image.$type] == $imagedir)
{
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$type].'/'.$image.$type;
break;
@ -912,7 +912,7 @@ class common
{
self::find_image('phpgwapi','');
}
foreach(array_merge($img_type,array('')) as $type)
foreach($img_type as $type)
{
if(isset(self::$found_files['phpgwapi'][$image.$type]))
{
@ -936,35 +936,35 @@ class common
*/
static function image($appname,$image='',$ext='',$use_lang=True)
{
if (!is_array($image))
static $cache; // do some caching in the request
$image_found =& $cache[$appname.$image.$ext.$use_lang];
if (!isset($image_found))
{
if (empty($image))
if (!is_array($image))
{
return '';
if (empty($image))
{
return '';
}
}
if ($use_lang)
{
foreach((array)$image as $img)
{
$lang_images[] = $img . '_' . $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
$lang_images[] = $img;
}
$image = $lang_images;
}
}
if ($use_lang)
{
foreach((array)$image as $img)
{
$lang_images[] = $img . '_' . $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
$lang_images[] = $img;
if (($image_found = self::find_image($appname,$img.$ext))) break;
}
$image = $lang_images;
}
foreach((array)$image as $img)
{
if(isset(self::$found_files[$appname][$img.$ext]))
{
$image_found = self::$found_files[$appname][$img.$ext].'/'.$img.$ext;
}
else
{
$image_found = self::find_image($appname,$img.$ext);
}
if ($image_found) break;
}
//echo "<p>".__METHOD__."($appname,".array2string($image).",$ext,$use_lang) = $image_found</p>\n";
//else $cache_hit = ' *** CACHE ***';
//echo '<p>'.__METHOD__."($appname,".array2string($image).",$ext,$use_lang) = ".array2string($image_found)." $cache_hit</p>\n";
return $image_found;
}