/[pub]/suikawiki/script/lib/SuikaWiki/Plugin/WikiFormText.wp2
Suika

Contents of /suikawiki/script/lib/SuikaWiki/Plugin/WikiFormText.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Tue Sep 21 03:18:21 2004 UTC (21 years, 10 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
Branch point for: helowiki, helowiki-2005
Changes since 1.8: +6 -3 lines
%m--wikipage-obsolete rule added

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: WikiFormText
5     @FullName:
6     WikiForm: Text input module
7     @Description:
8     This module provides text input fields of WikiForm implementation.
9 wakaba 1.6 @License: %%Perl%%
10 wakaba 1.1 @Author[list]:
11     Wakaba <[email protected]>
12 wakaba 1.6 @Date.RCS:
13 wakaba 1.9 $Date: 2004/07/25 06:54:29 $
14 wakaba 1.1 @RequiredModule[list]:
15     WikiFormCore
16    
17     PluginConst:
18     @NS_XHTML1:
19     http://www.w3.org/1999/xhtml
20    
21     FormattingRule:
22     @Category[list]:
23     form-input
24     @Name: text
25     @Description:
26     @@@@: Short text input (input[@type='text'])
27     @@@lang:en
28     @Formatting:
29 wakaba 1.3 __ATTRTEXT:%id__;__ATTRNODE:%label__;
30     my $id = SuikaWiki::Plugin->module_package ('WikiFormCore')
31     ->control_id ($o,
32     local_id => $p->{id},
33     require_local_id => 1);
34 wakaba 1.6 my $has_label = 0;
35 wakaba 1.3 if ($p->{label}->count) {
36 wakaba 1.6 $has_label = 1;
37 wakaba 1.1 for ($p->{-parent}->append_new_node
38     (type => '#element',
39     namespace_uri => $NS_XHTML1,
40     local_name => 'label')) {
41 wakaba 1.3 $_->set_attribute (for => $id->{global_id});
42     $_->append_node ($p->{label});
43 wakaba 1.1 }
44     }
45     for ($p->{-parent}->append_new_node
46     (type => '#element',
47     namespace_uri => $NS_XHTML1,
48     local_name => 'input')) {
49     $_->set_attribute (type => 'text');
50 wakaba 1.3 $_->set_attribute (name => $id->{local_id});
51 wakaba 1.6 $_->set_attribute (id => $id->{global_id}) if $has_label;
52 wakaba 1.3 __ATTRTEXT:%size__;__ATTRTEXT:%description__;
53 wakaba 1.8 $_->set_attribute (size => ($p->{size}||20)*2); ## Length
54 wakaba 1.1 $_->set_attribute (title => $p->{description}) if $p->{description};
55 wakaba 1.5 $_->set_attribute (disabled => 'disabled') if $o->{form}->{disabled};
56 wakaba 1.1 __ATTRTEXT:%class__;
57     my @class = split /\s+/, $p->{class};
58 wakaba 1.7 push @class, 'require' if $o->{form}->{require}->{id}->{$p->{id}};
59 wakaba 1.1 $_->option (use_EmptyElemTag => 1);
60 wakaba 1.8 __ATTRTEXT:%source__;__ATTRTEXT:%default__;
61 wakaba 1.4 if ($p->{source}) {
62 wakaba 1.9 my $v;
63 wakaba 1.8 if (ref $o->{var}->{source}->{$p->{source}}) {
64     my $d = $o->{var}->{source}->{$p->{source}}->(p=>$p,o=>$o);
65 wakaba 1.9 $v = $d->{value};
66 wakaba 1.8 push @class, @{$d->{class}||[]};
67     } else {
68 wakaba 1.9 $v = $o->{var}->{$p->{source}};
69 wakaba 1.8 }
70 wakaba 1.9 $_->set_attribute (value => ref $v eq 'ARRAY' ? join "\n", @$v :
71     ref $v ? '' . $v : $v);
72 wakaba 1.3 } else {
73     $_->set_attribute (value => $p->{default}); ## Default value
74     }
75 wakaba 1.8 $_->set_attribute (class => join ' ', @class) if @class;
76 wakaba 1.1 }
77    
78     FormattingRule:
79 wakaba 1.4 @Category[list]: form-template
80     @Name: text
81     @Description:
82     @@@: Inputed text
83     @@lang:en
84     @Parameter:
85     @@Name: source
86     @@Type: ID
87     @@Default:(require)
88     @@Description:
89     @@@@: WikiForm control ID of the source field
90     @@@lang:en
91     @After:
92     $p->{-result} .= $o->{wiki}->{input}->parameter ('wikiform__'.$p->{source});
93    
94     FormattingRule:
95 wakaba 1.1 @Category[list]:
96     form-input
97     @Name: textarea
98     @Description:
99     @@@@: Multiline text input
100     @@@lang:en
101     @Formatting:
102 wakaba 1.3 __ATTRTEXT:%id__;__ATTRNODE:%label__;
103     my $id = SuikaWiki::Plugin->module_package ('WikiFormCore')
104     ->control_id ($o,
105     local_id => $p->{id},
106     require_local_id => 1);
107 wakaba 1.6 my $has_label = 0;
108 wakaba 1.3 if ($p->{label}->count) {
109 wakaba 1.6 $has_label = 1;
110 wakaba 1.3 for ($p->{-parent}->append_new_node
111     (type => '#element',
112     namespace_uri => $NS_XHTML1,
113     local_name => 'label')) {
114     $_->set_attribute (for => $id->{global_id});
115     $_->append_node ($p->{label});
116 wakaba 1.1 }
117 wakaba 1.7 $p->{-parent}->append_new_node
118     (type => '#element',
119     namespace_uri => $NS_XHTML1,
120     local_name => 'br')
121     ->option (use_EmptyElemTag => 1);
122 wakaba 1.1 }
123    
124 wakaba 1.2 for ($p->{-parent}->append_new_node (type => '#element',
125     namespace_uri => $NS_XHTML1,
126     local_name => 'textarea')) {
127 wakaba 1.3 $_->set_attribute (name => $id->{local_id});
128 wakaba 1.6 $_->set_attribute (id => $id->{global_id}) if $has_label;
129 wakaba 1.1 __ATTRTEXT:%size__;__ATTRTEXT:%lines__;__ATTRTEXT:%description__;
130 wakaba 1.8 $_->set_attribute (cols => ($p->{size}||20)*2); ## Length
131 wakaba 1.1 $_->set_attribute (rows => ($p->{lines}||5)); ## Lines
132     $_->set_attribute (title => $p->{description}) if $p->{description};
133 wakaba 1.3 $_->set_attribute (disabled => 'disabled') if $o->{form}->{disabled};
134 wakaba 1.1 __ATTRTEXT:%class__;
135     my @class = split /\s+/, $p->{class};
136 wakaba 1.7 push @class, 'require' if $o->{form}->{require}->{id}->{$p->{id}};
137 wakaba 1.3 ## ISSUE: Can't we separate this into stylesheet?
138     if ($o->{wiki}->{var}->{client}->{user_agent_name}
139     =~ m#^Mozilla/[0-4]\.#) {
140 wakaba 1.1 $_->set_attribute (wrap => 'virtual');
141     }
142 wakaba 1.4 __ATTRTEXT:%source__;
143     if ($p->{source}) {
144 wakaba 1.8 if (ref $o->{var}->{source}->{$p->{source}}) {
145     my $d = $o->{var}->{source}->{$p->{source}}->(p=>$p,o=>$o);
146     $_->append_text ($d->{value});
147     push @class, @{$d->{class}||[]};
148     } else {
149     $_->append_text ($o->{var}->{$p->{source}});
150     }
151 wakaba 1.1 } else {
152     __ATTRTEXT:%default__;
153     $_->append_text ($p->{default}); ## Default value
154     }
155 wakaba 1.8 $_->set_attribute (class => join ' ', @class) if @class;
156 wakaba 1.1 }
157    

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24