cvs: pear /Structures_DataGrid package.xml /Structures_DataGrid/DataGrid/Renderer Common.php HTMLTable.php
| From: | Olivier Guilyardi | Date: | Thu, 23 Feb 2006 14:09:37 +0000 |
| Subject: | cvs: pear /Structures_DataGrid package.xml /Structures_DataGrid/DataGrid/Renderer Common.php HTMLTable.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38530@lists.php.net to get a copy of this message | ||
olivierg Thu Feb 23 14:09:37 2006 UTC
Modified files:
/pear/Structures_DataGrid package.xml
/pear/Structures_DataGrid/DataGrid/Renderer Common.php
HTMLTable.php
Log:
Fixed some minor bugs and added comments. Req #5859 is almost done.
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/package.xml?r1=1.40&r2=1.41&diff_format=u Index: pear/Structures_DataGrid/package.xml diff -u pear/Structures_DataGrid/package.xml:1.40 pear/Structures_DataGrid/package.xml:1.41 --- pear/Structures_DataGrid/package.xml:1.40 Wed Feb 15 20:55:47 2006 +++ pear/Structures_DataGrid/package.xml Thu Feb 23 14:09:36 2006 @@ -35,6 +35,14 @@ <license>PHP License</license> <state>beta</state> <notes> + + ########################################################################## + # WARNING - BACKWARD INCOMPATIBILITY # + # The Structures_DataGrid::renderer property is not public anymore. It # + # is now required to use the Structures_DataGrid::getRenderer() method # + # in order to access the renderer object. # + ########################################################################## + Req #4254 : Completed integration of the DBTable datasource driver @@ -89,6 +97,10 @@ Req #5838: New HTMLTable "convertEntities" option Thanks <abriening at comcast dot net> + + Req #5859: + The rendering layer has gone through a long refactoring process and + a new and flexible renderer driver interface has been implemented. Auto-alignment : The HTMLTable renderer now automatically aligns numeric values @@ -102,8 +114,23 @@ The query building process has been optimized, and is now more flexible due to the use of http_build_query(). This adds a new dependency : PHP_Compat >= 1.4.1 - - Added new DataSource driver MDB2 with same behaviour as DBQuery driver + + MDB2 compatibility: + Added new DataSource driver MDB2 with same behaviour as DBQuery driver + + Custom rendering containers: + The containers that rendering drivers use to do their job, such as + HTML_Table, Spreadsheet_Excel_Writer, etc.. can now be instantiated + and customized by the user. They are then passed to the rendering + driver with new methods such as Structures_DataGrid::fill() or + Structures_DataGrid_Renderer_*::setContainer(). + + New fill() method: + This method is meant to be to renderers what bind() is to datasources. + It accepts a "rendering container" object (where bind() accepts a + "datasource container") which it fills with data. No data is output + during this process. It is up to the user to decide what to do with + the container once it's been filled up. </notes> <deps> <dep type="pkg" rel="ge" version="1.2" optional="no">PEAR</dep> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/Common.php?r1=1.13&r2=1.14&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/Common.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/Common.php:1.13 pear/Structures_DataGrid/DataGrid/Renderer/Common.php:1.14 --- pear/Structures_DataGrid/DataGrid/Renderer/Common.php:1.13 Wed Feb 8 20:11:58 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/Common.php Thu Feb 23 14:09:36 2006 @@ -17,7 +17,7 @@ // | Olivier Guilyardi <olivier@samalyse.com> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.13 2006/02/08 20:11:58 wiesemann Exp $ +// $Id: Common.php,v 1.14 2006/02/23 14:09:36 olivierg Exp $ /** * Structures_DataGrid_Renderer_Common Class @@ -56,7 +56,7 @@ * added * * - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @access public * @package Structures_DataGrid @@ -214,63 +214,171 @@ $this->_options = array_merge($this->_options, $options); } + /** + * Attach a container object + * + * @param object Container of the class supported by the driver + * @access public + */ function setContainer(&$container) { $this->_container =& $container; } + /** + * Return the container used by the driver + * + * @return object Container of the class supported by the driver + * @access public + */ function &getContainer() { return $this->_container; } + /** + * Provide columns and records data + * + * @param array $columns Array of Structures_DataGrid_Column objects + * @param array $records 2D array of records values + * @access public + */ function setData(&$columns, &$records) { $this->_columnObjects = &$columns; $this->_records = &$records; } - + + /** + * Specify how the datagrid is currently sorted + * + * @param string $field Which field it is sorted by + * @param string $direction Direction (ASC|DESC) + * @access public + */ function setCurrentSorting($field, $direction) { $this->_currentSortField = $field; $this->_currentSortDirection = $direction; } + /** + * Specify page and row limits + * + * @param int $currentPage Current page number + * @param int $rowsPerPage Maximum number of rows per page + * @param int $totalRowNum Total number of data rows + * @access public + */ function setLimit($currentPage, $rowsPerPage, $totalRowNum) { $this->_page = $currentPage; $this->_pageLimit = $rowsPerPage; $this->_totalRecordsNum = $totalRowNum; } - + + /** + * Create or/and prepare the container + * + * Drivers are required to implement this method. + * + * This method is responsible for creating the container if it has not + * already been provided by the user with the setContainer() method. + * It is where preliminary container setup also happens. + * + * @abstract + * @access protected + */ function init() { } - + + + /** + * Build the header + * + * Drivers may optionally implement this method. + * + * @abstract + * @access protected + * @return void + */ function buildHeader() { } - + + /** + * Build the body + * + * Drivers are required to implement this method. + * + * @abstract + * @access protected + * @return void + */ function buildBody() { } + /** + * Build the footer + * + * Drivers may optionally implement this method. + * + * @abstract + * @access protected + * @return void + */ function buildFooter() { } + /** + * Finish building the datagrid. + * + * Drivers may optionally implement this method. + * + * @abstract + * @access protected + * @return void + */ function finalize() { } + /** + * Retrieve output from the container object + * + * Drivers are required to implement this method. + * + * @abstract + * @return mixed Output + * @access protected + */ function flatten() { } - + + /** + * Default formatter for all cells + * + * Drivers may optionally implement this method. + * + * @abstract + * @param string Cell value + * @return string Formatted cell value + * @access protected + */ function defaultCellFormatter ($value) { return $value; } - + + /** + * Build the grid + * + * @access public + * @return void + */ function build() { $this->_columns = array(); @@ -366,11 +474,26 @@ } /* What are we supposed to do with $status = true ? */ } - + + /** + * Set the HTTP Request prefix + * + * @param string $prefix The prefix string + * @return void + * @acess public + */ function setRequestPrefix($prefix) { $this->_requestPrefix = $prefix; } + /** + * Perform record/column to cell intersection and formatting + * + * @param object $column The column object + * @param array $record Array of record values + * @return string Formatted cell value + * @access private + */ function recordToCell(&$column, $record) { $value = ''; @@ -387,6 +510,17 @@ return $value; } + + /** + * Query the grid build status + * + * @return bool Wether the grid has already been built or not + * @access public + */ + function isBuilt() + { + return $this->_isBuilt; + } } ?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php?r1=1.76&r2=1.77&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.76 pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.77 --- pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.76 Wed Feb 8 18:49:11 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php Thu Feb 23 14:09:37 2006 @@ -18,7 +18,7 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: HTMLTable.php,v 1.76 2006/02/08 18:49:11 wiesemann Exp $ +// $Id: HTMLTable.php,v 1.77 2006/02/23 14:09:37 olivierg Exp $ require_once 'Structures/DataGrid/Renderer/Common.php'; require_once 'HTML/Table.php'; @@ -54,7 +54,7 @@ * - encoding : the content encoding. Default: ISO-8859-1 * * - * @version $Revision: 1.76 $ + * @version $Revision: 1.77 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -126,6 +126,7 @@ /** * Set a table attribute * + * @deprecated Use the HTML_Table constructor directly instead * @access public * @param string $name The CSS class to use for the table. */ @@ -299,7 +300,7 @@ /** * Handles building the header of the DataGrid * - * @access private + * @access protected * @return void * @todo Redesign/Rework the header URL building. */ @@ -374,7 +375,7 @@ /** * Handles building the body of the DataGrid * - * @access private + * @access protected * @return void */ function buildBody()
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/package.xml?r1=1.40&r2=1.41&diff_format=u Index: pear/Structures_DataGrid/package.xml diff -u pear/Structures_DataGrid/package.xml:1.40 pear/Structures_DataGrid/package.xml:1.41 --- pear/Structures_DataGrid/package.xml:1.40 Wed Feb 15 20:55:47 2006 +++ pear/Structures_DataGrid/package.xml Thu Feb 23 14:09:36 2006 @@ -35,6 +35,14 @@ <license>PHP License</license> <state>beta</state> <notes> + + ########################################################################## + # WARNING - BACKWARD INCOMPATIBILITY # + # The Structures_DataGrid::renderer property is not public anymore. It # + # is now required to use the Structures_DataGrid::getRenderer() method # + # in order to access the renderer object. # + ########################################################################## + Req #4254 : Completed integration of the DBTable datasource driver @@ -89,6 +97,10 @@ Req #5838: New HTMLTable "convertEntities" option Thanks <abriening at comcast dot net> + + Req #5859: + The rendering layer has gone through a long refactoring process and + a new and flexible renderer driver interface has been implemented. Auto-alignment : The HTMLTable renderer now automatically aligns numeric values @@ -102,8 +114,23 @@ The query building process has been optimized, and is now more flexible due to the use of http_build_query(). This adds a new dependency : PHP_Compat >= 1.4.1 - - Added new DataSource driver MDB2 with same behaviour as DBQuery driver + + MDB2 compatibility: + Added new DataSource driver MDB2 with same behaviour as DBQuery driver + + Custom rendering containers: + The containers that rendering drivers use to do their job, such as + HTML_Table, Spreadsheet_Excel_Writer, etc.. can now be instantiated + and customized by the user. They are then passed to the rendering + driver with new methods such as Structures_DataGrid::fill() or + Structures_DataGrid_Renderer_*::setContainer(). + + New fill() method: + This method is meant to be to renderers what bind() is to datasources. + It accepts a "rendering container" object (where bind() accepts a + "datasource container") which it fills with data. No data is output + during this process. It is up to the user to decide what to do with + the container once it's been filled up. </notes> <deps> <dep type="pkg" rel="ge" version="1.2" optional="no">PEAR</dep> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/Common.php?r1=1.13&r2=1.14&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/Common.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/Common.php:1.13 pear/Structures_DataGrid/DataGrid/Renderer/Common.php:1.14 --- pear/Structures_DataGrid/DataGrid/Renderer/Common.php:1.13 Wed Feb 8 20:11:58 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/Common.php Thu Feb 23 14:09:36 2006 @@ -17,7 +17,7 @@ // | Olivier Guilyardi <olivier@samalyse.com> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.13 2006/02/08 20:11:58 wiesemann Exp $ +// $Id: Common.php,v 1.14 2006/02/23 14:09:36 olivierg Exp $ /** * Structures_DataGrid_Renderer_Common Class @@ -56,7 +56,7 @@ * added * * - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @access public * @package Structures_DataGrid @@ -214,63 +214,171 @@ $this->_options = array_merge($this->_options, $options); } + /** + * Attach a container object + * + * @param object Container of the class supported by the driver + * @access public + */ function setContainer(&$container) { $this->_container =& $container; } + /** + * Return the container used by the driver + * + * @return object Container of the class supported by the driver + * @access public + */ function &getContainer() { return $this->_container; } + /** + * Provide columns and records data + * + * @param array $columns Array of Structures_DataGrid_Column objects + * @param array $records 2D array of records values + * @access public + */ function setData(&$columns, &$records) { $this->_columnObjects = &$columns; $this->_records = &$records; } - + + /** + * Specify how the datagrid is currently sorted + * + * @param string $field Which field it is sorted by + * @param string $direction Direction (ASC|DESC) + * @access public + */ function setCurrentSorting($field, $direction) { $this->_currentSortField = $field; $this->_currentSortDirection = $direction; } + /** + * Specify page and row limits + * + * @param int $currentPage Current page number + * @param int $rowsPerPage Maximum number of rows per page + * @param int $totalRowNum Total number of data rows + * @access public + */ function setLimit($currentPage, $rowsPerPage, $totalRowNum) { $this->_page = $currentPage; $this->_pageLimit = $rowsPerPage; $this->_totalRecordsNum = $totalRowNum; } - + + /** + * Create or/and prepare the container + * + * Drivers are required to implement this method. + * + * This method is responsible for creating the container if it has not + * already been provided by the user with the setContainer() method. + * It is where preliminary container setup also happens. + * + * @abstract + * @access protected + */ function init() { } - + + + /** + * Build the header + * + * Drivers may optionally implement this method. + * + * @abstract + * @access protected + * @return void + */ function buildHeader() { } - + + /** + * Build the body + * + * Drivers are required to implement this method. + * + * @abstract + * @access protected + * @return void + */ function buildBody() { } + /** + * Build the footer + * + * Drivers may optionally implement this method. + * + * @abstract + * @access protected + * @return void + */ function buildFooter() { } + /** + * Finish building the datagrid. + * + * Drivers may optionally implement this method. + * + * @abstract + * @access protected + * @return void + */ function finalize() { } + /** + * Retrieve output from the container object + * + * Drivers are required to implement this method. + * + * @abstract + * @return mixed Output + * @access protected + */ function flatten() { } - + + /** + * Default formatter for all cells + * + * Drivers may optionally implement this method. + * + * @abstract + * @param string Cell value + * @return string Formatted cell value + * @access protected + */ function defaultCellFormatter ($value) { return $value; } - + + /** + * Build the grid + * + * @access public + * @return void + */ function build() { $this->_columns = array(); @@ -366,11 +474,26 @@ } /* What are we supposed to do with $status = true ? */ } - + + /** + * Set the HTTP Request prefix + * + * @param string $prefix The prefix string + * @return void + * @acess public + */ function setRequestPrefix($prefix) { $this->_requestPrefix = $prefix; } + /** + * Perform record/column to cell intersection and formatting + * + * @param object $column The column object + * @param array $record Array of record values + * @return string Formatted cell value + * @access private + */ function recordToCell(&$column, $record) { $value = ''; @@ -387,6 +510,17 @@ return $value; } + + /** + * Query the grid build status + * + * @return bool Wether the grid has already been built or not + * @access public + */ + function isBuilt() + { + return $this->_isBuilt; + } } ?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php?r1=1.76&r2=1.77&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.76 pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.77 --- pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.76 Wed Feb 8 18:49:11 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php Thu Feb 23 14:09:37 2006 @@ -18,7 +18,7 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: HTMLTable.php,v 1.76 2006/02/08 18:49:11 wiesemann Exp $ +// $Id: HTMLTable.php,v 1.77 2006/02/23 14:09:37 olivierg Exp $ require_once 'Structures/DataGrid/Renderer/Common.php'; require_once 'HTML/Table.php'; @@ -54,7 +54,7 @@ * - encoding : the content encoding. Default: ISO-8859-1 * * - * @version $Revision: 1.76 $ + * @version $Revision: 1.77 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -126,6 +126,7 @@ /** * Set a table attribute * + * @deprecated Use the HTML_Table constructor directly instead * @access public * @param string $name The CSS class to use for the table. */ @@ -299,7 +300,7 @@ /** * Handles building the header of the DataGrid * - * @access private + * @access protected * @return void * @todo Redesign/Rework the header URL building. */ @@ -374,7 +375,7 @@ /** * Handles building the body of the DataGrid * - * @access private + * @access protected * @return void */ function buildBody()