ROLE_AUTH) { // die_message( _('PKWK_READONLY prohibits editing') ); //} $page = isset($vars['page']) ? $vars['page'] : ''; check_editable($page, true, true); //if (!is_page($page) && auth::is_check_role(PKWK_CREATE_PAGE)) { // die_message( _('PKWK_CREATE_PAGE prohibits editing') ); //} global $guiedit_use_fck; $guiedit_use_fck = isset($vars['text']) ? false : true; if ($guiedit_use_fck) { global $guiedit_pkwk_root; $guiedit_pkwk_root = '/hotdog/'; } if (GUIEDIT_FULL_SIZE) { $menubar = $sidebar = ''; $topicpath = false; } if (isset($vars['edit'])) { return plugin_guiedit_edit_data($page); } else if ($load_template_func && isset($vars['template'])) { return "timestanp"; return plugin_guiedit_template(); } else if (isset($vars['preview'])) { return plugin_guiedit_preview(); } else if (isset($vars['write'])) { return plugin_guiedit_write(); } else if (isset($vars['cancel'])) { return plugin_guiedit_cancel(); } $source = get_source($page); $postdata = $vars['original'] = join('', $source); if (isset($vars['text'])) { if (! empty($vars['id'])) { exist_plugin('edit'); $postdata = plugin_edit_parts($vars['id'], $source); if ($postdata === FALSE) { unset($vars['id']); $postdata = $vars['original']; } } if ($postdata == '') $postdata = auto_template($page); } return array('msg'=>$_title_edit, 'body'=>plugin_guiedit_edit_form($page, $postdata)); } // XML 形式で出力 function plugin_guiedit_send_xml($postdata) { // 文字コードを UTF-8 に変換 //$postdata = mb_convert_encoding($postdata, 'UTF-8', SOURCE_ENCODING); // 出力 header('Content-Type: application/xml; charset=UTF-8'); echo '' . "\n"; echo ''; exit; } // 編集するデータ function plugin_guiedit_edit_data($page) { global $vars; $source = get_source($vars['page']); $postdata = $vars['original'] = join('', $source); if (! empty($vars['id'])) { exist_plugin('edit'); $postdata = plugin_edit_parts($vars['id'], $source); if ($postdata === FALSE) { unset($vars['id']); $postdata = $vars['original']; } } if ($postdata == '') $postdata = auto_template($page); // 構文の変換 require_once(GUIEDIT_LIB_PATH . 'wiki2xhtml.php'); $postdata = guiedit_convert_html($postdata); plugin_guiedit_send_xml($postdata); } // テンプレート function plugin_guiedit_template() { global $vars; global $guiedit_use_fck; // テンプレートを取得 if (is_page($vars['template_page'])) { $vars['msg'] = join('', get_source($vars['template_page'])); $vars['msg'] = preg_replace('/^(\*{1,3}.*)\[#[A-Za-z][\w-]+\](.*)$/m', '$1$2', $vars['msg']); $vars['msg'] = preg_replace(PLUGIN_GUIEDIT_FREEZE_REGEX, '', $vars['msg']); } else if ($guiedit_use_fck) { exit; } if (!$guiedit_use_fck) { return plugin_guiedit_preview(); } // 構文の変換 require_once(GUIEDIT_LIB_PATH . 'wiki2xhtml.php'); $vars['msg'] = guiedit_convert_html($vars['msg']); plugin_guiedit_send_xml($vars['msg']); } // プレビュー 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 . '
' . "\n"; if ($postdata == '') { $body .= '' . $_msg_preview_delete . '
' . "\n"; } else { $body .= '
' . "\n"; $body .= '
' . $postdata . '
' . "\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_guiedit_write() { global $vars; global $guiedit_use_fck; if ($guiedit_use_fck) { // 構文の変換 require_once(GUIEDIT_LIB_PATH . 'xhtml2wiki.php'); $vars['msg'] = xhtml2wiki($vars['msg']); } $postdata = $vars['msg']; // 書き込み exist_plugin('edit'); require_once("edit.inc.php"); return plugin_edit_write(); } // キャンセル function plugin_guiedit_cancel() { global $vars; $location = 'Location: ' . get_script_uri() . '?' . rawurlencode($vars['page']); if (!empty($vars['id'])) { $location .= '#' . $vars['id']; } pkwk_headers_sent(); header($location); exit; } // 編集フォームの作成 function plugin_guiedit_edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE) { global $vars; global $load_template_func, $whatsnew; global $_button; global $notimeupdate; global $head_tags, $javascript; global $guiedit_use_fck;; // Newly generate $digest or not if ($digest === FALSE) $digest = md5(get_source($page, TRUE, TRUE)); $s_id = isset($vars['id']) ? htmlspecialchars($vars['id']) : ''; if (!$guiedit_use_fck) { $body = edit_form($page, $postdata, $digest, $b_template); $pattern = "/()/"; $replace = "$1guiedit$2\n" . ' ' . ' '; $body = preg_replace($pattern, $replace, $body); return $body; } require_once(GUIEDIT_LIB_PATH . 'guiedit.ini.php'); // フォームの値の設定 $s_digest = htmlspecialchars($digest); $s_page = htmlspecialchars($page); $s_original = htmlspecialchars($vars['original']); $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)); } // テンプレート $template = ''; if($load_template_func) { global $guiedit_non_list; $pages = array(); foreach(get_existpages() as $_page) { if ($_page == $whatsnew || check_non_list($_page)) continue; foreach($guiedit_non_list as $key) { $pos = strpos($_page . '/', $key . '/'); if ($pos !== FALSE && $pos == 0) continue 2; } $_s_page = htmlspecialchars($_page); $pages[$_page] = ' '; } ksort($pages); $s_pages = join("\n", $pages); $template = << $s_pages
EOD; } // チェックボックス「タイムスタンプを変更しない」 $add_notimestamp = ''; if ($notimeupdate != 0) { $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : ''; if ($notimeupdate == 2) { //if ($notimeupdate == 2 && auth::check_role('role_adm_contents')) { $add_notimestamp = ' ' . '' . "\n"; } $add_notimestamp = '' . "\n" . ' ' . '' . "\n" . $add_notimestamp . ' '; } // フォーム $body = <<
$template
$add_notimestamp
EOD; // JavaScript を有効にする $javascript = 1; $root = '/hotdog/'; $image = $root.'image'; $guiedit_root = '/hotdog/skin/guiedit/'; $fck_root = '/hotdog/skin/fckeditor/'; // ヘッダの設定 $head_tags[] = ' '; $head_tags[] = ' '; $head_tags[] = ' '; $head_tags[] = ' '; $head_tags[] = ' '; return $body; } ?>