[eGroupWare-svn] r56030 - in /trunk/egroupware/api: images.php js/jsapi/egw_images.js src/Image.php

[email protected] Thu, 05 May 2016 09:16:27 -0000
Newsgroups gmane.comp.web.egroupware.cvs
Message-ID <[email protected]>
Author: ralfbecker
Date: Thu May  5 11:16:27 2016
New Revision: 56030

URL: http://svn.stylite.de/viewvc/egroupware?rev=56030&view=rev
Log:
mv template specific images from "phpgwapi" to "api" and search "api" also on client-side for image, added debug GET parameter to images.php to JSON pretty-print instead of one line javascript

Added:
    trunk/egroupware/api/js/jsapi/egw_images.js
      - copied, changed from r56021, trunk/egroupware/api/js/jsapi/egw_images.js
Modified:
    trunk/egroupware/api/images.php
    trunk/egroupware/api/src/Image.php

Modified: trunk/egroupware/api/images.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/images.php?rev=56030&r1=56029&r2=56030&view=diff
==============================================================================
--- trunk/egroupware/api/images.php (original)
+++ trunk/egroupware/api/images.php Thu May  5 11:16:27 2016
@@ -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 <RalfBecker-AT-outdoor-training.de>
@@ -26,14 +28,17 @@
 
 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 @@
 	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'))

Copied: trunk/egroupware/api/js/jsapi/egw_images.js (from r56021, trunk/egroupware/api/js/jsapi/egw_images.js)
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/js/jsapi/egw_images.js?p2=trunk/egroupware/api/js/jsapi/egw_images.js&p1=trunk/egroupware/api/js/jsapi/egw_images.js&r1=56021&r2=56030&rev=56030&view=diff
==============================================================================
--- trunk/egroupware/api/js/jsapi/egw_images.js (original)
+++ trunk/egroupware/api/js/jsapi/egw_images.js Thu May  5 11:16:27 2016
@@ -97,6 +97,11 @@
 			{
 				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')
 			{

Modified: trunk/egroupware/api/src/Image.php
URL: http://svn.stylite.de/viewvc/egroupware/trunk/egroupware/api/src/Image.php?rev=56030&r1=56029&r2=56030&view=diff
==============================================================================
--- trunk/egroupware/api/src/Image.php (original)
+++ trunk/egroupware/api/src/Image.php Thu May  5 11:16:27 2016
@@ -166,7 +166,7 @@
 			{
 				$imagedirs[] = '/'.$app.'/templates/mobile/images';
 			}
-			if ($app == 'phpgwapi')
+			if ($app == 'api')
 			{
 				$imagedirs[] = $GLOBALS['egw']->framework->template_dir.'/images';
 			}


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z