function plugin_commentx_convert() { global $vars, $digest; //, $_btn_comment, $_btn_name, $_msg_comment; static $numbers = array(); static $all_numbers = 0; $_btn_name = _("Name: "); $_btn_comment = _("Post Comment"); $_msg_comment = _("Comment: "); $auth_guide = ''; if (PKWK_READONLY == ROLE_AUTH) { // Plus! if (exist_plugin('login')) { $auth_guide = do_plugin_inline('login'); } } if (is_callable(array('auth', 'check_role'))) { // Plus! if (auth::check_role('readonly')) { return $auth_guide; } } else { if (PKWK_READONLY) { return ''; } } if (!isset($numbers[$vars['page']])) { $numbers[$vars['page']] = 0; } $comment_no = $numbers[$vars['page']]++; $comment_all_no = $all_numbers++; $options = func_num_args() ? func_get_args() : array(); $noname = in_array('noname', $options); $nodate = in_array('nodate', $options) ? '1' : '0'; $above = in_array('above', $options) ? '1' : (in_array('below', $options) ? '0' : PLUGIN_COMMENTX_DIRECTION_DEFAULT); $textarea = in_array('textarea', $options) ? TRUE : (in_array('textfield', $options) ? FALSE : PLUGIN_COMMENTX_TEXTAREA); list($user, $link, $disabled) = plugin_commentx_get_nick(); if ($noname) { $nametags = '<label for="_p_comment_comment_' . $comment_all_no . '">' . $_msg_comment . '</label>'; } else { if ($textarea) { $nametags = '<label for="_p_comment_name_' . $comment_all_no . '">' . $_btn_name . '</label>' . '<input type="text" name="name" id="_p_comment_name_' . $comment_all_no . '" size="' . PLUGIN_COMMENTX_SIZE_TEXTAREA_NAME . '" value="' . $user . '"' . $disabled . ' /><br />' . "\n"; } else { $nametags = '<label for="_p_comment_name_' . $comment_all_no . '">' . $_btn_name . '</label>' . '<input type="text" name="name" id="_p_comment_name_' . $comment_all_no . '" size="' . PLUGIN_COMMENTX_SIZE_NAME . '" value="' . $user . '"' . $disabled . ' />' . "\n"; } } if ($textarea) { $comment_box = '<textarea name="msg" id="_p_comment_comment_{' . $comment_all_no . '}" rows="' . PLUGIN_COMMENTX_SIZE_TEXTAREA_ROWS . '" style="width:' . PLUGIN_COMMENTX_SIZE_TEXTAREA_COLS . ';" /></textarea>'; } else { $comment_box = '<input type="text" name="msg" id="_p_comment_comment_{' . $comment_all_no . '}" style="width:' . PLUGIN_COMMENTX_SIZE_MSG . ';" />'; } if (function_exists('edit_form_assistant')) { // Plus! $helptags = edit_form_assistant(); } $refpage = ''; $script = get_script_uri(); $s_page = htmlspecialchars($vars['page']); $r_page = htmlspecialchars(rawurlencode($vars['page'])); $ticket = md5(MUTIME); if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) { $keyword = $ticket; $_SESSION[$keyword] = md5(get_ticket() . $digest); } $string = <<<EOD <br /> {$auth_guide} <form action="{$script}?{$r_page}" method="post"> <div class="commentform" onmouseup="pukiwiki_pos()" onkeyup="pukiwiki_pos()"> <input type="hidden" name="refpage" value="{$refpage}" /> <input type="hidden" name="plugin" value="commentx" /> <input type="hidden" name="refer" value="{$s_page}" /> <input type="hidden" name="comment_no" value="{$comment_no}" /> <input type="hidden" name="nodate" value="{$nodate}" /> <input type="hidden" name="above" value="{$above}" /> <input type="hidden" name="digest" value="{$digest}" /> <input type="hidden" name="ticket" value="{$ticket}" /> {$nametags} {$comment_box} <input type="submit" name="comment" value="{$_btn_comment}" /> {$helptags} </div> </form> EOD; return $string; }
function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE) { global $script, $vars, $rows, $cols, $hr, $function_freeze; global $load_template_func, $load_refer_related; global $notimeupdate; global $_button, $_string; global $ajax, $ctrl_unload; // Newly generate $digest or not if ($digest === FALSE) { $digest = md5(get_source($page, TRUE, TRUE)); } $refer = $template = $addtag = $add_top = $add_ajax = ''; $checked_top = isset($vars['add_top']) ? ' checked="checked"' : ''; $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : ''; if (isset($vars['add'])) { $addtag = '<input type="hidden" name="add" value="true" />'; $add_top = '<input type="checkbox" name="add_top" value="true"' . $checked_top . ' /><span class="small">' . $_button['addtop'] . '</span>'; } if ($load_template_func && $b_template) { $pages = array(); foreach (auth::get_existpages() as $_page) { if (is_cantedit($_page) || check_non_list($_page)) { continue; } $s_page = htmlspecialchars($_page); $pages[$_page] = ' <option value="' . $s_page . '">' . $s_page . '</option>'; } ksort($pages, SORT_STRING); $s_pages = join("\n", $pages); $template = <<<EOD <select name="template_page"> <option value="">-- {$_button['template']} --</option> {$s_pages} </select> <input type="submit" name="template" value="{$_button['load']}" accesskey="r" /> <br /> EOD; if ($load_refer_related) { if (isset($vars['refer']) && $vars['refer'] != '') { $refer = '[[' . strip_bracket($vars['refer']) . ']]' . "\n\n"; } } } $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); $s_digest = htmlspecialchars($digest); $s_postdata = htmlspecialchars($refer . $postdata); $s_original = isset($vars['original']) ? htmlspecialchars($vars['original']) : $s_postdata; $s_id = isset($vars['id']) ? htmlspecialchars($vars['id']) : ''; $b_preview = isset($vars['preview']); // TRUE when preview $btn_preview = $b_preview ? $_button['repreview'] : $_button['preview']; $s_ticket = md5(MUTIME); if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) { // BugTrack/95 fix Problem: browser RSS request with session $_SESSION[$s_ticket] = md5(get_ticket() . $digest); $_SESSION['origin' . $s_ticket] = md5(get_ticket() . str_replace("\r", '', $s_original)); } if ($ajax && !is_mobile()) { $add_ajax = '<input type="button" name="add_ajax" value="' . $btn_preview . '" accesskey="p" onclick="pukiwiki_apx(this.form.page.value)" />'; } else { $add_ajax = '<input type="submit" name="preview" value="' . $btn_preview . '" accesskey="p" />'; } $add_notimestamp = ''; if ($notimeupdate != 0 && is_page($page)) { // enable 'do not change timestamp' $add_notimestamp = <<<EOD <input type="checkbox" name="notimestamp" id="_edit_form_notimestamp" value="true"{$checked_time} /> <label for="_edit_form_notimestamp"><span class="small">{$_button['notchangetimestamp']}</span></label> EOD; if ($notimeupdate == 2 && auth::check_role('role_adm_contents')) { // enable only administrator $add_notimestamp .= <<<EOD <input type="password" name="pass" size="12" /> EOD; } $add_notimestamp .= ' '; } $refpage = isset($vars['refpage']) ? htmlspecialchars($vars['refpage']) : ''; $add_assistant = edit_form_assistant(); $body = <<<EOD <div id="realview_outer"><div id="realview"></div><br /></div> <form action="{$script}" method="post" id="form"> <div class="edit_form" onmouseup="pukiwiki_pos()" onkeyup="pukiwiki_pos()"> {$template} {$addtag} <input type="hidden" name="cmd" value="edit" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="hidden" name="digest" value="{$s_digest}" /> <input type="hidden" name="ticket" value="{$s_ticket}" /> <input type="hidden" name="id" value="{$s_id}" /> <textarea id="msg" name="msg" rows="{$rows}" cols="{$cols}" onselect="pukiwiki_apv(this.form.page.value,this)" onfocus="pukiwiki_apv(this.form.page.value,this)" onkeyup="pukiwiki_apv(this.form.page.value,this)" onmouseup="pukiwiki_apv(this.form.page.value,this)">{$s_postdata}</textarea> <br /> {$add_assistant} <br /> <input type="submit" name="write" value="{$_button['update']}" accesskey="s" /> {$add_top} {$add_ajax} {$add_notimestamp} <input type="submit" id="cancel" name="cancel" value="{$_button['cancel']}" accesskey="c" /> <textarea id="original" name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea> </div> </form> EOD; if ($ajax) { global $head_tags; $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/msxml.js"></script>'; $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/realedit.js"></script>'; } if ($ctrl_unload) { global $head_tags; $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/ctrl_unload.js"></script>'; } return $body; }
function plugin_mceedit_edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE) { global $script, $vars, $rows, $cols, $hr, $function_freeze; global $whatsnew, $load_template_func; global $notimeupdate; global $_button, $_string; global $ajax; // Newly generate $digest or not if ($digest === FALSE) { $digest = md5(join('', get_source($page))); } // TinyMCE $lines = explode("\n", $postdata); if (preg_match('/^\\*{1,3}/m', $lines[0]) !== 0) { $before = array_shift($lines); } $postdata = implode("\n", $lines); $postdata = trim($postdata); if (preg_match('/\\A#html{{[\\r\\n](.*)[\\r\\n]}}\\Z/m', $postdata, $matches) === 0) { return "<p>The format of text data has to be<br />#html{{<br />}}<br /> or <br />**One headline<br />#html{{<br />}}<br />(This is for paragraph editing). </p>"; } $postdata = $matches[1]; $refer = $template = $addtag = $add_top = $add_ajax = ''; $checked_top = isset($vars['add_top']) ? ' checked="checked"' : ''; $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : ''; if (isset($vars['add'])) { $addtag = '<input type="hidden" name="add" value="true" />'; $add_top = '<input type="checkbox" name="add_top" value="true"' . $checked_top . ' /><span class="small">' . $_button['addtop'] . '</span>'; } if ($load_template_func && $b_template) { $pages = array(); foreach (get_existpages() as $_page) { if ($_page == $whatsnew || check_non_list($_page)) { continue; } $s_page = htmlspecialchars($_page); $pages[$_page] = ' <option value="' . $s_page . '">' . $s_page . '</option>'; } ksort($pages); $s_pages = join("\n", $pages); $template = <<<EOD <select name="template_page"> <option value="">-- {$_button['template']} --</option> {$s_pages} </select> <input type="submit" name="template" value="{$_button['load']}" accesskey="r" /> <br /> EOD; if (isset($vars['refer']) && $vars['refer'] != '') { $refer = '[[' . strip_bracket($vars['refer']) . ']]' . "\n\n"; } } $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); $s_digest = htmlspecialchars($digest); $s_postdata = htmlspecialchars($refer . $postdata); $s_original = isset($vars['original']) ? htmlspecialchars($vars['original']) : $s_postdata; $s_id = isset($vars['id']) ? htmlspecialchars($vars['id']) : ''; $b_preview = isset($vars['preview']); // TRUE when preview $btn_preview = $b_preview ? $_button['repreview'] : $_button['preview']; if ($ajax) { $add_ajax = '<input type="button" name="add_ajax" value="' . $btn_preview . '" accesskey="p" onclick="pukiwiki_apx(this.form.page.value)" />'; } $add_notimestamp = ''; if ($notimeupdate != 0) { // enable 'do not change timestamp' $add_notimestamp = <<<EOD <input type="checkbox" name="notimestamp" id="_edit_form_notimestamp" value="true"{$checked_time} /> <label for="_edit_form_notimestamp"><span class="small">{$_button['notchangetimestamp']}</span></label> EOD; if ($notimeupdate == 2 && auth::check_role('role_adm_contents')) { // enable only administrator $add_notimestamp .= <<<EOD <input type="password" name="pass" size="12" /> EOD; } $add_notimestamp .= ' '; } $refpage = htmlspecialchars($vars['refpage']); $add_assistant = edit_form_assistant(); $body = <<<EOD <div id="realview_outer"><div id="realview"></div><br /></div> <form action="{$script}" method="post"> <div class="edit_form" onmouseup="pukiwiki_pos()" onkeyup="pukiwiki_pos()"> {$template} {$addtag} <input type="hidden" name="cmd" value="mceedit" /> <input type="hidden" name="page" value="{$s_page}" /> <input type="hidden" name="digest" value="{$s_digest}" /> <input type="hidden" name="id" value="{$s_id}" /> <input type="hidden" name="before" value="{$before}" /> <textarea class="mceEditor" id="msg" name="msg" rows="{$rows}" cols="{$cols}" onselect="pukiwiki_apv(this.form.page.value,this)" onfocus="pukiwiki_apv(this.form.page.value,this)" onkeyup="pukiwiki_apv(this.form.page.value,this)" onmouseup="pukiwiki_apv(this.form.page.value,this)">{$s_postdata}</textarea> <br /> {$add_assistant} <br /> <input type="submit" name="write" value="{$_button['update']}" accesskey="s" /> {$add_top} {$add_ajax} {$add_notimestamp} <input type="submit" name="cancel" value="{$_button['cancel']}" accesskey="c" /> <textarea name="original" rows="1" cols="1" style="display:none">{$s_original}</textarea> </div> </form> EOD; // <input type="submit" name="preview" value="$btn_preview" accesskey="p" /> // if (isset($vars['help'])) { // $body .= $hr . catrule(); // } else { // $body .= '<ul><li><a href="' . // $script . '?cmd=edit&help=true&page=' . $r_page . // '">' . $_string['help'] . '</a></li></ul>'; // } if ($ajax) { global $head_tags; $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/msxml.js"></script>'; // $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/textloader.js"></script>'; $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'ajax/realedit.js"></script>'; $head_tags[] = ' <script language="javascript" type="text/javascript" src="' . SKIN_URI . 'tiny_mce/tiny_mce.js"></script>'; //TinyMCE $head_tags[] = ' <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "specific_textareas", editor_selector : "mceEditor" }); </script>'; //TinyMCE } return $body; }
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"; } }
function plugin_article_convert() { global $script, $vars, $digest; // global $_btn_article, $_btn_name, $_btn_subject; static $numbers = array(); $_btn_name = _('Name: '); $_btn_article = _('Submit'); $_btn_subject = _('Subject: '); // if (PKWK_READONLY) return ''; // Show nothing if (auth::check_role('readonly')) { return ''; } // Show nothing if (!isset($numbers[$vars['page']])) { $numbers[$vars['page']] = 0; } $article_no = $numbers[$vars['page']]++; $helptags = edit_form_assistant(); $s_page = htmlspecialchars($vars['page']); $s_digest = htmlspecialchars($digest); $name_cols = PLUGIN_ARTICLE_NAME_COLS; $subject_cols = PLUGIN_ARTICLE_SUBJECT_COLS; $article_rows = PLUGIN_ARTICLE_ROWS; $article_cols = PLUGIN_ARTICLE_COLS; $string = <<<EOD <form action="{$script}" method="post"> <div class="articleform" onmouseup="pukiwiki_pos()" onkeyup="pukiwiki_pos()"> <input type="hidden" name="article_no" value="{$article_no}" /> <input type="hidden" name="plugin" value="article" /> <input type="hidden" name="digest" value="{$s_digest}" /> <input type="hidden" name="refer" value="{$s_page}" /> <label for="_p_article_name_{$article_no}">{$_btn_name}</label> <input type="text" name="name" id="_p_article_name_{$article_no}" size="{$name_cols}" /><br /> <label for="_p_article_subject_{$article_no}">{$_btn_subject}</label> <input type="text" name="subject" id="_p_article_subject_{$article_no}" size="{$subject_cols}" /><br /> <textarea name="msg" rows="{$article_rows}" cols="{$article_cols}"> </textarea><br /> <input type="submit" name="article" value="{$_btn_article}" /> {$helptags} </div> </form> EOD; return $string; }
function plugin_comment_convert() { global $vars, $digest, $script; //, $_btn_comment, $_btn_name, $_msg_comment; static $numbers = array(); static $all_numbers = 0; static $comment_cols = PLUGIN_COMMENT_SIZE_MSG; $_btn_name = _("Name: "); $_btn_comment = _("Post Comment"); $_msg_comment = _("Comment: "); $auth_guide = ''; if (PKWK_READONLY == ROLE_AUTH) { exist_plugin('login'); $auth_guide = do_plugin_inline('login'); } // if (PKWK_READONLY) return ''; // Show nothing if (auth::check_role('readonly')) { return $auth_guide; } if (!isset($numbers[$vars['page']])) { $numbers[$vars['page']] = 0; } $comment_no = $numbers[$vars['page']]++; $comment_all_no = $all_numbers++; $options = func_num_args() ? func_get_args() : array(); list($user, $link, $disabled) = plugin_comment_get_nick(); if (in_array('noname', $options)) { $nametags = '<label for="_p_comment_comment_' . $comment_all_no . '">' . $_msg_comment . '</label>'; } else { $nametags = '<label for="_p_comment_name_' . $comment_all_no . '">' . $_btn_name . '</label>' . '<input type="text" name="name" id="_p_comment_name_' . $comment_all_no . '" size="' . PLUGIN_COMMENT_SIZE_NAME . '" value="' . htmlspecialchars($user) . '"' . $disabled . ' />' . "\n"; } $helptags = edit_form_assistant(); $nodate = in_array('nodate', $options) ? '1' : '0'; $above = in_array('above', $options) ? '1' : (in_array('below', $options) ? '0' : PLUGIN_COMMENT_DIRECTION_DEFAULT); $refpage = ''; $s_page = htmlspecialchars($vars['page']); $ticket = md5(MUTIME); if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) { $keyword = $ticket; $_SESSION[$keyword] = md5(get_ticket() . $digest); } $string = <<<EOD <br /> {$auth_guide} <form action="{$script}" method="post"> <div class="commentform" onmouseup="pukiwiki_pos()" onkeyup="pukiwiki_pos()"> <input type="hidden" name="refpage" value="{$refpage}" /> <input type="hidden" name="plugin" value="comment" /> <input type="hidden" name="refer" value="{$s_page}" /> <input type="hidden" name="comment_no" value="{$comment_no}" /> <input type="hidden" name="nodate" value="{$nodate}" /> <input type="hidden" name="above" value="{$above}" /> <input type="hidden" name="digest" value="{$digest}" /> <input type="hidden" name="ticket" value="{$ticket}" /> {$nametags} <input type="text" name="msg" id="_p_comment_comment_{$comment_all_no}" size="{$comment_cols}" /> <input type="submit" name="comment" value="{$_btn_comment}" /> {$helptags} </div> </form> EOD; return $string; }