Commit 6b8db18b authored by Carsten  Rose's avatar Carsten Rose
Browse files

Implemented $dbIndex for Report.

parent fb2b15e6
......@@ -25,7 +25,7 @@ General
* Project homepage: https://qfq.io
* Latest releases: https://w3.math.uzh.ch/qfq/
* Development: https://git.math.uzh.ch/typo3/qfq
* Slack: https://qfq-io.slack.com/
.. _installation:
......@@ -219,6 +219,7 @@ Setup CSS & JS
file11 = typo3conf/ext/qfq/Resources/Public/JavaScript/qfq.fabric.min.js
}
.. _form-editor:
FormEditor
......@@ -236,6 +237,9 @@ Setup a *report* to manage all *forms*:
# If there is a form given by SIP: show
form={{form:SE}}
# Only needed if QFQ uses more than one database.
dbIndex = {{DB_INDEX_QFQ:Y}}
10 {
# List of Forms: Do not show this list of forms if there is a form given by SIP.
# Table header.
......@@ -267,6 +271,11 @@ config.qfq.ini
+=============================+=======================================================+============================================================================+
| DB_INIT | DB_INIT=set names utf8 | Global init for using the database. |
+-----------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| DB_UPDATE | DB_UPDATE = auto | 'auto': apply DB Updates only if there is a newer version. |
| | | 'always': apply DB Updates always, especially play formEditor.sql every |
| | | time QFQ is called - *not* recommended! |
| | | 'never': never apply DB Updates. |
+-----------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| DB_<n>_USER | DB_1_USER=qfqUser | Credentials configured in MySQL |
| DB_<n>_PASSWORD | DB_1_PASSWORD=1234567890 | Credentials configured in MySQL |
| DB_<n>_SERVER | DB_1_SERVER=localhost | Hostname of MySQL Server |
......@@ -354,11 +363,6 @@ config.qfq.ini
| NEW_BUTTON_CLASS | NEW_BUTTON_CLASS = btn btn-default navbar-btn | Default Bootstrap CSS class for buttons on top of the form |
| NEW_BUTTON_GLYPH_ICON | NEW_BUTTON_GLYPH_ICON = glyphicon-plus | Default Icon for the form new button |
+-----------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| DB_UPDATE | DB_UPDATE = auto | 'auto': apply DB Updates only if there is a newer version. |
| | | 'always': apply DB Updates always, especially play formEditor.sql every |
| | | time QFQ is called - *not* recommended! |
| | | 'never': never apply DB Updates. |
+-----------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| DIRTY_RECORD_TIMEOUT_SECONDS| DIRTY_RECORD_TIMEOUT_SECONDS = 900 | Timeout for record locking. After this time, a record will be replaced |
+-----------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| DOCUMENTATION_QFQ | DOCUMENTATION_QFQ=http://docs.typo3.org... | Link to the online documentation of QFQ. Every QFQ installation also |
......@@ -400,6 +404,9 @@ Example: *typo3conf/config.qfq.ini*
DB_INIT = set names utf8
; auto | always | never
; DB_UPDATE = auto
; DB_INDEX_DATA = 1
; DB_INDEX_QFQ = 1
......@@ -492,9 +499,6 @@ Example: *typo3conf/config.qfq.ini*
; NEW_BUTTON_CLASS = btn btn-default navbar-btn
; NEW_BUTTON_GLYPH_ICON = glyphicon-plus
; auto | always | never
; DB_UPDATE = auto
; RECORD_LOCK_TIMEOUT_SECONDS = 900
; Local Documentation (doc fits to installed version): typo3conf/ext/qfq/Documentation/html/Manual.html
......@@ -743,13 +747,53 @@ QFQ Keywords (Bodytext)
| sqlLogMode | Overwrites config.qfq.ini: `SQL_LOG_MODE`_ . Only affects `Report`, not `Form`. |
+-------------------+---------------------------------------------------------------------------------+
Databases
---------
.. _`qfq-database`:
QFQ Database
------------
Recommended setup for Typo3 & QFQ Installation is with *two* databases. One for the Typo3 installation and one for QFQ.
A good practice is to name both databases equal, appending the suffix '_t3' and '_db'.
When QFQ is called, it checks for QFQ system tables. If they do not exist or have a lower version than the installed qfq
version, the system tables will be automatically installed or updated.
A Typo3 / QFQ Installation needs at least two databases. One for the Typo3 installation and one for QFQ.
.. _`system-tables`:
QFQ itself can be separated in 'QFQ system' and 'QFQ data' databases, if necessary (than at least three databases are needed).
Furthermore a `Form` can operate on any additional database, specified per `Form`.parameter.dbIndex and configured via `config.qfq.ini`_.
System tables
^^^^^^^^^^^^^
+-------------+------------+------+
| Name | Use | Note |
+=============+============+======+
| Clipboard | Temporary | |
+-------------+------------+------+
| Cron | Persistent | |
+-------------+------------+------+
| Dirty | Temporary | |
+-------------+------------+------+
| Form | Persistent | |
+-------------+------------+------+
| FormElement | Persistent | |
+-------------+------------+------+
| MailLog | Persistent | |
+-------------+------------+------+
| Period | Persistent | |
+-------------+------------+------+
| Split | Temporary | |
+-------------+------------+------+
Multi Databases
^^^^^^^^^^^^^^^
QFQ itself can be separated in 'QFQ system' (see `system-tables`_) and 'QFQ data' databases. This might be useful
for one central data database and multiple Typo3 QFQ installations. E.g. there are three departments and all work on the
same data database, but use different QFQ versions. Than it's helpful to have separate QFQ databases.
Furthermore a `Form` can operate on specified additional database, specified per `Form`.parameter.dbIndex and configured
via `config.qfq.ini`_.
Note:
* Option 'A' is the most simple and commonly used.
* Option 'B' separate the T3 and QFQ databases on two database hosts.
......@@ -776,7 +820,7 @@ In `config.qfq.ini`_ mutliple database credentials can be prepared. Mandatory is
`DB_1_USER`, `DB_1_SERVER`, `DB_1_PASSWORD`, `DB_1_NAME`. The number '1' indicates the `dbIndex`. Increment the number
to specify further database credential setups.
Often the `DB_1_xxx` is identically to the used Typo3 database credentials.
Typically the `DB_1_xxx` is identically to the used Typo3 database *credentials* (not database).
If not explicit specified, 'QFQ system' and 'QFQ database' will use the same database with the same credentials (setup 'A').
......@@ -786,7 +830,7 @@ To define separate 'QFQ data' and 'QFQ system', in `config.qfq.ini`_ define `DB
DB_INDEX_DATA = 1
DB_INDEX_QFQ = 2
To let a form operate (show, load and save) on a different database, use `Form.parameter.dbIndexData` (see `form-parameter`_).
To operate a form (show, load and save) on a different database, use `Form.parameter.dbIndex` (see `form-parameter`_).
Different QFQ versions, shared database
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......@@ -1999,7 +2043,7 @@ Parameter
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| Name | Type | Description |
+=============================+========+==========================================================================================================+
| dbIndexData | int | Database credential index, given via `config.qfq.ini`_ to let the current `Form` operate on the database.|
| dbIndex | int | Database credential index, given via `config.qfq.ini`_ to let the current `Form` operate on the database.|
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| bsColumns | int | Wrap the whole form in '<div class="col-md-??"> |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
......
......@@ -8,6 +8,9 @@ BASE_URL_PRINT = http://url.my/
DB_INIT = set names utf8
; auto | always | never
; DB_UPDATE = auto
; DB_INDEX_DATA = 1
; DB_INDEX_QFQ = 1
......@@ -100,9 +103,6 @@ DB_1_NAME = <DB>
; NEW_BUTTON_CLASS = btn btn-default navbar-btn
; NEW_BUTTON_GLYPH_ICON = glyphicon-plus
; auto | always | never
; DB_UPDATE = auto
; RECORD_LOCK_TIMEOUT_SECONDS = 900
; Local Documentation (doc fits to installed version): typo3conf/ext/qfq/Documentation/html/Manual.html
......
......@@ -86,7 +86,7 @@ abstract class AbstractBuildForm {
* @param array $feSpecNative
* @param array $db
*/
public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative, array $db) {
public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative, array $db = null) {
$this->formSpec = $formSpec;
$this->feSpecAction = $feSpecAction;
$this->feSpecNative = $feSpecNative;
......
......@@ -794,8 +794,8 @@ const F_FE_DATA_ERROR = 'data-error';
const F_PARAMETER = 'parameter'; // valid for F_ and FE_
// Form columns: via parameter field
const F_DB_INDEX_DATA = 'dbIndexData';
const DB_INDEX_DATA_DEFAULT = "1";
const F_DB_INDEX = 'dbIndex';
const DB_INDEX_DEFAULT = "1";
const F_LDAP_SERVER = 'ldapServer';
const F_LDAP_BASE_DN = 'ldapBaseDn';
......@@ -1198,8 +1198,9 @@ const TOKEN_DEBUG = 'debug';
const TOKEN_FORM = CLIENT_FORM;
const TOKEN_RECORD_ID = CLIENT_RECORD_ID;
const TOKEN_DEBUG_BODYTEXT = TYPO3_DEBUG_SHOW_BODY_TEXT;
const TOKEN_DB_INDEX = F_DB_INDEX;
const TOKEN_VALID_LIST = 'sql|head|althead|altsql|tail|shead|stail|rbeg|rend|renr|rsep|fbeg|fend|fsep|rbgd|debug|form|r|debugShowBodyText|sqlLog|sqlLogMode';
const TOKEN_VALID_LIST = 'sql|head|althead|altsql|tail|shead|stail|rbeg|rend|renr|rsep|fbeg|fend|fsep|rbgd|debug|form|r|debugShowBodyText|dbIndex|sqlLog|sqlLogMode';
const TOKEN_COLUMN_CTRL = '_';
......
......@@ -178,6 +178,12 @@ class QuickFormQuery {
$updateDb->checkNupdate($dbUpdate);
$this->store->StoreSystemUpdate(); // Do this after the DB-update
// Set dbIndex, evaluate any
$dbIndex = $this->store->getVar(TOKEN_DB_INDEX, STORE_TYPO3 . STORE_EMPTY);
$dbIndex = $this->eval->parse($dbIndex);
$dbIndex = ($dbIndex == '') ? DB_INDEX_DEFAULT : $dbIndex;
$this->store->setVar(TOKEN_DB_INDEX, $dbIndex, STORE_TYPO3);
}
/**
......@@ -345,10 +351,10 @@ class QuickFormQuery {
switch ($this->formSpec['render']) {
case 'plain':
$build = new BuildFormPlain($this->formSpec, $this->feSpecAction, $this->feSpecNative);
$build = new BuildFormPlain($this->formSpec, $this->feSpecAction, $this->feSpecNative, $this->dbArray);
break;
case 'table':
$build = new BuildFormTable($this->formSpec, $this->feSpecAction, $this->feSpecNative);
$build = new BuildFormTable($this->formSpec, $this->feSpecAction, $this->feSpecNative, $this->dbArray);
break;
case 'bootstrap':
$build = new BuildFormBootstrap($this->formSpec, $this->feSpecAction, $this->feSpecNative, $this->dbArray);
......@@ -669,16 +675,16 @@ class QuickFormQuery {
$formSpec = $this->eval->parseArray($form);
// Setting defaults later is too late.
if (!isset($formSpec[F_DB_INDEX_DATA])) {
$formSpec[F_DB_INDEX_DATA] = $this->dbIndexData;
if (!isset($formSpec[F_DB_INDEX])) {
$formSpec[F_DB_INDEX] = $this->dbIndexData;
}
// Some forms load/save the form data on extra defined databases.
if ($this->dbIndexData != $formSpec[F_DB_INDEX_DATA]) {
if (!isset($this->dbArray[$formSpec[F_DB_INDEX_DATA]])) {
$this->dbArray[$formSpec[F_DB_INDEX_DATA]] = new Database($formSpec[F_DB_INDEX_DATA]);
if ($this->dbIndexData != $formSpec[F_DB_INDEX]) {
if (!isset($this->dbArray[$formSpec[F_DB_INDEX]])) {
$this->dbArray[$formSpec[F_DB_INDEX]] = new Database($formSpec[F_DB_INDEX]);
}
$this->dbIndexData = $formSpec[F_DB_INDEX_DATA];
$this->dbIndexData = $formSpec[F_DB_INDEX];
}
$parameterLanguageFieldName = $this->store->getVar(SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME, STORE_SYSTEM);
......@@ -866,16 +872,8 @@ class QuickFormQuery {
$storeFormName = $this->store->getVar(SIP_FORM, $store, '', $foundInStore);
$formName = $this->eval->parse($storeFormName, 0, $dummy, $foundInStore);
// if($mode===FORM_DELETE && $formName===false) {
// return "";
// }
// If the formname is '': no formname name.
if ($formName === '' || $foundInStore === '')
return false;
// If the formname is surrounded by single ticks: the token (typically 'form') has not been replaced by a value.
if ($formName[0] === "'" && $formName[strlen($formName) - 1] === "'") {
// If the formname is empty or if 'form' has not been found in any store: no form.
if ($formName === '' || $foundInStore === '') {
return false;
}
......@@ -995,7 +993,7 @@ class QuickFormQuery {
Support::setIfNotSet($formSpec, F_BUTTON_ON_CHANGE_CLASS, '');
Support::setIfNotSet($formSpec, F_LDAP_USE_BIND_CREDENTIALS, '');
Support::setIfNotSet($formSpec, F_MODE, '');
Support::setIfNotSet($formSpec, F_DB_INDEX_DATA, $this->store->getVar(F_DB_INDEX_DATA, STORE_SYSTEM));
Support::setIfNotSet($formSpec, F_DB_INDEX, $this->store->getVar(F_DB_INDEX, STORE_SYSTEM));
Support::setIfNotSet($formSpec, F_ENTER_AS_SUBMIT, $this->store->getVar(SYSTEM_ENTER_AS_SUBMIT, STORE_SYSTEM));
// In case there is no F_MODE defined on the form, check if there is one in STORE_SIP.
......
......@@ -150,7 +150,10 @@ class Report {
$this->pageDefaults[DEFAULT_BOOTSTRAP_BUTTON]["pagen"] = TOKEN_BOOTSTRAP_BUTTON;
$this->pageDefaults[DEFAULT_BOOTSTRAP_BUTTON]["pages"] = TOKEN_BOOTSTRAP_BUTTON;
$this->db = new Database();
// Default should already set in QuickFormQuery() Constructor
$dbIndex = $this->store->getVar(TOKEN_DB_INDEX, STORE_TYPO3 . STORE_EMPTY);
$this->db = new Database($dbIndex);
$this->variables = new Variables($eval, $t3data["uid"]);
// Set static values, which won't change during this run.
......@@ -280,7 +283,8 @@ class Report {
// per sql command
//pro sql cmd wir der Indexarray abgefüllt. Dieser wird später verwendet um auf den $frArray zuzugreifen
//if(preg_match("/^sql/i", $frCmd) == 1){
if ($frCmd === TOKEN_FORM || $frCmd === TOKEN_SQL) {
// if ($frCmd === TOKEN_FORM || $frCmd === TOKEN_SQL) {
if ($frCmd === TOKEN_SQL) {
// Remember max level
$this->levelCount = max(substr_count($level, '.') + 1, $this->levelCount);
// $indexArray[10][50][5]
......
......@@ -159,8 +159,8 @@ class Config {
$default = [
SYSTEM_DB_INDEX_DATA => DB_INDEX_DATA_DEFAULT,
SYSTEM_DB_INDEX_QFQ => DB_INDEX_DATA_DEFAULT,
SYSTEM_DB_INDEX_DATA => DB_INDEX_DEFAULT,
SYSTEM_DB_INDEX_QFQ => DB_INDEX_DEFAULT,
SYSTEM_DATE_FORMAT => 'yyyy-mm-dd',
SYSTEM_SHOW_DEBUG_INFO => SYSTEM_SHOW_DEBUG_INFO_AUTO,
......
......@@ -832,7 +832,7 @@ class Store {
public static function StoreSystemUpdate() {
$db = null;
$storeSystemAdd = array();
$flagDirty = false;
$storeSystem = self::getStore(STORE_SYSTEM);
for ($ii = 1; $ii <= 3; $ii++) {
......@@ -856,10 +856,10 @@ class Store {
$storeSystemAdd = $db->sql($storeSystem[SYSTEM_FILL_STORE_SYSTEM_BY_SQL . "_$ii"], $mode, array(), $errMsg);
$storeSystemAdd = OnArray::keyNameRemoveLeadingUnderscore($storeSystemAdd);
$storeSystem = array_merge($storeSystem, $storeSystemAdd);
$flagDirty = true;
}
if (!empty($storeSystem)) {
if ($flagDirty) {
self::setStore($storeSystem, STORE_SYSTEM, true);
}
}
......
......@@ -92,7 +92,7 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase {
if (empty($this->dbArray)) {
$this->dbArray[DB_INDEX_DATA_DEFAULT] = new qfq\Database();
$this->dbArray[DB_INDEX_DEFAULT] = new qfq\Database();
}
/// Establish additional mysqli access
......
......@@ -264,7 +264,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
unset($formElement['emptyItemAtEnd']);
// SQL
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT name FROM Form AS f ORDER BY f.id LIMIT 3');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT name FROM Form AS f ORDER BY f.id LIMIT 3');
// $expect = ['form', 'formElement', 'phpunit_person'];
$expect = ['form', 'formElement', 'copyForm'];
$build->getKeyValueListFromSqlEnumSpec($formElement, $keys, $values);
......@@ -273,7 +273,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// SQL (one column, no keyword) + emptyItemAtStart
$formElement[FE_EMPTY_ITEM_AT_START] = '';
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT name FROM Form AS f ORDER BY f.id LIMIT 3');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT name FROM Form AS f ORDER BY f.id LIMIT 3');
// $expect = ['', 'form', 'formElement', 'phpunit_person'];
$expect = ['', 'form', 'formElement', 'copyForm'];
$build->getKeyValueListFromSqlEnumSpec($formElement, $keys, $values);
......@@ -284,7 +284,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// SQL (4 columns, none 'id' nor 'label') - Take the first two columns
$expectKeys = ['10', '20', '30'];
$expectValues = ['basic', 'access', 'various'];
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT ord, name, created, modified FROM FormElement AS fe ORDER BY fe.id LIMIT 3');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT ord, name, created, modified FROM FormElement AS fe ORDER BY fe.id LIMIT 3');
$build->getKeyValueListFromSqlEnumSpec($formElement, $keys, $values);
$this->assertEquals($expectKeys, $keys);
$this->assertEquals($expectValues, $values);
......@@ -292,7 +292,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// SQL (4 columns, none 'id', one 'label' ) - Take the first and the fourth two columns
$expectKeys = ['10', '20', '30'];
$expectValues = ['basic', 'access', 'various'];
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT ord, created, modified, name AS label FROM FormElement AS fe ORDER BY fe.id LIMIT 3');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT ord, created, modified, name AS label FROM FormElement AS fe ORDER BY fe.id LIMIT 3');
$build->getKeyValueListFromSqlEnumSpec($formElement, $keys, $values);
$this->assertEquals($expectKeys, $keys);
$this->assertEquals($expectValues, $values);
......@@ -300,7 +300,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// SQL (4 columns, none 'id', one 'label' ) - Take the first and the fourth two columns
$expectKeys = ['1', '2', '3'];
$expectValues = ['basic', 'access', 'various'];
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT ord, created, modified, name AS label, id FROM FormElement AS fe ORDER BY fe.id LIMIT 3');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT ord, created, modified, name AS label, id FROM FormElement AS fe ORDER BY fe.id LIMIT 3');
$build->getKeyValueListFromSqlEnumSpec($formElement, $keys, $values);
$this->assertEquals($expectKeys, $keys);
$this->assertEquals($expectValues, $values);
......@@ -340,108 +340,108 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$build = new \qfq\BuildFormPlain($form, array(), [$formElement], $this->dbArray);
// id: 1, firstName: John, name: Doe
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id, name, firstName FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id, name, firstName FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>id</th><th>name</th><th>firstName</th></tr></thead><tbody><tr class="record" ><td>1</td><td>Doe</td><td>John</td></tr><tr class="record" ><td>2</td><td>Smith</td><td>Jane</td></tr></tbody></table>', $result);
// _id: 1, name: Doe,
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>name</th></tr></thead><tbody><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smith</td></tr></tbody></table>', $result);
// _id: 1, name: Doe,title=''
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name AS "title=" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name AS "title=" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th></th></tr></thead><tbody><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smith</td></tr></tbody></table>', $result);
// _id: 1, name: Doe, column: _Person
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name AS "unused|width=2|title=_Person", firstName FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name AS "unused|width=2|title=_Person", firstName FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>firstName</th></tr></thead><tbody><tr class="record" ><td>John</td></tr><tr class="record" ><td>Jane</td></tr></tbody></table>', $result);
// _id: 1, name: Doe, title: PERSON
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name AS "PERSON" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name AS "PERSON" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>PERSON</th></tr></thead><tbody><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smith</td></tr></tbody></table>', $result);
// _id: 1, "This is a much longer text than necessary": Default max:20
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", "This is a much longer text than necessary" FROM Person ORDER BY id LIMIT 1');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", "This is a much longer text than necessary" FROM Person ORDER BY id LIMIT 1');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>This is a much longe</th></tr></thead><tbody><tr class="record" ><td>This is a much longe</td></tr></tbody></table>', $result);
// _id: 1, name: Jo (width:2)
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name AS "2" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name AS "2" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th></th></tr></thead><tbody><tr class="record" ><td>Do</td></tr><tr class="record" ><td>Sm</td></tr></tbody></table>', $result);
// _id: 1, name: Jo (width:2)
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name AS "2|PERSON" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name AS "2|PERSON" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>PE</th></tr></thead><tbody><tr class="record" ><td>Do</td></tr><tr class="record" ><td>Sm</td></tr></tbody></table>', $result);
// _id: 1, name: Doe ('width':3)
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name AS "Name|width=3" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name AS "Name|width=3" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>Nam</th></tr></thead><tbody><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smi</td></tr></tbody></table>', $result);
// _id: 1, name: Doe (width:3, title:PERSON)
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name AS "3|title=PERSON" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name AS "3|title=PERSON" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>PER</th></tr></thead><tbody><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smi</td></tr></tbody></table>', $result);
// _id: 1, name: <b>Doe</b>
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", CONCAT("<b>", name, "</b>") AS "Name" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", CONCAT("<b>", name, "</b>") AS "Name" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>Name</th></tr></thead><tbody><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smith</td></tr></tbody></table>', $result);
// _id: 1, name: <b>Doe</b>, width=2
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", CONCAT("<b>", name, "</b>") AS "Name|2" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", CONCAT("<b>", name, "</b>") AS "Name|2" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>Na</th></tr></thead><tbody><tr class="record" ><td>Do</td></tr><tr class="record" ><td>Sm</td></tr></tbody></table>', $result);
// _id: 1, name: <b>Doe</b> , nostrip
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", CONCAT("<b>", name, "</b>") AS "Name|nostrip" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", CONCAT("<b>", name, "</b>") AS "Name|nostrip" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>Name</th></tr></thead><tbody><tr class="record" ><td><b>Doe</b></td></tr><tr class="record" ><td><b>Smith</b></td></tr></tbody></table>', $result);
// _id: 1, icon: bullet-green.gif
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", "bullet-green.gif" AS "Status|icon" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", "bullet-green.gif" AS "Status|icon" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>Status</th></tr></thead><tbody><tr class="record" ><td><image src=\'typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif\'></td></tr><tr class="record" ><td><image src=\'typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif\'></td></tr></tbody></table>', $result);
// _id: 1, mailto: john@doe.com
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", "john@doe.com" AS "EMail|mailto" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", "john@doe.com" AS "EMail|mailto" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>EMail</th></tr></thead><tbody><tr class="record" ><td><a href="mailto:john@doe.com" >john@doe.com</a></td></tr><tr class="record" ><td><a href="mailto:john@doe.com" >john@doe.com</a></td></tr></tbody></table>', $result);
// _id: 1, url: www.uzh.ch
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", "www.uzh.ch" AS "URL|url" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", "www.uzh.ch" AS "URL|url" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>URL</th></tr></thead><tbody><tr class="record" ><td><a href="www.uzh.ch" >www.uzh.ch</a></td></tr><tr class="record" ><td><a href="www.uzh.ch" >www.uzh.ch</a></td></tr></tbody></table>', $result);
// _id: 1, name: Doe, _rowclass (text)
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name, IF(id=1,"text-warning", "text-danger") AS _rowClass FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name, IF(id=1,"text-warning", "text-danger") AS _rowClass FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>name</th></tr></thead><tbody><tr class="record text-warning" ><td>Doe</td></tr><tr class="record text-danger" ><td>Smith</td></tr></tbody></table>', $result);
// _id: 1, name: Doe, _rowClass (text & background)
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name, IF(id=1,"text-warning active", "text-danger success") AS _rowClass FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name, IF(id=1,"text-warning active", "text-danger success") AS _rowClass FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>name</th></tr></thead><tbody><tr class="record text-warning active" ><td>Doe</td></tr><tr class="record text-danger success" ><td>Smith</td></tr></tbody></table>', $result);
// _id: 1, name: Doe, _rowTitle
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name, firstName AS _rowTitle FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name, firstName AS _rowTitle FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>name</th></tr></thead><tbody><tr class="record" title="John" ><td>Doe</td></tr><tr class="record" title="Jane" ><td>Smith</td></tr></tbody></table>', $result);
// _id: 1, name: Doe, title, width, nostrip
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name, "<b>This again is a very long text</b>" AS "title=Important|width=10|nostrip" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name, "<b>This again is a very long text</b>" AS "title=Important|width=10|nostrip" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>name</th><th>Important</th></tr></thead><tbody><tr class="record" ><td>Doe</td><td><b>This again is a very long text</b></td></tr><tr class="record" ><td>Smith</td><td><b>This again is a very long text</b></td></tr></tbody></table>', $result);
// _id: 1, name: Doe, link
$formElement['sql1'] = $this->dbArray[DB_INDEX_DATA_DEFAULT]->sql('SELECT id AS "_id", name, CONCAT("s:1|p:form&form=person&r=" , id , "|t:", name) AS "link" FROM Person ORDER BY id LIMIT 2');
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name, CONCAT("s:1|p:form&form=person&r=" , id , "|t:", name) AS "link" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>name</th><th></th></tr></thead><tbody><tr class="record" ><td>Doe</td><td><a href="index.php?id=form&s=badcaffee1234" >Doe</a></td></tr><tr class="record" ><td>Smith</td><td><a href="index.php?id=form&s=badcaffee1234" >Smith</a></td></tr></tbody></table>', $result);
}
......@@ -523,8 +523,8 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// Use always the latest (production) FormEditor: played during QuickFormQuery()
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("DROP TABLE IF EXISTS `Form`");
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("DROP TABLE IF EXISTS `FormElement`");
$this->dbArray[DB_INDEX_DEFAULT]->sql("DROP TABLE IF EXISTS `Form`");
$this->dbArray[DB_INDEX_DEFAULT]->sql("DROP TABLE IF EXISTS `FormElement`");
$this->executeSQLFile(__DIR__ . '/../../sql/formEditor.sql', true);
$this->store->unsetStore(STORE_ADDITIONAL_FORM_ELEMENTS);
......@@ -540,7 +540,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$form = new \qfq\QuickFormQuery(['bodytext' => "form=form\nr=3", 'uid' => 1234], true);
// After instantiating QuickFormQuery, the latest updates will be played. The SIP is by default activated which breaks current tests.
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("UPDATE Form SET permitNew='always', permitEdit='always' WHERE name='form' ");
$this->dbArray[DB_INDEX_DEFAULT]->sql("UPDATE Form SET permitNew='always', permitEdit='always' WHERE name='form' ");
$form->process();
}
}
......
......@@ -104,7 +104,7 @@ class DirtyTest extends \AbstractDatabaseTest {
$result = $dirty->process();
$this->assertEquals($expected, $result);
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);
$this->dbArray[DB_INDEX_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);
// Alice release
$_GET[DIRTY_API_ACTION] = DIRTY_API_ACTION_RELEASE;
......@@ -113,7 +113,7 @@ class DirtyTest extends \AbstractDatabaseTest {
$result = $dirty->process();
$this->assertEquals($expected, $result);
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);
$this->dbArray[DB_INDEX_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);
}
/**
......@@ -131,7 +131,7 @@ class DirtyTest extends \AbstractDatabaseTest {
$result = $dirty->process();
$this->assertEquals($expected, $result);
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);
$this->dbArray[DB_INDEX_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);
// Alice release
$_GET[DIRTY_API_ACTION] = DIRTY_API_ACTION_RELEASE;
......@@ -141,7 +141,7 @@ class DirtyTest extends \AbstractDatabaseTest {
$result = $dirty->process();
$this->assertEquals($expected, $result);
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);
$this->dbArray[DB_INDEX_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);
}
/**
......@@ -158,7 +158,7 @@ class DirtyTest extends \AbstractDatabaseTest {
$result = $dirty->process();
// move lock to another owner (Alice fake becomes Bob) - but there is no lockrecord!
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("UPDATE Dirty SET qfqUserSessionCookie='SessionCookieBob' WHERE id=1", ROW_REGULAR);
$this->dbArray[DB_INDEX_DEFAULT]->sql("UPDATE Dirty SET qfqUserSessionCookie='SessionCookieBob' WHERE id=1", ROW_REGULAR);
// Alice lock again
$result = $dirty->process();
......@@ -187,7 +187,7 @@ class DirtyTest extends \AbstractDatabaseTest {
$result = $dirty->process();
$this->assertEquals($expected, $result);
$this->dbArray[DB_INDEX_DATA_DEFAULT]->sql("SELECT id FROM Dirty", ROW_EXPECT_0);