Skip to content

Commit

Permalink
Merge pull request #495 from splitbrain/autoload
Browse files Browse the repository at this point in the history
require autoloader
  • Loading branch information
Klap-in authored Sep 15, 2023
2 parents f2422a5 + facf2f2 commit 2b01138
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
8 changes: 5 additions & 3 deletions DokuPDF.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

// phpcs:disable: PSR1.Methods.CamelCapsMethodName.NotCamelCaps

use Mpdf\Mpdf;
use dokuwiki\plugin\dw2pdf\DokuImageProcessorDecorator;
use Mpdf\Mpdf;
use Mpdf\MpdfException;

/**
* Wrapper around the mpdf library class
Expand All @@ -21,14 +22,15 @@ class DokuPDF extends Mpdf
* @param string $pagesize
* @param string $orientation
* @param int $fontsize
*
* @throws MpdfException
* @throws Exception
*/
public function __construct($pagesize = 'A4', $orientation = 'portrait', $fontsize = 11, $docLang = 'en')
{
global $conf;
global $lang;

require_once __DIR__ . '/vendor/autoload.php';

if (!defined('_MPDF_TEMP_PATH')) {
define('_MPDF_TEMP_PATH', $conf['tmpdir'] . '/dwpdf/' . random_int(1, 1000) . '/');
}
Expand Down
33 changes: 15 additions & 18 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class action_plugin_dw2pdf extends ActionPlugin
*/
public function __construct()
{
require_once __DIR__ . '/vendor/autoload.php';

$this->tpl = $this->getExportConfig('template');
}

Expand Down Expand Up @@ -540,7 +542,7 @@ protected function generatePDF($cachefile, $event)

$body_end .= '</div>';

$mpdf->WriteHTML($body_end, 2, false, true); // finish body html
$mpdf->WriteHTML($body_end, 2, false); // finish body html
if ($isDebug) {
$html .= $body_end;
$html .= '</body>';
Expand Down Expand Up @@ -763,6 +765,8 @@ public function replaceDate($match)

/**
* Load all the style sheets and apply the needed replacements
*
* @return string css styles
*/
protected function loadCSS()
{
Expand Down Expand Up @@ -792,26 +796,19 @@ protected function loadCSS()
$css .= css_loadfile($file, $location);
}

if (function_exists('css_parseless')) {
// apply pattern replacements
if (function_exists('css_styleini')) {
// compatiblity layer for pre-Greebo releases of DokuWiki
$styleini = css_styleini($conf['template']);
} else {
// Greebo functionality
$styleUtils = new StyleUtils();
$styleini = $styleUtils->cssStyleini($conf['template']); // older versions need still the template
}
$css = css_applystyle($css, $styleini['replacements']);

// parse less
$css = css_parseless($css);
// apply pattern replacements
if (function_exists('css_styleini')) {
// compatiblity layer for pre-Greebo releases of DokuWiki
$styleini = css_styleini($conf['template']);
} else {
// @deprecated 2013-12-19: fix backward compatibility
$css = css_applystyle($css, DOKU_INC . 'lib/tpl/' . $conf['template'] . '/');
// Greebo functionality
$styleUtils = new StyleUtils();
$styleini = $styleUtils->cssStyleini($conf['template']); // older versions need still the template
}
$css = css_applystyle($css, $styleini['replacements']);

return $css;
// parse less
return css_parseless($css);
}

/**
Expand Down

0 comments on commit 2b01138

Please sign in to comment.