X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/46a80d9cbe249d0acba26f1378d30c951f2f9cfd..83be2f2d09c550b033101cdfe7b843e9893e0aa4:/IkiWiki/CGI.pm?ds=sidebyside diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index d3f0203d8..e8df1fe11 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -138,7 +138,6 @@ sub cgi_signin ($$) { #{{{ my $form = CGI::FormBuilder->new( title => "signin", name => "signin", - header => 1, charset => "utf-8", method => 'POST', required => 'NONE', @@ -158,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); @@ -229,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"); @@ -305,8 +306,8 @@ sub cgi_editpage ($$) { #{{{ eval q{use CGI::FormBuilder}; error($@) if $@; my $form = CGI::FormBuilder->new( + title => "editpage", fields => \@fields, - header => 1, charset => "utf-8", method => 'POST', validate => { @@ -323,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); @@ -404,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; @@ -499,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); @@ -511,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); @@ -559,7 +563,7 @@ sub cgi_editpage ($$) { #{{{ $message=$form->field('comments'); } - if ($form->field("do") eq "create") { + if (! $exists) { rcs_add($file); }