From c256b5bd9f03c7fb3739bc5b7a0f9144c4cd433d Mon Sep 17 00:00:00 2001 From: GeorgeClark Date: Sun, 11 Nov 2012 18:38:22 +0000 Subject: [PATCH] Item12233: Don't generate sort links for static git-svn-id: http://svn.foswiki.org/trunk@15990 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- .../lib/Foswiki/Plugins/TablePlugin/Core.pm | 7 +++ .../test/unit/TablePlugin/TablePluginTests.pm | 62 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm b/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm index 4d008da941..908705cc86 100644 --- a/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm +++ b/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm @@ -278,6 +278,13 @@ sub _parseAttributes { if $inParams->{initdirection} =~ /^up$/i; } + # Don't allow sort requests when rendering for static use. + # Force sort=off but allow initsort / initdirection + my $context = Foswiki::Func::getContext(); + if ( $context->{static} ) { + delete $inCollection->{sortAllTables}; + } + # If EditTablePlugin is installed and we are editing a table, # the CGI parameter 'sort' is defined as "off" to disable all # header sorting ((Item5135) diff --git a/TablePlugin/test/unit/TablePlugin/TablePluginTests.pm b/TablePlugin/test/unit/TablePlugin/TablePluginTests.pm index bd1bf71de9..808d93e991 100755 --- a/TablePlugin/test/unit/TablePlugin/TablePluginTests.pm +++ b/TablePlugin/test/unit/TablePlugin/TablePluginTests.pm @@ -1008,6 +1008,68 @@ EXPECTED $this->do_test( $expected, $actual ); } +=pod + +Item12233: Rendering for static targets (like PDF) should honor initial sort, but never generate sort links.. + +=cut + +sub test_sort_static_context { + my $this = shift; + + my $cgi = $this->{request}; + my $url = $cgi->url( -absolute => 1 ); + my $pubUrlSystemWeb = Foswiki::Func::getPubUrlPath() . '/System'; + $this->{session}->enterContext('static'); + + my $actual = < + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Title Date Size Span date
ABC 26 May 2007 - 22:36
def 07 Feb 2006 - 13:23
GHI 26 Jul 2007 - 13:23
jkl 16 Sep 2008 - 09:48
+EXPECTED + + $this->do_test( $expected, $actual ); +} + sub test_sort_off { my $this = shift;