Skip to content
Snippets Groups Projects
Commit 116bce3f authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'F13945_link_before_after' into 'develop'

Refs #13945. Implements text before/after link

See merge request !494
parents 4fb6cd14 f13125e7
No related branches found
No related tags found
2 merge requests!495New version 22.12.0,!494Refs #13945. Implements text before/after link
Pipeline #8469 passed
......@@ -784,6 +784,10 @@ Column: _link
| | |Mode |M:file|pdf|qfqpdf|zip |M:file, M:pdf, M:qfqpdf, |Mode. Used to specify type of download. One or more element sources needs to be configured. See :ref:`download`. |
| | | | |M:zip | |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Text before |v:text before link |v:Some Text |Useful to show text before a link, delivered through `... AS _link`. See :ref:`linkTextBeforeAfter` |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Text after |V:text after link |v:Some Text |Useful to show text after a link, delivered through `... AS _link`. See :ref:`linkTextBeforeAfter` |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |File |F:<filename> |F:fileadmin/file.pdf |Element source for download mode file|pdf|zip. See :ref:`download`. |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Delete record | x[:a|r|c] |x, x:r, x:c |a: ajax (only QFQ internal used), r: report (default), c: close (current page, open last page) |
......@@ -884,6 +888,8 @@ Link Examples
| SELECT "y|s:1|F:dir/data.R|t:Data|o:Clipboard|b" AS _link | <button class="btn btn-info" onClick="new QfqNS.Clipboard({uri: 'typo3conf/.../download.php?s=badcaffee1234'});" |
| | title='Copy to clipboard'>Data</button> |
+-----------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
| SELECT "p:/form_person|v:Hello |V: world.|t:Link" AS _link | 'Hello <a href="/form_person">Link</a> world.' |
+-----------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
.. _question:
......@@ -933,6 +939,32 @@ Examples:
| SELECT "p:/form_person|q:Edit Person:::10:0" AS _link | The Alert will be shown 10 seconds and is not modal. |
+------------------------------------------------------------+---------------------------------------------------------------------------+
.. _linkTextBeforeAfter:
Text before / after link
^^^^^^^^^^^^^^^^^^^^^^^^
* Renders text before and/or after a link.
* Example: `SELECT 'p:{{pageAlias:T}}|t:Reload|v:Some text before |v: some text after' AS _link`
* A typical usecase is to get several `AS _link` columns in one HTML table cell, by still using `fbeg,fend`::
10 {
sql = SELECT p.id
, 'p:{{pageAlias:T}}|t:Reload 1|v:<td>Some text before |V: - ' AS '_link|_noWrap'
, 'p:{{pageAlias:T}}|t:Reload 2|V:</td>' AS '_link|_noWrap'
, p.name
FROM Person AS p
head = <table>
tail = </table>
rbeg = <tr>
rend = </tr>
fbeg = <td>
fend = </td>
}
.. _column_pageX:
Columns: _page[X]
......
......@@ -1875,7 +1875,8 @@ const NAME_MONITOR = 'monitor';
const NAME_ATTRIBUTE = 'attribute';
const NAME_EMAIL = 'email';
const NAME_REALNAME = 'realname';
const NAME_BEFORE_LINK = 'beforeLink';
const NAME_AFTER_LINK = 'afterLink';
const FINAL_HREF = 'finalHref';
const FINAL_ANCHOR = 'finalAnchor';
const FINAL_CONTENT = 'finalContent';
......@@ -1949,6 +1950,9 @@ const TOKEN_FILE = 'F';
const TOKEN_FILE_DEPRECATED = 'f'; // since 5.12.17
const TOKEN_DOWNLOAD_MODE = 'M';
const TOKEN_ATTRIBUTE = 'A';
const TOKEN_BEFORE_LINK = 'v';
const TOKEN_AFTER_LINK = 'V';
const TOKEN_FUNCTION_CALL = 'call';
const TOKEN_ARGUMENT = 'arg';
const TOKEN_FORM_ID = 'fid';
......
......@@ -77,8 +77,8 @@ use IMATHUZH\Qfq\Core\Typo3\T3Handler;
* T:Thumbnail
* u:url
* U:URL Param
* v:
* V:
* v:Text before link
* V:Text after link
* w:websocket
* W:Dimension
* x:Delete
......@@ -160,6 +160,9 @@ class Link {
TOKEN_ATTRIBUTE => NAME_ATTRIBUTE,
TOKEN_MONITOR => NAME_MONITOR,
TOKEN_BEFORE_LINK => NAME_BEFORE_LINK,
TOKEN_AFTER_LINK => NAME_AFTER_LINK,
// The following don't need a renaming: already 'long'
TOKEN_L_FILE => TOKEN_L_FILE,
TOKEN_L_TAIL => TOKEN_L_TAIL,
......@@ -624,7 +627,7 @@ class Link {
throw new \UserReportException ("Mode not implemented. internal render mode=$mode", ERROR_UNKNOWN_MODE);
}
return $link;
return $vars[NAME_BEFORE_LINK] . $link . $vars[NAME_AFTER_LINK];
}
/**
......@@ -842,6 +845,12 @@ class Link {
case TOKEN_BOOTSTRAP_BUTTON:
$vars = $this->buildBootstrapButton($vars, $value);
break;
case TOKEN_BEFORE_LINK:
$vars = $this->buildTextBeforeLink($vars, $value);
break;
case TOKEN_AFTER_LINK:
$vars = $this->buildTextAfterLink($vars, $value);
break;
default:
break;
}
......@@ -916,6 +925,9 @@ class Link {
NAME_ACTION_DELETE => '',
NAME_BEFORE_LINK => '',
NAME_AFTER_LINK => '',
FINAL_HREF => '',
FINAL_CONTENT => '',
FINAL_SYMBOL => '',
......@@ -2135,6 +2147,26 @@ EOF;
return $vars;
}
/**
* @param $vars
* @param $value
* @return mixed
*/
private function buildTextBeforeLink($vars, $value) {
$vars[NAME_BEFORE_LINK] = $value;
return $vars;
}
/**
* @param $vars
* @param $value
* @return mixed
*/
private function buildTextAfterLink($vars, $value) {
$vars[NAME_AFTER_LINK] = $value;
return $vars;
}
/**
* Called by $this->callTable
*
......
......@@ -101,6 +101,8 @@ class LinkTest extends TestCase {
'finalClass' => '',
'finalQuestion' => '',
'finalThumbnail' => '',
'beforeLink' => '',
'afterLink' => '',
];
$link = new Link($this->sip, DB_INDEX_DEFAULT, true);
......@@ -892,6 +894,24 @@ class LinkTest extends TestCase {
$this->assertEquals('<a href="http://example.com" class="btn btn-default" title="Details" ><span class="glyphicon glyphicon-envelope" ></span></a>', $result);
}
/**
* @throws \CodeException
* @throws \UserFormException
* @throws \UserReportException
*/
public function testBeforeAfterText() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true);
$result = $link->renderLink('u:http://example.com|t:Link|v:Hello ');
$this->assertEquals('Hello <a href="http://example.com" >Link</a>', $result);
$result = $link->renderLink('u:http://example.com|t:Link|V: world');
$this->assertEquals('<a href="http://example.com" >Link</a> world', $result);
$result = $link->renderLink('u:http://example.com|t:Link|v:Hello |V: world');
$this->assertEquals('Hello <a href="http://example.com" >Link</a> world', $result);
}
/**
* @expectedException UserReportException
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment