Example #1
0
 public function mergeHeaders($into, Url $context)
 {
     $parser = new Parser($into);
     $html = $parser->findElement('html');
     if (!$html) {
         return $into;
     }
     $head = $html->findChildElement('head');
     if ($head) {
         if ($this->isMapping()) {
             $baseElement = new Element('base', new Liste(array(new Attribute('href', $context->toString(), Attribute::QUOTE_DOUBLE))));
             $head->getChildren()->insert($baseElement, 0);
         }
         foreach ($this->heads as $new) {
             if (!$this->isAlreadyIn($new, $head->getChildElements())) {
                 $head->getChildren()->append($new);
             }
         }
     }
     $body = $html->findChildElement('body');
     if ($body) {
         $handler = $this->onLoadHandler;
         if ($body->getAttribute('onload')) {
             $handler = $body->getAttribute('onload')->getValue() . $handler;
         }
         if ($handler) {
             $body->setAttribute('onload', $handler);
         }
     }
     $printer = new Printer();
     return $printer->printNodes($parser->getNodes());
 }