Example #1
0
function plugin_pcomment_convert()
{
    global $vars;
    global $_pcmt_messages;
    $params = array('noname' => FALSE, 'nodate' => FALSE, 'below' => FALSE, 'above' => FALSE, 'reply' => FALSE, '_args' => array());
    foreach (func_get_args() as $arg) {
        plugin_pcomment_check_arg($arg, $params);
    }
    $vars_page = isset($vars['page']) ? $vars['page'] : '';
    $page = isset($params['_args'][0]) && $params['_args'][0] != '' ? $params['_args'][0] : sprintf(PLUGIN_PCOMMENT_PAGE, strip_bracket($vars_page));
    $count = isset($params['_args'][1]) ? intval($params['_args'][1]) : 0;
    if ($count == 0) {
        $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
    }
    $_page = get_fullname(strip_bracket($page), $vars_page);
    if (!is_pagename($_page)) {
        return sprintf($_pcmt_messages['err_pagename'], htmlsc($_page));
    }
    $dir = PLUGIN_PCOMMENT_DIRECTION_DEFAULT;
    if ($params['below']) {
        $dir = 0;
    } elseif ($params['above']) {
        $dir = 1;
    }
    list($comments, $digest) = plugin_pcomment_get_comments($_page, $count, $dir, $params['reply']);
    if (PKWK_READONLY) {
        $form_start = $form = $form_end = '';
    } else {
        // Show a form
        if ($params['noname']) {
            $title = $_pcmt_messages['msg_comment'];
            $name = '';
        } else {
            $title = $_pcmt_messages['btn_name'];
            $name = '<input type="text" name="name" size="' . PLUGIN_PCOMMENT_SIZE_NAME . '" />';
        }
        $radio = $params['reply'] ? '<input type="radio" name="reply" value="0" tabindex="0" checked="checked" />' : '';
        $comment = '<input type="text" name="msg" size="' . PLUGIN_PCOMMENT_SIZE_MSG . '" />';
        $s_page = htmlsc($page);
        $s_refer = htmlsc($vars_page);
        $s_nodate = htmlsc($params['nodate']);
        $s_count = htmlsc($count);
        $form_start = '<form action="' . get_script_uri() . '" method="post">' . "\n";
        $form = <<<EOD
  <div>
  <input type="hidden" name="digest" value="{$digest}" />
  <input type="hidden" name="plugin" value="pcomment" />
  <input type="hidden" name="refer"  value="{$s_refer}" />
  <input type="hidden" name="page"   value="{$s_page}" />
  <input type="hidden" name="nodate" value="{$s_nodate}" />
  <input type="hidden" name="dir"    value="{$dir}" />
  <input type="hidden" name="count"  value="{$count}" />
  {$radio} {$title} {$name} {$comment}
  <input type="submit" value="{$_pcmt_messages['btn_comment']}" />
  </div>
EOD;
        $form_end = '</form>' . "\n";
    }
    if (!is_page($_page)) {
        $link = make_pagelink($_page);
        $recent = $_pcmt_messages['msg_none'];
    } else {
        $msg = $_pcmt_messages['msg_all'] != '' ? $_pcmt_messages['msg_all'] : $_page;
        $link = make_pagelink($_page, $msg);
        $recent = !empty($count) ? sprintf($_pcmt_messages['msg_recent'], $count) : '';
    }
    if ($dir) {
        return '<div>' . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . $form_start . $comments . "\n" . $form . $form_end . '</div>' . "\n";
    } else {
        return '<div>' . $form_start . $form . $comments . "\n" . $form_end . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . '</div>' . "\n";
    }
}
Example #2
0
function plugin_pcomment_convert()
{
    global $vars;
    //	global $_pcmt_messages;
    $_pcmt_messages = array('msg_name' => T_('Name: '), 'btn_comment' => T_('Post Comment'), 'msg_comment' => T_('Comment: '), 'msg_recent' => T_('Show recent %d comments.'), 'msg_all' => T_('Go to the comment page.'), 'msg_none' => T_('No comment.'), 'err_pagename' => T_('[[%s]] : not a valid page name.'));
    $params = array('noname' => FALSE, 'nodate' => FALSE, 'below' => FALSE, 'above' => FALSE, 'reply' => FALSE, '_args' => array());
    $params = PluginRenderer::getPluginOption(func_get_args(), $params);
    //	var_dump($params);
    $vars_page = isset($vars['page']) ? $vars['page'] : '';
    $page = isset($params['_args'][1]) && !empty($params['_args'][1]) ? $params['_args'][0] : Utility::stripBracket(sprintf(PLUGIN_PCOMMENT_PAGE, $vars_page));
    $count = isset($params['_args'][0]) ? intval($params['_args'][0]) : 0;
    if ($count == 0) {
        $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
    }
    $_page = get_fullname(strip_bracket($page), $vars_page);
    $wiki = Factory::Wiki($_page);
    if (!$wiki->isValied()) {
        return sprintf($_pcmt_messages['err_pagename'], Utility::htmlsc($_page));
    }
    $dir = PLUGIN_COMMENT_DIRECTION_DEFAULT;
    if ($params['below']) {
        $dir = 0;
    } elseif ($params['above']) {
        $dir = 1;
    }
    list($comments, $digest) = plugin_pcomment_get_comments($_page, $count, $dir, $params['reply']);
    $form = array();
    // if (PKWK_READONLY) {
    if (!Auth::check_role('readonly') && isset($vars['page'])) {
        // Show a form
        $form[] = '<input type="hidden" name="cmd" value="pcomment" />';
        $form[] = '<input type="hidden" name="digest" value="' . $digest . '" />';
        $form[] = '<input type="hidden" name="refer"  value="' . Utility::htmlsc($vars_page) . '" />';
        $form[] = '<input type="hidden" name="page"   value="' . Utility::htmlsc($page) . '" />';
        $form[] = '<input type="hidden" name="nodate" value="' . Utility::htmlsc($params['nodate']) . '" />';
        $form[] = '<input type="hidden" name="dir"    value="' . $dir . '" />';
        $form[] = '<input type="hidden" name="count"  value="' . $count . '" />';
        $form[] = '<div class="row">';
        if ($params['noname'] === false) {
            $form[] = '<div class="col-md-3">';
            list($nick, $link, $disabled) = plugin_pcomment_get_nick();
            if ($params['reply']) {
                $form[] = '<div class="input-group">';
                $form[] = '<span class="input-group-addon">';
                $form[] = '<input type="radio" name="reply" value="0" tabindex="0" checked="checked" />';
                $form[] = '</span>';
            }
            $form[] = '<input type="text" name="name" value="' . $nick . '" ' . $disabled . ' class="form-control" size="' . PLUGIN_COMMENT_SIZE_NAME . '" placeholder="' . $_pcmt_messages['msg_name'] . '" />';
            if ($params['reply']) {
                $form[] = '</div>';
            }
            $form[] = '</div>';
            $form[] = '<div class="col-md-9">';
            $form[] = '<div class="input-group">';
        } else {
            $form[] = '<div class="col-md-12">';
            $form[] = '<div class="input-group">';
            if ($params['reply']) {
                $form[] = '<span class="input-group-addon">';
                $form[] = '<input type="radio" name="reply" value="0" tabindex="0" checked="checked" />';
                $form[] = '</span>';
            }
        }
        $form[] = '<textarea name="msg" cols="' . PLUGIN_COMMENT_SIZE_MSG . '" rows="1" class="form-control" placeholder="' . $_pcmt_messages['msg_comment'] . '"></textarea>';
        $form[] = '<span class="input-group-btn">';
        $form[] = '<button type="submit" class="btn btn-info">' . $_pcmt_messages['btn_comment'] . '</button>';
        $form[] = '</span>';
        $form[] = '</div>';
        $form[] = '</div>';
        $form[] = '</div>';
    }
    if (PKWK_READONLY == Auth::ROLE_AUTH) {
        exist_plugin('login');
        $form[] = do_plugin_inline('login');
    }
    if (!$wiki->has()) {
        $link = make_pagelink($_page);
        $recent = $_pcmt_messages['msg_none'];
    } else {
        $msg = !empty($_pcmt_messages['msg_all']) ? $_pcmt_messages['msg_all'] : $_page;
        $link = make_pagelink($_page, $msg);
        $recent = !empty($count) ? sprintf($_pcmt_messages['msg_recent'], $count) : '';
    }
    $string = !Auth::check_role('readonly') ? '<form action="' . get_script_uri() . '" method="post" class="plugin-pcomment-form form-inline" data-collision-check="false">' : '';
    $string .= $dir ? '<p>' . $recent . ' ' . $link . '</p>' . "\n" . $comments . "\n" . join("\n", $form) : join("\n", $form) . "\n" . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . $comments . "\n";
    $string .= !Auth::check_role('readonly') ? '</form>' : '';
    return IS_MOBILE ? '<div data-role="collapsible" data-theme="b" data-content-theme="d"><h4>' . $_pcmt_messages['msg_comment'] . '</h4>' . $string . '</div>' : '<div class="pcomment">' . $string . '</div>';
}
function plugin_pcomment_convert()
{
    global $vars, $script;
    //	global $_pcmt_messages;
    $_pcmt_messages = array('btn_name' => _('Name: '), 'btn_comment' => _('Post Comment'), 'msg_comment' => _('Comment: '), 'msg_recent' => _('Show recent %d comments.'), 'msg_all' => _('Go to the comment page.'), 'msg_none' => _('No comment.'), 'err_pagename' => _('[[%s]] : not a valid page name.'));
    $params = array('noname' => FALSE, 'nodate' => FALSE, 'below' => FALSE, 'above' => FALSE, 'reply' => FALSE, '_args' => array());
    foreach (func_get_args() as $arg) {
        check_plugin_option($arg, $params);
    }
    $vars_page = isset($vars['page']) ? $vars['page'] : '';
    $page = isset($params['_args'][0]) && $params['_args'][0] != '' ? $params['_args'][0] : sprintf(PLUGIN_PCOMMENT_PAGE, strip_bracket($vars_page));
    $count = isset($params['_args'][1]) ? intval($params['_args'][1]) : 0;
    if ($count == 0) {
        $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
    }
    $_page = get_fullname(strip_bracket($page), $vars_page);
    if (!is_pagename($_page)) {
        return sprintf($_pcmt_messages['err_pagename'], htmlspecialchars($_page));
    }
    $dir = PLUGIN_PCOMMENT_DIRECTION_DEFAULT;
    if ($params['below']) {
        $dir = 0;
    } elseif ($params['above']) {
        $dir = 1;
    }
    list($comments, $digest) = plugin_pcomment_get_comments($_page, $count, $dir, $params['reply']);
    $auth_guide = '';
    if (PKWK_READONLY == ROLE_AUTH) {
        exist_plugin('login');
        $auth_guide = do_plugin_inline('login');
    }
    // if (PKWK_READONLY) {
    if (auth::check_role('readonly')) {
        $form_start = $form = $form_end = '';
    } else {
        // Show a form
        if ($params['noname']) {
            $title = $_pcmt_messages['msg_comment'];
            $name = '';
        } else {
            $title = $_pcmt_messages['btn_name'];
            // $name = '<input type="text" name="name" size="' . PLUGIN_PCOMMENT_SIZE_NAME . '" />';
            list($nick, $link, $disabled) = plugin_pcomment_get_nick();
            $name = '<input type="text" name="name" value="' . $nick . '" ' . $disabled . ' size="' . PLUGIN_PCOMMENT_SIZE_NAME . '" />';
        }
        $radio = $params['reply'] ? '<input type="radio" name="reply" value="0" tabindex="0" checked="checked" />' : '';
        $comment = '<input type="text" name="msg" size="' . PLUGIN_PCOMMENT_SIZE_MSG . '" />';
        $s_page = htmlspecialchars($page);
        $s_refer = htmlspecialchars($vars_page);
        $s_nodate = htmlspecialchars($params['nodate']);
        $helptags = edit_form_assistant();
        $form_start = '<form action="' . $script . '" method="post">' . "\n";
        $form = <<<EOD
  <div class="pcommentform" onmouseup="pukiwiki_pos()" onkeyup="pukiwiki_pos()">
  <input type="hidden" name="digest" value="{$digest}" />
  <input type="hidden" name="plugin" value="pcomment" />
  <input type="hidden" name="refer"  value="{$s_refer}" />
  <input type="hidden" name="page"   value="{$s_page}" />
  <input type="hidden" name="nodate" value="{$s_nodate}" />
  <input type="hidden" name="dir"    value="{$dir}" />
  <input type="hidden" name="count"  value="{$count}" />
  {$radio} {$title} {$name} {$comment}
  <input type="submit" value="{$_pcmt_messages['btn_comment']}" />
  {$helptags}
  </div>
EOD;
        $form_end = '</form>' . "\n";
    }
    if (!is_page($_page)) {
        $link = make_pagelink($_page);
        $recent = $_pcmt_messages['msg_none'];
    } else {
        $msg = $_pcmt_messages['msg_all'] != '' ? $_pcmt_messages['msg_all'] : $_page;
        $link = make_pagelink($_page, $msg);
        $recent = !empty($count) ? sprintf($_pcmt_messages['msg_recent'], $count) : '';
    }
    if ($dir) {
        return '<div>' . $auth_guide . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . $form_start . $comments . "\n" . $form . $form_end . '</div>' . "\n";
    } else {
        return '<div>' . $form_start . $form . $comments . "\n" . $form_end . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . $auth_guide . '</div>' . "\n";
    }
}
Example #4
0
function plugin_pcomment_convert()
{
    global $vars;
    $qm = get_qm();
    $qt = get_qt();
    $ret = '';
    $params = array('noname' => FALSE, 'nodate' => FALSE, 'below' => FALSE, 'above' => FALSE, 'reply' => FALSE, '_args' => array());
    // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5
    $args = func_get_args();
    // with array_walk()
    array_walk($args, 'plugin_pcomment_check_arg', $params);
    $vars_page = isset($vars['page']) ? $vars['page'] : '';
    $page = isset($params['_args'][0]) && $params['_args'][0] != '' ? $params['_args'][0] : $qm->replace('plg_pcomment.page', strip_bracket($vars_page));
    $count = isset($params['_args'][1]) && $params['_args'][1] != '' ? $params['_args'][1] : 0;
    if ($count == 0 && $count !== '0') {
        $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
    }
    //キャッシュのために、追加
    if (!in_array(strip_bracket($page), $qt->get_rel_pages())) {
        $qt->set_rel_page(strip_bracket($page));
    }
    $_page = get_fullname(strip_bracket($page), $vars_page);
    if (!is_pagename($_page)) {
        return sprintf($qm->m['plg_pcomment']['err_pagename'], htmlspecialchars($_page));
    }
    $dir = PLUGIN_PCOMMENT_DIRECTION_DEFAULT;
    if ($params['below']) {
        $dir = 0;
    } elseif ($params['above']) {
        $dir = 1;
    }
    list($comments, $digest) = plugin_pcomment_get_comments($_page, $count, $dir, $params['reply']);
    if (PKWK_READONLY) {
        $form_start = $form = $form_end = '';
    } else {
        // Show a form
        if ($params['noname']) {
            $title = $qm->m['plg_pcomment']['comment'];
            $name = '';
        } else {
            $title = $qm->m['plg_pcomment']['btn_name'];
            $name = '<input type="text" name="name" size="' . PLUGIN_PCOMMENT_SIZE_NAME . '" />';
        }
        $radio = $params['reply'] ? '<input type="radio" name="reply" value="0" tabindex="0" checked="checked" />' : '';
        $comment = '<input type="text" name="msg" size="' . PLUGIN_PCOMMENT_SIZE_MSG . '" />';
        $s_page = htmlspecialchars($page);
        $s_refer = htmlspecialchars($vars_page);
        $s_nodate = htmlspecialchars($params['nodate']);
        $s_count = htmlspecialchars($count);
        $form_start = '<form action="' . get_script_uri() . '" method="post">' . "\n";
        $form = <<<EOD
  <div>
  <input type="hidden" name="digest" value="{$digest}" />
  <input type="hidden" name="plugin" value="pcomment" />
  <input type="hidden" name="refer"  value="{$s_refer}" />
  <input type="hidden" name="page"   value="{$s_page}" />
  <input type="hidden" name="nodate" value="{$s_nodate}" />
  <input type="hidden" name="dir"    value="{$dir}" />
  <input type="hidden" name="count"  value="{$count}" />
  {$radio} {$title} {$name} {$comment}
  <input type="submit" value="{$qm->m['plg_pcomment']['btn_comment']}" />
  </div>
EOD;
        $form_end = '</form>' . "\n";
    }
    if (!is_page($_page)) {
        $link = make_pagelink($_page);
        $recent = $qm->m['plg_pcomment']['nothing'];
    } else {
        $msg = $qm->m['plg_pcomment']['all'] != '' ? $qm->m['plg_pcomment']['all'] : $_page;
        $link = make_pagelink($_page, $msg);
        $recent = !empty($count) ? sprintf($qm->m['plg_pcomment']['recent'], $count) : '';
    }
    if ($dir) {
        return '<div>' . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . $form_start . $comments . "\n" . $form . $form_end . '</div>' . "\n";
    } else {
        return '<div>' . $form_start . $form . $comments . "\n" . $form_end . '<p>' . $recent . ' ' . $link . '</p>' . "\n" . '</div>' . "\n";
    }
}