Fixed get_image_dir and get_image_path to not return the templates imagedir if it only contains the navbar icon (eg. idots or idsociety).

Thats only a fix, better would be if every app uses the image or find_image function.
This commit is contained in:
Ralf Becker 2003-05-03 10:59:16 +00:00
parent ce1a06d831
commit 3826112059

View File

@ -724,6 +724,32 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info'
}
}
/*!
@function is_image_dir
@abstract checks if image_dir exists and has more than just a navbar-icon
@note this is just a workaround for idots, better to use find_image, which has a fallback \
on a per image basis to the default dir
*/
function is_image_dir($dir)
{
if (!@is_dir($dir))
{
return False;
}
if ($d = opendir($dir))
{
while ($f = readdir($d))
{
$ext = strtolower(strrchr($f,'.'));
if (($ext == '.gif' || $ext == '.png') && strstr($f,'navbar') === False)
{
return True;
}
}
}
return False;
}
/*!
@function get_image_dir
@abstract get image dir of an application
@ -753,15 +779,15 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info'
$imagedir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/default/images';
$imagedir_olddefault = PHPGW_SERVER_ROOT . '/' . $appname . '/images';
if (@is_dir ($imagedir))
if ($this->is_image_dir ($imagedir))
{
return $imagedir;
}
elseif (@is_dir ($imagedir_default))
elseif ($this->is_image_dir ($imagedir_default))
{
return $imagedir_default;
}
elseif (@is_dir ($imagedir_olddefault))
elseif ($this->is_image_dir ($imagedir_olddefault))
{
return $imagedir_olddefault;
}
@ -801,15 +827,15 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info'
$imagedir_default = PHPGW_SERVER_ROOT . '/'.$appname.'/templates/default/images';
$imagedir_olddefault = PHPGW_SERVER_ROOT . '/'.$appname.'/images';
if (@is_dir ($imagedir))
if ($this->is_image_dir ($imagedir))
{
return $GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$appname.'/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images';
}
elseif (@is_dir ($imagedir_default))
elseif ($this->is_image_dir ($imagedir_default))
{
return $GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$appname.'/templates/default/images';
}
elseif (@is_dir ($imagedir_olddefault))
elseif ($this->is_image_dir ($imagedir_olddefault))
{
return $GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$appname.'/images';
}