Commit 9723404b authored by Carsten  Rose's avatar Carsten Rose
Browse files

'download' optional SIP encoded.

Manual.rst: describe new urlParam parameter `_sip`
Html2Pdf.php: optional SIP encoding
parent 7a30629e
......@@ -60,8 +60,6 @@ The converter is not included in QFQ and has to be manually installed.
* The Ubuntu package `wkhtmltopdf` needs a running Xserver - this does not work on a headless webserver. Best is to
install the QT version from the named website above.
* FE_GROUP protected pages/tt-content are not accessible via `wkhtmltopdf`.
* SIPs can't be used via `wkhtmltopdf`.
In `config-qfq-ini`_ specify the:
......@@ -328,6 +326,7 @@ Access privileges
-----------------
The Typo3 FE Groups can be used to implement access privileges. Such groups are assigned to
* Typo3 FE users,
* Typo3 pages,
* and/or Typo3 content records (e.g. QFQ records).
......@@ -352,13 +351,13 @@ QFQ Keywords (Bodytext)
| Name | Explanation |
+===================+=================================================================================+
| form | Formname defined in ttcontent record bodytext |
| | * Fix. E.g.: **form = person** |
| | * by SIP: **form = {{form}}** |
| | * by SQL: **form = {{SELECT c.form FROM conference AS c WHERE c.id={{a:C}} }}** |
| | - Fix. E.g.: **form = person** |
| | - by SIP: **form = {{form}}** |
| | - by SQL: **form = {{SELECT c.form FROM conference AS c WHERE c.id={{a:C}} }}** |
+-------------------+---------------------------------------------------------------------------------+
| r | <record id> The form will load the record with the specified id |
| | * Variants: **r = 123**, by SQL: **r = {{SELECT ...}}** |
| | * If not specified, the default is '0' |
| | - Variants: **r = 123**, by SQL: **r = {{SELECT ...}}** |
| | - If not specified, the default is '0' |
+-------------------+---------------------------------------------------------------------------------+
| <level>.db | Select a DB. Only necessary if a different than the standard DB should be used. |
+-------------------+---------------------------------------------------------------------------------+
......@@ -3639,15 +3638,22 @@ Parameter and (element) sources
in a PDF or ZIP.
* *urlParam*: `U:id=<t3 page>&<key 1>=<value 1>&<key 2>=<value 2>&...&<key n>=<value n>`.
Any QFQ internal parameter will be automatically converted to a SIP.
* By default, the options given to wkhtml will *not* be encoded by a SIP!
* To encode the parameter via SIP: Add '_sip=1' to the URL GET parameter.
E.g. `U:id=form&_sip=1&form=Person&r=1`.
In that way, specific sources for the `download` might be SIP encrypted.
* Any current HTML cookies will be forwarded to/via `wkhtml`. This includes the active FE / BE Login as well as any QFQ session.
* *url*: `u:<url>` - any URL, pointing to an internal or external destination.
* *Options* for `urlParam` or `url`:
* *WKHTML Options* for `urlParam` or `url`:
* The 'HTML to PDF' will be done via `wkhtmltopdf`.
* All possible options, suitable for `wkhtmltopdf`, can be submitted in the `u:...` or `U:...` element source.
Check `wkhtmltopdf.txt <https://wkhtmltopdf.org/usage/wkhtmltopdf.txt>`_ for all possible options. Be aware that
Check `wkhtmltopdf.txt <https://wkhtmltopdf.org/usage/wkhtmltopdf.txt>`_ for possible options. Be aware that
key/value tuple in the documentation is separated by a space, but to respect the QFQ key/value notation of URLs,
the key/value tuple in `u:...` or `U:...` has to be separated by '='. Please see last example below.
......@@ -3667,6 +3673,9 @@ Example: ::
# three sources: two pages and one file
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1|U:id=detail2&r=1|f:fileadmin/pdf/test.pdf" AS _link AS _link
# three sources: two pages and one file, parameter to wkhtml will be SIP encoded
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1&_sip=1|U:id=detail2&r=1&_sip=1|f:fileadmin/pdf/test.pdf" AS _link AS _link
# three sources: two pages and one file, the second page will be in landscape and pagesize A3
SELECT "d:complete.pdf|s|t:Complete PDF|U:id=detail&r=1|U:id=detail2&r=1&--orientation=Landscape&--page-size=A3|f:fileadmin/pdf/test.pdf" AS _link AS _link
......
......@@ -896,7 +896,7 @@ const DOWNLOAD_MODE_ZIP = 'zip';
const DOWNLOAD_EXPORT_FILENAME = '_exportFilename';
const DOWNLOAD_FILE_PREFIX = 'qfq.temp'; // temporary filename on server of single export file
const DOWNLOAD_OUTPUT_PDF = 'output';
const DOWNLOAD_SIP_ENCODE_PARAMETER = '_sip';
// HTML2PDF
const HTML2PDF_PAGEID = 'id';
......
......@@ -111,20 +111,34 @@ class Html2Pdf {
}
/**
* Split the wkthtml Parameter between:
* - general 'urlParam' for the specific website (page which will be converted to PDF).
* - `wkthml` Parameter. Those will always start with '-' and control wkhtml how to render the PDF.
* - '_sip' - to activate that `urlParam` parameters will be SIP encoded.
*
* @param string $urlParamString
* @param array $rcArgs
* @return array
* @param bool $rcSipEncode
* @return array The remaining 'real' URL parameter to call the T3 page.
* @throws UserFormException
*/
private function splitParam($urlParamString, array &$rcArgs) {
private function splitParam($urlParamString, array &$rcArgs, &$rcSipEncode) {
$urlParamNew = array();
$urlParam = KeyValueStringParser::parse($urlParamString, '=', '&', KVP_IF_VALUE_EMPTY_COPY_KEY);
foreach ($urlParam as $key => $value) {
if (substr($key, 0, 1) == '-') {
switch (substr($key, 0, 1)) {
case '-':
$rcArgs[$key] = $value;
} else {
break;
case '_':
if ($key == DOWNLOAD_SIP_ENCODE_PARAMETER) {
$rcSipEncode = true;
}
break;
default:
$urlParamNew[$key] = $value;
break;
}
}
......@@ -142,7 +156,6 @@ class Html2Pdf {
*/
public function page2pdf($token, $url) {
$rcArgs = array();
$urlParamNew = array();
$urlParamString = '';
$host = '';
......@@ -155,19 +168,19 @@ class Html2Pdf {
case TOKEN_URL_PARAM:
$host = $this->config[SYSTEM_BASE_URL_PRINT];
$urlParamString = $url;
// $url = $this->config[SYSTEM_BASE_URL_PRINT] . '/?' . $url;
break;
default:
break;
}
$urlParam = $this->splitParam($urlParamString, $rcArgs);
$rcSipEncode = false;
$urlParam = $this->splitParam($urlParamString, $rcArgs, $rcSipEncode);
$rcArgs = OnArray::arrayEscapeshellarg($rcArgs);
$options = KeyValueStringParser::unparse($rcArgs, ' ', ' ');
$urlParamString = KeyValueStringParser::unparse($urlParam, '=', '&');
if ($token == TOKEN_URL_PARAM) {
if ($rcSipEncode) {
$urlParamString = $this->sip->queryStringToSip($urlParamString, RETURN_URL);
}
......
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