From b8797c7ad6e393ab57f38c6c1ac04697a1b5aa1c Mon Sep 17 00:00:00 2001 From: seek3r Date: Sat, 29 Dec 2001 10:57:35 +0000 Subject: [PATCH] put in new find_image function that should help performance a fair bit --- phpgwapi/inc/class.common.inc.php | 58 +++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index fec00d83fb..fab213e1ed 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -42,6 +42,7 @@ class common { var $debug_info; // An array with debugging info from the API + var $found_files; /*! @function cmp_version @@ -766,21 +767,56 @@ function find_image($appname,$image) { - $imagedir = '/'.$appname.'/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images'; - $imagedir_default = '/'.$appname.'/templates/default/images'; - $imagedir_olddefault = '/'.$appname.'/images'; - if(@file_exists(PHPGW_SERVER_ROOT.$imagedir.'/'.$image)) + if (!is_array($this->found_files[$appname]['images'])) { - $imgfile = $GLOBALS['phpgw_info']['server']['webserver_url'].$imagedir.'/'.$image; + $imagedir_olddefault = '/'.$appname.'/images'; + $imagedir_default = '/'.$appname.'/templates/default/images'; + $imagedir = '/'.$appname.'/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images'; + + if (@is_dir(PHPGW_INCLUDE_ROOT.$imagedir_olddefault)) + { + $d = dir(PHPGW_INCLUDE_ROOT.$imagedir_olddefault); + while (false !== ($entry = $d->read())) + { + if ($entry != '.' && $entry != '..') + { + $this->found_files[$appname]['images'][$entry] = $imagedir_olddefault; + } + } + $d->close(); + } + + if (@is_dir(PHPGW_INCLUDE_ROOT.$imagedir_default)) + { + $d = dir(PHPGW_INCLUDE_ROOT.$imagedir_default); + while (false !== ($entry = $d->read())) + { + if ($entry != '.' && $entry != '..') + { + $this->found_files[$appname]['images'][$entry] = $imagedir_default; + } + } + $d->close(); + } + + if (@is_dir(PHPGW_INCLUDE_ROOT.$imagedir)) + { + $d = dir(PHPGW_INCLUDE_ROOT.$imagedir); + while (false !== ($entry = $d->read())) + { + if ($entry != '.' && $entry != '..') + { + $this->found_files[$appname]['images'][$entry] = $imagedir; + } + } + $d->close(); + } } - elseif(@file_exists(PHPGW_SERVER_ROOT.$imagedir_default.'/'.$image)) + + if(isset($this->found_files[$appname]['images'][$image])) { - $imgfile = $GLOBALS['phpgw_info']['server']['webserver_url'].$imagedir_default.'/'.$image; - } - elseif(@file_exists(PHPGW_SERVER_ROOT.$imagedir_olddefault.'/'.$image)) - { - $imgfile = $GLOBALS['phpgw_info']['server']['webserver_url'].$imagedir_olddefault.'/'.$image; + $imgfile = $GLOBALS['phpgw_info']['server']['webserver_url'].$this->found_files[$appname]['images'][$image].'/'.$image; } else {