2 package IkiWiki::Plugin::websetup;
9 hook(type => "sessioncgi", id => "websetup",
10 call => \&sessioncgi);
11 hook(type => "formbuilder_setup", id => "websetup",
12 call => \&formbuilder_setup);
15 sub showform ($$) { #{{{
19 if (! defined $session->param("name") ||
20 ! IkiWiki::is_admin($session->param("name"))) {
21 error(gettext("you are not logged in as an admin"));
24 eval q{use CGI::FormBuilder};
27 my $form = CGI::FormBuilder->new(
34 action => $config{cgiurl},
35 template => {type => 'div'},
36 stylesheet => IkiWiki::baseurl()."style.css",
38 my $buttons=["Save Setup", "Cancel"];
40 IkiWiki::decode_form_utf8($form);
41 IkiWiki::run_hooks(formbuilder_setup => sub {
42 shift->(form => $form, cgi => $cgi, session => $session,
45 IkiWiki::decode_form_utf8($form);
47 $form->field(name => "do", type => "hidden", value => "setup",
50 if (! $form->submitted) {
54 if ($form->submitted eq "Cancel") {
55 IkiWiki::redirect($cgi, $config{url});
58 elsif ($form->submitted eq 'Save Setup' && $form->validate) {
61 $form->text(gettext("Setup saved."));
64 IkiWiki::showform($form, $buttons, $session, $cgi);
67 sub sessioncgi ($$) { #{{{
71 if ($cgi->param("do") eq "setup") {
72 showform($cgi, $session);
77 sub formbuilder_setup (@) { #{{{
80 my $form=$params{form};
81 if ($form->title eq "preferences") {
82 push @{$params{buttons}}, "Wiki Setup";
83 if ($form->submitted && $form->submitted eq "Wiki Setup") {
84 showform($params{cgi}, $params{session});