X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/2e8d5c5adee8038440f935412888fb6dcf03ff6e..83be2f2d09c550b033101cdfe7b843e9893e0aa4:/IkiWiki/CGI.pm?ds=inline diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 5aa744c94..e8df1fe11 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -157,7 +157,8 @@ sub cgi_signin ($$) { #{{{ force => 1); run_hooks(formbuilder_setup => sub { - shift->(form => $form, cgi => $q, session => $session); + shift->(form => $form, cgi => $q, session => $session, + buttons => $buttons); }); decode_form_utf8($form); @@ -228,7 +229,8 @@ sub cgi_prefs ($$) { #{{{ my $buttons=["Save Preferences", "Logout", "Cancel"]; run_hooks(formbuilder_setup => sub { - shift->(form => $form, cgi => $q, session => $session); + shift->(form => $form, cgi => $q, session => $session, + buttons => $buttons); }); $form->field(name => "do", type => "hidden"); @@ -304,6 +306,7 @@ sub cgi_editpage ($$) { #{{{ eval q{use CGI::FormBuilder}; error($@) if $@; my $form = CGI::FormBuilder->new( + title => "editpage", fields => \@fields, charset => "utf-8", method => 'POST', @@ -321,7 +324,8 @@ sub cgi_editpage ($$) { #{{{ ); run_hooks(formbuilder_setup => sub { - shift->(form => $form, cgi => $q, session => $session); + shift->(form => $form, cgi => $q, session => $session, + buttons => \@buttons); }); decode_form_utf8($form); @@ -402,12 +406,12 @@ sub cgi_editpage ($$) { #{{{ preprocess($page, $page, filter($page, $page, $form->field('editcontent')), 0, 1)))); } - else { + elsif ($form->submitted eq "Save Page") { $form->tmpl_param("page_preview", ""); } $form->tmpl_param("page_conflict", ""); - if (! $form->submitted || $form->submitted eq "Preview" || + if ($form->submitted ne "Save Page" || ! $form->validate) { if ($form->field("do") eq "create") { my @page_locs; @@ -497,8 +501,11 @@ sub cgi_editpage ($$) { #{{{ else { # save page check_canedit($page, $q, $session); - if (! -e "$config{srcdir}/$file" && - $form->field("do") ne "create") { + + my $exists=-e "$config{srcdir}/$file"; + + if ($form->field("do") ne "create" && + ! $exists && ! -e "$config{underlaydir}/$file") { $form->tmpl_param("page_gone", 1); $form->field(name => "do", value => "create", force => 1); $form->tmpl_param("page_select", 0); @@ -509,8 +516,7 @@ sub cgi_editpage ($$) { #{{{ print misctemplate($form->title, $form->render(submit => \@buttons)); return; } - elsif (-e "$config{srcdir}/$file" && - $form->field("do") eq "create") { + elsif ($form->field("do") eq "create" && $exists) { $form->tmpl_param("creation_conflict", 1); $form->field(name => "do", value => "edit", force => 1); $form->tmpl_param("page_select", 0); @@ -557,7 +563,7 @@ sub cgi_editpage ($$) { #{{{ $message=$form->field('comments'); } - if ($form->field("do") eq "create") { + if (! $exists) { rcs_add($file); }