/** * Parses the HTML tags that would have been inserted to the <head> of a HTML document and returns the found tags as multidimensional array. * * @return array The parsed tags with their attributes and innerHTML parts */ protected function getHeadTags() { $headTags = array(); $headDataRaw = $this->fObj->JStop(); if ($headDataRaw) { // Create instance of the HTML parser: $parseObj = t3lib_div::makeInstance('t3lib_parsehtml'); // Removes script wraps: $headDataRaw = str_replace(array('/*<![CDATA[*/', '/*]]>*/'), '', $headDataRaw); // Removes leading spaces of a multiline string: $headDataRaw = trim(preg_replace('/(^|\\r|\\n)( |\\t)+/', '$1', $headDataRaw)); // Get script and link tags: $tags = array_merge($parseObj->getAllParts($parseObj->splitTags('link', $headDataRaw)), $parseObj->getAllParts($parseObj->splitIntoBlock('script', $headDataRaw))); foreach ($tags as $tagData) { $tagAttributes = $parseObj->get_tag_attributes($parseObj->getFirstTag($tagData), true); $headTags[] = array('name' => $parseObj->getFirstTagName($tagData), 'attributes' => $tagAttributes[0], 'innerHTML' => $parseObj->removeFirstAndLastTag($tagData)); } } return $headTags; }