From 8500c4d506d130aa0ca103e7f166115d1c957e47 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 16 Apr 2008 16:11:10 +0000 Subject: [PATCH] Cleaned the pollution from the forms system. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/File.pm | 2 +- lib/WebGUI/Asset/FilePile.pm | 2 +- lib/WebGUI/Asset/Wobject/Matrix.pm | 2 +- lib/WebGUI/Asset/Wobject/Thingy.pm | 22 +- lib/WebGUI/Exception.pm | 144 ++++++++++++++ lib/WebGUI/Form/Asset.pm | 63 +++++- lib/WebGUI/Form/Attachments.pm | 43 ++-- lib/WebGUI/Form/Button.pm | 21 +- lib/WebGUI/Form/Captcha.pm | 56 ++++-- lib/WebGUI/Form/CheckList.pm | 48 +++-- lib/WebGUI/Form/Checkbox.pm | 44 ++-- lib/WebGUI/Form/ClassName.pm | 40 ++-- lib/WebGUI/Form/Codearea.pm | 51 +++-- lib/WebGUI/Form/Color.pm | 55 +++-- lib/WebGUI/Form/Combo.pm | 80 ++++---- lib/WebGUI/Form/ContentType.pm | 48 ++++- lib/WebGUI/Form/Control.pm | 287 +++++++++++++++------------ lib/WebGUI/Form/Country.pm | 52 +++-- lib/WebGUI/Form/DatabaseLink.pm | 66 ++++-- lib/WebGUI/Form/Date.pm | 108 ++++++---- lib/WebGUI/Form/DateTime.pm | 102 +++++++--- lib/WebGUI/Form/DynamicField.pm | 43 ++-- lib/WebGUI/Form/Email.pm | 61 +++--- lib/WebGUI/Form/FieldType.pm | 119 ++++++----- lib/WebGUI/Form/File.pm | 99 ++++----- lib/WebGUI/Form/FilterContent.pm | 69 +++++-- lib/WebGUI/Form/Float.pm | 57 ++++-- lib/WebGUI/Form/Group.pm | 89 +++++++-- lib/WebGUI/Form/HTMLArea.pm | 59 ++++-- lib/WebGUI/Form/HexSlider.pm | 50 ++--- lib/WebGUI/Form/Hexadecimal.pm | 42 ++-- lib/WebGUI/Form/Hidden.pm | 58 +++--- lib/WebGUI/Form/HiddenList.pm | 55 +++-- lib/WebGUI/Form/Image.pm | 116 +++++------ lib/WebGUI/Form/IntSlider.pm | 57 ++++-- lib/WebGUI/Form/Integer.pm | 57 ++++-- lib/WebGUI/Form/Interval.pm | 61 ++++-- lib/WebGUI/Form/LdapLink.pm | 65 ++++-- lib/WebGUI/Form/List.pm | 262 ++++++++++++------------ lib/WebGUI/Form/MimeType.pm | 31 ++- lib/WebGUI/Form/Password.pm | 51 +++-- lib/WebGUI/Form/Phone.pm | 47 ++--- lib/WebGUI/Form/Radio.pm | 24 ++- lib/WebGUI/Form/RadioList.pm | 105 ++++++---- lib/WebGUI/Form/ReadOnly.pm | 47 ++--- lib/WebGUI/Form/SelectBox.pm | 106 ++++++---- lib/WebGUI/Form/SelectList.pm | 49 +++-- lib/WebGUI/Form/SelectRichEditor.pm | 37 ++-- lib/WebGUI/Form/SelectSlider.pm | 92 +++++++-- lib/WebGUI/Form/Slider.pm | 24 ++- lib/WebGUI/Form/Submit.pm | 20 +- lib/WebGUI/Form/SubscriptionGroup.pm | 32 +-- lib/WebGUI/Form/Template.pm | 63 ++++-- lib/WebGUI/Form/Text.pm | 57 +++--- lib/WebGUI/Form/Textarea.pm | 53 +++-- lib/WebGUI/Form/TimeField.pm | 90 ++++----- lib/WebGUI/Form/TimeZone.pm | 49 +++-- lib/WebGUI/Form/Url.pm | 64 ++++-- lib/WebGUI/Form/User.pm | 63 +++++- lib/WebGUI/Form/WhatNext.pm | 28 ++- lib/WebGUI/Form/Workflow.pm | 54 +++-- lib/WebGUI/Form/YesNo.pm | 79 +++++--- lib/WebGUI/Form/Zipcode.pm | 42 ++-- lib/WebGUI/Form/_control.skeleton | 55 +++-- lib/WebGUI/FormValidator.pm | 2 +- lib/WebGUI/Operation/Graphics.pm | 2 +- lib/WebGUI/ProfileField.pm | 12 +- lib/WebGUI/URL/Content.pm | 9 +- lib/WebGUI/i18n/English/WebGUI.pm | 18 ++ t/Form/Checkbox.t | 2 +- t/Form/ClassName.t | 2 +- t/Form/Email.t | 6 +- t/Form/Float.t | 6 +- t/Form/Integer.t | 12 +- t/Form/Phone.t | 8 +- t/Form/SelectBox.t | 10 +- t/Form/Text.t | 8 +- t/Form/Textarea.t | 6 +- t/Form/Url.t | 14 +- t/Form/Zipcode.t | 10 +- 81 files changed, 2675 insertions(+), 1570 deletions(-) create mode 100644 lib/WebGUI/Exception.pm diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index b0fbc1d16..042d6f34e 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.5.11 - fix: template variable isUncommitted is not documented in the help + - Cleaned the pollution from the forms system. - fix: Event is no longer editable by anyone who can add events - fixed: Package search is slow for large websites - fixed: rich editor image picker displays incorrectly in IE diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index 01aa074fd..cdc473db2 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -270,7 +270,7 @@ Get the storage location created by the form post. sub getStorageFromPost { my $self = shift; my $storageId = shift; - my $fileStorageId = WebGUI::Form::File->new($self->session, {name => 'newFile', value=>$storageId })->getValueFromPost; + my $fileStorageId = WebGUI::Form::File->new($self->session, {name => 'newFile', value=>$storageId })->getValue; $self->session->errorHandler->info( "File Storage Id: $fileStorageId" ); return $self->getStorageClass->get($self->session, $fileStorageId); } diff --git a/lib/WebGUI/Asset/FilePile.pm b/lib/WebGUI/Asset/FilePile.pm index d7fe31438..9d38b5f7e 100644 --- a/lib/WebGUI/Asset/FilePile.pm +++ b/lib/WebGUI/Asset/FilePile.pm @@ -143,7 +143,7 @@ sub editSave { my $self = shift; ##This is a hack. File uploads should go through the WebGUI::Form::File API - my $tempFileStorageId = WebGUI::Form::File->new($self->session,{name => 'file'})->getValueFromPost; + my $tempFileStorageId = WebGUI::Form::File->new($self->session,{name => 'file'})->getValue; my $tempStorage = WebGUI::Storage::Image->get($self->session, $tempFileStorageId); foreach my $filename (@{$tempStorage->getFiles}) { diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index 591e54540..e298b3e40 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -707,7 +707,7 @@ sub www_editListingSave { versionNumber=>$self->session->form->process("versionNumber") ); - my $storageId = WebGUI::Form::Image->new($self->session,{name => 'screenshot', value => $listing->{storageId}})->getValueFromPost; + my $storageId = WebGUI::Form::Image->new($self->session,{name => 'screenshot', value => $listing->{storageId}})->getValue; if ($storageId) { $data{storageId} = $storageId; $data{filename} = WebGUI::Storage->get($self->session, $storageId)->getFiles->[0]; diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index 3ba7be56d..4385feaf2 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -20,7 +20,6 @@ use WebGUI::Text; use WebGUI::Form::File; use base 'WebGUI::Asset::Wobject'; -our $VERSION = "1.0.0"; #------------------------------------------------------------------- @@ -342,7 +341,7 @@ sub _getDbDataType { else{ $formClass = 'WebGUI::Form::' . ucfirst $fieldType; my $formElement = eval { WebGUI::Pluggable::instanciate($formClass, "new", [$session]) }; - $dbDataType = $formElement->get("dbDataType"); + $dbDataType = $formElement->getDatabaseFieldType; } return $dbDataType; @@ -375,14 +374,7 @@ sub getEditFieldForm { "required" => $i18n->get('fieldstatus required label'), ); - foreach my $fieldType ( sort @{ WebGUI::Form::FieldType->new($session)->get("types") }) { - my $form = eval { WebGUI::Pluggable::instanciate("WebGUI::Form::".$fieldType, "new", [$session]) }; - if ($@) { - $session->errorHandler->error($@); - next; - } - $fieldTypes{$fieldType} = $form->getName($self->session); - } + %fieldTypes = %{WebGUI::Form::FieldType->new($session)->getTypes}; %fieldTypes = WebGUI::Utility::sortHash(%fieldTypes); $things = $self->session->db->read('select thingId, Thingy_things.label, count(*) from Thingy_things ' @@ -589,7 +581,7 @@ sub getFieldValue { } } elsif ($field->{fieldType} eq "file") { - $processedValue = WebGUI::Form::File->new($self->session,{value=>$value})->displayValue(); + $processedValue = WebGUI::Form::File->new($self->session,{value=>$value})->getValueAsHtml(); } return $processedValue; @@ -1159,14 +1151,13 @@ sub www_editThing { =>'text/css', rel=>'stylesheet'}); $tab = $tabForm->getTab('fields'); - - foreach my $fieldType ( sort @{ WebGUI::Form::FieldType->new($session)->get("types") }) { + foreach my $fieldType ( keys %{ WebGUI::Form::FieldType->new($session)->getTypes }) { my $form = eval { WebGUI::Pluggable::instanciate("WebGUI::Form::".$fieldType, "new", [$session]) }; - my $definition = $form->definition($session); if ($@) { $session->errorHandler->error($@); next; } + my $definition = $form->definition($session); if ($form->get("height")){ push(@hasHeightWidth, $fieldType); } @@ -1176,10 +1167,9 @@ sub www_editThing { if (defined $definition->[0]->{vertical}->{defaultValue}){ push(@hasVertical, $fieldType); } - if ($form->get("optionsSettable")){ + if ($form->areOptionsSettable){ push(@hasValues, $fieldType); } - } $tab->raw("