#?SuikaWikiConfig/2.0 Plugin: @Name: WikiFormSelection @FullName: WikiForm: Selection @Description: @@@: WikiFormSelection plugin module provides "selection" form controls. \ Note that this module is translation of SuikaWiki 2 version of WikiFormSelection plugin module. Some rules should be reimplemented. @@lang: en @License: %%GPL%% @Author[list]: Wakaba @Date.RCS: $Date: 2004/02/01 12:08:07 $ @RequiredModule[list]: Error WikiFormCore @Use: my $WIKIRESOURCE; use Message::Util::Error; PluginConst: @NS_XHTML1: http://www.w3.org/1999/xhtml @WIKIRESOURCE: {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} FormattingRule: @Category[list]: form-input @Name: check @Description: @@@: A boolean (true or false) selection @@lang: en @Parameter: @@Name: default @@Type: boolean @@Default: "0" @@Description: @@@@: Initial value @@@lang: en @Parameter: @@Name: desription @@Type: text @@Default: (none) @@Description: @@@@: Human readable description about this selection @@@lang: en @Parameter: @@Name: label @@Type: text @@Default: (none) @@Description: @@@@: A label descripting the selection @@@lang: en @Parameter: @@Name: value @@Type: text @@Default: (auto) @@Description: @@@@: Form control value returned when selected @@@lang: en @Formatting: my $id = SuikaWiki::Plugin->module_package ('WikiFormCore') ->control_id ($o, local_id => $p->{id}, require_local_id => 1); my $check = $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'input'); $check->set_attribute (type => 'checkbox'); $check->set_attribute (name => $id->{local_id}); __ATTRTEXT:%value__;__ATTRTEXT:%default__;__ATTRTEXT:%description__; $check->set_attribute (checked => 'checked') if $p->{default}; $check->set_attribute (value => $p->{value}) if length $p->{value}; $check->set_attribute (disabled => 'disabled') if $o->{form}->{disabled}; $check->set_attribute (title => $p->{description}) if length $p->{description}; __ATTRNODE:%label__; if ($p->{label}->count) { $check->set_attribute (id => $id->{global_id}); my $label = $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'label'); $label->set_attribute (for => $id->{global_id}); $label->append_node ($p->{label}); $label->set_attribute (title => $p->{description}) if length $p->{description}; } FormattingRule: @Category[list]: form-template @Name: iif @Description: @@@: Evaluates and returns given template selected by condition @@lang: en @Parameter: @@Name: false @@Type: template @@Default: (none) @@Description: @@@@: Template evaluated when condition is "no" / "off" / "false" / 0 / undef. @@@lang: en @Parameter: @@Name: source @@Type: id @@Default: #REQUIRED @@Description: @@@@: Source field name @@@lang: en @Parameter: @@Name: true @@Type: template @@Default: (none) @@Description: @@@@: Template eveluated when condition is not false. @@@lang: en @After: my $condition = lc $o->{wiki}->{input}->parameter ('wikiform__'.$p->{source}); $condition =~ tr/\x09\x0A\x0D\x20//d; my $template; if (not $condition or $condition eq 'no' or $condition eq 'off' or $condition eq 'false') { $template = $p->{false}; } else { $template = $p->{true}; } if (length $template) { try { $p->{-result} .= SuikaWiki::Plugin->text_formatter ('form_template') ->replace ($template, param => $o); } catch Message::Util::Formatter::error with { my $err = shift; SuikaWiki::Plugin->module_package ('Error') ->reporting_formatting_template_error ($err, $err->{option}->{param}->{wiki}); ##TODO: throw SuikaWiki::View::Implementation::error -type => 'ERROR_REPORTED'; }; }