Commit 1933d434 authored by Carsten  Rose's avatar Carsten Rose

WIP #10443 - HTML Code kann erzeugt werden via '... AS _link'

parent 216a3ae0
Pipeline #3475 failed with stages
in 1 minute and 54 seconds
......@@ -1831,6 +1831,16 @@ const REPORT_TOKEN_FINAL_VALUE = '&';
const WKHTML_OPTION_VIEWPORT = '--viewport-size';
const WKHTML_OPTION_VIEWPORT_VALUE = '1280x1024';
const DATA_ACTION = 'data-action';
const DATA_API = 'data-api';
const DATA_PARENT_ID = 'data-parent-id';
const DATA_RESPONSE = 'data-response';
const DATA_ON_ACTION = 'data-on-action';
const DATA_CALLBACK = 'data-callback';
const DATA_REFRESH = 'data-refresh';
const CLASS_QFQ_LIVE = "qfq-live";
// FormAction.php:
const ACTION_ELEMENT_NO_CHANGE = 0;
const ACTION_ELEMENT_MODIFIED = 1;
......
......@@ -123,7 +123,7 @@ class Link {
TOKEN_URL => 'buildUrl',
TOKEN_MAIL => 'buildMail',
TOKEN_PAGE => 'buildPage',
# TOKEN_LIVE => 'buildLive',
// TOKEN_LIVE => 'buildLive',
TOKEN_DOWNLOAD => 'buildDownload',
TOKEN_DROPDOWN => 'buildDropdown',
TOKEN_TOOL_TIP => 'buildToolTip',
......@@ -1361,15 +1361,16 @@ EOF;
}
}
if ($vars[NAME_MONITOR] == '1') {
return 1;
// Monitor & LIVE: return only 0/1 depending if r:5 is set.
if ($vars[NAME_MONITOR] == '1' || $tokenGiven[TOKEN_LIVE] ?? false) {
return ($vars[NAME_RENDER] == RENDER_MODE_5) ? 0 : 1;
}
$modeRender = $vars[NAME_RENDER];
$modeUrl = ($vars[FINAL_HREF] === '') ? 0 : 1;
$modeText = ($vars[FINAL_CONTENT] === '') ? 0 : 1;
// Create 'fake' modes for encrypted 'mailto'
// Create 'fake' modes for encrypted 'mailto'.
$prefix = "";
if ($vars[NAME_MAIL] != '') {
$prefix = "1";
......@@ -1676,6 +1677,7 @@ EOF;
* @return mixed
* @throws \CodeException
* @throws \UserFormException
* @throws \UserReportException
*/
private function buildLiveLate($vars) {
......@@ -1683,17 +1685,31 @@ EOF;
$htmlIdCount++;
$arr = $this->sip->queryStringToSip(API_DIR_EXT . '/' . API_LIVE_PHP . '?' . $vars[TOKEN_UID], RETURN_ARRAY);
$url = $arr[SIP_SIP_URL];
// By default: Live links should be SIP encoded.
if (($vars[NAME_SIP]) === false) {
$vars[NAME_SIP] = "1";
}
$uid = $vars[TOKEN_UID] ?? '';
if ($vars[NAME_SIP] === "1") {
$paramArray = $this->sip->queryStringToSip(API_DIR . '/' . API_LIVE_PHP . '?' . $uid, RETURN_ARRAY);
$url = $paramArray[SIP_SIP_URL];
if (Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))) {
$vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . $this->sip->debugSip($paramArray);
}
} else {
$url = API_DIR . '/' . API_LIVE_PHP . '?' . $uid;
}
$attributes = Support::doAttribute('id', $this->ttContentUid . '_' . $htmlIdCount);
$attributes .= Support::doAttribute('action', $vars[TOKEN_L_ACTION]);
$attributes .= Support::doAttribute('data-sip', $url);
$attributes .= Support::doAttribute('data-parent-id', $vars[TOKEN_L_PARENT_ID]);
$attributes .= Support::doAttribute('data-response', $vars[TOKEN_L_RESPONSE]);
$attributes .= Support::doAttribute('on', $vars[TOKEN_L_ON]);
$attributes .= Support::doAttribute('data-callback', $vars[TOKEN_L_CALLBACK]);
$attributes .= Support::doAttribute('data-refresh', $vars[TOKEN_L_REFRESH]);
$attributes .= Support::doAttribute('class', CLASS_QFQ_LIVE);
$attributes .= Support::doAttribute(DATA_ACTION, $vars[TOKEN_L_ACTION] ?? '');
$attributes .= Support::doAttribute(DATA_API, $url);
$attributes .= Support::doAttribute(DATA_PARENT_ID, $vars[TOKEN_L_PARENT_ID] ?? '');
$attributes .= Support::doAttribute(DATA_RESPONSE, $vars[TOKEN_L_RESPONSE] ?? '');
$attributes .= Support::doAttribute(DATA_ON_ACTION, $vars[TOKEN_L_ON] ?? '');
$attributes .= Support::doAttribute(DATA_CALLBACK, $vars[TOKEN_L_CALLBACK] ?? '');
$attributes .= Support::doAttribute(DATA_REFRESH, $vars[TOKEN_L_REFRESH] ?? '');
$vars[NAME_EXTRA_CONTENT_WRAP] = "<div $attributes>";
......
......@@ -1507,6 +1507,35 @@ EOF;
$this->assertEquals($expect, $result);
}
/**
* @throws \CodeException
* @throws \UserFormException
* @throws \UserReportException
*/
public function testLinkLive() {
$link = new Link($this->sip, DB_INDEX_DEFAULT, true);
Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3);
$expect = '<div id="_1" class="qfq-live" data-api="typo3conf/ext/qfq/Classes/Api/live.php?id=&s=badcaffee1234" ></div>';
$result = $link->renderLink('l');
$this->assertEquals($expect, $result);
$expect = '<div id="_2" class="qfq-live" data-api="typo3conf/ext/qfq/Classes/Api/live.php?id=1234&s=badcaffee1234" ></div>';
$result = $link->renderLink('l|uid:1234');
$this->assertEquals($expect, $result);
$expect = '<div id="_3" class="qfq-live" data-api="typo3conf/ext/qfq/Classes/Api/live.php?id=1234&s=badcaffee1234" >hello world</div>';
$result = $link->renderLink('l|uid:1234|t:hello world');
$this->assertEquals($expect, $result);
$result = $link->renderLink('l|uid:1234|t:hello world|r:5');
$this->assertEquals('', $result);
$result = $link->renderLink('l|uid:1234|t:hello world|r:3');
$this->assertEquals('', $result);
}
/**
* @expectedException UserReportException
*
......
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