switching svg images off for everything but application icons in Stylite or Pixelegg template

This commit is contained in:
Ralf Becker 2014-02-11 14:41:17 +00:00
parent cf6d844c67
commit 436fe041e0
2 changed files with 28 additions and 4 deletions

View File

@ -764,12 +764,23 @@ class common
* @param string $appname * @param string $appname
* @param string|array $image one or more image-name in order of precedence * @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 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 * @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; static $image_map_no_svg = null, $image_map_svg = null;
if (is_null($image_map)) $image_map = self::image_map(); 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 // array of images in descending precedence
if (is_array($image)) if (is_array($image))
@ -813,6 +824,18 @@ class common
return null; 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 * Scan filesystem for images of all apps
* *
@ -833,7 +856,7 @@ class common
} }
if (is_null($svg)) 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' : ''); $cache_name = 'image_map_'.$template_set.($svg ? '_svg' : '');
if (($map = egw_cache::getInstance(__CLASS__, $cache_name))) if (($map = egw_cache::getInstance(__CLASS__, $cache_name)))

View File

@ -1136,6 +1136,7 @@ abstract class egw_framework
self::validate_file('/phpgwapi/images.php', array( self::validate_file('/phpgwapi/images.php', array(
'template' => $GLOBALS['egw_info']['user']['preferences']['common']['template_set'], 'template' => $GLOBALS['egw_info']['user']['preferences']['common']['template_set'],
'etag' => md5(json_encode(common::image_map($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( self::validate_file('/phpgwapi/user.php', array(
'user' => $GLOBALS['egw_info']['user']['account_lid'], 'user' => $GLOBALS['egw_info']['user']['account_lid'],