Example #1
0
 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 asHtml(\JBBCode\ElementNode $el)
 {
     $content = '';
     foreach ($el->getChildren() as $child) {
         $content .= $child->getAsBBCode();
     }
     if ($el->getAttribute()['file'] == 'image') {
         return '<img src="' . base_url($content) . '"/>';
     }
 }
Example #3
0
 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);
     }
 }
Example #4
0
 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)
 {
     $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 -->';
 }
Example #6
0
 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 &amp; anzeigen
         $content = str_replace('&amp;', '&', $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);
 }
Example #7
0
 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>';
 }
Example #8
0
 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);
 }
Example #9
0
 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 . '%;']);
 }