English version  | Version française
PEAR resources

Download this resource (pear-3304.diff - 4k)

Index: DataGrid.php
===================================================================
RCS file: /repository/pear/Structures_DataGrid/DataGrid.php,v
retrieving revision 1.16
diff -u -u -r1.16 DataGrid.php
--- DataGrid.php	26 Jan 2005 21:25:47 -0000	1.16
+++ DataGrid.php	27 Jan 2005 18:38:35 -0000
@@ -71,12 +71,14 @@
      * Acts somewhat as a factory and instantiates the Renderer and the Core
      *
      * @param  string   $limit      The row limit per page.
-     * @param  string   $page       The current page viewed.
+     * @param  int      $page       The page to show (starting from 1). 
+     *                              Note : if you specify this, the "page" GET 
+     *                              variable will be ignored.
      * @param  string   $renderer   The renderer to use.
      * @return void
      * @access public
      */
-    function Structures_DataGrid($limit = null, $page = 1,
+    function Structures_DataGrid($limit = null, $page = null,
                                  $renderer = DATAGRID_RENDER_TABLE)
     {
         parent::Structures_DataGrid_Renderer($renderer, $limit, $page);
@@ -109,4 +111,4 @@
 
 }
 
-?>
\ No newline at end of file
+?>
Index: DataGrid/Core.php
===================================================================
RCS file: /repository/pear/Structures_DataGrid/DataGrid/Core.php,v
retrieving revision 1.26
diff -u -u -r1.26 Core.php
--- DataGrid/Core.php	10 Jan 2005 15:15:48 -0000	1.26
+++ DataGrid/Core.php	27 Jan 2005 18:38:35 -0000
@@ -74,6 +74,13 @@
     var $page;
 
     /**
+     * Whether the page number was provided at instantiation or not
+     * @var bool
+     * @access private
+     */
+    var $_forcePage; 
+    
+    /**
      * GET/POST/Cookie parameters prefix
      * @var string
      */
@@ -85,13 +92,21 @@
      * Creates default table style settings
      *
      * @param  string   $limit  The row limit per page.
-     * @param  string   $page   The current page viewed.
+     * @param  int      $page   The page to show (starting from 1). 
+     *                          Note : if you specify this, the "page" GET 
+     *                          variable will be ignored.
      * @access public
      */
-    function Structures_DataGrid_Core($limit = null, $page = 1)
+    function Structures_DataGrid_Core($limit = null, $page = null)
     {
         $this->rowLimit = $limit;
-        $this->page = $page;
+        if (!is_null($page)) {
+            $this->page = $page;
+            $this->_forcePage = true;
+        } else {
+            $this->page = 1;
+            $this->_forcePage = false;
+        }
         
         // Automatic handling of GET/POST/COOKIE variables
         $this->_parseHttpRequest();
@@ -278,9 +296,13 @@
         }
         
         // Add values to arguments
-        if (isset($_REQUEST[$prefix . 'page'])) {
-            $this->page = $_REQUEST[$prefix . 'page'];
-        }
+        if (!$this->_forcePage) {
+            if (isset($_REQUEST[$prefix . 'page'])) {
+                $this->page = $_REQUEST[$prefix . 'page'];
+            } else {
+                $this->page = 1;
+            }
+        } 
         
         if (isset($_REQUEST[$prefix . 'orderBy'])) {
             $this->sortArray[0] = $_REQUEST[$prefix . 'orderBy'];
Index: DataGrid/Renderer.php
===================================================================
RCS file: /repository/pear/Structures_DataGrid/DataGrid/Renderer.php,v
retrieving revision 1.17
diff -u -u -r1.17 Renderer.php
--- DataGrid/Renderer.php	10 Jan 2005 15:15:48 -0000	1.17
+++ DataGrid/Renderer.php	27 Jan 2005 18:38:35 -0000
@@ -43,10 +43,14 @@
      * as the default.
      *
      * @param  string   $renderer   The renderer to use.
+     * @param  int      $limit      The row limit per page
+     * @param  int      $page       The page to show (starting from 1). 
+     *                              Note : if you specify this, the "page" GET 
+     *                              variable will be ignored.
      * @access public
      */
     function Structures_DataGrid_Renderer($renderer = DATAGRID_RENDER_TABLE,
-                                          $limit = null, $page = 1)
+                                          $limit = null, $page = null)
     {
         if (PEAR::isError($this->setRenderer($renderer))) {
             $this->setRenderer(DATAGRID_RENDER_TABLE);
Icon
Faites-nous part de votre projet
Progress bar