From 38261120597f68a32246790a338f4239c807eeaf Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 3 May 2003 10:59:16 +0000 Subject: [PATCH] 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. --- phpgwapi/inc/class.common.inc.php | 38 ++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 2ae34545ac..b91ccfd34b 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -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'; }