+sub removal_confirm ($$@) { #{{{
+ my $q=shift;
+ my $session=shift;
+ my $attachment=shift;
+ my @pages=@_;
+
+ foreach my $page (@pages) {
+ check_canremove($page, $q, $session);
+ }
+
+ # Save current form state to allow returning to it later
+ # without losing any edits.
+ # (But don't save what button was submitted, to avoid
+ # looping back to here.)
+ # Note: "_submit" is CGI::FormBuilder internals.
+ $q->param(-name => "_submit", -value => "");
+ $session->param(postremove => scalar $q->Vars);
+ IkiWiki::cgi_savesession($session);
+
+ my ($f, $buttons)=confirmation_form($q, $session);
+ $f->title(sprintf(gettext("confirm removal of %s"),
+ join(", ", map { pagetitle($_) } @pages)));
+ $f->field(name => "page", type => "hidden", value => \@pages, force => 1);
+ if (defined $attachment) {
+ $f->field(name => "attachment", type => "hidden",
+ value => $attachment, force => 1);
+ }
+
+ IkiWiki::showform($f, $buttons, $session, $q);
+ exit 0;
+} #}}}
+
+sub postremove ($) { #{{{
+ my $session=shift;
+
+ # Load saved form state and return to edit form.
+ my $postremove=CGI->new($session->param("postremove"));
+ $session->clear("postremove");
+ IkiWiki::cgi_savesession($session);
+ IkiWiki::cgi($postremove, $session);
+} #}}}
+