diff --git a/api/etemplate.php b/api/etemplate.php new file mode 100644 index 0000000000..8f47eabfd7 --- /dev/null +++ b/api/etemplate.php @@ -0,0 +1,125 @@ +/templates/default/.xet + * + * @link https://www.egroupware.org + * @author Ralf Becker + * @package api + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + */ + +use EGroupware\Api; + +// add et2- prefix to following widgets/tags +/* disabling v/hbox replacement for now as it fails with nextmatch headers +const ADD_ET2_PREFIX_REGEXP = '#(\s|^|>)<((/?)([vh]?box|button))(\s|/?>)#m';*/ +const ADD_ET2_PREFIX_REGEXP = '#(\s|^|>)<((/?)(box|button))(\s|/?>)#m'; +const ADD_ET2_PREFIX_REPLACE = '$1<$3et2-$4$5'; + +// 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' => 'api', + 'noheader' => true, + // misuse session creation callback to send the template, in case we have no session + 'autocreate_session_callback' => 'send_template', + 'nocachecontrol' => true, + ) +); + +$start = microtime(true); +include '../header.inc.php'; + +send_template(); + +function send_template() +{ + $header_include = microtime(true); + + // release session, as we don't need it and it blocks parallel requests + $GLOBALS['egw']->session->commit_session(); + + header('Content-Type: application/xml; charset=UTF-8'); + + //$path = EGW_SERVER_ROOT.$_SERVER['PATH_INFO']; + // check for customized template in VFS + list(, $app, , $template, $name) = explode('/', $_SERVER['PATH_INFO']); + $path = Api\Etemplate::rel2path(Api\Etemplate::relPath($app.'.'.basename($name, '.xet'), $template)); + if (empty($path) || !file_exists($path) || !is_readable($path)) + { + http_response_code(404); + exit; + } + /* disable caching for now, as you need to delete the cache, once you change ADD_ET2_PREFIX_REGEXP + $cache = $GLOBALS['egw_info']['server']['temp_dir'].'/egw_cache/eT2-Cache-'.$GLOBALS['egw_info']['server']['install_id'].$_SERVER['PATH_INFO']; + if (file_exists($cache) && filemtime($cache) > filemtime($path) && + ($str = file_get_contents($cache)) !== false) + { + $cache_read = microtime(true); + } + else*/if (($str = file_get_contents($path)) !== false) + { + // fix -->