From 08afb14d51dfb3a5f85d9b0f678c705b6af9a991 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sun, 15 Jan 2006 04:37:19 +0000 Subject: [PATCH] first batch of Form i18n and compilation patches --- lib/WebGUI/Form/Asset.pm | 6 +++--- lib/WebGUI/Form/Button.pm | 2 +- lib/WebGUI/Form/CheckList.pm | 10 +++++----- lib/WebGUI/Form/FieldType.pm | 14 ++++++++------ lib/WebGUI/Form/List.pm | 12 ++++++------ lib/WebGUI/Form/SelectBox.pm | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/WebGUI/Form/Asset.pm b/lib/WebGUI/Form/Asset.pm index 313b77d66..789a67f9f 100644 --- a/lib/WebGUI/Form/Asset.pm +++ b/lib/WebGUI/Form/Asset.pm @@ -70,13 +70,13 @@ sub definition { my $i18n = WebGUI::International->new($session, "Asset"); push(@{$definition}, { formName=>{ - defaultValue=>$i18n->get("asset"); + defaultValue=>$i18n->get("asset"), }, label=>{ - defaultValue=>$i18n->get("asset"); + defaultValue=>$i18n->get("asset"), }, name=>{ - defaultValue=>"asset"; + defaultValue=>"asset", }, class=>{ defaultValue=> undef diff --git a/lib/WebGUI/Form/Button.pm b/lib/WebGUI/Form/Button.pm index 077012c62..5e426f55d 100644 --- a/lib/WebGUI/Form/Button.pm +++ b/lib/WebGUI/Form/Button.pm @@ -59,7 +59,7 @@ sub definition { my $i18n = WebGUI::International->new($session,"WebGUI"); push(@{$definition}, { formName=>{ - defaultValue=>"button" + defaultValue=>$i18n->get('button') }, defaultValue=>{ defaultValue=>$i18n->get(62) diff --git a/lib/WebGUI/Form/CheckList.pm b/lib/WebGUI/Form/CheckList.pm index 13386ec3c..04463cc5b 100644 --- a/lib/WebGUI/Form/CheckList.pm +++ b/lib/WebGUI/Form/CheckList.pm @@ -60,7 +60,7 @@ sub definition { my $class = shift; my $session = shift; my $definition = shift || []; - my $i18n = WebGUI::International->new($self->session); + my $i18n = WebGUI::International->new($session); push(@{$definition}, { formName=>{ defaultValue=>$i18n->get("941"), @@ -92,18 +92,18 @@ sub toHtml { %options = $self->orderedHash(); foreach my $key (keys %options) { my $checked = 0; - foreach my $item (@{$self->get("value}")) { + foreach my $item (@{ $self->{value} }) { if ($item eq $key) { $checked = 1; } } $output .= WebGUI::Form::Checkbox->new({ - name=>$self->get("name"), + name=>$self->{name}, value=>$key, - extras=>$self->get("extras"), + extras=>$self->{extras}, checked=>$checked })->toHtml; - $output .= ${$self->get("options}"){$key} . $alignment; + $output .= ${$self->{options}}{$key} . $alignment; } return $output; } diff --git a/lib/WebGUI/Form/FieldType.pm b/lib/WebGUI/Form/FieldType.pm index b1b355625..23ddc242b 100644 --- a/lib/WebGUI/Form/FieldType.pm +++ b/lib/WebGUI/Form/FieldType.pm @@ -60,8 +60,9 @@ A text label that will be displayed if toHtmlWithWrapper() is called. Defaults t sub definition { my $class = shift; + my $session = shift; my $definition = shift || []; - my $i18n = WebGUI::International->new($self->session); + my $i18n = WebGUI::International->new($session); push(@{$definition}, { formName=>{ defaultValue=>$i18n->get("fieldtype","WebGUI") @@ -70,10 +71,10 @@ sub definition { defaultValue=>$i18n->get("fieldtype","WebGUI") }, types=>{ - defaultValue=>$class->getTypes + defaultValue=>$class->getTypes($session) } }); - return $class->SUPER::definition($definition); + return $class->SUPER::definition($session, $definition); } #------------------------------------------------------------------- @@ -89,7 +90,8 @@ and DynamicField, the form class dispatcher. sub getTypes { my $class = shift; - opendir(DIR,$self->session->config->getWebguiRoot."/lib/WebGUI/Form/"); + my $session = shift; + opendir(DIR,$session->config->getWebguiRoot."/lib/WebGUI/Form/"); my @rawTypes = readdir(DIR); closedir(DIR); my @types; @@ -127,7 +129,7 @@ sub toHtml { my $self = shift; my %options; tie %options, "Tie::IxHash"; - foreach my $type (@{$self->get("types}")) { + foreach my $type (@{ $self->{types} }) { my $class = "WebGUI::Form::".ucfirst($type); my $cmd = "use ".$class; eval ($cmd); @@ -137,7 +139,7 @@ sub toHtml { } $options{$type} = $class->getName($self->session); } - $self->get("options") = \%options; + $self->{options} = \%options; return $self->SUPER::toHtml(); } diff --git a/lib/WebGUI/Form/List.pm b/lib/WebGUI/Form/List.pm index 7c3cb635e..9c8457c0e 100644 --- a/lib/WebGUI/Form/List.pm +++ b/lib/WebGUI/Form/List.pm @@ -71,10 +71,10 @@ sub correctOptions { s/\s+$//; # remove trailing spaces $options{$_} = $_; } - if (exists $self->get("options") && ref($self->get("options")) eq "HASH") { - %options = (%{$self->get("options}") , %options); + if (exists $self->{options} && ref($self->{options}) eq "HASH") { + %options = (%{$self->{options}} , %options); } - $self->get("options") = \%options; + $self->{options} = \%options; } @@ -237,11 +237,11 @@ sub orderedHash { my %options; tie %options, 'Tie::IxHash'; if ($self->get("sortByValue")) { - foreach my $optionKey (sort {"\L${$self->get("options}"){$a}" cmp "\L${$self->get("options}"){$b}" } keys %{$self->get("options}")) { - $options{$optionKey} = $self->get("options"){$optionKey}; + foreach my $optionKey (sort {"\L${$self->{options}}{$a}" cmp "\L${$self->{options}}{$b}" } keys %{$self->{options}}) { + $options{$optionKey} = $self->{options}{$optionKey}; } } else { - %options = %{$self->get("options}"); + %options = %{$self->{options}}; } return %options; } diff --git a/lib/WebGUI/Form/SelectBox.pm b/lib/WebGUI/Form/SelectBox.pm index c599bb336..4d4a767da 100644 --- a/lib/WebGUI/Form/SelectBox.pm +++ b/lib/WebGUI/Form/SelectBox.pm @@ -123,7 +123,7 @@ sub toHtml { if ($value eq $key) { $output .= ' selected="selected"'; } - $output .= '>'.${$self->get("options}"){$key}.''; + $output .= '>'.${$self->{options}}{$key}.''; } $output .= ''."\n"; return $output;