inject preprocessor and (daily) cache-buster for templates in dialog widget

also allow for a xml comment inside the deprecated menulist tag
fixes Admin ACL popup
This commit is contained in:
ralf 2022-07-27 17:53:56 +02:00
parent 77b475b5e6
commit 38721229b0
2 changed files with 13 additions and 2 deletions

View File

@ -71,7 +71,7 @@ function send_template()
}, $str); }, $str);
// fix <menulist...><menupopup type="select-*"/></menulist> --> <select type="select-*" .../> // fix <menulist...><menupopup type="select-*"/></menulist> --> <select type="select-*" .../>
$str = preg_replace('#<menulist([^>]*)>[\r\n\s]*<menupopup([^>]+>)[\r\n\s]*</menulist>#', '<select$1$2', $str); $str = preg_replace('#<menulist([^>]*)>[\r\n\s]*(<!--[^>]+-->[\r\n\s]*)?<menupopup([^>]+>)[\r\n\s]*</menulist>#', '$2<select$1$3', $str);
// fix legacy options, so new client-side has not to deal with them // fix legacy options, so new client-side has not to deal with them
$str = preg_replace_callback('#<([^- />]+)(-[^ ]+)?[^>]* (options="([^"]+)")[ />]#', static function ($matches) { $str = preg_replace_callback('#<([^- />]+)(-[^ ]+)?[^>]* (options="([^"]+)")[ />]#', static function ($matches) {

View File

@ -524,6 +524,17 @@ export class Et2Dialog extends Et2Widget(ScopedElementsMixin(SlotMixin(LionDialo
{ {
let old_template = this.__template; let old_template = this.__template;
this.__template = new_template_name; this.__template = new_template_name;
// inject preprocessor, if not already in template-url
const webserverUrl = this.egw().webserverUrl;
if (!new_template_name.match(new RegExp(webserverUrl+'/api/etemplate.php')))
{
this.__template = new_template_name.replace(new RegExp(webserverUrl), webserverUrl+'/api/etemplate.php');
}
// if we have no cache-buster, reload daily
if (this.__template.indexOf('?') === -1)
{
this.__template += '?'+((new Date).valueOf()/86400|0).toString();
}
this.requestUpdate("template", old_template); this.requestUpdate("template", old_template);
} }