Commit fa2d9f96 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3218 / download.php / export

Html2Pdf.php: Fixed a problem with broken adding of '=' to TOKEN_URL. Fixed problem that missing 'http' at the beginning confuses wkhtmltopdf.
parent e10937b6
......@@ -86,8 +86,8 @@ class Html2Pdf {
}
/**
* Converts a Webpag (URL) to a PDF file.
* The URL might be a local Typo3 page or a full URL.
* Converts a Webpage (URL) to a PDF file.
* The URL might be a local Typo3 page (without hostname, starting with the parameter) or a full URL.
*
* @param string $token TOKEN_URL | TOKEN_URL_PARAM
* @param string $url id=exportPage&r=123, www.nzz.ch/issue?id=456
......@@ -97,12 +97,25 @@ class Html2Pdf {
public function page2pdf($token, $url) {
$args = array();
$urlParamNew = array();
if ($token == TOKEN_URL_PARAM) {
$url = $this->config[SYSTEM_BASE_URL_PRINT] . '/?' . $url;
$urlParamString = '';
$host = '';
switch ($token) {
case TOKEN_URL:
$arr = explode('?', $url, 2);
$host = $arr[0];
$urlParamString = empty($arr[1]) ? '' : $arr[1];
break;
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 = KeyValueStringParser::parse($url, '=', '&');
$urlParam = KeyValueStringParser::parse($urlParamString, '=', '&', KVP_IF_VALUE_EMPTY_COPY_KEY);
foreach ($urlParam as $key => $value) {
if (substr($key, 0, 1) == '-') {
$args[$key] = $value;
......@@ -113,7 +126,17 @@ class Html2Pdf {
$args = OnArray::arrayEscapeshellarg($args);
$options = KeyValueStringParser::unparse($args, ' ', ' ');
$url = KeyValueStringParser::unparse($urlParamNew, '=', '&');
$urlParamString = KeyValueStringParser::unparse($urlParamNew, '=', '&');
if ($urlParamString != '') {
if (substr($host, -1, 1) != '/') {
$host .= '/';
}
$url = $host . '?' . $urlParamString;
}
if (substr($url, 0, 4) != 'http') {
$url = 'http://' . $url;
}
$urlPrint = escapeshellarg($url);
$wkhtmlToPdf = $this->config[SYSTEM_WKHTMLTOPDF];
......
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