mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
fix error "Can not parse attributes ''" in smallpart.course
thought preprocessor can currently not kope with nested details tags!
This commit is contained in:
parent
d7f8f7d997
commit
06cb34974a
@ -136,7 +136,7 @@ function send_template()
|
|||||||
return $matches[0];
|
return $matches[0];
|
||||||
}, $str);
|
}, $str);
|
||||||
|
|
||||||
// Change details title --> summary
|
// Change details title --> summary (This can currently not kope with nested details like in smallpart.curse.xet
|
||||||
$str = preg_replace_callback('#<details([^>]*?)>(.*?)</details>#su', static function ($matches)
|
$str = preg_replace_callback('#<details([^>]*?)>(.*?)</details>#su', static function ($matches)
|
||||||
{
|
{
|
||||||
$attrs = parseAttrs($matches[1]);
|
$attrs = parseAttrs($matches[1]);
|
||||||
@ -292,7 +292,7 @@ function send_template()
|
|||||||
$matches[2] = preg_replace('/^(select|taglist)/', '', $attrs['type']);
|
$matches[2] = preg_replace('/^(select|taglist)/', '', $attrs['type']);
|
||||||
unset($attrs['type']);
|
unset($attrs['type']);
|
||||||
}
|
}
|
||||||
return '<et2-select' . $matches[2] . ' ' . stringAttrs($attrs) . '>'.$matches[5].'</et2-select' . $matches[2] . '>';
|
return '<et2-select' . $matches[2] . stringAttrs($attrs) . '>'.$matches[5].'</et2-select' . $matches[2] . '>';
|
||||||
}, $str);
|
}, $str);
|
||||||
|
|
||||||
// nextmatch headers
|
// nextmatch headers
|
||||||
@ -316,7 +316,7 @@ function send_template()
|
|||||||
$matches[2] = "filter";
|
$matches[2] = "filter";
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<et2-nextmatch-header-' . $matches[2] . ' ' . stringAttrs($attrs) . '/>';
|
return '<et2-nextmatch-header-' . $matches[2] . stringAttrs($attrs) . '/>';
|
||||||
}, $str);
|
}, $str);
|
||||||
|
|
||||||
// fix <(button|buttononly|timestamper).../> --> <et2-(button|image|button-timestamp) (noSubmit="true")?.../>
|
// fix <(button|buttononly|timestamper).../> --> <et2-(button|image|button-timestamp) (noSubmit="true")?.../>
|
||||||
@ -499,6 +499,10 @@ function send_template()
|
|||||||
*/
|
*/
|
||||||
function parseAttrs($str)
|
function parseAttrs($str)
|
||||||
{
|
{
|
||||||
|
if (empty($str) || !trim($str))
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
if (!preg_match_all('/(^|\s)([a-z\d_-]+)="([^"]*)"/i', $str, $attrs, PREG_PATTERN_ORDER))
|
if (!preg_match_all('/(^|\s)([a-z\d_-]+)="([^"]*)"/i', $str, $attrs, PREG_PATTERN_ORDER))
|
||||||
{
|
{
|
||||||
throw new Exception("Can NOT parse attributes from '$str'");
|
throw new Exception("Can NOT parse attributes from '$str'");
|
||||||
@ -509,12 +513,18 @@ function parseAttrs($str)
|
|||||||
/**
|
/**
|
||||||
* Combine attribute array into a string
|
* Combine attribute array into a string
|
||||||
*
|
*
|
||||||
|
* If there are attributes the returned string is prefixed with a single space, otherwise an empty string is returned.
|
||||||
|
*
|
||||||
* @param array $attrs
|
* @param array $attrs
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function stringAttrs(array $attrs)
|
function stringAttrs(array $attrs)
|
||||||
{
|
{
|
||||||
return implode(' ', array_map(static function ($name, $value) {
|
if (!$attrs)
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return ' '.implode(' ', array_map(static function ($name, $value) {
|
||||||
return $name . '="' . $value . '"';
|
return $name . '="' . $value . '"';
|
||||||
}, array_keys($attrs), $attrs));
|
}, array_keys($attrs), $attrs));
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user