Commit 4bb218c5 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'B6576-Download-Links-not-disabled-with-r3'

parents 52fb8c68 84778dfa
Pipeline #806 passed with stage
in 1 minute and 42 seconds
......@@ -5418,7 +5418,8 @@ render mode might dynamically control the rendered link.
+------------+---------------------+--------------------+------------------+---------------------------------------------------------------------------+
|2 |<a href=url>text</a> | | |no link if text is empty |
+------------+---------------------+--------------------+------------------+---------------------------------------------------------------------------+
|3 |text |url |text |no link, only text or image, incl. optional tooltip |
|3 |text |url |text |no link, only text or image, incl. Optional tooltip. For Bootstrap buttons |
| | | | | r:3 will set the button to disable and no link/sip is rendered. |
+------------+---------------------+--------------------+------------------+---------------------------------------------------------------------------+
|4 |url |url |text |no link, show text, if text is empty, show url, incl. optional tooltip |
+------------+---------------------+--------------------+------------------+---------------------------------------------------------------------------+
......@@ -5433,6 +5434,13 @@ render mode might dynamically control the rendered link.
10.sql = SELECT CONCAT('u:', p.homepage, IF(p.showHomepage='yes', '|r:0', '|r:5') ) AS _link FROM Person AS p
Tip:
An easy way to switch between different options of rendering a link, incl. Bootstrap buttons, is to use the render mode.
* no render mode or 'r:0' - the full functional link/button.
* 'r:3' - the link/button is rendered with text/image/glyph/tooltip ... but without a HTML a-tag! For Bootstrap button, the button get the 'disabled' class.
* 'r:5' - no link/button at all.
Link Examples
^^^^^^^^^^^^^
......
......@@ -33,7 +33,7 @@ class Token {
switch ($key) {
case TOKEN_URL:
case TOKEN_MAIL:
break; // No check - can't be generally decided
break; // No check - can't be generally decided
case TOKEN_GLYPH:
throw new UserReportException ("Missing value for token '$key'", ERROR_MISSING_VALUE);
break;
......
......@@ -107,6 +107,7 @@ const NAME_MONITOR = 'monitor';
const FINAL_HREF = 'finalHref';
const FINAL_ANCHOR = 'finalAnchor';
const FINAL_CONTENT = 'finalContent';
const FINAL_CONTENT_PURE = 'finalContentPure';
const FINAL_SYMBOL = 'finalSymbol';
const FINAL_TOOL_TIP = 'finalToolTip';
const FINAL_CLASS = 'finalClass';
......@@ -227,8 +228,6 @@ class Link {
TOKEN_L_APPEND => TOKEN_L_APPEND,
TOKEN_L_INTERVAL => TOKEN_L_INTERVAL,
TOKEN_L_HTML_ID => TOKEN_L_HTML_ID,
];
// Used to find double definitions.
......@@ -335,7 +334,6 @@ class Link {
$this->renderControl[8][0][1] = 0;
$this->renderControl[8][1][0] = 8;
$this->renderControl[8][1][1] = 8;
}
/**
......@@ -587,12 +585,12 @@ class Link {
}
// Download Link needs some extra work
if ($rcTokenGiven[TOKEN_DOWNLOAD]) {
if (isset($rcTokenGiven[TOKEN_DOWNLOAD]) && $rcTokenGiven[TOKEN_DOWNLOAD]) {
$vars = $this->buildDownloadLate($vars);
}
// CopyToClipboard (Download) Link needs some extra work
if ($rcTokenGiven[TOKEN_COPY_TO_CLIPBOARD]) {
if (isset($rcTokenGiven[TOKEN_COPY_TO_CLIPBOARD]) && $rcTokenGiven[TOKEN_COPY_TO_CLIPBOARD]) {
$vars = $this->buildCopyToClipboardLate($vars);
}
......@@ -763,7 +761,7 @@ class Link {
$vars[FINAL_CLASS] = $this->doCssClass($vars);
$vars[FINAL_SYMBOL] = $this->doSymbol($vars);
$vars[FINAL_THUMBNAIL] = $this->doThumbnail($vars);
$vars[FINAL_CONTENT] = $this->doContent($vars); // must be called after doSymbol()
$vars[FINAL_CONTENT] = $this->doContent($vars, $vars[FINAL_CONTENT_PURE]); // must be called after doSymbol()
$vars[FINAL_QUESTION] = $this->doQuestion($vars);
$vars[FINAL_ANCHOR] = $this->doAnchor($vars);
......@@ -1030,7 +1028,7 @@ class Link {
* @throws UserFormException
* @throws UserReportException
*/
private function doContent(array $vars) {
private function doContent(array $vars, &$contentPure) {
$arr = array();
if ($vars[NAME_MONITOR] == '1') {
......@@ -1044,13 +1042,9 @@ class Link {
$arr[] = $vars[$key];
}
}
$content = implode(' ', $arr);
if ($vars[NAME_EXTRA_CONTENT_WRAP] != '') {
$content = Support::wrapTag($vars[NAME_EXTRA_CONTENT_WRAP], $content);
}
return $content;
$contentPure = implode(' ', $arr);
return Support::wrapTag($vars[NAME_EXTRA_CONTENT_WRAP], $contentPure);
}
/**
......@@ -1168,7 +1162,7 @@ EOF;
*/
private function getModeRender(array $vars, array $tokenGiven) {
if ($tokenGiven[TOKEN_COPY_TO_CLIPBOARD]) {
if (isset($tokenGiven[TOKEN_COPY_TO_CLIPBOARD]) && $tokenGiven[TOKEN_COPY_TO_CLIPBOARD]) {
if ($vars[NAME_RENDER] == '0') {
$vars[NAME_RENDER] = RENDER_MODE_1;
}
......@@ -1385,6 +1379,11 @@ EOF;
$vars[NAME_GLYPH_TITLE] = "Download";
}
// No download link! Only text/button
if($vars[NAME_RENDER]=='3'){
return $vars;
}
$text = DOWNLOAD_POPUP_REPLACE_TEXT;
$title = DOWNLOAD_POPUP_REPLACE_TITLE;
......
This diff is collapsed.
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