po: favor the type of linking page's masterpage on page creation

Signed-off-by: intrigeri <intrigeri@boum.org>
master
intrigeri 2009-08-28 13:12:58 +02:00 committed by Joey Hess
parent 18ddf727d1
commit 5136c22eed
1 changed files with 17 additions and 4 deletions

View File

@ -531,10 +531,23 @@ sub formbuilder (@) {
if ($form->field("do") eq "create") { if ($form->field("do") eq "create") {
foreach my $field ($form->field) { foreach my $field ($form->field) {
next unless "$field" eq "type"; next unless "$field" eq "type";
if ($field->type eq 'select') { next unless $field->type eq 'select';
# remove po from the list of types my $orig_value = $field->value;
my @types = grep { $_->[0] ne 'po' } $field->options; # remove po from the list of types
$field->options(\@types) if @types; my @types = grep { $_->[0] ne 'po' } $field->options;
$field->options(\@types) if @types;
# favor the type of linking page's masterpage
if ($orig_value eq 'po') {
my ($from, $type);
if (defined $form->field('from')) {
($from)=$form->field('from')=~/$config{wiki_file_regexp}/;
$from = masterpage($from);
}
if (defined $from && exists $pagesources{$from}) {
$type=pagetype($pagesources{$from});
}
$type=$config{default_pageext} unless defined $type;
$field->value($type) ;
} }
} }
} }