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(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 . '%;']); }