New: Support tags into header and footer into ODT templates
This commit is contained in:
parent
0370e06c84
commit
ec542f5ee5
@ -62,6 +62,7 @@ For users:
|
||||
- New: Add hidden option MAIN_ADD_PDF_BACKGROUND to add a PDF as background of invoice/order generated PDF.
|
||||
- New: Can convert a product/service into service/product.
|
||||
- New: Show delivery date into proposal template azur.
|
||||
- New: Support tags into header and footer into ODT templates.
|
||||
- Fix: Can use POS module with several concurrent users.
|
||||
- Fix: Installer don't fails with Mysql version that added a ssl_cypher field.
|
||||
- Fix: Sanitize input parameters.
|
||||
|
||||
@ -23,6 +23,7 @@ class Odf
|
||||
);
|
||||
protected $file;
|
||||
protected $contentXml; // To store content of content.xml file
|
||||
protected $stylesXml; // To store content of styles.xml file
|
||||
protected $manifestXml; // To store content of META-INF/manifest.xml file
|
||||
protected $tmpfile;
|
||||
protected $tmpdir='';
|
||||
@ -83,6 +84,9 @@ class Odf
|
||||
if (($this->manifestXml = $this->file->getFromName('META-INF/manifest.xml')) === false) {
|
||||
throw new OdfException("Something is wrong with META-INF/manifest.xm in source file '$filename'");
|
||||
}
|
||||
if (($this->stylesXml = $this->file->getFromName('styles.xml')) === false) {
|
||||
throw new OdfException("Nothing to parse - Check that the styles.xml file is correctly formed in source file '$filename'");
|
||||
}
|
||||
$this->file->close();
|
||||
|
||||
|
||||
@ -181,11 +185,13 @@ IMG;
|
||||
* Merge template variables
|
||||
* Called automatically for a save
|
||||
*
|
||||
* @param string $type 'content' or 'styles'
|
||||
* @return void
|
||||
*/
|
||||
private function _parse()
|
||||
private function _parse($type='content')
|
||||
{
|
||||
$this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml);
|
||||
if ($type == 'content') $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml);
|
||||
if ($type == 'styles') $this->stylesXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->stylesXml);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -286,11 +292,16 @@ IMG;
|
||||
*/
|
||||
private function _save()
|
||||
{
|
||||
$res=$this->file->open($this->tmpfile);
|
||||
$this->_parse();
|
||||
$res=$this->file->open($this->tmpfile); // tmpfile is odt template
|
||||
$this->_parse('content');
|
||||
$this->_parse('styles');
|
||||
|
||||
if (! $this->file->addFromString('content.xml', $this->contentXml)) {
|
||||
throw new OdfException('Error during file export addFromString');
|
||||
}
|
||||
if (! $this->file->addFromString('styles.xml', $this->stylesXml)) {
|
||||
throw new OdfException('Error during file export addFromString');
|
||||
}
|
||||
foreach ($this->images as $imageKey => $imageValue) {
|
||||
$this->file->addFile($imageKey, 'Pictures/' . $imageValue);
|
||||
$this->addImageToManifest($imageValue);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user