Skip to content

Commit

Permalink
Merge branch '1.5' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Guite committed Aug 31, 2017
2 parents 4e16502 + 5119424 commit fbd8cb5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/system/RoutesModule/Base/bootstrap.php
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
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
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

0 comments on commit fbd8cb5

Please sign in to comment.