/**
  * {@inheritdoc}
  */
 public function render()
 {
     $output = preg_match('/^<!DOCTYPE\\s.*>$/', trim($this->doctype->render())) ? trim($this->doctype->render()) . PHP_EOL : '<!DOCTYPE html>' . PHP_EOL;
     preg_match('/<html.*?>/', $this->html->render(), $result);
     $output .= isset($result[0]) ? $result[0] . PHP_EOL : '<html>' . PHP_EOL;
     $output .= substr($this->head->render(), 0, -7);
     $favicon = $this->favicon->render();
     if (!empty($favicon)) {
         $output .= $favicon . PHP_EOL;
     }
     if ($this->styleSheet->length()) {
         $output .= $this->styleSheet->render('html') . PHP_EOL;
     }
     if ($this->javaScript->length()) {
         $tmp = call_user_func($this->scriptOutput, $this->javaScript, $this->translations);
         if (!empty($tmp)) {
             $output .= $tmp . PHP_EOL;
         }
     }
     if (!$this->script->isEmpty()) {
         $output .= '<script type="text/javascript">' . $this->script->render() . '</script>' . PHP_EOL;
     }
     $output .= $this->customHeadCode;
     $output .= '</head>' . PHP_EOL;
     $bodyEndPos = strrpos($this->body, "</body>");
     if ($bodyEndPos !== false) {
         $output .= substr($this->body, 0, $bodyEndPos);
         $output .= $this->customBottomCode . '</body>';
     } else {
         $output .= $this->body;
     }
     $output .= '</html>';
     return $output;
 }
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $output = $this->prologRender();
     preg_match('/<' . $this->root->name() . '.*?>/', $this->root->render(false, true), $result);
     $output .= isset($result[0]) ? str_replace(array("/>", " />"), ">", $result[0]) . PHP_EOL : '<' . $this->root->name() . '>' . PHP_EOL;
     $output .= $this->body;
     $output .= '</' . $this->root->name() . '>';
     return $output;
 }
 /**
  * Kod źródłowy w formacie HTML
  * 
  * @param StyleSheetResource $res
  * @param string $output
  */
 protected function render_html(StyleSheetResource $res, &$output)
 {
     foreach ($res->getUrl() as $url) {
         $tag = new HtmlElement('link');
         $tag->attr('href', $url);
         $tag->attr('rel', 'stylesheet');
         $tag->attr('type', 'text/css');
         $output .= $tag->render();
         $tag->destroy($tag);
     }
 }
 /**
  * Kod znacznika <picture>
  * 
  * @param ImageResource $res
  * @param string $output
  */
 protected function render_html_picture(ImageResource $res, &$output)
 {
     $data = $res->imageData();
     $tmp = '';
     $source = function (array &$arr) use(&$data, &$tmp) {
         $tag = new HtmlElement('source');
         $srcset = '';
         foreach ($arr as &$img) {
             $srcset .= $img['url'];
             $srcset .= !empty($img['data']['srcset_x']) ? ' ' . $img['data']['srcset_x'] . 'x' : '';
             $srcset .= ', ';
         }
         $tag->attr('srcset', substr($srcset, 0, -2));
         $index = $arr[0]['data']['media_index'];
         if (isset($data['media'][$index])) {
             $tag->attr('media', $data['media'][$index]);
         }
         $tmp .= $tag->render() . PHP_EOL;
         $tag->destroy($tag);
     };
     foreach ($data as $k => $v) {
         if (is_integer($k) && $k > -1 && is_array($v)) {
             $source($data[$k]);
         }
     }
     if (isset($data[-1])) {
         $source($data[-1]);
     }
     $urls = $res->getUrl();
     $img = new HtmlElement('img');
     $img->attr('src', $urls[$data['src-index']]);
     $img->attr('alt', htmlspecialchars($res->getName()));
     $tag = new HtmlElement('picture');
     //$tag->attr('alt', htmlspecialchars($res->getName()));
     foreach ($data['attr'] as $k => $v) {
         $tag->attr(htmlspecialchars($k), htmlspecialchars($v));
     }
     preg_match('/<picture.*?>/', $tag->render(), $result);
     $output[] = (isset($result[0]) ? $result[0] . PHP_EOL : '<picture>' . PHP_EOL) . "<!--[if IE 9]><video style=\"display: none;\"><![endif]-->" . PHP_EOL . str_replace("</source>", '', $tmp) . "<!--[if IE 9]></video><![endif]-->" . PHP_EOL . $img->render() . PHP_EOL . '</picture>';
     $tag->destroy($tag);
     $img->destroy($img);
 }
 /**
  * Kod źródłowy w formacie HTML
  * 
  * @param JavaScriptResource $res
  * @param string $output
  */
 protected function render_html(JavaScriptResource $res, &$output)
 {
     foreach ($res->getUrl() as $url) {
         $tag = new HtmlElement('script');
         $tag->attr('src', $url);
         $tag->attr('type', 'text/javascript');
         $output .= $tag->render();
         $tag->destroy($tag);
     }
 }
 /**
  * Zawartość znacznika channel.
  *
  * @return string
  */
 private function channelContent()
 {
     $output = '';
     $output .= $this->title->render(false, true);
     $output .= $this->link->render(false, true);
     $output .= $this->description->render(false, true);
     if (!$this->language->isEmpty()) {
         $output .= $this->language->render(false, true);
     }
     if (!$this->copyright->isEmpty()) {
         $output .= $this->copyright->render(false, true);
     }
     if (!$this->managingEditor->isEmpty()) {
         $output .= $this->managingEditor->render(false, true);
     }
     if (!$this->webMaster->isEmpty()) {
         $output .= $this->webMaster->render(false, true);
     }
     if (!$this->pubDate->isEmpty()) {
         $output .= $this->pubDate->render(false, true);
     }
     if (!$this->lastBuildDate->isEmpty()) {
         $output .= $this->lastBuildDate->render(false, true);
     }
     if (!$this->category->isEmpty()) {
         $output .= $this->category->render(false, true);
     }
     if (!$this->generator->isEmpty()) {
         $output .= $this->generator->render(false, true);
     }
     if (!$this->ttl->isEmpty()) {
         $output .= $this->ttl->render(false, true);
     }
     if (!$this->imageUrl->isEmpty() && !$this->imageTitle->isEmpty() && !$this->imageLink->isEmpty()) {
         $output .= $this->image->render(false, true);
     }
     if (!$this->textInputLink->isEmpty() && !$this->textInputTitle->isEmpty() && !$this->textInputDescription->isEmpty() && !$this->textInputName->isEmpty()) {
         $output .= $this->textInput->render(false, true);
     }
     if ($this->skipHours->xpath('hour')->length) {
         $output .= $this->skipHours->render(false, true);
     }
     if ($this->skipDays->xpath('day')->length) {
         $output .= $this->skipDays->render(false, true);
     }
     $cloud = $this->cloud();
     if (!empty($cloud['domain']) && !empty($cloud['path']) && !empty($cloud['protocol']) && !empty($cloud['port']) && !empty($cloud['registerProcedure'])) {
         $output .= $this->cloud->render(false, true);
     }
     $output .= $this->body();
     return $output;
 }