Exemple #1
0
 /**
  * @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;
 }
 private function whenIExecute($action)
 {
     $this->resource->whenIDo_With(function (ExecuteResource $resource) use($action) {
         $model = $resource->doGet($action);
         $this->resource->request->getFormats()->append('html');
         $rendered = $resource->after($model, $this->resource->request)->getBody();
         $parser = new Parser($rendered);
         $this->dom = $parser->getRoot();
         return $model;
     }, ExecuteResource::class);
 }
Exemple #3
0
 /**
  * @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());
 }
Exemple #4
0
 public function theMarkUp($string)
 {
     $parser = new Parser($string);
     $this->test->when->nodes = $parser->getNodes();
 }
Exemple #5
0
 public function iParse($string)
 {
     $parser = new Parser($string);
     $this->nodes = $parser->getNodes();
 }
Exemple #6
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());
 }
Exemple #7
0
 public function iPrintTheMarkup($string)
 {
     $parser = new Parser($string);
     $printer = new Printer();
     $this->result = $printer->printNodes($parser->getNodes());
 }