cvs: pear /Structures_DataGrid DataGrid.php package2.xml /Structures_DataGrid/DataGrid Column.php Renderer.php

From: Date: Fri, 16 Jun 2006 18:10:06 +0000
Subject: cvs: pear /Structures_DataGrid DataGrid.php package2.xml /Structures_DataGrid/DataGrid Column.php Renderer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-40772@lists.php.net to get a copy of this message
wiesemann Fri Jun 16 18:10:06 2006 UTC Modified files: /pear/Structures_DataGrid DataGrid.php package2.xml /pear/Structures_DataGrid/DataGrid Column.php Renderer.php Log: - added request #7927: new parameters 'currRow' and 'currCol' available in column formatter callback functions (thanks to Clark Freifeld for the idea and the patch) - another fix for PHP bug #32660 (thanks to Michel D'Hooge for noting this and the patch) http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid.php?r1=1.77&r2=1.78&diff_format=u Index: pear/Structures_DataGrid/DataGrid.php diff -u pear/Structures_DataGrid/DataGrid.php:1.77 pear/Structures_DataGrid/DataGrid.php:1.78 --- pear/Structures_DataGrid/DataGrid.php:1.77 Fri Jun 16 15:46:16 2006 +++ pear/Structures_DataGrid/DataGrid.php Fri Jun 16 18:10:06 2006 @@ -18,7 +18,7 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DataGrid.php,v 1.77 2006/06/16 15:46:16 wiesemann Exp $ +// $Id: DataGrid.php,v 1.78 2006/06/16 18:10:06 wiesemann Exp $ require_once 'PEAR.php'; @@ -74,7 +74,7 @@ * ?> * </code> * - * @version $Revision: 1.77 $ + * @version $Revision: 1.78 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -525,6 +525,11 @@ function _saveRenderer() { if (isset($this->_renderer)) { + // The following line is a workaround for PHP bug 32660 + // See: http://bugs.php.net/bug.php?id=32660 + // Another solution would be to remove __get which is used only for BC + $this->_rendererBackup = 1; + $this->_rendererBackup =& $this->_renderer; $this->_rendererTypeBackup = $this->_rendererType; http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/package2.xml?r1=1.8&r2=1.9&diff_format=u Index: pear/Structures_DataGrid/package2.xml diff -u pear/Structures_DataGrid/package2.xml:1.8 pear/Structures_DataGrid/package2.xml:1.9 --- pear/Structures_DataGrid/package2.xml:1.8 Fri Jun 16 17:08:36 2006 +++ pear/Structures_DataGrid/package2.xml Fri Jun 16 18:10:06 2006 @@ -70,8 +70,8 @@ FEATURE REQUESTS: -- request #5758: new parameters for Structures_DataGrid_Column::formatter() - callback: 'fieldName', 'columnName', 'orderBy', 'attribs' +- requests #5758 and #7927: new parameters for Structures_DataGrid_Column::formatter() + callback: 'fieldName', 'columnName', 'orderBy', 'attribs', 'currRow', 'currCol' - request #5859: the rendering layer has gone through a long refactoring process and a new and flexible renderer driver interface has been implemented @@ -105,8 +105,7 @@ if it is null, then the corresponding column is considered unsortable, which is taken into account by various renderer drivers (HTMLTable, XUL, etc.) -- new rendering driver : Structures_DataGrid_Renderer_HTMLSortForm - +- new rendering driver: Structures_DataGrid_Renderer_HTMLSortForm </notes> <contents> <dir name="/"> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Column.php?r1=1.28&r2=1.29&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Column.php diff -u pear/Structures_DataGrid/DataGrid/Column.php:1.28 pear/Structures_DataGrid/DataGrid/Column.php:1.29 --- pear/Structures_DataGrid/DataGrid/Column.php:1.28 Fri Jun 16 17:05:22 2006 +++ pear/Structures_DataGrid/DataGrid/Column.php Fri Jun 16 18:10:06 2006 @@ -16,14 +16,14 @@ // | Author: Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: Column.php,v 1.28 2006/06/16 17:05:22 wiesemann Exp $ +// $Id: Column.php,v 1.29 2006/06/16 18:10:06 wiesemann Exp $ /** * Structures_DataGrid_Column Class * * This class represents a single column for the DataGrid. * - * @version $Revision: 1.28 $ + * @version $Revision: 1.29 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @access public * @package Structures_DataGrid @@ -212,7 +212,7 @@ * * @access public */ - function formatter($record) + function formatter($record, $row, $col) { // Define the parameter list $paramList = array(); @@ -221,6 +221,8 @@ $paramList['columnName'] = $this->columnName; $paramList['orderBy'] = $this->orderBy; $paramList['attribs'] = $this->attribs; + $paramList['currRow'] = $row; + $paramList['currCol'] = $col; // Call the formatter if (isset($GLOBALS['_STRUCTURES_DATAGRID']['column_formatter_BC'])) { http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer.php?r1=1.48&r2=1.49&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer.php diff -u pear/Structures_DataGrid/DataGrid/Renderer.php:1.48 pear/Structures_DataGrid/DataGrid/Renderer.php:1.49 --- pear/Structures_DataGrid/DataGrid/Renderer.php:1.48 Sun Jun 11 11:41:48 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer.php Fri Jun 16 18:10:06 2006 @@ -17,7 +17,7 @@ // | Olivier Guilyardi <olivier@samalyse.com> | // +----------------------------------------------------------------------+ // -// $Id: Renderer.php,v 1.48 2006/06/11 11:41:48 olivierg Exp $ +// $Id: Renderer.php,v 1.49 2006/06/16 18:10:06 wiesemann Exp $ require_once 'PHP/Compat/Function/http_build_query.php'; @@ -99,7 +99,7 @@ * - extraVars * - excludeVars * - * @version $Revision: 1.48 $ + * @version $Revision: 1.49 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @access public * @package Structures_DataGrid @@ -676,12 +676,17 @@ $this->_pageLimit = $this->_recordsNum; } + $row = 0; for ($rec = 0; $rec < $this->_recordsNum; $rec++) { $content = array(); + $col = 0; foreach ($this->_columnObjects as $column) { - $content[] = $this->recordToCell($column, $this->_records[$rec]); + $content[] = $this->recordToCell($column, $this->_records[$rec], + $row, $col); + $col++; } $this->_records[$rec] = $content; + $row++; } if ($this->_options['buildHeader']) { @@ -797,14 +802,16 @@ * * @param object $column The column object * @param array $record Array of record values + * @param int $row The row number of the cell + * @param int $col The column number of the cell * @return string Formatted cell value * @access private */ - function recordToCell(&$column, $record) + function recordToCell(&$column, $record, $row = null, $col = null) { $value = ''; if (isset($column->formatter) and !empty($column->formatter)) { - $value = $column->formatter($record); + $value = $column->formatter($record, $row, $col); } else if (isset($column->fieldName) and isset($record[$column->fieldName])) { $value = $this->defaultCellFormatter($record[$column->fieldName]); }

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