2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
5 // $Id: edit.inc.php,v 1.9 2003/06/05 05:00:45 arino Exp $
9 function plugin_edit_action()
11 global $vars,$_title_edit;
13 check_editable($vars['page']);
15 if (array_key_exists('preview',$vars) or array_key_exists('template',$vars)) {
16 return plugin_edit_preview();
18 else if (array_key_exists('write',$vars)) {
19 return plugin_edit_write();
22 $postdata = @join('',get_source($vars['page']));
23 if ($postdata == '') {
24 $postdata = auto_template($vars['page']);
27 return array('msg'=>$_title_edit,'body'=>edit_form($vars['page'],$postdata));
30 function plugin_edit_preview()
33 global $_title_preview,$_msg_preview,$_msg_preview_delete;
35 if (array_key_exists('template_page',$post) and is_page($post['template_page']))
37 $post['msg'] = join('',get_source($post['template_page']));
38 // ¸«½Ð¤·¤Î¸ÇÍIDÉô¤òºï½ü
39 $post['msg'] = preg_replace('/^(\*{1,3}.*)\[#[A-Za-z][\w-]+\](.*)$/m','$1$2',$post['msg']);
42 // ¼ê½ñ¤¤Î#freeze¤òºï½ü
43 $post['msg'] = preg_replace('/^#freeze\s*$/m','',$post['msg']);
45 if (!empty($post['add']))
49 $postdata = $post['msg']."\n\n".@join('',get_source($post['page']));
53 $postdata = @join('',get_source($post['page']))."\n\n".$post['msg'];
58 $postdata = $post['msg'];
61 $body = "$_msg_preview<br />\n";
64 $body .= "<strong>$_msg_preview_delete</strong>";
70 $postdata = make_str_rules($postdata);
71 $postdata = explode("\n",$postdata);
72 $postdata = drop_submit(convert_html($postdata));
80 $body .= edit_form($post['page'],$post['msg'],$post['digest'],FALSE);
82 return array('msg'=>$_title_preview,'body'=>$body);
85 // ½ñ¤¹þ¤ß¤â¤·¤¯¤ÏÄɲä⤷¤¯¤Ï¥³¥á¥ó¥È¤ÎÁÞÆþ
86 function plugin_edit_write()
88 global $script,$post,$vars;
89 global $_title_collided,$_msg_collided_auto,$_msg_collided,$_title_deleted;
93 // ¼ê½ñ¤¤Î#freeze¤òºï½ü
94 $post['msg'] = preg_replace('/^#freeze\s*$/m','',$post['msg']);
96 $postdata_input = $post['msg'];
98 if (!empty($post['add'])) {
99 if (!empty($post['add_top'])) {
100 $postdata = $post['msg'];
102 $postdata .= @join('',get_source($post['page']));
105 $postdata = @join('',get_source($post['page']));
107 $postdata .= $post['msg'];
111 $postdata = $post['msg'];
114 $oldpagesrc = join('',get_source($post['page']));
115 $oldpagemd5 = md5($oldpagesrc);
117 if ($oldpagemd5 != $post['digest']) {
118 $retvars['msg'] = $_title_collided;
120 $post['digest'] = $vars['digest'] = $oldpagemd5;
121 list($postdata_input,$auto) = do_update_diff($oldpagesrc,$postdata_input,$post['original']);
123 $retvars['body'] = ($auto ? $_msg_collided_auto : $_msg_collided)."\n";
126 global $do_update_diff_table;
127 $retvars['body'] .= $do_update_diff_table;
130 $retvars['body'] .= edit_form($post['page'],$postdata_input,$oldpagemd5,FALSE);
133 $notimestamp = !empty($post['notimestamp']);
134 page_write($post['page'],$postdata,$notimestamp);
136 if ($postdata != '') {
137 header("Location: $script?".rawurlencode($post['page']));
141 $retvars['msg'] = $_title_deleted;
142 $retvars['body'] = str_replace('$1',htmlspecialchars($post['page']),$_title_deleted);