Beispiel #1
0
 private function escape($string)
 {
     if (is_string($string)) {
         switch ($this->escape_level) {
             case self::ESCAPE_ATTR:
                 $string = \escape::attribute($string);
                 break;
             case self::ESCAPE_HTML:
                 $string = \escape::html($string);
                 break;
         }
     }
     return $string;
 }
Beispiel #2
0
kirbytext::$tags['twitter'] = array('attr' => array('class', 'title', 'text', 'rel', 'target', 'popup'), 'html' => function ($tag) {
    // get and sanitize the username
    $username = str_replace('@', '', $tag->attr('twitter'));
    // build the profile url
    $url = 'https://twitter.com/' . $username;
    // sanitize the link text
    $text = $tag->attr('text', '@' . $username);
    // build the final link
    return html::a($url, $text, array('class' => $tag->attr('class'), 'title' => $tag->attr('title'), 'rel' => $tag->attr('rel'), 'target' => $tag->target()));
});
kirbytext::$tags['youtube'] = array('attr' => array('width', 'height', 'class', 'caption'), 'html' => function ($tag) {
    $caption = $tag->attr('caption');
    if (!empty($caption)) {
        $figcaption = '<figcaption>' . escape::html($caption) . '</figcaption>';
    } else {
        $figcaption = null;
    }
    return '<figure class="' . $tag->attr('class', kirby()->option('kirbytext.video.class', 'video')) . '">' . embed::youtube($tag->attr('youtube'), array('width' => $tag->attr('width', kirby()->option('kirbytext.video.width')), 'height' => $tag->attr('height', kirby()->option('kirbytext.video.height')))) . $figcaption . '</figure>';
});
kirbytext::$tags['vimeo'] = array('attr' => array('width', 'height', 'class', 'caption'), 'html' => function ($tag) {
    $caption = $tag->attr('caption');
    if (!empty($caption)) {
        $figcaption = '<figcaption>' . escape::html($caption) . '</figcaption>';
    } else {
        $figcaption = null;
    }
    return '<figure class="' . $tag->attr('class', kirby()->option('kirbytext.video.class', 'video')) . '">' . embed::vimeo($tag->attr('vimeo'), array('width' => $tag->attr('width', kirby()->option('kirbytext.video.width')), 'height' => $tag->attr('height', kirby()->option('kirbytext.video.height')))) . $figcaption . '</figure>';
});
kirbytext::$tags['gist'] = array('attr' => array('file'), 'html' => function ($tag) {
    return embed::gist($tag->attr('gist'), $tag->attr('file'));
});