[35224] trunk/www/ports.php

eridius at macports.org eridius at macports.org
Thu Mar 20 23:09:31 PDT 2008


Revision: 35224
          http://trac.macosforge.org/projects/macports/changeset/35224
Author:   eridius at macports.org
Date:     2008-03-20 23:09:31 -0700 (Thu, 20 Mar 2008)

Log Message:
-----------
Page numbers should start at 1

Modified Paths:
--------------
    trunk/www/ports.php

Modified: trunk/www/ports.php
===================================================================
--- trunk/www/ports.php	2008-03-21 06:04:51 UTC (rev 35223)
+++ trunk/www/ports.php	2008-03-21 06:09:31 UTC (rev 35224)
@@ -20,8 +20,8 @@
     }
     $by = isset($_GET['by']) ? $_GET['by'] : '';
     $substr = isset($_GET['substr']) ? $_GET['substr'] : '';
-    $page = isset($_GET['page']) ? max($_GET['page'], 0) : '';
-    $pagesize = isset($_GET['pagesize']) ? max($_GET['pagesize'], 0) : 50; # arbitrary setting
+    $page = isset($_GET['page']) ? max($_GET['page'], 1) : '1';
+    $pagesize = isset($_GET['pagesize']) ? max($_GET['pagesize'], 1) : 50; # arbitrary setting
 
     print_header('The MacPorts Project -- Available Ports', 'utf-8');
 ?>
@@ -121,7 +121,7 @@
         $where = ($criteria == '' ? '' : "WHERE $criteria");
         $query = "SELECT DISTINCT $fields FROM $tables $where ORDER BY name";
         if ($paging) {
-            $offset = $pagesize * $page;
+            $offset = $pagesize * ($page-1);
             $query .= " LIMIT $pagesize OFFSET $offset";
             # get the total count
             $countquery = "SELECT COUNT(*) FROM $tables $where ORDER By name";
@@ -131,8 +131,8 @@
             $pagecount = ceil($totalcount / $pagesize);
             # generate a paging control and cache it so we can show it twice
             $pagecontrol = "<p>Page ";
-            for ($i = 0; $i < $pagecount; $i++) {
-                if ($i != 0) {
+            for ($i = 1; $i <= $pagecount; $i++) {
+                if ($i != 1) {
                     $pagecontrol .= " | ";
                 }
                 if ($i == $page) {

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080320/b320fcca/attachment-0001.html 


More information about the macports-changes mailing list