1 %# BEGIN LICENSE BLOCK;
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 %# General Public License for more details.
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
25 %# If you're having TicketList display a single record, you need
26 %# to wrap the calls in your own table(s).
27 % unless (defined $SingleRecord) {
28 <TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH=100%>
32 <& /Elements/CollectionAsTable/Header,
34 AllowSorting => $AllowSorting,
41 maxitems => \$maxitems &>
44 % if (defined $SingleRecord) {
45 <& /Elements/CollectionAsTable/Row, Format => \@Format, i => 0, record => $SingleRecord, maxitems => $maxitems &>
48 % while (my $record = $Collection->Next) {
50 <& /Elements/CollectionAsTable/Row, Format => \@Format, i => $i, record => $record, maxitems => $maxitems &>
54 % unless (defined $SingleRecord) {
58 % if ($ShowNavigation) {
60 <&|/l, $Page, int($TotalFound/$Rows)+1&>Page [_1] of [_2]</&>
63 my $prev = $m->comp('/Elements/QueryString',
70 my $next = $m->comp('/Elements/QueryString',
79 <A href="<%$BaseURL%><%$prev%>"><&|/l&>Previous Page</&></a>
81 % if (($Page * $Rows) < $TotalFound) {
82 <A href="<%$BaseURL%><%$next%>"><&|/l&>Next Page</&></a>
88 $Format ||= $RT::DefaultSearchResultFormat;
89 # Scrub the html of the format string to remove any potential nasties.
90 $Format = $m->comp('/Elements/ScrubHTML', Content => $Format);
92 $Rows ||= '25'; # we need a positive value
94 unless ($Collection) {
95 $Collection = RT::Tickets->new($session{'CurrentUser'});
96 $Collection->FromSQL($Query);
99 my (@Format) = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $Format);
101 $Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order);
102 $Collection->RowsPerPage($Rows);
103 $Collection->GotoPage($Page-1); # SB uses page 0 as the first page
104 my $TotalFound = $Collection->CountAll();
111 $Title => 'Ticket Search'
113 $SingleRecord => undef
114 $AllowSorting => undef
118 $Format => $RT::DefaultSearchResultFormat