Commit 43269c52 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes #10286. Download links with G:0, G:<custom> now works as exepcted

parent c15a5b4b
Pipeline #4915 passed with stages
in 4 minutes and 3 seconds
......@@ -419,10 +419,9 @@ class Link {
private function renderDropdown(string $dropdownSymbol, array $menuEntryLinkArr, $htmlId, $flagMenuEnabled) {
$ul = '';
$li = '';
$attribute = '';
if ($flagMenuEnabled) {
$tmp = '';
foreach ($menuEntryLinkArr as $link) {
$attribute = '';
......@@ -485,7 +484,7 @@ class Link {
// Misuse the link class to render the menu symbol: this gives tooltip, glyph, button, text ... - set render mode to '3' = 'no link'
$paramArr[TOKEN_RENDER] = '3';
if (!isset($paramArr[TOKEN_GLYPH])) {
if (!isset($paramArr[TOKEN_GLYPH]) || $paramArr[TOKEN_GLYPH] == '1') {
$paramArr[TOKEN_GLYPH] = 'glyphicon-option-vertical';
}
......@@ -619,10 +618,6 @@ class Link {
break;
}
if (($str[0] ?? '') == TOKEN_DROPDOWN) {
return $this->processDropdown($str);
}
$vars = $this->fillParameter($str, $tokenGiven);
$vars = $this->processParameter($vars, $tokenGiven);
$mode = $this->getModeRender($vars, $tokenGiven);
......@@ -1555,7 +1550,7 @@ EOF;
* @return array
*/
private function buildUrl($vars, $value) {
// $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassExternal;
$vars[NAME_LINK_CLASS_DEFAULT] = '';
return $vars;
......@@ -1570,7 +1565,7 @@ EOF;
* @return array
*/
private function buildMail($vars, $value) {
// $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassExternal;
$vars[NAME_LINK_CLASS_DEFAULT] = '';
return $vars;
......@@ -1646,8 +1641,19 @@ EOF;
$vars[NAME_GLYPH] = '';
$vars[NAME_EXTRA_CONTENT_WRAP] = '';
} else {
$vars[NAME_GLYPH] = GLYPH_ICON_FILE;
$vars[NAME_GLYPH_TITLE] = "Download";
switch ($vars[NAME_GLYPH]) {
case '0':
$vars[NAME_GLYPH] = '';
$vars[NAME_GLYPH_TITLE] = '';
break;
case '':
case '1':
$vars[NAME_GLYPH] = GLYPH_ICON_FILE;
$vars[NAME_GLYPH_TITLE] = "Download";
break;
default:
break;
}
}
// No download link! Only text/button
......
......@@ -1449,18 +1449,34 @@ EOF;
$result = $link->renderLink('d|F:file.pdf|r:5');
$this->assertEquals('', $result);
// Single file
// Single file, no BS button
$result = $link->renderLink('d|F:file.pdf|t:DL|b:0');
$this->assertEquals('<a href="typo3conf/ext/qfq/Classes/Api/download.php?s=badcaffee1234" class="0" ><span data-toggle="modal" data-target="#qfqModal101" data-title="Download: " data-text="Please wait" data-backdrop="static" data-keyboard="false" onclick="$(\'#qfqModalTitle101\').text($(this).data(\'title\')); $(\'#qfqModalText101\').text($(this).data(\'text\'));">DL</span></a>', $result);
// Single file
// Single file, no BS button, disabled
$result = $link->renderLink('d|F:file.pdf|t:DL|b:0|r:3');
$this->assertEquals('<span class="0 disabled" >DL</span>', $result);
// Single file
// Single file, nothing
$result = $link->renderLink('d|F:file.pdf|t:DL|b:0|r:5');
$this->assertEquals('', $result);
// Single file, standard Glyph
$result = $link->renderLink('d|F:file.pdf|t:DL');
$this->assertEquals('<a href="typo3conf/ext/qfq/Classes/Api/download.php?s=badcaffee1234" class="0" title="Download" ><span class="btn btn-default" data-toggle="modal" data-target="#qfqModal101" data-title="Download: " data-text="Please wait" data-backdrop="static" data-keyboard="false" onclick="$(\'#qfqModalTitle101\').text($(this).data(\'title\')); $(\'#qfqModalText101\').text($(this).data(\'text\'));"><span class="glyphicon glyphicon-file" ></span> DL</span></a>', $result);
// Single file, default Glyph
$result = $link->renderLink('d|F:file.pdf|t:DL|G:1');
$this->assertEquals('<a href="typo3conf/ext/qfq/Classes/Api/download.php?s=badcaffee1234" class="0" title="Download" ><span class="btn btn-default" data-toggle="modal" data-target="#qfqModal101" data-title="Download: " data-text="Please wait" data-backdrop="static" data-keyboard="false" onclick="$(\'#qfqModalTitle101\').text($(this).data(\'title\')); $(\'#qfqModalText101\').text($(this).data(\'text\'));"><span class="glyphicon glyphicon-file" ></span> DL</span></a>', $result);
// Single file, no Glyph
$result = $link->renderLink('d|F:file.pdf|t:DL|G:0');
$this->assertEquals('<a href="typo3conf/ext/qfq/Classes/Api/download.php?s=badcaffee1234" class="0" ><span class="btn btn-default" data-toggle="modal" data-target="#qfqModal101" data-title="Download: " data-text="Please wait" data-backdrop="static" data-keyboard="false" onclick="$(\'#qfqModalTitle101\').text($(this).data(\'title\')); $(\'#qfqModalText101\').text($(this).data(\'text\'));">DL</span></a>', $result);
// Single file, custom Glyph
$result = $link->renderLink('d|F:file.pdf|t:DL|G:glyphicon-ok');
$this->assertEquals('<a href="typo3conf/ext/qfq/Classes/Api/download.php?s=badcaffee1234" class="0" title="Details" ><span class="btn btn-default" data-toggle="modal" data-target="#qfqModal101" data-title="Download: " data-text="Please wait" data-backdrop="static" data-keyboard="false" onclick="$(\'#qfqModalTitle101\').text($(this).data(\'title\')); $(\'#qfqModalText101\').text($(this).data(\'text\'));"><span class="glyphicon glyphicon-ok" ></span> DL</span></a>', $result);
}
/**
......@@ -1476,11 +1492,21 @@ EOF;
$result = $link->renderLink('z');
$this->assertEquals($expect, $result);
// Empty definition.
// Empty definition, default glyph
$expect = '<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyphicon-option-vertical" ></span></span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"></ul></span>';
$result = $link->renderLink('z:');
$this->assertEquals($expect, $result);
// Empty definition, G:1 (default glyph)
$expect = '<span class="dropdown"><span title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyphicon-option-vertical" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"></ul></span>';
$result = $link->renderLink('z|t:Menu|G:1|o:Details');
$this->assertEquals($expect, $result);
// Dropdown menu with text, no glyph, tooltip.
$expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" >Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"></ul></span>';
$result = $link->renderLink('z|t:Menu|G:0|o:Open menu');
$this->assertEquals($expect, $result);
// Dropdown menu with text, custom Glyph and a tooltip.
$expect = '<span class="dropdown"><span title="Open menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="dropdown-toggle" id="badcaffee1234" ><span class="glyphicon glyph-icon-left" ></span> Menu</span><ul style="max-height: 70vh; overflow-y: auto" class="dropdown-menu" aria-labelledby="badcaffee1234"></ul></span>';
$result = $link->renderLink('z|t:Menu|G:glyph-icon-left|o:Open menu');
......
Supports Markdown
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