diff --git a/phpgwapi/categories.php b/api/categories.php similarity index 87% rename from phpgwapi/categories.php rename to api/categories.php index fd71d275c8..1ba6ef5618 100644 --- a/phpgwapi/categories.php +++ b/api/categories.php @@ -2,21 +2,23 @@ /** * API: loading categories and setting styles * - * Usage: /egroupware/phpgwapi/categories.php[?app=calendar] + * Usage: /egroupware/api/categories.php[?app=calendar] * * @link www.egroupware.org * @author Nathan Gray - * @package API + * @package api * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ +use EGroupware\Api; + // switch evtl. set output-compression off, as we cant calculate a Content-Length header with transparent compression ini_set('zlib.output_compression', 0); $GLOBALS['egw_info'] = array( 'flags' => array( - 'currentapp' => 'home', + 'currentapp' => 'api', 'noheader' => true, 'nocachecontrol' => true, ) @@ -25,10 +27,10 @@ $GLOBALS['egw_info'] = array( include '../header.inc.php'; // Get appname -$appname = $_GET['app'] && $GLOBALS['egw_info']['apps'][$_GET['app']] ? $_GET['app'] : categories::GLOBAL_APPNAME; +$appname = $_GET['app'] && $GLOBALS['egw_info']['apps'][$_GET['app']] ? $_GET['app'] : Api\Categories::GLOBAL_APPNAME; -$cats = new categories('', $appname); -$categories = $cats->return_array('all',0, false, '', 'ASC','',$appname==categories::GLOBAL_APPNAME); +$cats = new Api\Categories('', $appname); +$categories = $cats->return_array('all',0, false, '', 'ASC','',$appname==Api\Categories::GLOBAL_APPNAME); $content = "/* Category CSS for $appname */\n\n"; @@ -50,7 +52,7 @@ foreach($categories as $cat) $etag = '"'.md5($content).'"'; // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header -egw_session::cache_control(86400); // cache for 1 day +Api\Session::cache_control(86400); // cache for 1 day Header('Content-Type: text/css; charset=utf-8'); Header('ETag: '.$etag); @@ -58,7 +60,7 @@ Header('ETag: '.$etag); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { header("HTTP/1.1 304 Not Modified"); - common::egw_exit(); + exit; } // we run our own gzip compression, to set a correct Content-Length of the encoded content diff --git a/phpgwapi/config.php b/api/config.php similarity index 82% rename from phpgwapi/config.php rename to api/config.php index c9a7e52046..1af9594458 100644 --- a/phpgwapi/config.php +++ b/api/config.php @@ -1,22 +1,24 @@ - * @package addressbook + * @package api * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ +use EGroupware\Api; + // switch evtl. set output-compression off, as we cant calculate a Content-Length header with transparent compression ini_set('zlib.output_compression', 0); $GLOBALS['egw_info'] = array( 'flags' => array( - 'currentapp' => 'home', + 'currentapp' => 'api', 'noheader' => true, 'nocachecontrol' => true, ) @@ -25,12 +27,12 @@ $GLOBALS['egw_info'] = array( include '../header.inc.php'; // use an etag over config and link-registry -$config = json_encode(config::clientConfigs()); -$link_registry = egw_link::json_registry(); +$config = json_encode(Api\Config::clientConfigs()); +$link_registry = Api\Link::json_registry(); $etag = '"'.md5($config.$link_registry).'"'; // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header -egw_session::cache_control(86400); // cache for one day +Api\Session::cache_control(86400); // cache for one day Header('Content-Type: text/javascript; charset=utf-8'); Header('ETag: '.$etag); @@ -38,7 +40,7 @@ Header('ETag: '.$etag); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { header("HTTP/1.1 304 Not Modified"); - common::egw_exit(); + exit; } $content = 'egw.set_configs('.$config.", egw && egw.window !== window);\n"; diff --git a/phpgwapi/images.php b/api/images.php similarity index 83% rename from phpgwapi/images.php rename to api/images.php index c2ac8b567a..4918c37fcd 100644 --- a/phpgwapi/images.php +++ b/api/images.php @@ -2,21 +2,23 @@ /** * API: loading available images by application and image-name (without extension) * - * Usage: /egroupware/phpgwapi/images.php?template=idots + * Usage: /egroupware/api/images.php?template=idots * * @link www.egroupware.org * @author Ralf Becker - * @package phpgwapi + * @package api * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ +use EGroupware\Api; + // switch evtl. set output-compression off, as we cant calculate a Content-Length header with transparent compression ini_set('zlib.output_compression', 0); $GLOBALS['egw_info'] = array( 'flags' => array( - 'currentapp' => 'home', + 'currentapp' => 'api', 'noheader' => true, 'nocachecontrol' => true, ) @@ -24,13 +26,13 @@ $GLOBALS['egw_info'] = array( include '../header.inc.php'; -$content = json_encode(common::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'])); // 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 -egw_session::cache_control(86400); // cache for one day +Api\Session::cache_control(86400); // cache for one day Header('Content-Type: text/javascript; charset=utf-8'); Header('ETag: '.$etag); @@ -38,7 +40,7 @@ Header('ETag: '.$etag); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { header("HTTP/1.1 304 Not Modified"); - common::egw_exit(); + exit; } $content = 'egw.set_images('.$content.", egw && egw.window !== window);\n"; diff --git a/phpgwapi/lang.php b/api/lang.php similarity index 74% rename from phpgwapi/lang.php rename to api/lang.php index 6db7b8e7da..5963833dfb 100644 --- a/phpgwapi/lang.php +++ b/api/lang.php @@ -1,16 +1,18 @@ - * @package addressbook + * @package api * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ +use EGroupware\Api; + // just to be sure, noone tries something nasty ... if (!preg_match('/^[a-z0-9_]+$/i', $_GET['app'])) die('No valid application-name given!'); if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/i', $_GET['lang'])) die('No valid lang-name given!'); @@ -20,7 +22,7 @@ ini_set('zlib.output_compression', 0); $GLOBALS['egw_info'] = array( 'flags' => array( - 'currentapp' => 'home', + 'currentapp' => 'api', 'noheader' => true, 'load_translations' => false, // do not automatically load translations 'nocachecontrol' => true, @@ -31,16 +33,16 @@ try { include('../header.inc.php'); } -catch (egw_exception_no_permission_app $e) +catch (\EGroupware\Api\Exception\NoPermission\App $e) { // ignore missing run rights for an app, as translations of other apps are loaded sometimes without run rights } // use an etag with app, lang and a hash over the creation-times of all lang-files -$etag = '"'.$_GET['app'].'-'.$_GET['lang'].'-'.translation::etag($_GET['app'], $_GET['lang']).'"'; +$etag = '"'.$_GET['app'].'-'.$_GET['lang'].'-'. Api\Translation::etag($_GET['app'], $_GET['lang']).'"'; // headers to allow caching, we specify etag on url to force reload, even with Expires header -egw_session::cache_control(864000); // cache for 10 days +Api\Session::cache_control(864000); // cache for 10 days Header('Content-Type: text/javascript; charset=utf-8'); Header('ETag: '.$etag); @@ -48,18 +50,18 @@ Header('ETag: '.$etag); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { header("HTTP/1.1 304 Not Modified"); - common::egw_exit(); + exit; } -translation::init(false); -translation::add_app($_GET['app'], $_GET['lang']); -if (!count(translation::$lang_arr)) +Api\Translation::init(false); +Api\Translation::add_app($_GET['app'], $_GET['lang']); +if (!count(Api\Translation::$lang_arr)) { - translation::add_app($_GET['app'], 'en'); + Api\Translation::add_app($_GET['app'], 'en'); } // fix for phrases containing \n -$content = 'egw.set_lang_arr("'.$_GET['app'].'", '.str_replace('\\\\n', '\\n', json_encode(translation::$lang_arr)).', egw && egw.window !== window);'; +$content = 'egw.set_lang_arr("'.$_GET['app'].'", '.str_replace('\\\\n', '\\n', json_encode(Api\Translation::$lang_arr)).', egw && egw.window !== window);'; // 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/src/Categories.php b/api/src/Categories.php index 641f2f70ec..f7b7e2b323 100644 --- a/api/src/Categories.php +++ b/api/src/Categories.php @@ -1039,7 +1039,7 @@ class Categories $cats = new Categories('',$appname); $last_mod = $cats->return_array('all',0,1,'','DESC','last_mod', $appname == self::GLOBAL_APPNAME); $time = count($last_mod) ? $last_mod[0]['last_mod'] : time(); - $path = '/phpgwapi/categories.php?app='.$appname.'&'.$time; + $path = '/api/categories.php?app='.$appname.'&'.$time; egw_framework::includeCSS($path); return $path; diff --git a/phpgwapi/user.php b/api/user.php similarity index 91% rename from phpgwapi/user.php rename to api/user.php index a7fdd61769..64c79dd480 100644 --- a/phpgwapi/user.php +++ b/api/user.php @@ -2,21 +2,23 @@ /** * API: loading user preferences and data * - * Usage: /egroupware/phpgwapi/lang.php?user=123 + * Usage: /egroupware/api/user.php?user=123 * * @link www.egroupware.org * @author Ralf Becker - * @package addressbook + * @package api * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ +use EGroupware\Api; + // switch evtl. set output-compression off, as we cant calculate a Content-Length header with transparent compression ini_set('zlib.output_compression', 0); $GLOBALS['egw_info'] = array( 'flags' => array( - 'currentapp' => 'home', + 'currentapp' => 'api', 'noheader' => true, 'nocachecontrol' => true, ) @@ -31,7 +33,7 @@ $user = $GLOBALS['egw']->accounts->json($GLOBALS['egw_info']['user']['account_id $etag = '"'.md5($preferences.$ab_preferences.$user).'"'; // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header -egw_session::cache_control(86400); // cache for 1 day +Api\Session::cache_control(86400); // cache for 1 day Header('Content-Type: text/javascript; charset=utf-8'); Header('ETag: '.$etag); @@ -39,7 +41,7 @@ Header('ETag: '.$etag); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { header("HTTP/1.1 304 Not Modified"); - common::egw_exit(); + exit; } $content = 'egw.set_preferences('.$preferences.", 'common', egw && egw.window !== window);\n"; diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php index 2574700316..05ecc74bfa 100644 --- a/phpgwapi/inc/class.egw_framework.inc.php +++ b/phpgwapi/inc/class.egw_framework.inc.php @@ -1425,15 +1425,15 @@ abstract class egw_framework // specifying etag in url to force reload, as we send expires header if ($GLOBALS['egw_info']['flags']['js_link_registry']) { - self::validate_file('/phpgwapi/config.php', array( + self::validate_file('/api/config.php', array( 'etag' => md5(json_encode(config::clientConfigs()).egw_link::json_registry()), )); - self::validate_file('/phpgwapi/images.php', array( + self::validate_file('/api/images.php', array( 'template' => $GLOBALS['egw_info']['server']['template_set'], 'etag' => md5(json_encode(common::image_map($GLOBALS['egw_info']['server']['template_set']))), 'svg' => html::$ua_mobile, // always load non-svg image map, ATM we use svg icons only for mobile theme )); - self::validate_file('/phpgwapi/user.php', array( + self::validate_file('/api/user.php', array( 'user' => $GLOBALS['egw_info']['user']['account_lid'], 'lang' => $GLOBALS['egw_info']['user']['preferences']['common']['lang'], // add etag on url, so we can set an expires header diff --git a/phpgwapi/js/jsapi/egw_images.js b/phpgwapi/js/jsapi/egw_images.js index 85e6008caf..69226b94d1 100644 --- a/phpgwapi/js/jsapi/egw_images.js +++ b/phpgwapi/js/jsapi/egw_images.js @@ -44,7 +44,7 @@ egw.extend('images', egw.MODULE_GLOBAL, function() return { /** - * Set imagemap, called from /phpgwapi/images.php + * Set imagemap, called from /api/images.php * * @param {array|object} _images * @param {boolean} _need_clone _images need to be cloned, as it is from different window context diff --git a/phpgwapi/js/jsapi/egw_lang.js b/phpgwapi/js/jsapi/egw_lang.js index 691acc26fb..af0758eba0 100644 --- a/phpgwapi/js/jsapi/egw_lang.js +++ b/phpgwapi/js/jsapi/egw_lang.js @@ -147,7 +147,7 @@ egw.extend('lang', egw.MODULE_GLOBAL, function() if (typeof lang_arr[_apps[i].app] === "undefined") { jss.push(this.webserverUrl + - '/phpgwapi/lang.php?app=' + _apps[i].app + + '/api/lang.php?app=' + _apps[i].app + '&lang=' + _apps[i].lang + '&etag=' + (_apps[i].etag || this.config('max_lang_time'))); }