Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/system/RoutesModule/Base/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Zikula contributors <support@zikula.org>.
* @link http://www.zikula.org
* @link http://zikula.org
* @version Generated by ModuleStudio 1.0.1 (https://modulestudio.de) at Wed Aug 30 15:50:40 CEST 2017.
* @version Generated by ModuleStudio 1.0.1 (https://modulestudio.de) at Thu Aug 31 12:47:48 CEST 2017.
*/

/**
Expand Down
54 changes: 0 additions & 54 deletions src/system/RoutesModule/Helper/Base/AbstractViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ public function processTemplate($type, $func, array $templateParameters = [], $t
$template = $this->getViewTemplate($type, $func);
}

if ($templateExtension == 'pdf.twig') {
$template = str_replace('.pdf', '.html', $template);

return $this->processPdf($templateParameters, $template);
}

// look whether we need output with or without the theme
$raw = $this->request->query->getBoolean('raw', false);
if (!$raw && $templateExtension != 'html.twig') {
Expand Down Expand Up @@ -219,52 +213,4 @@ public function availableExtensions($type, $func)

return $extensions;
}

/**
* Processes a template file using dompdf (LGPL).
*
* @param array $templateParameters Template data
* @param string $template Name of template to use
*
* @return mixed Output
*/
protected function processPdf(array $templateParameters = [], $template)
{
// first the content, to set page vars
$output = $this->twig->render($template, $templateParameters);

// make local images absolute
$output = str_replace('img src="/', 'img src="' . $this->request->server->get('DOCUMENT_ROOT') . '/', $output);

// then the surrounding
$output = $this->twig->render('@ZikulaRoutesModule/includePdfHeader.html.twig') . $output . '</body></html>';

// create name of the pdf output file
$siteName = $this->variableApi->getSystemVar('sitename');
$pageTitle = iconv('UTF-8', 'ASCII//TRANSLIT', $this->pageVars->get('title', ''));
$fileTitle = iconv('UTF-8', 'ASCII//TRANSLIT', $siteName)
. '-'
. ($pageTitle != '' ? $pageTitle . '-' : '')
. date('Ymd') . '.pdf';
$fileTitle = str_replace(' ', '_', $fileTitle);

/*
if (true === $this->request->query->getBoolean('dbg', false)) {
die($output);
}
*/

// instantiate pdf object
$pdf = new \Dompdf\Dompdf();
// define page properties
$pdf->setPaper('A4', 'portrait');
// load html input data
$pdf->loadHtml($output);
// create the actual pdf file
$pdf->render();
// stream output to browser
$pdf->stream($fileTitle);

return new Response();
}
}
2 changes: 1 addition & 1 deletion src/system/RoutesModule/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Zikula contributors <support@zikula.org>.
* @link http://www.zikula.org
* @link http://zikula.org
* @version Generated by ModuleStudio 1.0.1 (https://modulestudio.de) at Wed Aug 30 15:50:40 CEST 2017.
* @version Generated by ModuleStudio 1.0.1 (https://modulestudio.de) at Thu Aug 31 12:47:48 CEST 2017.
*/

/**
Expand Down