コード例 #1
0
 /**
  * @param HtmlBlock                $block
  * @param ElementRendererInterface $htmlRenderer
  * @param bool                     $inTightList
  *
  * @return string
  */
 public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
 {
     if (!$block instanceof HtmlBlock) {
         throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
     }
     if ($this->config->getConfig('safe') === true) {
         return '';
     }
     return $block->getStringContent();
 }
コード例 #2
0
ファイル: RawHtmlRenderer.php プロジェクト: heavenwoo/beelog
 /**
  * @param Html                     $inline
  * @param ElementRendererInterface $htmlRenderer
  *
  * @return string
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof Html) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     if ($this->config->getConfig('safe') === true) {
         return '';
     }
     return $inline->getContent();
 }
コード例 #3
0
 /**
  * @param Link                     $inline
  * @param ElementRendererInterface $htmlRenderer
  *
  * @return HtmlElement
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof Link) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     $attrs = [];
     foreach ($inline->getData('attributes', []) as $key => $value) {
         $attrs[$key] = $htmlRenderer->escape($value, true);
     }
     if (!($this->config->getConfig('safe') && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl()))) {
         $attrs['href'] = $htmlRenderer->escape($inline->getUrl(), true);
     }
     if (isset($inline->data['title'])) {
         $attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
     }
     return new HtmlElement('a', $attrs, $htmlRenderer->renderInlines($inline->children()));
 }
コード例 #4
0
 /**
  * @param HtmlBlock                $block
  * @param ElementRendererInterface $htmlRenderer
  * @param bool                     $inTightList
  *
  * @return string
  */
 public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
 {
     if (!$block instanceof HtmlBlock) {
         throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
     }
     // Kept for BC reasons
     if ($this->config->getConfig('safe') === true) {
         return '';
     }
     if ($this->config->getConfig('html_input') === Environment::HTML_INPUT_STRIP) {
         return '';
     }
     if ($this->config->getConfig('html_input') === Environment::HTML_INPUT_ESCAPE) {
         return htmlspecialchars($block->getStringContent(), ENT_NOQUOTES);
     }
     return $block->getStringContent();
 }
コード例 #5
0
 /**
  * @param HtmlInline               $inline
  * @param ElementRendererInterface $htmlRenderer
  *
  * @return string
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof HtmlInline) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     // Kept for BC reasons
     if ($this->config->getConfig('safe') === true) {
         return '';
     }
     if ($this->config->getConfig('html_input') === Environment::HTML_INPUT_STRIP) {
         return '';
     }
     if ($this->config->getConfig('html_input') === Environment::HTML_INPUT_ESCAPE) {
         return htmlspecialchars($inline->getContent(), ENT_NOQUOTES);
     }
     return $inline->getContent();
 }
コード例 #6
0
ファイル: LinkRenderer.php プロジェクト: PovilasLT/maze
 private function buildLink($inline, $htmlRenderer)
 {
     $attrs = [];
     foreach ($inline->getData('attributes', []) as $key => $value) {
         $attrs[$key] = $htmlRenderer->escape($value, true);
     }
     if (!($this->config->getConfig('safe') && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl()))) {
         $attrs['href'] = $htmlRenderer->escape($inline->getUrl(), true);
     }
     if (isset($inline->data['title'])) {
         $attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
     }
     if ($this->isExternalUrl($inline->getUrl())) {
         $attrs['rel'] = 'nofollow';
         $attrs['target'] = '_blank';
     }
     return new HtmlElement('a', $attrs, $htmlRenderer->renderInlines($inline->children()));
 }
コード例 #7
0
 /**
  * @param Image                    $inline
  * @param ElementRendererInterface $htmlRenderer
  *
  * @return HtmlElement
  */
 public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof Image) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     $attrs = [];
     foreach ($inline->getData('attributes', []) as $key => $value) {
         $attrs[$key] = $htmlRenderer->escape($value, true);
     }
     if ($this->config->getConfig('safe') && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl())) {
         $attrs['src'] = '';
     } else {
         $attrs['src'] = $htmlRenderer->escape($inline->getUrl(), true);
     }
     $alt = $htmlRenderer->renderInlines($inline->children());
     $alt = preg_replace('/\\<[^>]*alt="([^"]*)"[^>]*\\>/', '$1', $alt);
     $attrs['alt'] = preg_replace('/\\<[^>]*\\>/', '', $alt);
     if (isset($inline->data['title'])) {
         $attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
     }
     return new HtmlElement('img', $attrs, '', true);
 }
コード例 #8
0
 /**
  * @param string|null $key
  * @param mixed       $default
  *
  * @return mixed
  */
 public function getConfig($key = null, $default = null)
 {
     return $this->config->getConfig($key, $default);
 }