From 3185150009189bbe35ac50ede2e48bcebfd893b0 Mon Sep 17 00:00:00 2001 From: Marko Zabreznik Date: Mon, 14 Nov 2016 16:00:17 +0100 Subject: [PATCH] Update Backend.php --- src/Pdf/Docx/Backend.php | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/Pdf/Docx/Backend.php b/src/Pdf/Docx/Backend.php index 212c040..afdfede 100644 --- a/src/Pdf/Docx/Backend.php +++ b/src/Pdf/Docx/Backend.php @@ -165,6 +165,48 @@ public function setValue($search, $replace, $limit = -1) ); } } + + /** + * Method: getAllTags + * ========================================================================= + * Find all placeholders and return array. + * + * Paramters: + * ------------------------------------------------------------------------- + * none + * + * Returns: + * ------------------------------------------------------------------------- + * ```Array``` + */ + public function getAllTags() + { + + $tags = array(); + + $regex = '/\$\{([^}]+)\}/u'; + + foreach ($this->headerXMLs as $index => $headerXML) + { + if (preg_match_all($regex, $headerXML->asXml(), $matches)) { + $tags = array_merge($tags, $matches[1]); + } + } + + if (preg_match_all($regex, $this->documentXML->asXml(), $matches)) { + $tags = array_merge($tags, $matches[1]); + } + + + foreach ($this->footerXMLs as $index => $footerXML) + { + if (preg_match_all($regex, $footerXML->asXml(), $matches)) { + $tags = array_merge($tags, $matches[1]); + } + } + + return $tags; + } /** * Method: cloneBlock