Merge pull request #57 from RomanSyroeshko/PHPWord#56
Postprocessing of documents returned by Template class before moving to final destination
This commit is contained in:
commit
cc61801ca0
|
|
@ -117,14 +117,9 @@ class PHPWord_Template
|
||||||
/**
|
/**
|
||||||
* Save Template
|
* Save Template
|
||||||
*
|
*
|
||||||
* @param string $strFilename
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function save($strFilename)
|
public function save() {
|
||||||
{
|
|
||||||
if (file_exists($strFilename)) {
|
|
||||||
unlink($strFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);
|
$this->_objZip->addFromString('word/document.xml', $this->_documentXML);
|
||||||
|
|
||||||
// Close zip file
|
// Close zip file
|
||||||
|
|
@ -132,6 +127,21 @@ class PHPWord_Template
|
||||||
throw new Exception('Could not close zip file.');
|
throw new Exception('Could not close zip file.');
|
||||||
}
|
}
|
||||||
|
|
||||||
rename($this->_tempFileName, $strFilename);
|
return $this->_tempFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save Template As...
|
||||||
|
*
|
||||||
|
* @param string $strFilename
|
||||||
|
*/
|
||||||
|
public function saveAs($strFilename) {
|
||||||
|
$tempFilename = $this->save();
|
||||||
|
|
||||||
|
if (file_exists($strFilename)) {
|
||||||
|
unlink($strFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
rename($tempFilename, $strFilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue