/[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.6 - (hide annotations) (download)
Sat Feb 14 10:56:11 2004 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +9 -4 lines
Bug fix for labeling

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     $Date: 2004/02/01 12:16:05 $
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.1 $_->set_attribute (size => ($p->{size}||5)*2); ## Length
54     $_->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.3 push @class, 'require' if $o->{form}->{require}->{$p->{id}};
59 wakaba 1.1 $_->set_attribute (class => join ' ', @class) if @class;
60     $_->option (use_EmptyElemTag => 1);
61 wakaba 1.4 if ($p->{source}) {
62     $_->append_text ($o->{var}->{$p->{source}});
63 wakaba 1.3 } else {
64     __ATTRTEXT:%default__;
65     $_->set_attribute (value => $p->{default}); ## Default value
66     }
67 wakaba 1.1 }
68    
69     FormattingRule:
70 wakaba 1.4 @Category[list]: form-template
71     @Name: text
72     @Description:
73     @@@: Inputed text
74     @@lang:en
75     @Parameter:
76     @@Name: source
77     @@Type: ID
78     @@Default:(require)
79     @@Description:
80     @@@@: WikiForm control ID of the source field
81     @@@lang:en
82     @After:
83     $p->{-result} .= $o->{wiki}->{input}->parameter ('wikiform__'.$p->{source});
84    
85     FormattingRule:
86 wakaba 1.1 @Category[list]:
87     form-input
88     @Name: textarea
89     @Description:
90     @@@@: Multiline text input
91     @@@lang:en
92     @Formatting:
93 wakaba 1.3 __ATTRTEXT:%id__;__ATTRNODE:%label__;
94     my $id = SuikaWiki::Plugin->module_package ('WikiFormCore')
95     ->control_id ($o,
96     local_id => $p->{id},
97     require_local_id => 1);
98 wakaba 1.6 my $has_label = 0;
99 wakaba 1.3 if ($p->{label}->count) {
100 wakaba 1.6 $has_label = 1;
101 wakaba 1.3 for ($p->{-parent}->append_new_node
102     (type => '#element',
103     namespace_uri => $NS_XHTML1,
104     local_name => 'label')) {
105     $_->set_attribute (for => $id->{global_id});
106     $_->append_node ($p->{label});
107 wakaba 1.1 }
108     }
109    
110 wakaba 1.2 for ($p->{-parent}->append_new_node (type => '#element',
111     namespace_uri => $NS_XHTML1,
112     local_name => 'textarea')) {
113 wakaba 1.3 $_->set_attribute (name => $id->{local_id});
114 wakaba 1.6 $_->set_attribute (id => $id->{global_id}) if $has_label;
115 wakaba 1.1 __ATTRTEXT:%size__;__ATTRTEXT:%lines__;__ATTRTEXT:%description__;
116     $_->set_attribute (cols => ($p->{size}||5)*2); ## Length
117     $_->set_attribute (rows => ($p->{lines}||5)); ## Lines
118     $_->set_attribute (title => $p->{description}) if $p->{description};
119 wakaba 1.3 $_->set_attribute (disabled => 'disabled') if $o->{form}->{disabled};
120 wakaba 1.1 __ATTRTEXT:%class__;
121     my @class = split /\s+/, $p->{class};
122 wakaba 1.3 push @class, 'require' if $o->{form}->{require}->{$p->{id}};
123 wakaba 1.1 $_->set_attribute (class => join ' ', @class) if @class;
124 wakaba 1.3 ## ISSUE: Can't we separate this into stylesheet?
125     if ($o->{wiki}->{var}->{client}->{user_agent_name}
126     =~ m#^Mozilla/[0-4]\.#) {
127 wakaba 1.1 $_->set_attribute (wrap => 'virtual');
128     }
129 wakaba 1.4 __ATTRTEXT:%source__;
130     if ($p->{source}) {
131     $_->append_text ($o->{var}->{$p->{source}});
132 wakaba 1.1 } else {
133     __ATTRTEXT:%default__;
134     $_->append_text ($p->{default}); ## Default value
135     }
136     }
137    

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24