/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 dirname(__DIR__).'/header.inc.php'; send_template(); /** * Give usage plus option error and exit * * @param string $prog * @param string? $err * @return void */ function usage($prog, $err=null) { error_log("Usage: $prog [(-i|--in-place)] \n"); error_log("\t convert to new syntax and output or replace it in-place.\n\n"); if ($err) error_log("$err\n\n"); exit; } function send_template() { $header_include = microtime(true); if (PHP_SAPI === 'cli') { $in_place = false; $args = $_SERVER['argv']; $prog = array_shift($args); while($args[0][0] === '-') { switch($arg = array_shift($args)) { case '-i': case '--in-place': $in_place = true; break; default: usage($prog, "Invalid argument '$arg'!"); } if (count($args) !== 1) { usage($prog); } } $fspath = array_shift($args); if ($fspath[0] !== '/') $fspath = '/'.$fspath; } else { // 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'); $fspath = $_SERVER['PATH_INFO']; } // check for customized template in VFS list(, $app, , $template, $name) = explode('/', $fspath); $path = Api\Etemplate::rel2path(Api\Etemplate::relPath($app . '.' . basename($name, '.xet'), $template)); if(empty($path) || !file_exists($path) || !is_readable($path)) { if (PHP_SAPI === 'cli') { usage("Path '$path' NOT found!"); } else { 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']) . '-' . filemtime($path); if (PHP_SAPI !== 'cli' && 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 --> 1) { $attrs['multiple'] = true; } else { unset($attrs['rows']); } // automatic convert empty_label for multiple=true to a placeholder if (!empty($attrs['empty_label']) && !empty($attrs['multiple'])) { $attrs['placeholder'] = $attrs['empty_label']; unset($attrs['empty_label']); } // type attribute need to go in widget type