function get_plugin_option($args, &$params, $tolower = TRUE, $separator = ':') { return PluginRenderer::getPluginOption($args, $params, $tolower, $separator); }
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>'; }