public function asHtml(ElementNode $el) { $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsHTML(); } $param = $el->getAttribute(); if (is_array($param)) { $param = array_shift($param); } $param = trim($param); if ($content == '' and $param == '') { return ''; } // Erlaubte Farbnamen $allowed_colors = (array) $this->config->get('callbacks.color_param.allowed_colors'); $color = mb_convert_case($param, MB_CASE_TITLE); // Wenn im Parameter keine erlaubte Farbe steht if (!in_array($color, $allowed_colors)) { // Prüfen, ob eine hexadezimale Farbe angegeben wurde if (strlen($param) == 7 && $param[0] == '#' and preg_match('~#[a-f0-9]{6}~i', $param)) { $color = $param; } else { $color = $this->config->get('callbacks.color_param.default_color'); } } // Ansonsten ist der Farbnamen gülig return Html::span($content, ['style' => 'color:' . $color . ';']); }
public function visitElementNode(ElementNode $element_node) { if ($element_node->getCodeDefinition()->parseContent()) { foreach ($element_node->getChildren() as $child) { $child->accept($this); } } }
public function visitElementNode(ElementNode $element_node) { // Nur nach Urls suchen, wenn nicht in URL-Tag und der Content geparst werden soll if ($element_node->getCodeDefinition()->getTagName() !== 'url' and $element_node->getCodeDefinition()->parseContent()) { foreach ($element_node->getChildren() as $child) { $child->accept($this); } } }
function visitElementNode(\JBBCode\ElementNode $elementNode) { if ($elementNode->getCodeDefinition()->parseContent()) { /* We only want to visit text nodes within elements if the element's code definition allows for its content to be parsed. */ foreach ($elementNode->getChildren() as $child) { $child->accept($this); } } }
public function asHtml(\JBBCode\ElementNode $el) { $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsBBCode(); } if ($el->getAttribute()['file'] == 'image') { return '<img src="' . base_url($content) . '"/>'; } }
public function asHtml(ElementNode $el) { $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsHTML(); } $flags = ENT_COMPAT | ENT_HTML401; $encoding = ini_get("default_charset"); $double_encode = false; // Do not double encode return '<!-- no_p --><pre><code>' . htmlspecialchars($content, $flags, $encoding, $double_encode) . '</code></pre><!-- no_p -->'; }
public function asHtml(ElementNode $el) { $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsText(); } $param = $el->getAttribute(); if (is_array($param)) { $param = array_shift($param); } $param = trim($param); if ($content == '' and $param == '') { return ''; } $short_url = $this->config->get('callbacks.url_content.short_url'); // Url finden if ($param == '') { // Die Url steht im Content $url = $content; // In der anzuzeigenden URL kein & anzeigen $content = str_replace('&', '&', $content); } else { // Die Url steht im Parameter $url = $param; $short_url = false; $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsHTML(); } } // http:// voranstellen, wenn nichts angegeben if (!preg_match('~^[a-z]+://~i', $url)) { $url = "http://" . $url; } // Wenn die URL nicht gültig ist, zeigen wir nur den Text if (!$this->config->getValidation()->isValidUrl($url)) { return $content; } return Html::anchorFromConfig($url, $content, $this->config); }
public function asHtml(ElementNode $el) { $bodyHtml = ''; foreach ($el->getChildren() as $child) { $bodyHtml .= $child->getAsHTML(); } $listPieces = explode('[*]', $bodyHtml); unset($listPieces[0]); $listPieces = array_map(function ($li) { return Html::tag('li', $li); }, $listPieces); return Html::tag('ul', implode('', $listPieces)); }
public function asHtml(\JBBCode\ElementNode $el) { $bodyHtml = ''; foreach ($el->getChildren() as $child) { $bodyHtml .= $child->getAsHTML(); } $list = array(); preg_match_all('#\\[li\\](.*?)\\[\\/li\\]#is', $bodyHtml, $list); $list = array_map(function ($li) { return '<li>' . $li . '</li>'; }, $list[1]); return '<ul>' . implode('', $list) . '</ul>'; }
public function visitElementNode(\JBBCode\ElementNode $elementNode) { $attrs = $elementNode->getAttribute(); if (is_array($attrs)) { foreach ($attrs as &$el) { $el = $this->htmlSafe($el); } $elementNode->setAttribute($attrs); } foreach ($elementNode->getChildren() as $child) { $child->accept($this); } }
public function asHtml(ElementNode $el) { $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsText(); } $param = $el->getAttribute(); if (is_array($param)) { $param = array_shift($param); } $param = trim($param); if ($content == '' and $param == '') { return ''; } if ($param == '') { // Die Email steht im Content $email = ''; foreach ($el->getChildren() as $child) { $email .= $child->getAsText(); } } else { // Die Email steht im Parameter $email = $param; $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsHTML(); } } // Nur Content anzeigen, wenn keine gültige Email angegeben wurde if (!$this->config->getValidation()->isValidEmail($email)) { return $content; } // Mail vor Bots schützen? if ($this->config->get('callbacks.email_content.protect_email')) { return Html::mail_to_safe($email, $content); } return Html::mail_to($email, $content); }
public function visitElementNode(\JBBCode\ElementNode $elementNode) { $tagName = strtolower($elementNode->getTagName()); // Update this tag name's frequency if (isset($this->frequencies[$tagName])) { $this->frequencies[$tagName]++; } else { $this->frequencies[$tagName] = 1; } // Visit all the node's childrens foreach ($elementNode->getChildren() as $child) { $child->accept($this); } }
public function asHtml(\JBBCode\ElementNode $el) { $url = ''; foreach ($el->getChildren() as $child) { $url .= $child->getAsText(); } // Split the argument on the pipe character $argPieces = explode('|', $el->getAttribute()); $altText = $argPieces[0]; $class = 'default-class'; if (count($argPieces) > 1) { $class = $argPieces[1]; } return '<img src="' + $url + '" alt="' + $altText + '" class="' + $class + '" />'; }
public function asHtml(ElementNode $el) { $bodyHtml = ''; foreach ($el->getChildren() as $child) { $bodyHtml .= $child->getAsHTML(); } $trList = array(); preg_match_all('#\\[tr\\](.*?)\\[\\/tr\\]#is', $bodyHtml, $trList); $trList = array_map(function ($tr) { $tdList = array(); preg_match_all('#\\[td\\](.*?)\\[\\/td\\]#is', $tr, $tdList); $tdList = array_map(function ($td) { return Html::tag('td', $td); }, $tdList[1]); return Html::tag('tr', implode('', $tdList)); }, $trList[1]); return Html::tag('table', implode('', $trList), ['class' => 'bb-table']); }
public function asHtml(\JBBCode\ElementNode $el) { $bodyHtml = ''; foreach ($el->getChildren() as $child) { $bodyHtml .= $child->getAsHTML(); } $trList = array(); preg_match_all('#\\[tr\\](.*?)\\[\\/tr\\]#is', $bodyHtml, $trList); $trList = array_map(function ($tr) { $tdList = array(); preg_match_all('#\\[td\\](.*?)\\[\\/td\\]#is', $tr, $tdList); $tdList = array_map(function ($td) { return '<td>' . $td . '</td>'; }, $tdList[1]); return '<tr>' . implode('', $tdList) . '</tr>'; }, $trList[1]); return '<table class="table table-hover table-bordered table-striped"><tbody>' . implode('', $trList) . '</tbody></table>'; }
public function asHtml(ElementNode $el) { $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsHTML(); } $content = trim($content); if ($content == '') { return ''; } $param = $el->getAttribute(); if (is_array($param)) { $param = array_shift($param); } $list_type = false; $list_attr = array(); if (in_array($param, array('a', 'A', 'i', 'I'))) { $list_type = 'ol'; $list_attr['type'] = $param; } if (!$list_type) { //Wir prüfen, ob eine Zahl angegeben wurde if (preg_match('/^(-){0,1}[0-9]+$/', $param)) { $list_type = 'ol'; $list_attr['start'] = intval($param); } } //Default ist ul, $param ist dann egal if (!$list_type) { $list_type = 'ul'; $list_attr['type'] = 'disc'; } $delimiter = '[*]'; if (substr($content, 0, strlen($delimiter)) === $delimiter) { $content = substr_replace($content, '', 0, strlen($delimiter)); } //Text in Lines aufteilen; jede Line ist ein neuer Listenpunkt $lines = explode($delimiter, $content); $items = array(); foreach ($lines as $line) { $items[] = trim($line); } return '<!-- no_p -->' . Html::$list_type($items, $list_attr) . '<!-- no_p -->'; }
public function asHtml(ElementNode $el) { $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsHTML(); } $param = $el->getAttribute(); if (is_array($param)) { $param = array_shift($param); } $param = (string) trim($param); if (preg_match('/^\\<blockquote/', trim($content)) == 0) { $content = "<cite>" . $param . "</cite>" . $content; } else { $search = '</blockquote>'; $replace = "</blockquote><cite>" . $param . "</cite>"; $len = strlen($search); $pos = strrpos($content, $search); $content = substr_replace($content, $replace, $pos, $len); } return '<blockquote title="Zitat">' . $content . '</blockquote>'; }
public function asHtml(ElementNode $el) { $content = ''; foreach ($el->getChildren() as $child) { $content .= $child->getAsHTML(); } $param = $el->getAttribute(); if (is_array($param)) { $param = array_shift($param); } $param = trim($param); if ($content == '') { return ''; } $size = intval($param); if ($size == 0) { $size = 100; } // Mindestgröße: 75% $size = max($size, $this->config->get('callbacks.size_param.min_size')); // Maximale Größe: 150% $size = min($size, $this->config->get('callbacks.size_param.max_size')); return Html::span($content, ['style' => 'font-size:' . $size . '%;']); }
/** * Creates a new text node with the given parent and text string. * * @param $parent the parent of the text node * @param $string the text of the text node * * @return TextNode the newly created TextNode */ protected function createTextNode(ElementNode $parent, $string) { if (count($parent->getChildren())) { $children = $parent->getChildren(); $lastElement = end($children); reset($children); if ($lastElement->isTextNode()) { $lastElement->setValue($lastElement->getValue() . $string); return $lastElement; } } $textNode = new $this->textNodeClassName($string); $textNode->setNodeId(++$this->nextNodeid); $parent->addChild($textNode); return $textNode; }
/** * Creates a new text node with the given parent and text string. * * @param ElementNode $parent the parent of the text node * @param string $string the text of the text node * * @return TextNode the newly created TextNode */ protected function createTextNode(ElementNode $parent, $string) { $children = $parent->getChildren(); if (!empty($children)) { $lastElement = end($children); reset($children); if ($lastElement->isTextNode()) { $lastElement->setValue($lastElement->getValue() . $string); return $lastElement; } } $textNode = new TextNode($string); $parent->addChild($textNode); return $textNode; }