Commit 5aee0e86 authored by Carsten  Rose's avatar Carsten Rose

Merge branch 'master' into F5695-Multiform

parents 34be39d7 6d9b9daf
...@@ -6893,6 +6893,21 @@ Output:: ...@@ -6893,6 +6893,21 @@ Output::
hello world- hello world-
.. _strip_tags:
strip_tags: strip html tags
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The SQL function strip_tags(input) returns 'input' without any HTML tags.
Example::
10.sql = SELECT strip_tags('<a href="https://example.com"><b>my name</b> <i>is john</i></a> - end of sentence')
Output::
my name is john - end of sentence
.. _download: .. _download:
Download Download
...@@ -8323,7 +8338,7 @@ has the form be used. The following report includes the regular `form-editor`_ a ...@@ -8323,7 +8338,7 @@ has the form be used. The following report includes the regular `form-editor`_ a
# All forms # All forms
sql = SELECT CONCAT('p:{{pageAlias:T}}&form=Form&r=', f.id) as _pagee sql = SELECT CONCAT('p:{{pageAlias:T}}&form=Form&r=', f.id) as _pagee
, CONCAT(f.name, ' <span class="text-muted">(', f.id, ')</span>') , CONCAT(f.name, ' <span class="text-muted">(', f.id, ')</span>')
, QMORE(f.title,50) , QMORE(strip_tags(f.title),50)
, f.tableName , f.tableName
, CONCAT('p:{{pageAlias:T}}&formIdHistory=', f.id, '|s|b|t:<span class="badge">', COUNT(fsl.id), '</span>' , CONCAT('p:{{pageAlias:T}}&formIdHistory=', f.id, '|s|b|t:<span class="badge">', COUNT(fsl.id), '</span>'
, IF(COUNT(fsl.id)=0, '|r:3','') ) as _link , IF(COUNT(fsl.id)=0, '|r:3','') ) as _link
......
...@@ -61,6 +61,7 @@ class DownloadPage { ...@@ -61,6 +61,7 @@ class DownloadPage {
'method' => "GET", 'method' => "GET",
'header' => "Accept-language: en\r\n" . 'header' => "Accept-language: en\r\n" .
"Cookie: " . SESSION_NAME . "=" . $_COOKIE[SESSION_NAME] . "\r\n", "Cookie: " . SESSION_NAME . "=" . $_COOKIE[SESSION_NAME] . "\r\n",
'timeout' => 600,
), ),
); );
$ctx = array_merge($ctx,$cookie); $ctx = array_merge($ctx,$cookie);
......
...@@ -373,6 +373,12 @@ class QuickFormQuery { ...@@ -373,6 +373,12 @@ class QuickFormQuery {
case FORM_REST: case FORM_REST:
$fillStoreForm = new FillStoreForm(); $fillStoreForm = new FillStoreForm();
$fillStoreForm->process($formMode); $fillStoreForm->process($formMode);
// STORE_TYPO3 has been filled: fire fillStoreVar again.
if (!empty($this->formSpec[FE_FILL_STORE_VAR])) {
$this->fillStoreVar($this->formSpec[FE_FILL_STORE_VAR]);
}
break; break;
} }
...@@ -1078,21 +1084,8 @@ class QuickFormQuery { ...@@ -1078,21 +1084,8 @@ class QuickFormQuery {
// Fire FE_FILL_STORE_VAR after the primary form record has been loaded // Fire FE_FILL_STORE_VAR after the primary form record has been loaded
if (!empty($formSpec[FE_FILL_STORE_VAR])) { if (!empty($formSpec[FE_FILL_STORE_VAR])) {
$this->fillStoreVar($formSpec[FE_FILL_STORE_VAR]);
$rows = $this->evaluate->parse($formSpec[FE_FILL_STORE_VAR], ROW_EXPECT_0_1); // unset($formSpec[FE_FILL_STORE_VAR]);
unset($formSpec[FE_FILL_STORE_VAR]);
if (is_array($rows)) {
$this->store->appendToStore($rows, STORE_VAR);
// LOG
if (!empty($form[FORM_LOG_ACTIVE])) {
Logger::logFormLine($form, "F:add to STORE_VAR", $rows);
}
} else {
if (!empty($rows)) {
throw new \UserFormException("Invalid statement for '" . FE_FILL_STORE_VAR . "': " . $formSpec[FE_FILL_STORE_VAR], ERROR_INVALID_OR_MISSING_PARAMETER);
}
}
} }
$this->formSpec = $formSpec; $this->formSpec = $formSpec;
...@@ -1136,6 +1129,36 @@ class QuickFormQuery { ...@@ -1136,6 +1129,36 @@ class QuickFormQuery {
return $formName; return $formName;
} }
/**
* If $sql selects one row, append the row to STORE_VAR.
*
* @param $sql
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
* @throws \UserReportException
*/
private function fillStoreVar($sql) {
if (empty($sql)) {
return;
}
$rows = $this->evaluate->parse($sql, ROW_EXPECT_0_1);
if (is_array($rows)) {
$this->store->appendToStore($rows, STORE_VAR);
// LOG
if (!empty($form[FORM_LOG_ACTIVE])) {
Logger::logFormLine($form, "F:add to STORE_VAR", $rows);
}
} else {
if (!empty($rows)) {
throw new \UserFormException("Invalid statement for '" . FE_FILL_STORE_VAR . "': " . $formSpec[FE_FILL_STORE_VAR], ERROR_INVALID_OR_MISSING_PARAMETER);
}
}
}
/** /**
* Depending on $sql reads FormElements to a specific container or all. Preprocess all FormElements. * Depending on $sql reads FormElements to a specific container or all. Preprocess all FormElements.
* This code is dirty: the nearly same function exists in class 'Database' - the difference is only * This code is dirty: the nearly same function exists in class 'Database' - the difference is only
......
...@@ -8,12 +8,11 @@ ...@@ -8,12 +8,11 @@
namespace IMATHUZH\Qfq\Core\Store; namespace IMATHUZH\Qfq\Core\Store;
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser; use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray; use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Sanitize; use IMATHUZH\Qfq\Core\Helper\Sanitize;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Helper\Support; use IMATHUZH\Qfq\Core\Helper\Support;
/* /*
...@@ -790,15 +789,17 @@ class Store { ...@@ -790,15 +789,17 @@ class Store {
$sipArray = self::getStore(STORE_SIP); $sipArray = self::getStore(STORE_SIP);
foreach ($sipArray as $key => $value) { foreach ($sipArray as $key => $value) {
if ($key[0] === '_') { if ($key[0] === '_') {
continue; continue;
} }
switch ($key) { switch ($key) {
case SIP_SIP: case SIP_SIP:
case SIP_RECORD_ID: case SIP_RECORD_ID:
case SIP_FORM; case SIP_FORM;
case SIP_URLPARAM: case SIP_URLPARAM:
continue; continue 2;
default: default:
$tmpParam[$key] = $value; $tmpParam[$key] = $value;
} }
......
...@@ -83,3 +83,23 @@ BEGIN ...@@ -83,3 +83,23 @@ BEGIN
SET output = IF(input = '', token, input); SET output = IF(input = '', token, input);
RETURN output; RETURN output;
END; END;
###
#
# strip_tags(input) - copied from https://stackoverflow.com/questions/2627940/remove-html-tags-from-record
#
DROP FUNCTION IF EXISTS strip_tags;
CREATE FUNCTION `strip_tags`(str TEXT)
RETURNS TEXT
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DECLARE start, end INT DEFAULT 1;
LOOP
SET start = LOCATE("<", str, start);
IF (!start) THEN RETURN str; END IF;
SET end = LOCATE(">", str, start);
IF (!end) THEN SET end = start; END IF;
SET str = INSERT(str, start, end - start + 1, "");
END LOOP;
END;
\ No newline at end of file
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