/[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.4 - (hide annotations) (download)
Fri Jan 16 07:50:17 2004 UTC (22 years, 6 months ago) by wakaba
Branch: MAIN
Changes since 1.3: +22 -6 lines
(form-template/text): New rule

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24