cvs: pear /Structures_DataGrid/DataGrid Renderer.php

From: Date: Wed, 27 Oct 2004 16:16:44 +0000
Subject: cvs: pear /Structures_DataGrid/DataGrid Renderer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-25291@lists.php.net to get a copy of this message
asnagy Wed Oct 27 12:16:44 2004 EDT Modified files: /pear/Structures_DataGrid/DataGrid Renderer.php Log: Added automatic GET/POST/COOKIE variable handling for paging and sorting http://cvs.php.net/diff.php/pear/Structures_DataGrid/DataGrid/Renderer.php?r1=1.9&r2=1.10&ty=u Index: pear/Structures_DataGrid/DataGrid/Renderer.php diff -u pear/Structures_DataGrid/DataGrid/Renderer.php:1.9 pear/Structures_DataGrid/DataGrid/Renderer.php:1.10 --- pear/Structures_DataGrid/DataGrid/Renderer.php:1.9 Fri Oct 22 09:54:57 2004 +++ pear/Structures_DataGrid/DataGrid/Renderer.php Wed Oct 27 12:16:43 2004 @@ -16,7 +16,7 @@ // | Author: Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: Renderer.php,v 1.9 2004/10/22 13:54:57 asnagy Exp $ +// $Id: Renderer.php,v 1.10 2004/10/27 16:16:43 asnagy Exp $ require_once 'Structures/DataGrid/Core.php'; @@ -26,7 +26,7 @@ * This class handles managing the output for the DataGrid. * By default, the output is handled by the HTML_Table renderer. * - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @access public * @package Structures_DataGrid @@ -63,6 +63,10 @@ */ function render() { + if ((!count($this->sortArray)) && ($this->page == null)) { + $this->_parseHttpRequest(); + } + return $this->renderer->render($this); } @@ -138,6 +142,37 @@ } } } + + /** + * Parse HTTP Request parameters + * + * @access private + * @return array Associative array of parsed arguments, each of these + * defaulting to null if not found. + */ + function _parseHttpRequest() + { + // Determine parameter prefix + if ((isset($this->renderer->requestPrefix)) && + ($this->renderer->requestPrefix != '')) { + $prefix = $this->renderer->requestPrefix; + } else { + $prefix = null; + } + + // Add values to arguments + if (isset($_REQUEST[$prefix . 'page'])) { + $this->page = $_REQUEST[$prefix . 'page']; + } + + if (isset($_REQUEST[$prefix . 'orderBy'])) { + $this->sortArray[0] = $_REQUEST[$prefix . 'orderBy']; + } + + if (isset($_REQUEST[$prefix . 'direction'])) { + $this->sortArray[1] = $_REQUEST[$prefix . 'direction']; + } + } }

« previous php.pear.cvs (#25291) next »