use strict;
package SuikaWiki::Plugin::Registry;


our %Info;
$Info{q#WikiFormSelection#}->{Name} = q#WikiFormSelection#;
$Info{q#WikiFormSelection#}->{q#Version#} = q#2004.0831.0328#;
$Info{q#WikiFormSelection#}->{q#InterfaceVersion#} = q#2.9.1#;
$Info{q#WikiFormSelection#}->{q#mkpluginVersion#} = q#2.1.19#;
$Info{q#WikiFormSelection#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::WikiFormSelection10407310328071Kk0#;
$Info{q#WikiFormSelection#}->{RequiredModule} = [q#Error#, q#WikiFormCore#];
$Info{q#WikiFormSelection#}->{Description} = [[q#WikiFormSelection plugin module provides "selection" form controls.

Note that this module is translation of SuikaWiki 2 version of
WikiFormSelection plugin module.  Some rules should be reimplemented.#, q#en#, q##]];
$Info{q#WikiFormSelection#}->{License} = [[q#%%GPL%%#, q##, q##]];
$Info{q#WikiFormSelection#}->{Author} = [[[], [q##], [q##]]];
package SuikaWiki::Plugin::plugin::WikiFormSelection10407310328071Kk0;


#line 1 "(WikiPlugin module source selection.wp2, block Plugin/Use)"
my $WIKIRESOURCE;
use Message::Util::Error;
#line 1 "(WikiPlugin module WikiFormSelection, chunk 1)"

$SuikaWiki::Plugin::Rule{form_input}->{check} = {q#Parameter#, {q#value#, {q#Type#, q#text#, q#Default#, q#(auto)#, q#Description#, [[q#Form control value returned when selected#, q#en#, q##]]}, q#label#, {q#Type#, q#text#, q#Default#, q#(none)#, q#Description#, [[q#A label descripting the selection#, q#en#, q##]]}, q#default#, {q#Type#, q#boolean#, q#Default#, q#"0"#, q#Description#, [[q#Initial value#, q#en#, q##]]}, q#desription#, {q#Type#, q#text#, q#Default#, q#(none)#, q#Description#, [[q#Human readable description about this selection#, q#en#, q##]]}}, q#Description#, [[q#A boolean (true or false) selection#, q#en#, q##]], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;

#line 1 "(WikiPlugin module source selection.wp2, block FormattingRule[name()='[q#form-input#]/check']/Formatting)"
my $id = SuikaWiki::Plugin->module_package ('WikiFormCore')
->control_id ($o,
local_id => $p->{id},
require_local_id => 1);
my $check = $p->{-parent}->append_new_node
(type => '#element',
namespace_uri => q#http://www.w3.org/1999/xhtml#,
local_name => 'input');
$check->set_attribute (type => 'checkbox');
$check->set_attribute (name => $id->{local_id});
$p->{q#value#} = do { my $r = $f->parse_attr ($p=>q#value#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};$p->{q#default#} = do { my $r = $f->parse_attr ($p=>q#default#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};$p->{q#description#} = do { my $r = $f->parse_attr ($p=>q#description#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};
$check->set_attribute (checked => 'checked') if $p->{default};
$check->set_attribute (value => $p->{value}) if length $p->{value};
$check->set_attribute (disabled => 'disabled') if $o->{form}->{disabled};
$check->set_attribute (title => $p->{description})
if length $p->{description};
$f->parse_attr ($p=>q#label#, $o, -non_parsed_to_node => 1, %opt);
if ($p->{label}->count) {
$check->set_attribute (id => $id->{global_id});
my $label = $p->{-parent}->append_new_node
(type => '#element',
namespace_uri => q#http://www.w3.org/1999/xhtml#,
local_name => 'label');
$label->set_attribute (for => $id->{global_id});
$label->append_node ($p->{label});
$label->set_attribute (title => $p->{description})
if length $p->{description};
}}}
#line 1 "(WikiPlugin module WikiFormSelection, chunk 2)"
;

$SuikaWiki::Plugin::Rule{form_template}->{iif} = {q#after#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;

#line 1 "(WikiPlugin module source selection.wp2, block FormattingRule[name()='[q#form-template#]/iif']/After)"
my $condition = lc $o->{wiki}->{input}->parameter
('wikiform__'.$p->{source});
$condition =~ tr/\x09\x0A\x0D\x20//d;
my $template;
if (not $condition or $condition eq 'no' or $condition eq 'off' or
$condition eq 'false') {
$template = $p->{false};
} else {
$template = $p->{true};
}
if (length $template) {
try {
$p->{-result} .= SuikaWiki::Plugin->text_formatter ('form_template')
->replace ($template, param => $o);
} catch Message::Util::Formatter::error with {
my $err = shift;
SuikaWiki::Plugin->module_package ('Error')
->reporting_formatting_template_error
($err, $err->{option}->{param}->{wiki});
throw SuikaWiki::View::Implementation::error -type => 'ERROR_REPORTED';
};      
}}, q#Parameter#, {q#source#, {q#Type#, q#id#, q#Default#, q#\#REQUIRED#, q#Description#, [[q#Source field name#, q#en#, q##]]}, q#false#, {q#Type#, q#template#, q#Default#, q#(none)#, q#Description#, [[q#Template evaluated when condition is "no" / "off" / "false" / 0 / undef.#, q#en#, q##]]}, q#true#, {q#Type#, q#template#, q#Default#, q#(none)#, q#Description#, [[q#Template eveluated when condition is not false.#, q#en#, q##]]}}, q#Description#, [[q#Evaluates and returns given template selected by condition#, q#en#, q##]]}
#line 1 "(WikiPlugin module WikiFormSelection, chunk 4)"
;
package SuikaWiki::Plugin::Registry;

$Info{q#WikiFormSelection#}->{provide} = {q#rule#, {q#form_input#, [q#check#], q#form_template#, [q#iif#]}};

1;
