| 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.2 |
@Date.RCS: $Date: 2003/11/25 12:39:40 $ |
| 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 |
|
|
__ATTRTEXT:%id__; |
| 29 |
|
|
my $CORE = SuikaWiki::Plugin->module_package ('WikiFormCore'); |
| 30 |
|
|
my $name = $CORE->get_ctrl_name ($p->{id}); |
| 31 |
|
|
my $id = $CORE->get_ctrl_id ($p->{id}, $o->{form_index_no}); |
| 32 |
|
|
if (defined $p->{label}) { |
| 33 |
|
|
for ($p->{-parent}->append_new_node |
| 34 |
|
|
(type => '#element', |
| 35 |
|
|
namespace_uri => $NS_XHTML1, |
| 36 |
|
|
local_name => 'label')) { |
| 37 |
|
|
$_->set_attribute (for => $id); |
| 38 |
|
|
__ATTRNODE:%label->{$_}__; |
| 39 |
|
|
} |
| 40 |
|
|
} |
| 41 |
|
|
for ($p->{-parent}->append_new_node |
| 42 |
|
|
(type => '#element', |
| 43 |
|
|
namespace_uri => $NS_XHTML1, |
| 44 |
|
|
local_name => 'input')) { |
| 45 |
|
|
$_->set_attribute (type => 'text'); |
| 46 |
|
|
$_->set_attribute (name => $name); ## Form-unique control name |
| 47 |
|
|
$_->set_attribute (id => $id); ## Document-unique element name |
| 48 |
|
|
__ATTRTEXT:%size__;__ATTRTEXT:%default__; |
| 49 |
|
|
__ATTRTEXT:%description__; |
| 50 |
|
|
$_->set_attribute (size => ($p->{size}||5)*2); ## Length |
| 51 |
|
|
$_->set_attribute (value => $p->{default}); ## Default value |
| 52 |
|
|
$_->set_attribute (title => $p->{description}) if $p->{description}; |
| 53 |
|
|
$_->set_attribute (disabled => 'disabled') if $o->{form_disabled}; |
| 54 |
|
|
__ATTRTEXT:%class__; |
| 55 |
|
|
my @class = split /\s+/, $p->{class}; |
| 56 |
|
|
push @class, 'require' if $o->{require}->{$p->{id}}; |
| 57 |
|
|
$_->set_attribute (class => join ' ', @class) if @class; |
| 58 |
|
|
$_->option (use_EmptyElemTag => 1); |
| 59 |
|
|
} |
| 60 |
|
|
|
| 61 |
|
|
FormattingRule: |
| 62 |
|
|
@Category[list]: |
| 63 |
|
|
form-input |
| 64 |
|
|
@Name: textarea |
| 65 |
|
|
@Description: |
| 66 |
|
|
@@@@: Multiline text input |
| 67 |
|
|
@@@lang:en |
| 68 |
|
|
@Formatting: |
| 69 |
|
|
my $name; |
| 70 |
|
|
my $id; |
| 71 |
|
|
if (defined $o->{var}->{content}) { |
| 72 |
|
|
__ATTRTEXT:%id__; |
| 73 |
|
|
$name = $p->{id}; |
| 74 |
|
|
} else { |
| 75 |
|
|
my $CORE = SuikaWiki::Plugin->module_package ('WikiFormCore'); |
| 76 |
|
|
$name = $CORE->get_ctrl_name ($p->{id}); |
| 77 |
|
|
$id = $CORE->get_ctrl_id ($p->{id}, $o->{form_index_no}); |
| 78 |
|
|
} |
| 79 |
|
|
|
| 80 |
|
|
if ($id && defined $p->{label}) { |
| 81 |
wakaba |
1.2 |
for ($p->{-parent}->append_new_node (type => '#element', |
| 82 |
|
|
namespace_uri => $NS_XHTML1, |
| 83 |
|
|
local_name => 'label')) { |
| 84 |
wakaba |
1.1 |
$_->set_attribute (for => $id); |
| 85 |
|
|
__ATTRNODE:%label->{$_}__; |
| 86 |
|
|
} |
| 87 |
|
|
} |
| 88 |
|
|
|
| 89 |
wakaba |
1.2 |
for ($p->{-parent}->append_new_node (type => '#element', |
| 90 |
|
|
namespace_uri => $NS_XHTML1, |
| 91 |
|
|
local_name => 'textarea')) { |
| 92 |
wakaba |
1.1 |
$_->set_attribute (name => $name); ## Form-unique control name |
| 93 |
|
|
$_->set_attribute (id => $id) if $id; ## Document-unique element name |
| 94 |
|
|
__ATTRTEXT:%size__;__ATTRTEXT:%lines__;__ATTRTEXT:%description__; |
| 95 |
|
|
$_->set_attribute (cols => ($p->{size}||5)*2); ## Length |
| 96 |
|
|
$_->set_attribute (rows => ($p->{lines}||5)); ## Lines |
| 97 |
|
|
$_->set_attribute (title => $p->{description}) if $p->{description}; |
| 98 |
|
|
$_->set_attribute (disabled => 'disabled') if $o->{form_disabled}; |
| 99 |
|
|
__ATTRTEXT:%class__; |
| 100 |
|
|
my @class = split /\s+/, $p->{class}; |
| 101 |
|
|
push @class, 'require' if $o->{require}->{$p->{id}}; |
| 102 |
|
|
$_->set_attribute (class => join ' ', @class) if @class; |
| 103 |
|
|
if ($o->user_agent_names =~ m#Mozilla/[0-4]\.#) { |
| 104 |
|
|
$_->set_attribute (wrap => 'virtual'); |
| 105 |
|
|
} |
| 106 |
|
|
if (defined $o->{var}->{content}) { # we--edit |
| 107 |
|
|
$_->append_text ($o->{var}->{content}); |
| 108 |
|
|
} else { |
| 109 |
|
|
__ATTRTEXT:%default__; |
| 110 |
|
|
$_->append_text ($p->{default}); ## Default value |
| 111 |
|
|
} |
| 112 |
|
|
} |
| 113 |
|
|
|
| 114 |
|
|
FormattingRule: |
| 115 |
|
|
@Category[list]: |
| 116 |
|
|
form-input |
| 117 |
|
|
@Name: submit |
| 118 |
|
|
@Description: |
| 119 |
|
|
@@@@: Submitting the form |
| 120 |
|
|
@@@lang:en |
| 121 |
|
|
@Parameter: |
| 122 |
|
|
@@Name: id |
| 123 |
|
|
@@Type: |
| 124 |
|
|
HTML4:name |
| 125 |
|
|
@@Default:(none) |
| 126 |
|
|
@@Description: |
| 127 |
|
|
@@@@: Form control name |
| 128 |
|
|
@@@lang:en |
| 129 |
|
|
@Formatting: |
| 130 |
|
|
my $SUBMIT = $p->{-parent}->append_new_node |
| 131 |
|
|
(type => '#element', |
| 132 |
|
|
namespace_uri => $NS_XHTML1, |
| 133 |
|
|
local_name => 'input'); |
| 134 |
|
|
for ($SUBMIT) { |
| 135 |
|
|
$_->set_attribute (type => 'submit'); |
| 136 |
|
|
__ATTRTEXT:%id__; |
| 137 |
|
|
$_->set_attribute (name => SuikaWiki::Plugin->module_package ('WikiFormCore')->get_ctrl_name ($p->{id})) if $p->{id}; |
| 138 |
|
|
__ATTRTEXT:%class__;__ATTRTEXT:%description__; |
| 139 |
|
|
__ATTRTEXT:%accesskey__;__ATTRTEXT:%tabindex__; |
| 140 |
|
|
for my $attr (qw/class accesskey tabindex/) { |
| 141 |
|
|
$_->set_attribute ($attr => $p->{$attr}) if $p->{$attr}; |
| 142 |
|
|
} |
| 143 |
|
|
$_->set_attribute (title => $p->{description}) if $p->{description}; |
| 144 |
|
|
$_->set_attribute (disabled => 'disabled') if $o->{form_disabled}; |
| 145 |
|
|
__ATTRTEXT:%label__; |
| 146 |
|
|
$_->set_attribute (value => ($p->{label} || $o->resource ('Form:Button:OK'))); |
| 147 |
|
|
$_->option (use_EmptyElemTag => 1); |
| 148 |
|
|
} |