[Rt-commit] r12938 - in rt/branches/3.8-TESTING: share/html/Elements

kyoki at bestpractical.com kyoki at bestpractical.com
Thu Jun 5 17:04:49 EDT 2008


Author: kyoki
Date: Thu Jun  5 17:04:49 2008
New Revision: 12938

Added:
   rt/branches/3.8-TESTING/share/html/Elements/CollectionListPaging
Modified:
   rt/branches/3.8-TESTING/   (props changed)
   rt/branches/3.8-TESTING/share/html/Elements/TicketList

Log:
 r22505 at nyx:  kyoki | 2008-06-05 16:38:17 -0400
 extracted TicketList paging to a reusable component


Added: rt/branches/3.8-TESTING/share/html/Elements/CollectionListPaging
==============================================================================
--- (empty file)
+++ rt/branches/3.8-TESTING/share/html/Elements/CollectionListPaging	Thu Jun  5 17:04:49 2008
@@ -0,0 +1,48 @@
+<%ARGS>
+$BaseURL => undef
+$Rows => undef
+$TotalFound => undef
+$CurrentPage => undef
+$Pages => undef
+$URLParams => undef
+</%ARGS>
+
+<%INIT>
+$m->out(loc('Page') . ' ');
+
+my $prev = $m->comp(
+		    '/Elements/QueryString',
+		    @$URLParams,
+		    Page    => ( $CurrentPage - 1 )
+		   );
+my %show;
+$show{1} = 1;
+$show{$_} = 1 for (($CurrentPage - 2)..($CurrentPage + 2));
+$show{$Pages} = 1;
+my $dots;
+for my $number (1..$Pages){
+  if ($show{$number}){
+    $dots = undef;
+    my $qs = $m->comp('/Elements/QueryString', @$URLParams, Page => $number);
+    $m->out(  qq{<a href="$BaseURL$qs">}
+	      . (($number == $CurrentPage)  ? "<em>$number</em>" : $number) 
+	      . qq{</a> });
+  }
+  elsif (not $dots){
+    $dots = 1;
+    $m->out(" ... ");
+  }
+}
+
+my $next = $m->comp(
+		    '/Elements/QueryString',
+		    @$URLParams,
+		    Page    => ( $CurrentPage + 1 )
+		   );
+</%INIT>
+% if ($CurrentPage > 1) {
+<a href="<%$BaseURL%><%$prev%>"><&|/l&>Previous</&></a>
+% }
+% if (($CurrentPage * $Rows) < $TotalFound) {
+<a href="<%$BaseURL%><%$next%>"><&|/l&>Next</&></a>
+% }

Modified: rt/branches/3.8-TESTING/share/html/Elements/TicketList
==============================================================================
--- rt/branches/3.8-TESTING/share/html/Elements/TicketList	(original)
+++ rt/branches/3.8-TESTING/share/html/Elements/TicketList	Thu Jun  5 17:04:49 2008
@@ -78,69 +78,26 @@
 
 </table>
 
-% if ($Rows && $ShowNavigation) {
+%if ($Rows && $ShowNavigation) {
 <hr />
-% my $oddRows = ($TotalFound && $TotalFound % $Rows == 0 )? 0 : 1;
-% my $pages = int($TotalFound/$Rows)+$oddRows;
-% $pages = 1 if $pages < 1;
-<&|/l, $Page, $pages &>Page </&>
-
-<%perl>
-my $prev = $m->comp(
-    '/Elements/QueryString',
-    Query   => $Query,
-    Format  => $Format,
-    Rows    => $Rows,
-    OrderBy => $OrderBy,
-    Order   => $Order,
-    Page    => ( $Page - 1 )
-);
-
-my %show;
-$show{1} = 1;
-$show{$_} = 1 for (($Page - 2)..($Page + 2));
-$show{$pages} = 1;
-my $dots;
-for my $number (1..$pages){
-  if ($show{$number}){
-    $dots = undef;
-    if ($number == $Page){
-      $number = ("<em>$number </em>");
-    }	
-    my $num = $m->comp(
-		       '/Elements/QueryString',
-		       Query   => $Query,
-		       Format  => $Format,
-		       Rows    => $Rows,
-		       OrderBy => $OrderBy,
-		       Order   => $Order,
-		       Page    => $number
-		      );
-    $m->out("<a href=\"$BaseURL$num\">$number </a>");
-  }
-  elsif (not $dots){
-    $dots = 1;
-    $m->out(" ... ");
-  }
+<%PERL>
+my $oddRows = ($TotalFound && $TotalFound % $Rows == 0 )? 0 : 1;
+my $pages = int($TotalFound/$Rows)+$oddRows;
+$pages = 1 if $pages < 1;
+my @url_params = (Query => $Query, 
+                  Format => $Format, 
+                  Rows => $Rows, 
+                  OrderBy => $OrderBy, 
+                  Order => $Order);
+$m->comp( '/Elements/CollectionListPaging',
+          BaseURL => $BaseURL,
+          Rows => $Rows,
+          TotalFound => $TotalFound,
+          CurrentPage => $Page,
+          Pages => $pages,
+          URLParams => \@url_params);
 }
-
-my $next = $m->comp(
-    '/Elements/QueryString',
-    Query   => $Query,
-    Format  => $Format,
-    Rows    => $Rows,
-    OrderBy => $OrderBy,
-    Order   => $Order,
-    Page    => ( $Page + 1 )
-);
-</%perl>
-% if ($Page > 1) {
-<a href="<%$BaseURL%><%$prev%>"><&|/l&>Previous</&></a>
-% }
-% if (($Page * $Rows) < $TotalFound) {
-<a href="<%$BaseURL%><%$next%>"><&|/l&>Next</&></a>
-% }
-% }
+</%PERL>
 <%INIT>
 unless ($Collection) {
         $Collection = RT::Tickets->new( $session{'CurrentUser'} );


More information about the Rt-commit mailing list