Beispiel #1
0
function bbcodeCodeHighlight($dom, $contents, $arg)
{
    // in <pre> style
    $contents = preg_replace('/^\\n|\\n$/', "", $contents);
    include_once "geshi.php";
    if (!$arg) {
        $div = $dom->createElement('div');
        $div->setAttribute('class', 'codeblock');
        $div->appendChild($dom->createTextNode($contents));
        return $div;
    } else {
        $language = $arg;
        $geshi = new GeSHi($contents, $language);
        $geshi->set_header_type(GESHI_HEADER_NONE);
        $geshi->enable_classes();
        $geshi->enable_keyword_links(false);
        $code = str_replace("\n", "", $geshi->parse_code());
        return markupToMarkup($dom, "<div class=\"codeblock geshi\">{$code}</div>");
    }
}
Beispiel #2
0
function bbcodeForum($dom, $nothing, $arg)
{
    global $forumLinkCache, $loguser;
    $id = (int) $arg;
    if (!isset($forumLinkCache[$id])) {
        $rForum = Query("SELECT\n\t\t\t\t\t\t\tid, title\n\t\t\t\t\t\tFROM {forums}\n\t\t\t\t\t\tWHERE id={0} and minpower <= {1}", $id, $loguser["powerlevel"]);
        if (NumRows($rForum)) {
            $forum = Fetch($rForum);
            $forumLinkCache[$id] = actionLinkTag($forum['title'], "forum", $forum['id']);
        } else {
            $forumLinkCache[$id] = "&lt;invalid forum ID&gt;";
        }
    }
    return markupToMarkup($dom, $forumLinkCache[$id]);
}