Commit 9fb20689 authored by Carsten  Rose's avatar Carsten Rose
Browse files

F6358: Copy to clipboard - uri implemented, untested

parent 62da0ee1
Pipeline #648 passed with stage
in 1 minute and 43 seconds
......@@ -397,9 +397,10 @@ A download might be:
* an export of several files as a ZIP archive,
* an export of a T3-'XML'-Page converted to Excel,
* a converted HTML page to PDF,
* a PDF file, concatenated on single PDF files and/or converted HTML page to PDF.
* a thumbnail, streamed from cache dir of if not present/recent rendered on request.
* a file to monitor constantly.
* a PDF file, concatenated on single PDF files and/or converted HTML page to PDF,
* a thumbnail, streamed from cache dir of if not present/recent rendered on request,
* a file to monitor constantly,
* a file, delivered as a JSON structure, used in 'copy to clipboard',
'api/download.php' will be called with a SIP (no other vars used). The SIP contains:
* DOWNLOAD_EXPORT_FILENAME - any target filename, if none given take DOWNLOAD_OUTPUT_PDF ('output.pdf').
......@@ -444,13 +445,18 @@ A download might be:
* append: 0|1
The retrieved lines are outputted without any conversion.
* DOWNLOAD_OUTPUT_FORMAT: raw (default), json
* If this parameter is missing, 'raw' ist meant.
* 'json' is used for 'copy to clipboard'.
* The base64 encoding is necessary:
* to deliver multiple elements with the same token (e.g. multiple PDF files to concatenate).
* special parameter names, like 'id', should not force the regular interpretation of 'id' during conversion to a SIP.
During preparing and delivering the download ()file / pdf / excel / zip), a popup shows a spinning gear by default. The
During preparing and delivering the download (file / pdf / excel / zip), a popup shows a spinning gear by default. The
popup itself will display an individual message. The popup needs some HTML code (only once per T3 page).
Download links might be generated in `report` as well as in `subrecords of forms`. To trigger the generation of the HTML
popup code, a variable DOWNLOAD_POPUP_REQUEST in STORE_SYSTEM will be set to 'true' (string) in class Link(), as soon as
......
......@@ -31,6 +31,10 @@ try {
// If all is fine - 'process()' never returns! The output file is delivered and PHP is stopped after that.
$data = $download->process(STORE_SIP, OUTPUT_MODE_DIRECT);
if ($download->getOutputFormat() === DOWNLOAD_OUTPUT_FORMAT_JSON) {
$data = json_encode([JSON_TEXT => $data]);
}
} catch (qfq\CodeException $e) {
$data = $e->formatMessage();
} catch (qfq\DbException $e) {
......
......@@ -1326,6 +1326,10 @@ const DOWNLOAD_EXPORT_FILENAME = '_exportFilename';
const TMP_FILE_PREFIX = 'qfq.temp.'; // temporary filename on server of single export file
const DOWNLOAD_OUTPUT_FILENAME = 'output';
const DOWNLOAD_SIP_ENCODE_PARAMETER = '_sip';
const DOWNLOAD_OUTPUT_FORMAT = '_dataFormat';
const DOWNLOAD_OUTPUT_FORMAT_RAW = 'raw';
const DOWNLOAD_OUTPUT_FORMAT_JSON = 'json';
const JSON_TEXT = 'text';
const OUTPUT_MODE_DIRECT = 'direct';
const OUTPUT_MODE_FILE = 'file';
......
......@@ -66,6 +66,11 @@ class Download {
*/
private $downloadDebugLog = '';
/**
* @var string DOWNLOAD_OUTPUT_FORMAT_RAW | DOWNLOAD_OUTPUT_FORMAT_JSON
*/
private $outputFormat = DOWNLOAD_OUTPUT_FORMAT_RAW;
/**
* @param bool|false $phpUnit
* @throws CodeException
......@@ -101,7 +106,7 @@ class Download {
// Check that all files exist and readable
foreach ($files AS $filename) {
if(!is_readable($filename)){
if (!is_readable($filename)) {
throw new downloadException("Error reading file $filename. Not found or no permission", ERROR_DOWNLOAD_FILE_NOT_READABLE);
}
}
......@@ -299,7 +304,7 @@ class Download {
$downloadMode = $vars[DOWNLOAD_MODE];
if($downloadMode == DOWNLOAD_MODE_MONITOR){
if ($downloadMode == DOWNLOAD_MODE_MONITOR) {
$monitor = new Monitor();
return $monitor->dump($vars[TOKEN_L_FILE], $vars[TOKEN_L_TAIL], $vars[TOKEN_L_APPEND]);
......@@ -410,8 +415,23 @@ class Download {
$vars = $this->store->getStore(STORE_SIP);
}
$this->setOutputFormat(empty($vars[DOWNLOAD_OUTPUT_FORMAT]) ? DOWNLOAD_OUTPUT_FORMAT_RAW : $vars[DOWNLOAD_OUTPUT_FORMAT]);
return $this->doElements($vars, $outputMode);
}
/**
* @param $outputFormat
*/
private function setOutputFormat($outputFormat) {
$this->outputFormat = $outputFormat;
}
/**
* @return string - DOWNLOAD_OUTPUT_FORMAT_RAW | DOWNLOAD_OUTPUT_FORMAT_JSON
*/
public function getOutputFormat() {
return $this->outputFormat;
}
}
......@@ -839,7 +839,7 @@ class Link {
$tmpUrlParam = array();
$tmpUrlParam[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE;
// $tmpUrlParam[DOWNLOAD_EXPORT_FILENAME] = $vars[NAME_DOWNLOAD];
$tmpUrlParam[DOWNLOAD_OUTPUT_FORMAT] = DOWNLOAD_OUTPUT_FORMAT_JSON;
$tmpUrlParam[SIP_DOWNLOAD_PARAMETER] = base64_encode(implode(PARAM_DELIMITER, $vars[NAME_COLLECT_ELEMENTS]));
$vars[NAME_URL_PARAM] = KeyValueStringParser::unparse($tmpUrlParam, '=', '&');
}
......@@ -1401,6 +1401,8 @@ EOF;
* @param $vars
* @return array
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
private function buildCopyToClipboardLate($vars) {
......@@ -1420,13 +1422,26 @@ EOF;
$attributes = Support::doAttribute('class', $bootstrapButton, true);
if ($vars[NAME_COPY_TO_CLIPBOARD] !== '') {
$value = $vars[NAME_COPY_TO_CLIPBOARD];
$source = "{text: '" . $vars[NAME_COPY_TO_CLIPBOARD] ." '}";
} elseif ($vars[NAME_FILE] !== ''){
$tmpUrlParam[SIP_DOWNLOAD_PARAMETER] = base64_encode(implode(PARAM_DELIMITER, $vars[NAME_COLLECT_ELEMENTS]));
$urlNParam = KeyValueStringParser::unparse($tmpUrlParam, '=', '&');
$vars[NAME_URL] = API_DIR . '/' . API_DOWNLOAD_PHP;
$paramArray = $this->sip->queryStringToSip($urlNParam, RETURN_ARRAY);
$urlNParam = $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);
}
$source = "{uri: '" .API_DIR . '/' . API_DOWNLOAD_PHP . '&s=' . $paramArray[SIP_SIP_URL] . " '}";
$onClick = <<<EOF
onClick="new QfqNS.Clipboard({text: '$value'});"
EOF;
}
$onClick = "onClick=\"new QfqNS.Clipboard($source);\"";
// <button class="btn btn-info"
// onClick="new QfqNS.Clipboard({text: 'test clipboard'});">
......
......@@ -443,7 +443,7 @@ VALUES
'extraButtonInfo = Query: &#123;&#123;!SELECT ... as sendMailTo...&#125;&#125;<br><b>sendMailTo / sendMailCc / sendMailBcc</b>: Separate multiple by comma.<br><b>sendMailFrom</b><br><b>sendMailSubject</b><br><b>sendMailReplyTo</b>: Optional<br><b>sendMailFlagAutoSubmit</b>: Optional. on|off. Default on - if "on", suppresses OoO answers from receivers.<br><b>sendMailGrId</b>: Optional<br><b>sendMailXId</b>: Optional',
'60,4', '', 'yes', '', '', ''),
(4, 'content', '{{SELECT IF("{{type:FR:alnumx}}"="mail","Mail body","URL") }}', 'show', '', 'text', 'none', 'all', 70,
'extraButtonInfo = Website: URL absolute like "http://..." or relative like "?id=pagealias..."<br>Mail: Static Body or &#123;{SELECT ...&#125;}', '40,4', '', 'yes', '', '', ''),
'', '40,4', 'Website: URL absolute like "http://..." or relative like "?id=pagealias..."<br>Mail: Static Body or &#123;{SELECT ...&#125;}', 'yes', '', '', ''),
(4, 'outputFile', 'Log output to file', 'show', '{{SELECT IF("{{type:FR:alnumx}}"="mail","hidden","show") }}', 'text', 'none', 'all', 80, '', '', 'CWD: Site installation directory', 'yes', '', '', ''),
(4, 'outputMode', 'Mode output', 'show', '{{SELECT IF("{{type:FR:alnumx}}"="mail","hidden","show") }}', 'radio', 'specialchar', 'alnumx', 90, 'buttonClass=btn-default', '', '', 'yes', '', '', ''),
......
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