From 1ddf1b50a4099d03991c0f113392b8cc9700c547 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 16 Apr 2009 19:21:28 +0000 Subject: [PATCH] add export mode for StoryArchive. Turn off search variables when in export mode. --- lib/WebGUI/Asset/Wobject/StoryArchive.pm | 32 +++++++++++++++++++----- t/Asset/Wobject/StoryArchive.t | 25 +++++++++++++++++- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/StoryArchive.pm b/lib/WebGUI/Asset/Wobject/StoryArchive.pm index ce4eae985..4129e17f6 100644 --- a/lib/WebGUI/Asset/Wobject/StoryArchive.pm +++ b/lib/WebGUI/Asset/Wobject/StoryArchive.pm @@ -158,6 +158,24 @@ sub definition { } +#------------------------------------------------------------------- + +=head2 exportHtml_view ( ) + +Extend the base method to change how the tag cloud works and the search +interface. + +Sets an internal flag to indicate that it is exporting to signal viewTemplateVars +to make those changes. + +=cut + +sub exportHtml_view { + my $self = shift; + $self->{_exportMode} = 1; + return $self->next::method(@_); +} + #------------------------------------------------------------------- =head2 getFolder ( date ) @@ -376,12 +394,14 @@ sub viewTemplateVariables { startAsset => $self, displayFunc => 'view', }); - my $i18n = WebGUI::International->new($session, 'Asset'); - $var->{searchHeader} = WebGUI::Form::formHeader($session, { action => $self->getUrl }) - . WebGUI::Form::hidden($session, { name => 'func', value => 'view' }); - $var->{searchFooter} = WebGUI::Form::formFooter($session); - $var->{searchButton} = WebGUI::Form::submit($session, { name => 'search', value => $i18n->get('search')}); - $var->{searchForm} = WebGUI::Form::text($session, { name => 'query', value => $query}); + if (! $self->{_exportMode}) { + my $i18n = WebGUI::International->new($session, 'Asset'); + $var->{searchHeader} = WebGUI::Form::formHeader($session, { action => $self->getUrl }) + . WebGUI::Form::hidden($session, { name => 'func', value => 'view' }); + $var->{searchFooter} = WebGUI::Form::formFooter($session); + $var->{searchButton} = WebGUI::Form::submit($session, { name => 'search', value => $i18n->get('search')}); + $var->{searchForm} = WebGUI::Form::text($session, { name => 'query', value => $query}); + } return $var; } diff --git a/t/Asset/Wobject/StoryArchive.t b/t/Asset/Wobject/StoryArchive.t index 2523179ba..aa14a53a6 100644 --- a/t/Asset/Wobject/StoryArchive.t +++ b/t/Asset/Wobject/StoryArchive.t @@ -58,7 +58,7 @@ $canPostMaker->prepare({ fail => [1, $reader ], }); -my $tests = 31 +my $tests = 33 + $canPostMaker->plan ; plan tests => 1 @@ -183,6 +183,18 @@ $creationDateSth->execute([$yesterday, $pastStory->getId]); my $templateVars; $templateVars = $archive->viewTemplateVariables(); + +cmp_deeply( + $templateVars, + superhashof({ + searchHeader => ignore(), + searchForm => ignore(), + searchButton => ignore(), + searchFooter => ignore(), + }), + 'viewTemplateVars: search variables present' +); + KEY: foreach my $key (keys %{ $templateVars }) { next KEY if isIn($key, qw/canPostStories addStoryUrl date_loop mode/); delete $templateVars->{$key}; @@ -387,6 +399,17 @@ cmp_bag( 'keywordCloud template variable has keywords and correct links', ); +$archive->{_exportMode} = 1; +$templateVars = $archive->viewTemplateVariables(); +ok( ( !exists $templateVars->{searchHeader} + && !exists $templateVars->{searchForm} + && !exists $templateVars->{searchButton} + && !exists $templateVars->{searchForm} + ), + '... export mode, no search variables present' +); +$archive->{_exportMode} = 0; + ################################################################ # # RSS and Atom checks