Exemple #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;
 }
Exemple #2
0
        }
        return $figure;
    } else {
        $class = trim($tag->attr('class') . ' ' . $tag->attr('imgclass'));
        return $_link($_image($class));
    }
});
// link tag
kirbytext::$tags['link'] = array('attr' => array('text', 'class', 'title', 'rel', 'target', 'popup'), 'html' => function ($tag) {
    $link = url($tag->attr('link'));
    $text = $tag->attr('text');
    if (empty($text)) {
        $text = escape::attr($link);
    } else {
        if (str::isURL($text)) {
            $text = escape::attr($text);
        }
    }
    return html::a($link, $text, array('rel' => $tag->attr('rel'), 'class' => $tag->attr('class'), 'title' => $tag->attr('title'), 'target' => $tag->target()));
});
// tel tag
kirbytext::$tags['tel'] = array('attr' => array('text', 'class', 'title'), 'html' => function ($tag) {
    $text = $tag->attr('text');
    $tel = str_replace(array('/', ' ', '-'), '', $tag->attr('tel'));
    if (empty($text)) {
        $text = $tag->attr('tel');
    }
    return html::a('tel:' . $tel, html($text), array('rel' => $tag->attr('rel'), 'class' => $tag->attr('class'), 'title' => html($tag->attr('title'))));
});
// twitter tag
kirbytext::$tags['twitter'] = array('attr' => array('class', 'title', 'text', 'rel', 'target', 'popup'), 'html' => function ($tag) {
Exemple #3
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'));
});