Commit b3c96c60 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Evaluate.php, QuickFormQuery.php: 1) split exception in user/support, 2) start...

Evaluate.php, QuickFormQuery.php: 1) split exception in user/support, 2) start to implement that '!' in '{{!...' is not necessary anymore. Implemented for 'fillStoreVar' in FE Action elements.
parent 0df4c49d
Pipeline #1100 passed with stage
in 1 minute and 45 seconds
......@@ -99,7 +99,7 @@ class Evaluate {
} else {
$value = Support::handleEscapeSpaceComment($value);
$arr[$key] = $this->parse($value, 0, $debugStack);
$arr[$key] = $this->parse($value, ROW_IMPLODE_ALL, 0, $debugStack);
}
}
......@@ -112,7 +112,8 @@ class Evaluate {
*
* Token to replace have to be enclosed by '{{' and '}}'
*
* @param $line
* @param string $line
* @param string $sqlMode ROW_IMPLODE | ROW_REGULAR - might be overwritten in $line by '{{!...'
* @param int $recursion
*
* @param array $debugStack
......@@ -123,7 +124,7 @@ class Evaluate {
* @throws UserFormException
* @throws UserReportException
*/
public function parse($line, $recursion = 0, &$debugStack = array(), &$foundInStore = '') {
public function parse($line, $sqlMode = ROW_IMPLODE_ALL, $recursion = 0, &$debugStack = array(), &$foundInStore = '') {
$flagTokenReplaced = false;
if ($recursion > 4) {
......@@ -154,7 +155,7 @@ class Evaluate {
$post = substr($result, $posFirstClose + $this->endDelimiterLength);
$match = substr($result, $posMatchOpen + $this->startDelimiterLength, $posFirstClose - $posMatchOpen - $this->startDelimiterLength);
$evaluated = $this->substitute($match, $foundInStore);
$evaluated = $this->substitute($match, $foundInStore, $sqlMode);
// newline
$debugLocal[] = '';
......@@ -182,7 +183,7 @@ class Evaluate {
// More to substitute in the new evaluated result? Start recursion just with the new result..
if (strpos($evaluated, $this->endDelimiter) !== false) {
$evaluated = $this->parse($evaluated, $recursion + 1, $debugLocal, $foundInStore);
$evaluated = $this->parse($evaluated, ROW_IMPLODE_ALL, $recursion + 1, $debugLocal, $foundInStore);
}
}
$result = $pre . $evaluated . $post;
......@@ -196,7 +197,7 @@ class Evaluate {
if (is_array($result)) {
$str = "array(" . count($result) . ")";
} else {
$str = "$result";
$str = "$result";
}
$debugLocal[] = $debugIndent . "FINAL: " . $str;
......@@ -269,8 +270,8 @@ class Evaluate {
* If neither a) or b) match, return the token itself.
*
* @param string $token
* @param string $foundInStore Returns the name of the store where $key has been found. If $key is not found,
* return ''.
* @param string $foundInStore Returns the name of the store where $key has been found. If $key is not found, return ''.
* @param string $sqlMode - ROW_IMPLODE | ROW_REGULAR - might be overwritten in $line by '{{!...'
*
* @return array|null|string
* @throws CodeException
......@@ -278,8 +279,7 @@ class Evaluate {
* @throws UserFormException
* @throws UserReportException
*/
public function substitute($token, &$foundInStore = '') {
$sqlMode = ROW_IMPLODE_ALL;
public function substitute($token, &$foundInStore = '', $sqlMode = ROW_IMPLODE_ALL) {
$token = trim($token);
$dbIndex = $this->dbIndex;
......@@ -287,7 +287,9 @@ class Evaluate {
// Check if the $token starts with '[<int>]...' - yes: open the necessary database.
if (strlen($token) > 2 && $token[0] === '[') {
if ($token[2] !== ']') {
throw new UserFormException("Missing token ']' in '$token' on position 3", ERROR_TOKEN_MISSING);
throw new UserFormException(json_encode(
[ERROR_MESSAGE_TO_USER => "Missing token ']' on position 3",
ERROR_MESSAGE_SUPPORT => "In string '$token'"]), ERROR_TOKEN_MISSING);
}
$dbIndex = $token[1];
$token = trim(substr($token, 3));
......
......@@ -1086,7 +1086,7 @@ class QuickFormQuery {
}
$storeFormName = $this->store->getVar(SIP_FORM, $store, '', $foundInStore);
$formName = $this->eval->parse($storeFormName, 0, $dummy, $foundInStore);
$formName = $this->eval->parse($storeFormName, ROW_IMPLODE_ALL, 0, $dummy, $foundInStore);
// If the formname is empty or if 'form' has not been found in any store: no form.
if ($formName === '' || $foundInStore === '') {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment