From 4f514d215921f01383086c4b0ee0a0fe74987b30 Mon Sep 17 00:00:00 2001 From: Dave Gudgeon Date: Tue, 1 Apr 2014 22:13:03 +0100 Subject: [PATCH] Load any number of headers and footers --- src/PhpWord/Template.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index e38e2a5a..7d933755 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -75,16 +75,17 @@ class Template $this->_objZip = new $zipClass(); $this->_objZip->open($this->_tempFileName); - // Find and load up to three headers and footers - for ($i = 1; $i <= 3; $i++) { - $headerName = $this->getHeaderName($i); - $footerName = $this->getFooterName($i); - if ($this->_objZip->locateName($headerName) !== false) { - $this->_headerXMLs[$i] = $this->_objZip->getFromName($headerName); - } - if ($this->_objZip->locateName($footerName) !== false) { - $this->_footerXMLs[$i] = $this->_objZip->getFromName($footerName); - } + // Find and load headers and footers + $i = 1; + while ($this->_objZip->locateName($this->getHeaderName($i)) !== false) { + $this->_headerXMLs[$i] = $this->_objZip->getFromName($this->getHeaderName($i)); + $i++; + } + + $i = 1; + while ($this->_objZip->locateName($this->getFooterName($i)) !== false) { + $this->_footerXMLs[$i] = $this->_objZip->getFromName($this->getFooterName($i)); + $i++; } $this->_documentXML = $this->_objZip->getFromName('word/document.xml');