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