[*] PDF : Display Hook
This commit is contained in:
@@ -43,8 +43,6 @@ abstract class HTMLTemplateCore
|
||||
*/
|
||||
public function getHeader()
|
||||
{
|
||||
$this->assignHookData();
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'logo_path' => $this->getLogo(),
|
||||
'img_ps_dir' => 'http://'.Tools::getMediaServer(_PS_IMG_)._PS_IMG_,
|
||||
@@ -94,15 +92,18 @@ abstract class HTMLTemplateCore
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML content of the template's footer
|
||||
*/
|
||||
public function assignHookData()
|
||||
* Assign hook data
|
||||
*
|
||||
* @param $object generally the object used in the constructor
|
||||
*/
|
||||
public function assignHookData($object)
|
||||
{
|
||||
$data = array('title' => 'cool',
|
||||
'delivery' => array('date' => '25/11/11', 'delay' => '3'));
|
||||
$template = ucfirst(str_replace('HTMLTemplate', '', get_class($this)));
|
||||
$hook_name = 'displayPDF'.$template;
|
||||
|
||||
foreach ($data as $key => $value)
|
||||
$this->smarty->assign($key, $value);
|
||||
$this->smarty->assign(array(
|
||||
'HOOK_DISPLAY_PDF' => Hook::exec($hook_name, array('object' => $object))
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+8
-7
@@ -54,7 +54,6 @@ class PDFCore
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
$render = false;
|
||||
$this->pdf_renderer->setFontForLang('fr');
|
||||
foreach ($this->objects as $object)
|
||||
@@ -69,6 +68,8 @@ class PDFCore
|
||||
if (count($this->objects) > 1)
|
||||
$this->filename = $template->getBulkFilename();
|
||||
}
|
||||
|
||||
$template->assignHookData($object);
|
||||
|
||||
$this->pdf_renderer->createHeader($template->getHeader());
|
||||
$this->pdf_renderer->createFooter($template->getFooter());
|
||||
@@ -89,12 +90,12 @@ class PDFCore
|
||||
$class = false;
|
||||
$classname = 'HTMLTemplate'.$this->template;
|
||||
|
||||
if (class_exists($classname))
|
||||
{
|
||||
$class = new $classname($object, $this->smarty);
|
||||
if (!($class instanceof HTMLTemplate))
|
||||
throw new PrestashopException('Invalid class. It should be an instance of HTMLTemplate');
|
||||
}
|
||||
if (class_exists($classname))
|
||||
{
|
||||
$class = new $classname($object, $this->smarty);
|
||||
if (!($class instanceof HTMLTemplate))
|
||||
throw new PrestashopException('Invalid class. It should be an instance of HTMLTemplate');
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user