From 86f1dde06fd93bde246b4cac7270508cffe4f351 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Wed, 13 May 2009 14:33:36 +0000 Subject: [PATCH] configurable favicon, configurable vfs image store for images, logos, icons --- admin/templates/default/config.tpl | 16 +++- phpgwapi/inc/class.common.inc.php | 97 ++++++++++++------------ phpgwapi/inc/class.egw_framework.inc.php | 14 +++- phpgwapi/inc/class.html.inc.php | 5 +- 4 files changed, 75 insertions(+), 57 deletions(-) diff --git a/admin/templates/default/config.tpl b/admin/templates/default/config.tpl index f8a4c80ece..dc3cf039d0 100644 --- a/admin/templates/default/config.tpl +++ b/admin/templates/default/config.tpl @@ -75,6 +75,11 @@ + + {lang_Enter_the_VFS-Path_where_additional_images,_icons_or_logos_can be_placed_(and_found_by_EGroupwares_applications)._The_path_MUST_start_with_/,and_be_readable_by_all_users}: + + +  {lang_appearance} @@ -100,6 +105,11 @@ + {lang_Enter_the_URL_or_filename_(in_your_templates_image_directory)_of_your_favicon_(the_little_icon_that_appears_in_the_browsers_tabs)}: + + + + {lang_Show_an_asterisk_(*)_to_mark_untranslated_strings}: - + {lang_Enable_the_spellcheck_in_the_ritch_text_editor_?}: diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index a4347d74ba..a0e9c38e25 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -809,6 +809,7 @@ class common function find_image($appname,$image) { $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])) { @@ -853,6 +854,22 @@ class common } $d->close(); } + + if (!isset(self::$found_files['vfs']) && 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 ($type == 'image' || $type == 'application') self::$found_files['vfs'][$entry] = $vfs_imagedir; + } + } + } + closedir($d); + } } if (!$GLOBALS['egw_info']['server']['image_type']) @@ -865,64 +882,44 @@ class common // priority: : PNG->JPG->GIF $img_type=array('.png','.jpg','.gif'); } + $imgfile = ''; + // first look in the instance specific image dir in vfs + foreach(array_merge($img_type,array('')) as $type) + { + // first look in the instance specific image dir in vfs + if(self::$found_files['vfs'][$image.$type]==$vfs_imagedir) + { + $imgfile = egw::link(egw_vfs::download_url(self::$found_files['vfs'][$image.$type].'/'.$image.$type)); + break; + } + // then look in the selected template dir + if(self::$found_files[$appname][$image.$type]==$imagedir) + { + $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$type].'/'.$image.$type; + break; + } + //then look everywhere else + if (isset(self::$found_files[$appname][$image.$type])) + { + $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$type].'/'.$image.$type; + break; + } + } - // first look in the selected template dir - if(@self::$found_files[$appname][$image.$img_type[0]]==$imagedir) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[0]].'/'.$image.$img_type[0]; - } - elseif(@self::$found_files[$appname][$image.$img_type[1]]==$imagedir) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[1]].'/'.$image.$img_type[1]; - } - elseif(@self::$found_files[$appname][$image.$img_type[2]]==$imagedir) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[2]].'/'.$image.$img_type[2]; - } - // then look everywhere else - elseif(isset(self::$found_files[$appname][$image.$img_type[0]])) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[0]].'/'.$image.$img_type[0]; - } - elseif(isset(self::$found_files[$appname][$image.$img_type[1]])) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[1]].'/'.$image.$img_type[1]; - } - elseif(isset(self::$found_files[$appname][$image.$img_type[2]])) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[2]].'/'.$image.$img_type[2]; - } - elseif(isset(self::$found_files[$appname][$image])) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image].'/'.$image; - } - else + if (empty($imgfile)) { // searching the image in the api-dirs if (!isset(self::$found_files['phpgwapi'])) { $this->find_image('phpgwapi',''); } - - if(isset(self::$found_files['phpgwapi'][$image.$img_type[0]])) + foreach(array_merge($img_type,array('')) as $type) { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[0]].'/'.$image.$img_type[0]; - } - elseif(isset(self::$found_files['phpgwapi'][$image.$img_type[1]])) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[1]].'/'.$image.$img_type[1]; - } - elseif(isset(self::$found_files['phpgwapi'][$image.$img_type[2]])) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[2]].'/'.$image.$img_type[2]; - } - elseif(isset(self::$found_files['phpgwapi'][$image])) - { - $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image].'/'.$image; - } - else - { - $imgfile = ''; + if(isset(self::$found_files['phpgwapi'][$image.$type])) + { + $imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$type].'/'.$image.$type; + break; + } } } return $imgfile; diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index e15e3eb528..69da1f8e20 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -241,10 +241,20 @@ abstract class egw_framework } if($app!='wiki') $robots =''; + if (substr($GLOBALS['egw_info']['server']['favicon_file'],0,4) == 'http') + { + $var['favicon_file'] = $GLOBALS['egw_info']['server']['favicon_file']; + } + else + { + $var['favicon_file'] = $GLOBALS['egw']->common->image('phpgwapi',$GLOBALS['egw_info']['server']['favicon_file']?$GLOBALS['egw_info']['server']['favicon_file']:'favicon.ico'); + } return $this->_get_css()+array( - 'img_icon' => EGW_IMAGES_DIR . '/favicon.ico', - 'img_shortcut' => EGW_IMAGES_DIR . '/favicon.ico', + #'img_icon' => EGW_IMAGES_DIR . '/favicon.ico', + 'img_icon' => $var['favicon_file'], + #'img_shortcut' => EGW_IMAGES_DIR . '/favicon.ico', + 'img_shortcut' => $var['favicon_file'], 'pngfix' => $pngfix, 'slider_effects' => $slider_effects, 'simple_show_hide' => $simple_show_hide, diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 435bcb0582..48f74926ca 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -889,8 +889,9 @@ class html { $name = $GLOBALS['egw']->link('/index.php',$name); } - if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://') + if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'etemplate/thumbnail.php') ) { + if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name; $url = $name; } else // no URL, so try searching the image @@ -912,7 +913,7 @@ class html $path = EGW_SERVER_ROOT.$url; } - if (is_null($path) || !@is_readable($path)) + if (is_null($path) || (!@is_readable($path) && stripos($path,'webdav.php')===false)) { // if the image-name is a percentage, use a progressbar if (substr($name,-1) == '%' && is_numeric($percent = substr($name,0,-1)))