@ -1048,32 +1048,45 @@ EOF;
*/
protected function parse_conditions($input)
{
$matches = preg_split('/< roundcube: ( if | elseif | else | endif ) \ s + ( [ ^ > ]+)>\n?/is', $input, 2, PREG_SPLIT_DELIM_CAPTURE);
while (preg_match('/< roundcube:if \ s + [ ^ > ]+>(((?!< roundcube: ( if | endif ) ) . ) * ) < roundcube:endif [ ^ > ]*>/is', $input, $conditions)) {
$result = $this->eval_condition($conditions[0]);
$input = str_replace($conditions[0], $result, $input);
}
return $input;
}
/**
* Process & evaluate conditional tags
*/
protected function eval_condition($input)
{
$matches = preg_split('/< roundcube: ( if | elseif | else | endif ) \ s * ( [ ^ > ]*)>\n?/is', $input, 2, PREG_SPLIT_DELIM_CAPTURE);
if ($matches & & count($matches) == 4) {
if (preg_match('/^(else|endif)$/i', $matches[1])) {
return $matches[0] . $this->parse_conditions($matches[3]);
return $matches[0] . $this->eval_condition ($matches[3]);
}
$attrib = html::parse_attrib_string($matches[2]);
if (isset($attrib['condition'])) {
$condmet = $this->check_condition($attrib['condition']);
$submatches = preg_split('/< roundcube: ( elseif | else | endif ) \ s + ( [ ^ > ]+)>\n?/is', $matches[3], 2, PREG_SPLIT_DELIM_CAPTURE);
$condpart s = preg_split('/< roundcube: ( ( elseif | else | endif ) [^ > ]* )>\n?/is', $matches[3], 2, PREG_SPLIT_DELIM_CAPTURE);
if ($condmet) {
$result = $submatches[0];
if ($submatches[1 ] != 'endif') {
$result .= preg_replace('/.*< roundcube:endif \s + [ ^ > ]+>\n?/Uis', '', $submatche s[3], 1);
$result = $condpart s[0];
if ($condparts[2 ] != 'endif') {
$result .= preg_replace('/.*< roundcube:endif [^ > ]*>\n?/Uis', '', $condpart s[3], 1);
}
else {
$result .= $submatche s[3];
$result .= $condpart s[3];
}
}
else {
$result = "< roundcube: $ submatches[ 1 ] $ submatches [ 2 ] > " . $submatche s[3];
$result = "< roundcube: $ condparts[ 1 ] > " . $condpart s[3];
}
return $matches[0] . $this->parse_conditions ($result);
return $matches[0] . $this->eval_condition ($result);
}
rcube::raise_error(array(