From 436fe041e099fde51cd725be75f5d0fc0ebab761 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 11 Feb 2014 14:41:17 +0000 Subject: [PATCH] switching svg images off for everything but application icons in Stylite or Pixelegg template --- phpgwapi/inc/class.common.inc.php | 31 +++++++++++++++++++++--- phpgwapi/inc/class.egw_framework.inc.php | 1 + 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index a27fd96dd4..f2dd960cf0 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -764,12 +764,23 @@ class common * @param string $appname * @param string|array $image one or more image-name in order of precedence * @param string $extension='' extension to $image, makes sense only with an array + * @param boolean $svg=false should svg images be returned or not: + * true: always return svg, false: never return svg (current default), null: browser dependent, see svg_usable() * @return string url of image or null if not found */ - static function image($app,$image,$extension='') + static function image($app,$image,$extension='',$svg=false) { - static $image_map; - if (is_null($image_map)) $image_map = self::image_map(); + static $image_map_no_svg = null, $image_map_svg = null; + if (is_null($svg)) $svg = self::svg_usable (); + if ($svg) + { + $image_map =& $image_map_svg; + } + else + { + $image_map =& $image_map_no_svg; + } + if (is_null($image_map)) $image_map = self::image_map(null, $svg); // array of images in descending precedence if (is_array($image)) @@ -813,6 +824,18 @@ class common return null; } + /** + * Does browser support svg + * + * All non IE and IE 9+ + * + * @return boolean + */ + static function svg_usable() + { + return html::$user_agent !== 'msie' || html::$ua_version >= 9; + } + /** * Scan filesystem for images of all apps * @@ -833,7 +856,7 @@ class common } if (is_null($svg)) { - $svg = html::$user_agent !== 'msie' || html::$ua_version >= 9; + $svg = self::svg_usable(); } $cache_name = 'image_map_'.$template_set.($svg ? '_svg' : ''); if (($map = egw_cache::getInstance(__CLASS__, $cache_name))) diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index 3c2f776667..33f57b090a 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -1136,6 +1136,7 @@ abstract class egw_framework self::validate_file('/phpgwapi/images.php', array( 'template' => $GLOBALS['egw_info']['user']['preferences']['common']['template_set'], 'etag' => md5(json_encode(common::image_map($GLOBALS['egw_info']['user']['preferences']['common']['template_set']))), + 'svg' => 0, // always load non-svg image map )); self::validate_file('/phpgwapi/user.php', array( 'user' => $GLOBALS['egw_info']['user']['account_lid'],