/** * @param string $response * @return string */ public function wrap($response) { $parser = new Parser($response); $root = $parser->getRoot(); $body = $this->findBody($root); $this->wrapChildren($body); $head = $this->findElement($root, 'html/head'); if ($head) { foreach ($head->getChildElements() as $headElement) { if (!in_array($headElement->getName(), self::$ignoredHeadElements)) { $this->headElements->put($headElement); } } } $id = uniqid('box-'); $open = ''; $close = ''; if ($body->getAttribute('onload') && $body->getAttribute('onload')->getValue()) { $handler = $body->getAttribute('onload')->getValue(); $handler = rtrim($handler, ';') . ';'; $handler = str_replace('top.document.body', 'document.body', $handler); $this->onLoadHandler = str_replace('document.body', "top.document.getElementById('{$id}')", $handler); $open = '<div id="' . $id . '">'; $close = '</div>'; } $printer = new Printer(); return $open . $printer->printNodes($body->getChildren()) . $close; }
/** * @param array|object $model * @return string */ public function render($model = array()) { $animator = new Animator($model); $animator->enableLogging($this->logginEnabled); foreach ($this->parser->getNodes() as $node) { if ($node instanceof Element) { $animator->animate($node); } } if ($this->logginEnabled) { $this->log = $animator->getLog(); } $printer = new Printer(); return $printer->printNodes($this->parser->getNodes()); }
public function itShouldBe($string) { $printer = new Printer(); $this->test->assertEquals($string, $printer->printNodes($this->test->when->nodes)); }
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()); }
private function thenTheFootShouldBe($string) { $printer = new Printer(); $footerContent = $printer->printNodes($this->dom->findChildElement('html')->findChildElement('body')->findChildElement('footer')->getChildren()); $this->assertEquals($string, $footerContent); }
public function iPrintTheMarkup($string) { $parser = new Parser($string); $printer = new Printer(); $this->result = $printer->printNodes($parser->getNodes()); }