From 64048c0846deae1995dc1788bf8b1070f49a895a Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 12 Jan 2006 19:51:54 +0000 Subject: [PATCH] migrated tabform to new session system --- docs/migration.txt | 5 +++++ lib/WebGUI/Asset.pm | 2 +- lib/WebGUI/Asset/FilePile.pm | 2 +- lib/WebGUI/Operation/Commerce.pm | 2 +- lib/WebGUI/Operation/Settings.pm | 2 +- lib/WebGUI/Operation/User.pm | 2 +- lib/WebGUI/TabForm.pm | 37 +++++++++++++++++++++++--------- 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/docs/migration.txt b/docs/migration.txt index fc8ccfd14..18ce3b02a 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -831,6 +831,11 @@ perl -pi.bak -e 's!WebGUI\:\:Storage\:\:Image\-\>createTemp\(!WebGUI::Storage::I perl -pi.bak -e 's!WebGUI\:\:Subscription\-\>new\(!WebGUI::Subscription->new(\$self->session,!g' fileNameGoesHere +5.23.23 WebGUI::TabForm API Refactored + +perl -pi.bak -e 's!WebGUI\:\:TabForm\-\>new\(!WebGUI::TabForm->new(\$self->session,!g' fileNameGoesHere + + 6. Automatic list of Assets in Help System. ------------------------------------- diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 160961823..f8b70e3ec 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -483,7 +483,7 @@ sub getEditForm { my $i18n = WebGUI::International->new($self->session, "Asset"); my $uiLevelOverride = $self->get("className"); $uiLevelOverride =~ s/\:\:/_/g; - my $tabform = WebGUI::TabForm->new(undef,undef,$self->getUrl(),$uiLevelOverride); + my $tabform = WebGUI::TabForm->new($self->session,undef,undef,$self->getUrl(),$uiLevelOverride); $tabform->hidden({ name=>"func", value=>"editSave" diff --git a/lib/WebGUI/Asset/FilePile.pm b/lib/WebGUI/Asset/FilePile.pm index 48d06ab55..26bdc479a 100644 --- a/lib/WebGUI/Asset/FilePile.pm +++ b/lib/WebGUI/Asset/FilePile.pm @@ -51,7 +51,7 @@ These methods are available from this class: #------------------------------------------------------------------- sub edit { my $self = shift; - my $tabform = WebGUI::TabForm->new(); + my $tabform = WebGUI::TabForm->new($self->session,); $tabform->hidden({ name=>"func", value=>"add" diff --git a/lib/WebGUI/Operation/Commerce.pm b/lib/WebGUI/Operation/Commerce.pm index 5bfd66c8e..c9c8922cf 100644 --- a/lib/WebGUI/Operation/Commerce.pm +++ b/lib/WebGUI/Operation/Commerce.pm @@ -391,7 +391,7 @@ sub www_editCommerceSettings { $paymentPlugin = $session->config->get("paymentPlugins")->[0]; $shippingPlugin = $session->config->get("shippingPlugins")->[0]; - $tabform = WebGUI::TabForm->new(\%tabs); + $tabform = WebGUI::TabForm->new($session,\%tabs); $tabform->hidden({name => 'op', value => 'editCommerceSettingsSave'}); # general diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index db73ef781..2167b49ce 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -41,7 +41,7 @@ sub www_editSettings { user=>{ label=>$i18n->get("user") }, auth=>{ label=>$i18n->get("authentication") }, ); - my $tabform = WebGUI::TabForm->new(\%tabs); + my $tabform = WebGUI::TabForm->new($session,\%tabs); $tabform->hidden({ name=>"op", value=>"saveSettings"}); diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm index 4582e66b2..f001b08e0 100644 --- a/lib/WebGUI/Operation/User.pm +++ b/lib/WebGUI/Operation/User.pm @@ -298,7 +298,7 @@ sub www_editUser { "profile"=> { label=>$i18n->get("profile")}, "groups"=> { label=>$i18n->get('89')}, ); - my $tabform = WebGUI::TabForm->new(\%tabs); + my $tabform = WebGUI::TabForm->new($session,\%tabs); my $u = WebGUI::User->new(($session->form->process("uid") eq 'new') ? '' : $session->form->process("uid")); $session->style->setScript($session->config->get("extrasURL")."/swapLayers.js", {type=>"text/javascript"}); $session->style->setRawHeadTags(''); diff --git a/lib/WebGUI/TabForm.pm b/lib/WebGUI/TabForm.pm index d7aada134..23abbb559 100644 --- a/lib/WebGUI/TabForm.pm +++ b/lib/WebGUI/TabForm.pm @@ -19,8 +19,6 @@ use strict; use Tie::IxHash; use WebGUI::Form; use WebGUI::HTMLForm; -use WebGUI::Session; -use WebGUI::Style; =head1 NAME @@ -48,7 +46,7 @@ Package that makes creating tab-based forms simple through an object-oriented AP } ); - $tabform = WebGUI::TabForm->new(\%tabs); + $tabform = WebGUI::TabForm->new($self->session,\%tabs); $tabform->hidden($name, $value); $tabform->submit(\%params); @@ -158,10 +156,14 @@ sub hidden { #------------------------------------------------------------------- -=head2 new ( tabHashRef , cssString) +=head2 new ( session, tabHashRef , cssString) Constructor. +=head3 session + +A reference to the current session. + =head3 tabHashRef A hash reference containing the definition of the tabs. It should be constructed like this: @@ -190,23 +192,24 @@ A string containing the link to the tab-CascadingStyleSheet sub new { my $class = shift; + my $session = shift; my $startingTabs = shift; - my $css = shift || $self->session->config->get("extrasURL").'/tabs/tabs.css'; - my $cancelUrl = shift || $self->session->url->page(); + my $css = shift || $session->config->get("extrasURL").'/tabs/tabs.css'; + my $cancelUrl = shift || $session->url->page(); my $uiLevelOverride = shift; my %tabs; tie %tabs, 'Tie::IxHash'; foreach my $key (keys %{$startingTabs}) { - $tabs{$key}{form} = WebGUI::HTMLForm->new($self->session,uiLevelOverride=>$uiLevelOverride); + $tabs{$key}{form} = WebGUI::HTMLForm->new($session,uiLevelOverride=>$uiLevelOverride); $tabs{$key}{label} = $startingTabs->{$key}->{label}; $tabs{$key}{uiLevel} = $startingTabs->{$key}->{uiLevel}; } - my $i18n = WebGU::International::get($session); - my $cancel = WebGUI::Form::button({ + my $i18n = WebGU::International->new($session); + my $cancel = WebGUI::Form::button($session,{ value=>$i18n->get('cancel'), extras=>q|onclick="history.go(-1);"| }); - bless { _uiLevelOverride=>$uiLevelOverride, _cancel=>$cancel, _submit=>WebGUI::Form::submit($self->session,), _form=>WebGUI::Form::formHeader(), _hidden=>"", _tab=>\%tabs, _css=>$css }, $class; + bless { _session=>$session, _uiLevelOverride=>$uiLevelOverride, _cancel=>$cancel, _submit=>WebGUI::Form::submit($self->session), _form=>WebGUI::Form::formHeader($session), _hidden=>"", _tab=>\%tabs, _css=>$css }, $class; } @@ -247,6 +250,20 @@ sub print { } +#------------------------------------------------------------------- + +=head2 session ( ) + +Returns a reference to the current session. + +=cut + +sub session { + my $self = shift; + return $self->{_session}; +} + + #------------------------------------------------------------------- =head2 submit ( hashRef )