summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2009-01-02 15:50:47 +0100
committerintrigeri <intrigeri@boum.org>2009-01-02 16:02:25 +0100
commitfae3cef41a55dace8545429c0139d01b93c69307 (patch)
tree44d2b220d35c6fccc9691ed00604b4154e80448b /IkiWiki
parente5222db332190de20551bb18c5c46df1632e0e1d (diff)
po(formbuilder_setup): remove the rename/remove buttons on slave pages
This has to be done after the rename/remove plugins have added their buttons, so we set this hook to be run last. The canrename/canremove hooks already ensure this is forbidden at the backend level, so this is only UI sugar. Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/po.pm30
1 files changed, 25 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 80b874939..ff73a14e6 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -43,7 +43,7 @@ sub import {
hook(type => "canremove", id => "po", call => \&canremove);
hook(type => "canrename", id => "po", call => \&canrename);
hook(type => "editcontent", id => "po", call => \&editcontent);
- hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup);
+ hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup, last => 1);
hook(type => "formbuilder", id => "po", call => \&formbuilder);
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
@@ -447,11 +447,31 @@ sub formbuilder_setup (@) {
my $form=$params{form};
my $q=$params{cgi};
- return unless (defined $form->field("do") && $form->field("do") eq "create");
+ return unless defined $form->field("do");
- my $template=template("pocreatepage.tmpl");
- $template->param(LANG => $config{po_master_language}{name});
- $form->tmpl_param(message => $template->output);
+ if ($form->field("do") eq "create") {
+ # Warn the user: new pages must be written in master language.
+ my $template=template("pocreatepage.tmpl");
+ $template->param(LANG => $config{po_master_language}{name});
+ $form->tmpl_param(message => $template->output);
+ }
+ elsif ($form->field("do") eq "edit") {
+ # Remove the rename/remove buttons on slave pages.
+ # This has to be done after the rename/remove plugins have added
+ # their buttons, which is why this hook must be run last.
+ # The canrename/canremove hooks already ensure this is forbidden
+ # at the backend level, so this is only UI sugar.
+ if (istranslation($form->field("page"))) {
+ map {
+ for (my $i = 0; $i < @{$params{buttons}}; $i++) {
+ if (@{$params{buttons}}[$i] eq $_) {
+ delete @{$params{buttons}}[$i];
+ last;
+ }
+ }
+ } qw(Rename Remove);
+ }
+ }
}
# Do not allow to create pages of type po: they are automatically created.