Example #1
0
function sbm_make($cmd, &$info)
{
    global $vars, $_sbm_msg;
    $title = rawurlencode($vars['page']);
    $link = get_page_absuri($vars['page']);
    $rlink = rawurlencode($link);
    $rtlink = rawurlencode(get_script_absuri() . '?') . $title;
    // url
    switch ($cmd) {
        case 'twitter':
            if (exist_plugin_inline('bitly')) {
                $val = bitly_convert('shorten', $link);
                $rlink = !$val['rc'] ? 'N/A' : $val['msg'];
                $url = str_replace('$link', $rlink, $info['url']);
            } else {
                $url = $info['url'];
            }
            break;
        default:
            $url = $info['url'];
    }
    $width = empty($info['width']) ? '16' : $info['width'];
    $height = empty($info['height']) ? '16' : $info['height'];
    $msg_alt = isset($info['msg']) ? $info['msg'] : 'msg_alt';
    $alt = sprintf($_sbm_msg[$msg_alt], $info['name']);
    // img
    switch ($cmd) {
        case 'yahoo_jp_entry':
            $img = str_replace('$rlink', $link, $info['img']);
            break;
        case 'livedoor_entry':
            $img = str_replace('$link', $link, $info['img']);
            $alt = '';
            break;
        default:
            $img = $info['img'];
    }
    // Conversion processing
    $url = str_replace('$title', $title, $url);
    $url = str_replace('$link', $link, $url);
    $url = str_replace('$rlink', $rlink, $url);
    $url = str_replace('$rtlink', $rtlink, $url);
    $retval = <<<EOD
<a href="{$url}">
<img src="{$img}" width="{$width}" height="{$height}" style="border: none;" alt="{$alt}" title="{$alt}" />
</a>
EOD;
    switch ($cmd) {
        case 'hatena_entry':
            $retval .= '<img src="http://b.hatena.ne.jp/entry/image/' . $link . '" alt="counter"/>';
    }
    return $retval;
}
function plugin_whiteflow_topicpath_inline()
{
    global $vars, $defaultpage, $title, $disp_mode;
    // disp_mode ?
    if ($title == $defaultpage || $vars["page"] == $defaultpage) {
        $val = '<a href="' . get_script_uri() . '">トップページ</a>';
        return $val . $disp_mode;
    }
    if (!exist_plugin_inline('topicpath')) {
        return;
    }
    $args = func_get_args();
    $val = call_user_func_array('plugin_topicpath_inline', $args);
    return $val . $disp_mode;
}
function plugin_gcounter_inline()
{
    if (!exist_plugin_inline('counter')) {
        return '<span>gcounter(): counter plugin does not exist.</span>';
    }
    if (plugin_gcounter_init_gcounter() === FALSE) {
        return '<span>gcounter(): failed to create gcounter log file.</span>';
    }
    global $vars;
    $tmp = $vars['page'];
    $vars['page'] = PLUGIN_GCOUNTER_PAGE;
    $args = func_get_args();
    $body = array_pop($args);
    $body = do_plugin_inline('counter', csv_implode(',', $args), $body);
    $vars['page'] = $tmp;
    return $body;
}
Example #4
0
 function toString()
 {
     $body = $this->body == '' ? '' : make_link($this->body);
     $str = FALSE;
     // Try to call the plugin
     if (exist_plugin_inline($this->name)) {
         $str = do_plugin_inline($this->name, $this->param, $body);
     }
     if ($str !== FALSE) {
         return $str;
         // Succeed
     } else {
         // No such plugin, or Failed
         $body = ($body == '' ? '' : '{' . $body . '}') . ';';
         return make_line_rules(htmlspecialchars('&' . $this->plain) . $body);
     }
 }
<div id="related">
 Link: <?php 
        echo $related;
        ?>
</div>
<?php 
    }
    ?>


<div id="footer">
<table id="footertable" border="0" cellspacing="0" cellpadding="0">
<tr>
 <td id="footerltable">
  <?php 
    if (exist_plugin_inline('qrcode')) {
        ?>
  <?php 
        $a_script = $script;
        $a_script = str_replace("\\", "\\\\", $a_script);
        $a_script = str_replace(':', '\\:', $a_script);
        $a_script = str_replace(';', '\\;', $a_script);
        $a_script = str_replace(',', '\\,', $a_script);
        $a_page = str_replace('%', '%25', $r_page);
        echo plugin_qrcode_inline(1, "{$script}?{$a_page}");
        ?>
  <?php 
    }
    ?>
 </td>
 <td id="footerctable"><div id="sigunature">
?>

<?php 
if ($wikinote->is_effect()) {
    echo '<div id="wrap_body">';
}
?>
<!-- BEGIN id:wrap_body -->
<div id="body"><!-- BEGIN id:body -->
<h1 class="title"><?php 
echo $heading_title;
?>
</h1>
<div id="subtitle">
<?php 
if ($is_read && exist_plugin_inline('topicpath')) {
    echo '<div class="topicpath">' . do_plugin_inline('topicpath') . '</div>';
}
?>
</div>
<?php 
echo $body;
?>
</div><!-- END id:body -->

<div id="summary"><!-- BEGIN id:summary -->
<?php 
if ($notes != '') {
    ?>
<!-- BEGIN id:note -->
<div id="note">
Example #7
0
            foreach ($_ignore as $key) {
                unset($_vars[$key]);
            }
        } else {
            $_vars =& $vars;
        }
        pkwk_spamfilter($method . ' to #' . $_plugin, $_page, $_vars, $_method, $exitmode);
    }
}
// If page output, enable session.
// NOTE: if action plugin(command) use session, call pkwk_session_start()
//       in plugin action-API function.
pkwk_session_start();
// auth remoteip
if (isset($auth_api['remoteip']['use']) && $auth_api['remoteip']['use']) {
    if (exist_plugin_inline('remoteip')) {
        do_plugin_inline('remoteip');
    }
}
$is_protect = auth::is_protect();
// Plugin execution
if ($plugin != '') {
    if ($is_protect) {
        $plugin_arg = '';
        if (auth::is_protect_plugin_action($plugin)) {
            if (exist_plugin_action($plugin)) {
                do_plugin_action($plugin);
            }
            // Location で飛ばないプラグインの場合
            $plugin_arg = $plugin;
        }
Example #8
0
    function export_d($page, $table_num, $file)
    {
        $download = T_('download');
        $back = T_('back');
        $ref = exist_plugin_inline('ref') ? do_plugin_inline('ref', $page . '/' . $file) : T_('ref plugin is not found');
        $body = <<<EOD
<h3>{$page} table number {$table_num}</h3>
<fieldset>
<legend>{$download}</legend>
{$ref}
<form enctype="multipart/form-data" action="{$this->script_uri}" method="post">
\t<input type="hidden" name="cmd"       value="table_edit2" />
\t<input type="hidden" name="refer"     value="{$page}" />
\t<input type="hidden" name="table_num" value="{$table_num}" />
\t<input type="hidden" name="file_name" value="{$file}" />
\t<button type="submit" class="btn btn-primary" name="csv_back"><span class="fa fa-download"></span>{$down}</button>
</form>
</fieldset>
EOD;
        return array('msg' => T_('export'), 'body' => $body);
    }
function plugin_minicalendar_viewer_convert()
{
    global $vars, $get, $post, $script, $weeklabels;
    global $_err_calendar_viewer_param, $_err_calendar_viewer_param2;
    global $_msg_calendar_viewer_right, $_msg_calendar_viewer_left;
    global $_msg_calendar_viewer_restrict;
    global $_symbol_paraedit, $trackback;
    static $viewed = array();
    if (func_num_args() < 2) {
        return PLUGIN_MINICALENDAR_VIEWER_USAGE . '<br />' . "\n";
    }
    $func_vars_array = func_get_args();
    // デフォルト値をセット
    $pagename = $func_vars_array[0];
    // 基準となるページ名
    $limit_page = 7;
    // 表示する件数制限
    $date_YM = '';
    // 一覧表示する年月
    $mode = 'past';
    // 動作モード
    $date_sep = '-';
    // 日付のセパレータ calendar2なら"-" calendarなら""
    // Check $func_args[1]
    if (preg_match("/[0-9]{4}" . $date_sep . "[0-9]{2}/", $func_vars_array[1])) {
        //指定年月の一覧表示
        $page_YM = $func_vars_array[1];
        $limit_base = 0;
        $limit_page = 31;
        //手抜き。31日分をリミットとする。
    } else {
        if (preg_match("/this/si", $func_vars_array[1])) {
            //今月の一覧表示
            $page_YM = get_date('Y' . $date_sep . 'm');
            $limit_base = 0;
            $limit_page = 31;
        } else {
            if (preg_match("/^[0-9]+\$/", $func_vars_array[1])) {
                //n日分表示
                $limit_pitch = $func_vars_array[1];
                $limit_page = $limit_pitch;
                $limit_base = 0;
                $page_YM = '';
            } else {
                if (preg_match("/([0-9]+)\\*([0-9]+)/", $func_vars_array[1], $reg_array)) {
                    $limit_pitch = $reg_array[2];
                    $limit_page = $reg_array[1] + $limit_pitch;
                    $limit_base = $reg_array[1];
                    $page_YM = '';
                } else {
                    return '#calendar_viewer(): ' . $_err_calendar_viewer_param2 . '<br />' . "\n";
                }
            }
        }
    }
    // $func_args[2]: Change default delimiter
    if (isset($func_vars_array[2]) && preg_match("/^(past|pastex|view|viewex|future|futureex)\$/si", $func_vars_array[2])) {
        $mode = $func_vars_array[2];
    }
    // $func_args[3]: Change default delimiter
    if (isset($func_vars_array[3])) {
        $date_sep = $func_vars_array[3];
    }
    // Avoid Loop etc.
    if (isset($viewed[$pagename])) {
        if ($viewed[$pagename] > PLUGIN_MINICALENDAR_MAX_VIEWS) {
            $s_page = htmlspecialchars($pagename);
            return '#calendar_viewer(): You already view: ' . $s_page . '<br />';
        }
        $viewed[$pagename]++;
        // Valid
    } else {
        $viewed[$pagename] = 1;
        // Valid
    }
    // 一覧表示するページ名とファイル名のパターン ファイル名には年月を含む
    if ($pagename == '') {
        // pagename無しのyyyy-mm-ddに対応するための処理
        $pagepattern = '';
        $pagepattern_len = 0;
        $filepattern = encode($page_YM);
        $filepattern_len = strlen($filepattern);
    } else {
        $pagepattern = strip_bracket($pagename) . '/';
        $pagepattern_len = strlen($pagepattern);
        $filepattern = encode($pagepattern . $page_YM);
        $filepattern_len = strlen($filepattern);
    }
    // ページリストの取得
    $pagelist = array();
    if ($dir = @opendir(DATA_DIR)) {
        $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd');
        $page_date = '';
        while ($file = readdir($dir)) {
            if ($file == '..' || $file == '.') {
                continue;
            }
            if (substr($file, 0, $filepattern_len) != $filepattern) {
                continue;
            }
            $page = decode(trim(preg_replace("/\\.txt\$/", " ", $file)));
            $page_date = substr($page, $pagepattern_len);
            // $pageがカレンダー形式なのかチェック デフォルトでは yyyy-mm-dd
            if (plugin_minicalendar_viewer_isValidDate($page_date, $date_sep) == FALSE) {
                continue;
            }
            // mode毎に別条件ではじく
            // pastex modeでは今日を含む未来のページはNG
            // futureex modeでは今日を含む過去のページはNG
            // past modeでは未来のページはNG
            // future modeでは過去のページはNG
            if ($page_date >= $_date && $mode == 'pastex') {
                continue;
            }
            if ($page_date <= $_date && $mode == 'futureex') {
                continue;
            }
            if ($page_date > $_date && $mode == 'past') {
                continue;
            }
            if ($page_date < $_date && $mode == 'future') {
                continue;
            }
            $pagelist[] = $page;
        }
    }
    closedir($dir);
    // まずソート
    if ($mode == 'past' || $mode == 'pastex' || $mode == 'viewex') {
        rsort($pagelist);
    } else {
        sort($pagelist);
    }
    // ここからインクルード
    $tmppage = $vars['page'];
    $return_body = '';
    // $limit_pageの件数までインクルード
    $tmp = max($limit_base, 0);
    // Skip minus
    while ($tmp < $limit_page) {
        if (!isset($pagelist[$tmp])) {
            break;
        }
        $page = $pagelist[$tmp];
        $get['page'] = $post['page'] = $vars['page'] = $page;
        // 現状で閲覧許可がある場合だけ表示する
        if (check_readable($page, FALSE, FALSE)) {
            if (function_exists('convert_filter')) {
                $body = convert_html(convert_filter(get_source($page)));
            } else {
                $body = convert_html(get_source($page));
            }
        } else {
            $body = str_replace('$1', $page, $_msg_calendar_viewer_restrict);
        }
        $r_page = rawurlencode($page);
        $s_page = htmlspecialchars($page);
        if (PLUGIN_MINICALENDAR_VIEWER_DATE_FORMAT !== FALSE) {
            $time = strtotime(basepagename($page));
            // $date_sep must be assumed '-' or ''!
            if ($time == -1 || $time == FALSE) {
                $s_page = htmlspecialchars($page);
                // Failed. Why?
            } else {
                $week = $weeklabels[date('w', $time)];
                $s_page = htmlspecialchars(str_replace(array('$w'), array($week), date(PLUGIN_CALENDAR_VIEWER_DATE_FORMAT, $time)));
            }
        }
        $refpage = rawurlencode($tmppage);
        $page_title = basepagename($page);
        $s_page_title = htmlspecialchars($page_title);
        // if (PKWK_READONLY) {
        if (auth::check_role('readonly')) {
            $link = get_page_uri($page);
        } else {
            $link = get_cmd_uri('edit', $page, '', 'refpage=' . $refpage);
        }
        $link = '<a class="anchor_super" href="' . $link . '">' . $_symbol_paraedit . '</a>';
        $head = '<h3 class="minicalendar">' . $s_page_title . ' ' . $link . '</h3>' . "\n";
        $tail = '';
        if (PLUGIN_MINICALENDAR_VIEWER_HOLIDAYVIEW === TRUE) {
            $time = strtotime($page_title);
            if ($time != -1) {
                $yy = intval(date('Y', $time));
                $mm = intval(date('n', $time));
                $dd = intval(date('d', $time));
                $monthlabel = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
                $mmstr = $monthlabel[$mm];
                $h_today = public_holiday($yy, $mm, $dd);
                if ($h_today['rc'] != 0) {
                    $classname = 'date_holiday';
                } else {
                    if ($h_today['w'] == 0) {
                        $classname = 'date_holiday';
                    } else {
                        if ($h_today['w'] == 6) {
                            $classname = 'date_weekend';
                        } else {
                            $classname = 'date_weekday';
                        }
                    }
                }
                $head = '<h3 class="' . $classname . '"><span class="day">' . sprintf('%02d', $dd) . '</span> <br />' . '<b>' . $mmstr . '</b>, <b>' . $yy . '</b>' . $link . '</h3>' . "\n";
            }
        }
        if (PLUGIN_MINICALENDAR_VIEWER_COMMENT === TRUE) {
            if (is_page(':config/plugin/addline/comment') && exist_plugin_inline('addline')) {
                $comm = convert_html(array('&addline(comment,above){comment};'));
                $comm = preg_replace(array("'<p>'si", "'</p>'si"), array("", ""), $comm);
                $tail .= str_replace('>comment', '><img src="' . IMAGE_URI . 'plus/comment.png" width="15" height="15" alt="Comment" title="Comment" />Comment', $comm);
            }
        }
        if (PLUGIN_MINICALENDAR_VIEWER_TRACKBACK === TRUE) {
            if ($trackback) {
                $tb_id = tb_get_id($page);
                $tail .= '<a href="' . $script . '?plugin=tb&amp;__mode=view&amp;tb_id=' . $tb_id . '">' . '<img src="' . IMAGE_URI . 'plus/trackback.png" width="15" height="15" alt="" title="" />Trackback(' . tb_count($page) . ')' . '</a>' . "\n";
            }
        }
        if ($tail != '') {
            $tail = '<div class="trackback">' . $tail . '</div>';
        }
        $return_body .= $head . '<div class="minicalendar_viewer">' . $body . '</div>' . $tail;
        ++$tmp;
    }
    //ここで、前後のリンクを表示
    //?plugin=minicalendar_viewer&file=ページ名&date=yyyy-mm
    $enc_pagename = rawurlencode(substr($pagepattern, 0, $pagepattern_len - 1));
    if ($page_YM != '') {
        // 年月表示時
        $date_sep_len = strlen($date_sep);
        $this_year = substr($page_YM, 0, 4);
        $this_month = substr($page_YM, 4 + $date_sep_len, 2);
        // 次月
        $next_year = $this_year;
        $next_month = $this_month + 1;
        if ($next_month > 12) {
            $next_year++;
            $next_month = 1;
        }
        $next_YM = sprintf('%04d%s%02d', $next_year, $date_sep, $next_month);
        $next_YMX = sprintf('%04d%02d', $next_year, $next_month);
        // 前月
        $prev_year = $this_year;
        $prev_month = $this_month - 1;
        if ($prev_month < 1) {
            $prev_year--;
            $prev_month = 12;
        }
        $prev_YM = sprintf('%04d%s%02d', $prev_year, $date_sep, $prev_month);
        $prev_YMX = sprintf('%04d%02d', $prev_year, $prev_month);
        //		if ($mode == "past" || $mode == "pastex") {
        //			$right_YM   = $prev_YM;
        //			$right_YMX  = $prev_YMX;
        //			$right_text = $prev_YM."&gt;&gt;";
        //			$left_YM    = $next_YM;
        //			$left_YMX   = $next_YMX;
        //			$left_text  = "&lt;&lt;".$next_YM;
        //		} else {
        $left_YM = $prev_YM;
        $left_YMX = $prev_YMX;
        $left_text = '&lt;&lt;' . $prev_YM;
        $right_YM = $next_YM;
        $right_YMX = $next_YMX;
        $right_text = $next_YM . '&gt;&gt;';
        //		}
    } else {
        // n件表示時
        if ($limit_base >= count($pagelist)) {
            $right_YM = '';
        } else {
            $right_base = $limit_base + $limit_pitch;
            $right_YM = $right_base . '*' . $limit_pitch;
            $right_text = sprintf($_msg_calendar_viewer_right, $limit_pitch);
        }
        $left_base = $limit_base - $limit_pitch;
        if ($left_base >= 0) {
            $left_YM = $left_base . '*' . $limit_pitch;
            $left_text = sprintf($_msg_calendar_viewer_left, $limit_pitch);
        } else {
            $left_YM = '';
        }
        $prev_YMX = '';
        $next_YMX = '';
    }
    // ナビゲート用のリンクを末尾に追加
    $s_date_sep = htmlspecialchars($date_sep);
    if ($left_YM != '') {
        if ($left_YMX != '') {
            $left_link = '<a href="' . $script . '?plugin=minicalendar&amp;file=' . $enc_pagename . '&amp;date=' . $left_YMX . '">' . $left_text . '</a>';
        } else {
            $left_link = '<a href="' . $script . '?plugin=minicalendar_viewer&amp;file=' . $enc_pagename . '&amp;date=' . $left_YM . '&amp;date_sep=' . $s_date_sep . '&amp;mode=' . $mode . '">' . $left_text . '</a>';
        }
    } else {
        $left_link = '';
    }
    if ($right_YM != '') {
        if ($right_YMX != '') {
            $right_link = '<a href="' . $script . '?plugin=minicalendar&amp;file=' . $enc_pagename . '&amp;date=' . $right_YMX . '">' . $right_text . '</a>';
        } else {
            $right_link = '<a href="' . $script . '?plugin=minicalendar_viewer&amp;file=' . $enc_pagename . '&amp;date=' . $right_YM . '&amp;date_sep=' . $s_date_sep . '&amp;mode=' . $mode . '">' . $right_text . '</a>';
        }
    } else {
        $right_link = '';
    }
    //past modeは<<新 旧>> 他は<<旧 新>>
    $return_body .= '<div class="prevnext">';
    $return_body .= '<div class="prevnext_r">' . $right_link . '</div>';
    $return_body .= '<div class="prevnext_l">' . $left_link . '</div>';
    $return_body .= '</div><br style="display:block;clear:both" />';
    $get['page'] = $post['page'] = $vars['page'] = $tmppage;
    return $return_body;
}
 function test_exist_inline()
 {
     $this->assertTrue(exist_plugin_inline('xxx'));
 }
Example #11
0
function print_qr_code($page)
{
    if (!exist_plugin_inline('qrcode')) {
        return '';
    }
    $script = get_script_absuri();
    $r_page = rawurlencode($page);
    $a_script = $script;
    $a_script = str_replace("\\", "\\\\", $a_script);
    $a_script = str_replace(':', '\\:', $a_script);
    $a_script = str_replace(';', '\\;', $a_script);
    $a_script = str_replace(',', '\\,', $a_script);
    $a_page = str_replace('%', '%25', $r_page);
    return plugin_qrcode_inline(1, $script . '?' . $a_page);
}
Example #12
0
 function validate_options()
 {
     global $vars;
     if ($this->options['tag'][1] != '') {
         if (!exist_plugin($this->conf['plugin_tag'])) {
             $this->error .= "The option, tag, requires #{$this->conf['plugin_tag']} plugin, but it does not exist. ";
             return;
         }
         $this->options['hierarchy'][1] = false;
         // best is to turn off the default only so that 'hierarchy' can be configured by option.
     } else {
         if ($this->options['prefix'][1] == '') {
             $this->options['prefix'][1] = $vars['page'] != '' ? $vars['page'] . '/' : '';
         }
     }
     if ($this->options['prefix'][1] == '/') {
         $this->options['prefix'][1] = '';
     } elseif ($this->options['prefix'][1] != '') {
         $this->options['prefix'][1] = $this->get_fullname($this->options['prefix'][1], $vars['page']);
     }
     $this->options['prefix'][4] = $this->options['prefix'][1];
     if ($this->options['sort'][1] == 'date') {
         $this->options['hierarchy'][1] = false;
     }
     // alpha func
     if ($this->options['popular'][1] != false) {
         $this->options['sort'][1] = 'popular';
         $this->options['hierarchy'][1] = false;
         // Future Work: info_popular. hmmm
     }
     // Another Idea
     // sort=popular>today,popular>total,popular>yesterday,popular>recent
     // if (strpos($this->options['sort'][1], 'popular>') !== false) {
     //     list($this->optiions['sort'][1], $this->options['popular'][1]) = explode('>', $this->options['sort'][1]);
     //     $this->options['hierarchy'][1] = false;
     // }
     if ($this->options['contents'][1] != '') {
         if (!exist_plugin_convert($this->conf['plugin_contents'])) {
             $this->error .= "The option, contents, requires {$this->conf['plugin_contents']} plugin, but it does not exist. ";
             return;
         }
     }
     if ($this->options['include'][1] != '') {
         if (!exist_plugin_convert($this->conf['plugin_include'])) {
             $this->error .= "The option, include, requires {$this->conf['plugin_include']} plugin, but it does not exist. ";
             return;
         }
         $this->options['hierarchy'][1] = false;
         // hierarchy + include => XHTML invalid
         $this->options['date'][1] = false;
         // include does not use definitely
         $this->options['new'][1] = false;
         // include does not use definitely
         $this->options['contents'][1] = '';
         // include does not use definitely
     }
     if ($this->options['linkstr'][1] === 'title' || $this->options['linkstr'][1] === 'headline') {
         if (!exist_plugin_convert($this->conf['plugin_contents'])) {
             $this->error .= "The option, linkstr, requires {$this->conf['plugin_contents']} plugin, but it does not exist. ";
             return;
         }
     }
     // to support lower versions
     // basename -> linkstr
     if ($this->options['basename'][1] === true) {
         $this->options['linkstr'][1] = 'basename';
     }
     // new,date -> info
     foreach ($this->options['info'][2] as $key) {
         if ($this->options[$key][1]) {
             array_push($this->options['info'][1], $key);
         }
     }
     $this->options['info'][1] = array_unique($this->options['info'][1]);
     // to save time (to avoid in_array everytime)
     foreach ($this->options['info'][1] as $key) {
         $this->options[$key][1] = true;
     }
     if ($this->options['new'][1] && !exist_plugin_inline($this->conf['plugin_new'])) {
         $this->error .= "The option, new, requires {$this->conf['plugin_new']} plugin, but it does not exist. ";
         return;
     }
 }
function weblog_viewer_show_headings($page, &$params, $prefix = "", $child_count = "")
{
    global $script, $auto_template_name;
    global $_weblog_list_anchor, $_weblog_msgs;
    static $_auto_template_name = "";
    if (!$_auto_template_name) {
        $_auto_template_name = preg_quote($auto_template_name, '/');
    }
    // テンプレートページは表示しない場合
    if (preg_match("/\\/" . $_auto_template_name . "(_m)?\$/", $page)) {
        return;
    }
    $ret = '';
    $rules = '/\\(\\(((?:(?!\\)\\)).)*)\\)\\)/';
    $is_done = (isset($params[$page]) and $params[$page] > 0);
    //ページが表示済みのときTrue
    if (!$is_done) {
        $params[$page] = ++$_weblog_list_anchor;
    }
    $name = strip_bracket($page);
    $title = $name . ' ' . get_pg_passage($page, FALSE);
    if ($params['weblog']) {
        if (!ereg("(.*/)?([0-9]{4})-([0-9]{2})-([0-9]{2})-([0-9]{6}).*\$", $name, $m)) {
            return;
        }
        if (!checkdate($m[3], $m[4], $m[2])) {
            return;
        }
    }
    if ($use_static_url = 1) {
        $pgid = get_pgid_by_name($page);
        $href = XOOPS_WIKI_URL . "/{$pgid}.html";
    } else {
        $href = $script . '?' . rawurlencode($name);
    }
    //ページ名が「数字と-」だけの場合は、*(**)行を取得してみる
    $_name = "";
    if (preg_match("/^(.*\\/)?[0-9\\-]+\$/", $name)) {
        $_name = get_heading($page);
    }
    //基準ページ名は省く nao-pon
    if ($name != $prefix) {
        $name = str_replace($prefix, "", $name);
        $_is_base = false;
    } else {
        $_is_base = true;
    }
    //階層でマージン設定
    $name = str_replace("/", "\t", $name);
    //マルチバイトを考慮してTABに変換
    $c_count = count_chars($name);
    if ($_is_base) {
        $c_margin = 0;
        //基準ページ
    } else {
        $c_margin = $c_count[9] * 15;
        //TABのコード=9
    }
    //[/(\tに変換済)]以前をカット
    $name = preg_replace("/.*\t/", "", $name);
    $ret .= '<li style="margin-left:' . $c_margin . 'px;">';
    if ($params['weblog']) {
        $_page = preg_replace("/(.*\\/)?([0-9\\-]+)\$/", "\\2", $page);
        $t_year = substr($_page, 0, 4);
        $t_month = substr($_page, 5, 2);
        $t_day = substr($_page, 8, 2);
        $t_hour = substr($_page, 11, 2);
        $t_min = substr($_page, 13, 2);
        $t_sec = substr($_page, 15, 2);
        $timestamp = mktime($t_hour, $t_min, $t_sec, $t_month, $t_day, $t_year);
        //		$info =  get_pg_info_db($page);
        //		$timestamp = $info['buildtime'];
        $make_date[1] = date("Y", $timestamp);
        $make_date[2] = date("m", $timestamp);
        $make_date[3] = date("d", $timestamp);
        $make_date[4] = date("H:i", $timestamp);
        if ($params['weblog'] === "time") {
            $page_attr = $make_date[4];
        } else {
            $page_attr = $make_date[2] . "/" . $make_date[3] . " " . $make_date[4];
        }
        $ret .= $page_attr . " - ";
    }
    if ($_name) {
        $name = $_name;
    }
    if ($params['relatedcount']) {
        $name .= " (" . links_get_related_count($page) . ")";
    }
    if ($child_count != "") {
        $name .= " ({$child_count})";
    }
    //Newマーク付加
    if (!$params['nonew'] && exist_plugin_inline("new")) {
        $new_mark = do_plugin_inline("new", "{$page}/,nolink", "");
    }
    $ret .= '<a id="list_' . $params[$page] . '" href="' . $href . '" title="' . $title . '">' . $name . '</a>' . $new_mark;
    $anchor = WEBLOG_LIST_ANCHOR_ORIGIN;
    $_ret = '';
    if ($_ret != '') {
        $ret .= "<ul>{$_ret}</ul>\n";
    }
    $ret .= '</li>' . "\n";
    return $ret;
}
function plugin_calendar_viewer_convert()
{
    global $vars, $get, $post, $_labels;
    //	global $_msg_calendar_viewer_right, $_msg_calendar_viewer_left;
    //	global $_msg_calendar_viewer_restrict, $_err_calendar_viewer_param2;
    global $_symbol_paraedit, $trackback;
    $_calendar_viewer_msg = array('_err_param2' => T_('Wrong second parameter.'), '_msg_right' => T_('Next %d &gt;&gt;'), '_msg_left' => T_('&lt;&lt; Prev %d'), '_msg_restrict' => T_('Due to the blocking, the calendar_viewer cannot refer to $1.'), '_title_format' => T_('%1s, %2s %3s %4s'));
    if (!isset($vars['page'])) {
        return '';
    }
    static $viewed = array();
    if (func_num_args() < 2) {
        return PLUGIN_CALENDAR_VIEWER_USAGE . '<br />' . "\n";
    }
    $func_args = func_get_args();
    // Default values
    $pagename = $func_args[0];
    // 基準となるページ名
    $page_YM = '';
    // 一覧表示する年月
    $limit_base = 0;
    // 先頭から数えて何ページ目から表示するか (先頭)
    $limit_pitch = 0;
    // 何件づつ表示するか
    $limit_page = 0;
    // サーチするページ数
    $mode = 'past';
    // 動作モード
    $date_sep = '-';
    // 日付のセパレータ calendar2なら '-', calendarなら ''
    // Check $func_args[1]
    $matches = array();
    if (preg_match('/[0-9]{4}' . $date_sep . '[0-9]{2}/', $func_args[1])) {
        // 指定年月の一覧表示
        $page_YM = $func_args[1];
        $limit_page = 31;
    } else {
        if (preg_match('/this/si', $func_args[1])) {
            // 今月の一覧表示
            $page_YM = get_date('Y' . $date_sep . 'm');
            $limit_page = 31;
        } else {
            if (preg_match('/^[0-9]+$/', $func_args[1])) {
                // n日分表示
                $limit_pitch = $func_args[1];
                $limit_page = $func_args[1];
            } else {
                if (preg_match('/(-?[0-9]+)\\*([0-9]+)/', $func_args[1], $matches)) {
                    // 先頭より数えて x ページ目から、y件づつ表示
                    $limit_base = $matches[1];
                    $limit_pitch = $matches[2];
                    $limit_page = $matches[1] + $matches[2];
                    // 読み飛ばす + 表示する
                } else {
                    return '#calendar_viewer(): ' . $_calendar_viewer_msg['_err_param2'] . '<br />' . "\n";
                }
            }
        }
    }
    // $func_args[2]: Mode setting
    if (isset($func_args[2]) && preg_match('/^(past|pastex|view|viewex|future|futureex)$/si', $func_args[2])) {
        $mode = $func_args[2];
    }
    // $func_args[3]: Change default delimiter
    if (isset($func_args[3])) {
        $date_sep = $func_args[3];
    }
    // Avoid Loop etc.
    if (isset($viewed[$pagename])) {
        if ($viewed[$pagename] > PLUGIN_CALENDAR_MAX_VIEWS) {
            $s_page = htmlsc($pagename);
            return '#calendar_viewer(): You already view: ' . $s_page . '<br />';
        }
        $viewed[$pagename]++;
        // Valid
    } else {
        $viewed[$pagename] = 1;
        // Valid
    }
    // 一覧表示するページ名とファイル名のパターン ファイル名には年月を含む
    if ($pagename == '') {
        // pagename無しのyyyy-mm-ddに対応するための処理
        $pagepattern = '';
        $pagepattern_len = 0;
        $filepattern = encode($page_YM);
        $filepattern_len = strlen($filepattern);
    } else {
        $pagepattern = strip_bracket($pagename) . '/';
        $pagepattern_len = strlen($pagepattern);
        $filepattern = encode($pagepattern . $page_YM);
        $filepattern_len = strlen($filepattern);
    }
    // ページリストの取得
    $pagelist = array();
    if ($dir = @opendir(DATA_DIR)) {
        $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd');
        $page_date = '';
        while ($file = readdir($dir)) {
            if ($file == '..' || $file == '.') {
                continue;
            }
            if (substr($file, 0, $filepattern_len) != $filepattern) {
                continue;
            }
            $page = decode(trim(preg_replace('/\\.txt$/', ' ', $file)));
            $page_date = substr($page, $pagepattern_len);
            // Verify the $page_date pattern (Default: yyyy-mm-dd).
            // Past-mode hates the future, and
            // Future-mode hates the past.
            if (plugin_calendar_viewer_isValidDate($page_date, $date_sep) == FALSE || $page_date > $_date && $mode == 'past' || $page_date < $_date && $mode == 'future' || $page_date >= $_date && $mode == 'pastex' || $page_date <= $_date && $mode == 'futureex') {
                continue;
            }
            $pagelist[] = $page;
        }
    }
    closedir($dir);
    if ($mode == 'past' || $mode == 'pastex' || $mode == 'viewex') {
        rsort($pagelist, SORT_STRING);
        // New => Old
    } else {
        sort($pagelist, SORT_STRING);
        // Old => New
    }
    // Include start
    $tmppage = $vars['page'];
    $return_body = '';
    // $limit_page の件数までインクルード
    $tmp = max($limit_base, 0);
    // Skip minus
    while ($tmp < $limit_page) {
        if (!isset($pagelist[$tmp])) {
            break;
        }
        $page = $pagelist[$tmp];
        $get['page'] = $post['page'] = $vars['page'] = $page;
        $wiki = Factory::Wiki($page);
        // 現状で閲覧許可がある場合だけ表示する
        if ($wiki->isReadable()) {
            if (function_exists('convert_filter')) {
                $body = RendererFactory::factory(convert_filter($wiki->get()));
            } else {
                $body = $wiki->render();
            }
        } else {
            $body = str_replace('$1', $page, $_calendar_viewer_msg['_msg_restrict']);
        }
        if (PLUGIN_CALENDAR_VIEWER_DATE_FORMAT !== FALSE) {
            $time = strtotime(basename($page));
            // $date_sep must be assumed '-' or ''!
            if ($time == -1) {
                $s_page = htmlsc($page);
                // Failed. Why?
            } else {
                $week = $_labels['week'][date('w', $time)][0];
                $month = $_labels['month'][preg_replace('/^0/', '', date('m', $time))][0];
                $s_page = htmlsc(str_replace(array('$w', '$m'), array($week, $month), date(PLUGIN_CALENDAR_VIEWER_DATE_FORMAT, $time)));
            }
        } else {
            $s_page = htmlsc($page);
        }
        // if (PKWK_READONLY) {
        if (Auth::check_role('readonly')) {
            $link = get_page_uri($page);
        } else {
            $link = get_cmd_uri('edit', $page, '', array('page' => $page));
        }
        $link = '<a class="anchor_super" href="' . $link . '">' . $_symbol_paraedit . '</a>';
        $head = '<h1>' . $s_page . $link . '</h1>' . "\n";
        $page_title = basepagename($page);
        $tail = '';
        if (PLUGIN_CALENDAR_VIEWER_HOLIDAYVIEW === TRUE) {
            $time = strtotime($page_title);
            if ($time != -1) {
                $yy = intval(date('Y', $time));
                $mm = intval(date('n', $time));
                $dd = intval(date('d', $time));
                $h_today = PublicHolidayFactory::factory('JP', $yy, $mm, $dd);
                if ($h_today['rc'] != 0) {
                    $classname = 'date_holiday';
                    $weekclass = 'week_sun';
                } else {
                    switch ($h_today['w']) {
                        case 0:
                            $classname = 'date_holiday';
                            $weekclass = 'week_sun';
                            break;
                        case 6:
                            $classname = 'date_weekend';
                            $weekclass = 'week_sat';
                        default:
                            $classname = 'date_weekday';
                            $weekclass = 'week_day';
                            break;
                    }
                }
            }
        }
        if (PLUGIN_CALENDAR_VIEWER_COMMENT === TRUE) {
            if (is_page(':config/plugin/addline/comment') && exist_plugin_inline('addline')) {
                $comm = RendererFactory::factory(array('&addline(comment,above){comment};'));
                $comm = preg_replace(array("'<p>'si", "'</p>'si"), array("", ""), $comm);
                $tail .= str_replace('>comment', '><img src="' . IMAGE_URI . 'plus/comment.png" width="15" height="15" alt="Comment" title="Comment" />Comment', $comm);
            }
        }
        if (PLUGIN_CALENDAR_VIEWER_TRACKBACK === TRUE && $trackback) {
            $tb_link = get_cmd_uri('tb', '', '', array('__mode' => 'view', 'tb_id' => tb_get_id($page)));
            $tail .= '<a class="pkwk-icon_linktext cmd-trackback" href="' . $tb_link . '">' . 'Trackback(' . tb_count($page) . ')' . '</a>' . "\n";
        }
        $page_id = str_replace('/', '_', $page);
        $return_body .= '<article id="' . $page_id . '">' . "\n";
        $return_body .= $head . $body;
        $return_body .= '</article>' . "\n";
        ++$tmp;
    }
    // ここで、前後のリンクを表示
    // ?plugin=calendar_viewer&file=ページ名&date=yyyy-mm
    $page = substr($pagepattern, 0, $pagepattern_len - 1);
    $r_page = rawurlencode($page);
    if ($page_YM != '') {
        // 年月表示時
        $date_sep_len = strlen($date_sep);
        $this_year = substr($page_YM, 0, 4);
        $this_month = substr($page_YM, 4 + $date_sep_len, 2);
        // 次月
        $next_year = $this_year;
        $next_month = $this_month + 1;
        if ($next_month > 12) {
            ++$next_year;
            $next_month = 1;
        }
        $next_YM = sprintf('%04d%s%02d', $next_year, $date_sep, $next_month);
        // 前月
        $prev_year = $this_year;
        $prev_month = $this_month - 1;
        if ($prev_month < 1) {
            --$prev_year;
            $prev_month = 12;
        }
        $prev_YM = sprintf('%04d%s%02d', $prev_year, $date_sep, $prev_month);
        if ($mode == 'past') {
            $right_YM = $prev_YM;
            $right_text = $prev_YM . '&gt;&gt;';
            // >>
            $left_YM = $next_YM;
            $left_text = '&lt;&lt;' . $next_YM;
            // <<
        } else {
            $left_YM = $prev_YM;
            $left_text = '&lt;&lt;' . $prev_YM;
            // <<
            $right_YM = $next_YM;
            $right_text = $next_YM . '&gt;&gt;';
            // >>
        }
    } else {
        // n件表示時
        if ($limit_base <= 0) {
            $left_YM = '';
            // 表示しない (それより前の項目はない)
        } else {
            $left_YM = $limit_base - $limit_pitch . '*' . $limit_pitch;
            $left_text = sprintf($_calendar_viewer_msg['_msg_left'], $limit_pitch);
        }
        if ($limit_base + $limit_pitch >= count($pagelist)) {
            $right_YM = '';
            // 表示しない (それより後の項目はない)
        } else {
            $right_YM = $limit_base + $limit_pitch . '*' . $limit_pitch;
            $right_text = sprintf($_calendar_viewer_msg['_msg_right'], $limit_pitch);
        }
    }
    // ナビゲート用のリンクを末尾に追加
    if ($left_YM != '' || $right_YM != '') {
        $s_date_sep = htmlsc($date_sep);
        $left_link = $right_link = '';
        if ($left_YM != '') {
            $left_link = '<a href="' . get_cmd_uri('calendar_viewer', '', '', array('mode' => $mode, 'file' => $page, 'date_sep' => $date_sep, 'date' => $left_YM)) . '">' . $left_text . '</a>';
        }
        if ($right_YM != '') {
            $right_link = '<a href="' . get_cmd_uri('calendar_viewer', '', '', array('mode' => $mode, 'file' => $page, 'date_sep' => $date_sep, 'date' => $right_YM)) . '">' . $right_text . '</a>';
        }
        $center_link = '<a href="' . get_page_uri($page) . '">' . $page . '</a>';
        // past modeは<<新 旧>> 他は<<旧 新>>
        $nav = '<nav class="calendar_viewer_navi">' . "\n";
        $nav .= <<<EOD
<ul class="navi">
\t<li class="navi_left">{$left_link}</li>
\t<li class="navi_none">{$center_link}</li>
\t<li class="navi_right">{$right_link}</li>
</ul>
<hr />
EOD;
        $nav .= '</nav>' . "\n";
    }
    $get['page'] = $post['page'] = $vars['page'] = $tmppage;
    return $nav . $return_body;
}
Example #15
0
	function toString()
	{
		$body = ($this->body == '') ? '' : make_link($this->body);
		
		// プラグイン呼び出し
		if (exist_plugin_inline($this->name))
		{
			$str = do_plugin_inline($this->name,$this->param,$body);
			if ($str !== FALSE) //成功
			{
				return $str;
			}
		}
		
		// プラグインが存在しないか、変換に失敗
		return make_line_rules(htmlspecialchars('&'.$this->plain).($body == '' ? ';' : "\{$body};"));
	}