From ac0867ab779f0e4dad3d98001355dd8b42c9568a Mon Sep 17 00:00:00 2001 From: ralf Date: Fri, 22 Jul 2022 20:43:09 +0200 Subject: [PATCH] implement et2-searchbox and using it in NM reorganized preprocessor a bit to fix some not replaced size attributes also pass on constructor args in all Et2Url widgets There is still a JS error in new searchbox, causing admin searchbox to not render :( --- api/etemplate.php | 62 +++++++------- api/js/etemplate/Et2Textbox/Et2Password.ts | 4 +- api/js/etemplate/Et2Textbox/Et2Searchbox.ts | 81 +++++++++++++++++++ api/js/etemplate/Et2Url/Et2Url.ts | 5 +- api/js/etemplate/Et2Url/Et2UrlEmail.ts | 5 +- .../etemplate/Et2Url/Et2UrlEmailReadonly.ts | 5 -- api/js/etemplate/Et2Url/Et2UrlFax.ts | 5 +- api/js/etemplate/Et2Url/Et2UrlFaxReadonly.ts | 5 -- api/js/etemplate/Et2Url/Et2UrlPhone.ts | 5 +- .../etemplate/Et2Url/Et2UrlPhoneReadonly.ts | 5 -- api/js/etemplate/Et2Url/Et2UrlReadonly.ts | 5 -- api/js/etemplate/et2_extension_nextmatch.ts | 9 ++- api/js/etemplate/etemplate2.ts | 1 + 13 files changed, 133 insertions(+), 64 deletions(-) create mode 100644 api/js/etemplate/Et2Textbox/Et2Searchbox.ts diff --git a/api/etemplate.php b/api/etemplate.php index 4f6917fa3e..4b079ec5a4 100644 --- a/api/etemplate.php +++ b/api/etemplate.php @@ -13,11 +13,12 @@ use EGroupware\Api; // add et2- prefix to following widgets/tags, if NO <]*)expose_view="true"\s([^><]*)\\/>/', '', $str); + // fix --> + $str = preg_replace('##', '', $str); + + // fix <(textbox|int(eger)?|float) precision="int(eger)?|float" .../> --> or + $str = preg_replace_callback('#<(textbox|int(eger)?|float|number).*?\s(type="(int(eger)?|float)")?.*?(/|>#', + static function ($matches) + { + if ($matches[1] === 'textbox' && !in_array($matches[4], ['float', 'int', 'integer'], true)) + { + return ''; // regular textbox --> nothing to do + } + $type = $matches[1] === 'float' || $matches[4] === 'float' ? 'float' : 'int'; + $tag = str_replace('<' . $matches[1], ''; + }, $str); + // modify <(vfs-mime|link-string|link-list) --> ', + $str = preg_replace(ADD_ET2_PREFIX_LEGACY_REGEXP, '', str_replace('', '', $str)); // change link attribute only_app to et2-link attribute app and map r/o link-entry to link @@ -278,33 +297,6 @@ function send_template() } 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 -->