コード例 #1
0
ファイル: uname.inc.php プロジェクト: big2men/qhm
function plugin_uname_inline()
{
    $qt = get_qt();
    //---- キャッシュのための処理を登録 -----
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    global $vars;
    $name = isset($vars['uname']) ? $vars['uname'] : '';
    //unameパラメータがセットされていない場合
    if ($name == '') {
        return 'あなた';
    } else {
        $name = htmlspecialchars(mb_convert_encoding($name, SOURCE_ENCODING, 'UTF8,EUC-JP,Shift_JIS'));
    }
    $args = func_get_args();
    $num = count($args);
    $ntitle = "さん";
    if ($num > 1) {
        strip_htmltag(array_pop($args), FALSE);
        $tmpstr = strip_htmltag(array_pop($args), FALSE);
        if ($tmpstr == "none") {
            $ntitle = '';
        } else {
            $ntitle = $tmpstr;
        }
    }
    return $name . $ntitle;
}
コード例 #2
0
ファイル: _set.inc.php プロジェクト: logue/pukiwiki_adv
/**
 * I18N - 各言語毎のメッセージを一時的に設定するプラグイン
 *
 * @copyright   Copyright &copy; 2005, Katsumi Saito <*****@*****.**>
 * @version     $Id: _set.inc.php,v 0.1 2005/05/07 23:38:00 upk Exp $
 * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 */
function plugin__set_inline()
{
    global $i18n_temp_msg;
    $argc = func_num_args();
    $argv = func_get_args();
    list($key, $lang, $msg) = i18n_set_param($argc, $argv);
    $i18n_temp_msg[$key][$lang] = strip_htmltag($msg);
    return '';
}
コード例 #3
0
function plugin_img3_inline()
{
    global $script;
    global $_img3_msg;
    static $img_no = 0;
    // パラメータ
    @(list($src, $title, $ratio, $align) = func_get_args());
    if (is_null($src) || empty($src)) {
        return '';
    }
    if (is_null($title) || empty($title)) {
        $title = 'image';
    }
    if (is_null($ratio) || empty($ratio)) {
        $ratio = 1;
    }
    if (is_null($align) || empty($align)) {
        $align = '';
    }
    // ファイルの存在チェック
    // $url = rawurldecode($src);
    $url_arry = parse_url($src);
    if (empty($url_arry['scheme'])) {
        if (!file_exists($src)) {
            return $_img3_msg['not_found'];
        }
    } else {
        if (!USE_IMAGE_URI) {
            return $_img3_msg['not_permitted'];
        }
    }
    $src = htmlspecialchars($src);
    $title = strip_htmltag($title);
    $title = htmlspecialchars($title);
    $ratio = htmlspecialchars($ratio);
    $align = htmlspecialchars($align);
    $size = img3_set_image_size($src, $ratio);
    // width, height の取得
    if ($size[4] == 0) {
        return $_img3_msg['not_support'];
    }
    if (!empty($align)) {
        $img_no++;
        return <<<EOD
<style type="text/css">
img.img3{$img_no} { vertical-align: {$align}; }
</style>
<img src="{$src}" alt="{$title}" title="{$title}" {$size[6]} class="img3{$img_no}" />
EOD;
    }
    return <<<EOD
<img src="{$src}" alt="{$title}" title="{$title}" {$size[6]} />
EOD;
}
コード例 #4
0
ファイル: ruby.inc.php プロジェクト: geoemon2k/source_wiki
function plugin_ruby_inline()
{
    if (func_num_args() != 2) {
        return PLUGIN_RUBY_USAGE;
    }
    list($ruby, $body) = func_get_args();
    // strip_htmltag() is just for avoiding AutoLink insertion
    $body = strip_htmltag($body);
    if ($ruby == '' || $body == '') {
        return PLUGIN_RUBY_USAGE;
    }
    return '<ruby><rb>' . $body . '</rb>' . '<rp>(</rp>' . '<rt>' . htmlsc($ruby) . '</rt>' . '<rp>)</rp>' . '</ruby>';
}
コード例 #5
0
ファイル: aname.inc.php プロジェクト: KimuraYoichi/PukiWiki
function plugin_aname_inline()
{
    $convert = FALSE;
    if (func_num_args() < 2) {
        return plugin_aname_usage($convert);
    }
    $args = func_get_args();
    // ONE or more
    $body = strip_htmltag(array_pop($args), FALSE);
    // Strip anchor tags only
    array_push($args, $body);
    return plugin_aname_tag($args, $convert);
}
コード例 #6
0
ファイル: ruby.inc.php プロジェクト: big2men/qhm
function plugin_ruby_inline()
{
    $qm = get_qm();
    if (func_num_args() != 2) {
        return $qm->m['plg_ruby']['err_usage'];
    }
    list($ruby, $body) = func_get_args();
    // strip_htmltag() is just for avoiding AutoLink insertion
    $body = strip_htmltag($body);
    if ($ruby == '' || $body == '') {
        return $qm->m['plg_ruby']['err_usage'];
    }
    return '<ruby><rb>' . $body . '</rb>' . '<rp>(</rp>' . '<rt>' . h($ruby) . '</rt>' . '<rp>)</rp>' . '</ruby>';
}
コード例 #7
0
/**
 * @copyright   Copyright &copy; 2006, Katsumi Saito <*****@*****.**>
 * @version     $Id: _get.inc.php,v 0.2 2006/04/30 16:56:00 upk Exp $
 * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
 */
function plugin__get_inline()
{
    switch (func_num_args()) {
        case 2:
            list($msg) = func_get_args();
            return strip_htmltag($msg);
        case 3:
            list($name, $msg) = func_get_args();
            return i18n_gettext($name, $msg);
        case 4:
            list($name, $lang, $msg) = func_get_args();
            return i18n_setlocale($name, $lang, $msg);
    }
    return '';
}
コード例 #8
0
/**
 * Get TITLE: line or the first headline of a page
 *
 * Usage:
 * - &get_title(page,[option])
 * Option
 * - firsthead Get the first headline instead of title
 *
 * @package    plugin
 * @license    http://www.gnu.org/licenses/gpl.html GPL v2
 * @author     sonots
 * @link       http://lsx.sourceforge.jp/?Plugin%2Fget_title.inc.php
 * @version    $Id: get_title.inc.php,v 2.0 2008-07-30 16:28:39Z sonots $
 */
function plugin_get_title_inline()
{
    $args = func_get_args();
    array_pop($args);
    $page = array_shift($args);
    $conf_options = array('firsthead' => false);
    $options = sonots::parse_options($args, $conf_options);
    if ($options['firsthead']) {
        $str = PluginSonotsMetapage::firsthead($page);
    } else {
        $str = PluginSonotsMetapage::title($page);
    }
    if (is_null($str)) {
        $str = $page;
    }
    $str = strip_htmltag(make_link($str));
    return $str;
}
コード例 #9
0
ファイル: _.inc.php プロジェクト: aterai/pukiwiki-plus-i18n
/**
 * Plug-in that achieves gettext in PukiWiki page
 * PukiWiki ページ内で gettext を実現するプラグイン
 *
 * @copyright   Copyright &copy; 2005-2006, Katsumi Saito <*****@*****.**>
 * @version     $Id: _.inc.php,v 0.10 2006/02/04 23:42:00 upk Exp $
 * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 * o :config/i18n/text/ja/text or :config/i18n/text/ja_JP is acceptable.
 * o There are zh_TW etc. ,
 *   too and the form of language_country can be selected though the language name is appropriate in principle.
 * o 原則的には、言語名が適切であるものの、zh_TW などもあり 言語_国 の形式も選択可能。
 *
 * o &_(ja){掲示板};
 *   一度、英語の文字列を得て、表示言語に変換する。
 * o &_{BBS};
 *   英語表記であることを信じ、表示言語に変換する。
 *
 * 全てにおいて、未定義語の場合は、指定文字列をそのまま戻す。
 * All, a specified character string is returned as it is for an undefined word.
 *
 */
function plugin___inline()
{
    global $language_considering_setting_level;
    global $language;
    global $i18n_temp_msg;
    switch (func_num_args()) {
        case 1:
            list($msg) = func_get_args();
            // $parm_lang = DEFAULT_LANG;
            $parm_lang = 'en_US';
            break;
        default:
            list($parm_lang, $msg) = func_get_args();
    }
    $msg = strip_htmltag($msg);
    // FIXME: level 5
    $view_lang = $language_considering_setting_level == 0 ? get_language(5) : $language;
    $view_lang_split = accept_language::split_locale_str($view_lang);
    // ja_JP なら ja に分割
    if ($parm_lang == $view_lang || $parm_lang == $view_lang_split[1]) {
        return $msg;
    }
    // 指定言語と同じ
    // 指定文字列が en 以外の場合は、ベース言語に変換後、他言語に変換する
    $parm_lang_split = accept_language::split_locale_str($parm_lang);
    if (isset($i18n_temp_msg)) {
        $temp_msg = i18n_TempMsg($parm_lang_split, $view_lang_split, $msg);
        if (!empty($temp_msg)) {
            return $temp_msg;
        }
    }
    if ($parm_lang_split[1] !== 'en') {
        $msg = i18n_ConfMsgGet($parm_lang_split, $msg, 1);
    }
    // :config から、単語を検索
    return i18n_ConfMsgGet($view_lang_split, $msg);
}
コード例 #10
0
ファイル: html.php プロジェクト: geoemon2k/source_wiki
function make_heading(&$str, $strip = TRUE)
{
    global $NotePattern;
    // Cut fixed-heading anchors
    $id = '';
    $matches = array();
    if (preg_match('/^(\\*{0,3})(.*?)\\[#([A-Za-z][\\w-]+)\\](.*?)$/m', $str, $matches)) {
        $str = $matches[2] . $matches[4];
        $id =& $matches[3];
    } else {
        $str = preg_replace('/^\\*{0,3}/', '', $str);
    }
    // Cut footnotes and tags
    if ($strip === TRUE) {
        $str = strip_htmltag(make_link(preg_replace($NotePattern, '', $str)));
    }
    return $id;
}
コード例 #11
0
ファイル: edit.inc.php プロジェクト: KimuraYoichi/PukiWiki
function plugin_edit_inline()
{
    static $usage = '&edit(pagename#anchor[[,noicon],nolabel])[{label}];';
    global $script, $vars, $fixed_heading_anchor_edit;
    if (PKWK_READONLY) {
        return '';
    }
    // Show nothing
    // Arguments
    $args = func_get_args();
    // {label}. Strip anchor tags only
    $s_label = strip_htmltag(array_pop($args), FALSE);
    $page = array_shift($args);
    if ($page == NULL) {
        $page = '';
    }
    $_noicon = $_nolabel = FALSE;
    foreach ($args as $arg) {
        switch (strtolower($arg)) {
            case '':
                break;
            case 'nolabel':
                $_nolabel = TRUE;
                break;
            case 'noicon':
                $_noicon = TRUE;
                break;
            default:
                return $usage;
        }
    }
    // Separate a page-name and a fixed anchor
    list($s_page, $id, $editable) = anchor_explode($page, TRUE);
    // Default: This one
    if ($s_page == '') {
        $s_page = isset($vars['page']) ? $vars['page'] : '';
    }
    // $s_page fixed
    $isfreeze = is_freeze($s_page);
    $ispage = is_page($s_page);
    // Paragraph edit enabled or not
    $short = htmlspecialchars('Edit');
    if ($fixed_heading_anchor_edit && $editable && $ispage && !$isfreeze) {
        // Paragraph editing
        $id = rawurlencode($id);
        $title = htmlspecialchars(sprintf('Edit %s', $page));
        $icon = '<img src="' . IMAGE_DIR . 'paraedit.png' . '" width="9" height="9" alt="' . $short . '" title="' . $title . '" /> ';
        $class = ' class="anchor_super"';
    } else {
        // Normal editing / unfreeze
        $id = '';
        if ($isfreeze) {
            $title = 'Unfreeze %s';
            $icon = 'unfreeze.png';
        } else {
            $title = 'Edit %s';
            $icon = 'edit.png';
        }
        $title = htmlspecialchars(sprintf($title, $s_page));
        $icon = '<img src="' . IMAGE_DIR . $icon . '" width="20" height="20" alt="' . $short . '" title="' . $title . '" />';
        $class = '';
    }
    if ($_noicon) {
        $icon = '';
    }
    // No more icon
    if ($_nolabel) {
        if (!$_noicon) {
            $s_label = '';
            // No label with an icon
        } else {
            $s_label = $short;
            // Short label without an icon
        }
    } else {
        if ($s_label == '') {
            $s_label = $title;
        }
        // Rich label with an icon
    }
    // URL
    if ($isfreeze) {
        $url = $script . '?cmd=unfreeze&amp;page=' . rawurlencode($s_page);
    } else {
        $s_id = $id == '' ? '' : '&amp;id=' . $id;
        $url = $script . '?cmd=edit&amp;page=' . rawurlencode($s_page) . $s_id;
    }
    $atag = '<a' . $class . ' href="' . $url . '" title="' . $title . '">';
    static $atags = '</a>';
    if ($ispage) {
        // Normal edit link
        return $atag . $icon . $s_label . $atags;
    } else {
        // Dangling edit link
        return '<span class="noexists">' . $atag . $icon . $atags . $s_label . $atag . '?' . $atags . '</span>';
    }
}
コード例 #12
0
ファイル: tb.inc.php プロジェクト: nsmr0604/pukiwiki
function plugin_tb_output_rsslist($tb_id)
{
    global $script, $vars, $entity_pattern;
    $page = tb_id2page($tb_id);
    if ($page === false) {
        return false;
    }
    $items = '';
    foreach (tb_get(tb_get_filename($page)) as $arr) {
        // _utime_, title, excerpt, _blog_name_
        array_shift($arr);
        // Cut utime
        list($url, $title, $excerpt) = array_map(create_function('$a', 'return htmlspecialchars($a);'), $arr);
        $items .= <<<EOD

   <item>
    <title>{$title}</title>
    <link>{$url}</link>
    <description>{$excerpt}</description>
   </item>
EOD;
    }
    $title = htmlspecialchars($page);
    $link = $script . '?' . rawurlencode($page);
    $vars['page'] = $page;
    $excerpt = strip_htmltag(convert_html(get_source($page)));
    $excerpt = preg_replace("/&{$entity_pattern};/", '', $excerpt);
    $excerpt = mb_strimwidth(preg_replace("/[\r\n]/", ' ', $excerpt), 0, 255, '...');
    $lang = PLUGIN_TB_LANGUAGE;
    $rc = <<<EOD
<?xml version="1.0" encoding="utf-8" ?>
<response>
 <error>0</error>
 <rss version="0.91">
  <channel>
   <title>{$title}</title>
   <link>{$link}</link>
   <description>{$excerpt}</description>
   <language>{$lang}</language>{$items}
  </channel>
 </rss>
</response>
EOD;
    pkwk_common_headers();
    header('Content-Type: text/xml');
    echo mb_convert_encoding($rc, 'UTF-8', SOURCE_ENCODING);
    exit;
}
コード例 #13
0
ファイル: trackback.php プロジェクト: nsmr0604/pukiwiki
function tb_send($page, $plus, $minus = '')
{
    global $page_title;
    $script = get_script_uri();
    // Disable 'max execution time' (php.ini: max_execution_time)
    if (ini_get('safe_mode') == '0') {
        set_time_limit(0);
    }
    // Get URLs from <a>(anchor) tag from convert_html()
    $links = array();
    $plus = convert_html($plus);
    // WARNING: heavy and may cause side-effect
    preg_match_all('#href="(https?://[^"]+)"#', $plus, $links, PREG_PATTERN_ORDER);
    $links = array_unique($links[1]);
    // Reject from minus list
    if ($minus != '') {
        $links_m = array();
        $minus = convert_html($minus);
        // WARNING: heavy and may cause side-effect
        preg_match_all('#href="(https?://[^"]+)"#', $minus, $links_m, PREG_PATTERN_ORDER);
        $links_m = array_unique($links_m[1]);
        $links = array_diff($links, $links_m);
    }
    // Reject own URL (Pattern _NOT_ started with '$script' and '?')
    $links = preg_grep('/^(?!' . preg_quote($script, '/') . '\\?)./', $links);
    // No link, END
    if (!is_array($links) || empty($links)) {
        return;
    }
    $r_page = rawurlencode($page);
    $excerpt = strip_htmltag(convert_html(get_source($page)));
    // Sender's information
    $putdata = array('title' => $page, 'url' => $script . '?' . $r_page, 'excerpt' => mb_strimwidth(preg_replace("/[\r\n]/", ' ', $excerpt), 0, 255, '...'), 'blog_name' => $page_title . ' (' . PLUGIN_TRACKBACK_VERSION . ')', 'charset' => SOURCE_ENCODING);
    foreach ($links as $link) {
        $tb_id = tb_get_url($link);
        // Get Trackback ID from the URL
        if (empty($tb_id)) {
            continue;
        }
        // Trackback is not supported
        $result = http_request($tb_id, 'POST', '', $putdata, 2, CONTENT_CHARSET);
        // FIXME: Create warning notification space at pukiwiki.skin!
    }
}
コード例 #14
0
ファイル: rss.inc.php プロジェクト: big2men/qhm
function plugin_rss_action()
{
    global $vars, $rss_max, $page_title, $whatsnew, $trackback;
    global $qblog_defaultpage, $qblog_title, $qblog_close;
    $qm = get_qm();
    $qt = get_qt();
    $version = isset($vars['ver']) ? $vars['ver'] : '';
    switch ($version) {
        case '':
            $version = '2.0';
            break;
            // Default
        // Default
        case '1':
            $version = '1.0';
            break;
            // Sugar
        // Sugar
        case '2':
            $version = '2.0';
            break;
            // Sugar
        // Sugar
        case '0.91':
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '1.0':
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '2.0':
            break;
        default:
            die($qm->m['plg_rss']['err_version']);
    }
    $lang = LANG;
    $qblog_mode = FALSE;
    //blogモード
    if (isset($vars['blog_rss']) && $vars['blog_rss'] != '') {
        $blog_mode = $vars['blog_rss'];
        //ブログページ名
        $qt->setv('blog_rss_mode', true);
        $page_title_utf8 = $page_title . ' - ' . $blog_mode;
    } else {
        if (isset($vars['qblog_rss'])) {
            //閉鎖中はRSS出力しない
            if ($qblog_close) {
                exit;
            }
            $qblog_mode = TRUE;
            $blog_mode = FALSE;
            $page_title_utf8 = mb_convert_encoding($qblog_title, 'UTF-8', SOURCE_ENCODING);
        } else {
            $blog_mode = false;
            $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING);
        }
    }
    $self = get_script_uri();
    // Creating <item>
    global $ignore_plugin, $strip_plugin, $strip_plugin_inline;
    $items = $rdf_li = '';
    if ($qblog_mode) {
        $qblog_recent = CACHEQBLOG_DIR . 'qblog_recent.dat';
        if (!file_exists($qblog_recent)) {
            die($qm->m['plg_rss']['err_nodata']);
        }
        // ページネーション用のヘッダー行を飛ばす
        $lines = file_head($qblog_recent, $rss_max + 1);
        array_shift($lines);
    } else {
        $recent = CACHE_DIR . 'recent.dat';
        if (!file_exists($recent)) {
            die($qm->m['plg_rss']['err_nodata']);
        }
        $lines = file_head($recent, $rss_max);
    }
    foreach ($lines as $line) {
        $skip_list = FALSE;
        if ($qblog_mode) {
            $page = trim($line);
            $time = strtotime(get_qblog_date('Y-m-d 00:00:00', $page));
        } else {
            list($time, $page) = explode("\t", rtrim($line));
        }
        //blogモードで、$blog_name/Hogehogeでないなら(つまり、ブログページでないなら、何もしない
        if ($blog_mode && !preg_match('/^' . $blog_mode . '\\/.*/', $page)) {
            continue;
        }
        $r_page = rawurlencode($page);
        $title = get_page_title($page);
        $source = get_source($page);
        foreach ($source as $k => $l) {
            if (preg_match($ignore_plugin, $l)) {
                // リストから省く
                $skip_list = TRUE;
                break;
            }
            if (preg_match($strip_plugin, $l)) {
                // 説明から省く
                unset($source[$k]);
            }
        }
        if ($skip_list) {
            continue;
        }
        //html(noskinを避ける)
        if (count($source) > 0) {
            $source = str_replace('#html(noskin)', '#html()', $source);
            $source = preg_replace($strip_plugin_inline, '', $source);
            // 行内のプラグインを説明から省く
        }
        $contents = mb_strimwidth(strip_htmltag(convert_html($source)), 0, RSS_DESP_LENGTH, '...');
        $contents = preg_replace_callback('/(&[^;]+;)/', 'plugin_rss_html_entity_decode', $contents);
        $contents = plugin_rss_utf8_for_xml($contents);
        switch ($version) {
            case '0.91':
                /* FALLTHROUGH */
            /* FALLTHROUGH */
            case '2.0':
                $date = get_date('D, d M Y H:i:s T', $time);
                $date = $version == '0.91' ? ' <description>' . $date . ' -- ' . $contents . '</description>' : ' <pubDate>' . $date . '</pubDate>' . ' <description>' . $contents . '</description>';
                $items .= <<<EOD
<item>
 <title>{$title}</title>
 <link>{$self}?{$r_page}</link>
{$date}
</item>

EOD;
                break;
            case '1.0':
                // Add <item> into <items>
                $rdf_li .= '    <rdf:li rdf:resource="' . $self . '?' . $r_page . '" />' . "\n";
                $date = substr_replace(get_date('Y-m-d\\TH:i:sO', $time), ':', -2, 0);
                $trackback_ping = '';
                if ($trackback) {
                    $tb_id = md5($r_page);
                    $trackback_ping = ' <trackback:ping>' . $self . '?tb_id=' . $tb_id . '</trackback:ping>';
                }
                $items .= <<<EOD
<item rdf:about="{$self}?{$r_page}">
 <title>{$title}</title>
 <link>{$self}?{$r_page}</link>
 <description><![CDATA[{$contents}]]></description>
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$self}?{$r_page}</dc:identifier>
{$trackback_ping}
</item>

EOD;
                break;
        }
    }
    // Feeding start
    pkwk_common_headers();
    header('Content-type: application/xml; charset=utf-8');
    print '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n";
    $r_whatsnew = rawurlencode($blog_mode ? $blog_mode : $whatsnew);
    $pagename = $qblog_mode ? $qblog_defaultpage : $r_whatsnew;
    $description = $qblog_mode ? 'QBlog Recent Changes' : $qm->m['plg_rss']['description'];
    $page_title_utf8 = h(plugin_rss_utf8_for_xml($page_title_utf8));
    $description = h(plugin_rss_utf8_for_xml($description));
    switch ($version) {
        case '0.91':
            print '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' . ' "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n";
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '2.0':
            print <<<EOD
<rss version="{$version}">
 <channel>
  <title>{$page_title_utf8}</title>
  <link>{$self}?{$pagename}</link>
  <description>{$description}</description>
  <language>{$lang}</language>

{$items}
 </channel>
</rss>
EOD;
            break;
        case '1.0':
            $xmlns_trackback = $trackback ? '  xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"' : '';
            print <<<EOD
<rdf:RDF
  xmlns:dc="http://purl.org/dc/elements/1.1/"
{$xmlns_trackback}
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xml:lang="{$lang}">
 <channel rdf:about="{$self}?{$pagename}">
  <title>{$page_title_utf8}</title>
  <link>{$self}?{$pagename}</link>
  <description>{$description}</description>
  <items>
   <rdf:Seq>
{$rdf_li}
   </rdf:Seq>
  </items>
 </channel>

{$items}
</rdf:RDF>
EOD;
            break;
    }
    exit;
}
コード例 #15
0
function plugin_weblog_rss_action()
{
    global $rss_max, $page_title, $WikiName, $BracketName, $script, $whatsnew, $trackback, $use_static_url, $anon_writable;
    global $vars;
    global $options, $_weblog_msgs;
    //コンフィグの読み込み(指定weblog固有)
    $conf_name = $vars['config'];
    $options = weblog_get_options($conf_name, $options);
    $page = strip_bracket($options['PREFIX']);
    $with_content = $vars['content'];
    $list_count = $vars['count'];
    if ($list_count == 0) {
        $list_count = $rss_max;
    }
    $lines = get_existpages(false, $page, $list_count, " ORDER BY editedtime DESC", true);
    header("Content-type: application/xml");
    if (is_page($page)) {
        $linkpage = $page;
    } else {
        if (strrchr($page, "/")) {
            $_p = substr($page, 0, -strlen(strrchr($page, "/")));
            if (is_page($_p)) {
                $linkpage = $_p;
            }
        } else {
            $linkpage = $whatsnew;
        }
    }
    if ($use_static_url) {
        $linkpage_url = XOOPS_WIKI_URL . "/" . get_pgid_by_name($linkpage) . ".html";
    } else {
        $linkpage_url = $script . "?" . rawurlencode($linkpage);
    }
    $page_title_utf8 = $page_title;
    if (function_exists("mb_convert_encoding")) {
        $page_title_utf8 = mb_convert_encoding($page_title_utf8, "UTF-8", "auto");
        //		$page_utf8 = mb_convert_encoding($linkpage,"UTF-8","auto");
        $page_utf8 = mb_convert_encoding($options['NAME'], "UTF-8", "auto");
        $page_add_utf8 = $linkpage ? "-" . $page_utf8 : "";
    }
    $item = "";
    $rdf_li = "";
    foreach ($lines as $line) {
        $vars['page'] = $line;
        $page_name = strip_bracket($line);
        if (!preg_match("/^(.*\\/)?[0-9\\-]+\$/", $page_name)) {
            continue;
        }
        $src = @join("", get_source($page_name));
        $sources = $src;
        if (preg_match("/\\&weblog_field\\(__SUBJECT\\)\\{([^}]+)\\}\\;/m", $sources, $match)) {
            $subject = $match[1];
        }
        if (preg_match("/\\&weblog_field\\(__AUTHOR\\)\\{([^}]+)\\}\\;/m", $sources, $match)) {
            $author = $match[1];
        }
        if (preg_match("/\\&weblog_field\\(__CATEGORY,:([^\\)]+)\\)\\{([^}]+)\\}\\;((\\[ )?\\[\\[.*\\]\\]( \\])?)+/m", $sources, $match)) {
            $catpath = $match[1];
            $category = $match[2];
        }
        if (preg_match("/#weblog_field\\(__BODY\\,Start\\)\\s*\n(.*\n)#weblog_field\\(__BODY\\,End\\)\n/ms", $sources, $match)) {
            $body = $match[1];
            $body = preg_replace("/\\s*((\r\n)|(\r)|(\n))/", "\n", $body);
        }
        $title = mb_convert_encoding($subject, "UTF-8", "auto");
        $url = strip_bracket($line);
        //		if ($page) $title = preg_replace("/^".preg_quote($page_utf8,"/")."\//","",$title);
        $title = htmlspecialchars($title);
        $desc = date("D, d M Y H:i:s T", filemtime(get_filename(encode($line))));
        $dcdate = substr_replace(date("Y-m-d\\TH:i:sO", filemtime(get_filename(encode($line)))), ':', -2, 0);
        if ($use_static_url) {
            $link_url = XOOPS_WIKI_URL . "/" . get_pgid_by_name($line) . ".html";
        } else {
            $link_url = $script . "?" . rawurlencode($url);
        }
        $items .= "<item rdf:about=\"" . $link_url . "\">\n";
        $items .= " <title>{$title}</title>\n";
        $items .= " <link>" . $link_url . "</link>\n";
        $items .= " <dc:date>{$dcdate}</dc:date>\n";
        $_anon_writable = $anon_writable;
        $anon_writable = 0;
        $desc = convert_html($body, false, false);
        $desc = mb_convert_encoding(mb_substr(strip_htmltag($desc), 0, 250, "EUC-JP"), "UTF-8", "auto");
        $desc = htmlspecialchars($desc);
        $desc = mb_ereg_replace("\n", "", $desc);
        $items .= " <description>{$desc}</description>\n";
        if ($with_content == "true") {
            $src = preg_replace("/\\&weblog_field\\(__EDIT\\,[^\\)]+\\);/m", "", $src);
            $content = convert_html($src, false, false);
            $content = mb_convert_encoding($content, "UTF-8", "auto");
            $content = preg_replace("/\\<input [^\\>]+\\/>(\n)?/ms", "", $content);
            $content = preg_replace("/^(\\s*\n)+/mS", "\n", $content);
            $content = preg_replace("/\\s*\\<br \\/\\>\\s*/mS", "<br />", $content);
            $content = preg_replace("/class\\=\"p\\_right\"/", 'style="text-align:right;"', $content);
            $items .= "<content:encoded>\n<![CDATA[\n";
            $items .= "{$content}\n";
            $items .= "]]>\n</content:encoded>\n";
        }
        $anon_writable = $anon_writable = 0;
        //trackback
        if ($trackback) {
            $dc_identifier = $trackback_ping = '';
            $r_page = rawurlencode($url);
            $tb_id = tb_get_id($url);
            $dc_identifier = " <dc:identifer>{$link_url}</dc:identifer>\n";
            $trackback_ping = " <trackback:ping>{$script}?pwm_ping={$tb_id}</trackback:ping>\n";
            $items .= $dc_identifier . $trackback_ping;
        }
        if ($category != "") {
            $cats = explode(",", $category);
            foreach ($cats as $cat_item) {
                //				$subject = $catpath."/".$cat_item;
                $subject = $cat_item;
                $subject = mb_convert_encoding($subject, "UTF-8", "auto");
                $items .= "<dc:subject>{$subject}</dc:subject>\n";
            }
        }
        $items .= "</item>\n\n";
        $rdf_li .= "<rdf:li rdf:resource=\"" . $link_url . "\" />\n";
    }
    //	header('Content-type: text');
    $r_page = rawurlencode($page);
    echo <<<EOD
<?xml version="1.0" encoding="utf-8"?>

<rdf:RDF 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
EOD;
    if ($with_content == "true") {
        echo "  xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n";
    }
    if ($trackback) {
        echo "  xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\"\n";
    }
    echo <<<EOD
  xml:lang="ja">
  <channel rdf:about="{$script}?plugin=weblog_rss&amp;config={$conf_name}&amp;content={$with_content}&amp;count={$list_count}">
  <title>{$page_title_utf8}.{$page_add_utf8}</title>
  <link>{$linkpage_url}</link>
  <description>PukiWiki Weblog RecentChanges</description>
  <items>
   <rdf:Seq>
      {$rdf_li}
   </rdf:Seq>
  </items>
 </channel>
 {$items}
</rdf:RDF>
EOD;
    exit;
}
コード例 #16
0
ファイル: mixirss.inc.php プロジェクト: logue/pukiwiki_adv
function plugin_mixirss_action()
{
    global $vars, $get, $post, $rss_max, $rss_description, $page_title, $whatsnew;
    global $modifier;
    global $exclude_plugin;
    global $memcache;
    $version = isset($vars['ver']) ? $vars['ver'] : '';
    switch ($version) {
        case '':
            $version = '1.0';
            break;
            // mixi Default
        // mixi Default
        case '1':
            $version = '1.0';
            break;
        case '2':
            $version = '2.0';
            break;
        case '0.91':
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '1.0':
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '2.0':
            break;
        default:
            die('Invalid RSS version!!');
    }
    // Official Main routine ...
    $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING);
    $rss_description_utf8 = mb_convert_encoding(htmlspecialchars($rss_description), 'UTF-8', SOURCE_ENCODING);
    // Disable plugin
    $exclude_plugin[] = 'include';
    $self = get_script_absuri();
    change_uri('', 1);
    // Force absoluteURI.
    // Creating <item>
    $items = $rdf_li = '';
    foreach (Recent::get() as $page => $time) {
        $wiki = Factory::Wiki($page);
        $r_page = rawurlencode($page);
        $url = $wiki->uri();
        $title = mb_convert_encoding($page, 'UTF-8', SOURCE_ENCODING);
        switch ($version) {
            case '0.91':
                /* FALLTHROUGH */
            /* FALLTHROUGH */
            case '2.0':
                $date = get_date('D, d M Y H:i:s T', $time);
                $date = $version == '0.91' ? ' <description>' . $date . '</description>' : ' <pubDate>' . $date . '</pubDate>';
                $items .= <<<EOD
<item>
 <title>{$title}</title>
 <link>{$url}</link>
{$date}
</item>
EOD;
                break;
            case '1.0':
                // Add <item> into <items>
                //			$rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                $date = substr_replace(get_date('Y-m-d\\TH:i:sO', $time), ':', -2, 0);
                if (plugin_mixirss_isValidDate(substr($page, -10)) && check_readable($page, false, false)) {
                    // for Calendar/MiniCalendar
                    $get['page'] = $post['page'] = $vars['page'] = $page;
                    $source = get_source($page);
                    $rdf_hx = '';
                    $rdf_lx = '';
                    $itemhx = '';
                    $itemlx = '';
                    while (!empty($source)) {
                        $line = array_shift($source);
                        if (preg_match('/^(\\*{1,3})(.*)\\[#([A-Za-z][\\w-]+)\\](.*)$/m', $line, $matches)) {
                            $anchortitle = strip_htmltag(RendererFactory::factory($matches[2]));
                            $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle);
                            $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>';
                            $sharp = '#';
                            $rdf_hx .= '    <rdf:li rdf:resource="' . $url . $sharp . $matches[3] . '" />' . "\n";
                            $itemhx .= <<<EOD
<item rdf:about="{$url}{$sharp}{$matches[3]}">
 <title>{$anchortitle}</title>
 <link>{$url}{$sharp}{$matches[3]}</link>
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}{$sharp}{$matches[3]}</dc:identifier>
</item>
EOD;
                        } else {
                            if (preg_match('/^(\\-{1,3})(.*)$/m', $line, $matches)) {
                                $anchortitle = strip_htmltag(RendererFactory::factory($matches[2]));
                                $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle);
                                $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>';
                                $sharp = '#';
                                $rdf_lx .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                                $itemlx .= <<<EOD
<item rdf:about="{$url}">
 <title>{$anchortitle}</title>
 <link>{$url}</link>
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
</item>

EOD;
                            }
                        }
                    }
                    if ($itemhx != '') {
                        $rdf_li .= $rdf_hx;
                        $items .= $itemhx;
                    } else {
                        if ($itemlx != '') {
                            $rdf_li .= $rdf_lx;
                            $items .= $itemlx;
                        } else {
                            // default
                            $rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                            $items .= <<<EOD
<item rdf:about="{$url}">
 <title>{$title}</title>
 <link>{$url}</link>
{$description}
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
</item>

EOD;
                        }
                    }
                    // upk 2006-03-22
                    // } else if (check_readable($page,false,false) && !ereg(MIXIRSS_IGNORE_REGEX, $page)) {
                } else {
                    if ($wiki->isReadable()) {
                        $get['page'] = $post['page'] = $vars['page'] = $page;
                        //miko added
                        $description = strip_htmltag($wiki->render());
                        $description = mb_strimwidth(preg_replace("/[\r\n]/", ' ', $description), 0, MIXIRSS_DESCRIPTION_LENGTH, '...');
                        $description = ' <description><![CDATA[' . mb_convert_encoding($description, 'UTF-8', SOURCE_ENCODING) . ']]></description>';
                        //miko added
                        $rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                        global $newtitle, $newbase;
                        if (isset($newbase) && $newbase != '') {
                            $anchortitle = $newtitle . ' (' . $title . ')';
                            $newtitle = $newbase = '';
                        } else {
                            $anchortitle = $title;
                        }
                        $items .= <<<EOD
<item rdf:about="{$url}">
 <title>{$anchortitle}</title>
 <link>{$url}</link>
{$description}
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
</item>

EOD;
                    }
                }
                break;
        }
    }
    // Feeding start
    $html = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    $w_whatsnew = Factory::Wiki($whatsnew);
    $url_whatsnew = $w_whatsnew->uri();
    switch ($version) {
        case '0.91':
            $html .= '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' . ' "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n";
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '2.0':
            $html .= <<<EOD
<rss version="{$version}">
 <channel>
  <title><![CDATA[{$page_title_utf8}]]></title>
  <link>{$url_whatsnew}</link>
  <description><![CDATA[{$rss_description_utf8}]]></description>
  <language>ja</language>

{$items}
 </channel>
</rss>
EOD;
            break;
        case '1.0':
            $html .= <<<EOD
<rdf:RDF
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xml:lang="ja">
 <channel rdf:about="{$url_whatsnew}">
  <title><![CDATA[{$page_title_utf8}]]></title>
  <link>{$url_whatsnew}</link>
  <description><![CDATA[{$rss_description_utf8}]]></description>
  <items>
   <rdf:Seq>
{$rdf_li}
   </rdf:Seq>
  </items>
 </channel>

{$items}
</rdf:RDF>
EOD;
            break;
    }
    $header = Header::getHeaders('application/xml', $w_whatsnew->time());
    Header::writeResponse($header, 200, $html);
    exit;
}
コード例 #17
0
function plugin_mceedit_inline()
{
    static $usage = '&edit(pagename#anchor[[,noicon],nolabel])[{label}];';
    global $script, $vars, $fixed_heading_edited;
    global $_symbol_paraedit;
    if (!$fixed_heading_edited || is_freeze($vars['page'])) {
        return '';
    }
    $args = func_get_args();
    $s_label = strip_htmltag(array_pop($args), FALSE);
    // {label}. Strip anchor tags only
    if ($s_label == '') {
        $s_label = $_symbol_paraedit;
    }
    list($page, $id) = array_pad($args, 2, '');
    if (!is_page($page)) {
        $page = $vars['page'];
    }
    if ($id != '') {
        $id = '&amp;id=' . rawurlencode($id);
    }
    $r_page = rawurlencode($page);
    return "<a class=\"anchor_super\" href=\"{$script}?cmd=edit&amp;page={$r_page}{$id}\">{$s_label}</a>";
}
コード例 #18
0
ファイル: tabbox.inc.php プロジェクト: big2men/qhm
function plugin_tabbox_convert()
{
    static $s_tab_cnt = 0;
    static $s_tab_confnum = 0;
    //jquery ライブラリの読み込み
    $qt = get_qt();
    $qt->setv('jquery_include', true);
    $args = func_get_args();
    $last = func_num_args() - 1;
    $body = '';
    $ret = $head = '';
    $options = array('tab' => PLUGIN_TABBOX_DEF_TAB, 'selected' => PLUGIN_TABBOX_DEF_SELECTED, 'hover' => PLUGIN_TABBOX_DEF_HOVER, 'box' => PLUGIN_TABBOX_DEF_BOX, 'default' => PLUGIN_TABBOX_DEF_DEFAULT, 'height' => PLUGIN_TABBOX_DEF_HEIGHT);
    $config = false;
    foreach ($args as $arg) {
        if (trim($arg) == 'conf') {
            $config = true;
        }
    }
    if ($config) {
        if ($last > 0) {
            $body = array_pop($args);
        }
        $options['conf'] = 'conf';
        $s_tab_confnum++;
    } else {
        if ($s_tab_cnt == 0) {
            $s_tab_confnum++;
        }
        $body = array_pop($args);
        foreach ($args as $arg) {
            list($key, $val) = explode('=', $arg, 2);
            $options[$key] = htmlspecialchars($val);
        }
        $options['tab'] = isset($options['tab']) ? $options['tab'] : PLUGIN_TABBOX_DEF_TAB;
        $options['selected'] = isset($options['selected']) ? $options['selected'] : PLUGIN_TABBOX_DEF_SELECTED;
        $options['hover'] = isset($options['hover']) ? $options['hover'] : PLUGIN_TABBOX_DEF_HOVER;
        $options['box'] = isset($options['box']) ? $options['box'] : PLUGIN_TABBOX_DEF_BOX;
        $options['default'] = isset($options['default']) ? $options['default'] : PLUGIN_TABBOX_DEF_DEFAULT;
        $options['height'] = isset($options['height']) ? $options['height'] : PLUGIN_TABBOX_DEF_HEIGHT;
    }
    $body = str_replace("\r", "\n", str_replace("\r\n", "\n", $body));
    // confが指定された場合
    if (isset($options['conf'])) {
        $tmp = explode("\n", $body);
        foreach ($tmp as $buff) {
            list($key, $val) = explode('=', $buff, 2);
            $options[$key] = htmlspecialchars($val);
        }
        // confに指定がない場合、デフォルトを設定
        $options['tab'] = isset($options['tab']) ? $options['tab'] : PLUGIN_TABBOX_DEF_TAB;
        $options['selected'] = isset($options['selected']) ? $options['selected'] : PLUGIN_TABBOX_DEF_TAB;
        $options['hover'] = isset($options['hover']) ? $options['hover'] : PLUGIN_TABBOX_DEF_HOVER;
        $options['box'] = isset($options['box']) ? $options['box'] : PLUGIN_TABBOX_DEF_BOX;
        $options['default'] = isset($options['default']) ? $options['default'] : PLUGIN_TABBOX_DEF_DEFAULT;
        $options['height'] = isset($options['default']) ? $options['default'] : PLUGIN_TABBOX_DEF_HEIGHT;
    } else {
        $lines = explode("\n", $body);
        $buff = "";
        $box = array();
        $title = array();
        $link = array();
        foreach ($lines as $l) {
            if (preg_match("/^\\*\\s?(.*)\$/", $l, $matches)) {
                if (count($title) > 0) {
                    $box[] = $buff;
                }
                $tmp = strip_htmltag(substr(convert_html($matches[1]), 3, -5), FALSE);
                $title[] = $tmp;
                $buff = '';
            } else {
                $buff .= "{$l}\n";
            }
        }
        if (count($title) > 0) {
            $box[] = $buff;
        }
    }
    // はじめての定義の場合、javascriptを出力
    if ($s_tab_cnt == 0) {
        $head = '
<script type="text/javascript">
<!--
$(document).ready(function(){

  	$("div.max").each(function(){
		var maxh = 0;
		$(this).find("div").each(function(){
			if ($(this).height() > maxh) {
				maxh = $(this).height();
			}
		});
		$(this).find("div").each(function(){
			$(this).height(maxh);
		});
	});

	$("div.tabpanel > div.tabbox").hide();
	if (window.location.hash.length == 0) {
		// default指定があるため
	}
	else {
		var thistab = window.location.hash.split("-");
		$("ul.tablist li").children("a").each(function(){
			var tmptab = $(this).attr("href").split("-");
			if (thistab[0] == tmptab[0]) {
				$(this).removeClass("selected");
			}
		});
		$(window.location.hash).show();
		$("a[href="+window.location.hash+"]").addClass("selected");
	}

	$("ul.tablist").each(function(){
		var tabDefault = $(this).find("a.selected").attr("href").split("#");
		$("#"+tabDefault[tabDefault.length-1]).show();
	});
	$("ul.tablist > li > a").click(function() {
		if ($(this).is(".selected")) {
			return false;
		}
		var objtab = $(this);
  		splitID = $(this).attr("href").split("#");
  		targetID = "#"+splitID[splitID.length-1];
  		var prevh = $(this).closest("div.tabpanel").find("div:visible").height();
  		$(this).closest("div.tabpanel").find("div.tabbox:visible").animate({height:$(targetID).height()},"fast","swing",function(){
  			$(this).hide();
  			objtab.closest("ul.tablist").find("li").children("a").removeClass();
			objtab.addClass("selected");
			$(targetID + ", "+ targetID + " *").show();
			$(this).height(prevh);
		});

		return false;
	});
});
//-->
</script>
<style type="text/css">
ul.tablist{
margin: 0 !important;
padding: 1px 0;
width:100%;
}

ul.tablist li {
float:left;
list-style-image:none;
list-style-position:outside;
list-style-type:none;
margin: 0 0 -1px;
padding: 0;
}

ul.tablist a {
outline:none;
display:block;
margin:0 1px 0 0;
padding:3px 10px;
position:relative;
z-index:1;
line-height:normal;
background:#fff url(image/tabbox_tab.png) repeat-x scroll 0 0;
font-size:0.9em;
border-top: 1px solid #ccc;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
}

div.tabpanel div.tabbox {
display:block;
clear:left;
font-weight:normal;
line-height:normal;
padding:10px 10px 8px;
margin:0 0;
position:relative;
z-index:1;
}
</style>
';
    }
    $s_tab_cnt++;
    $dclass = "tabconf{$s_tab_confnum}";
    if (isset($options['conf']) || $s_tab_cnt == 1) {
        $head .= '
<style type="text/css">
div.' . $dclass . ' ul.tablist a {
' . $options['tab'] . '
}

div.' . $dclass . ' ul.tablist a:hover {
' . $options['hover'] . '
}

div.' . $dclass . ' ul.tablist a.selected {
cursor:default;
text-decoration:none;
z-index:5;
' . $options['selected'] . '
}

div.' . $dclass . ' div.tabbox {
' . $options['box'] . '
}
</style>
';
    }
    if (!isset($options['conf'])) {
        $ret .= '<div class="tabpanel ' . $dclass . ' ' . $options['height'] . '">';
        $ret .= '<ul class="tablist">';
        $tabid = 'tab' . $s_tab_cnt;
        for ($i = 0; $i < count($title); $i++) {
            $tabcnt = $i + 1;
            $selclass = $options['default'] == $tabcnt ? ' class="selected"' : '';
            $ret .= '<li><a ' . $selclass . ' href="#' . $tabid . '-' . $tabcnt . '">' . $title[$i] . '</a></li>';
        }
        $ret .= '</ul>';
        for ($i = 0; $i < count($box); $i++) {
            $tabcnt = $i + 1;
            $ret .= '<div id="' . $tabid . '-' . $tabcnt . '" class="tabbox">' . convert_html($box[$i]) . '</div>';
        }
        $ret .= '</div>';
    }
    $qt->appendv_once('plugin_tabbox' . $s_tab_confnum, 'beforescript', $head);
    return $ret;
}
コード例 #19
0
ファイル: toc.inc.php プロジェクト: logue/pukiwiki_adv
function toc_convert_index($idx, $lvl)
{
    global $plugin_num_proc;
    global $fixed_heading_edited;
    global $fixed_heading_anchor;
    static $num = 0;
    // 不要な行のカウント
    $off = 0;
    foreach ($idx as $id => $data) {
        if ($data['sw']) {
            break;
        }
        $off++;
    }
    // 全行を変換
    $lines = array();
    foreach ($idx as $id => $data) {
        $lines[] = $data['dat'];
    }
    $plugin_num_proc = 'toc' . $num++;
    $bkup_fixed_heading_edited = $fixed_heading_edited;
    $fixed_heading_edited = 0;
    $html = convert_html($lines);
    $html = ereg_replace("\r|\n", '', $html);
    // \r \n の除去
    $fixed_heading_edited = $bkup_fixed_heading_edited;
    $rc = $matches = array();
    $i = 0;
    while (preg_match("'<h(.?)(.*?)>(.*?)</h.?>'si", $html, $matches)) {
        if (!empty($matches[2])) {
            preg_match("'^id=\"(.*?)\"'si", trim($matches[2]), $mat);
            $matches[2] = $mat[1];
        }
        if ($off > $i) {
            $i++;
            $html = str_replace($matches[0], '', $html);
            // 該当行の削除
            $matches = array();
            continue;
        }
        $dat_lvl = $matches[1] - 1;
        if (!toc_from_to_check($lvl, $dat_lvl)) {
            continue;
        }
        if (empty($matches[2])) {
            $rc[$i]['tag'] = '';
        } else {
            $rc[$i]['tag'] = '#';
            // convert_html すると、h2_content_X_1 の X の部分がカウントアップされてしまうので対処する
            if ($fixed_heading_anchor) {
                $rc[$i]['tag'] .= $matches[2];
            } else {
                $matches2 = array();
                // h2_content_1_1
                if (preg_match("'h(.+)_content_(.+)_(.+)'si", $matches[2], $matches2)) {
                    $rc[$i]['tag'] .= 'h' . $matches2[1] . '_content_' . --$matches2[2] . '_' . $matches2[3];
                } else {
                    $rc[$i]['tag'] .= $matches[2];
                }
            }
        }
        $rc[$i]['dat'] = strip_htmltag($matches[3]);
        $rc[$i]['lvl'] = $dat_lvl;
        $i++;
        $html = str_replace($matches[0], '', $html);
        // 該当行の削除
        $matches = array();
    }
    return $rc;
}
コード例 #20
0
 function makelink_metalines()
 {
     $metalines = array();
     foreach ($this->metalines as $metaline) {
         $anchor = $metaline['anchor'];
         $headline = $metaline['headline'];
         $headline = strip_htmltag(make_link($headline));
         // convert inline plugin
         $metaline['display'] = $this->make_pagelink($this->options['page'][1], $headline, $anchor);
         $metalines[] = $metaline;
     }
     $this->metalines = $metalines;
 }
コード例 #21
0
 /**
  * Get string used in html link
  *
  * @access public
  * @static
  * @param string $page pagename
  * @param string $option option
  *  - name|page|pagename|absolute: pagename (absolute path)
  *  - base|basename      : page basename
  *  - title              : TITLE: of page
  *  - headline|firsthead : The first headline of a page
  *  - relative|relname   : relative pagename from currdir
  * @param string $currdir current dir name($currdir is required for relative)
  * @param boolean $usecache use cache of Toc or not (used for title and headline)
  * @return string
  * @uses sonots::get_basename
  * @uses title
  * @uses firsthead
  * @uses relname
  */
 function linkstr($page, $option = 'relative', $currdir = '', $usecache = true)
 {
     switch ($option) {
         case 'name':
         case 'page':
         case 'pagename':
         case 'absolute':
         default:
             $linkstr = htmlspecialchars($page);
             break;
         case 'base':
         case 'basename':
             $linkstr = htmlspecialchars(sonots::get_basename($page));
             break;
         case 'title':
             $title = PluginSonotsMetapage::title($page, $usecache);
             if (is_null($title)) {
                 $linkstr = htmlspecialchars($page);
             } else {
                 $linkstr = strip_htmltag(make_link($title));
             }
             break;
         case 'firsthead':
         case 'headline':
             $firsthead = PluginSonotsMetapage::firsthead($page, $usecache);
             if (is_null($firsthead)) {
                 $linkstr = htmlspecialchars($page);
             } else {
                 $linkstr = strip_htmltag(make_link($firsthead));
             }
             break;
         case 'relname':
         case 'relative':
             $linkstr = htmlspecialchars(PluginSonotsMetapage::relname($page, $currdir));
             break;
     }
     return $linkstr;
 }
コード例 #22
0
ファイル: html.php プロジェクト: severnaya99/Sg-2010
function make_heading(&$str,$strip=TRUE)
{
	global $NotePattern;
	
	// 見出しの固有ID部を削除
	$id = '';
	if (preg_match('/^(\*{0,3})(.*?)\[#([A-Za-z][\w-]+)\](.*?)$/m',$str,$matches))
	{
		$str = $matches[2].$matches[4];
		$id = $matches[3];
	}
	else
	{
		$str = preg_replace('/^\*{0,3}/','',$str);
	}
	if ($strip)
	{
		$str = strip_htmltag(make_link(preg_replace($NotePattern,'',$str)));
	} 
	
	return $id; 
}
コード例 #23
0
function plugin_mixirss_action()
{
    global $vars, $get, $post, $rss_max, $rss_description, $page_title, $whatsnew, $trackback;
    global $modifier;
    global $exclude_plugin;
    $version = isset($vars['ver']) ? $vars['ver'] : '';
    switch ($version) {
        case '':
            $version = '1.0';
            break;
            // mixi Default
        // mixi Default
        case '1':
            $version = '1.0';
            break;
        case '2':
            $version = '2.0';
            break;
        case '0.91':
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '1.0':
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '2.0':
            break;
        default:
            die('Invalid RSS version!!');
    }
    $recent = CACHE_DIR . 'recent.dat';
    if (!file_exists($recent)) {
        die('recent.dat is not found');
    }
    $time_recent = filemtime($recent);
    $rsscache = CACHE_DIR . 'rsscache' . $version . '.dat';
    if (file_exists($rsscache)) {
        $time_rsscache = filemtime($rsscache);
    } else {
        $time_rsscache = 0;
    }
    // if caching rss file, return cache.
    if ($time_recent <= $time_rsscache) {
        pkwk_common_headers();
        header('Content-type: application/xml');
        print '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n";
        print implode('', file($rsscache));
        exit;
    }
    // Official Main routine ...
    $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING);
    $rss_description_utf8 = mb_convert_encoding(htmlspecialchars($rss_description), 'UTF-8', SOURCE_ENCODING);
    // Disable plugin
    $exclude_plugin[] = 'include';
    $self = get_script_absuri();
    change_uri('', 1);
    // Force absoluteURI.
    // Creating <item>
    $items = $rdf_li = '';
    $source = file($recent);
    foreach (array_splice($source, 0, $rss_max) as $line) {
        list($time, $page) = explode("\t", rtrim($line));
        $r_page = rawurlencode($page);
        $url = get_page_uri($page);
        $title = mb_convert_encoding($page, 'UTF-8', SOURCE_ENCODING);
        switch ($version) {
            case '0.91':
                /* FALLTHROUGH */
            /* FALLTHROUGH */
            case '2.0':
                $date = get_date('D, d M Y H:i:s T', $time);
                $date = $version == '0.91' ? ' <description>' . $date . '</description>' : ' <pubDate>' . $date . '</pubDate>';
                $items .= <<<EOD
<item>
 <title>{$title}</title>
 <link>{$url}</link>
{$date}
</item>

EOD;
                break;
            case '1.0':
                // Add <item> into <items>
                //			$rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                $date = substr_replace(get_date('Y-m-d\\TH:i:sO', $time), ':', -2, 0);
                $trackback_ping = '';
                if ($trackback) {
                    $tb_id = md5($r_page);
                    $trackback_ping = ' <trackback:ping rdf:resource="' . $self . '?tb_id=' . $tb_id . '"/>';
                }
                if (plugin_mixirss_isValidDate(substr($page, -10)) && check_readable($page, false, false)) {
                    // for Calendar/MiniCalendar
                    $get['page'] = $post['page'] = $vars['page'] = $page;
                    $source = get_source($page);
                    $rdf_hx = '';
                    $rdf_lx = '';
                    $itemhx = '';
                    $itemlx = '';
                    while (!empty($source)) {
                        $line = array_shift($source);
                        if (preg_match('/^(\\*{1,3})(.*)\\[#([A-Za-z][\\w-]+)\\](.*)$/m', $line, $matches)) {
                            $anchortitle = strip_htmltag(convert_html($matches[2]));
                            $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle);
                            $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>';
                            $sharp = '#';
                            $rdf_hx .= '    <rdf:li rdf:resource="' . $url . $sharp . $matches[3] . '" />' . "\n";
                            $itemhx .= <<<EOD
<item rdf:about="{$url}{$sharp}{$matches[3]}">
 <title>{$anchortitle}</title>
 <link>{$url}{$sharp}{$matches[3]}</link>
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}{$sharp}{$matches[3]}</dc:identifier>
{$trackback_ping}
</item>

EOD;
                        } else {
                            if (preg_match('/^(\\-{1,3})(.*)$/m', $line, $matches)) {
                                $anchortitle = strip_htmltag(convert_html($matches[2]));
                                $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle);
                                $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>';
                                $sharp = '#';
                                $rdf_lx .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                                $itemlx .= <<<EOD
<item rdf:about="{$url}">
 <title>{$anchortitle}</title>
 <link>{$url}</link>
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
{$trackback_ping}
</item>

EOD;
                            }
                        }
                    }
                    if ($itemhx != '') {
                        $rdf_li .= $rdf_hx;
                        $items .= $itemhx;
                    } else {
                        if ($itemlx != '') {
                            $rdf_li .= $rdf_lx;
                            $items .= $itemlx;
                        } else {
                            // default
                            $rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                            $items .= <<<EOD
<item rdf:about="{$url}">
 <title>{$title}</title>
 <link>{$url}</link>
{$description}
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
{$trackback_ping}
</item>

EOD;
                        }
                    }
                    // upk 2006-03-22
                    // } else if (check_readable($page,false,false) && !ereg(MIXIRSS_IGNORE_REGEX, $page)) {
                } else {
                    if (check_readable($page, false, false) && !is_ignore_page($page)) {
                        $get['page'] = $post['page'] = $vars['page'] = $page;
                        //miko added
                        $description = strip_htmltag(convert_html(get_source($page)));
                        $description = mb_strimwidth(preg_replace("/[\r\n]/", ' ', $description), 0, MIXIRSS_DESCRIPTION_LENGTH, '...');
                        $description = ' <description><![CDATA[' . mb_convert_encoding($description, 'UTF-8', SOURCE_ENCODING) . ']]></description>';
                        //miko added
                        $rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                        global $newtitle, $newbase;
                        if (isset($newbase) && $newbase != '') {
                            $anchortitle = $newtitle . ' (' . $title . ')';
                            $newtitle = $newbase = '';
                        } else {
                            $anchortitle = $title;
                        }
                        $items .= <<<EOD
<item rdf:about="{$url}">
 <title>{$anchortitle}</title>
 <link>{$url}</link>
{$description}
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
{$trackback_ping}
</item>

EOD;
                    }
                }
                break;
        }
    }
    // Feeding start
    pkwk_common_headers();
    header('Content-type: application/xml');
    print '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n";
    $url_whatsnew = get_page_uri($whatsnew);
    $html = '';
    switch ($version) {
        case '0.91':
            $html .= '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' . ' "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n";
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '2.0':
            $html .= <<<EOD
<rss version="{$version}">
 <channel>
  <title><![CDATA[{$page_title_utf8}]]></title>
  <link>{$url_whatsnew}</link>
  <description><![CDATA[{$rss_description_utf8}]]></description>
  <language>ja</language>

{$items}
 </channel>
</rss>
EOD;
            break;
        case '1.0':
            $xmlns_trackback = $trackback ? '  xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"' : '';
            $html .= <<<EOD
<rdf:RDF
  xmlns:dc="http://purl.org/dc/elements/1.1/"
{$xmlns_trackback}
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xml:lang="ja">
 <channel rdf:about="{$url_whatsnew}">
  <title><![CDATA[{$page_title_utf8}]]></title>
  <link>{$url_whatsnew}</link>
  <description><![CDATA[{$rss_description_utf8}]]></description>
  <items>
   <rdf:Seq>
{$rdf_li}
   </rdf:Seq>
  </items>
 </channel>

{$items}
</rdf:RDF>
EOD;
            break;
    }
    print $html;
    // Write Cache-file
    $fp = fopen($rsscache, 'w');
    flock($fp, LOCK_EX);
    rewind($fp);
    fputs($fp, $html);
    flock($fp, LOCK_UN);
    fclose($fp);
    log_write('cmd', 'mixirss');
    exit;
}
コード例 #24
0
function plugin_mixirecent_convert()
{
    global $vars, $date_format;
    // $_mixirecent_plugin_frame;
    static $done;
    $_mixirecent_plugin_frame_s = _('recent(%d)');
    $_mixirecent_plugin_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_mixirecent_plugin_frame_s);
    $mixirecent_lines = PLUGIN_MIXIRECENT_DEFAULT_LINES;
    if (func_num_args()) {
        $args = func_get_args();
        if (!is_numeric($args[0]) || isset($args[1])) {
            return PLUGIN_MIXIRECENT_USAGE . '<br />';
        } else {
            $mixirecent_lines = $args[0];
        }
    }
    // Show only the first one
    if (isset($done)) {
        return '<!-- #mixirecent(): You already view changes -->';
    }
    // Get latest N changes
    if (file_exists(PLUGIN_MIXIRECENT_CACHE)) {
        $source = file(PLUGIN_MIXIRECENT_CACHE);
        $lines = array_splice($source, 0, $mixirecent_lines);
    } else {
        return '#mixirecent(): Cache file of RecentChanges not found' . '<br />';
    }
    $date = $items = '';
    foreach ($lines as $line) {
        list($time, $page) = explode("\t", rtrim($line));
        $_date = get_date($date_format, $time);
        if ($date != $_date) {
            // End of the day
            if ($date != '') {
                $items .= '</ul>' . "\n";
            }
            // New day
            $date = $_date;
            $items .= '<strong>' . $date . '</strong>' . "\n" . '<ul class="mixirecent_list">' . "\n";
        }
        $s_page = htmlspecialchars($page);
        $pg_passage = get_pg_passage($page, FALSE);
        if (plugin_mixirecent_isValidDate(substr($page, -10)) && check_readable($page, false, false)) {
            // for Calendar/MiniCalendar
            $savepage = $vars['page'];
            $title = $page;
            $source = get_source($page);
            $itemhx = '';
            $itemlx = '';
            while (!empty($source)) {
                $line = array_shift($source);
                if (preg_match('/^(\\*{1,3})(.*)\\[#([A-Za-z][\\w-]+)\\](.*)$/m', $line, $matches)) {
                    $anchortitle = strip_htmltag(convert_html($matches[2]));
                    $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle);
                    $anchortitle = PLUGIN_MIXIRECENT_NOTITLE ? $anchortitle : $anchortitle . '(' . $title . ')';
                    $sharp = '#';
                    $itemhx .= "<li><a href=\"" . get_page_uri($page) . "{$sharp}{$matches[3]}\" title=\"{$s_page} {$pg_passage}\">{$anchortitle}</a></li>\n";
                }
            }
            if ($itemhx != '') {
                $items .= $itemhx;
            } else {
                if ($page == $vars['page']) {
                    // No need to link to the page now you read, notifies where you just read
                    $items .= ' <li>' . $s_page . '</li>' . "\n";
                } else {
                    $items .= ' <li><a href="' . get_page_uri($page) . '" title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '</a></li>' . "\n";
                }
            }
            $vars['page'] = $savepage;
        } else {
            if ($page == $vars['page']) {
                // No need to link to the page now you read, notifies where you just read
                $items .= ' <li>' . $s_page . '</li>' . "\n";
            } else {
                $items .= ' <li><a href="' . get_page_uri($page) . '" title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '</a></li>' . "\n";
            }
        }
    }
    // End of the day
    if ($date != '') {
        $items .= '</ul>' . "\n";
    }
    $done = TRUE;
    return sprintf($_mixirecent_plugin_frame, count($lines), $items);
}
コード例 #25
0
function tb_send($page, $links)
{
    global $trackback, $page_title;
    if (!$trackback) {
        return;
    }
    // No link, END
    if (!is_array($links) || empty($links)) {
        return;
    }
    $script = get_script_uri();
    // PROHIBITION OF INVALID TRANSMISSION
    $url = parse_url($script);
    $host = empty($url['host']) ? $script : $url['host'];
    if (is_ipaddr($host)) {
        if (is_localIP($host)) {
            return;
        }
    } else {
        if (is_ReservedTLD($host)) {
            return;
        }
    }
    if (is_ignore_page($page)) {
        return;
    }
    // Disable 'max execution time' (php.ini: max_execution_time)
    if (ini_get('safe_mode') == '0') {
        set_time_limit(0);
    }
    $r_page = rawurlencode($page);
    $excerpt = strip_htmltag(convert_html(get_source($page)));
    // Sender's information
    $putdata = array('title' => $page, 'url' => $script . '?' . $r_page, 'excerpt' => mb_strimwidth(preg_replace("/[\r\n]/", ' ', $excerpt), 0, 255, '...'), 'blog_name' => $page_title . ' (' . PLUGIN_TRACKBACK_VERSION . ')', 'charset' => SOURCE_ENCODING);
    foreach ($links as $link) {
        if (path_check($script, $link)) {
            continue;
        }
        // Same Site
        $tb_id = tb_get_url($link);
        // Get Trackback ID from the URL
        if (empty($tb_id)) {
            continue;
        }
        // Trackback is not supported
        $result = http_request($tb_id, 'POST', '', $putdata, 2, CONTENT_CHARSET);
        // FIXME: Create warning notification space at pukiwiki.skin!
    }
}
コード例 #26
0
function plugin_edit_inline()
{
    static $usage = '&edit(pagename,anchor);';
    global $script, $vars, $fixed_heading_edited;
    global $_symbol_paraedit, $_symbol_paraguiedit;
    if (!$fixed_heading_edited || is_freeze($vars['page']) || auth::check_role('readonly')) {
        return '';
    }
    // Arguments
    $args = func_get_args();
    // {label}. Strip anchor tags only
    $s_label = strip_htmltag(array_pop($args), FALSE);
    if ($s_label == '') {
        $s_label = $_symbol_paraedit;
        $s_label_edit =& $_symbol_paraedit;
        $s_label_guiedit =& $_symbol_paraguiedit;
    }
    list($page, $id) = array_pad($args, 2, '');
    if (!is_page($page)) {
        $page = $vars['page'];
    }
    if ($id != '') {
        $id = '&amp;id=' . rawurlencode($id);
    }
    $r_page = rawurlencode($page);
    //$use_edit_plugin = ($fixed_heading_edited == 2) ? 'guiedit' : 'edit';
    // return '<a class="anchor_super" href="' . $script . '?cmd='.$use_edit_plugin.'&amp;page=' . $r_page . $id . '">' . $s_label . '</a>';
    $tag_edit = '<a class="anchor_super" href="' . $script . '?cmd=edit&amp;page=' . $r_page . $id . '">' . $s_label_edit . '</a>';
    $tag_guiedit = '<a class="anchor_super" href="' . $script . '?cmd=guiedit&amp;page=' . $r_page . $id . '">' . $s_label_guiedit . '</a>';
    switch ($fixed_heading_edited) {
        case 2:
            return $tag_guiedit;
        case 3:
            return $tag_edit . $tag_guiedit;
        default:
            return $tag_edit;
    }
}
コード例 #27
0
 function get_titlestr($inclpage, $option = null, $current = null)
 {
     switch ($option) {
         case 'off':
             $titlestr = '';
             break;
         case 'name':
             $titlestr = htmlspecialchars($inclpage);
             break;
         case 'basename':
             $titlestr = htmlspecialchars(basename($inclpage));
             break;
         case 'relname':
             if (!isset($current)) {
                 $current = $GLOBALS['vars']['page'];
             }
             if (($i = strpos($inclpage, $current . '/')) === 0) {
                 $titlestr = htmlspecialchars(substr($inclpage, strlen($current) + 1));
             } else {
                 $titlestr = htmlspecialchars($inclpage);
             }
             break;
         case 'on':
         case 'title':
         default:
             if (exist_plugin('contentsx')) {
                 $contentsx = new PluginContentsx();
                 if (method_exists($contentsx, 'get_title')) {
                     $titlestr = $contentsx->get_title($inclpage);
                     $titlestr = strip_htmltag(make_link($titlestr));
                 }
             }
             if ($titlestr == '') {
                 $titlestr = htmlspecialchars($inclpage);
             }
             break;
     }
     return $titlestr;
 }
コード例 #28
0
 function linkstr_metapages()
 {
     switch ($this->options['linkstr'][1]) {
         case 'absolute':
             foreach ($this->metapages as $i => $metapage) {
                 $this->metapages[$i]['linkstr'] = htmlspecialchars($metapage['page']);
             }
             break;
         case 'basename':
             foreach ($this->metapages as $i => $metapage) {
                 $this->metapages[$i]['linkstr'] = htmlspecialchars($this->my_basename($metapage['page']));
             }
             break;
         case 'title':
             $contentsx = new PluginContentsx();
             foreach ($this->metapages as $i => $metapage) {
                 $title = $contentsx->get_title($metapage['page']);
                 $title = strip_htmltag(make_link($title));
                 $this->metapages[$i]['linkstr'] = $title;
             }
             break;
         case 'headline':
             $contentsx = new PluginContentsx();
             foreach ($this->metapages as $i => $metapage) {
                 $metalines = $contentsx->get_metalines($metapage['page']);
                 $title = $metalines[0]['headline'];
                 $title = strip_htmltag(make_link($title));
                 $this->metapages[$i]['linkstr'] = $title;
             }
             break;
     }
     // default: relative
     if ($this->options['hierarchy'][1] === true) {
         foreach ($this->metapages as $i => $metapage) {
             if (!isset($metapage['linkstr']) || $metapage['linkstr'] === '') {
                 $this->metapages[$i]['linkstr'] = htmlspecialchars($this->my_basename($metapage['page']));
             }
         }
     } else {
         foreach ($this->metapages as $i => $metapage) {
             if (!isset($metapage['linkstr']) || $metapage['linkstr'] === '') {
                 $this->metapages[$i]['linkstr'] = htmlspecialchars($metapage['relative']);
             }
         }
     }
 }
コード例 #29
0
 function parse(&$lines)
 {
     $this->last =& $this;
     $matches = array();
     while (!empty($lines)) {
         $line = array_shift($lines);
         // Escape comments
         if (substr($line, 0, 2) == '//') {
             continue;
         }
         // Extend TITLE by miko
         if (preg_match('/^(TITLE):(.*)$/', $line, $matches)) {
             global $newtitle, $newbase;
             if ($newbase == '') {
                 // $newbase = trim($matches[2]);
                 $newbase = convert_html($matches[2]);
                 $newbase = strip_htmltag($newbase);
                 //$newbase = trim($newbase);
                 $newtitle = trim($newbase);
                 // For BugTrack/132.
                 // $newtitle = htmlspecialchars($newbase);
                 //$newtitle = str_replace('&amp;','&',htmlspecialchars($newbase));
             }
             continue;
         }
         if (preg_match('/^(LEFT|CENTER|RIGHT):(.*)$/', $line, $matches)) {
             // <div style="text-align:...">
             $this->last =& $this->last->add(new Align(strtolower($matches[1])));
             if ($matches[2] == '') {
                 continue;
             }
             $line = $matches[2];
         }
         $line = rtrim($line, "\r\n");
         // Empty
         if ($line == '') {
             $this->last =& $this;
             continue;
         }
         // Horizontal Rule
         if (substr($line, 0, 4) == '----') {
             $this->insert(new HRule($this, $line));
             continue;
         }
         // Multiline-enabled block plugin
         if (!PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK && preg_match('/^#[^{]+(\\{\\{+)\\s*$/', $line, $matches)) {
             $len = strlen($matches[1]);
             $line .= "\r";
             // Delimiter
             while (!empty($lines)) {
                 $next_line = rtrim(array_shift($lines), "\r\n");
                 if (preg_match('/\\}{' . $len . '}/', $next_line)) {
                     $line .= $next_line;
                     break;
                 } else {
                     $line .= $next_line .= "\r";
                     // Delimiter
                 }
             }
         }
         // The first character
         $head = $line[0];
         // Heading
         if ($head == '*') {
             $this->insert(new Heading($this, $line));
             continue;
         }
         // Pre
         if ($head == ' ' || $head == "\t") {
             $this->last =& $this->last->add(new Pre($this, $line));
             continue;
         }
         // CPre
         if (substr($line, 0, 2) == '# ' or substr($line, 0, 2) == "#\t") {
             $this->last =& $this->last->add(new CPre($this, $line));
             continue;
         }
         // Line Break
         if (substr($line, -1) == '~') {
             $line = substr($line, 0, -1) . "\r";
         }
         // Other Character
         if (isset($this->classes[$head])) {
             $classname = $this->classes[$head];
             $this->last =& $this->last->add(new $classname($this, $line));
             continue;
         }
         // Other Character
         if (isset($this->factories[$head])) {
             $factoryname = 'Factory_' . $this->factories[$head];
             $this->last =& $this->last->add($factoryname($this, $line));
             continue;
         }
         // Default
         $this->last =& $this->last->add(Factory_Inline($line));
     }
 }
コード例 #30
0
 /**
  * Display Table of Contents
  *
  * @access public
  * @static
  * @param array &$headlines
  * @param string $cssclass css class
  * @param string $optlink link option
  * @param boolean $optinclude show toc of including pages too or not
  * @return string list html
  */
 function display_toc(&$headlines, $cssclass = '', $optlink = 'anchor')
 {
     $links = $levels = array();
     foreach ($headlines as $i => $headline) {
         $linkstr = strip_htmltag(make_link($headline->string));
         switch ($optlink) {
             case 'page':
                 $link = sonots::make_pagelink_nopg($headline->page, $linkstr, '#' . $headline->anchor);
                 break;
             case 'off':
                 $link = $linkstr;
                 break;
             case 'anchor':
             default:
                 $link = sonots::make_pagelink_nopg('', $linkstr, '#' . $headline->anchor);
                 break;
         }
         $links[$i] = $link;
         $levels[$i] = $headline->depth;
     }
     return sonots::display_list($links, $levels, $cssclass);
 }