From f7cb73e8a6260822731b14fbf837f3f2986476e5 Mon Sep 17 00:00:00 2001 From: Dmitry Lukashin Date: Thu, 19 Oct 2017 17:33:46 +0300 Subject: [PATCH 1/5] Get rid of duplicated code in TemplateProcessor.php --- src/PhpWord/TemplateProcessor.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 2f6d6258..27ffa458 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -268,9 +268,7 @@ class TemplateProcessor */ public function cloneRow($search, $numberOfClones) { - if ('${' !== substr($search, 0, 2) && '}' !== substr($search, -1)) { - $search = '${' . $search . '}'; - } + $search = static::ensureMacroCompleted($search); $tagPos = strpos($this->tempDocumentMainPart, $search); if (!$tagPos) { From ba9e8958d71074f7d43ee83e20b1508e4a9886f7 Mon Sep 17 00:00:00 2001 From: Dmitry Lukashin Date: Thu, 19 Oct 2017 18:51:57 +0300 Subject: [PATCH 2/5] Replace self:: with static:: calls --- src/PhpWord/TemplateProcessor.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 27ffa458..13dcc71c 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -212,18 +212,18 @@ class TemplateProcessor { if (is_array($search)) { foreach ($search as &$item) { - $item = self::ensureMacroCompleted($item); + $item = static::ensureMacroCompleted($item); } } else { - $search = self::ensureMacroCompleted($search); + $search = static::ensureMacroCompleted($search); } if (is_array($replace)) { foreach ($replace as &$item) { - $item = self::ensureUtf8Encoded($item); + $item = static::ensureUtf8Encoded($item); } } else { - $replace = self::ensureUtf8Encoded($replace); + $replace = static::ensureUtf8Encoded($replace); } if (Settings::isOutputEscapingEnabled()) { From 45ee8b7faf0bb41b6cf8d1f5bf21cfd5e07353aa Mon Sep 17 00:00:00 2001 From: kisabelle Date: Fri, 21 Sep 2018 11:53:16 -0700 Subject: [PATCH 3/5] Add documentation for enabling evenAndOddHeaders --- docs/containers.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/containers.rst b/docs/containers.rst index dc194d59..34b2a9a3 100644 --- a/docs/containers.rst +++ b/docs/containers.rst @@ -104,6 +104,12 @@ You can pass an optional parameter to specify where the header/footer should be - ``Footer::FIRST`` each first page of the section - ``Footer::EVEN`` each even page of the section. Will only be applied if the evenAndOddHeaders is set to true in phpWord->settings +To change the evenAndOddHeaders use the ``getSettings`` method to return the Settings object, and then call the ``setEvenAndOddHeaders`` method: + +.. code-block:: php + $phpWord->getSettings()->setEvenAndOddHeaders(true); + + Footers ------- From 2a088fb45b646544c7e88433eddbd2b51c470cfd Mon Sep 17 00:00:00 2001 From: troosan Date: Wed, 26 Dec 2018 20:07:32 +0100 Subject: [PATCH 4/5] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae41bd4d..8c2c73ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ v0.16.0 (xx dec 2018) - RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals @Patrick64 #1493 - Fix parsing of Office 365 documents @Timanx #1485 +### Miscelaneous +- Get rid of duplicated code in TemplateProcessor @abcdmitry #1161 + v0.15.0 (14 Jul 2018) ---------------------- ### Added From 575c5531b8a6d67a0eb270d2dc1ecfb08d637df3 Mon Sep 17 00:00:00 2001 From: troosan Date: Wed, 26 Dec 2018 20:07:53 +0100 Subject: [PATCH 5/5] replace self with static --- src/PhpWord/TemplateProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 71090357..599ca0cf 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -521,7 +521,7 @@ class TemplateProcessor $xmlImage = str_replace(array('{RID}', '{WIDTH}', '{HEIGHT}'), array($rid, $preparedImageAttrs['width'], $preparedImageAttrs['height']), $imgTpl); // replace variable - $varNameWithArgsFixed = self::ensureMacroCompleted($varNameWithArgs); + $varNameWithArgsFixed = static::ensureMacroCompleted($varNameWithArgs); $matches = array(); if (preg_match('/(<[^<]+>)([^<]*)(' . preg_quote($varNameWithArgsFixed) . ')([^>]*)(<[^>]+>)/Uu', $partContent, $matches)) { $wholeTag = $matches[0];