1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
6 %# <jesse@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/copyleft/gpl.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
48 <table border="0" cellspacing="0" cellpadding="1" width="100%">
51 <& /Elements/CollectionAsTable/Header,
53 FormatString => $Format,
54 AllowSorting => $AllowSorting,
61 maxitems => $maxitems &>
65 % while (my $record = $Collection->Next) {
67 % # Every $RT::MyTicketsLength or ten rows, flush the buffer and put something
69 % my $flushrows = $RT::MyTicketsLength || 10;
70 % $m->flush_buffer() unless ($i % $flushrows);
71 <& /Elements/CollectionAsTable/Row, Format => \@Format, i => $i, record => $record, maxitems => $maxitems &>
76 % if ($Rows && $ShowNavigation) {
79 % if (($TotalFound % $Rows) == 0) {
81 % } else { $oddRows = 1; }
82 % my $pages = int($TotalFound/$Rows)+$oddRows;
83 % $pages = 1 if $pages < 1;
84 <&|/l, $Page, $pages &>Page [_1] of [_2]</&>
88 '/Elements/QueryString',
97 '/Elements/QueryString',
103 Page => ( $Page + 1 )
107 <a href="<%$BaseURL%><%$prev%>"><&|/l&>Previous Page</&></a>
109 % if (($Page * $Rows) < $TotalFound) {
110 <a href="<%$BaseURL%><%$next%>"><&|/l&>Next Page</&></a>
116 $Format ||= $RT::DefaultSearchResultFormat;
118 # DisplayFormat lets us use a "temporary" format for display, while
119 # still using our original format for next/prev page links.
120 # bulk update uses this feature to add checkboxes
123 $DisplayFormat ||= $Format;
125 # Scrub the html of the format string to remove any potential nasties.
126 $Format = $m->comp('/Elements/ScrubHTML', Content => $Format);
127 $DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $DisplayFormat);
130 unless ($Collection) {
131 $Collection = RT::Tickets->new($session{'CurrentUser'});
132 $Collection->FromSQL($Query);
135 my (@Format) = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $DisplayFormat);
137 # Find the maximum number of items in any row, so we can pad the table.
139 foreach my $col (@Format) {
141 if ( $col->{title} && ($col->{title} eq 'NEWLINE') ) {
145 $maxitems = $item if $item > $maxitems;
149 if ($OrderBy =~ /\|/) {
151 my @OrderBy = split /\|/,$OrderBy;
152 my @Order = split /\|/,$Order;
153 $Collection->OrderByCols(
154 map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } } ( 0
157 $Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order);
160 $Collection->RowsPerPage($Rows) if ($Rows);
161 $Page = 1 unless $Page > 0; # workaround problems with Page = '' or undef
162 $Collection->GotoPage( $Page - 1 ); # SB uses page 0 as the first page
163 my $TotalFound = $Collection->CountAll();
170 $Title => 'Ticket Search'
172 $AllowSorting => undef
176 $Format => $RT::DefaultSearchResultFormat
177 $DisplayFormat => undef