Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require autoloader #495

Merged
merged 3 commits into from
Sep 15, 2023
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
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