Skip to content

Commit

Permalink
Item12233: Don't generate sort links for static
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@15990 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Nov 11, 2012
1 parent 633f027 commit c256b5b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
7 changes: 7 additions & 0 deletions TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm
Expand Up @@ -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)
Expand Down
62 changes: 62 additions & 0 deletions TablePlugin/test/unit/TablePlugin/TablePluginTests.pm
Expand Up @@ -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 = <<ACTUAL;
%TABLE{sort="on" initsort=" 1 "}%
| *Title* | *Date* | *Size* | *Span date* |
| def | 07 Feb 2006 - 13:23 |
| jkl| 16 Sep 2008 - 09:48 |
| GHI | 26 Jul 2007 - 13:23 |
| ABC | 26 May 2007 - 22:36 |
ACTUAL

my $expected = <<EXPECTED;
<nop>
<nop>
<nop>
<nop>
<nop>
<nop>
<table id="tableTestTopicTableFormatting1" class="foswikiTable" rules="none" border="1">
<thead>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<th class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol"> Title </th>
<th class="foswikiTableCol1"> Date </th>
<th class="foswikiTableCol2"> Size </th>
<th class="foswikiTableCol3 foswikiLastCol"> Span date </th>
</tr>
</thead>
<tbody>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol"> ABC </td>
<td rowspan="1" class="foswikiTableCol1 foswikiLastCol"> 26 May 2007 - 22:36 </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol"> def </td>
<td rowspan="1" class="foswikiTableCol1 foswikiLastCol"> 07 Feb 2006 - 13:23 </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol"> GHI </td>
<td rowspan="1" class="foswikiTableCol1 foswikiLastCol"> 26 Jul 2007 - 13:23 </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td rowspan="1" class="foswikiTableCol0 foswikiSortedAscendingCol foswikiSortedCol foswikiFirstCol foswikiLast"> jkl </td>
<td rowspan="1" class="foswikiTableCol1 foswikiLastCol foswikiLast"> 16 Sep 2008 - 09:48 </td>
</tr>
</tbody></table>
EXPECTED

$this->do_test( $expected, $actual );
}

sub test_sort_off {
my $this = shift;

Expand Down

0 comments on commit c256b5b

Please sign in to comment.