Пример #1
0
<?php

echo CodeHighlight::execute($db_object->object->body);
if (!empty($tags)) {
    ?>
    {tpl:tags.tpl.php}
<?php 
}
Пример #2
0
function plugin_code_convert()
{
    if (file_exists(PLUGIN_DIR . 'code/codehighlight.php')) {
        require_once PLUGIN_DIR . 'code/codehighlight.php';
    } else {
        die_message('file ' . PLUGIN_DIR . 'code/codehighlight.php not exist or not readable.');
    }
    static $plugin_code_jscript_flag = true;
    $lang = null;
    $option = array('number' => false, 'nonumber' => false, 'outline' => false, 'nooutline' => false, 'comment' => false, 'nocomment' => false, 'menu' => false, 'nomenu' => false, 'icon' => false, 'noicon' => false, 'link' => false, 'nolink' => false);
    $num_of_arg = func_num_args();
    $args = func_get_args();
    if ($num_of_arg < 1) {
        return PLUGIN_CODE_USAGE;
    }
    $arg = $args[$num_of_arg - 1];
    if (strlen($arg) == 0) {
        return PLUGIN_CODE_USAGE;
    }
    if ($num_of_arg != 1 && !_plugin_code_check_argment($args[0], $option)) {
        $is_setlang = true;
        $lang = htmlspecialchars(strtolower($args[0]));
        // 言語名かオプションの判定
    } else {
        $lang = PLUGIN_CODE_LANGUAGE;
        // default
    }
    $begin = 0;
    $end = null;
    // オプションを調べる
    for ($i = 1; $i < $num_of_arg - 1; ++$i) {
        if (!_plugin_code_check_argment($args[$i], $option)) {
            _plugin_code_get_region($args[$i], $begin, $end);
        }
    }
    $multiline = _plugin_code_multiline_argment($arg, $data, $option, $begin, $end);
    if (PLUGIN_CODE_CACHE && !$multiline) {
        $html = _plugin_code_read_cache($arg);
        if ($html != '' or $html != null) {
            return $html;
        }
    }
    if (isset($data['_error']) && $data['_error'] != '') {
        return $data['_error'];
    }
    $lines = $data['data'];
    $title = isset($data['title']) ? $data['title'] : '';
    $highlight = new CodeHighlight();
    $lines = $highlight->highlight($lang, $lines, $option);
    $lines = '<div class="' . $lang . '">' . $lines . '</div>';
    if ($plugin_code_jscript_flag && ($option['outline'] || $option['comment'])) {
        $plugin_code_jscript_flag = false;
        $title .= '<script type="text/javascript" src="' . SKIN_URI . 'code.js"></script>' . "\n";
    }
    $html = $title . $lines;
    if (PLUGIN_CODE_CACHE && !$multiline) {
        _plugin_code_write_cache($arg, $html);
    }
    return $html;
}