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

B2340 Report: Problematic Bracket - form now on, only ''{[(<'' will change the nesting token.

parent 2109e086
Pipeline #849 passed with stage
in 1 minute and 38 seconds
...@@ -35,13 +35,37 @@ require_once(__DIR__ . '/report/Report.php'); ...@@ -35,13 +35,37 @@ require_once(__DIR__ . '/report/Report.php');
* @package qfq * @package qfq
*/ */
abstract class AbstractBuildForm { abstract class AbstractBuildForm {
/**
* @var array
*/
protected $formSpec = array(); // copy of the loaded form protected $formSpec = array(); // copy of the loaded form
/**
* @var array
*/
protected $feSpecAction = array(); // copy of all formElement.class='action' of the loaded form protected $feSpecAction = array(); // copy of all formElement.class='action' of the loaded form
/**
* @var array
*/
protected $feSpecNative = array(); // copy of all formElement.class='native' of the loaded form protected $feSpecNative = array(); // copy of all formElement.class='native' of the loaded form
/**
* @var array
*/
protected $buildElementFunctionName = array(); protected $buildElementFunctionName = array();
/**
* @var array
*/
protected $pattern = array(); protected $pattern = array();
/**
* @var array
*/
protected $wrap = array(); protected $wrap = array();
/**
* @var array
*/
protected $symbol = array(); protected $symbol = array();
/**
* @var bool
*/
protected $showDebugInfoFlag = false; protected $showDebugInfoFlag = false;
// protected $feDivClass = array(); // Wrap FormElements in <div class="$feDivClass[type]"> // protected $feDivClass = array(); // Wrap FormElements in <div class="$feDivClass[type]">
...@@ -80,7 +104,13 @@ abstract class AbstractBuildForm { ...@@ -80,7 +104,13 @@ abstract class AbstractBuildForm {
*/ */
protected $dbArray = array(); protected $dbArray = array();
/**
* @var bool|mixed
*/
protected $dbIndexData = false; protected $dbIndexData = false;
/**
* @var bool|string
*/
protected $dbIndexQfq = false; protected $dbIndexQfq = false;
/** /**
...@@ -183,8 +213,12 @@ abstract class AbstractBuildForm { ...@@ -183,8 +213,12 @@ abstract class AbstractBuildForm {
* formElement.dynamicUpdate-yes values/states * formElement.dynamicUpdate-yes values/states
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public function process($mode, $htmlElementNameIdZero = false, $latestFeSpecNative = array()) { public function process($mode, $htmlElementNameIdZero = false, $latestFeSpecNative = array()) {
$htmlHead = ''; $htmlHead = '';
...@@ -493,9 +527,12 @@ abstract class AbstractBuildForm { ...@@ -493,9 +527,12 @@ abstract class AbstractBuildForm {
* @return array|string * @return array|string
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
* @throws DownloadException * @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
private function processReportSyntax($value) { private function processReportSyntax($value) {
...@@ -544,8 +581,12 @@ abstract class AbstractBuildForm { ...@@ -544,8 +581,12 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0, array &$json, public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0, array &$json,
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false, $modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false,
...@@ -1049,6 +1090,7 @@ abstract class AbstractBuildForm { ...@@ -1049,6 +1090,7 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function deriveNewRecordUrlFromExistingSip(&$toolTipNew) { public function deriveNewRecordUrlFromExistingSip(&$toolTipNew) {
...@@ -1114,6 +1156,7 @@ abstract class AbstractBuildForm { ...@@ -1114,6 +1156,7 @@ abstract class AbstractBuildForm {
* @return string complete rendered HTML input element. * @return string complete rendered HTML input element.
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function buildInput(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public function buildInput(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$textarea = ''; $textarea = '';
...@@ -1446,6 +1489,7 @@ abstract class AbstractBuildForm { ...@@ -1446,6 +1489,7 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function buildCheckbox(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public function buildCheckbox(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$itemKey = array(); $itemKey = array();
...@@ -2048,6 +2092,7 @@ abstract class AbstractBuildForm { ...@@ -2048,6 +2092,7 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function buildRadio(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public function buildRadio(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
...@@ -2269,6 +2314,7 @@ abstract class AbstractBuildForm { ...@@ -2269,6 +2314,7 @@ abstract class AbstractBuildForm {
* @return mixed * @return mixed
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function buildSelect(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public function buildSelect(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$itemKey = array(); $itemKey = array();
...@@ -2337,7 +2383,8 @@ abstract class AbstractBuildForm { ...@@ -2337,7 +2383,8 @@ abstract class AbstractBuildForm {
/** /**
* @param string $linkNew Complete Button, incl. SIP href * @param string $linkNew Complete Button, incl. SIP href
* @param string $deleteColumnTitle - if null, no delete column is rendered * @param $flagDelete
* @param $deleteTitle
* @param array $firstRow First row of all subrecords to extract columntitles * @param array $firstRow First row of all subrecords to extract columntitles
* @param array $control Array with <th> column names / format. * @param array $control Array with <th> column names / format.
* *
...@@ -2376,6 +2423,7 @@ abstract class AbstractBuildForm { ...@@ -2376,6 +2423,7 @@ abstract class AbstractBuildForm {
* *
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws DbException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
...@@ -3132,6 +3180,7 @@ abstract class AbstractBuildForm { ...@@ -3132,6 +3180,7 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function buildDateTime(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public function buildDateTime(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
...@@ -3329,6 +3378,7 @@ abstract class AbstractBuildForm { ...@@ -3329,6 +3378,7 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function buildEditor(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public function buildEditor(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
...@@ -3517,6 +3567,7 @@ abstract class AbstractBuildForm { ...@@ -3517,6 +3567,7 @@ abstract class AbstractBuildForm {
* @return mixed * @return mixed
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
...@@ -3587,6 +3638,7 @@ abstract class AbstractBuildForm { ...@@ -3587,6 +3638,7 @@ abstract class AbstractBuildForm {
* @return mixed * @return mixed
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
...@@ -3703,6 +3755,7 @@ EOT; ...@@ -3703,6 +3755,7 @@ EOT;
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
......
...@@ -111,26 +111,30 @@ class BodytextParser { ...@@ -111,26 +111,30 @@ class BodytextParser {
return; return;
} }
$pos = 0;
$tokenList = '{}<>[]()';
// Definition: first line of bodytext, has to be a comment line. If the last char is one of the valid token: set that one. // Definition: first line of bodytext, has to be a comment line. If the last char is one of the valid token: set that one.
// Nothing found: set {}. // Nothing found: set {}.
$nestingOpen = '{';
$nestingClose = '}';
if ($firstLine[0] === '#') { if ($firstLine[0] === '#') {
$token = substr($firstLine, -1); $token = substr($firstLine, -1);
$pos = strpos($tokenList, $token); switch($token) {
if ($pos === false) { case '<':
$pos = 0; $nestingOpen = '<';
} else { $nestingClose = '>';
if ($pos % 2 === 1) { break;
$pos -= 1; case '[':
} $nestingOpen = '[';
$nestingClose = ']';
break;
case '(':
$nestingOpen = '(';
$nestingClose = ')';
break;
default:
break;
} }
} }
$nestingOpen = substr($tokenList, $pos, 1);
$nestingClose = substr($tokenList, $pos + 1, 1);
} }
/** /**
......
...@@ -574,6 +574,7 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -574,6 +574,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function tail() { public function tail() {
...@@ -654,8 +655,12 @@ EOF; ...@@ -654,8 +655,12 @@ EOF;
* @return mixed * @return mixed
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) { public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
$html = ''; $html = '';
......
...@@ -65,7 +65,9 @@ class BuildFormPlain extends AbstractBuildForm { ...@@ -65,7 +65,9 @@ class BuildFormPlain extends AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function doSubrecords() { public function doSubrecords() {
$json = array(); $json = array();
......
...@@ -68,7 +68,9 @@ class BuildFormTable extends AbstractBuildForm { ...@@ -68,7 +68,9 @@ class BuildFormTable extends AbstractBuildForm {
* @return string * @return string
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function doSubrecords() { public function doSubrecords() {
//TODO: $json is not returned - which is wrong. In this case, dynamic update won't work for subrecords //TODO: $json is not returned - which is wrong. In this case, dynamic update won't work for subrecords
...@@ -83,6 +85,7 @@ class BuildFormTable extends AbstractBuildForm { ...@@ -83,6 +85,7 @@ class BuildFormTable extends AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function head($mode = FORM_LOAD) { public function head($mode = FORM_LOAD) {
$html = ''; $html = '';
......
...@@ -34,6 +34,7 @@ class Delete { ...@@ -34,6 +34,7 @@ class Delete {
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function __construct($dbIndexData = false, $phpUnit = false) { public function __construct($dbIndexData = false, $phpUnit = false) {
......
...@@ -227,6 +227,9 @@ class QuickFormQuery { ...@@ -227,6 +227,9 @@ class QuickFormQuery {
* @throws DownloadException * @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public function process() { public function process() {
$html = ''; $html = '';
...@@ -285,7 +288,7 @@ class QuickFormQuery { ...@@ -285,7 +288,7 @@ class QuickFormQuery {
* *
* @param $formName * @param $formName
* @param $formLogMode * @param $formLogMode
* @return * @return string
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
...@@ -1360,6 +1363,9 @@ class QuickFormQuery { ...@@ -1360,6 +1363,9 @@ class QuickFormQuery {
* @throws DownloadException * @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
private function doReport() { private function doReport() {
...@@ -1378,10 +1384,7 @@ class QuickFormQuery { ...@@ -1378,10 +1384,7 @@ class QuickFormQuery {
* *
* @return string - the html code * @return string - the html code
* @throws CodeException * @throws CodeException
* @throws DbException
* @throws DownloadException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
private function buildInlineReport() { private function buildInlineReport() {
$uid = $this->t3data[T3DATA_UID]; $uid = $this->t3data[T3DATA_UID];
......
...@@ -541,7 +541,9 @@ class Save { ...@@ -541,7 +541,9 @@ class Save {
* *
* @return false|string New pathFilename or false on error * @return false|string New pathFilename or false on error
* @throws CodeException * @throws CodeException
* @throws DbException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
* @internal param $recordId * @internal param $recordId
*/ */
private function doUpload($formElement, $sipUpload, Sip $sip, &$modeUpload) { private function doUpload($formElement, $sipUpload, Sip $sip, &$modeUpload) {
......
...@@ -783,6 +783,7 @@ class Database { ...@@ -783,6 +783,7 @@ class Database {
* @param $mode * @param $mode
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws UserFormException
*/ */
public function createTable($table, $columnDefinition, $mode) { public function createTable($table, $columnDefinition, $mode) {
......
...@@ -56,6 +56,9 @@ class Dirty { ...@@ -56,6 +56,9 @@ class Dirty {
* @param bool $dbIndexData * @param bool $dbIndexData
* @param bool $dbIndexQfq * @param bool $dbIndexQfq
* @throws CodeException * @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/ */
public function __construct($phpUnit = false, $dbIndexData = false, $dbIndexQfq = false) { public function __construct($phpUnit = false, $dbIndexData = false, $dbIndexQfq = false) {
...@@ -71,6 +74,10 @@ class Dirty { ...@@ -71,6 +74,10 @@ class Dirty {
/** /**
* @param $dbIndexData * @param $dbIndexData
* @param $dbIndexQfq * @param $dbIndexQfq
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/ */
private function doDbArray($dbIndexData, $dbIndexQfq) { private function doDbArray($dbIndexData, $dbIndexQfq) {
...@@ -95,6 +102,7 @@ class Dirty { ...@@ -95,6 +102,7 @@ class Dirty {
* @throws CodeException * @throws CodeException
* @throws DbException * @throws DbException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function process() { public function process() {
...@@ -144,7 +152,6 @@ class Dirty { ...@@ -144,7 +152,6 @@ class Dirty {
* *
* @return array * @return array
* @throws CodeException * @throws CodeException
* @throws DbException
*/ */
private function acquireDirty($recordId, array $tableVars, $recordHashMd5) { private function acquireDirty($recordId, array $tableVars, $recordHashMd5) {
...@@ -277,8 +284,6 @@ class Dirty { ...@@ -277,8 +284,6 @@ class Dirty {
* @param int $recordId * @param int $recordId
* @param string $recordHashMd5 - timestamp e.g. '2017-07-27 14:06:56' * @param string $recordHashMd5 - timestamp e.g. '2017-07-27 14:06:56'
* @param $rcMd5 * @param $rcMd5
* @param string $tableId
*
* @return bool true if $recordHashMd5 is different from current record md5 hash. * @return bool true if $recordHashMd5 is different from current record md5 hash.
*/ */
private function isRecordModified($tableName, $recordId, $recordHashMd5, &$rcMd5) { private function isRecordModified($tableName, $recordId, $recordHashMd5, &$rcMd5) {
...@@ -304,7 +309,6 @@ class Dirty { ...@@ -304,7 +309,6 @@ class Dirty {
* *
* @return int LOCK_NOT_FOUND | LOCK_FOUND_OWNER | LOCK_FOUND_CONFLICT, * @return int LOCK_NOT_FOUND | LOCK_FOUND_OWNER | LOCK_FOUND_CONFLICT,
* @throws CodeException * @throws CodeException
* @throws DbException
*/ */
public function getCheckDirty($tableName, $recordId, array &$recordDirty, &$msg) { public function getCheckDirty($tableName, $recordId, array &$recordDirty, &$msg) {
...@@ -349,7 +353,6 @@ class Dirty { ...@@ -349,7 +353,6 @@ class Dirty {
* @param bool $flagCheckModifiedFirst * @param bool $flagCheckModifiedFirst
* @return array * @return array
* @throws CodeException * @throws CodeException
* @throws DbException
* @throws UserFormException * @throws UserFormException
*/ */
public function checkDirtyAndRelease($formMode, $lockTimeout, $dirtyMode, $tableName, $recordId, $flagCheckModifiedFirst = false) { public function checkDirtyAndRelease($formMode, $lockTimeout, $dirtyMode, $tableName, $recordId, $flagCheckModifiedFirst = false) {
......
...@@ -48,6 +48,7 @@ class FormAction { ...@@ -48,6 +48,7 @@ class FormAction {
* @param bool|false $phpUnit * @param bool|false $phpUnit
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
* @throws UserReportException
*/ */
public function __construct(array $formSpec, Database $db, $phpUnit = false) { public function __construct(array $formSpec, Database $db, $phpUnit = false) {
$this->formSpec = $formSpec; $this->formSpec = $formSpec;
...@@ -252,6 +253,9 @@ class FormAction { ...@@ -252,6 +253,9 @@ class FormAction {
* @throws DownloadException * @throws DownloadException
* @throws UserFormException * @throws UserFormException