| 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: %%Perl%% |
| 10 |
@Author[list]: |
| 11 |
Wakaba <w@suika.fam.cx> |
| 12 |
@Date.RCS: |
| 13 |
$Date: 2004/07/25 06:54:29 $ |
| 14 |
@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 |
__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 |
my $has_label = 0; |
| 35 |
if ($p->{label}->count) { |
| 36 |
$has_label = 1; |
| 37 |
for ($p->{-parent}->append_new_node |
| 38 |
(type => '#element', |
| 39 |
namespace_uri => $NS_XHTML1, |
| 40 |
local_name => 'label')) { |
| 41 |
$_->set_attribute (for => $id->{global_id}); |
| 42 |
$_->append_node ($p->{label}); |
| 43 |
} |
| 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 |
$_->set_attribute (name => $id->{local_id}); |
| 51 |
$_->set_attribute (id => $id->{global_id}) if $has_label; |
| 52 |
__ATTRTEXT:%size__;__ATTRTEXT:%description__; |
| 53 |
$_->set_attribute (size => ($p->{size}||20)*2); ## Length |
| 54 |
$_->set_attribute (title => $p->{description}) if $p->{description}; |
| 55 |
$_->set_attribute (disabled => 'disabled') if $o->{form}->{disabled}; |
| 56 |
__ATTRTEXT:%class__; |
| 57 |
my @class = split /\s+/, $p->{class}; |
| 58 |
push @class, 'require' if $o->{form}->{require}->{id}->{$p->{id}}; |
| 59 |
$_->option (use_EmptyElemTag => 1); |
| 60 |
__ATTRTEXT:%source__;__ATTRTEXT:%default__; |
| 61 |
if ($p->{source}) { |
| 62 |
my $v; |
| 63 |
if (ref $o->{var}->{source}->{$p->{source}}) { |
| 64 |
my $d = $o->{var}->{source}->{$p->{source}}->(p=>$p,o=>$o); |
| 65 |
$v = $d->{value}; |
| 66 |
push @class, @{$d->{class}||[]}; |
| 67 |
} else { |
| 68 |
$v = $o->{var}->{$p->{source}}; |
| 69 |
} |
| 70 |
$_->set_attribute (value => ref $v eq 'ARRAY' ? join "\n", @$v : |
| 71 |
ref $v ? '' . $v : $v); |
| 72 |
} else { |
| 73 |
$_->set_attribute (value => $p->{default}); ## Default value |
| 74 |
} |
| 75 |
$_->set_attribute (class => join ' ', @class) if @class; |
| 76 |
} |
| 77 |
|
| 78 |
FormattingRule: |
| 79 |
@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 |
@Category[list]: |
| 96 |
form-input |
| 97 |
@Name: textarea |
| 98 |
@Description: |
| 99 |
@@@@: Multiline text input |
| 100 |
@@@lang:en |
| 101 |
@Formatting: |
| 102 |
__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 |
my $has_label = 0; |
| 108 |
if ($p->{label}->count) { |
| 109 |
$has_label = 1; |
| 110 |
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 |
} |
| 117 |
$p->{-parent}->append_new_node |
| 118 |
(type => '#element', |
| 119 |
namespace_uri => $NS_XHTML1, |
| 120 |
local_name => 'br') |
| 121 |
->option (use_EmptyElemTag => 1); |
| 122 |
} |
| 123 |
|
| 124 |
for ($p->{-parent}->append_new_node (type => '#element', |
| 125 |
namespace_uri => $NS_XHTML1, |
| 126 |
local_name => 'textarea')) { |
| 127 |
$_->set_attribute (name => $id->{local_id}); |
| 128 |
$_->set_attribute (id => $id->{global_id}) if $has_label; |
| 129 |
__ATTRTEXT:%size__;__ATTRTEXT:%lines__;__ATTRTEXT:%description__; |
| 130 |
$_->set_attribute (cols => ($p->{size}||20)*2); ## Length |
| 131 |
$_->set_attribute (rows => ($p->{lines}||5)); ## Lines |
| 132 |
$_->set_attribute (title => $p->{description}) if $p->{description}; |
| 133 |
$_->set_attribute (disabled => 'disabled') if $o->{form}->{disabled}; |
| 134 |
__ATTRTEXT:%class__; |
| 135 |
my @class = split /\s+/, $p->{class}; |
| 136 |
push @class, 'require' if $o->{form}->{require}->{id}->{$p->{id}}; |
| 137 |
## ISSUE: Can't we separate this into stylesheet? |
| 138 |
if ($o->{wiki}->{var}->{client}->{user_agent_name} |
| 139 |
=~ m#^Mozilla/[0-4]\.#) { |
| 140 |
$_->set_attribute (wrap => 'virtual'); |
| 141 |
} |
| 142 |
__ATTRTEXT:%source__; |
| 143 |
if ($p->{source}) { |
| 144 |
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 |
} else { |
| 152 |
__ATTRTEXT:%default__; |
| 153 |
$_->append_text ($p->{default}); ## Default value |
| 154 |
} |
| 155 |
$_->set_attribute (class => join ' ', @class) if @class; |
| 156 |
} |
| 157 |
|