/** * Form the data array that contains a 'isHTMLEntity' status (if the HTML entity * is on the 'pos' position in the string passed) and It could contain the * length of the html entity('htmlEntityLength') and the number of characters * It represents('entityLength') * @param Number pos * @param String string * @return Array */ protected function isHTMLEntity($pos, $string) { $endityEndPos = strpos($string, ";", $pos); if ($endityEndPos === FALSE) { return array('isHTMLEntity' => false); } $suspect = substr($string, $pos, $endityEndPos - $pos + 1); $data = getHTMLEntityData($suspect); $data['htmlEntityLength'] = strlen($suspect); return $data; }
/** * Highlight item string basing on the pattern value * skipping the HTML entities * @param String item * @param String pattern * @return String */ protected function highlightValueWithHTMLEntities($item, $pattern) { $valueArr = $this->getSplitStringWithCapturedDelimiters("/&[^&;]{3,7};/", $item); $valueArr2 = array(); foreach ($valueArr as $subitem) { $data = getHTMLEntityData($subitem); if ($data['isHTMLEntity']) { $valueArr2[] = $subitem; } else { $valueArr2[] = preg_replace($pattern, $this->addHighlightingSpan('$1'), $subitem); } } return implode("", $valueArr2); }