Commit 0bb95af6 authored by Carsten  Rose's avatar Carsten Rose
Browse files

AbstractBuildForm.php: Column with a specific 'title' starting with '_... '...

AbstractBuildForm.php: Column with a specific 'title' starting with '_... ' has not been surpressed. Fixed.
parent 635a37be
......@@ -819,24 +819,20 @@ will be rendered inside the form as a HTML table.
* Notice the **exclamation mark** after '{{' - this is necessary to return an array of elements, instead of a single string.
* Exactly one column **'id'** has to exist; it specifies the primary record for the target form.
In case the id should no be visible to the user, it has to be named **'_id'**.
* Columnname: *[title=]<title>[|<number>][|width=<number>][|nostrip][|icon][|url][|mailto][|_rowClass][|_rowTitle]*
* All but the first parameter are position independet.
* *<number>*: Max. number of chars displayed per cell in the column. Any 'digit only' will be treated as '''width'''.
Default max width: 20.
* *width=<number>*: identical with <number>.
In case the id should not be visible to the user, it has to be named **'_id'**.
* Columnname: *[title=]<title>[|[width=]<number>][|nostrip][|icon][|url][|mailto][|_rowClass][|_rowTitle]*
* All parameter are position independet.
* Separate parameter by '|'.
* *[title=]<text>*: Title of the column. The keyword 'title=' is optional. Columns with a title starting with '_' won't be rendered.
* *[width=]<number>*: Max. width of chars displayed per cell. The keyword 'width=' is optional. Default max width: 20.
This setting also affects the title of the column.
* *nostrip*: by default, html tags will be stripped off the cell content before rendering. This protects the table
layout. 'nostrip' deactivates the cleaning to make links, images, ... possible.
layout. 'nostrip' deactivates the cleaning to make pure html possible.
* *icon*: the cell value contains the name of an icon in *typo3conf/ext/qfq/Resources/Public/icons*. Empty cell values
will omit an html image tag (=nothing rendered in the cell).
* *mailto*: value will be rendered as a mailto link.
* *url*: value will be rendered as a link.
* *title=<text>* or '<none of the above>': column '''title'''.
* Examples::
SELECT note1 AS 'Comment', note2 AS 'Comment\|50' , note3 AS 'title=Comment\|width=100\|nostrip', note4 AS '50\|Comment',
'checked.png' AS 'Status\|icon', email AS 'mailto', CONCAT(homepage, '\|Homepage') AS 'url' ...
* *_rowClass*
......@@ -851,6 +847,12 @@ will be rendered inside the form as a HTML table.
* Defines the title attribute of a subrecod table row (tooltip).
* Examples::
SELECT note1 AS 'Comment', note2 AS 'Comment|50' , note3 AS 'title=Comment|width=100|nostrip', note4 AS '50|Comment',
'checked.png' AS 'Status|icon', email AS 'mailto', CONCAT(homepage, '|Homepage') AS 'url',
ELT(status,'info','warning','danger') AS '_rowClass', help AS '_rowTitle' ...
* *parameter*
* *form*: Target form, e.g. *form=person*
......
......@@ -1504,6 +1504,8 @@ abstract class AbstractBuildForm {
*/
private function createFormLink(array $formElement, $targetRecordId, array $record, $symbol, $toolTip) {
//TODO: Umstellen auf Benutzung der Link Klasse.
$queryStringArray = [
SIP_FORM => $formElement[SUBRECORD_PARAMETER_FORM],
SIP_RECORD_ID => $targetRecordId
......@@ -1576,7 +1578,7 @@ abstract class AbstractBuildForm {
* mailto Only key. Value will rendered (later) as a 'href mailto'
*
*
* @param $titleRaw
* @param array $titleRaw
* @return array
* @throws UserFormException
*/
......@@ -1593,11 +1595,6 @@ abstract class AbstractBuildForm {
break;
}
// Don't render Columns starting with '_...'.
if (substr($columnName, 0, 1) === '_') {
continue;
}
$flagWidthLimit = true;
$control['width'][$columnName] = SUBRECORD_COLUMN_WIDTH;
......@@ -1624,6 +1621,12 @@ abstract class AbstractBuildForm {
if (!isset($control['title'][$columnName]))
$control['title'][$columnName] = ''; // Fallback: Might be wrong, but better than nothing.
// Don't render Columns starting with '_...'.
if (substr($control['title'][$columnName], 0, 1) === '_') {
unset($control['title'][$columnName]); // Do not render column later.
continue;
}
// Limit title length
$control['title'][$columnName] = substr($control['title'][$columnName], 0, $control['width'][$columnName]);
......@@ -1691,6 +1694,8 @@ abstract class AbstractBuildForm {
*/
public function createDeleteUrl($table, $recordId, $mode = RETURN_URL) {
//TODO: Umstellen auf Benutzung der Link Klasse.
$queryStringArray = [
SIP_TABLE => $table,
SIP_RECORD_ID => $recordId,
......
......@@ -388,6 +388,16 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="table table-hover"><tr><th>name</th></tr><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smith</td></tr></table>', $result);
// _id: 1, name: Doe,title=''
$formElement['sql1'] = $this->db->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="table table-hover"><tr><th></th></tr><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smith</td></tr></table>', $result);
// _id: 1, name: Doe, column: _Person
$formElement['sql1'] = $this->db->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="table table-hover"><tr><th>firstName</th></tr><tr class="record" ><td>John</td></tr><tr class="record" ><td>Jane</td></tr></table>', $result);
// _id: 1, name: Doe, title: PERSON
$formElement['sql1'] = $this->db->sql('SELECT id AS "_id", name AS "PERSON" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
......@@ -423,6 +433,11 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="table table-hover"><tr><th>Name</th></tr><tr class="record" ><td>Doe</td></tr><tr class="record" ><td>Smith</td></tr></table>', $result);
// _id: 1, name: <b>Doe</b>, width=2
$formElement['sql1'] = $this->db->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="table table-hover"><tr><th>Na</th></tr><tr class="record" ><td>Do</td></tr><tr class="record" ><td>Sm</td></tr></table>', $result);
// _id: 1, name: <b>Doe</b> , nostrip
$formElement['sql1'] = $this->db->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);
......@@ -459,12 +474,9 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$this->assertEquals('<table class="table table-hover"><tr><th>name</th></tr><tr class="record" title="John" ><td>Doe</td></tr><tr class="record" title="Jane" ><td>Smith</td></tr></table>', $result);
// _id: 1, name: Doe, title, width, nostrip
//TODO: Test zum laufen bringen
// $formElement['sql1'] = $this->db->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="table table-hover"><tr><th>name</th></tr><tr class="record" title="John" ><td>Doe</td></tr><tr class="record" title="Jane" ><td>Smith</td></tr></table>', $result);
$formElement['sql1'] = $this->db->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="table table-hover"><tr><th>name</th><th>Important</th></tr><tr class="record" ><td>Doe</td><td><b>This ag</td></tr><tr class="record" ><td>Smith</td><td><b>This ag</td></tr></table>', $result);
}
/**
......
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