diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 2f82fc69e..f4f85e1ab 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -21,6 +21,9 @@ - Added more error trapping in caching system. - Fixed some layout and control bugs in the color picker form element. - Added a simple Style Wizard. + - Removed $session{os}{slash} since it is no longer needed. + - Reworked the form system to use inheritance and added a new master form + class for lists called List. See migration.txt for details - Updated preload.perl to automatically preload all WebGUI related modules, which increased shared memory usage by 30%. - Added StockData asset. @@ -34,6 +37,10 @@ "dashboard". You can create more than one dashboard per site. Assets that come with templates for the Dashboard: StockData, WeatherData, SearchBox, SyndicatedContent +- [ 1361669 ] editUserProfileField causes huge memory consumption, loop +- [ 1354464 ] Dynamic Field does not work correctly +- [ 1354467 ] WebGUI::Form::Group is implemented incorrectly + 6.7.8 - fix [ 1364895 ] Error in ITransact Commerce Module diff --git a/docs/migration.txt b/docs/migration.txt index 63a2c2381..c6a27edd4 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -281,7 +281,7 @@ dates then you will notice no side effects from the format change. If you are not, then you should convert your plugin to use WebGUI::FormProcessor. In addition to the format change above, we also made one related API change. -WebGUI::Form::dateTime() and WebGUI::HTMLForm->dateTime() no longer have +WebGUI::Form::DateTime() and WebGUI::HTMLForm->dateTime() no longer have "dateExtras" and "timeExtras", but rather just "extras" properties. This is because there is only one field to represent both the date and the time, unlike before. @@ -348,6 +348,9 @@ http://www.plainblack.com/translations/translations 5.8 WebGUI::Session Changes +In 6.8 we removed $session{os}{slash}. This is due to requiring Windows 2000 +or higher. + In 6.1 we changed the session API to remove functions that didn't really belong in WebGUI::Session. The main changes of interest are that you no longer do HTTP redirects and set cookies via session. Take a look at WebGUI::HTTP for @@ -389,6 +392,38 @@ to convert your content, if necessary. 5.13 Form Changes +The following form changes were made in 6.8: + +All forms types now use inheritance to build List type forms. This is +what the class hierarchy looks like: + +List + CheckList + RadioList + HiddenList + SelectList + Group + LdapLink + SelectBox + ComboBox + ContentType + DatabaseLink + FilterContent + Template + TimeZone + WhatNext + +The new SelectBox class behaves exactly like a SelectList but only supports single +select instead of multiple select and defaults to being 1 character high. By +default, all SelectLists are not 5 characters high. The size setting can +be used to override the defaults in all List type forms. + +All List type forms now also have a sortByValue property which defaults +to 0 (off). This made automatic testing of the Forms easy. + +getName is now in the Form::Control base class. It retreives whatever +is stored in the formName field of the definition field structure. + The following form changes were made in 6.3: The interval subroutine in WebGUI::Form and WebGUI::HTMLForm had an API diff --git a/docs/upgrades/upgrade_6.7.8-6.8.0.pl b/docs/upgrades/upgrade_6.7.8-6.8.0.pl index 70bb6b66b..316dc9032 100644 --- a/docs/upgrades/upgrade_6.7.8-6.8.0.pl +++ b/docs/upgrades/upgrade_6.7.8-6.8.0.pl @@ -40,6 +40,7 @@ addInOutBoard(); addDashboardStuff(); addZipArchive(); updateUserProfileDayLabels(); +changeSelectListToSelectBox(); fixVeryLateDates(); finish(); @@ -1655,6 +1656,20 @@ sub updateUserProfileDayLabels { WebGUI::SQL->write(q!update userProfileField set dataValues='{0=>WebGUI::International::get(\"sunday\",\"DateTime\"),1=>WebGUI::International::get(\"monday\",\"DateTime\")}' where fieldName='firstDayOfWeek'!); } +#------------------------------------------------- +sub changeSelectListToSelectBox { + print "\tChanging all selectLists to selectBox's in userProfileField.\n" unless ($quiet); + WebGUI::SQL->write(q!update userProfileField set dataType='selectBox' where dataType='selectList'!); + my $sql = q!select fieldName,dataDefault from userProfileField where dataType IN ('selectBox','timeZone')!; + my $sth = WebGUI::SQL->read($sql); + while (my $hash = $sth->hashRef) { + $hash->{dataDefault} =~ tr/][//d; + WebGUI::SQL->write(sprintf q!update userProfileField set dataDefault=%s where fieldName=%s!, quote($hash->{dataDefault}), quote($hash->{fieldName}) ); + } +} + +(); + #--- DO NOT EDIT BELOW THIS LINE #------------------------------------------------- diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index 8bdf087ef..d3a26bc95 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -13,6 +13,7 @@ our $STATUS = "beta"; #------------------------------------------------------------------- use strict qw(vars subs); +use trace; use Tie::CPHash; use Time::HiRes; use WebGUI::Affiliate; diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 1a37b7842..d3ed68d59 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -193,7 +193,7 @@ sub definition { defaultValue=>'7' }, ownerUserId=>{ - fieldType=>'selectList', + fieldType=>'selectBox', defaultValue=>'3' }, startDate=>{ @@ -580,7 +580,7 @@ sub getEditForm { $clause = "userId=".quote($self->get("ownerUserId")); } my $users = WebGUI::SQL->buildHashRef("select userId,username from users where $clause order by username"); - $tabform->getTab("security")->selectList( + $tabform->getTab("security")->selectBox( -name=>"ownerUserId", -options=>$users, -label=>WebGUI::International::get(108,"Asset"), diff --git a/lib/WebGUI/Asset/Event.pm b/lib/WebGUI/Asset/Event.pm index 181e3878f..a8784db3b 100644 --- a/lib/WebGUI/Asset/Event.pm +++ b/lib/WebGUI/Asset/Event.pm @@ -115,7 +115,7 @@ sub getEditForm { name=>"interval", defaultValue=>1 }) - .WebGUI::Form::selectList({ + .WebGUI::Form::selectBox({ name=>"recursEvery", options=>\%recursEvery }) diff --git a/lib/WebGUI/Asset/File/ZipArchive.pm b/lib/WebGUI/Asset/File/ZipArchive.pm index eec512876..99917eb6b 100644 --- a/lib/WebGUI/Asset/File/ZipArchive.pm +++ b/lib/WebGUI/Asset/File/ZipArchive.pm @@ -65,7 +65,7 @@ sub unzip { } $zip->extractTree(); } elsif($filename =~ m/\.tar/i){ - Archive::Tar->extract_archive($filepath.$session{os}{slash}.$filename,1); + Archive::Tar->extract_archive($filepath.'/'.$filename,1); if (Archive::Tar->error){ WebGUI::ErrorHandler::warn(Archive::Tar->error); return 0; diff --git a/lib/WebGUI/Asset/FilePile.pm b/lib/WebGUI/Asset/FilePile.pm index 7e5820486..bc6715525 100644 --- a/lib/WebGUI/Asset/FilePile.pm +++ b/lib/WebGUI/Asset/FilePile.pm @@ -115,7 +115,7 @@ sub edit { $clause = "userId=".quote($self->get("ownerUserId")); } my $users = WebGUI::SQL->buildHashRef("select userId,username from users where $clause order by username"); - $tabform->getTab("security")->selectList( + $tabform->getTab("security")->selectBox( -name=>"ownerUserId", -options=>$users, -label=>WebGUI::International::get(108,"Asset_FilePile"), diff --git a/lib/WebGUI/Asset/RichEdit.pm b/lib/WebGUI/Asset/RichEdit.pm index 62d79534d..b2e011617 100644 --- a/lib/WebGUI/Asset/RichEdit.pm +++ b/lib/WebGUI/Asset/RichEdit.pm @@ -108,11 +108,11 @@ sub definition { defaultValue=>0 }, directionality=>{ - fieldType=>'selectList', + fieldType=>'selectBox', defaultValue=>'ltr' }, toolbarLocation=>{ - fieldType=>'selectList', + fieldType=>'selectBox', defaultValue=>'bottom' }, cssFile=>{ @@ -120,15 +120,15 @@ sub definition { defaultValue=>undef }, toolbarRow1=>{ - fieldType=>'checkList', + fieldType=>'checkBox', defaultValue=>undef }, toolbarRow2=>{ - fieldType=>'checkList', + fieldType=>'checkBox', defaultValue=>undef }, toolbarRow3=>{ - fieldType=>'checkList', + fieldType=>'checkBox', defaultValue=>undef }, enableContextMenu => { @@ -332,7 +332,7 @@ sub getEditForm { -name=>"nowrap", -uiLevel=>9 ); - $tabform->getTab("properties")->selectList( + $tabform->getTab("properties")->selectBox( -value=>[$self->getValue("directionality")], -label=>WebGUI::International::get('directionality', 'Asset_RichEdit'), -hoverHelp=>WebGUI::International::get('directionality description', 'Asset_RichEdit'), @@ -342,7 +342,7 @@ sub getEditForm { rtl=>WebGUI::International::get('right to left', 'Asset_RichEdit'), } ); - $tabform->getTab("display")->selectList( + $tabform->getTab("display")->selectBox( -value=>[$self->getValue("toolbarLocation")], -label=>WebGUI::International::get('toolbar location', 'Asset_RichEdit'), -hoverHelp=>WebGUI::International::get('toolbar location description', 'Asset_RichEdit'), diff --git a/lib/WebGUI/Asset/Shortcut.pm b/lib/WebGUI/Asset/Shortcut.pm index 965bc56a3..4c9e05ecc 100644 --- a/lib/WebGUI/Asset/Shortcut.pm +++ b/lib/WebGUI/Asset/Shortcut.pm @@ -56,7 +56,7 @@ sub _drawQueryBuilder { value=>$self->getValue("shortcutCriteria"), extras=>'style="width: 100%" '.$self->{_disabled} }); - my $conjunctionField = WebGUI::Form::selectList({ + my $conjunctionField = WebGUI::Form::selectBox({ name=>"conjunction", options=>{ "AND" => WebGUI::International::get("AND","Asset_Shortcut"), @@ -208,7 +208,7 @@ sub definition { defaultValue=>0 }, resolveMultiples=>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>"mostRecent", }, shortcutCriteria=>{ @@ -313,7 +313,7 @@ sub getEditForm { if ($self->getValue("shortcutByCriteria") == 0) { $self->{_disabled} = 'disabled=true'; } - $tabform->getTab("properties")->selectList( + $tabform->getTab("properties")->selectBox( -name=>"resolveMultiples", -value=>[ $self->getValue("resolveMultiples") ], -label=>WebGUI::International::get("Resolve Multiples","Asset_Shortcut"), diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 1d3461b61..d3f7a96c6 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -229,7 +229,7 @@ sub process { return $self->processRaw($self->get("template"),$vars); # skip all the junk below here for now until we have time to bring it inline with the new system my $file = _getTemplateFile($self->get("templateId")); - my $fileCacheDir = $session{config}{uploadsPath}.$session{os}{slash}."temp".$session{os}{slash}."templatecache"; + my $fileCacheDir = $session{config}{uploadsPath}.'/temp/templatecache'; my %params = ( filename=>$file->getPath, global_vars=>1, diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index c03e20275..86a9faf08 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -352,7 +352,7 @@ sub definition { defaultValue=>'javascript' }, richEditor =>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>"PBrichedit000000000002" }, attachmentsPerPost =>{ @@ -372,11 +372,11 @@ sub definition { defaultValue=>1 }, sortOrder =>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>'desc' }, sortBy =>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>'dateUpdated' }, rssTemplateId =>{ @@ -574,14 +574,14 @@ sub getEditForm { userDefined4=>WebGUI::International::get('user defined 4', 'Asset_Collaboration'), userDefined5=>WebGUI::International::get('user defined 5', 'Asset_Collaboration'), ); - $tabform->getTab("display")->selectList( + $tabform->getTab("display")->selectBox( -name=>"sortBy", -value=>[$self->getValue("sortBy")], -options=>\%options, -label=>WebGUI::International::get('sort by', 'Asset_Collaboration'), -hoverHelp=>WebGUI::International::get('sort by description', 'Asset_Collaboration'), ); - $tabform->getTab("display")->selectList( + $tabform->getTab("display")->selectBox( -name=>"sortOrder", -value=>[$self->getValue("sortOrder")], -options=>{ @@ -621,7 +621,7 @@ sub getEditForm { -hoverHelp=>WebGUI::International::get('edit stamp description', 'Asset_Collaboration'), -value=>$self->getValue("addEditStampToPosts") ); - $tabform->getTab("display")->selectList( + $tabform->getTab("display")->selectBox( -name=>"richEditor", -label=>WebGUI::International::get('rich editor', 'Asset_Collaboration'), -hoverHelp=>WebGUI::International::get('rich editor description', 'Asset_Collaboration'), @@ -1015,7 +1015,7 @@ sub www_search { tie %results, 'Tie::IxHash'; %results = (10=>'10', 25=>'25', 50=>'50', 100=>'100'); my $numResults = $session{scratch}{$self->getId."_numResults"} || $self->get("threadsPerPage"); - $var{'results.form'} = WebGUI::Form::selectList({ + $var{'results.form'} = WebGUI::Form::selectBox({ name=>"numResults", options=>\%results, value=>[$numResults] diff --git a/lib/WebGUI/Asset/Wobject/DataForm.pm b/lib/WebGUI/Asset/Wobject/DataForm.pm index ef4f5f3d6..a4ee96c75 100644 --- a/lib/WebGUI/Asset/Wobject/DataForm.pm +++ b/lib/WebGUI/Asset/Wobject/DataForm.pm @@ -799,7 +799,7 @@ sub www_editField { -value=>$field{sequenceNumber} ); } - $f->selectList( + $f->selectBox( -name=>"tid", -options=>$tab, -label=>WebGUI::International::get(104,"Asset_DataForm"), @@ -812,7 +812,7 @@ sub www_editField { -label=>WebGUI::International::get(79,"Asset_DataForm"), -hoverHelp=>WebGUI::International::get('79 description',"Asset_DataForm"), ); - $f->selectList( + $f->selectBox( -name=>"status", -options=>\%fieldStatus, -label=>WebGUI::International::get(22,"Asset_DataForm"), diff --git a/lib/WebGUI/Asset/Wobject/EventsCalendar.pm b/lib/WebGUI/Asset/Wobject/EventsCalendar.pm index 788c8fa20..330155b7b 100644 --- a/lib/WebGUI/Asset/Wobject/EventsCalendar.pm +++ b/lib/WebGUI/Asset/Wobject/EventsCalendar.pm @@ -58,19 +58,19 @@ sub definition { defaultValue=>'PBtmpl0000000000000023' }, scope =>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>'0' }, startMonth=>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>"current" }, endMonth=>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>"after12" }, defaultMonth=>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>"current" }, paginateAfter=>{ @@ -89,7 +89,7 @@ sub definition { sub getEditForm { my $self = shift; my $tabform = $self->SUPER::getEditForm(); - $tabform->getTab("properties")->selectList( + $tabform->getTab("properties")->selectBox( -name=>"scope", -label=>WebGUI::International::get(507,"Asset_EventsCalendar"), -hoverHelp=>WebGUI::International::get('507 description',"Asset_EventsCalendar"), @@ -114,7 +114,7 @@ sub getEditForm { -value=>$self->getValue('eventTemplateId'), -namespace=>"EventsCalendar/Event", ); - $tabform->getTab("display")->selectList( + $tabform->getTab("display")->selectBox( -name=>"startMonth", -options=>{ "january"=>WebGUI::International::get('january','Asset_EventsCalendar'), @@ -136,14 +136,14 @@ sub getEditForm { "after3"=>WebGUI::International::get(89,"Asset_EventsCalendar"), "current"=>WebGUI::International::get(82,"Asset_EventsCalendar") ); - $tabform->getTab("display")->selectList( + $tabform->getTab("display")->selectBox( -name=>"endMonth", -options=>\%options, -label=>WebGUI::International::get(84,"Asset_EventsCalendar"), -hoverHelp=>WebGUI::International::get('84 description',"Asset_EventsCalendar"), -value=>[$self->getValue("endMonth")] ); - $tabform->getTab("display")->selectList( + $tabform->getTab("display")->selectBox( -name=>"defaultMonth", -options=>{ "current"=>WebGUI::International::get(82,"Asset_EventsCalendar"), diff --git a/lib/WebGUI/Asset/Wobject/HttpProxy.pm b/lib/WebGUI/Asset/Wobject/HttpProxy.pm index d6f5e8547..dce25248c 100644 --- a/lib/WebGUI/Asset/Wobject/HttpProxy.pm +++ b/lib/WebGUI/Asset/Wobject/HttpProxy.pm @@ -48,7 +48,7 @@ sub definition { defaultValue=>'http://' }, timeout=>{ - fieldType=>"selectList", + fieldType=>"selectBox", defaultValue=>30 }, removeStyle=>{ @@ -149,7 +149,7 @@ sub getEditForm { -name=>"filterHtml", -value=>$self->getValue("filterHtml") ); - $tabform->getTab("properties")->selectList( + $tabform->getTab("properties")->selectBox( -name=>"timeout", -options=>\%hash, -label=>WebGUI::International::get(4,"Asset_HttpProxy"), diff --git a/lib/WebGUI/Asset/Wobject/InOutBoard.pm b/lib/WebGUI/Asset/Wobject/InOutBoard.pm index 38c34343a..f4502536b 100644 --- a/lib/WebGUI/Asset/Wobject/InOutBoard.pm +++ b/lib/WebGUI/Asset/Wobject/InOutBoard.pm @@ -184,7 +184,7 @@ sub view { $nameHash{""} = WebGUI::International::get('myself',"Asset_InOutBoard"); %nameHash = WebGUI::Utility::sortHash(%nameHash); - $f->selectList( + $f->selectBox( -name=>"delegate", -options=>\%nameHash, -value=>[ $session{scratch}{userId} ], @@ -412,7 +412,7 @@ sub www_viewReport { my $departmentSQLclause = ($defaultDepartment eq WebGUI::International::get('all departments', 'Asset_InOutBoard')) ? '' : 'and c.fieldData='.quote($defaultDepartment); - $f->selectList( + $f->selectBox( -name=>"selectDepartment", -options=>\%depHash, -value=>[ $defaultDepartment ], @@ -422,7 +422,7 @@ sub www_viewReport { tie %paginHash, "Tie::IxHash"; ##Because default sort order is alpha %paginHash = (50 => 50, 100 => 100, 300 => 300, 500 => 500, 1000 => 1000, 10_000 => 10_000,); my $pageReportAfter = $session{form}{reportPagination} || 50; - $f->selectList( + $f->selectBox( -name=>"reportPagination", -options=>\%paginHash, -value=>[ $pageReportAfter ], diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index 1413302d6..fe3feec4f 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -477,7 +477,7 @@ sub www_editListing { -label=>"Description" ); if ($self->canEdit) { - $f->selectList( + $f->selectBox( -name=>"maintainerId", -value=>[$listing->{maintainerId}], -label=>"Listing Maintainer", @@ -507,7 +507,7 @@ sub www_editListing { ); } elsif ($field->{fieldType} eq "goodBad") { my $value = ($field->{value} || $field->{defaultValue} || "No"); - $f->selectList( + $f->selectBox( -name=>$field->{name}, -value=>[$value], -label=>$field->{label}, @@ -617,7 +617,7 @@ sub www_editListingSave { while (my ($id, $name, $type) = $a->array) { my $value; if ($type eq "goodBad") { - $value = WebGUI::FormProcessor::selectList($name); + $value = WebGUI::FormProcessor::selectBox($name); } else { $value = WebGUI::FormProcessor::process($name,$type); } @@ -652,7 +652,7 @@ sub www_editField { -value=>$field->{label}, -label=>"Label" ); - $f->selectList( + $f->selectBox( -name=>"fieldType", -value=>[$field->{fieldType}], -label=>"Type", @@ -678,7 +678,7 @@ sub www_editField { foreach my $category ($self->getCategories) { $cats{$category} = $category; } - $f->selectList( + $f->selectBox( -name=>"category", -value=>[$field->{category}], -label=>"Category", @@ -982,7 +982,7 @@ sub www_viewDetail { -value=>$session{user}{email}, -label=>"Your Email Address" ); - $f->selectList( + $f->selectBox( -name=>"subject", -extras=>'class="content"', -options=>{ @@ -1051,7 +1051,7 @@ sub www_viewDetail { my ($mean,$median,$count) = WebGUI::SQL->quickArray("select meanValue, medianValue, countValue from Matrix_ratingSummary where listingId=".quote($listingId)." and category=".quote($category)); $ratingsTable .= ''.$category.''.$mean.''.$median.''.$count.''; - $f->selectList( + $f->selectBox( -name=>$category, -label=>$category, -value=>[5], diff --git a/lib/WebGUI/Asset/Wobject/Navigation.pm b/lib/WebGUI/Asset/Wobject/Navigation.pm index e216e4a00..dfd6b4349 100644 --- a/lib/WebGUI/Asset/Wobject/Navigation.pm +++ b/lib/WebGUI/Asset/Wobject/Navigation.pm @@ -46,7 +46,7 @@ sub definition { defaultValue=>"descendants" }, startType=>{ - fieldType=>'selectList', + fieldType=>'selectBox', defaultValue=>"relativeToCurrentUrl" }, startPoint=>{ @@ -54,11 +54,11 @@ sub definition { defaultValue=>0 }, ancestorEndPoint=>{ - fieldType=>'selectList', + fieldType=>'selectBox', defaultValue=>55 }, descendantEndPoint=>{ - fieldType=>'selectList', + fieldType=>'selectBox', defaultValue=>55 }, showSystemPages=>{ @@ -110,7 +110,7 @@ sub getEditForm { $pedigreeChecked = 1; } } - $tabform->getTab("properties")->selectList( + $tabform->getTab("properties")->selectBox( -name=>"startType", -options=>{ specificUrl=>$i18n->get('Specific URL'), @@ -140,7 +140,7 @@ sub getEditForm { ); $tabform->getTab("properties")->raw( ''.$i18n->get("Ancestor End Point").'' - .WebGUI::Form::selectList({ + .WebGUI::Form::selectBox({ name=>"ancestorEndPoint", value=>[$self->getValue("ancestorEndPoint")], options=>\%options @@ -190,7 +190,7 @@ sub getEditForm { ); $tabform->getTab("properties")->raw( ''.$i18n->get('Descendant End Point').'' - .WebGUI::Form::selectList({ + .WebGUI::Form::selectBox({ name=>"descendantEndPoint", value=>[$self->getValue("descendantEndPoint")], options=>\%options diff --git a/lib/WebGUI/Asset/Wobject/Product.pm b/lib/WebGUI/Asset/Wobject/Product.pm index 9fcfd5b40..3d37793ff 100644 --- a/lib/WebGUI/Asset/Wobject/Product.pm +++ b/lib/WebGUI/Asset/Wobject/Product.pm @@ -365,7 +365,7 @@ sub www_addAccessory { @usedAccessories = WebGUI::SQL->buildArray("select accessoryAssetId from Product_accessory where assetId=".quote($self->getId)); push(@usedAccessories,$self->getId); $accessory = WebGUI::SQL->buildHashRef("select asset.assetId, assetData.title from asset left join assetData on assetData.assetId=asset.assetId where asset.className='WebGUI::Asset::Wobject::Product' and asset.assetId not in (".quoteAndJoin(\@usedAccessories).") and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).") group by assetData.assetId"); - $f->selectList( + $f->selectBox( -name => "accessoryAccessId", -options => $accessory, -label => WebGUI::International::get(17,'Asset_Product'), @@ -404,7 +404,7 @@ sub www_addRelated { @usedRelated = WebGUI::SQL->buildArray("select relatedAssetId from Product_related where assetId=".quote($self->getId)); push(@usedRelated,$self->getId); $related = WebGUI::SQL->buildHashRef("select assetId,title from asset where className='WebGUI::Asset::Wobject::Product' and assetId not in (".quoteAndJoin(\@usedRelated).")"); - $f->selectList( + $f->selectBox( -name => "relatedAssetId", -options => $related, -label => WebGUI::International::get(20,'Asset_Product'), diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index 8988dc561..bc8839b84 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -246,7 +246,7 @@ sub getEditForm { -afterEdit => 'func=edit' ); - $tabform->getTab('display')->selectList( + $tabform->getTab('display')->selectBox( -name => "questionOrder", -options => { sequential => WebGUI::International::get(5,'Asset_Survey'), @@ -264,7 +264,7 @@ sub getEditForm { -label => WebGUI::International::get(83,'Asset_Survey'), -hoverHelp => WebGUI::International::get('83 description','Asset_Survey') ); - $tabform->getTab('properties')->selectList( + $tabform->getTab('properties')->selectBox( -name => "mode", -options => { survey => WebGUI::International::get(9,'Asset_Survey'), @@ -854,7 +854,7 @@ sub www_editAnswer { $question = WebGUI::SQL->buildHashRef("select Survey_questionId,question from Survey_question where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); $question = { ('-1' => WebGUI::International::get(82,'Asset_Survey'),%$question) }; - $f->selectList( + $f->selectBox( -name=>"gotoQuestion", -options=>$question, -value=>[$answer->{gotoQuestion}], @@ -956,7 +956,7 @@ sub www_editQuestion { my $sectionList = WebGUI::SQL->buildHashRef("select Survey_sectionId,sectionName from Survey_section where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); - $f->selectList( + $f->selectBox( -name => "section", -options=> $sectionList, -value => [$question->{Survey_sectionId}], @@ -967,7 +967,7 @@ sub www_editQuestion { my $ql = WebGUI::SQL->buildHashRef("select Survey_questionId,question from Survey_question where Survey_id=".quote($self->get("Survey_id"))." order by sequenceNumber"); $ql = { ('-1' => WebGUI::International::get(82,'Asset_Survey'),%$ql) }; - $f->selectList( + $f->selectBox( -name => "gotoQuestion", -options=> $ql, -value => [$question->{gotoQuestion}], diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index 2f8ed5bea..9cc7afb76 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -98,7 +98,7 @@ sub definition { }, displayMode=>{ tab=>"display", - fieldType=>'selectList', + fieldType=>'selectBox', defaultValue=>'interleaved', options=>{ 'interleaved'=>WebGUI::International::get('interleaved','Asset_SyndicatedContent'), diff --git a/lib/WebGUI/AssetBranch.pm b/lib/WebGUI/AssetBranch.pm index 4c6cafb73..16e92e086 100644 --- a/lib/WebGUI/AssetBranch.pm +++ b/lib/WebGUI/AssetBranch.pm @@ -105,7 +105,7 @@ sub www_editBranch { -label=>WebGUI::International::get(104,"Asset"), -uiLevel=>9, -subtext=>'
'.WebGUI::International::get("change","Asset").' '.WebGUI::Form::yesNo({name=>"change_url"}), - -value=>WebGUI::Form::selectList({ + -value=>WebGUI::Form::selectBox({ name=>"baseUrlBy", extras=>'onchange="toggleSpecificBaseUrl()"', id=>"baseUrlBy", @@ -114,7 +114,7 @@ sub www_editBranch { specifiedBase=>"Specified Base", none=>"None" } - }).' / '.WebGUI::Form::selectList({ + }).' / '.WebGUI::Form::selectBox({ name=>"endOfUrl", options=>{ menuTitle=>WebGUI::International::get(411,"Asset"), @@ -221,7 +221,7 @@ sub www_editBranch { $clause = "userId=".quote($self->get("ownerUserId")); } my $users = WebGUI::SQL->buildHashRef("select userId,username from users where $clause order by username"); - $tabform->getTab("security")->selectList( + $tabform->getTab("security")->selectBox( -name=>"ownerUserId", -options=>$users, -label=>WebGUI::International::get(108,"Asset"), @@ -302,16 +302,16 @@ sub www_editBranchSave { $data{encryptPage} = WebGUI::FormProcessor::yesNo("encryptPage") if (WebGUI::FormProcessor::yesNo("change_encryptPage")); $data{startDate} = WebGUI::FormProcessor::dateTime("startDate") if (WebGUI::FormProcessor::yesNo("change_startDate")); $data{endDate} = WebGUI::FormProcessor::dateTime("endDate") if (WebGUI::FormProcessor::yesNo("change_endDate")); - $data{ownerUserId} = WebGUI::FormProcessor::selectList("ownerUserId") if (WebGUI::FormProcessor::yesNo("change_ownerUserId")); + $data{ownerUserId} = WebGUI::FormProcessor::selectBox("ownerUserId") if (WebGUI::FormProcessor::yesNo("change_ownerUserId")); $data{groupIdView} = WebGUI::FormProcessor::group("groupIdView") if (WebGUI::FormProcessor::yesNo("change_groupIdView")); $data{groupIdEdit} = WebGUI::FormProcessor::group("groupIdEdit") if (WebGUI::FormProcessor::yesNo("change_groupIdEdit")); $data{extraHeadTags} = WebGUI::FormProcessor::group("extraHeadTags") if (WebGUI::FormProcessor::yesNo("change_extraHeadTags")); my ($urlBaseBy, $urlBase, $endOfUrl); my $changeUrl = WebGUI::FormProcessor::yesNo("change_url"); if ($changeUrl) { - $urlBaseBy = WebGUI::FormProcessor::selectList("baseUrlBy"); + $urlBaseBy = WebGUI::FormProcessor::selectBox("baseUrlBy"); $urlBase = WebGUI::FormProcessor::text("baseUrl"); - $endOfUrl = WebGUI::FormProcessor::selectList("endOfUrl"); + $endOfUrl = WebGUI::FormProcessor::selectBox("endOfUrl"); } my $descendants = $self->getLineage(["self","descendants"],{returnObjects=>1}); foreach my $descendant (@{$descendants}) { diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index 00fc1f311..1e6137055 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -151,7 +151,7 @@ sub www_export { -name=>"depth", -value=>99, ); - $f->selectList( + $f->selectBox( -label=>WebGUI::International::get('Export as user',"Asset"), -hoverHelp=>WebGUI::International::get('Export as user description',"Asset"), -name=>"userId", diff --git a/lib/WebGUI/Auth/LDAP.pm b/lib/WebGUI/Auth/LDAP.pm index 0b5af6547..853357b10 100644 --- a/lib/WebGUI/Auth/LDAP.pm +++ b/lib/WebGUI/Auth/LDAP.pm @@ -113,7 +113,7 @@ sub addUserForm { $jsArray //--> |; - $f->selectList( + $f->selectBox( -name=>"authLDAP_ldapConnection", -label=>WebGUI::International::get("ldapConnection",'AuthLDAP'), -hoverHelp=>WebGUI::International::get("ldapConnection description",'AuthLDAP'), @@ -217,7 +217,7 @@ sub createAccount { $vars->{'create.form.ldapConnection.label'} = WebGUI::International::get("ldapConnection","AuthLDAP"); my $url = WebGUI::URL::page("op=auth;method=createAccount;connection="); - $vars->{'create.form.ldapConnection'} = WebGUI::Form::selectList({ + $vars->{'create.form.ldapConnection'} = WebGUI::Form::selectBox({ name=>"ldapConnection", options=>WebGUI::LDAPLink::getList(), value=>[$connection->{ldapLinkId}], @@ -361,7 +361,7 @@ sub editUserFormSave { sub editUserSettingsForm { my $self = shift; my $f = WebGUI::HTMLForm->new; - my $ldapConnection = WebGUI::Form::selectList({ + my $ldapConnection = WebGUI::Form::selectBox({ name=>"ldapConnection", options=>WebGUI::LDAPLink::getList(), value=>[$session{setting}{ldapConnection}] diff --git a/lib/WebGUI/Cache.pm b/lib/WebGUI/Cache.pm index 210eb2acc..3998b59a0 100644 --- a/lib/WebGUI/Cache.pm +++ b/lib/WebGUI/Cache.pm @@ -77,7 +77,7 @@ Flushes the caching system. Must be overridden. =cut sub flush { - rmtree($WebGUI::Session::session{config}{uploadsPath}.$WebGUI::Session::session{os}{slash}."temp"); + rmtree($WebGUI::Session::session{config}{uploadsPath}."/temp"); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Commerce/Payment/ITransact.pm b/lib/WebGUI/Commerce/Payment/ITransact.pm index 6e192ccd3..0f4ecf126 100644 --- a/lib/WebGUI/Commerce/Payment/ITransact.pm +++ b/lib/WebGUI/Commerce/Payment/ITransact.pm @@ -386,7 +386,7 @@ sub checkoutForm { 'Zambia' => 'Zambia', 'Zimbabwe' => 'Zimbabwe' ); - $f->selectList( + $f->selectBox( -name=>"country", -label=>$i18n->get("country"), -value=>[$session{form}{country}], @@ -416,9 +416,9 @@ sub checkoutForm { $f->readOnly( -label => $i18n->get('expiration date'), -value => - WebGUI::Form::selectList({name => 'expMonth', options => \%months, value => [$session{form}{expMonth}]}). + WebGUI::Form::selectBox({name => 'expMonth', options => \%months, value => [$session{form}{expMonth}]}). " / ". - WebGUI::Form::selectList({name => 'expYear', options => \%years, value => [$session{form}{expYear}]}) + WebGUI::Form::selectBox({name => 'expYear', options => \%years, value => [$session{form}{expYear}]}) ); $f->integer( -name => 'cvv2', diff --git a/lib/WebGUI/ErrorHandler.pm b/lib/WebGUI/ErrorHandler.pm index 55c92a0cb..d9f19261f 100644 --- a/lib/WebGUI/ErrorHandler.pm +++ b/lib/WebGUI/ErrorHandler.pm @@ -18,7 +18,6 @@ use FileHandle; #use Log::Log4perl; use strict; use WebGUI::Session; -use Log::Log4perl; use Apache2::RequestUtil; $Log::Log4perl::caller_depth++; @@ -202,7 +201,7 @@ Returns a reference to the logger. =cut sub getLogger { - Log::Log4perl::init_once($WebGUI::Session::session{config}{webguiRoot}.$WebGUI::Session::session{os}{slash}.'etc'.$WebGUI::Session::session{os}{slash}."log.conf"); + Log::Log4perl::init_once($WebGUI::Session::session{config}{webguiRoot}."/etc/log.conf"); return Log::Log4perl->get_logger($WebGUI::Session::session{config}{configFile}); } diff --git a/lib/WebGUI/Form/Asset.pm b/lib/WebGUI/Form/Asset.pm index 406c4e668..5194665c5 100644 --- a/lib/WebGUI/Form/Asset.pm +++ b/lib/WebGUI/Form/Asset.pm @@ -69,8 +69,11 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("asset","Asset") + }, label=>{ - defaultValue=>$class->getName() + defaultValue=>WebGUI::International::get("asset","Asset") }, name=>{ defaultValue=> "asset" @@ -82,20 +85,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("asset","Asset"); -} - - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/Button.pm b/lib/WebGUI/Form/Button.pm index 67032f711..541f14cc8 100644 --- a/lib/WebGUI/Form/Button.pm +++ b/lib/WebGUI/Form/Button.pm @@ -57,6 +57,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("button","WebGUI") + }, defaultValue=>{ defaultValue=>WebGUI::International::get(62,"WebGUI") }, @@ -64,20 +67,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("button","WebGUI"); -} - - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/CheckList.pm b/lib/WebGUI/Form/CheckList.pm index 8c63e03c9..628ccbf4f 100644 --- a/lib/WebGUI/Form/CheckList.pm +++ b/lib/WebGUI/Form/CheckList.pm @@ -15,9 +15,8 @@ package WebGUI::Form::CheckList; =cut use strict; -use base 'WebGUI::Form::Control'; +use base 'WebGUI::Form::List'; use WebGUI::Form::Checkbox; -use WebGUI::Form::HiddenList; use WebGUI::International; use WebGUI::Session; @@ -31,7 +30,7 @@ Creates a series of check box form fields. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. Also take a look ath WebGUI::Form::Checkbox as this class creates a list of checkboxes. +This is a subclass of WebGUI::Form::List. Also take a look at WebGUI::Form::Checkbox as this class creates a list of checkboxes. =head1 METHODS @@ -49,14 +48,6 @@ See the super class for additional details. The following additional parameters have been added via this sub class. -=head4 options - -A hash reference containing key values that will be returned with the form post and displayable text pairs. Defaults to an empty hash reference. - -=head4 defaultValue - -An array reference of the items to be checked if no value is specified. Defaults to an empty array reference. - =head4 vertical Boolean representing whether the checklist should be represented vertically or horizontally. If set to "1" will be displayed vertically. Defaults to "0". @@ -71,11 +62,8 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { - options=>{ - defaultValue=>{} - }, - defaultValue=>{ - defaultValue=>[], + formName=>{ + defaultValue=>WebGUI::International::get("941","WebGUI"), }, vertical=>{ defaultValue=>0 @@ -87,47 +75,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 displayValue ( ) - -Return the all options - -=cut - -sub displayValue { - my ($self) = @_; - return join ", ", @{ $self->{value} }; -} - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("941","WebGUI"); -} - - -#------------------------------------------------------------------- - -=head2 getValueFromPost ( ) - -Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar. - -=cut - -sub getValueFromPost { - my $self = shift; - my @data = $session{req}->param($self->{name}); - return wantarray ? @data : join("\n",@data); -} - #------------------------------------------------------------------- =head2 toHtml ( ) @@ -139,14 +86,11 @@ Renders a series of checkboxes. sub toHtml { my $self = shift; my $output; - my $alignment; - if ($self->{vertical}) { - $alignment = "
\n"; - } - else { - $alignment = "    \n"; - } - foreach my $key (keys %{$self->{options}}) { + my $alignment = $self->alignmentSeparator; + my %options; + tie %options, 'Tie::IxHash'; + %options = $self->orderedHash(); + foreach my $key (keys %options) { my $checked = 0; foreach my $item (@{$self->{value}}) { if ($item eq $key) { @@ -164,23 +108,5 @@ sub toHtml { return $output; } -#------------------------------------------------------------------- - -=head2 toHtmlAsHidden ( ) - -Creates a series of hidden fields representing the data in the list. - -=cut - -sub toHtmlAsHidden { - my $self = shift; - return WebGUI::Form::HiddenList->new( - value=>$self->{value}, - defaultValue=>$self->{defaultValue}, - name=>$self->{name}, - options=>$self->{options} - )->toHtmlAsHidden; -} - 1; diff --git a/lib/WebGUI/Form/Checkbox.pm b/lib/WebGUI/Form/Checkbox.pm index 8967fa908..bbdf1f5fb 100644 --- a/lib/WebGUI/Form/Checkbox.pm +++ b/lib/WebGUI/Form/Checkbox.pm @@ -65,6 +65,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("943","WebGUI") + }, checked=>{ defaultValue=> 0 }, @@ -91,19 +94,6 @@ sub generateIdParameter { return undef } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("943","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/Codearea.pm b/lib/WebGUI/Form/Codearea.pm index 0401da725..981a018c8 100644 --- a/lib/WebGUI/Form/Codearea.pm +++ b/lib/WebGUI/Form/Codearea.pm @@ -59,6 +59,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("codearea","WebGUI") + }, profileEnabled=>{ defaultValue=>1 } @@ -66,19 +69,6 @@ sub definition { return $class->SUPER::definition($definition); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("codearea","WebGUI"); -} - - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/Color.pm b/lib/WebGUI/Form/Color.pm index 628f3e5c8..7d0431a72 100644 --- a/lib/WebGUI/Form/Color.pm +++ b/lib/WebGUI/Form/Color.pm @@ -40,17 +40,23 @@ The following methods are specifically available from this class. Check the supe #------------------------------------------------------------------- -=head2 getName () +=head2 definition ( ) -Returns the human readable name or type of this form control. +See the super class for additional details. =cut -sub getName { - return WebGUI::International::get("color","WebGUI"); +sub definition { + my $class = shift; + my $definition = shift || []; + push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("color","WebGUI") + }, + }); + return $class->SUPER::definition($definition); } - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/Combo.pm b/lib/WebGUI/Form/Combo.pm index 5b15b15dd..89464f1c0 100644 --- a/lib/WebGUI/Form/Combo.pm +++ b/lib/WebGUI/Form/Combo.pm @@ -15,7 +15,7 @@ package WebGUI::Form::Combo; =cut use strict; -use base 'WebGUI::Form::SelectList'; +use base 'WebGUI::Form::SelectBox'; use WebGUI::Form::Text; use WebGUI::International; use WebGUI::Session; @@ -30,7 +30,7 @@ Creates a select list merged with a text box form control. =head1 SEE ALSO -This is a subclass of WebGUI::Form::SelectList. +This is a subclass of WebGUI::Form::SelectBox. =head1 METHODS @@ -59,6 +59,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("combobox","WebGUI") + }, profileEnabled=>{ defaultValue=>1 } @@ -66,19 +69,6 @@ sub definition { return $class->SUPER::definition($definition); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("combobox","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/ContentType.pm b/lib/WebGUI/Form/ContentType.pm index fb239af8e..b205a87fa 100644 --- a/lib/WebGUI/Form/ContentType.pm +++ b/lib/WebGUI/Form/ContentType.pm @@ -15,8 +15,7 @@ package WebGUI::Form::ContentType; =cut use strict; -use base 'WebGUI::Form::Control'; -use WebGUI::Form::SelectList; +use base 'WebGUI::Form::SelectBox'; use WebGUI::International; use WebGUI::Session; @@ -30,7 +29,7 @@ Creates a content type selector which can be used in conjunction with WebGUI::HT =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectBox. =head1 METHODS @@ -66,8 +65,11 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("1007","WebGUI") + }, label=>{ - defaultValue=>$class->getName() + defaultValue=>WebGUI::International::get("1007","WebGUI") }, types=>{ defaultValue=>[qw(mixed html code text)] @@ -79,33 +81,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("1007","WebGUI"); -} - - -#------------------------------------------------------------------- - -=head2 getValueFromPost ( ) - -Returns either what's posted or if nothing comes back it returns "mixed". - -=cut - -sub getValueFromPost { - my $self = shift; - return $session{req}->param($self->{name}) || "mixed"; -} - #------------------------------------------------------------------- =head2 toHtml ( ) @@ -128,18 +103,8 @@ sub toHtml { $types{html} = WebGUI::International::get(1009); } } - return WebGUI::Form::SelectList->new( - options=>\%types, - id=>$self->{id}, - name=>$self->{name}, - value=>[$self->{value}], - extras=>$self->{extras}, - defaultValue=>[$self->{defaultValue}] - )->toHtml; - + $self->{options} = \%types, + return $self->SUPER::toHtml(); } - - 1; - diff --git a/lib/WebGUI/Form/Control.pm b/lib/WebGUI/Form/Control.pm index 8c2428ee8..d9d080a83 100644 --- a/lib/WebGUI/Form/Control.pm +++ b/lib/WebGUI/Form/Control.pm @@ -92,6 +92,10 @@ Add extra attributes to the form tag like onmouseover='doSomething()' +=head4 formName + +The internationalized form name. + =head4 label A text label that will be displayed if toHtmlWithWrapper() is called. @@ -144,6 +148,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>'A name for this form was not supplied' + }, name=>{ defaultValue=>undef }, @@ -273,7 +280,9 @@ Returns a human readable name for this form control type. You MUST override this =cut sub getName { - return "Form control not properly created." + my $self = shift; + my $definition = $self->definition; + return $definition->[0]->{formName}->{defaultValue}; } @@ -358,18 +367,23 @@ sub fixTags { =head2 getValueFromPost ( ) -Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. +Retrieves a value from a form GET or POST and returns it. If the value +comes back as undef, this method will return the defaultValue instead. +It also handles return data in list or scalar contexts. If a Form +field that supports multiple select requests its values in scalar +context, it will return a newline "\n" separated scalar. =cut sub getValueFromPost { my $self = shift; - my $formValue = $session{req}->param($self->{name}); - if (defined $formValue) { - return $formValue; - } else { - return $self->{defaultValue}; + my @formValues = $session{req}->param($self->{name}); + unless (@formValues) { + @formValues = (ref $self->{defaultValue} eq "ARRAY") + ? @{$self->{defaultValue} } + : ( $self->{defaultValue} ); } + return wantarray ? @formValues : join("\n",@formValues); } #------------------------------------------------------------------- @@ -467,7 +481,6 @@ sub prepareWrapper { return ($fieldClass, $rowClass, $labelClass, $hoverHelp, $subtext); } - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/DatabaseLink.pm b/lib/WebGUI/Form/DatabaseLink.pm index 24da56bca..3b0c254b9 100644 --- a/lib/WebGUI/Form/DatabaseLink.pm +++ b/lib/WebGUI/Form/DatabaseLink.pm @@ -15,9 +15,8 @@ package WebGUI::Form::DatabaseLink; =cut use strict; -use base 'WebGUI::Form::Control'; +use base 'WebGUI::Form::SelectBox'; use WebGUI::DatabaseLink; -use WebGUI::Form::SelectList; use WebGUI::Grouping; use WebGUI::Icon; use WebGUI::International; @@ -34,7 +33,7 @@ Creates a database connection chooser control. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectBox. =head1 METHODS @@ -78,8 +77,11 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("1075","WebGUI") + }, label=>{ - defaultValue=>$class->getName() + defaultValue=>WebGUI::International::get("1075","WebGUI") }, name=>{ defaultValue=>"databaseLinkId" @@ -99,18 +101,6 @@ sub definition { #------------------------------------------------------------------- -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("1075","WebGUI"); -} - -#------------------------------------------------------------------- - =head2 toHtml ( ) Renders a database connection picker control. @@ -119,13 +109,8 @@ Renders a database connection picker control. sub toHtml { my $self = shift; - return WebGUI::Form::SelectList->new( - id=>$self->{id}, - name=>$self->{name}, - options=>WebGUI::DatabaseLink::getList(), - value=>[$self->{value}], - extras=>$self->{extras} - )->toHtml; + $self->{options} = WebGUI::DatabaseLink::getList(); + return $self->SUPER::toHtml(); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form/Date.pm b/lib/WebGUI/Form/Date.pm index e31cb3ca8..20f00eea9 100644 --- a/lib/WebGUI/Form/Date.pm +++ b/lib/WebGUI/Form/Date.pm @@ -77,6 +77,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("479","WebGUI") + }, defaultValue=>{ defaultValue=>time() }, @@ -109,19 +112,6 @@ sub displayValue { return WebGUI::DateTime::epochToHuman($self->{value},"%z"); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("479","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/DateTime.pm b/lib/WebGUI/Form/DateTime.pm index f8882975f..b7d9b547c 100644 --- a/lib/WebGUI/Form/DateTime.pm +++ b/lib/WebGUI/Form/DateTime.pm @@ -72,6 +72,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("972","WebGUI") + }, defaultValue=>{ defaultValue=>time() }, @@ -88,19 +91,6 @@ sub definition { return $class->SUPER::definition($definition); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("972","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/DynamicField.pm b/lib/WebGUI/Form/DynamicField.pm index da13db158..28674bcfb 100644 --- a/lib/WebGUI/Form/DynamicField.pm +++ b/lib/WebGUI/Form/DynamicField.pm @@ -38,7 +38,6 @@ The following methods are specifically available from this class. Check the supe =cut - #------------------------------------------------------------------- =head2 definition ( [ additionalTerms ] ) @@ -59,6 +58,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("475","WebGUI"), + }, fieldType=>{ defaultValue=> "Text" }, @@ -66,20 +68,6 @@ sub definition { return $class->SUPER::definition($definition); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("475","WebGUI"); -} - - - #------------------------------------------------------------------- =head2 new ( params) @@ -98,35 +86,21 @@ sub new { my $param = \%raw; my $fieldType = ucfirst($param->{fieldType}); delete $param->{fieldType}; - # Set options for fields that use a list. - if (isIn($fieldType,qw(SelectList CheckList RadioList))) { - delete $param->{size}; - my %options; - tie %options, 'Tie::IxHash'; - foreach (split(/\n/, $param->{possibleValues})) { - s/\s+$//; # remove trailing spaces - $options{$_} = $_; - } - if (exists $param->{options} && ref($param->{options}) eq "HASH") { - %options = (%{$param->{options}} , %options); - } - $param->{options} = \%options; - } - # Convert value to list for selectList / checkList - if (isIn($fieldType,qw(SelectList CheckList)) && ref $param->{value} ne "ARRAY") { - my @defaultValues; - foreach (split(/\n/, $param->{value})) { - s/\s+$//; # remove trailing spaces - push(@defaultValues, $_); - } - $param->{value} = \@defaultValues; - } - + my $size; + if (exists $param->{size}) { + $size = $param->{size}; + delete $param->{size}; + } # Return the appropriate field object. if ($fieldType eq "") { WebGUI::ErrorHandler::warn("Something is trying to create a dynamic field called ".$param->{name}.", but didn't pass in a field type."); $fieldType = "Text"; } + ##No infinite loops, please + elsif ($fieldType eq 'DynamicField') { + WebGUI::ErrorHandler::warn("Something is trying to create a DynamicField via DynamicField."); + $fieldType = "Text"; + } no strict 'refs'; my $cmd = "WebGUI::Form::".$fieldType; my $load = "use ".$cmd; @@ -135,8 +109,19 @@ sub new { WebGUI::ErrorHandler::error("Couldn't compile form control: ".$fieldType.". Root cause: ".$@); return undef; } - return $cmd->new($param); + my $formObj = $cmd->new($param); + ##Fix up methods for List type forms and restore the size to all Forms *except* + ##List type forms + if ($formObj->isa('WebGUI::Form::List')) { + $formObj->correctValues($param->{value}); + $formObj->correctOptions($param->{possibleValues}); + } + elsif ($size) { + $formObj->{size} = $size; + } + return $formObj; } + 1; diff --git a/lib/WebGUI/Form/Email.pm b/lib/WebGUI/Form/Email.pm index f19e9e032..3b33013a1 100644 --- a/lib/WebGUI/Form/Email.pm +++ b/lib/WebGUI/Form/Email.pm @@ -58,6 +58,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("480","WebGUI") + }, profileEnabled=>{ defaultValue=>1 } @@ -65,19 +68,6 @@ sub definition { return $class->SUPER::definition($definition); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("480","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/FieldType.pm b/lib/WebGUI/Form/FieldType.pm index b8c90efe7..0e4b622a4 100644 --- a/lib/WebGUI/Form/FieldType.pm +++ b/lib/WebGUI/Form/FieldType.pm @@ -15,10 +15,10 @@ package WebGUI::Form::FieldType; =cut use strict; -use base 'WebGUI::Form::Control'; -use WebGUI::Form::SelectList; +use base 'WebGUI::Form::SelectBox'; use WebGUI::International; use WebGUI::Session; +use WebGUI::Utility; use Tie::IxHash; =head1 NAME @@ -31,7 +31,7 @@ Creates a form control that will allow you to select a form control type. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectBox. =head1 METHODS @@ -49,10 +49,6 @@ See the super class for additional details. The following additional parameters have been added via this sub class. -=head4 size - -Defaults to 1. How many characters tall should this control be represented. - =head4 types An array reference containing the form control types to be selectable. Defaults to all available types. @@ -67,11 +63,11 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { - label=>{ - defaultValue=>$class->getName() + formName=>{ + defaultValue=>WebGUI::International::get("fieldtype","WebGUI") }, - size=>{ - defaultValue=>1 + label=>{ + defaultValue=>WebGUI::International::get("fieldtype","WebGUI") }, types=>{ defaultValue=>$class->getTypes @@ -82,21 +78,12 @@ sub definition { #------------------------------------------------------------------- -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("744","WebGUI"); -} - -#------------------------------------------------------------------- - =head2 getTypes ( ) -A class method that returns an array reference of all the form control types present in the system. +A class method that returns an array reference of all the valid form +control types present in the system. Invalid form types include +Control.pm, the form master class and List, the list form master class +and DynamicField, the form class dispatcher. =cut @@ -108,7 +95,7 @@ sub getTypes { my @types; foreach my $type (@rawTypes) { if ($type =~ /^(.*)\.pm$/) { - next if ($1 eq "Control"); + next if (isIn($1, qw/Control List DynamicField/)); push(@types,$1); } } @@ -150,14 +137,9 @@ sub toHtml { } $options{$type} = $class->getName; } - return WebGUI::Form::SelectList->new( - id=>$self->{id}, - name=>$self->{name}, - options=>\%options, - value=>[$self->{value}], - extras=>$self->{extras}, - size=>$self->{size} - )->toHtml; + $self->{options} = \%options; + + return $self->SUPER::toHtml(); } diff --git a/lib/WebGUI/Form/File.pm b/lib/WebGUI/Form/File.pm index 0dd15c7e9..1530e29ca 100644 --- a/lib/WebGUI/Form/File.pm +++ b/lib/WebGUI/Form/File.pm @@ -67,6 +67,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("file","WebGUI") + }, name=>{ defaultValue=>"file" }, @@ -128,20 +131,6 @@ sub displayValue { return $fileValue; } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("file","WebGUI"); -} - - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/FilterContent.pm b/lib/WebGUI/Form/FilterContent.pm index b75ce6a69..273aced1d 100644 --- a/lib/WebGUI/Form/FilterContent.pm +++ b/lib/WebGUI/Form/FilterContent.pm @@ -15,9 +15,8 @@ package WebGUI::Form::FilterContent; =cut use strict; -use base 'WebGUI::Form::Control'; +use base 'WebGUI::Form::SelectBox'; use Tie::IxHash; -use WebGUI::Form::SelectList; use WebGUI::International; use WebGUI::Session; @@ -31,7 +30,7 @@ Creates a select list containing the content filter options. This is for use wit =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectBox. =head1 METHODS @@ -53,47 +52,36 @@ The following additional parameters have been added via this sub class. The name of this field to be passed through the URI. Defaults to "filterContent". +=head4 defaultValue + +Defaults to "most". Possible values are "none", "macros", "javascript", "most" and "all". + =head4 hoverHelp A tooltip for what to do with this field. Defaults to a general explaination of content filters. -=head4 label - -A text label that will be displayed if toHtmlWithWrapper() is called. Defaults to getName(). - =cut sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { - label=>{ - defaultValue=>$class->getName() + formName=>{ + defaultValue=>WebGUI::International::get("418","WebGUI") }, name=>{ defaultValue=>"filterContent" }, hoverHelp=>{ - defaultValue=>WebGUI::International::get('418 description') - } + defaultValue=>WebGUI::International::get('418 description', 'WebGUI') + }, + defaultValue=>{ + defaultValue=>"most", + }, }); return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("418","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) @@ -126,17 +114,8 @@ sub toHtml { 'most'=>WebGUI::International::get(421), 'all'=>WebGUI::International::get(419) ); - return WebGUI::Form::SelectList->new( - id=>$self->{id}, - options=>\%filter, - name=>$self->{name}, - value=>[$self->{value}], - extras=>$self->{extras}, - defaultValue=>[$self->{defaultValue}] - )->toHtml; - + $self->{options} = \%filter; + return $self->SUPER::toHtml(); } - 1; - diff --git a/lib/WebGUI/Form/Float.pm b/lib/WebGUI/Form/Float.pm index 0406386c1..ea968db86 100644 --- a/lib/WebGUI/Form/Float.pm +++ b/lib/WebGUI/Form/Float.pm @@ -70,6 +70,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("float","WebGUI") + }, maxlength=>{ defaultValue=> 14 }, @@ -86,20 +89,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("float","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/Group.pm b/lib/WebGUI/Form/Group.pm index a53a23b16..44ebca8a6 100644 --- a/lib/WebGUI/Form/Group.pm +++ b/lib/WebGUI/Form/Group.pm @@ -15,9 +15,7 @@ package WebGUI::Form::Group; =cut use strict; -use base 'WebGUI::Form::Control'; -use WebGUI::Form::HiddenList; -use WebGUI::Form::SelectList; +use base 'WebGUI::Form::SelectList'; use WebGUI::Grouping; use WebGUI::Icon; use WebGUI::International; @@ -26,7 +24,7 @@ use WebGUI::SQL; =head1 NAME -Package WebGUI::Form::group +Package WebGUI::Form::Group =head1 DESCRIPTION @@ -34,7 +32,7 @@ Creates a group chooser field. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectList. =head1 METHODS @@ -68,10 +66,6 @@ An array reference containing a list of groups to exclude from the list. Default This will be used if no value is specified. Should be passed as an array reference. Defaults to 7 (Everyone). -=head4 label - -A text label that will be displayed if toHtmlWithWrapper() is called. Defaults to getName(). - =head4 profileEnabled Flag that tells the User Profile system that this is a valid form element in a User Profile @@ -82,18 +76,18 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { - label=>{ - defaultValue=>$class->getName() + formName=>{ + defaultValue=>WebGUI::International::get("group","WebGUI") }, size=>{ defaultValue=>1 }, - defaultValue=>{ - defaultValue=>[7] - }, multiple=>{ defaultValue=>0 }, + defaultValue=>{ + defaultValue=>[7] + }, excludeGroups=>{ defaultValue=>[] }, @@ -104,37 +98,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("group","WebGUI"); -} - - -#------------------------------------------------------------------- - -=head2 getValueFromPost ( ) - -Returns either what's posted or if nothing comes back it returns "2" the ID of the Registered Users group. - -=cut - -sub getValueFromPost { - my $self = shift; - my @data = $session{req}->param($self->{name}); - if (scalar(@data)) { - return wantarray ? @data : join("\n",@data); - } - return wantarray ? @{[2]} : 2; -} - #------------------------------------------------------------------- =head2 toHtml ( ) @@ -149,17 +112,8 @@ sub toHtml { if ($self->{excludeGroups}[0] ne "") { $where = "and groupId not in (".quoteAndJoin($self->{excludeGroups}).")"; } - return WebGUI::Form::SelectList->new( - options=>WebGUI::SQL->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName"), - name=>$self->{name}, - id=>$self->{id}, - value=>$self->{value}, - extras=>$self->{extras}, - size=>$self->{size}, - multiple=>$self->{multiple}, - defaultValue=>$self->{defaultValue} - )->toHtml; - + $self->{options} = WebGUI::SQL->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName"); + return $self->SUPER::toHtml(); } #------------------------------------------------------------------- @@ -172,12 +126,8 @@ Creates a series of hidden fields representing the data in the list. sub toHtmlAsHidden { my $self = shift; - return WebGUI::Form::HiddenList->new( - value=>$self->{value}, - defaultValue=>$self->{defaultValue}, - name=>$self->{name}, - options=>WebGUI::SQL->buildHashRef("select groupId,groupName from groups") - )->toHtmlAsHidden; + $self->{options} = WebGUI::SQL->buildHashRef("select groupId,groupName from groups"); + return $self->SUPER::toHtmlAsHidden(); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form/HTMLArea.pm b/lib/WebGUI/Form/HTMLArea.pm index b4e410863..48effdfe4 100644 --- a/lib/WebGUI/Form/HTMLArea.pm +++ b/lib/WebGUI/Form/HTMLArea.pm @@ -73,6 +73,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("477","WebGUI") + }, rows=>{ defaultValue=> $session{setting}{textAreaRows}+20 }, @@ -89,19 +92,6 @@ sub definition { return $class->SUPER::definition($definition); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("477","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/Hidden.pm b/lib/WebGUI/Form/Hidden.pm index 90aeee105..7c4b486dc 100644 --- a/lib/WebGUI/Form/Hidden.pm +++ b/lib/WebGUI/Form/Hidden.pm @@ -57,9 +57,12 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("hidden","WebGUI") + }, profileEnabled=>{ defaultValue=>1 - } + }, }); return $class->SUPER::definition($definition); } @@ -76,19 +79,6 @@ sub generateIdParameter { return undef } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("hidden","WebGUI"); -} - - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/HiddenList.pm b/lib/WebGUI/Form/HiddenList.pm index a34302cd6..0b2aec3f6 100644 --- a/lib/WebGUI/Form/HiddenList.pm +++ b/lib/WebGUI/Form/HiddenList.pm @@ -15,7 +15,7 @@ package WebGUI::Form::HiddenList; =cut use strict; -use base 'WebGUI::Form::Control'; +use base 'WebGUI::Form::List'; use WebGUI::International; use WebGUI::Session; @@ -25,11 +25,11 @@ Package WebGUI::Form::HiddenList =head1 DESCRIPTION -Creates a list of hidden fields. This is to be used by list type controls (selectList, checkList, etc) to store their vaiuses as hidden values. +Creates a list of hidden fields. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::List. =head1 METHODS @@ -65,11 +65,8 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { - options=>{ - defaultValue=>{} - }, - defaultValue=>{ - defaultValue=>[] + formName=>{ + defaultValue=>WebGUI::International::get("hidden list","WebGUI"), }, profileEnabled=>{ defaultValue=>1 @@ -78,20 +75,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("hidden list","WebGUI"); -} - - #------------------------------------------------------------------- =head2 toHtml ( ) @@ -102,31 +85,7 @@ A synonym for toHtmlAsHidden. sub toHtml { my $self = shift; - $self->toHtmlAsHidden; -} - -#------------------------------------------------------------------- - -=head2 toHtmlAsHidden ( ) - -Renders an input tag of type hidden. - -=cut - -sub toHtmlAsHidden { - my $self = shift; - my $output; - foreach my $key (keys %{$self->{options}}) { - foreach my $item (@{$self->{value}}) { - if ($item eq $key) { - $output .= WebGUI::Form::Hidden->( - name=>$self->{name}, - value=>$key - ); - } - } - } - return $output; + return $self->toHtmlAsHidden; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form/Image.pm b/lib/WebGUI/Form/Image.pm index f9c5060bf..4209719c9 100644 --- a/lib/WebGUI/Form/Image.pm +++ b/lib/WebGUI/Form/Image.pm @@ -69,6 +69,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("image","WebGUI") + }, name=>{ defaultValue=>"file" }, @@ -103,18 +106,4 @@ sub displayValue { return $fileValue; } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("image","WebGUI"); -} - 1; - - diff --git a/lib/WebGUI/Form/Integer.pm b/lib/WebGUI/Form/Integer.pm index 41745ba9f..56c3baff3 100644 --- a/lib/WebGUI/Form/Integer.pm +++ b/lib/WebGUI/Form/Integer.pm @@ -70,6 +70,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("482","WebGUI") + }, maxlength=>{ defaultValue=> 11 }, @@ -86,20 +89,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("482","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/Interval.pm b/lib/WebGUI/Form/Interval.pm index 55714bb7a..d992f4ed9 100644 --- a/lib/WebGUI/Form/Interval.pm +++ b/lib/WebGUI/Form/Interval.pm @@ -19,9 +19,9 @@ use warnings; use base qw(WebGUI::Form::Control); use Tie::IxHash; use WebGUI::DateTime; +use WebGUI::Form::SelectBox; use WebGUI::Form::Hidden; use WebGUI::Form::Integer; -use WebGUI::Form::SelectList; use WebGUI::International; use WebGUI::Session; @@ -67,6 +67,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("interval","WebGUI"), + }, defaultValue=>{ defaultValue=>1, }, @@ -77,20 +80,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("interval","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) @@ -133,7 +122,7 @@ sub toHtml { extras=>$self->{extras}, id=>$self->{id}."_interval", )->toHtml; - $cmd = "WebGUI::Form::SelectList"; + $cmd = "WebGUI::Form::SelectBox"; $out .= $cmd->new( options=>\%units, name=>$self->{name}."_units", diff --git a/lib/WebGUI/Form/LdapLink.pm b/lib/WebGUI/Form/LdapLink.pm index 663e7dd13..40747de9c 100644 --- a/lib/WebGUI/Form/LdapLink.pm +++ b/lib/WebGUI/Form/LdapLink.pm @@ -15,10 +15,8 @@ package WebGUI::Form::LdapLink; =cut use strict; -use base 'WebGUI::Form::Control'; +use base 'WebGUI::Form::SelectList'; use WebGUI::LDAPLink; -use WebGUI::Form::SelectList; -use WebGUI::Form::HiddenList; use WebGUI::Grouping; use WebGUI::Icon; use WebGUI::International; @@ -35,7 +33,7 @@ Creates an LDAP connection chooser control. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectList. =head1 METHODS @@ -57,6 +55,14 @@ The following additional parameters have been added via this sub class. The identifier for this field. Defaults to "ldapLinkId". +=head4 size + +The number of characters tall this list should be. Defaults to '1'. + +=head4 multiple + +Boolean indicating whether the user can select multiple items from this list like a checkList. Defaults to "0". + =head4 defaultValue An LDAP link id. Defaults to "0", which is nothing. @@ -65,14 +71,6 @@ An LDAP link id. Defaults to "0", which is nothing. A URL that will be acted upon after editing an LDAP link. -=head4 size - -The number of characters tall this list should be. Defaults to '1'. - -=head4 multiple - -Boolean indicating whether the user can select multiple items from this list like a checkList. Defaults to "0". - =head4 label A text label that will be displayed if toHtmlWithWrapper() is called. Defaults to getName(). @@ -83,14 +81,11 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("LDAPLink_1075","AuthLDAP") + }, label=>{ - defaultValue=>$class->getName() - }, - name=>{ - defaultValue=>"ldapLinkId" - }, - defaultValue=>{ - defaultValue=>[0] + defaultValue=>WebGUI::International::get("LDAPLink_1075","AuthLDAP") }, size=>{ defaultValue=>1 @@ -98,6 +93,12 @@ sub definition { multiple=>{ defaultValue=>0 }, + name=>{ + defaultValue=>"ldapLinkId" + }, + defaultValue=>{ + defaultValue=>[0] + }, afterEdit=>{ defaultValue=>undef } @@ -107,32 +108,6 @@ sub definition { #------------------------------------------------------------------- -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("LDAPLink_1075","AuthLDAP"); -} - -#------------------------------------------------------------------- - -=head2 getValueFromPost ( ) - -Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar. - -=cut - -sub getValueFromPost { - my $self = shift; - my @data = $session{req}->param($self->{name}); - return wantarray ? @data : join("\n",@data); -} - -#------------------------------------------------------------------- - =head2 toHtml ( ) Renders a database connection picker control. @@ -141,15 +116,8 @@ Renders a database connection picker control. sub toHtml { my $self = shift; - return WebGUI::Form::SelectList->new( - name=>$self->{name}, - id=>$self->{id}, - options=>WebGUI::LDAPLink::getList(), - value=>$self->{value}, - multiple=>$self->{multiple}, - size=>$self->{size}, - extras=>$self->{extras} - )->toHtml; + $self->{options} = WebGUI::LDAPLink::getList(); + return $self->SUPER::toHtml(); } #------------------------------------------------------------------- @@ -162,11 +130,8 @@ Creates a series of hidden fields representing the data in the list. sub toHtmlAsHidden { my $self = shift; - return WebGUI::Form::HiddenList->new( - value=>$self->{value}, - name=>$self->{name}, - options=>WebGUI::LDAPLink::getList() - )->toHtmlAsHidden; + $self->{options} = WebGUI::LDAPLink::getList(); + return $self->SUPER::toHtmlAsHidden(); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form/List.pm b/lib/WebGUI/Form/List.pm new file mode 100644 index 000000000..987a2b81a --- /dev/null +++ b/lib/WebGUI/Form/List.pm @@ -0,0 +1,257 @@ +package WebGUI::Form::List; + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2005 Plain Black Corporation. + ------------------------------------------------------------------- + Please read the legal notices (docs/legal.txt) and the license + (docs/license.txt) that came with this distribution before using + this software. + ------------------------------------------------------------------- + http://www.plainblack.com info@plainblack.com + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Form::Control'; +use WebGUI::International; +use WebGUI::Session; + +=head1 NAME + +Package WebGUI::Form::List + +=head1 DESCRIPTION + +Master class for all list type form elements. Not useful by itself. + +=head1 SEE ALSO + +This is a subclass of WebGUI::Form::Control. + +=head1 METHODS + +The following methods are specifically available from this class. Check the superclass for additional methods. + +=cut + +#------------------------------------------------------------------- + +=head2 alignmentSeparator ( ) + +Return an HTML separator to generate either horizontal or vertical lists +of radio/check boxes. + +=cut + +sub alignmentSeparator { + my ($self) = @_; + if ($self->{vertical}) { + return "
\n"; + } + else { + return "    \n"; + } +} + +#------------------------------------------------------------------- + +=head2 correctOptions ( ) + +Parse a string for a list of options to present to the user. This method +will mainly be called from WebGUI::Form::DynamicField. +=cut + +sub correctOptions { + my ($self, $possibleValues) = @_; + my %options; + tie %options, 'Tie::IxHash'; + foreach (split(/\n/, $possibleValues)) { + s/\s+$//; # remove trailing spaces + $options{$_} = $_; + } + if (exists $self->{options} && ref($self->{options}) eq "HASH") { + %options = (%{$self->{options}} , %options); + } + $self->{options} = \%options; +} + + +##------------------------------------------------------------------- + +=head2 correctValues ( ) + +Parse a string for a list of values that should be selected. This method +will mainly be called from WebGUI::Form::DynamicField. Form types that +don't have multiple select, like RadioLists, need to override this +method. + +=cut + +sub correctValues { + my ($self, $value) = @_; + return unless defined $value; + my @defaultValues; + foreach (split(/\n/, $self->{value})) { + s/\s+$//; # remove trailing spaces + push(@defaultValues, $_); + } + $self->{value} = \@defaultValues; +} + + +#------------------------------------------------------------------- + +=head2 definition ( [ additionalTerms ] ) + +See the super class for additional details. + +=head3 additionalTerms + +The following additional parameters have been added via this sub class. + +=head4 options + +A hash reference containing key values that will be returned with the form post and displayable text pairs. Defaults to an empty hash reference. + +=head4 defaultValue + +An array reference of the items to be checked if no value is specified. Defaults to an empty array reference. + +=head4 size + +The number of characters tall this list should be. Defaults to '1'. + +=head4 multiple + +A boolean indicating whether the user can select multiple items from this list like a checkList. Defaults to "0". + +=head4 sortByValue + +A boolean value for whether or not the values in the options hash should be sorted. Defaults to "0". + +=head4 profileEnabled + +Flag that tells the User Profile system that this is a valid form element in a User Profile + +=cut + +sub definition { + my $class = shift; + my $definition = shift || []; + push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("486","WebGUI"), + }, + options=>{ + defaultValue=>{} + }, + defaultValue=>{ + defaultValue=>[], + }, + multiple=>{ + defaultValue=>0 + }, + sortByValue=>{ + defaultValue=>0 + }, + size=>{ + defaultValue=>1 + }, + profileEnabled=>{ + defaultValue=>0 + }, + }); + return $class->SUPER::definition($definition); +} + + +#------------------------------------------------------------------- + +=head2 displayValue ( ) + +Return all the options + +=cut + +sub displayValue { + my ($self) = @_; + return join ", ", $self->getValues(); +} + +#------------------------------------------------------------------- + +=head2 getValues ( ) + +Handle returning an array regardless of whether the form values are a scalar or array. + +=cut + +sub getValues { + my $self = shift; + my @values = (); + if (ref $self->{value} eq 'ARRAY') { + @values = @{ $self->{value} }; + } + else { + push @values, $self->{value}; + } + return @values; +} + +#------------------------------------------------------------------- + +=head2 orderedHash ( ) + +Based on whether the sortByValue flag is set, return the options hash +for List type Forms sorted by values. The sort is done without regard +to the case of the values. + +=cut + +sub orderedHash { + my ($self) = @_; + my %options; + tie %options, 'Tie::IxHash'; + if ($self->{sortByValue}) { + foreach my $optionKey (sort {"\L${$self->{options}}{$a}" cmp "\L${$self->{options}}{$b}" } keys %{$self->{options}}) { + $options{$optionKey} = $self->{options}{$optionKey}; + } + } else { + %options = %{$self->{options}}; + } + return %options; +} + +#------------------------------------------------------------------- + +=head2 toHtmlAsHidden ( ) + +Creates a series of hidden fields representing the data in the list. + +=cut + +sub toHtmlAsHidden { + my $self = shift; + my %options; + tie %options, 'Tie::IxHash'; + %options = $self->orderedHash(); + my $output; + my @values = $self->getValues(); + foreach my $key (keys %options) { + foreach my $item (@values) { + if ($item eq $key) { + $output .= WebGUI::Form::Hidden->( + name=>$self->{name}, + value=>$key + ); + } + } + } + return $output; +} + +1; + diff --git a/lib/WebGUI/Form/Password.pm b/lib/WebGUI/Form/Password.pm index cc3b126e7..be8f53d9c 100644 --- a/lib/WebGUI/Form/Password.pm +++ b/lib/WebGUI/Form/Password.pm @@ -65,6 +65,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("51","WebGUI") + }, maxlength=>{ defaultValue=>35 }, @@ -78,21 +81,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("51","WebGUI"); -} - - - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/Phone.pm b/lib/WebGUI/Form/Phone.pm index 7c1ad8ecb..a2f2adf21 100644 --- a/lib/WebGUI/Form/Phone.pm +++ b/lib/WebGUI/Form/Phone.pm @@ -58,26 +58,16 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("481","WebGUI") + }, profileEnabled=>{ defaultValue=>1 - } + }, }); return $class->SUPER::definition($definition); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("944","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/Radio.pm b/lib/WebGUI/Form/Radio.pm index 3bf67007d..9b3543c6a 100644 --- a/lib/WebGUI/Form/Radio.pm +++ b/lib/WebGUI/Form/Radio.pm @@ -61,6 +61,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("radio","WebGUI") + }, checked=>{ defaultValue=> 0 }, @@ -84,19 +87,6 @@ sub generateIdParameter { return undef } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("radio","WebGUI"); -} - - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/RadioList.pm b/lib/WebGUI/Form/RadioList.pm index 41c6974fb..d5154add0 100644 --- a/lib/WebGUI/Form/RadioList.pm +++ b/lib/WebGUI/Form/RadioList.pm @@ -15,7 +15,7 @@ package WebGUI::Form::RadioList; =cut use strict; -use base 'WebGUI::Form::Control'; +use base 'WebGUI::Form::List'; use WebGUI::Form::Radio; use WebGUI::International; use WebGUI::Session; @@ -30,7 +30,7 @@ Creates a series of radio button form fields. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. Also take a look ath WebGUI::Form::checkbox as this class creates a list of checkboxes. +This is a subclass of WebGUI::Form::List. Also take a look at WebGUI::Form::Radio as this class creates a list of radio buttons. =head1 METHODS @@ -38,6 +38,17 @@ The following methods are specifically available from this class. Check the supe =cut +##------------------------------------------------------------------- + +=head2 correctValues ( ) + +Override method from master class since RadioList only supports a single value + +=cut + +sub correctValues { } + + #------------------------------------------------------------------- =head2 definition ( [ additionalTerms ] ) @@ -48,10 +59,6 @@ See the super class for additional details. The following additional parameters have been added via this sub class. -=head4 options - -A hash reference containing key values that will be returned with the form post and displayable text pairs. Defaults to an empty hash reference. - =head4 vertical Boolean representing whether the checklist should be represented vertically or horizontally. If set to "1" will be displayed vertically. Defaults to "0". @@ -66,8 +73,8 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { - options=>{ - defaultValue=>{} + formName=>{ + defaultValue=>WebGUI::International::get("942","WebGUI") }, vertical=>{ defaultValue=>0 @@ -80,32 +87,6 @@ sub definition { } -#------------------------------------------------------------------- - -=head2 displayValue ( ) - -Return the all options - -=cut - -sub displayValue { - my ($self) = @_; - return join ", ", @{ $self->{value} }; -} - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("942","WebGUI"); -} - - #------------------------------------------------------------------- =head2 toHtml ( ) @@ -117,14 +98,11 @@ Renders a series of radio buttons. sub toHtml { my $self = shift; my $output; - my $alignment; - if ($self->{vertical}) { - $alignment = "
\n"; - } - else { - $alignment = "    \n"; - } - foreach my $key (keys %{$self->{options}}) { + my $alignment = $self->alignmentSeparator; + my %options; + tie %options, 'Tie::IxHash'; + %options = $self->orderedHash; + foreach my $key (keys %options) { my $checked = 0; if ($self->{value} eq $key) { $checked = 1; diff --git a/lib/WebGUI/Form/ReadOnly.pm b/lib/WebGUI/Form/ReadOnly.pm index 97c14ad0b..1bb52a4c0 100644 --- a/lib/WebGUI/Form/ReadOnly.pm +++ b/lib/WebGUI/Form/ReadOnly.pm @@ -58,27 +58,16 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("read only","WebGUI") + }, profileEnabled=>{ defaultValue=>1 - } + }, }); return $class->SUPER::definition($definition); } -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("read only","WebGUI"); -} - - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) @@ -91,7 +80,6 @@ sub getValueFromPost { return undef; } - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/SelectBox.pm b/lib/WebGUI/Form/SelectBox.pm new file mode 100644 index 000000000..2c0a7c0cc --- /dev/null +++ b/lib/WebGUI/Form/SelectBox.pm @@ -0,0 +1,104 @@ +package WebGUI::Form::SelectBox; + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2005 Plain Black Corporation. + ------------------------------------------------------------------- + Please read the legal notices (docs/legal.txt) and the license + (docs/license.txt) that came with this distribution before using + this software. + ------------------------------------------------------------------- + http://www.plainblack.com info@plainblack.com + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Form::List'; +use WebGUI::International; +use WebGUI::Session; + +=head1 NAME + +Package WebGUI::Form::SelectBox + +=head1 DESCRIPTION + +Creates a select list, aka dropdown list form control with single select. + +=head1 SEE ALSO + +This is a subclass of WebGUI::Form::List. + +=head1 METHODS + +The following methods are specifically available from this class. Check the superclass for additional methods. + +=cut + +#------------------------------------------------------------------- + +=head2 definition ( [ additionalTerms ] ) + +See the super class for additional details. + +=head3 additionalTerms + +The following additional parameters have been added via this sub class. + +=head4 size + +The number of characters tall this list should be. Defaults to '1'. + +=head4 profileEnabled + +Flag that tells the User Profile system that this is a valid form element in a User Profile + +=cut + +sub definition { + my $class = shift; + my $definition = shift || []; + push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("487","WebGUI"), + }, + size=>{ + defaultValue=>1, + }, + profileEnabled=>{ + defaultValue=>1, + }, + }); + return $class->SUPER::definition($definition); +} + +#------------------------------------------------------------------- + +=head2 toHtml ( ) + +Renders a select list form control. + +=cut + +sub toHtml { + my $self = shift; + my $output = ''."\n"; + return $output; +} + +1; + diff --git a/lib/WebGUI/Form/SelectList.pm b/lib/WebGUI/Form/SelectList.pm index c75d0fb9e..146590dc1 100644 --- a/lib/WebGUI/Form/SelectList.pm +++ b/lib/WebGUI/Form/SelectList.pm @@ -15,8 +15,7 @@ package WebGUI::Form::SelectList; =cut use strict; -use base 'WebGUI::Form::Control'; -use WebGUI::Form::HiddenList; +use base 'WebGUI::Form::List'; use WebGUI::International; use WebGUI::Session; @@ -26,11 +25,11 @@ Package WebGUI::Form::SelectList =head1 DESCRIPTION -Creates a select list, aka dropdown list form control. +Creates a select list, aka dropdown list form control with multiple select. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::List. =head1 METHODS @@ -48,25 +47,13 @@ See the super class for additional details. The following additional parameters have been added via this sub class. -=head4 options - -A hash reference containing key values that will be returned with the form post and displayable text pairs. Defaults to an empty hash reference. - -=head4 defaultValue - -An array reference of the items to be checked if no value is specified. Defaults to an empty array reference. - =head4 size -The number of characters tall this list should be. Defaults to '1'. +The number of characters tall this list should be. Defaults to '5'. =head4 multiple -Boolean indicating whether the user can select multiple items from this list like a checkList. Defaults to "0". - -=head4 sortByValue - -A boolean value for whether or not the values in the options hash should be sorted. Defaults to "0". +A boolean indicating whether the user can select multiple items from this list like a checkList. Defaults to "1". =head4 profileEnabled @@ -78,20 +65,14 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { - options=>{ - defaultValue=>{} - }, - defaultValue=>{ - defaultValue=>[], + formName=>{ + defaultValue=>WebGUI::International::get("484","WebGUI"), }, multiple=>{ - defaultValue=>0 - }, - sortByValue=>{ - defaultValue=>0 + defaultValue=>1 }, size=>{ - defaultValue=>1 + defaultValue=>5 }, profileEnabled=>{ defaultValue=>1 @@ -100,47 +81,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 displayValue ( ) - -Return the all options - -=cut - -sub displayValue { - my ($self) = @_; - return join ", ", @{ $self->{value} }; -} - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("484","WebGUI"); -} - - -#------------------------------------------------------------------- - -=head2 getValueFromPost ( ) - -Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar. - -=cut - -sub getValueFromPost { - my $self = shift; - my @data = $session{req}->param($self->{name}); - return wantarray ? @data : join("\n",@data); -} - #------------------------------------------------------------------- =head2 toHtml ( ) @@ -151,46 +91,23 @@ Renders a select list form control. sub toHtml { my $self = shift; - my $multiple = ' multiple="1"' if ($self->{multiple}); - my $output = '{extras}.$multiple.'>'; + my %options; + tie %options, 'Tie::IxHash'; + %options = $self->orderedHash; + my @values = $self->getValues(); foreach my $key (keys %options) { - $output .= ''; + $output .= ''; } - $output .= ''."\n"; - return $output; -} - -#------------------------------------------------------------------- - -=head2 toHtmlAsHidden ( ) - -Creates a series of hidden fields representing the data in the list. - -=cut - -sub toHtmlAsHidden { - my $self = shift; - return WebGUI::Form::HiddenList->new( - value=>$self->{value}, - defaultValue=>$self->{defaultValue}, - name=>$self->{name}, - options=>$self->{options} - )->toHtmlAsHidden; + $output .= ''."\n"; + return $output; } 1; diff --git a/lib/WebGUI/Form/Submit.pm b/lib/WebGUI/Form/Submit.pm index 7c2650da1..3a674241a 100644 --- a/lib/WebGUI/Form/Submit.pm +++ b/lib/WebGUI/Form/Submit.pm @@ -39,17 +39,23 @@ The following methods are specifically available from this class. Check the supe #------------------------------------------------------------------- -=head2 getName () +=head2 definition ( ) -Returns the human readable name or type of this form control. +See the super class for additional details. =cut -sub getName { - return WebGUI::International::get("submit","WebGUI"); +sub definition { + my $class = shift; + my $definition = shift || []; + push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("submit","WebGUI") + }, + }); + return $class->SUPER::definition($definition); } - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/Template.pm b/lib/WebGUI/Form/Template.pm index 9f6ec2bb2..0c728854b 100644 --- a/lib/WebGUI/Form/Template.pm +++ b/lib/WebGUI/Form/Template.pm @@ -15,9 +15,8 @@ package WebGUI::Form::Template; =cut use strict; -use base 'WebGUI::Form::Control'; +use base 'WebGUI::Form::SelectBox'; use WebGUI::Asset::Template; -use WebGUI::Form::SelectList; use WebGUI::Icon; use WebGUI::International; use WebGUI::Session; @@ -33,7 +32,7 @@ Creates a template chooser control. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectBox. =head1 METHODS @@ -69,8 +68,11 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("assetName","Asset_Template") + }, label=>{ - defaultValue=>$class->getName() + defaultValue=>WebGUI::International::get("assetName","Asset_Template") }, name=>{ defaultValue=>"templateId" @@ -84,18 +86,6 @@ sub definition { #------------------------------------------------------------------- -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("assetName","Asset_Template"); -} - -#------------------------------------------------------------------- - =head2 toHtml ( ) Renders a database connection picker control. @@ -112,17 +102,8 @@ sub toHtml { delete $templateList->{$assetId}; } } - # not sure why, but for some reason this fails under certain circumstances unless defined - # in this manner. The syndicated content asset is an example where it fails. - my $cmd = "WebGUI::Form::SelectList"; - my $selectList = $cmd->new( - id=>$self->{id}, - name=>$self->{name}, - options=>$templateList, - value=>[$self->{value}], - extras=>$self->{extras} - ); - return $selectList->toHtml; + $self->{options} = $templateList; + return $self->SUPER::toHtml(); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form/Text.pm b/lib/WebGUI/Form/Text.pm index d49964a9c..3f50449c3 100644 --- a/lib/WebGUI/Form/Text.pm +++ b/lib/WebGUI/Form/Text.pm @@ -65,6 +65,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=> WebGUI::International::get("475","WebGUI") + }, maxlength=>{ defaultValue=> 255 }, @@ -78,21 +81,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("475","WebGUI"); -} - - - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/Textarea.pm b/lib/WebGUI/Form/Textarea.pm index a298dffd4..ee7410167 100644 --- a/lib/WebGUI/Form/Textarea.pm +++ b/lib/WebGUI/Form/Textarea.pm @@ -69,6 +69,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("476","WebGUI") + }, rows=>{ defaultValue=> $session{setting}{textAreaRows} || 5 }, @@ -85,21 +88,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("476","WebGUI"); -} - - - #------------------------------------------------------------------- =head2 toHtml ( ) diff --git a/lib/WebGUI/Form/TimeField.pm b/lib/WebGUI/Form/TimeField.pm index bedbb3eb0..432f68ac9 100644 --- a/lib/WebGUI/Form/TimeField.pm +++ b/lib/WebGUI/Form/TimeField.pm @@ -69,6 +69,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("971","WebGUI") + }, maxlength=>{ defaultValue=>8 }, @@ -82,20 +85,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("971","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/TimeZone.pm b/lib/WebGUI/Form/TimeZone.pm index a4646fa2f..af5dd87a1 100644 --- a/lib/WebGUI/Form/TimeZone.pm +++ b/lib/WebGUI/Form/TimeZone.pm @@ -15,9 +15,8 @@ package WebGUI::Form::TimeZone; =cut use strict; -use base 'WebGUI::Form::Control'; +use base 'WebGUI::Form::SelectBox'; use WebGUI::DateTime; -use WebGUI::Form::SelectList; use WebGUI::International; use WebGUI::Session; @@ -31,7 +30,7 @@ Creates a template chooser control. =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectBox. =head1 METHODS @@ -41,14 +40,24 @@ The following methods are specifically available from this class. Check the supe #------------------------------------------------------------------- -=head2 getName () +=head2 definition ( ) -Returns the human readable name or type of this form control. +See the super class for additional details. =cut -sub getName { - return WebGUI::International::get("timezone","DateTime"); +sub definition { + my $class = shift; + my $definition = shift || []; + push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("timezone","DateTime") + }, + value=>{ + defaultValue=>undef + }, + }); + return $class->SUPER::definition($definition); } #------------------------------------------------------------------- @@ -61,15 +70,8 @@ Renders a database connection picker control. sub toHtml { my $self = shift; - my $cmd = "WebGUI::Form::SelectList"; - my $selectList = $cmd->new( - id=>$self->{id}, - name=>$self->{name}, - options=>WebGUI::DateTime::getTimeZones(), - value=>[$self->{value}], - extras=>$self->{extras} - ); - return $selectList->toHtml; + $self->{options} = WebGUI::DateTime::getTimeZones(); + return $self->SUPER::toHtml(); } diff --git a/lib/WebGUI/Form/Url.pm b/lib/WebGUI/Form/Url.pm index f7772994f..6a4561818 100644 --- a/lib/WebGUI/Form/Url.pm +++ b/lib/WebGUI/Form/Url.pm @@ -62,6 +62,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("478","WebGUI") + }, maxlength=>{ defaultValue=> 2048 }, @@ -72,20 +75,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("478","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/WhatNext.pm b/lib/WebGUI/Form/WhatNext.pm index a91743ad7..6dcd27b45 100644 --- a/lib/WebGUI/Form/WhatNext.pm +++ b/lib/WebGUI/Form/WhatNext.pm @@ -15,8 +15,7 @@ package WebGUI::Form::WhatNext; =cut use strict; -use base 'WebGUI::Form::Control'; -use WebGUI::Form::SelectList; +use base 'WebGUI::Form::SelectBox'; use WebGUI::International; use WebGUI::Session; @@ -30,7 +29,7 @@ Creates a what next question field. This is used to allow users direct the flow =head1 SEE ALSO -This is a subclass of WebGUI::Form::Control. +This is a subclass of WebGUI::Form::SelectBox. =head1 METHODS @@ -52,18 +51,6 @@ The following additional parameters have been added via this sub class. The identifier for this field. Defaults to "proceed". -=head4 defaultValue - -A database link id. Defaults to "0", which is the WebGUI database. - -=head4 afterEdit - -A URL that will be acted upon after editing a database link. - -=head4 hoverHelp - -A tooltip to tell the user what to do with the field. Defaults a standard piece of help for Database Links. - =head4 label A text label that will be displayed if toHtmlWithWrapper() is called. Defaults to getName(). @@ -74,33 +61,21 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("744","WebGUI") + }, label=>{ - defaultValue=>$class->getName() + defaultValue=>WebGUI::International::get("744","WebGUI") }, name=>{ defaultValue=>"proceed" }, - options=>{ - defaultValue=>{} - } }); return $class->SUPER::definition($definition); } #------------------------------------------------------------------- -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("744","WebGUI"); -} - -#------------------------------------------------------------------- - =head2 toHtml ( ) Renders a question selector asking the user where they want to go. @@ -109,16 +84,7 @@ Renders a question selector asking the user where they want to go. sub toHtml { my $self = shift; - return WebGUI::Form::SelectList->new( - id=>$self->{id}, - name=>$self->{name}, - options=>$self->{options}, - value=>[$self->{value}], - extras=>$self->{extras} - )->toHtml; + return $self->SUPER::toHtml(); } - - 1; - diff --git a/lib/WebGUI/Form/YesNo.pm b/lib/WebGUI/Form/YesNo.pm index 33bf3660d..d73664c6e 100644 --- a/lib/WebGUI/Form/YesNo.pm +++ b/lib/WebGUI/Form/YesNo.pm @@ -22,7 +22,7 @@ use WebGUI::Session; =head1 NAME -Package WebGUI::Form::yesNo +Package WebGUI::Form::YesNo =head1 DESCRIPTION @@ -62,6 +62,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=>WebGUI::International::get("483","WebGUI") + }, defaultValue=>{ defaultValue=>0 }, @@ -72,20 +75,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("483","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Form/Zipcode.pm b/lib/WebGUI/Form/Zipcode.pm index 26eb64750..b4131747b 100644 --- a/lib/WebGUI/Form/Zipcode.pm +++ b/lib/WebGUI/Form/Zipcode.pm @@ -62,6 +62,9 @@ sub definition { my $class = shift; my $definition = shift || []; push(@{$definition}, { + formName=>{ + defaultValue=> WebGUI::International::get("944","WebGUI") + }, maxlength=>{ defaultValue=> 10 }, @@ -72,20 +75,6 @@ sub definition { return $class->SUPER::definition($definition); } - -#------------------------------------------------------------------- - -=head2 getName () - -Returns the human readable name or type of this form control. - -=cut - -sub getName { - return WebGUI::International::get("944","WebGUI"); -} - - #------------------------------------------------------------------- =head2 getValueFromPost ( ) diff --git a/lib/WebGUI/Icon.pm b/lib/WebGUI/Icon.pm index 28355b0c0..e436c26e5 100644 --- a/lib/WebGUI/Icon.pm +++ b/lib/WebGUI/Icon.pm @@ -238,7 +238,7 @@ sub getToolbarOptions { my %options; tie %options, 'Tie::IxHash'; $options{useLanguageDefault} = WebGUI::International::get(1084); - my $dir = $session{config}{extrasPath}.$session{os}{slash}."toolbar"; + my $dir = $session{config}{extrasPath}."/toolbar"; opendir (DIR,$dir) or WebGUI::ErrorHandler::warn("Can't open toolbar directory!"); my @files = readdir(DIR); foreach my $file (@files) { diff --git a/lib/WebGUI/International.pm b/lib/WebGUI/International.pm index 56e2a24f3..07f808d55 100644 --- a/lib/WebGUI/International.pm +++ b/lib/WebGUI/International.pm @@ -142,7 +142,7 @@ Returns a hash reference to the languages (languageId/lanugage) installed on thi sub getLanguages { my ($hashRef); - my $dir = $session{config}{webguiRoot}.$session{os}{slash}."lib".$session{os}{slash}."WebGUI".$session{os}{slash}."i18n"; + my $dir = $session{config}{webguiRoot}."/lib/WebGUI/i18n"; opendir (DIR,$dir) or WebGUI::ErrorHandler::fatal("Can't open I18N directory! ".$dir); my @files = readdir(DIR); closedir(DIR); diff --git a/lib/WebGUI/Operation/Commerce.pm b/lib/WebGUI/Operation/Commerce.pm index 40db8994c..1b5aacae1 100644 --- a/lib/WebGUI/Operation/Commerce.pm +++ b/lib/WebGUI/Operation/Commerce.pm @@ -435,11 +435,11 @@ sub www_editCommerceSettings { # payment plugin if (%paymentPlugins) { WebGUI::Style::setRawHeadTags(''); - $tabform->getTab("payment")->selectList( + $tabform->getTab("payment")->selectBox( -name => 'commercePaymentPlugin', -options => \%paymentPlugins, -label => $i18n->get('payment form'), - -value => [$paymentPlugin], + -value => $paymentPlugin, -extras => 'onchange="activePayment=operateHidden(this.options[this.selectedIndex].value,activePayment)"' ); @@ -473,11 +473,11 @@ sub www_editCommerceSettings { # shipping plugin if (%shippingPlugins) { WebGUI::Style::setRawHeadTags(''); - $tabform->getTab('shipping')->selectList( + $tabform->getTab('shipping')->selectBox( -name => 'commerceShippingPlugin', -options=> \%shippingPlugins, -label => $i18n->get('shipping plugin label'), - -value => [$shippingPlugin], + -value => $shippingPlugin, -extras => 'onchange="activeShipping=operateHidden(this.options[this.selectedIndex].value,activeShipping)"' ); @@ -593,12 +593,12 @@ sub www_listTransactions { $output .= ''; $output .= ''; $output .= ''.$i18n->get('transaction status').''; - $output .= ''.WebGUI::Form::selectList({name => 'tStatus', value => [$session{form}{tStatus}], options => $transactionOptions}); + $output .= ''.WebGUI::Form::selectBox({name => 'tStatus', value => [$session{form}{tStatus}], options => $transactionOptions}); $output .= ''; $output .= ''; $output .= ''.$i18n->get('shipping status').''; - $output .= ''.WebGUI::Form::selectList({name => 'sStatus', value => [$session{form}{sStatus}], options => $shippingOptions}); + $output .= ''.WebGUI::Form::selectBox({name => 'sStatus', value => [$session{form}{sStatus}], options => $shippingOptions}); $output .= ''; $output .= ''; diff --git a/lib/WebGUI/Operation/FormHelpers.pm b/lib/WebGUI/Operation/FormHelpers.pm index 69869cc45..c823a33d9 100644 --- a/lib/WebGUI/Operation/FormHelpers.pm +++ b/lib/WebGUI/Operation/FormHelpers.pm @@ -53,7 +53,7 @@ sub www_richEditPageTree { -label=>WebGUI::International::get(104), -hoverHelp=>WebGUI::International::get('104 description'), ); - $f->selectList( + $f->selectBox( -name=>"target", -label=>WebGUI::International::get('target'), -hoverHelp=>WebGUI::International::get('target description'), diff --git a/lib/WebGUI/Operation/Group.pm b/lib/WebGUI/Operation/Group.pm index 44337a298..f3584529f 100644 --- a/lib/WebGUI/Operation/Group.pm +++ b/lib/WebGUI/Operation/Group.pm @@ -117,9 +117,9 @@ sub getGroupSearchForm { -name=>"doit", -value=>1 ); - $f->selectList( + $f->selectBox( -name=>"modifier", - -value=>([$session{scratch}{groupSearchModifier} || WebGUI::International::get("contains") ]), + -value=>($session{scratch}{groupSearchModifier} || WebGUI::International::get("contains") ), -options=>{ startsWith=>WebGUI::International::get("starts with"), contains=>WebGUI::International::get("contains"), diff --git a/lib/WebGUI/Operation/Help.pm b/lib/WebGUI/Operation/Help.pm index 5c0db570c..c16afddcb 100644 --- a/lib/WebGUI/Operation/Help.pm +++ b/lib/WebGUI/Operation/Help.pm @@ -61,7 +61,7 @@ sub _linkTOC { #------------------------------------------------------------------- sub _getHelpFilesList { - my $dir = join $session{os}{slash}, $session{config}{webguiRoot},"lib","WebGUI","Help"; + my $dir = join '/', $session{config}{webguiRoot},"lib","WebGUI","Help"; opendir (DIR,$dir) or WebGUI::ErrorHandler::fatal("Can't open Help directory!"); my @files; foreach my $file (readdir DIR) { diff --git a/lib/WebGUI/Operation/Profile.pm b/lib/WebGUI/Operation/Profile.pm index 013096157..7caf15919 100644 --- a/lib/WebGUI/Operation/Profile.pm +++ b/lib/WebGUI/Operation/Profile.pm @@ -47,35 +47,25 @@ sub getRequiredProfileFields { $method = $data->{dataType}; $label = WebGUI::Operation::Shared::secureEval($data->{fieldLabel}); $default = WebGUI::Operation::Shared::secureEval($data->{dataDefault}); - if ($method eq "selectList") { - $values = WebGUI::Operation::Shared::secureEval($data->{dataValues}); - # note: this big if statement doesn't look elegant, but doing regular ORs caused problems with the array reference. - if ($session{form}{$data->{fieldName}}) { - $default = [$session{form}{$data->{fieldName}}]; - } - elsif ($session{user}{$data->{fieldName}}) { - $default = [$session{user}{$data->{fieldName}}]; - } - $hash{'profile.formElement'} = WebGUI::Form::selectList({ - "name"=>$data->{fieldName}, - "options"=>$values, - "value"=>$default - }); + $values = WebGUI::Operation::Shared::secureEval($data->{dataValues}); + my $default; + if ($session{form}{$data->{fieldName}}) { + $default = $session{form}{$data->{fieldName}}; } + elsif ($session{user}{$data->{fieldName}}) { + $default = $session{user}{$data->{fieldName}}; + } else { - if ($session{form}{$data->{fieldName}}) { - $default = $session{form}{$data->{fieldName}}; - } - elsif (exists $session{user}{$data->{fieldName}}) { - $default = $session{user}{$data->{fieldName}}; - } - else { - $default = $data->{dataDefault}; - } - - my $cmd = 'WebGUI::Form::'.$method.'({"name"=>$data->{fieldName},"value"=>$default})'; - $hash{'profile.formElement'} = eval($cmd); + $default = WebGUI::Operation::Shared::secureEval($data->{dataDefault}); } + my $form = WebGUI::Form::DynamicField->new( + name => $data->{fieldName}, + value => $default, + options => $values, + fieldType => $method, + ); + + $hash{'profile.form.element'} = $form->displayForm(); $hash{'profile.formElement.label'} = $label; push(@array,\%hash) } @@ -184,6 +174,7 @@ sub www_editProfile { if ($data->{required}) { $hash{'profile.form.element.subtext'} = "*"; } + push(@profile,\%hash); if (($previousCategory && $category ne $previousCategory) || $counter eq $a->rows) { my @temp = @profile; my $hashRef; @@ -193,7 +184,6 @@ sub www_editProfile { @profile = (); } $previousCategory = $category; - push(@profile,\%hash); } $a->finish; diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index af37a088a..4acb6157d 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -249,7 +249,7 @@ sub www_editProfileField { foreach $key (keys %hash) { $hash{$key} = WebGUI::Operation::Shared::secureEval($hash{$key}); } - $f->selectList( + $f->selectBox( -name=>"profileCategoryId", -options=>\%hash, -label=>WebGUI::International::get(489,"WebGUIProfile"), diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index 2fa4fb66b..aa8cc8298 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -118,7 +118,7 @@ sub www_editSettings { -value=>$session{setting}{metaDataEnabled} ); # user interface settings - $tabform->getTab("ui")->selectList( + $tabform->getTab("ui")->selectBox( -name=>"richEditor", -label=>$i18n->get("default rich editor"), -hoverHelp=>$i18n->get("default rich editor description"), @@ -207,7 +207,7 @@ sub www_editSettings { -hoverHelp=>$i18n->get('show performance indicators description'), -value=>$session{setting}{showPerformanceIndicators} ); - $tabform->getTab("misc")->selectList( + $tabform->getTab("misc")->selectBox( -name=>"hostToUse", -value=>[$session{setting}{hostToUse}], -options=>{ @@ -274,7 +274,7 @@ sub www_editSettings { foreach (@{$session{config}{authMethods}}) { $options->{$_} = $_; } - $tabform->getTab("auth")->selectList( + $tabform->getTab("auth")->selectBox( -name=>"authMethod", -options=>$options, -label=>$i18n->get(164), diff --git a/lib/WebGUI/Operation/Subscription.pm b/lib/WebGUI/Operation/Subscription.pm index 3a68ea958..8337534f3 100644 --- a/lib/WebGUI/Operation/Subscription.pm +++ b/lib/WebGUI/Operation/Subscription.pm @@ -230,7 +230,7 @@ sub www_editSubscription { -hoverHelp => $i18n->get('subscription group description'), -value => [$properties->{subscriptionGroup} || 2] ); - $f->selectList( + $f->selectBox( -name => 'duration', -label => $i18n->get('subscription duration'), -hoverHelp => $i18n->get('subscription duration description'), diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm index 46e2f3827..ea36e6598 100644 --- a/lib/WebGUI/Operation/User.pm +++ b/lib/WebGUI/Operation/User.pm @@ -125,9 +125,9 @@ sub getUserSearchForm { -name=>"doit", -value=>1 ) - .WebGUI::Form::selectList( + .WebGUI::Form::selectBox( -name=>"modifier", - -value=>([$session{scratch}{userSearchModifier} || "contains"]), + -value=>($session{scratch}{userSearchModifier} || "contains"), -options=>{ startsWith=>WebGUI::International::get("starts with"), contains=>WebGUI::International::get("contains"), @@ -139,9 +139,9 @@ sub getUserSearchForm { -value=>$session{scratch}{userSearchKeyword}, -size=>15 ) - .WebGUI::Form::selectList( + .WebGUI::Form::selectBox( -name => "status", - -value => [$session{scratch}{userSearchStatus} || "users.status like '%'"], + -value => ($session{scratch}{userSearchStatus} || "users.status like '%'"), -options=> { "" => WebGUI::International::get(821), Active => WebGUI::International::get(817), @@ -252,22 +252,22 @@ sub www_editUser { -value => $u->status ); } else { - $tabform->getTab("account")->selectList( + $tabform->getTab("account")->selectBox( -name => "status", -options => \%status, -label => $i18n->get(816), - -value => [$u->status] + -value => $u->status ); } my $options; foreach (@{$session{config}{authMethods}}) { $options->{$_} = $_; } - $tabform->getTab("account")->selectList( + $tabform->getTab("account")->selectBox( -name=>"authMethod", -options=>$options, -label=>$i18n->get(164), - -value=>[$u->authMethod], + -value=>$u->authMethod, -extras=>"onChange=\"active=operateHidden(this.options[this.selectedIndex].value,active)\"" ); foreach (@{$session{config}{authMethods}}) { diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 5238ecaac..6a3d21aac 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -287,10 +287,8 @@ sub open { $session{os}{name} = $^O; if ($session{os}{name} =~ /MSWin32/i || $session{os}{name} =~ /^Win/i) { $session{os}{type} = "Windowsish"; - $session{os}{slash} = "\\"; } else { $session{os}{type} = "Linuxish"; - $session{os}{slash} = "/"; } ###---------------------------- ### default database handler object diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index dcb8afafc..2fd73774e 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -114,7 +114,7 @@ sub _makePath { my $self = shift; my $node = $session{config}{uploadsPath}; foreach my $folder ($self->{_part1}, $self->{_part2}, $self->{_id}) { - $node .= $session{os}{slash}.$folder; + $node .= '/'.$folder; unless (-e $node) { # check to see if it already exists unless (mkdir($node)) { # check to see if there was an error during creation $self->_addError("Couldn't create storage location: $node : $!"); @@ -482,7 +482,7 @@ sub getFileIconUrl { my $self = shift; my $filename = shift; my $extension = $self->getFileExtension($filename); - my $path = $session{config}{extrasPath}.$session{os}{slash}."fileIcons".$session{os}{slash}.$extension.".gif"; + my $path = $session{config}{extrasPath}.'/fileIcons/'.$extension.".gif"; if (-e $path) { return $session{config}{extrasURL}."/fileIcons/".$extension.".gif"; } @@ -600,11 +600,11 @@ sub getPath { return undef; } my $path = $session{config}{uploadsPath} - .$session{os}{slash}.$self->{_part1} - .$session{os}{slash}.$self->{_part2} - .$session{os}{slash}.$self->getId; + .'/'.$self->{_part1} + .'/'.$self->{_part2} + .'/'.$self->getId; if (defined $file) { - $path .= $session{os}{slash}.$file; + $path .= '/'.$file; } return $path; } diff --git a/lib/WebGUI/Storage/Image.pm b/lib/WebGUI/Storage/Image.pm index c5a9a99cf..185682f52 100644 --- a/lib/WebGUI/Storage/Image.pm +++ b/lib/WebGUI/Storage/Image.pm @@ -116,7 +116,7 @@ sub generateThumbnail { $image->Scale(width=>($x/$r),height=>($y/$r)); $image->Sharpen('0.0x1.0'); } - $error = $image->Write($self->getPath.$session{os}{slash}.'thumb-'.$filename); + $error = $image->Write($self->getPath.'/'.'thumb-'.$filename); if ($error) { WebGUI::ErrorHandler::error("Couldn't create thumbnail: ".$error); return 0; diff --git a/lib/WebGUI/i18n/English/Automated_Information.pm b/lib/WebGUI/i18n/English/Automated_Information.pm index 3fb42d475..154886007 100644 --- a/lib/WebGUI/i18n/English/Automated_Information.pm +++ b/lib/WebGUI/i18n/English/Automated_Information.pm @@ -4,7 +4,7 @@ use WebGUI::Session; use WebGUI::International; ##Get list of all macros by namespace/module name -my $dir = join $session{os}{slash}, $session{config}{webguiRoot},"lib","WebGUI","Macro"; +my $dir = join '/', $session{config}{webguiRoot},"lib","WebGUI","Macro"; opendir (DIR,$dir) or WebGUI::ErrorHandler::fatal("Can't open Macro directory: $dir!"); my @macros = map { s/Macro_//; s/\.pm//; $_; } grep { /\.pm$/ } diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 790b75916..ca5aba29d 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -362,6 +362,16 @@ Be aware that any database links you create here will be available to all conten lastUpdated => 1031514049 }, + '486' => { + message => q|List|, + lastUpdated => 1133087205 + }, + + '487' => { + message => q|Select Box|, + lastUpdated => 1133087205 + }, + '391' => { message => q|Delete attached file.|, lastUpdated => 1031514049 @@ -3223,6 +3233,12 @@ that Asset and all Assets below it.

context => q|Field type name| }, + 'fieldtype' => { + message => q|Field Type|, + lastUpdated =>0, + context => q|Field type name| + }, + 'hidden list' => { message => q|Hidden List|, lastUpdated =>0, diff --git a/sbin/preload.perl b/sbin/preload.perl index 6a483909d..1e3878a6d 100644 --- a/sbin/preload.perl +++ b/sbin/preload.perl @@ -15,6 +15,7 @@ print "\nStarting WebGUI ".$WebGUI::VERSION."\n"; # Database connectivity. #---------------------------------------- #use Apache::DBI (); # Uncomment if you want to enable connection pooling. Not recommended on servers with many sites, or those using db slaves. +use Log::Log4perl (); use DBI (); DBI->install_driver("mysql"); # Change to match your database driver. diff --git a/t/FormGetName.t b/t/FormGetName.t new file mode 100644 index 000000000..f0159afc8 --- /dev/null +++ b/t/FormGetName.t @@ -0,0 +1,77 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2005 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +# ---- BEGIN DO NOT EDIT ---- +use strict; +use lib '../lib'; +use Getopt::Long; +use WebGUI::Session; +use WebGUI::Form::FieldType; +use WebGUI::Form::DynamicField; +# ---- END DO NOT EDIT ---- + +#The goal of this test is to verify that getName works with all Form types. +#getName is now inherited by all Forms and pulls the internationalized ID +#from sub definition. +#It would be nice to have a way to automatically verify that each Form has +#the correct name, but it would have to be table driven. + +use Test::More; # increment this value for each test you create + +my $numTests = 0; + +initialize(); # this line is required + +# put your tests here + +diag("Getting the list of all Form types\n"); + +my $fieldType = WebGUI::Form::FieldType->new(); + +my @formTypes = @{ $fieldType->{types} }; + +##We have to remove DynamicField from this list, since when you call new +##it wants to return a type. We'll check it manually. + +$numTests = (2 * scalar @formTypes) + 1; + +plan tests => $numTests; + +diag("Planning on running $numTests tests\n"); + +foreach my $formType (sort @formTypes) { + my $form = WebGUI::Form::DynamicField->new(fieldType => $formType); + my $ref = (split /::/, ref $form)[-1]; + is($ref, $formType, "checking form type $formType"); + ok($form->getName, sprintf "form getName = %s", $form->getName); +} + +my $name = WebGUI::Form::DynamicField->getName(); + +ok($name, 'did not inherit default form name'); + +cleanup(); # this line is required + +# ---- DO NOT EDIT BELOW THIS LINE ----- + +sub initialize { + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + WebGUI::Session::open("..",$configFile); +} + +sub cleanup { + WebGUI::Session::close(); +} + diff --git a/t/FormListEquiv.t b/t/FormListEquiv.t new file mode 100644 index 000000000..ee9f0808a --- /dev/null +++ b/t/FormListEquiv.t @@ -0,0 +1,400 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2005 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +# ---- BEGIN DO NOT EDIT ---- +use strict; +use lib '../lib'; +use Getopt::Long; +use WebGUI::Session; +use WebGUI::Form::DynamicField; +use WebGUI::Form::SelectList; +use Data::Dumper; +# ---- END DO NOT EDIT ---- + +#The goal of this test is to verify that all SelectList type Forms +#can be generated directly and via DynamicField + +use Test::More; # increment this value for each test you create + +##In general, there should be many tests for each form type +# Object creation, direct +# Object creation, DynamicField +# sortByName set for direct +# sortByName set for dynamic +# getName set for direct +# compare output of toHtml from both objects +# compare output of toHtmlWithWrapper from both objects +my $numTests = 8*13; + +initialize(); # this line is required + +# put your tests here + +diag("Planning on running $numTests tests\n"); + +plan tests => $numTests; + +diag("SelectList, simple equivalency with size"); + +my ($direct, $dynamic); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'SelectList', + name => 'mySelectList', + label => 'list of selections', + possibleValues => join("\n", qw(a b c d e f g h)), + value => join("\n", qw(a e c g)), + sortByValue => 1, + multiple => 1, +); +$direct = WebGUI::Form::SelectList->new({ + name => 'mySelectList', + label => 'list of selections', + options => { a=>'a', b=>'b', c=>'c', d=>'d', e=>'e', f=>'f', g=>'g', h=>'h', }, + value => [ qw(a c e g) ], + sortByValue => 1, + multiple => 1, +}); + +is(ref $dynamic, "WebGUI::Form::SelectList", 'checking dynamic SelectList'); +is(ref $direct, "WebGUI::Form::SelectList", 'checking direct SelectList'); +is($direct->getName, WebGUI::International::get('484','WebGUI'), 'Check getName'); +is($dynamic->{sortByValue}, 1, 'dynamic CheckList was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct CheckList was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching SelectList output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching SelectList output, toHtmlAsHidden"); + +diag("CheckList, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'CheckList', + name => 'myCheckList', + label => 'list of selections', + possibleValues => join("\n", qw(a b c d e f g h)), + value => join("\n", qw(a c e g)), + sortByValue => 1, +); +$direct = WebGUI::Form::CheckList->new({ + name => 'myCheckList', + label => 'list of selections', + options => { a=>'a', b=>'b', c=>'c', d=>'d', e=>'e', f=>'f', g=>'g', h=>'h', }, + value => [ qw(a c e g) ], + sortByValue => 1, +}); + +is(ref $dynamic, "WebGUI::Form::CheckList", 'checking dynamic CheckList'); +is(ref $direct, "WebGUI::Form::CheckList", 'checking direct CheckList'); +is($direct->getName, WebGUI::International::get('941','WebGUI'), 'Check getName'); +is($dynamic->{sortByValue}, 1, 'dynamic CheckList was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct CheckList was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching CheckList output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching CheckList output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching CheckList output, toHtmlAsHidden"); + +diag("RadioList, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'RadioList', + name => 'myRadioList', + label => 'list of selections', + possibleValues => join("\n", qw(a b c d e f g h)), + value => 'b', + sortByValue => 1, +); +$direct = WebGUI::Form::RadioList->new({ + name => 'myRadioList', + label => 'list of selections', + options => { a=>'a', b=>'b', c=>'c', d=>'d', e=>'e', f=>'f', g=>'g', h=>'h', }, + value => 'b', + sortByValue => 1, +}); + +is(ref $dynamic, "WebGUI::Form::RadioList", 'checking dynamic RadioList'); +is(ref $direct, "WebGUI::Form::RadioList", 'checking direct RadioList'); +is($direct->getName, WebGUI::International::get('942','WebGUI'), 'Radio getName'); +is($dynamic->{sortByValue}, 1, 'dynamic RadioList was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct RadioList was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching RadioList output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching RadioList output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching RadioList output, toHtmlAsHidden"); + +diag("SelectBox, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'SelectBox', + name => 'mySelectBox', + label => 'list of selections', + possibleValues => join("\n", qw(a b c d e f g h)), + value => 'b', + sortByValue => 1, +); +$direct = WebGUI::Form::SelectBox->new({ + name => 'mySelectBox', + label => 'list of selections', + options => { a=>'a', b=>'b', c=>'c', d=>'d', e=>'e', f=>'f', g=>'g', h=>'h', }, + value => 'b', + sortByValue => 1, +}); + +is(ref $dynamic, "WebGUI::Form::SelectBox", 'checking dynamic SelectBox'); +is(ref $direct, "WebGUI::Form::SelectBox", 'checking direct SelectBox'); +is($direct->getName, WebGUI::International::get('487','WebGUI'), 'SelectBox getName'); +is($dynamic->{sortByValue}, 1, 'dynamic SelectBox was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct SelectBox was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching SelectBox output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching SelectBox output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching SelectBox output, toHtmlAsHidden"); + +diag("HiddenList, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'HiddenList', + name => 'myHiddenList', + label => 'list of groups', + sortByValue => 1, +); +$direct = WebGUI::Form::HiddenList->new({ + name => 'myHiddenList', + label => 'list of groups', + sortByValue => 1, +}); + +#diag("direct" . Dumper($direct)); +#diag("dynamic" . Dumper($dynamic)); + +is(ref $dynamic, "WebGUI::Form::HiddenList", 'checking dynamic HiddenList'); +is(ref $direct, "WebGUI::Form::HiddenList", 'checking direct HiddenList'); +is($direct->getName, WebGUI::International::get('hidden list','WebGUI'), 'HiddenList getName'); +is($dynamic->{sortByValue}, 1, 'dynamic HiddenList was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct HiddenList was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching HiddenList output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching HiddenList output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching HiddenList output, toHtmlAsHidden"); + +diag("Group, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'Group', + name => 'myGroup', + label => 'list of groups', + sortByValue => 1, +); +$direct = WebGUI::Form::Group->new({ + name => 'myGroup', + label => 'list of groups', + sortByValue => 1, +}); + +#diag("direct" . Dumper($direct)); +#diag("dynamic" . Dumper($dynamic)); + +is(ref $dynamic, "WebGUI::Form::Group", 'checking dynamic Group'); +is(ref $direct, "WebGUI::Form::Group", 'checking direct Group'); +is($direct->getName, WebGUI::International::get('group','WebGUI'), 'Group getName'); +is($dynamic->{sortByValue}, 1, 'dynamic Group was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct Group was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching Group output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching Group output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching Group output, toHtmlAsHidden"); + +diag("TimeZone, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'TimeZone', + name => 'myTimeZone', + label => 'list of time zones', + sortByValue => 1, +); +$direct = WebGUI::Form::TimeZone->new({ + name => 'myTimeZone', + label => 'list of time zones', + sortByValue => 1, +}); + +#diag("direct" . Dumper($direct)); +#diag("dynamic" . Dumper($dynamic)); + +is(ref $dynamic, "WebGUI::Form::TimeZone", 'checking dynamic TimeZone'); +is(ref $direct, "WebGUI::Form::TimeZone", 'checking direct TimeZone'); +is($direct->getName, WebGUI::International::get('timezone','DateTime'), 'TimeZone getName'); +is($dynamic->{sortByValue}, 1, 'dynamic TimeZone was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct TimeZone was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching TimeZone output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching TimeZone output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching TimeZone output, toHtmlAsHidden"); + +diag("ContentType, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'ContentType', + name => 'myContentType', + label => 'list of content types', + sortByValue => 1, +); +$direct = WebGUI::Form::ContentType->new({ + name => 'myContentType', + label => 'list of content types', + sortByValue => 1, +}); + +is(ref $dynamic, "WebGUI::Form::ContentType", 'checking dynamic ContentType'); +is(ref $direct, "WebGUI::Form::ContentType", 'checking direct ContentType'); +is($direct->getName, WebGUI::International::get('1007','WebGUI'), 'ContentType getName'); +is($dynamic->{sortByValue}, 1, 'dynamic ContentType was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct ContentType was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching ContentType output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching ContentType output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching ContentType output, toHtmlAsHidden"); + +diag("FilterContent, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'FilterContent', + name => 'myFilterContent', + label => 'list of types to filter', + sortByValue => 1, +); +$direct = WebGUI::Form::FilterContent->new({ + name => 'myFilterContent', + label => 'list of types to filter', + sortByValue => 1, +}); + +is(ref $dynamic, "WebGUI::Form::FilterContent", 'checking dynamic FilterContent'); +is(ref $direct, "WebGUI::Form::FilterContent", 'checking direct FilterContent'); +is($direct->getName, WebGUI::International::get('418','WebGUI'), 'FilterContent getName'); +is($dynamic->{sortByValue}, 1, 'dynamic FilterContent was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct FilterContent was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching FilterContent output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching FilterContent output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching FilterContent output, toHtmlAsHidden"); + +diag("LdapLink, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'LdapLink', + name => 'myLdapLink', + label => 'list of ldap links', + sortByValue => 1, +); +$direct = WebGUI::Form::LdapLink->new({ + name => 'myLdapLink', + label => 'list of ldap links', + sortByValue => 1, +}); + +#diag("direct" . Dumper($direct)); +#diag("dynamic" . Dumper($dynamic)); + +is(ref $dynamic, "WebGUI::Form::LdapLink", 'checking dynamic LdapLink'); +is(ref $direct, "WebGUI::Form::LdapLink", 'checking direct LdapLink'); +is($direct->getName, WebGUI::International::get("LDAPLink_1075","AuthLDAP"), 'LdapLink getName'); +is($dynamic->{sortByValue}, 1, 'dynamic LdapLink was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct LdapLink was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching LdapLink output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching LdapLink output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching LdapLink output, toHtmlAsHidden"); + +diag("Template, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'Template', + name => 'myTemplate', + label => 'list of ldap links', + sortByValue => 1, +); +$direct = WebGUI::Form::Template->new({ + name => 'myTemplate', + label => 'list of ldap links', + sortByValue => 1, +}); + +#diag("direct" . Dumper($direct)); +#diag("dynamic" . Dumper($dynamic)); + +is(ref $dynamic, "WebGUI::Form::Template", 'checking dynamic Template'); +is(ref $direct, "WebGUI::Form::Template", 'checking direct Template'); +is($direct->getName, WebGUI::International::get("assetName","Asset_Template"), 'Template getName'); +is($dynamic->{sortByValue}, 1, 'dynamic Template was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct Template was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching Template output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching Template output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching Template output, toHtmlAsHidden"); + +diag("WhatNext, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'WhatNext', + name => 'myWhatNext', + label => 'list of what to do next', + sortByValue => 1, +); +$direct = WebGUI::Form::WhatNext->new({ + name => 'myWhatNext', + label => 'list of what to do next', + sortByValue => 1, +}); + +#diag("direct" . Dumper($direct)); +#diag("dynamic" . Dumper($dynamic)); + +is(ref $dynamic, "WebGUI::Form::WhatNext", 'checking dynamic WhatNext'); +is(ref $direct, "WebGUI::Form::WhatNext", 'checking direct WhatNext'); +is($direct->getName, WebGUI::International::get('744','WebGUI'), 'WhatNext getName'); +is($dynamic->{sortByValue}, 1, 'dynamic WhatNext was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct WhatNext was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching WhatNext output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching WhatNext output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching WhatNext output, toHtmlAsHidden"); + +diag("DatabaseLink, simple equivalency"); + +$dynamic = WebGUI::Form::DynamicField->new( + fieldType => 'DatabaseLink', + name => 'myDatabaseLink', + label => 'list of databases', + sortByValue => 1, +); +$direct = WebGUI::Form::DatabaseLink->new({ + name => 'myDatabaseLink', + label => 'list of databases', + sortByValue => 1, +}); + +is(ref $dynamic, "WebGUI::Form::DatabaseLink", 'checking dynamic DatabaseLink'); +is(ref $direct, "WebGUI::Form::DatabaseLink", 'checking direct DatabaseLink'); +is($direct->getName, WebGUI::International::get('1075','WebGUI'), 'DatabaseLink getName'); +is($dynamic->{sortByValue}, 1, 'dynamic DatabaseLink was assigned sortByValue'); +is($direct->{sortByValue}, 1, 'direct DatabaseLink was assigned sortByValue'); +is($dynamic->toHtml, $direct->toHtml, "matching DatabaseLink output, toHtml"); +is($dynamic->toHtmlWithWrapper, $direct->toHtmlWithWrapper, "matching DatabaseLink output, toHtmlWithWrapper"); +is($dynamic->toHtmlAsHidden, $direct->toHtmlAsHidden, "matching DatabaseLink output, toHtmlAsHidden"); + + + +cleanup(); # this line is required + +# ---- DO NOT EDIT BELOW THIS LINE ----- + +sub initialize { + $|=1; # disable output buffering + my $configFile; + GetOptions( + 'configFile=s'=>\$configFile + ); + exit 1 unless ($configFile); + WebGUI::Session::open("..",$configFile); +} + +sub cleanup { + WebGUI::Session::close(); +} +