Minor improvement
authorAlexander Ebert <ebert@woltlab.com>
Sat, 20 Aug 2016 10:44:34 +0000 (12:44 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 20 Aug 2016 10:44:39 +0000 (12:44 +0200)
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php

index 4379be102d041e1e836bd6701c7d291532509b53..4a55f39bc9bc64971249f4176219864595a236d4 100644 (file)
@@ -182,13 +182,15 @@ class HtmlOutputNodeProcessor extends AbstractHtmlNodeProcessor {
                }
                foreach ($nodes as $node) {
                        $split = preg_split('+'.$keywordPattern.'+', $node->textContent, -1, PREG_SPLIT_DELIM_CAPTURE);
-                       if (count($split) == 1) return;
+                       $count = count($split);
+                       if ($count == 1) return;
                        
-                       for ($i = 0; $i < count($split); $i++) {
+                       for ($i = 0; $i < $count; $i++) {
                                if ($i % 2 == 0) { // text
                                        $node->parentNode->insertBefore($node->ownerDocument->createTextNode($split[$i]), $node);
                                }
                                else { // match
+                                       /** @var \DOMElement $element */
                                        $element = $node->ownerDocument->createElement('span');
                                        $element->setAttribute('class', 'highlight');
                                        $element->appendChild($node->ownerDocument->createTextNode($split[$i]));