deprecated and replace attributes: needed-->required, blur-->placeholder in preprocessor

remove client-side code for them and enable translation of placeholder
This commit is contained in:
ralf 2022-03-05 15:22:45 +02:00
parent 3b896e0919
commit 5ac43d7a5a

View File

@ -67,7 +67,7 @@ function send_template()
$str = preg_replace('#<menulist([^>]*)>[\r\n\s]*<menupopup([^>]+>)[\r\n\s]*</menulist>#', '<select$1$2', $str);
// 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)
{
// take care of (static) type attribute, if used
if (preg_match('/ type="([a-z-]+)"/', $matches[0], $type))
@ -116,6 +116,17 @@ function send_template()
return $matches[0];
}, $str);
// 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 <textbox multiline="true" .../> --> <textarea .../> (et2-prefix and self-closing is handled below)
$str = preg_replace('#<textbox(.*?)\smultiline="true"(.*?)/>#u', '<textarea$1$2/>', $str);