diff --git a/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php b/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php index a4946f2..113682f 100755 --- a/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php +++ b/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php @@ -29,6 +29,9 @@ use PhpOffice\PhpWord\Shared\ZipArchive; class TemplateProcessor { const MAXIMUM_REPLACEMENTS_DEFAULT = -1; + private int $countRels = 100; //start id for relationship between image and document.xml + private $rels; + private $types; /** * ZipArchive object. @@ -130,7 +133,8 @@ class TemplateProcessor $this->tempDocumentSettingsPart = $this->readPartWithRels($this->getSettingsPartName()); $this->tempDocumentContentTypes = $this->zipClass->getFromName($this->getDocumentContentTypesName()); - $this->_countRels=100; //start id for relationship between image and document.xml + // DEPRECATED + //$this->_countRels=100; //start id for relationship between image and document.xml } /** @@ -841,13 +845,22 @@ class TemplateProcessor $this->zipClass->addFromString($this->getDocumentContentTypesName(), $this->tempDocumentContentTypes); - if(isset($this->_rels) && $this->_rels!="") + /*if(isset($this->_rels) && $this->_rels!="") { $this->zipClass->addFromString('word/_rels/document.xml.rels', $this->_rels); } if(isset($this->_types) && $this->_types!="") { $this->zipClass->addFromString('[Content_Types].xml', $this->_types); + }*/ + + if(isset($this->rels) && $this->rels!="") + { + $this->zipClass->addFromString('word/_rels/document.xml.rels', $this->rels); + } + if(isset($this->types) && $this->types!="") + { + $this->zipClass->addFromString('[Content_Types].xml', $this->types); } // Close zip file @@ -1270,7 +1283,7 @@ class TemplateProcessor $toAdd = $toAddImg = $toAddType = ''; $aSearch = array('RID', 'IMG'); $aSearchType = array('IMG', 'EXT'); - $countrels=$this->_countRels++; + $countrels=$this->countRels++; //I'm work for jpg files, if you are working with other images types -> Write conditions here $imgExt = 'jpg'; $imgName = 'img' . $countrels . '.' . $imgExt; @@ -1330,14 +1343,23 @@ class TemplateProcessor - if(!isset($this->_rels) || (isset($this->_rels) && $this->_rels=="")) + /*if(!isset($this->_rels) || (isset($this->_rels) && $this->_rels=="")) { $this->_rels=$this->zipClass->getFromName('word/_rels/document.xml.rels'); $this->_types=$this->zipClass->getFromName('[Content_Types].xml'); } $this->_types = str_replace('', $toAddType, $this->_types) . ''; - $this->_rels = str_replace('', $toAdd, $this->_rels) . ''; + $this->_rels = str_replace('', $toAdd, $this->_rels) . '';*/ + + if(!isset($this->rels) || (isset($this->rels) && $this->rels=="")) + { + $this->rels=$this->zipClass->getFromName('word/_rels/document.xml.rels'); + $this->types=$this->zipClass->getFromName('[Content_Types].xml'); + } + + $this->types = str_replace('', $toAddType, $this->types) . ''; + $this->rels = str_replace('', $toAdd, $this->rels) . ''; } function limpiarString($str) {