[*] PDF : You can now enable diskcache

This commit is contained in:
fBrignoli
2011-12-15 09:05:16 +00:00
parent 5c96a0bcf6
commit d348f31dec
3 changed files with 21 additions and 33 deletions
+11 -12
View File
@@ -43,7 +43,7 @@ class PDFCore
public function __construct($objects, $template, $smarty) public function __construct($objects, $template, $smarty)
{ {
$this->pdf_renderer = new PDFGenerator(); $this->pdf_renderer = new PDFGenerator((bool)Configuration::get('PS_PDF_USE_CACHE'));
$this->template = $template; $this->template = $template;
$this->smarty = $smarty; $this->smarty = $smarty;
@@ -58,17 +58,17 @@ class PDFCore
$this->pdf_renderer->setFontForLang('fr'); $this->pdf_renderer->setFontForLang('fr');
foreach ($this->objects as $object) foreach ($this->objects as $object)
{ {
$template = $this->getTemplateObject($object); $template = $this->getTemplateObject($object);
if (!$template) if (!$template)
continue; continue;
if (empty($this->filename))
{
$this->filename = $template->getFilename();
if (count($this->objects) > 1)
$this->filename = $template->getBulkFilename();
}
if (empty($this->filename))
{
$this->filename = $template->getFilename();
if (count($this->objects) > 1)
$this->filename = $template->getBulkFilename();
}
$template->assignHookData($object); $template->assignHookData($object);
$this->pdf_renderer->createHeader($template->getHeader()); $this->pdf_renderer->createHeader($template->getHeader());
@@ -82,7 +82,6 @@ class PDFCore
if ($render) if ($render)
$this->pdf_renderer->render($this->filename); $this->pdf_renderer->render($this->filename);
} }
public function getTemplateObject($object) public function getTemplateObject($object)
+3 -3
View File
@@ -44,9 +44,9 @@ class PDFGeneratorCore extends TCPDF
public $font_by_lang = array('jp' => 'cid0jp'); public $font_by_lang = array('jp' => 'cid0jp');
public function __construct() public function __construct($use_cache = false)
{ {
parent::__construct('P', 'mm', 'A4', true, 'UTF-8', false, false); parent::__construct('P', 'mm', 'A4', true, 'UTF-8', $use_cache, false);
} }
/** /**
@@ -90,7 +90,7 @@ class PDFGeneratorCore extends TCPDF
/** /**
* Change the font * Change the font
* @param unknown_type $iso_lang * @param string $iso_lang
*/ */
public function setFontForLang($iso_lang) public function setFontForLang($iso_lang)
{ {
+7 -18
View File
@@ -72,29 +72,18 @@ class AdminPdfControllerCore extends AdminController
'icon' => 'pdf', 'icon' => 'pdf',
'class' => 'width2', 'class' => 'width2',
'fields' => array( 'fields' => array(
'PS_PDF_ENCODING' => array( 'PS_PDF_USE_CACHE' => array(
'title' => $this->l('Encoding:'), 'title' => $this->l('Use disk as cache'),
'desc' => $this->l('Encoding for PDF invoice'), 'desc' => $this->l('Save memory but slow down the rendering process.'),
'type' => 'selectLang', 'validation' => 'isBool',
'cast' => 'strval', 'cast' => 'intval',
'identifier' => 'mode', 'type' => 'bool'
'list' => $this->encoding_list )
),
'PS_PDF_FONT' => array(
'title' => $this->l('Font:'),
'desc' => $this->l('Font for PDF invoice'),
'type' => 'selectLang',
'cast' => 'strval',
'identifier' => 'mode',
'list' => $this->font_list
)
), ),
'submit' => array() 'submit' => array()
) )
); );
$this->context->smarty->assign('custom_key', 'PS_PDF_ENCODING¤PS_PDF_FONT');
parent::__construct(); parent::__construct();
} }
} }