diff --git a/api/images.php b/api/images.php index 4918c37fcd..1ecf45d9a7 100644 --- a/api/images.php +++ b/api/images.php @@ -2,7 +2,9 @@ /** * API: loading available images by application and image-name (without extension) * - * Usage: /egroupware/api/images.php?template=idots + * Usage: + * - /egroupware/api/images.php?template=idots + * - /egroupware/api/images.php?template=pixelegg&debug=1 gives pretty-printed JSON * * @link www.egroupware.org * @author Ralf Becker @@ -26,14 +28,17 @@ $GLOBALS['egw_info'] = array( include '../header.inc.php'; -$content = json_encode(Api\Image::map(preg_match('/^[a-z0-9_-]+$/i',$_GET['template']) ? $_GET['template'] : null, $_GET['svg'])); +$content = json_encode(Api\Image::map(preg_match('/^[a-z0-9_-]+$/i',$_GET['template']) ? $_GET['template'] : null, $_GET['svg']), + JSON_FORCE_OBJECT | // export empty php-arrays as empty objects, not empty arrays + JSON_UNESCAPED_SLASHES | // do not escape slashes, smaller and better readable + (!empty($_GET['debug']) ? JSON_PRETTY_PRINT : 0)); // use an etag over the image mapp $etag = '"'.md5($content).'"'; // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header Api\Session::cache_control(86400); // cache for one day -Header('Content-Type: text/javascript; charset=utf-8'); +Header('Content-Type: '.(empty($_GET['debug'])?'text/javascript':'application/json').'; charset=utf-8'); Header('ETag: '.$etag); // if servers send a If-None-Match header, response with 304 Not Modified, if etag matches @@ -43,7 +48,7 @@ if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $ exit; } -$content = 'egw.set_images('.$content.", egw && egw.window !== window);\n"; +if (empty($_GET['debug'])) $content = 'egw.set_images('.$content.", egw && egw.window !== window);\n"; // we run our own gzip compression, to set a correct Content-Length of the encoded content if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) diff --git a/api/js/jsapi/egw_images.js b/api/js/jsapi/egw_images.js index 56acf919fa..c6995ab696 100644 --- a/api/js/jsapi/egw_images.js +++ b/api/js/jsapi/egw_images.js @@ -97,6 +97,11 @@ egw.extend('images', egw.MODULE_GLOBAL, function() { return this.webserverUrl+images[_app][_name]; } + tries['api'] = _name; + if (typeof images['api'] != 'undefined' && typeof images['api'][_name] == 'string') + { + return this.webserverUrl+images['api'][_name]; + } tries['phpgwapi'] = _name; if (typeof images['phpgwapi'] != 'undefined' && typeof images['phpgwapi'][_name] == 'string') { diff --git a/api/src/Image.php b/api/src/Image.php index 39146cb0a6..ae53a1f4b6 100644 --- a/api/src/Image.php +++ b/api/src/Image.php @@ -166,7 +166,7 @@ class Image { $imagedirs[] = '/'.$app.'/templates/mobile/images'; } - if ($app == 'phpgwapi') + if ($app == 'api') { $imagedirs[] = $GLOBALS['egw']->framework->template_dir.'/images'; }