summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/po.pm
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2009-01-02 13:43:40 +0100
committerintrigeri <intrigeri@boum.org>2009-01-02 14:09:34 +0100
commit724dbabc4aecf26f6c6899cea823a38a6c0f4375 (patch)
tree8717316d04c89281f834df7ff44f003862ccadea /IkiWiki/Plugin/po.pm
parent12178c2a64be73021725e90cd6e2ecf1769324d1 (diff)
po: do not allow to create pages of type po
The main reason to do so is to bypass the "favor the type of linking page on page creation" logic, which is unsuitable when a broken link is clicked on a slave (PO) page. Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki/Plugin/po.pm')
-rw-r--r--IkiWiki/Plugin/po.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 61331edeb..68fd69283 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -44,6 +44,7 @@ sub import {
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", id => "po", call => \&formbuilder);
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
inject(name => "IkiWiki::bestlink", call => \&mybestlink);
@@ -452,6 +453,31 @@ sub formbuilder_setup (@) {
$form->tmpl_param(message => $template->output);
}
+# Do not allow to create pages of type po: they are automatically created.
+# The main reason to do so is to bypass the "favor the type of linking page
+# on page creation" logic, which is unsuitable when a broken link is clicked
+# on a slave (PO) page.
+sub formbuilder (@) {
+ my %params=@_;
+ my $form=$params{form};
+ my $q=$params{cgi};
+
+ return unless (defined $form->field("do") && $form->field("do") eq "create");
+
+ for my $field ($form->field) {
+ next unless "$field" eq "type";
+ if ($field->type eq 'select') {
+ # remove po from the types list
+ my @types = grep { $_ ne 'po' } $field->options;
+ $field->options(\@types) if scalar @types;
+ }
+ else {
+ # make sure the default value is not po;
+ # does this case actually happen?
+ debug "po(formbuilder) type field is not select - not implemented yet";
+ }
+ }
+}
# ,----
# | Injected functions