function plugin_edit_preview() { global $vars; global $_title_preview, $_msg_preview, $_msg_preview_delete; $page = isset($vars['page']) ? $vars['page'] : ''; // Loading template if (isset($vars['template_page']) && is_page($vars['template_page'])) { $vars['msg'] = join('', get_source($vars['template_page'])); // Cut fixed anchors $vars['msg'] = preg_replace('/^(\\*{1,3}.*)\\[#[A-Za-z][\\w-]+\\](.*)$/m', '$1$2', $vars['msg']); } $vars['msg'] = preg_replace(PLUGIN_EDIT_FREEZE_REGEX, '', $vars['msg']); $postdata = $vars['msg']; if (isset($vars['add']) && $vars['add']) { if (isset($vars['add_top']) && $vars['add_top']) { $postdata = $postdata . "\n\n" . @join('', get_source($page)); } else { $postdata = @join('', get_source($page)) . "\n\n" . $postdata; } } $body = $_msg_preview . '<br />' . "\n"; if ($postdata == '') { $body .= '<strong>' . $_msg_preview_delete . '</strong>'; } $body .= '<br />' . "\n"; if ($postdata) { $postdata = make_str_rules($postdata); $postdata = explode("\n", $postdata); $postdata = drop_submit(convert_html($postdata)); $body .= '<div id="preview">' . $postdata . '</div>' . "\n"; } $body .= edit_form($page, $vars['msg'], $vars['digest'], FALSE); return array('msg' => $_title_preview, 'body' => $body); }
function page_write($page, $postdata, $notimestamp = FALSE) { global $trackback; if (PKWK_READONLY) { return; } // Do nothing $postdata = make_str_rules($postdata); // Create and write diff $oldpostdata = is_page($page) ? join('', get_source($page)) : ''; $diffdata = do_diff($oldpostdata, $postdata); file_write(DIFF_DIR, $page, $diffdata); // Create backup make_backup($page, $postdata == ''); // Is $postdata null? // Create wiki text file_write(DATA_DIR, $page, $postdata, $notimestamp); if ($trackback) { // TrackBack Ping $_diff = explode("\n", $diffdata); $plus = join("\n", preg_replace('/^\\+/', '', preg_grep('/^\\+/', $_diff))); $minus = join("\n", preg_replace('/^-/', '', preg_grep('/^-/', $_diff))); tb_send($page, $plus, $minus); } links_update($page); }
function plugin_expand_action() { global $post; $postdata = $post['fullcontents']; $postdata = make_str_rules($postdata); $postdata = drop_submit(convert_html($postdata)); return array('msg' => _('View all contents'), 'body' => $postdata); }
function page_write($page,$postdata,$notimestamp=FALSE) { $postdata = make_str_rules($postdata); // 差分ファイルの作成 $oldpostdata = is_page($page) ? join('',get_source($page)) : ''; $diffdata = do_diff($oldpostdata,$postdata); file_write(DIFF_DIR,$page,$diffdata); // バックアップの作成 make_backup($page,$postdata == ''); // ファイルの書き込み file_write(DATA_DIR,$page,$postdata,$notimestamp); // TrackBack Ping の送信 // 「追加」行を抽出 $lines = join("\n",preg_replace('/^\+/','',preg_grep('/^\+/',explode("\n",$diffdata)))); tb_send($page,$lines); // linkデータベースを更新 links_update($page); }
function plugin_guiedit_preview() { global $vars; // global $_title_preview, $_msg_preview, $_msg_preview_delete; global $note_hr, $foot_explain; global $guiedit_use_fck; //FIXME $_msg_preview = _('To confirm the changes, click the button at the bottom of the page'); $_msg_preview_delete = _('(The contents of the page are empty. Updating deletes this page.)'); if ($guiedit_use_fck) { $postdata = Xhtml2WikiFactory::factory($vars['msg']); } if ($postdata) { $postdata = make_str_rules($postdata); $postdata = explode("\n", $postdata); $postdata = drop_submit(RendererFactory::factory($postdata, true)); } // テキスト編集の場合 if (!$guiedit_use_fck) { $body = $_msg_preview . '<br />' . "\n"; if ($postdata == '') { $body .= '<strong>' . $_msg_preview_delete . '</strong><br />' . "\n"; } else { $body .= '<br />' . "\n"; $body .= '<div id="preview">' . $postdata . '</div>' . "\n"; } $body .= plugin_guiedit_edit_form($vars['page'], $vars['msg'], $vars['digest'], FALSE); return array('msg' => $_title['preview'], 'body' => $body); } // 注釈 ksort($foot_explain, SORT_NUMERIC); $postdata .= !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : ''; // 通常の編集フォーム if (DEBUG) { $postdata .= '<hr />' . Utility::editForm($vars['page'], $vars['msg']); } plugin_guiedit_send_ajax($postdata); }
function page_write($page, $postdata, $notimestamp = FALSE) { global $trackback, $autoalias, $aliaspage; global $autoglossary, $glossarypage; global $use_spam_check; // if (PKWK_READONLY) return; // Do nothing if (auth::check_role('readonly')) { return; } // Do nothing if (is_page($page)) { $oldpostdata = get_source($page, TRUE, TRUE); } else { if (auth::is_check_role(PKWK_CREATE_PAGE)) { die_message(_('PKWK_CREATE_PAGE prohibits editing')); } $oldpostdata = ''; } $postdata = make_str_rules($postdata); // Create and write diff $diffdata = do_diff($oldpostdata, $postdata); $role_adm_contents = auth::check_role('role_adm_contents'); $links = array(); if ($trackback > 1 || $role_adm_contents && $use_spam_check['page_contents']) { $links = get_this_time_links($postdata, $diffdata); } // Blocking SPAM if ($role_adm_contents) { if ($use_spam_check['page_remote_addr'] && SpamCheck($_SERVER['REMOTE_ADDR'], 'ip')) { die_message('Writing was limited by IPBL (Blocking SPAM).'); } if ($use_spam_check['page_contents'] && SpamCheck($links)) { die_message('Writing was limited by DNSBL (Blocking SPAM).'); } if ($use_spam_check['page_write_proxy'] && is_proxy()) { die_message('Writing was limited by PROXY (Blocking SPAM).'); } } // Logging postdata postdata_write(); // Create diff text file_write(DIFF_DIR, $page, $diffdata); // Create backup make_backup($page, $postdata == ''); // Is $postdata null? // Create wiki text file_write(DATA_DIR, $page, $postdata, $notimestamp); if (function_exists('senna_update')) { senna_update($page, $oldpostdata, $postdata); } if ($trackback > 1) { // TrackBack Ping tb_send($page, $links); } unset($oldpostdata, $diffdata, $links); links_update($page); // Update autoalias.dat (AutoAliasName) if ($autoalias && $page == $aliaspage) { $aliases = get_autoaliases(); if (empty($aliases)) { // Remove @unlink(CACHE_DIR . PKWK_AUTOALIAS_REGEX_CACHE); } else { // Create or Update autolink_pattern_write(CACHE_DIR . PKWK_AUTOALIAS_REGEX_CACHE, get_autolink_pattern(array_keys($aliases), $autoalias)); } } // Update glossary.dat (AutoGlossary) if ($autoglossary && $page == $glossarypage) { $words = get_autoglossaries(); if (empty($words)) { // Remove @unlink(CACHE_DIR . PKWK_GLOSSARY_REGEX_CACHE); } else { // Create or Update autolink_pattern_write(CACHE_DIR . PKWK_GLOSSARY_REGEX_CACHE, get_glossary_pattern(array_keys($words), $autoglossary)); } } log_write('update', $page); }
function plugin_mceedit_preview() { global $vars; // global $_title_preview, $_msg_preview, $_msg_preview_delete; $page = isset($vars['page']) ? $vars['page'] : ''; // Loading template if (isset($vars['template_page']) && is_page($vars['template_page'])) { $vars['msg'] = join('', get_source($vars['template_page'])); // Cut fixed anchors $vars['msg'] = preg_replace('/^(\\*{1,3}.*)\\[#[A-Za-z][\\w-]+\\](.*)$/m', '$1$2', $vars['msg']); } // 手書きの#freezeを削除 $vars['msg'] = preg_replace(PLUGIN_EDIT_FREEZE_REGEX, '', $vars['msg']); $postdata = $vars['msg']; if (isset($vars['add']) && $vars['add']) { if (isset($vars['add_top']) && $vars['add_top']) { $postdata = $postdata . "\n\n" . @join('', get_source($page)); } else { $postdata = @join('', get_source($page)) . "\n\n" . $postdata; } } $body = _('To confirm the changes, click the button at the bottom of the page') . "<br />\n"; if ($postdata == '') { $body .= "<strong>" . _('(The contents of the page are empty. Updating deletes this page.)') . "</strong>"; } $body .= "<br />\n"; if ($postdata) { $postdata = make_str_rules($postdata); $postdata = explode("\n", $postdata); $postdata = drop_submit(convert_html($postdata)); $body .= '<div id="preview">' . $postdata . '</div>' . "\n"; } $body .= plugin_mceedit_edit_form($page, $vars['msg'], $vars['digest'], FALSE); return array('msg' => _('Preview of $1'), 'body' => $body); }
function plugin_guiedit_preview() { global $vars; // global $_title_preview, $_msg_preview, $_msg_preview_delete; global $note_hr, $foot_explain; global $guiedit_use_fck; //FIXME $_msg_preview = _('To confirm the changes, click the button at the bottom of the page'); $_msg_preview_delete = _('(The contents of the page are empty. Updating deletes this page.)'); if ($guiedit_use_fck) { // 構文の変換 require_once GUIEDIT_LIB_PATH . 'xhtml2wiki.php'; // $source = $vars['msg']; $vars['msg'] = xhtml2wiki($vars['msg']); } $postdata = $vars['msg']; if ($postdata) { $postdata = make_str_rules($postdata); $postdata = explode("\n", $postdata); $postdata = drop_submit(convert_html($postdata)); } // テキスト編集の場合 if (!$guiedit_use_fck) { $body = $_msg_preview . '<br />' . "\n"; if ($postdata == '') { $body .= '<strong>' . $_msg_preview_delete . '</strong><br />' . "\n"; } else { $body .= '<br />' . "\n"; $body .= '<div id="preview">' . $postdata . '</div>' . "\n"; } $body .= plugin_guiedit_edit_form($vars['page'], $vars['msg'], $vars['digest'], FALSE); return array('msg' => $_title['preview'], 'body' => $body); } // 注釈 ksort($foot_explain, SORT_NUMERIC); $postdata .= !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : ''; // 通常の編集フォーム if (GUIEDIT_DEBUG) { global $hr; $postdata .= $hr . edit_form($vars['page'], $vars['msg']); } plugin_guiedit_send_xml($postdata); }
function plugin_edit_preview() { global $vars, $layout_pages; global $qblog_defaultpage; $qm = get_qm(); $qt = get_qt(); $page = isset($vars['page']) ? $vars['page'] : ''; $layout_name = ''; if (array_key_exists($page, $layout_pages)) { $layout_name = $layout_pages[$page]; } // Loading template if (isset($vars['template_page']) && is_page($vars['template_page'])) { $vars['msg'] = join('', get_source($vars['template_page'])); // Cut fixed anchors $vars['msg'] = preg_replace('/^(\\*{1,3}.*)\\[#[A-Za-z][\\w-]+\\](.*)$/m', '$1$2', $vars['msg']); } $vars['msg'] = preg_replace(PLUGIN_EDIT_FREEZE_REGEX, '', $vars['msg']); $postdata = $vars['msg']; if (isset($vars['add']) && $vars['add']) { if (isset($vars['add_top']) && $vars['add_top']) { $postdata = $postdata . "\n\n" . @join('', get_source($page)); } else { $postdata = @join('', get_source($page)) . "\n\n" . $postdata; } } $msgstyle = ' <style type="text/css"> #preview_notice { background-color: #ff9; padding: 2px 0; font-weight: bold; text-align: center; border-radius: 10px 10px 0 0; -moz-border-radius: 10px 10px 0 0; -ms-filter: "alpha( opacity=20 )"; /* IE8 */ filter: alpha( opacity=20 ); /* IE7 */ opacity: 0.8; position: fixed; width: 550px; bottom: 0; left: 50%; margin-left: -275px; z-index: 30; } ul.toolbar_menu li.preview_notice, ul.toolbar_menu_min li.preview_notice { padding: 0 2px; margin: 0 auto; background-color: #ff9; color: #000; font-weight: bold; background-image: none; cursor: auto; text-align: center; } </style> '; if ($layout_name !== '') { $msgstyle .= ' <style type="text/css"> #preview_body { display: none; } </style> '; } $qt->appendv_once('plugin_edit_preview', 'beforescript', $msgstyle); $addscript = ' <script type="text/javascript"> $(function(){ $("div.toolbar_upper ul.toolbar_menu, div.toolbar_upper ul.toolbar_menu_min").prepend("<li class=\\"preview_notice\\">' . $qm->m['plg_edit']['label_preview'] . '</li>") .children(":nth-child(2)").remove(); $("#preview_notice") .css("cursor", "pointer") .click(function(){ $("#msg").focus(); }); }); </script> '; if ($layout_name !== '') { $addscript .= ' <script type="text/javascript"> $(function(){ var $layout = $("div.preview_highlight").parent(), $div = $("<div></div>"), $div2 = $("<div>' . h($layout_name) . 'のプレビュー</div>"); var paddingWidth = parseInt($layout.css("padding-left").match(/\\d+/)[0]) + parseInt($layout.css("padding-right").match(/\\d+/)[0]), paddingHeight = parseInt($layout.css("padding-top").match(/\\d+/)[0]) + parseInt($layout.css("padding-bottom").match(/\\d+/)[0]); $div.css({ width: $layout.width() + paddingWidth + 10, height: $layout.height() + paddingHeight + 10, position: "absolute", left: $layout.offset().left - 8, top: $layout.offset().top -8, border: "3px solid #FF6600", zIndex: 999, opacity: 0 }); $("body").append($div); $div2.css({ width: 160, height: 30, position: "absolute", left: $div.offset().left + $div.width() + 10 - 160, top: $div.offset().top -22, backgroundColor: "#FF6600", color: "white", textAlign: "center", fontSize: 14, lineHeight: "30px", zIndex: 1000, opacity: 0 }); $("body").append($div2); $("html, body").animate({scrollTop: $div2.offset().top}, 400, function(){ $div.animate({opacity: 1}, 600); $div2.animate({opacity: 1}, 600); }); }); </script> '; } $qt->appendv_once('plugin_edit_preview_js', 'beforescript', $addscript); $preview_notice = '<div id="preview_notice">' . $qm->m['fmt_msg_preview'] . '</div>' . "\n"; $qt->appendv_once('plugin_edit_preview_block', 'lastscript', $preview_notice); $body = '<div id="preview_body">'; if ($postdata == '') { $body .= '<strong>' . $qm->m['fmt_msg_preview_delete'] . '</strong>'; } $body .= '<br />' . "\n"; if ($postdata) { if ($page !== $qblog_defaultpage && is_qblog()) { $postdata = "#qblog_head\n" . $postdata; } $postdata = make_str_rules($postdata); $postdata = explode("\n", $postdata); $postdata = drop_submit(convert_html($postdata)); $body .= $postdata; } $body .= '</div>' . "\n"; $body .= edit_form($page, $vars['msg'], $vars['digest'], FALSE); return array('msg' => $qm->m['fmt_title_preview'], 'body' => $body); }
function process() { $qm = get_qm(); $qt = get_qt(); $this->init(); $this->check(); $this->sections->set_section($this->id, $this->postdata, $this->level); $msgstyle = ' <style type="text/css"> #preview_notice { background-color: #ff9; padding: 2px 0; font-weight: bold; text-align: center; border-radius: 10px 10px 0 0; -moz-border-radius: 10px 10px 0 0; -ms-filter: "alpha( opacity=20 )"; /* IE8 */ filter: alpha( opacity=20 ); /* IE7 */ opacity: 0.8; position: fixed; width: 550px; bottom: 0; left: 50%; margin-left: -275px; z-index: 30; } ul.toolbar_menu li.preview_notice, ul.toolbar_menu_min li.preview_notice { padding: 0 2px; margin: 0 auto; background-color: #ff9; color: #000; font-weight: bold; background-image: none; cursor: auto; text-align: center; } </style> '; $qt->appendv_once('plugin_secedit_preview', 'beforescript', $msgstyle); $addscript = ' <script type="text/javascript"> $(function(){ $("div.toolbar_upper ul.toolbar_menu, div.toolbar_upper ul.toolbar_menu_min").prepend("<li class=\\"preview_notice\\">' . $qm->m['plg_edit']['label_preview'] . '</li>") .children(":nth-child(2)").remove(); $("#preview_notice") .css("cursor", "pointer") .click(function(){ $("#msg").focus(); }); }); </script> '; $qt->appendv_once('plugin_secedit_preview_js', 'beforescript', $addscript); $preview_notice = '<div id="preview_notice">' . $qm->m['fmt_msg_preview'] . '</div>' . "\n"; $qt->appendv_once('plugin_secedit_preview_block', 'lastscript', $preview_notice); $body = ''; if ($this->postdata == '') { $body .= '<strong>' . $qm->m['fmt_msg_preview_delete'] . '</strong>'; } $body .= '<br />' . "\n"; if ($this->postdata) { $src = make_str_rules($this->postdata); $src = explode("\n", $src); $src = drop_submit(convert_html($src)); $body .= $src; } $body = '<div id="preview_body">' . "\n" . $body . "\n" . '</div>'; $body .= $this->form(); return array('msg' => $qm->m['fmt_title_preview'], 'body' => $body); }
function process() { global $_title_preview, $_msg_preview, $_msg_preview_delete; $this->init(); $this->check(); $this->sections->set_section($this->id, $this->postdata, $this->level); $msg = $_msg_preview . "<br />\n"; $msg .= $this->sections->get_source() === '' ? "<strong>{$_msg_preview_delete}</strong>" : ''; $msg .= "<br />\n"; $preview = ''; if ($this->postdata !== '') { $src = preg_replace(PLUGIN_SECEDIT_FREEZE_REGEX, '', $this->postdata); $src = make_str_rules($src); $preview = '<div id="preview">' . drop_submit(convert_html($src)) . "</div>\n"; } return array('msg' => $_title_preview, 'body' => $msg . $preview . $this->form()); }