/[pub]/suikawiki/script/misc/plugins/form/selection.pm
Suika

Contents of /suikawiki/script/misc/plugins/form/selection.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sun May 16 23:05:49 2010 UTC (15 years, 11 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
Branch point for: helowiki-2005
added latest .pm files

1 use strict;
2 package SuikaWiki::Plugin::Registry;
3
4
5 our %Info;
6 $Info{q#WikiFormSelection#}->{Name} = q#WikiFormSelection#;
7 $Info{q#WikiFormSelection#}->{q#Version#} = q#2004.0831.0328#;
8 $Info{q#WikiFormSelection#}->{q#InterfaceVersion#} = q#2.9.1#;
9 $Info{q#WikiFormSelection#}->{q#mkpluginVersion#} = q#2.1.19#;
10 $Info{q#WikiFormSelection#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::WikiFormSelection10407310328071Kk0#;
11 $Info{q#WikiFormSelection#}->{RequiredModule} = [q#Error#, q#WikiFormCore#];
12 $Info{q#WikiFormSelection#}->{Description} = [[q#WikiFormSelection plugin module provides "selection" form controls.
13
14 Note that this module is translation of SuikaWiki 2 version of
15 WikiFormSelection plugin module. Some rules should be reimplemented.#, q#en#, q##]];
16 $Info{q#WikiFormSelection#}->{License} = [[q#%%GPL%%#, q##, q##]];
17 $Info{q#WikiFormSelection#}->{Author} = [[[], [q##], [q##]]];
18 package SuikaWiki::Plugin::plugin::WikiFormSelection10407310328071Kk0;
19
20
21 #line 1 "(WikiPlugin module source selection.wp2, block Plugin/Use)"
22 my $WIKIRESOURCE;
23 use Message::Util::Error;
24 #line 1 "(WikiPlugin module WikiFormSelection, chunk 1)"
25
26 $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) = @_;
27
28 #line 1 "(WikiPlugin module source selection.wp2, block FormattingRule[name()='[q#form-input#]/check']/Formatting)"
29 my $id = SuikaWiki::Plugin->module_package ('WikiFormCore')
30 ->control_id ($o,
31 local_id => $p->{id},
32 require_local_id => 1);
33 my $check = $p->{-parent}->append_new_node
34 (type => '#element',
35 namespace_uri => q#http://www.w3.org/1999/xhtml#,
36 local_name => 'input');
37 $check->set_attribute (type => 'checkbox');
38 $check->set_attribute (name => $id->{local_id});
39 $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};
40 $check->set_attribute (checked => 'checked') if $p->{default};
41 $check->set_attribute (value => $p->{value}) if length $p->{value};
42 $check->set_attribute (disabled => 'disabled') if $o->{form}->{disabled};
43 $check->set_attribute (title => $p->{description})
44 if length $p->{description};
45 $f->parse_attr ($p=>q#label#, $o, -non_parsed_to_node => 1, %opt);
46 if ($p->{label}->count) {
47 $check->set_attribute (id => $id->{global_id});
48 my $label = $p->{-parent}->append_new_node
49 (type => '#element',
50 namespace_uri => q#http://www.w3.org/1999/xhtml#,
51 local_name => 'label');
52 $label->set_attribute (for => $id->{global_id});
53 $label->append_node ($p->{label});
54 $label->set_attribute (title => $p->{description})
55 if length $p->{description};
56 }}}
57 #line 1 "(WikiPlugin module WikiFormSelection, chunk 2)"
58 ;
59
60 $SuikaWiki::Plugin::Rule{form_template}->{iif} = {q#after#, sub {my ($f, $rule_name, $p, $o, %opt) = @_;
61
62 #line 1 "(WikiPlugin module source selection.wp2, block FormattingRule[name()='[q#form-template#]/iif']/After)"
63 my $condition = lc $o->{wiki}->{input}->parameter
64 ('wikiform__'.$p->{source});
65 $condition =~ tr/\x09\x0A\x0D\x20//d;
66 my $template;
67 if (not $condition or $condition eq 'no' or $condition eq 'off' or
68 $condition eq 'false') {
69 $template = $p->{false};
70 } else {
71 $template = $p->{true};
72 }
73 if (length $template) {
74 try {
75 $p->{-result} .= SuikaWiki::Plugin->text_formatter ('form_template')
76 ->replace ($template, param => $o);
77 } catch Message::Util::Formatter::error with {
78 my $err = shift;
79 SuikaWiki::Plugin->module_package ('Error')
80 ->reporting_formatting_template_error
81 ($err, $err->{option}->{param}->{wiki});
82 throw SuikaWiki::View::Implementation::error -type => 'ERROR_REPORTED';
83 };
84 }}, 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##]]}
85 #line 1 "(WikiPlugin module WikiFormSelection, chunk 4)"
86 ;
87 package SuikaWiki::Plugin::Registry;
88
89 $Info{q#WikiFormSelection#}->{provide} = {q#rule#, {q#form_input#, [q#check#], q#form_template#, [q#iif#]}};
90
91 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24