From: Michael M Slusarz Date: Fri, 7 Jan 2011 20:05:27 +0000 (-0700) Subject: Add Horde_Domhtml::getHead() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4093127d427c15117fa49212ba3670efa4e34eb9;p=horde.git Add Horde_Domhtml::getHead() --- diff --git a/framework/Text_Filter/lib/Horde/Text/Filter/Xss.php b/framework/Text_Filter/lib/Horde/Text/Filter/Xss.php index d76535fa4..99c1afc7a 100644 --- a/framework/Text_Filter/lib/Horde/Text/Filter/Xss.php +++ b/framework/Text_Filter/lib/Horde/Text/Filter/Xss.php @@ -109,14 +109,8 @@ class Horde_Text_Filter_Xss extends Horde_Text_Filter_Base $meta->setAttribute('http-equiv', 'x-dns-prefetch-control'); $meta->setAttribute('value-equiv', 'off'); - $head = $dom->dom->getElementsByTagName('head'); - if ($head->length) { - $head->item(0)->appendChild($meta); - } else { - $headelt = $dom->dom->createElement('head'); - $headelt->appendChild($meta); - $dom->dom->appendChild($headelt); - } + $head = $dom->getHead(); + $head->appendChild($meta); } if ($this->_params['return_dom']) { diff --git a/framework/Util/lib/Horde/Domhtml.php b/framework/Util/lib/Horde/Domhtml.php index a4c222bd0..81273e0c0 100644 --- a/framework/Util/lib/Horde/Domhtml.php +++ b/framework/Util/lib/Horde/Domhtml.php @@ -87,6 +87,24 @@ class Horde_Domhtml } /** + * Returns the HEAD element, or creates one if it doesn't exist. + * + * @return DOMElement HEAD element. + */ + public function getHead() + { + $head = $this->dom->getElementsByTagName('head'); + if ($head->length) { + return $head->item(0); + } + + $headelt = $this->dom->createElement('head'); + $this->dom->appendChild($headelt); + + return $headelt; + } + + /** * Returns the full HTML text in the original charset. * * @return string HTML text. diff --git a/imp/view.php b/imp/view.php index 62354b95a..a66c2c46c 100644 --- a/imp/view.php +++ b/imp/view.php @@ -307,7 +307,7 @@ case 'print_attach': $headers = $contents->getHeaderOb(); $imp_ui_mbox = new IMP_Ui_Mailbox(); - $headelt = $doc->dom->getElementsByTagName('head')->item(0); + $headelt = $doc->getHead(); foreach ($headelt->getElementsByTagName('title') as $node) { $headelt->removeChild($node); }