From 33cdfd98eddc8bcbad4ea96256ee3bd0efc13af7 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:19:50 -0500 Subject: [PATCH 01/19] Utilizing SharedString instead of String --- src/PhpWord/Element/Bookmark.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Element/Bookmark.php b/src/PhpWord/Element/Bookmark.php index 764dd605cf..98020f426a 100644 --- a/src/PhpWord/Element/Bookmark.php +++ b/src/PhpWord/Element/Bookmark.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Style; /** @@ -47,7 +47,7 @@ class Bookmark extends AbstractElement public function __construct($name) { - $this->name = String::toUTF8($name); + $this->name = SharedString::toUTF8($name); return $this; } From 7791ca2aa5565d63d9cd628d53c032f86f219d0c Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:20:42 -0500 Subject: [PATCH 02/19] Utilizing SharedString instead of String --- src/PhpWord/Element/CheckBox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php index 9362c3b17a..3273724e3a 100644 --- a/src/PhpWord/Element/CheckBox.php +++ b/src/PhpWord/Element/CheckBox.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; /** * Check box element @@ -56,7 +56,7 @@ public function __construct($name = null, $text = null, $fontStyle = null, $para */ public function setName($name) { - $this->name = String::toUTF8($name); + $this->name = SharedString::toUTF8($name); return $this; } From b84be1339fffb4cf5bc94948d28313a92026cea6 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:21:23 -0500 Subject: [PATCH 03/19] Utilizing SharedString instead of String --- src/PhpWord/Element/Link.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index 480016f44c..d1268eaa56 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; @@ -78,8 +78,8 @@ class Link extends AbstractElement */ public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false) { - $this->source = String::toUTF8($source); - $this->text = is_null($text) ? $this->source : String::toUTF8($text); + $this->source = SharedString::toUTF8($source); + $this->text = is_null($text) ? $this->source : SharedString::toUTF8($text); $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle); $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); $this->internal = $internal; From 0f2c0282268fa08e149e2c3c6065a8d9d2c2f879 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:21:58 -0500 Subject: [PATCH 04/19] Utilizing SharedString instead of String --- src/PhpWord/Element/ListItem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php index 5914f431c6..63942a839b 100644 --- a/src/PhpWord/Element/ListItem.php +++ b/src/PhpWord/Element/ListItem.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Style\ListItem as ListItemStyle; /** @@ -57,7 +57,7 @@ class ListItem extends AbstractElement */ public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) { - $this->textObject = new Text(String::toUTF8($text), $fontStyle, $paragraphStyle); + $this->textObject = new Text(SharedString::toUTF8($text), $fontStyle, $paragraphStyle); $this->depth = $depth; // Version >= 0.10.0 will pass numbering style name. Older version will use old method From e1a8ea8c0f37562c5ecc1b2da96e448597b3dc1d Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:22:28 -0500 Subject: [PATCH 05/19] Utilizing SharedString instead of String --- src/PhpWord/Element/PreserveText.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index 247b3cebab..f38e31bd87 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; @@ -61,7 +61,7 @@ public function __construct($text = null, $fontStyle = null, $paragraphStyle = n $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle); $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); - $this->text = String::toUTF8($text); + $this->text = SharedString::toUTF8($text); $matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if (isset($matches[0])) { $this->text = $matches; From f59feade8f25b583c7f3a2ce9fb1e8ab0e2dbed2 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:23:04 -0500 Subject: [PATCH 06/19] Utilizing SharedString instead of String --- src/PhpWord/Element/Text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php index 17fb118034..036372c05c 100644 --- a/src/PhpWord/Element/Text.php +++ b/src/PhpWord/Element/Text.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; @@ -136,7 +136,7 @@ public function getParagraphStyle() */ public function setText($text) { - $this->text = String::toUTF8($text); + $this->text = SharedString::toUTF8($text); return $this; } From 1971611e663853dad42b1675105a68e622387111 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:23:39 -0500 Subject: [PATCH 07/19] Utilizing SharedString instead of String --- src/PhpWord/Element/Title.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index 90009a9b05..a879fc627e 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Style; /** @@ -61,7 +61,7 @@ class Title extends AbstractElement */ public function __construct($text, $depth = 1) { - $this->text = String::toUTF8($text); + $this->text = SharedString::toUTF8($text); $this->depth = $depth; if (array_key_exists("Heading_{$this->depth}", Style::getStyles())) { $this->style = "Heading{$this->depth}"; From e0ebb8fe1cd16e7494944efc48bed53234fde37e Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:24:42 -0500 Subject: [PATCH 08/19] Rename file to SharedString.php and class to SharedString --- src/PhpWord/Shared/{String.php => SharedString.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/PhpWord/Shared/{String.php => SharedString.php} (99%) diff --git a/src/PhpWord/Shared/String.php b/src/PhpWord/Shared/SharedString.php similarity index 99% rename from src/PhpWord/Shared/String.php rename to src/PhpWord/Shared/SharedString.php index 526d75247e..814fbe9c50 100644 --- a/src/PhpWord/Shared/String.php +++ b/src/PhpWord/Shared/SharedString.php @@ -20,7 +20,7 @@ /** * Common string functions */ -class String +class SharedString { /** * Control characters array From f50c9c262fa6daa98d4c79057abeca00d431b6ba Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:25:10 -0500 Subject: [PATCH 09/19] Utilizing SharedString instead of String --- src/PhpWord/Style/AbstractStyle.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index 418e4a3587..d271fa8a3f 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Style; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; /** * Abstract style class @@ -161,7 +161,7 @@ public function setStyleValue($key, $value) if (isset($this->aliases[$key])) { $key = $this->aliases[$key]; } - $method = 'set' . String::removeUnderscorePrefix($key); + $method = 'set' . SharedString::removeUnderscorePrefix($key); if (method_exists($this, $method)) { $this->$method($value); } From 809e1face22c83e73788078bb98fcf47134742cd Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:25:40 -0500 Subject: [PATCH 10/19] Utilizing SharedString instead of String --- src/PhpWord/Style/Paragraph.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index 0de3713910..74ba8ce6d1 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Exception\InvalidStyleException; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\SimpleType\Jc; /** @@ -167,7 +167,7 @@ class Paragraph extends Border */ public function setStyleValue($key, $value) { - $key = String::removeUnderscorePrefix($key); + $key = SharedString::removeUnderscorePrefix($key); if ('indent' == $key || 'hanging' == $key) { $value = $value * 720; } elseif ('spacing' == $key) { From 658e1708c9bcdacf8a5a46e425c8f38cde6f4601 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:27:06 -0500 Subject: [PATCH 11/19] Utilizing SharedString instead of String --- src/PhpWord/TemplateProcessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index aefda39556..a22d2435e0 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -20,7 +20,7 @@ use PhpOffice\PhpWord\Exception\CopyFileException; use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Shared\ZipArchive; class TemplateProcessor @@ -148,7 +148,7 @@ public function setValue($macro, $replace, $limit = self::MAXIMUM_REPLACEMENTS_D $macro = '${' . $macro . '}'; } - if (!String::isUTF8($replace)) { + if (!SharedString::isUTF8($replace)) { $replace = utf8_encode($replace); } From 695a8855e58800fdb72ca67833126beb4ae3cbc9 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:27:54 -0500 Subject: [PATCH 12/19] Utilizing SharedString instead of String --- src/PhpWord/Writer/RTF/Element/AbstractElement.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index 9b4eb80e17..65518a0635 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -17,7 +17,7 @@ namespace PhpOffice\PhpWord\Writer\RTF\Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style\Paragraph as ParagraphStyle; @@ -112,7 +112,7 @@ protected function writeOpening() */ protected function writeText($text) { - return String::toUnicode($text); + return SharedString::toUnicode($text); } /** From 70ba335778fbab3cdf5ae6e0365f40ada0857308 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:28:28 -0500 Subject: [PATCH 13/19] Utilizing SharedString instead of String --- src/PhpWord/Writer/Word2007/Element/AbstractElement.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index 5654ab7ba9..7c7431e0c8 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -18,7 +18,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; use PhpOffice\PhpWord\Element\AbstractElement as Element; -use PhpOffice\PhpWord\Shared\String; +use PhpOffice\PhpWord\Shared\SharedString; use PhpOffice\PhpWord\Shared\XMLWriter; /** @@ -167,6 +167,6 @@ private function writeTextStyle($styleType) */ protected function getText($text) { - return String::controlCharacterPHP2OOXML($text); + return SharedString::controlCharacterPHP2OOXML($text); } } From 83f53ecad2d8a0dfb40575e337af6713fabbc8b9 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:30:04 -0500 Subject: [PATCH 14/19] Utilizing SharedString instead of String --- .../{StringTest.php => SharedStringTest.php} | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) rename tests/PhpWord/Shared/{StringTest.php => SharedStringTest.php} (61%) diff --git a/tests/PhpWord/Shared/StringTest.php b/tests/PhpWord/Shared/SharedStringTest.php similarity index 61% rename from tests/PhpWord/Shared/StringTest.php rename to tests/PhpWord/Shared/SharedStringTest.php index a12d52f9b9..e49dd2a26d 100644 --- a/tests/PhpWord/Shared/StringTest.php +++ b/tests/PhpWord/Shared/SharedStringTest.php @@ -23,16 +23,16 @@ * @coversDefaultClass \PhpOffice\PhpWord\Shared\String * @runTestsInSeparateProcesses */ -class StringTest extends \PHPUnit_Framework_TestCase +class SharedStringTest extends \PHPUnit_Framework_TestCase { /** * Is UTF8 */ public function testIsUTF8() { - $this->assertTrue(String::isUTF8('')); - $this->assertTrue(String::isUTF8('éééé')); - $this->assertFalse(String::isUTF8(utf8_decode('éééé'))); + $this->assertTrue(SharedString::isUTF8('')); + $this->assertTrue(SharedString::isUTF8('éééé')); + $this->assertFalse(SharedString::isUTF8(utf8_decode('éééé'))); } /** @@ -40,8 +40,8 @@ public function testIsUTF8() */ public function testControlCharacterOOXML2PHP() { - $this->assertEquals('', String::controlCharacterOOXML2PHP('')); - $this->assertEquals(chr(0x08), String::controlCharacterOOXML2PHP('_x0008_')); + $this->assertEquals('', SharedString::controlCharacterOOXML2PHP('')); + $this->assertEquals(chr(0x08), SharedString::controlCharacterOOXML2PHP('_x0008_')); } /** @@ -49,8 +49,8 @@ public function testControlCharacterOOXML2PHP() */ public function testControlCharacterPHP2OOXML() { - $this->assertEquals('', String::controlCharacterPHP2OOXML('')); - $this->assertEquals('_x0008_', String::controlCharacterPHP2OOXML(chr(0x08))); + $this->assertEquals('', SharedString::controlCharacterPHP2OOXML('')); + $this->assertEquals('_x0008_', SharedString::controlCharacterPHP2OOXML(chr(0x08))); } /** @@ -58,9 +58,9 @@ public function testControlCharacterPHP2OOXML() */ public function testToUnicode() { - $this->assertEquals('a', String::toUnicode('a')); - $this->assertEquals('\uc0{\u8364}', String::toUnicode('€')); - $this->assertEquals('\uc0{\u233}', String::toUnicode('é')); + $this->assertEquals('a', SharedString::toUnicode('a')); + $this->assertEquals('\uc0{\u8364}', SharedString::toUnicode('€')); + $this->assertEquals('\uc0{\u233}', SharedString::toUnicode('é')); } /** @@ -68,6 +68,6 @@ public function testToUnicode() */ public function testRemoveUnderscorePrefix() { - $this->assertEquals('item', String::removeUnderscorePrefix('_item')); + $this->assertEquals('item', SharedString::removeUnderscorePrefix('_item')); } } From bf8f315952199c7a435f325e4d7a1789c7f1c0fe Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:39:45 -0500 Subject: [PATCH 15/19] Added support for PHP 7 testing with Travis CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c39a05c460..70a73becb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 - hhvm matrix: From 7410598c2b8f00a78d5d647ed481f88f82fdeab8 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 10:55:05 -0500 Subject: [PATCH 16/19] Updated the constructor to make it php 5 and 7 friendly. --- src/PhpWord/Shared/PCLZip/pclzip.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Shared/PCLZip/pclzip.lib.php b/src/PhpWord/Shared/PCLZip/pclzip.lib.php index 4e2a496f20..149bf587ad 100644 --- a/src/PhpWord/Shared/PCLZip/pclzip.lib.php +++ b/src/PhpWord/Shared/PCLZip/pclzip.lib.php @@ -212,7 +212,7 @@ class PclZip // Note that no real action is taken, if the archive does not exist it is not // created. Use create() for that. // -------------------------------------------------------------------------------- - function PclZip($p_zipname) + function __construct($p_zipname) { // ----- Tests the zlib From a1d544f8b1b2a2a3dddd2903b950e23d8fc0caf9 Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 11:06:30 -0500 Subject: [PATCH 17/19] Updated mpdf dependency. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9629e3067c..e4897ba916 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "phploc/phploc": "2.*", "dompdf/dompdf":"0.6.*", "tecnick.com/tcpdf": "6.*", - "mpdf/mpdf": "5.*", + "mpdf/mpdf": "6.*", "zendframework/zend-validator": "2.5.*" }, "suggest": { From d335e17fecf54c6d276769d81722a43828260a3b Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Fri, 8 Jan 2016 14:01:31 -0500 Subject: [PATCH 18/19] Using dev-development for mpdf for now for PHP7 compatibility. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e4897ba916..e355ba269e 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "phploc/phploc": "2.*", "dompdf/dompdf":"0.6.*", "tecnick.com/tcpdf": "6.*", - "mpdf/mpdf": "6.*", + "mpdf/mpdf": "dev-development", "zendframework/zend-validator": "2.5.*" }, "suggest": { From 8580a69decccac9eddadc1f9e1b09f56ae15b99b Mon Sep 17 00:00:00 2001 From: Raul Ruiz Date: Thu, 21 Jan 2016 20:39:23 -0500 Subject: [PATCH 19/19] Fix for invalid XML in Word Document. --- src/PhpWord/TemplateProcessor.php | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index a22d2435e0..84aac97ed4 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -134,6 +134,43 @@ public function applyXslStyleSheet($xslDOMDocument, $xslOptions = array(), $xslO $this->tempDocumentMainPart = $xmlTransformed; } + + /** + * Clean all template parts of hidden XML within variables/placeholders. + * + * @return void + */ + public function fixBrokenVariables() + { + $this->tempDocumentMainPart = $this->fixBrokenVariablesForPart($this->tempDocumentMainPart); + + foreach ($this->tempDocumentHeaders as &$headerXML) { + $headerXML = $this->fixBrokenVariablesForPart($headerXML); + } + + foreach ($this->tempDocumentFooters as &$footerXML) { + $headerXML = $this->fixBrokenVariablesForPart($footerXML); + } + } + + /** + * Fix dirty hidden XML within variables in document part. + * + * @param string $documentPartXML said document part + * + * @return string + */ + protected function fixBrokenVariablesForPart(string $documentPartXML) + { + return + preg_replace_callback( + '|\$([^{]*)(\{.*})|U', + function ($match) { + return '$'.strip_tags($match[2]); + }, + $documentPartXML + ); + } /** * @param mixed $macro