Commit 060075a6 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes bug that no mime_type_content is called if there is on file.

parent dc1410b7
Pipeline #2757 passed with stages
in 4 minutes and 10 seconds
...@@ -7080,7 +7080,7 @@ Parameter and (element) sources ...@@ -7080,7 +7080,7 @@ Parameter and (element) sources
* *uid*: `uid:<tt-content record id>` - the tt_content.uid of a QFQ PageContent record (shown on hover in the backend). This will render * *uid*: `uid:<tt-content record id>` - the tt_content.uid of a QFQ PageContent record (shown on hover in the backend). This will render
only the specified QFQ content record, without any Typo3 layout elements (Menu, Body,...) only the specified QFQ content record, without any Typo3 layout elements (Menu, Body,...)
QFQ will retrieve the tt-content's bodytext from the Typo3 database, parse it, and render it as a PDF. Parameters can be QFQ will retrieve the tt-content's bodytext from the Typo3 database, parse it, and render it as a PDF. Parameters can be
passed: `uid:<tt-content record id>[?arg1=value1][&arg2=value2][...]` and will be available in the SIP store for the QFQ PageContent, passed: `uid:<tt-content record id>[&arg1=value1][&arg2=value2][...]` and will be available in the SIP store for the QFQ PageContent,
or passed as wkhtmltopdf arguments, if applicable. or passed as wkhtmltopdf arguments, if applicable.
* *WKHTML Options* for `page`, `urlParam` or `url`: * *WKHTML Options* for `page`, `urlParam` or `url`:
......
...@@ -222,19 +222,19 @@ class Download { ...@@ -222,19 +222,19 @@ class Download {
/** /**
* Get the mimetype of $filename and store them in $rcMimetype. * Get the mimetype of $filename and store them in $rcMimetype.
* Checks if the extension of $outputFilename fit's to the mimetype. If not, append the mimetype extension.
* *
* @param string $filename * @param string $pathFileName
* @param string $outputFilename * @param string $outputFilename
* @param string $rcMimetype * @param string $rcMimetype
* *
* @return string possible updated $outputFilename, according the mimetype. * @return string possible updated $outputFilename, according the mimetype.
*/ */
private private function targetFilenameExtension($pathFileName, $outputFilename, &$rcMimetype) {
function targetFilenameExtension($filename, $outputFilename, &$rcMimetype) {
$rcMimetype = mime_content_type($filename); if ($pathFileName != '' && file_exists($pathFileName)) {
$rcMimetype = mime_content_type($pathFileName);
}
return $outputFilename; return $outputFilename;
} }
...@@ -245,8 +245,7 @@ class Download { ...@@ -245,8 +245,7 @@ class Download {
* @param $outputFilename * @param $outputFilename
* @throws \DownloadException * @throws \DownloadException
*/ */
private private function outputFile($file, $outputFilename) {
function outputFile($file, $outputFilename) {
$json = ''; $json = '';
$flagJson = ($this->getOutputFormat() === DOWNLOAD_OUTPUT_FORMAT_JSON); $flagJson = ($this->getOutputFormat() === DOWNLOAD_OUTPUT_FORMAT_JSON);
...@@ -295,14 +294,16 @@ class Download { ...@@ -295,14 +294,16 @@ class Download {
* @throws \CodeException * @throws \CodeException
* @throws \DbException * @throws \DbException
* @throws \DownloadException * @throws \DownloadException
* @throws \UserFormException
* @throws \UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \UserFormException
* @throws \UserReportException
*/ */
private private function getElement($element, $downloadMode, &$rcData) {
function getElement($element, $downloadMode, &$rcData) {
$filename = ''; $filename = '';
$rcArgs = array(); $rcArgs = array();
...@@ -391,8 +392,7 @@ class Download { ...@@ -391,8 +392,7 @@ class Download {
* @throws \UserFormException * @throws \UserFormException
* @throws \UserReportException * @throws \UserReportException
*/ */
private private function getEvaluatedBodyText($uid, $urlParam) {
function getEvaluatedBodyText($uid, $urlParam) {
foreach ($urlParam as $key => $paramValue) { foreach ($urlParam as $key => $paramValue) {
$this->store->setVar($key, $paramValue, STORE_SIP); $this->store->setVar($key, $paramValue, STORE_SIP);
} }
...@@ -415,8 +415,7 @@ class Download { ...@@ -415,8 +415,7 @@ class Download {
* @return string ZIP filename - has to be deleted later. * @return string ZIP filename - has to be deleted later.
* @throws \DownloadException * @throws \DownloadException
*/ */
private private function zipFiles(array $files) {
function zipFiles(array $files) {
$zipFile = HelperFile::tempnam(); $zipFile = HelperFile::tempnam();
if (false === $zipFile) { if (false === $zipFile) {
...@@ -462,14 +461,16 @@ class Download { ...@@ -462,14 +461,16 @@ class Download {
* @throws \CodeException * @throws \CodeException
* @throws \DbException * @throws \DbException
* @throws \DownloadException * @throws \DownloadException
* @throws \UserFormException
* @throws \UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \UserFormException
* @throws \UserReportException
*/ */
private private function doElements(array $vars, $outputMode) {
function doElements(array $vars, $outputMode) {
$tmpFiles = array(); $tmpFiles = array();
...@@ -590,8 +591,7 @@ class Download { ...@@ -590,8 +591,7 @@ class Download {
* @throws \UserFormException * @throws \UserFormException
* @throws \UserReportException * @throws \UserReportException
*/ */
private private function doThumbnail($urlParam) {
function doThumbnail($urlParam) {
$thumbnail = new Thumbnail(); $thumbnail = new Thumbnail();
$pathFilenameThumbnail = $thumbnail->process($urlParam, THUMBNAIL_VIA_DOWNLOAD); $pathFilenameThumbnail = $thumbnail->process($urlParam, THUMBNAIL_VIA_DOWNLOAD);
...@@ -609,14 +609,16 @@ class Download { ...@@ -609,14 +609,16 @@ class Download {
* @throws \CodeException * @throws \CodeException
* @throws \DbException * @throws \DbException
* @throws \DownloadException * @throws \DownloadException
* @throws \UserFormException
* @throws \UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception * @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \UserFormException
* @throws \UserReportException
*/ */
public public function process($vars, $outputMode = OUTPUT_MODE_DIRECT) {
function process($vars, $outputMode = OUTPUT_MODE_DIRECT) {
if (!is_array($vars)) { if (!is_array($vars)) {
$vars = $this->store->getStore(STORE_SIP); $vars = $this->store->getStore(STORE_SIP);
...@@ -630,16 +632,14 @@ class Download { ...@@ -630,16 +632,14 @@ class Download {
/** /**
* @param $outputFormat * @param $outputFormat
*/ */
private private function setOutputFormat($outputFormat) {
function setOutputFormat($outputFormat) {
$this->outputFormat = $outputFormat; $this->outputFormat = $outputFormat;
} }
/** /**
* @return string - DOWNLOAD_OUTPUT_FORMAT_RAW | DOWNLOAD_OUTPUT_FORMAT_JSON * @return string - DOWNLOAD_OUTPUT_FORMAT_RAW | DOWNLOAD_OUTPUT_FORMAT_JSON
*/ */
public public function getOutputFormat() {
function getOutputFormat() {
return $this->outputFormat; return $this->outputFormat;
} }
} }
......
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