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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sun Feb 1 12:08:07 2004 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, release-3-0-0, HEAD
Branch point for: paragraph-200404, helowiki, helowiki-2005
New

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: WikiFormSelection
5     @FullName:
6     WikiForm: Selection
7     @Description:
8     @@@:
9     WikiFormSelection plugin module provides "selection" form controls.
10     \
11     Note that this module is translation of SuikaWiki 2 version of
12     WikiFormSelection plugin module. Some rules should be reimplemented.
13     @@lang: en
14     @License: %%GPL%%
15     @Author[list]:
16     Wakaba <[email protected]>
17     @Date.RCS: $Date: 2004/01/16 07:50:17 $
18     @RequiredModule[list]:
19     Error
20     WikiFormCore
21     @Use:
22     my $WIKIRESOURCE;
23     use Message::Util::Error;
24    
25     PluginConst:
26     @NS_XHTML1:
27     http://www.w3.org/1999/xhtml
28     @WIKIRESOURCE:
29     {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
30    
31     FormattingRule:
32     @Category[list]: form-input
33     @Name: check
34     @Description:
35     @@@: A boolean (true or false) selection
36     @@lang: en
37     @Parameter:
38     @@Name: default
39     @@Type: boolean
40     @@Default: "0"
41     @@Description:
42     @@@@: Initial value
43     @@@lang: en
44     @Parameter:
45     @@Name: desription
46     @@Type: text
47     @@Default: (none)
48     @@Description:
49     @@@@: Human readable description about this selection
50     @@@lang: en
51     @Parameter:
52     @@Name: label
53     @@Type: text
54     @@Default: (none)
55     @@Description:
56     @@@@: A label descripting the selection
57     @@@lang: en
58     @Parameter:
59     @@Name: value
60     @@Type: text
61     @@Default: (auto)
62     @@Description:
63     @@@@: Form control value returned when selected
64     @@@lang: en
65     @Formatting:
66     my $id = SuikaWiki::Plugin->module_package ('WikiFormCore')
67     ->control_id ($o,
68     local_id => $p->{id},
69     require_local_id => 1);
70     my $check = $p->{-parent}->append_new_node
71     (type => '#element',
72     namespace_uri => $NS_XHTML1,
73     local_name => 'input');
74     $check->set_attribute (type => 'checkbox');
75     $check->set_attribute (name => $id->{local_id});
76     __ATTRTEXT:%value__;__ATTRTEXT:%default__;__ATTRTEXT:%description__;
77     $check->set_attribute (checked => 'checked') if $p->{default};
78     $check->set_attribute (value => $p->{value}) if length $p->{value};
79     $check->set_attribute (disabled => 'disabled') if $o->{form}->{disabled};
80     $check->set_attribute (title => $p->{description})
81     if length $p->{description};
82    
83     __ATTRNODE:%label__;
84     if ($p->{label}->count) {
85     $check->set_attribute (id => $id->{global_id});
86     my $label = $p->{-parent}->append_new_node
87     (type => '#element',
88     namespace_uri => $NS_XHTML1,
89     local_name => 'label');
90     $label->set_attribute (for => $id->{global_id});
91     $label->append_node ($p->{label});
92     $label->set_attribute (title => $p->{description})
93     if length $p->{description};
94     }
95    
96     FormattingRule:
97     @Category[list]: form-template
98     @Name: iif
99     @Description:
100     @@@:
101     Evaluates and returns given template selected by condition
102     @@lang: en
103     @Parameter:
104     @@Name: false
105     @@Type: template
106     @@Default: (none)
107     @@Description:
108     @@@@:
109     Template evaluated when condition is "no" / "off" / "false" / 0 / undef.
110     @@@lang: en
111     @Parameter:
112     @@Name: source
113     @@Type: id
114     @@Default: #REQUIRED
115     @@Description:
116     @@@@: Source field name
117     @@@lang: en
118     @Parameter:
119     @@Name: true
120     @@Type: template
121     @@Default: (none)
122     @@Description:
123     @@@@:
124     Template eveluated when condition is not false.
125     @@@lang: en
126     @After:
127     my $condition = lc $o->{wiki}->{input}->parameter
128     ('wikiform__'.$p->{source});
129     $condition =~ tr/\x09\x0A\x0D\x20//d;
130     my $template;
131     if (not $condition or $condition eq 'no' or $condition eq 'off' or
132     $condition eq 'false') {
133     $template = $p->{false};
134     } else {
135     $template = $p->{true};
136     }
137    
138     if (length $template) {
139     try {
140     $p->{-result} .= SuikaWiki::Plugin->text_formatter ('form_template')
141     ->replace ($template, param => $o);
142     } catch Message::Util::Formatter::error with {
143     my $err = shift;
144     SuikaWiki::Plugin->module_package ('Error')
145     ->reporting_formatting_template_error
146     ($err, $err->{option}->{param}->{wiki});
147     ##TODO:
148     throw SuikaWiki::View::Implementation::error -type => 'ERROR_REPORTED';
149     };
150     }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24