/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, if NO array( 'currentapp' => 'api', 'noheader' => true, // miss-use 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; } $cache = $GLOBALS['egw_info']['server']['temp_dir'].'/egw_cache/eT2-Cache-'. $GLOBALS['egw_info']['server']['install_id'].'-'.str_replace('/', '-', $_SERVER['PATH_INFO']); if (file_exists($cache) && filemtime($cache) > max(filemtime($path), filemtime(__FILE__)) && ($str = file_get_contents($cache)) !== false) { $cache_read = microtime(true); } elseif(($str = file_get_contents($path)) !== false) { // replace single quote enclosing attribute values with double quotes $str = preg_replace_callback("#([a-z_-]+)='([^']*)'([ />])#i", static function($matches){ return $matches[1].'="'.str_replace('"', '"', $matches[2]).'"'.$matches[3]; }, $str); // fix --> '.$matches[5].''; return $replace; }, $str); // nextmatch headers $str = preg_replace_callback('#<(nextmatch-)([^ ]+)(header|filter) ([^>]+?)/>#s', static function (array $matches) { preg_match_all('/(^|\s)([a-z0-9_-]+)="([^"]*)"/i', $matches[4], $attrs, PREG_PATTERN_ORDER); $attrs = array_combine($attrs[2], $attrs[3]); if ($matches[2] === 'custom') { $attrs['widget_type'] = $attrs['type']; } if(!$matches[2] || in_array($matches[2], ['sort']) || ($matches[2] == "custom" && empty($attrs['widget_type']))) { return $matches[0]; } // No longer needed & type causes problems unset($attrs['type'], $attrs['tags']); if($matches[2] === 'taglist') { $matches[2] = "filter"; } $replace = ''; return $replace; }, $str); // ^^^^^^^^^^^^^^^^ above widgets get transformed independent of legacy="true" set in overlay ^^^^^^^^^^^^^^^^^^ // eTemplate marked as legacy --> replace only some widgets (eg. requiring jQueryUI) with web-components if (preg_match('/]* legacy="true"/', $str)) { $str = preg_replace_callback('#]+)/>#', static function($matches) { if ($matches[1] === 'date-time_today') $matches[1] = 'date-time-today'; return ""; }, $str); } else { // fix deprecated attributes: needed, blur, ... static $deprecated = [ 'needed' => 'required', 'blur' => 'placeholder', ]; $str = preg_replace_callback('#<[^ ]+[^>]* (' . implode('|', array_keys($deprecated)) . ')="([^"]+)"[ />]#', static function ($matches) use ($deprecated) { return str_replace($matches[1] . '="', $deprecated[$matches[1]] . '="', $matches[0]); }, $str); // fix -->