cvs: pear /Structures_DataGrid/DataGrid DataSource.php Renderer.php /Structures_DataGrid/DataGrid/DataSource Array.php Common.php DBQuery.php
DBTable.php DataObject.php MDB2.php /Structures_DataGrid/DataGrid/Record DataObject.php /Structures_DataGrid/DataGrid/Renderer CSV.php Common.php
Console.php HTMLTable.php XLS.php XML.php XUL.php
| From: | Olivier Guilyardi | Date: | Thu, 16 Mar 2006 12:37:20 +0000 |
| Subject: | cvs: pear /Structures_DataGrid/DataGrid DataSource.php Renderer.php /Structures_DataGrid/DataGrid/DataSource Array.php Common.php DBQuery.php DBTable.php DataObject.php MDB2.php /Structures_DataGrid/DataGrid/Record DataObject.php /Structures_DataGrid/DataGrid/Renderer CSV.php Common.php Console.php HTMLTable.php XLS.php XML.php XUL.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39121@lists.php.net to get a copy of this message | ||
olivierg Thu Mar 16 12:37:20 2006 UTC
Removed files:
/pear/Structures_DataGrid/DataGrid/DataSource Common.php
/pear/Structures_DataGrid/DataGrid/Renderer Common.php
Modified files:
/pear/Structures_DataGrid/DataGrid DataSource.php Renderer.php
/pear/Structures_DataGrid/DataGrid/DataSource Array.php DBQuery.php
DBTable.php
DataObject.php
MDB2.php
/pear/Structures_DataGrid/DataGrid/Record DataObject.php
/pear/Structures_DataGrid/DataGrid/Renderer CSV.php Console.php
HTMLTable.php XLS.php
XML.php XUL.php
Log:
Moved Renderer_Common to Renderer and DataSource_Common to DataSource
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource.php?r1=1.13&r2=1.14&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource.php diff -u /dev/null pear/Structures_DataGrid/DataGrid/DataSource.php:1.14 --- /dev/null Thu Mar 16 12:37:20 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource.php Thu Mar 16 12:37:20 2006 @@ -0,0 +1,381 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2005 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.0 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Olivier Guilyardi <olivier@samalyse.com> | +// | Andrew Nagy <asnagy@webitecture.org> | +// +----------------------------------------------------------------------+ +// +// $Id: DataSource.php,v 1.14 2006/03/16 12:37:20 olivierg Exp $ + + +/** +* Base abstract class for data source drivers +* +* <b>Recognized options (valid for all drivers) :</b> +* +* <b>"generate_columns" </b> Generate +* Structures_DataGrid_Column objects with labels. (default : false) +* +* <b>"labels" : </b> How to translate the field names to column labels. +* Only used when "generate_columns" is true. Default : array(). +* This is an associative array of the form : +* <code> +* array ("fieldName" => "fieldLabel", ...) +* </code> +* +* <b>"fields" : </b> Which fields should be rendered (Only used when +* "generate_columns" is true. The default is an empty array : all of +* the DataObject's fields will be rendered. +* This is an array of the form : +* <code> +* array ("fieldName1", "fieldName2", ...) +* </code> +* +* Users may want to see the create() factory method +* +* Developers : +* +* <b>HOWTO develop a new source driver</b> +* +* Subclass this Structures_DataGrid_DataSource class : +* <code> +* class Structures_DataGrid_DataSource_Foo extends +* Structures_DataGrid_DataSource +* </code> +* +* In the constructor, initialize default options . These defaults will be +* used to validate user provided options, so you need to set all possible +* ones +* <code> +* function Structures_DataGrid_DataSource_Foo() +* { +* parent::Structures_DataGrid_DataSource(); // required +* $this->_addDefaultOptions(array( 'bar' => true)); +* } +* </code> +* +* Expose the fetch(), count() and bind() methods, overloading +* the provided skeleton. See the corresponding prototypes +* for more information on how to do this. +* +* Do not forget to call Structures_DataGrid_DataSource::setOptions() +* from your bind() method. +* ex : if ($options) $this->setOptions($options); +* +* Eventually, use the dump() debugging method to test your brand new +* driver +* +* @author Olivier Guilyardi <olivier@samalyse.com> +* @author Andrew Nagy <asnagy@webitecture.org> +* @author Mark Wiesemann <wiesemann@php.net> +* @package Structures_DataGrid +* @category Structures +* @version $Revision $ +*/ +class Structures_DataGrid_DataSource +{ + /* FIXME: Did we really need to rename this class from DataSource to + * DataSource_Common ? IIRC we did this to mimic the MDB2 internals, + * which is pointless. There are some good practices in MDB2, that + * we have tried to implement in the Renderer layer. But the "Common" + * suffix is convention that we do not need to follow. + * + * It will break BC for no reason. for people who have written their own + * drivers by subclassing the old DataSource class. + * + * This is fixed... + */ + + /** + * Common and driver-specific options + * + * @var array + * @access protected + * @see Structures_DataGrid_DataSource::_setOption() + * @see Structures_DataGrid_DataSource::addDefaultOptions() + */ + var $_options = array(); + + /** + * Special driver features + * + * @var array + * @access protected + */ + var $_features = array(); + + /** + * Constructor + * + */ + function Structures_DataGrid_DataSource() + { + $this->_options = array('generate_columns' => false, + 'labels' => array(), + 'fields' => array()); + + $this->_features = array( + 'multiSort' => false, // Multiple field sorting + ); + } + + /** + * Adds some default options. + * + * This method is meant to be called by drivers. It allows adding some + * default options. + * + * @access protected + * @param array $options An associative array of the form: + * array(optionName => optionValue, ...) + * @return void + * @see Structures_DataGrid_DataSource::_setOption + */ + function _addDefaultOptions($options) + { + $this->_options = array_merge($this->_options, $options); + } + + /** + * Add special driver features + * + * This method is meant to be called by drivers. It allows specifying + * the special features that are supported by the current driver. + * + * @access protected + * @param array $features An associative array of the form: + * array(feature => true|false, ...) + * @return void + */ + function _setFeatures($features) + { + $this->_features = array_merge($this->_features, $features); + } + + /** + * Set options + * + * @param mixed $options An associative array of the form : + * array("option_name" => "option_value",...) + * @access protected + */ + function setOptions($options) + { + $this->_options = array_merge($this->_options, $options); + } + + /** + * Generate columns if options are properly set + * + * Note : must be called after fetch() + * + * @access public + * @return array Array of Column objects. Empty array if irrelevant. + */ + function getColumns() + { + $columns = array(); + if ($this->_options['generate_columns'] + and $fieldList = $this->_options['fields']) { + + include_once('Structures/DataGrid/Column.php'); + + foreach ($fieldList as $field) { + $label = strtr($field, $this->_options['labels']); + $col = new Structures_DataGrid_Column($label, $field, $field); + $columns[] = $col; + } + } + + return $columns; + } + + + // Begin driver method prototypes DocBook template + + /**#@+ + * + * This method is public, but please note that it is not intended to be + * called by user-space code. It is meant to be called by the main + * Structures_DataGrid class. + * + * It is an abstract method, part of the DataGrid Datasource driver + * interface, and must overloaded by drivers. + */ + + /** + * Fetching method prototype + * + * When overloaded this method must return a 2D array of records + * on success or a PEAR_Error object on failure. + * + * @abstract + * @param integer $offset Limit offset (starting from 0) + * @param integer $len Limit length + * @param string $sortSpec If the driver supports the "multiSort" + * feature this can be either a single field + * (string), or a sort specification array of + * the form : array(field => direction, ...) + * If "multiSort" is not supported, then this + * can only be a string. + * @param string $sortDir Sort direction : 'ASC' or 'DESC' + * @return object PEAR_Error with message + * "No data source driver loaded" + * @access public + */ + function &fetch($offset=0, $len=null, $sortSpec=null, $sortDir='ASC') + /* FIXME: Why is there these $sortField and $sortDir parameters ? This + * is redundant with the sort() method. + */ + { + return new PEAR_Error("No data source driver loaded"); + } + + /** + * Counting method prototype + * + * Note : must be called before fetch() + * + * When overloaded, this method must return the total number or records + * or a PEAR_Error object on failure + * + * @abstract + * @return object PEAR_Error with message + * "No data source driver loaded" + * @access public + */ + function count() + { + return new PEAR_Error("No data source driver loaded"); + } + + /** + * Sorting method prototype + * + * When overloaded this method must return true on success or a PEAR_Error + * object on failure. + * + * Note : must be called before fetch() + * + * @abstract + * @param string $sortSpec If the driver supports the "multiSort" + * feature this can be either a single field + * (string), or a sort specification array of + * the form : array(field => direction, ...) + * If "multiSort" is not supported, then this + * can only be a string. + * @param string $sortDir Sort direction : 'ASC' or 'DESC' + * @return object PEAR_Error with message + * "No data source driver loaded" + * @access public + */ + function sort($sortSpec, $sortDir = null) + { + return new PEAR_Error("No data source driver loaded"); + } + + /** + * Datasource binding method prototype + * + * When overloaded this method must return true on success or a PEAR_Error + * object on failure. + * + * @abstract + * @param mixed $container The datasource container + * @param array $options Binding options + * @return object PEAR_Error with message + * "No data source driver loaded" + * @access public + */ + function bind($container, $options = array()) + { + return new PEAR_Error("No data source driver loaded"); + } + + /**#@-*/ + + // End DocBook template + + /** + * List special driver features + * + * @return array Of the form: array(feature => true|false, etc...) + * @access public + */ + function getFeatures() + { + return $this->_features; + } + + /** + * Tell if the driver as a specific feature + * + * @param string $name Feature name + * @return bool + * @access public + */ + function hasFeature($name) + { + } + + /** + * Dump the data as returned by fetch(). + * + * This method is meant for debugging purposes. It returns what fetch() + * would return to its DataGrid host as a nicely formatted console-style + * table. + * + * @param integer $offset Limit offset (starting from 0) + * @param integer $len Limit length + * @param string $sortField Field to sort by + * @param string $sortDir Sort direction : 'ASC' or 'DESC' + * @return string The table string, ready to be printed + * @uses Structures_DataGrid_DataSource::fetch() + * @access public + */ + function dump($offset=0, $len=null, $sortField=null, $sortDir='ASC') + { + $records =& $this->fetch($offset, $len, $sortField, $sortDir); + $columns = $this->getColumns(); + + if (!$columns and !$records) { + return "<Empty set>\n"; + } + + include_once 'Console/Table.php'; + $table = new Console_Table(); + + $headers = array(); + if ($columns) { + foreach ($columns as $col) { + $headers[] = is_null($col->fieldName) + ? $col->columnName + : "{$col->columnName} ({$col->fieldName})"; + } + } else { + $headers = array_keys($records[0]); + } + + $table->setHeaders($headers); + + foreach ($records as $rec) { + $table->addRow($rec); + } + + return $table->getTable(); + } + +} +?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer.php?r1=1.30&r2=1.31&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer.php diff -u /dev/null pear/Structures_DataGrid/DataGrid/Renderer.php:1.31 --- /dev/null Thu Mar 16 12:37:20 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer.php Thu Mar 16 12:37:20 2006 @@ -0,0 +1,829 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2005 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.0 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Andrew Nagy <asnagy@webitecture.org> | +// | Olivier Guilyardi <olivier@samalyse.com> | +// +----------------------------------------------------------------------+ +// +// $Id: Renderer.php,v 1.31 2006/03/16 12:37:20 olivierg Exp $ + +require_once 'PHP/Compat/Function/http_build_query.php'; + +/** + * Base class of all Renderer drivers + * + * Recognized options : + * + * - buildHeader : whether to build the header (default : true) + * - buildFooter : whether to build the footer (default : true) + * - fillWithEmptyRows : ensures that all pages have the same number of + * rows (default : false) + * - numberAlign : whether to right-align numeric values (default : true) + * - defaultCellValue : what value to put by default into empty cells + * - defaultColumnValues : per-column default cell value. This is an array + * of the form : array(fieldName => value, ...) + * - disableColumnSorting : by default sorting is enabled on all columns. With this + * option it is possible to disable sorting on specific columns. + * This is an array of the form : array(fieldName, ...). + * This option only affects drivers that support sorting. + * - encoding : the content encoding. If the mbstring extension is + * present the default value is set from + * mb_internal_encoding(), otherwise it is ISO-8859-1 + * - extraVars : variables to be added to the generated HTTP queries + * - excludeVars : variables to be removed to the generated HTTP queries + * + * --- DRIVER INTERFACE --- + * + * Methods (none required) : + * - Constructor + * - setContainer() + * - getContainer() + * - init() + * - defaultCellFormatter() + * - buildHeader() + * - buildBody() + * - buildFooter() + * - finalize() + * - flatten() + * - render() + * + * Properties (read-only) : + * - $_columns + * - $_records + * - $_columnsNum + * - $_recordsNum + * - $_totalRecordsNum + * - $_currentSort + * - $_page + * - $_pageLimit + * - $_requestPrefix + * - $_sortableFields + * - $_options + * + * Options that drivers should handle : + * - encoding + * - fillWithEmptyRows + * - numberAlign + * + * @version $Revision: 1.31 $ + * @author Olivier Guilyardi <olivier@samalyse.com> + * @access public + * @package Structures_DataGrid + * @category Structures + * @abstract + */ +class Structures_DataGrid_Renderer +{ + /** + * Columns' fields names and labels + * + * Drivers can read the content of this property but must not change it. + * + * @var array Structure: + * array(<columnIndex> => array(field => <fieldName>, + * label=> <label>), ...) + * Where <columnIndex> is zero-based + * @access protected + */ + var $_columns = array(); + + /** + * Records content + * + * Drivers can read the content of this property but must not change it. + * + * @var array Structure: + * array( + * <rowIndex> => array( + * <columnIndex> => array (<cellValue>, ...), + * ...), + * ...) + * Where <rowIndex> and <columnIndex> are zero-based + * @access protected + */ + var $_records = array(); + + /** + * Fields/directions the data is currently sorted by + * + * Drivers can read the content of this property but must not change it. + * + * @var array Structure: array (fieldName => direction, ....) + * @access protected + */ + var $_currentSort = array(); + + /** + * Number of columns + * @var int + * @access protected + */ + var $_columnsNum; + + /** + * Number of records in the current page + * + * Drivers can read the content of this property but must not change it. + * + * @var int + * @access protected + */ + var $_recordsNum; + + /** + * Total number of records as reported by the datasource + * + * Drivers can read the content of this property but must not change it. + * + * @var int + * @access protected + */ + var $_totalRecordsNum; + + /** + * Current page + * + * Drivers can read the content of this property but must not change it. + * + * @var int + * @access protected + */ + var $_page = 1; + + /** + * Number of records per page + * + * Drivers can read the content of this property but must not change it. + * + * @var int + * @access protected + */ + var $_pageLimit = null; + + /** + * GET/POST/Cookie parameters prefix + * + * Drivers can read the content of this property but must not change it. + * + * @var string + * @access protected + */ + var $_requestPrefix = ''; + + /** + * Which fields the datagrid may be sorted by + * + * Drivers can read the content of this property but must not change it. + * + * @var array Field names + * @access protected + */ + var $_sortableFields = array(); + + /** + * Common and driver-specific options + * + * Drivers can read the content of this property but must not change it. + * + * @var array + * @access protected + * @see Structures_DataGrid_Renderer::setOption() + * @see Structures_DataGrid_Renderer::_addDefaultOptions() + */ + var $_options = array(); + + /** + * Columns objects + * + * Beware : this is a private property, it is not meant to be accessed + * by drivers. Use the $_columns property instead + * + * @var array + * @access private + * @see Structures_DataGrid_Renderer::_columns + */ + var $_columnObjects = array(); + + /** + * Whether the datagrid has been built or not + * @var bool + * @access private + * @see Structures_DataGrid_Renderer::isBuilt() + */ + var $_isBuilt = false; + + /** + * Cache for the GET parameters that are common to all sorting http queries + * + * @var array + * @access private + * @see Structures_DataGrid_Renderer::buildSortingHttpQuery() + */ + var $_sortingHttpQueryCommon = null; + + /** + * Instantiate the driver and set default options and features + * + * Drivers may overload this method in order to change/add default options. + * + * @access public + * @see Structures_DataGrid_Renderer::_addDefaultOptions() + */ + function Structures_DataGrid_Renderer() + { + $this->_options = array( + + /* Options that the drivers may/should handle */ + 'encoding' => function_exists('mb_internal_encoding') + ? mb_internal_encoding() : 'ISO-8859-1', + 'fillWithEmptyRows' => false, + 'numberAlign' => true, + 'extraVars' => array(), + 'excludeVars' => array(), + + /* Options that must not be accessed by drivers */ + 'buildHeader' => true, + 'buildFooter' => true, + 'defaultCellValue' => null, + 'defaultColumnValues' => array(), + 'disableColumnSorting' => array(), + + ); + + } + + /** + * Adds some default options. + * + * This method is meant to be called by drivers. It allows adding some + * default options. + * + * @access protected + * @param array $options An associative array of the from: + * array(optionName => optionValue, ...) + * @return void + * @see Structures_DataGrid_Renderer::setOption() + */ + function _addDefaultOptions($options) + { + $this->_options = array_merge($this->_options, $options); + } + + /** + * Set options + * + * @param mixed $options An associative array of the form : + * array("option_name" => "option_value",...) + * @access public + */ + function setOptions($options) + { + $this->_options = array_merge($this->_options, $options); + } + + /** + * 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 + * + * @var array + * @param array $spec Form: array (fieldName => direction, ....) + * @access public + */ + function setCurrentSorting($spec) + { + $this->_currentSort = $spec; + } + + /** + * 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; + } + + /** + * Attach a container object + * + * Drivers that provide support for the Structures_DataGrid::fill() method + * must implement this method. + * + * @abstract + * @param object Container of the class supported by the driver + * @access public + * @return mixed True or PEAR_Error + */ + function setContainer(&$container) + { + return $this->_noSupport(__FUNCTION__); + } + + /** + * Return the container used by the driver + * + * Drivers should implement this method when they have some kind of support + * for rendering containers. + * + * @abstract + * @return object Container of the class supported by the driver + * or PEAR_Error + * @access public + */ + function &getContainer() + { + return $this->_noSupport(__FUNCTION__); + } + + /** + * Create or/and prepare the container + * + * Drivers may optionally 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 should also be done. + * + * @abstract + * @access protected + */ + function init() + { + } + + /** + * Build the header + * + * Drivers may optionally implement this method. + * + * @abstract + * + * @param array $columns Columns' fields names and labels (This is a + * convenient reference to the $_columns protected + * property) + * @access protected + * @return void + */ + function buildHeader(&$columns) + { + } + + /** + * Build the body + * + * Drivers may overload() this method, if buildRow() and buildEmptyRow() + * are not flexible enough. + * + * @access protected + * @return void + */ + function buildBody() + { + for ($row = 0; $row < $this->_recordsNum; $row++) { + $this->buildRow($row,$this->_records[$row]); + } + + if ($this->_options['fillWithEmptyRows'] && !is_null($this->_pageLimit)) { + for ($row = $this->_recordsNum; $row < $this->_pageLimit; $row++) { + $this->buildEmptyRow($row); + } + } + } + + /** + * Build a body row + * + * This is a very simple method for drivers to build a row. + * For more flexibility, drivers should overload buildBody() + * + * @param int $index Row index (zero-based) + * @param array $data Record data. + * Structure: array(0 => <value0>, 1 => <value1>, ...) + * @return void + * @access protected + * @abstract + */ + function buildRow($index,$data) + { + } + + /** + * Build an empty row + * + * Drivers must overload this method if they need to do something with + * empty rows that remain at the end of the body. + * + * This method will only be called if the "fillWithEmptyRows" option is + * enabled. + * + * @param int $index Row index (zero-based) + * @return void + * @access protected + * @abstract + */ + function buildEmptyRow($index) + { + } + + /** + * 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 may optionally implement this method. + * + * This method is meant to retrieve final output from the container. + * + * Usually the container is an object (ex: HTMLTable instance), + * and the final output a string. + * + * The driver knows how to retrieve such final output from a given + * container (ex: HTMLTable::toHTML()), and this is where to do it. + * + * Sometimes the container may not be an object, but the final output + * itself. In this case, this method should simply return the container. + * + * This method mustn't output anything directly to the standard output. + * + * @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 + * + * Drivers must not overload this method. Pre and post-build operations + * can be performed in init() and finalize() + * + * @access public + * @return void + */ + function build() + { + $this->_columns = array(); + foreach ($this->_columnObjects as $index => $column) + { + if (!is_null($column->orderBy)) { + $field = $column->orderBy; + if (!in_array($field,$this->_sortableFields) and + !in_array($field, $this->_options['disableColumnSorting']) + ) { + $this->_sortableFields[] = $field; + } + } else if (!is_null($column->fieldName)) { + $field = $column->fieldName; + } else { + $field = $column->columnName; + } + + $label = $column->columnName; + + if (isset($this->_options['defaultColumnValues'][$field])) { + $column->setAutoFillValue($this->_options['defaultColumnValues'][$field]); + } else if (!is_null($this->_options['defaultCellValue'])) { + $column->setAutoFillValue($this->_options['defaultCellValue']); + } + + if (isset($column->attribs) && + strtolower(get_class($this)) == 'structures_datagrid_renderer_htmltable') + { + if (!array_key_exists($field, $this->_options['columnAttributes'])) { + $this->_options['columnAttributes'][$field] = array(); + } + $this->_options['columnAttributes'][$field] = + array_merge($this->_options['columnAttributes'][$field], + $column->attribs); + } + + $this->_columns[$index] = compact('field','label'); + } + + $this->_columnsNum = count($this->_columns); + $this->_recordsNum = count($this->_records); + + $this->init(); + + if (is_null($this->_pageLimit)) { + $this->_pageLimit = $this->_recordsNum; + } + + for ($rec = 0; $rec < $this->_recordsNum; $rec++) { + $content = array(); + foreach ($this->_columnObjects as $column) { + $content[] = $this->recordToCell($column, $this->_records[$rec]); + } + $this->_records[$rec] = $content; + } + + if ($this->_options['buildHeader']) { + $this->buildHeader($this->_columns); + } + + $this->buildBody(); + + if ($this->_options['buildFooter']) { + $this->buildFooter(); + } + + $this->finalize(); + + $this->_isBuilt = true; + } + + /** + * Returns the output from the renderer (e.g. HTML table, XLS object, ...) + * + * Drivers must not overload this method. Output generation has to be + * implemented in flatten(). + * + * @access public + * @return mixed The output from the renderer + */ + function getOutput() + { + if ($this->_isImplemented('flatten')) { + $this->_isBuilt or $this->build(); + return $this->flatten(); + } else { + return $this->_noSupport(__FUNCTION__); + } + } + + /** + * Render to the standard output + * + * This method may be overloaded by renderer drivers in order to prepare + * writing to the standard output (like calling header(), etc...). + * + * @access public + * @return mixed True or a PEAR_Error + */ + function render() + { + if ($this->_isImplemented('flatten')) { + $this->_isBuilt or $this->build(); + echo $this->flatten(); + } else { + $this->build(); + } + } + + /** + * Return an error related to an unsupported public method + * + * When a given public method is not implemented/supported by the driver + * it must return a PEAR_Error object with code DATAGRID_ERROR_UNSUPPORTED. + * This is a helper method for generating such PEAR_Error objects. + * + * Example: + * + * <code> + * function anUnsupportedMethod() + * { + * return $this->_noSupport(__FUNCTION__); + * } + * </code> + * + * @param string $method The name of the unsupported method + * @return object PEAR_Error with code DATAGRID_ERROR_UNSUPPORTED + * @access protected + */ + function _noSupport($method) + { + return new PEAR_Error("The renderer driver class \"" .get_class($this). + "\" does not support the $method() method", + DATAGRID_ERROR_UNSUPPORTED); + } + + /** + * Sets the rendered status. This can be used to "flush the cache" in case + * you need to render the datagrid twice with the second time having changes + * + * This is quite an obsolete method... + * + * @access public + * @param bool $status The rendered status of the DataGrid + */ + function setRendered($status = false) + { + if (!$status) { + $this->_isBuilt = false; + } + /* What are we supposed to do with $status = true ? */ + } + + /** + * Set the HTTP Request prefix + * + * @param string $prefix The prefix string + * @return void + * @access 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 = ''; + if (isset($column->formatter) and !empty($column->formatter)) { + $value = $column->formatter($record); + } else if (isset($column->fieldName) and isset($record[$column->fieldName])) { + $value = $this->defaultCellFormatter($record[$column->fieldName]); + } + + if (empty($value) and !is_null($column->autoFillValue)) { + $value = $column->autoFillValue; + } + + return $value; + } + + /** + * Query the grid build status + * + * @return bool Whether the grid has already been built or not + * @access public + */ + function isBuilt() + { + return $this->_isBuilt; + } + + /** + * Build an HTTP query for sorting a given column + * + * This is a handy method that most drivers can use in order to build + * the HTTP queries that are used to sort columns. + * + * It takes the global "extraVars", "excludeVars" options as well as the + * $_requestPrefix property into account and can also convert the ampersand + * to XML/HTML entities according to the "encoding" option. + * + * @param $field Sort field name + * @param $direciton Sort direction + * @param $convertAmpersand Whether to convert ampersands to XML/HTML + * compliant entities + * @param $extraParameters Optional extra HTTP parameters + * @return string Query string of the + * @access protected + * + */ + function _buildSortingHttpQuery($field, $direction, $convertAmpersand = false, + $extraParameters = array()) + { + $prefix = $this->_requestPrefix; + + if (is_null($this->_sortingHttpQueryCommon)) { + // Build and cache the list of common get parameters + $this->_sortingHttpQueryCommon = $this->_options['extraVars']; + $ignore = $this->_options['excludeVars']; + $ignore[] = $prefix . 'orderBy'; + $ignore[] = $prefix . 'direction'; + foreach ($extraParameters as $var => $value) { + $ignore[] = $prefix . $var; + } + foreach ($_GET as $key => $val) { + if (!in_array ($key, $ignore)) { + $this->_sortingHttpQueryCommon[$key] = $val; + } + } + } + + // Build list of GET variables + $get = array(); + $get[$prefix . 'orderBy'] = $field; + $get[$prefix . 'direction'] = $direction; + foreach ($extraParameters as $var => $value) { + $get[$prefix . $var] = $value; + } + + // Merge common and column-specific GET variables + $get = array_merge($this->_sortingHttpQueryCommon, $get); + + // Build query + if ($convertAmpersand and ini_get('arg_separator.output') == '&') { + $query = htmlentities(http_build_query($get),ENT_QUOTES, + $this->_options['encoding']); + } else { + $query = http_build_query($get); + } + + return $query; + } + + /** + * Detect whether a method is implemented a child class + * + * This method is able to detect if a given method is implemented in the + * driver (child class) even if it is declared in the root class. + * + * @param $method Method name + * @param $class The class to scan (Internal use) + * @return bool + * @access protected + */ + function _isImplemented($method, $class = null) + { + if (is_null($class)) { + $class = get_class($this); + } + + $parent = get_parent_class ($class); + + if (!$parent) { + return false; + } else { + $methods = get_class_methods($class); + if (in_array ($method, $methods)) { + return true; + } else { + return $this->_isImplemented($method, $parent); + } + } + } + +} + +?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/Array.php?r1=1.18&r2=1.19&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/Array.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/Array.php:1.18 pear/Structures_DataGrid/DataGrid/DataSource/Array.php:1.19 --- pear/Structures_DataGrid/DataGrid/DataSource/Array.php:1.18 Wed Feb 15 20:49:07 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/Array.php Thu Mar 16 12:37:20 2006 @@ -17,16 +17,16 @@ // | Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: Array.php,v 1.18 2006/02/15 20:49:07 wiesemann Exp $ +// $Id: Array.php,v 1.19 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** * Array Data Source Driver * * This class is a data source driver for a 2D Array * - * @version $Revision: 1.18 $ + * @version $Revision: 1.19 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @author Andrew Nagy <asnagy@webitecture.org> * @access public @@ -34,7 +34,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_Array - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * The array @@ -46,7 +46,7 @@ function Structures_DataGrid_DataSource_Array() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); } /** @@ -149,4 +149,4 @@ } } -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php?r1=1.4&r2=1.5&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php:1.4 pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php:1.5 --- pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php:1.4 Sat Jan 14 13:34:05 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php Thu Mar 16 12:37:20 2006 @@ -17,10 +17,10 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DBQuery.php,v 1.4 2006/01/14 13:34:05 wiesemann Exp $ +// $Id: DBQuery.php,v 1.5 2006/03/16 12:37:20 olivierg Exp $ require_once 'DB.php'; -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** @@ -28,7 +28,7 @@ * * This class is a data source driver for the PEAR::DB object * - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ * @author Andrew S. Nagy <asnagy@php.net> * @author Mark Wiesemann <wiesemann@php.net> * @access public @@ -36,7 +36,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_DBQuery - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * Reference to the PEAR::DB object @@ -77,7 +77,7 @@ */ function Structures_DataGrid_DataSource_DBQuery() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); } /** http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php?r1=1.5&r2=1.6&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.5 pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.6 --- pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.5 Wed Dec 21 11:10:13 2005 +++ pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php Thu Mar 16 12:37:20 2006 @@ -17,16 +17,16 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DBTable.php,v 1.5 2005/12/21 11:10:13 wiesemann Exp $ +// $Id: DBTable.php,v 1.6 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** * PEAR::DB_Table Data Source Driver * * This class is a data source driver for the PEAR::DB_Table object * -* @version $Revision: 1.5 $ +* @version $Revision: 1.6 $ * @author Andrew S. Nagy <asnagy@php.net> * @author Mark Wiesemann <wiesemann@php.net> * @access public @@ -34,7 +34,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_DBTable - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * Reference to the Result object returned by DB_Table @@ -75,7 +75,7 @@ */ function Structures_DataGrid_DataSource_DBTable() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); $this->_addDefaultOptions(array('where' => null)); } @@ -186,4 +186,4 @@ } -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php?r1=1.26&r2=1.27&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.26 pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.27 --- pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.26 Thu Mar 16 01:05:52 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php Thu Mar 16 12:37:20 2006 @@ -17,9 +17,9 @@ // | Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: DataObject.php,v 1.26 2006/03/16 01:05:52 olivierg Exp $ +// $Id: DataObject.php,v 1.27 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** * PEAR::DB_DataObject Data Source Driver @@ -38,7 +38,7 @@ * same kind of information as the "fields" options. If the "fields" * option is set, this one will not be used. Default : "fb_fieldsToRender". * - * @version $Revision: 1.26 $ + * @version $Revision: 1.27 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @author Andrew Nagy <asnagy@webitecture.org> * @access public @@ -46,7 +46,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_DataObject - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * Reference to the DataObject @@ -75,7 +75,7 @@ */ function Structures_DataGrid_DataSource_DataObject() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); $this->_addDefaultOptions(array( 'use_private_vars' => false, http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php:1.1 pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php:1.2 --- pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php:1.1 Sat Jan 14 13:34:46 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php Thu Mar 16 12:37:20 2006 @@ -17,10 +17,10 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: MDB2.php,v 1.1 2006/01/14 13:34:46 wiesemann Exp $ +// $Id: MDB2.php,v 1.2 2006/03/16 12:37:20 olivierg Exp $ require_once 'MDB2.php'; -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** @@ -28,7 +28,7 @@ * * This class is a data source driver for the PEAR::MDB2 object * - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @author Andrew S. Nagy <asnagy@php.net> * @author Mark Wiesemann <wiesemann@php.net> * @access public @@ -36,7 +36,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_MDB2 - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * Reference to the PEAR::MDB2 object @@ -77,7 +77,7 @@ */ function Structures_DataGrid_DataSource_MDB2() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); } /** http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Record/DataObject.php?r1=1.10&r2=1.11&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Record/DataObject.php diff -u pear/Structures_DataGrid/DataGrid/Record/DataObject.php:1.10 pear/Structures_DataGrid/DataGrid/Record/DataObject.php:1.11 --- pear/Structures_DataGrid/DataGrid/Record/DataObject.php:1.10 Mon Jan 10 15:17:34 2005 +++ pear/Structures_DataGrid/DataGrid/Record/DataObject.php Thu Mar 16 12:37:20 2006 @@ -16,14 +16,14 @@ // | Author: Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: DataObject.php,v 1.10 2005/01/10 15:17:34 asnagy Exp $ +// $Id: DataObject.php,v 1.11 2006/03/16 12:37:20 olivierg Exp $ require_once 'Structures/DataGrid/Record.php'; /** * Structures_DataGrid_Record_DataObject Class * - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @access public * @package Structures_DataGrid @@ -49,7 +49,7 @@ function setRecord($data) { - if (strtolower(is_subclass_of($data, 'db_dataobject'))) { + if (is_subclass_of($data, 'db_dataobject')) { parent::setRecord($data->toArray()); } else { return new PEAR_Error('Invalid data type. ' . http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/CSV.php?r1=1.12&r2=1.13&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/CSV.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/CSV.php:1.12 pear/Structures_DataGrid/DataGrid/Renderer/CSV.php:1.13 --- pear/Structures_DataGrid/DataGrid/Renderer/CSV.php:1.12 Tue Feb 28 10:53:25 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/CSV.php Thu Mar 16 12:37:20 2006 @@ -18,9 +18,9 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: CSV.php,v 1.12 2006/02/28 10:53:25 wiesemann Exp $ +// $Id: CSV.php,v 1.13 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; /** * Structures_DataGrid_Renderer_CSV Class @@ -34,7 +34,7 @@ * - useQuotes: (bool) Whether or not to encapuslate the values with quotes * (default: false) * - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -42,7 +42,7 @@ * @package Structures_DataGrid * @category Structures */ -class Structures_DataGrid_Renderer_CSV extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_CSV extends Structures_DataGrid_Renderer { /** @@ -54,7 +54,7 @@ */ function Structures_DataGrid_Renderer_CSV() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'delimiter' => ',', http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/Console.php?r1=1.6&r2=1.7&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/Console.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.6 pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.7 --- pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.6 Mon Mar 13 17:33:36 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/Console.php Thu Mar 16 12:37:20 2006 @@ -18,15 +18,15 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Console.php,v 1.6 2006/03/13 17:33:36 wiesemann Exp $ +// $Id: Console.php,v 1.7 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; require_once 'Console/Table.php'; /** * Structures_DataGrid_Renderer_Console Class * - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -34,7 +34,7 @@ * @package Structures_DataGrid * @category Structures */ -class Structures_DataGrid_Renderer_Console extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_Console extends Structures_DataGrid_Renderer { /** @@ -46,7 +46,7 @@ */ function Structures_DataGrid_Renderer_Console() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); } /** http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php?r1=1.93&r2=1.94&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.93 pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.94 --- pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.93 Thu Mar 16 12:23:57 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php Thu Mar 16 12:37:20 2006 @@ -18,9 +18,9 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: HTMLTable.php,v 1.93 2006/03/16 12:23:57 olivierg Exp $ +// $Id: HTMLTable.php,v 1.94 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; require_once 'HTML/Table.php'; /** @@ -51,7 +51,7 @@ * - sortingResetsPaging: whether sorting HTTP queries reset paging * (default : true) * - * @version $Revision: 1.93 $ + * @version $Revision: 1.94 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -59,7 +59,7 @@ * @package Structures_DataGrid * @category Structures */ -class Structures_DataGrid_Renderer_HTMLTable extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_HTMLTable extends Structures_DataGrid_Renderer { /** * Rendering container @@ -101,7 +101,7 @@ */ function Structures_DataGrid_Renderer_HTMLTable() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'evenRowAttributes' => array(), http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/XLS.php?r1=1.26&r2=1.27&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/XLS.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.26 pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.27 --- pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.26 Sat Feb 25 09:58:45 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/XLS.php Thu Mar 16 12:37:20 2006 @@ -18,9 +18,9 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: XLS.php,v 1.26 2006/02/25 09:58:45 wiesemann Exp $ +// $Id: XLS.php,v 1.27 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; require_once 'Spreadsheet/Excel/Writer.php'; /** @@ -40,7 +40,7 @@ * (true = send to browser, false = write to a file) * (default: true) * - * @version $Revision: 1.26 $ + * @version $Revision: 1.27 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -48,7 +48,7 @@ * @package Structures_DataGrid * @category Structures */ -class Structures_DataGrid_Renderer_XLS extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_XLS extends Structures_DataGrid_Renderer { // FIXME: refactoring incomplete // FIXME: remove $_workbook, use $_container (?) @@ -75,7 +75,7 @@ */ function Structures_DataGrid_Renderer_XLS() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'headerFormat' => 0, http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/XML.php?r1=1.21&r2=1.22&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/XML.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/XML.php:1.21 pear/Structures_DataGrid/DataGrid/Renderer/XML.php:1.22 --- pear/Structures_DataGrid/DataGrid/Renderer/XML.php:1.21 Tue Feb 28 11:02:10 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/XML.php Thu Mar 16 12:37:20 2006 @@ -18,15 +18,15 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: XML.php,v 1.21 2006/02/28 11:02:10 wiesemann Exp $ +// $Id: XML.php,v 1.22 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; require_once 'XML/Util.php'; /** * Structures_DataGrid_Renderer_XML Class * - * @version $Revision: 1.21 $ + * @version $Revision: 1.22 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -41,7 +41,7 @@ * - rowTag: (string) The name of the tag for each row (without brackets) * (default: 'Row') */ -class Structures_DataGrid_Renderer_XML extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_XML extends Structures_DataGrid_Renderer { /** @@ -53,7 +53,7 @@ */ function Structures_DataGrid_Renderer_XML() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'outerTag' => 'DataGrid', http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/XUL.php?r1=1.19&r2=1.20&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/XUL.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/XUL.php:1.19 pear/Structures_DataGrid/DataGrid/Renderer/XUL.php:1.20 --- pear/Structures_DataGrid/DataGrid/Renderer/XUL.php:1.19 Thu Mar 16 01:05:52 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/XUL.php Thu Mar 16 12:37:20 2006 @@ -18,9 +18,9 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: XUL.php,v 1.19 2006/03/16 01:05:52 olivierg Exp $ +// $Id: XUL.php,v 1.20 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; //require_once 'XML/XUL.php'; require_once 'XML/Util.php'; @@ -61,7 +61,7 @@ * - selfPath: (string) The complete path for sorting and paging links * (default: $_SERVER['PHP_SELF']) * - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -70,7 +70,7 @@ * @category Structures * @todo Implement PEAR::XML_XUL upon maturity */ -class Structures_DataGrid_Renderer_XUL extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_XUL extends Structures_DataGrid_Renderer { /** * The generated XUL data @@ -88,7 +88,7 @@ */ function Structures_DataGrid_Renderer_XUL() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'selfPath' => $_SERVER['PHP_SELF']
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource.php?r1=1.13&r2=1.14&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource.php diff -u /dev/null pear/Structures_DataGrid/DataGrid/DataSource.php:1.14 --- /dev/null Thu Mar 16 12:37:20 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource.php Thu Mar 16 12:37:20 2006 @@ -0,0 +1,381 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2005 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.0 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Olivier Guilyardi <olivier@samalyse.com> | +// | Andrew Nagy <asnagy@webitecture.org> | +// +----------------------------------------------------------------------+ +// +// $Id: DataSource.php,v 1.14 2006/03/16 12:37:20 olivierg Exp $ + + +/** +* Base abstract class for data source drivers +* +* <b>Recognized options (valid for all drivers) :</b> +* +* <b>"generate_columns" </b> Generate +* Structures_DataGrid_Column objects with labels. (default : false) +* +* <b>"labels" : </b> How to translate the field names to column labels. +* Only used when "generate_columns" is true. Default : array(). +* This is an associative array of the form : +* <code> +* array ("fieldName" => "fieldLabel", ...) +* </code> +* +* <b>"fields" : </b> Which fields should be rendered (Only used when +* "generate_columns" is true. The default is an empty array : all of +* the DataObject's fields will be rendered. +* This is an array of the form : +* <code> +* array ("fieldName1", "fieldName2", ...) +* </code> +* +* Users may want to see the create() factory method +* +* Developers : +* +* <b>HOWTO develop a new source driver</b> +* +* Subclass this Structures_DataGrid_DataSource class : +* <code> +* class Structures_DataGrid_DataSource_Foo extends +* Structures_DataGrid_DataSource +* </code> +* +* In the constructor, initialize default options . These defaults will be +* used to validate user provided options, so you need to set all possible +* ones +* <code> +* function Structures_DataGrid_DataSource_Foo() +* { +* parent::Structures_DataGrid_DataSource(); // required +* $this->_addDefaultOptions(array( 'bar' => true)); +* } +* </code> +* +* Expose the fetch(), count() and bind() methods, overloading +* the provided skeleton. See the corresponding prototypes +* for more information on how to do this. +* +* Do not forget to call Structures_DataGrid_DataSource::setOptions() +* from your bind() method. +* ex : if ($options) $this->setOptions($options); +* +* Eventually, use the dump() debugging method to test your brand new +* driver +* +* @author Olivier Guilyardi <olivier@samalyse.com> +* @author Andrew Nagy <asnagy@webitecture.org> +* @author Mark Wiesemann <wiesemann@php.net> +* @package Structures_DataGrid +* @category Structures +* @version $Revision $ +*/ +class Structures_DataGrid_DataSource +{ + /* FIXME: Did we really need to rename this class from DataSource to + * DataSource_Common ? IIRC we did this to mimic the MDB2 internals, + * which is pointless. There are some good practices in MDB2, that + * we have tried to implement in the Renderer layer. But the "Common" + * suffix is convention that we do not need to follow. + * + * It will break BC for no reason. for people who have written their own + * drivers by subclassing the old DataSource class. + * + * This is fixed... + */ + + /** + * Common and driver-specific options + * + * @var array + * @access protected + * @see Structures_DataGrid_DataSource::_setOption() + * @see Structures_DataGrid_DataSource::addDefaultOptions() + */ + var $_options = array(); + + /** + * Special driver features + * + * @var array + * @access protected + */ + var $_features = array(); + + /** + * Constructor + * + */ + function Structures_DataGrid_DataSource() + { + $this->_options = array('generate_columns' => false, + 'labels' => array(), + 'fields' => array()); + + $this->_features = array( + 'multiSort' => false, // Multiple field sorting + ); + } + + /** + * Adds some default options. + * + * This method is meant to be called by drivers. It allows adding some + * default options. + * + * @access protected + * @param array $options An associative array of the form: + * array(optionName => optionValue, ...) + * @return void + * @see Structures_DataGrid_DataSource::_setOption + */ + function _addDefaultOptions($options) + { + $this->_options = array_merge($this->_options, $options); + } + + /** + * Add special driver features + * + * This method is meant to be called by drivers. It allows specifying + * the special features that are supported by the current driver. + * + * @access protected + * @param array $features An associative array of the form: + * array(feature => true|false, ...) + * @return void + */ + function _setFeatures($features) + { + $this->_features = array_merge($this->_features, $features); + } + + /** + * Set options + * + * @param mixed $options An associative array of the form : + * array("option_name" => "option_value",...) + * @access protected + */ + function setOptions($options) + { + $this->_options = array_merge($this->_options, $options); + } + + /** + * Generate columns if options are properly set + * + * Note : must be called after fetch() + * + * @access public + * @return array Array of Column objects. Empty array if irrelevant. + */ + function getColumns() + { + $columns = array(); + if ($this->_options['generate_columns'] + and $fieldList = $this->_options['fields']) { + + include_once('Structures/DataGrid/Column.php'); + + foreach ($fieldList as $field) { + $label = strtr($field, $this->_options['labels']); + $col = new Structures_DataGrid_Column($label, $field, $field); + $columns[] = $col; + } + } + + return $columns; + } + + + // Begin driver method prototypes DocBook template + + /**#@+ + * + * This method is public, but please note that it is not intended to be + * called by user-space code. It is meant to be called by the main + * Structures_DataGrid class. + * + * It is an abstract method, part of the DataGrid Datasource driver + * interface, and must overloaded by drivers. + */ + + /** + * Fetching method prototype + * + * When overloaded this method must return a 2D array of records + * on success or a PEAR_Error object on failure. + * + * @abstract + * @param integer $offset Limit offset (starting from 0) + * @param integer $len Limit length + * @param string $sortSpec If the driver supports the "multiSort" + * feature this can be either a single field + * (string), or a sort specification array of + * the form : array(field => direction, ...) + * If "multiSort" is not supported, then this + * can only be a string. + * @param string $sortDir Sort direction : 'ASC' or 'DESC' + * @return object PEAR_Error with message + * "No data source driver loaded" + * @access public + */ + function &fetch($offset=0, $len=null, $sortSpec=null, $sortDir='ASC') + /* FIXME: Why is there these $sortField and $sortDir parameters ? This + * is redundant with the sort() method. + */ + { + return new PEAR_Error("No data source driver loaded"); + } + + /** + * Counting method prototype + * + * Note : must be called before fetch() + * + * When overloaded, this method must return the total number or records + * or a PEAR_Error object on failure + * + * @abstract + * @return object PEAR_Error with message + * "No data source driver loaded" + * @access public + */ + function count() + { + return new PEAR_Error("No data source driver loaded"); + } + + /** + * Sorting method prototype + * + * When overloaded this method must return true on success or a PEAR_Error + * object on failure. + * + * Note : must be called before fetch() + * + * @abstract + * @param string $sortSpec If the driver supports the "multiSort" + * feature this can be either a single field + * (string), or a sort specification array of + * the form : array(field => direction, ...) + * If "multiSort" is not supported, then this + * can only be a string. + * @param string $sortDir Sort direction : 'ASC' or 'DESC' + * @return object PEAR_Error with message + * "No data source driver loaded" + * @access public + */ + function sort($sortSpec, $sortDir = null) + { + return new PEAR_Error("No data source driver loaded"); + } + + /** + * Datasource binding method prototype + * + * When overloaded this method must return true on success or a PEAR_Error + * object on failure. + * + * @abstract + * @param mixed $container The datasource container + * @param array $options Binding options + * @return object PEAR_Error with message + * "No data source driver loaded" + * @access public + */ + function bind($container, $options = array()) + { + return new PEAR_Error("No data source driver loaded"); + } + + /**#@-*/ + + // End DocBook template + + /** + * List special driver features + * + * @return array Of the form: array(feature => true|false, etc...) + * @access public + */ + function getFeatures() + { + return $this->_features; + } + + /** + * Tell if the driver as a specific feature + * + * @param string $name Feature name + * @return bool + * @access public + */ + function hasFeature($name) + { + } + + /** + * Dump the data as returned by fetch(). + * + * This method is meant for debugging purposes. It returns what fetch() + * would return to its DataGrid host as a nicely formatted console-style + * table. + * + * @param integer $offset Limit offset (starting from 0) + * @param integer $len Limit length + * @param string $sortField Field to sort by + * @param string $sortDir Sort direction : 'ASC' or 'DESC' + * @return string The table string, ready to be printed + * @uses Structures_DataGrid_DataSource::fetch() + * @access public + */ + function dump($offset=0, $len=null, $sortField=null, $sortDir='ASC') + { + $records =& $this->fetch($offset, $len, $sortField, $sortDir); + $columns = $this->getColumns(); + + if (!$columns and !$records) { + return "<Empty set>\n"; + } + + include_once 'Console/Table.php'; + $table = new Console_Table(); + + $headers = array(); + if ($columns) { + foreach ($columns as $col) { + $headers[] = is_null($col->fieldName) + ? $col->columnName + : "{$col->columnName} ({$col->fieldName})"; + } + } else { + $headers = array_keys($records[0]); + } + + $table->setHeaders($headers); + + foreach ($records as $rec) { + $table->addRow($rec); + } + + return $table->getTable(); + } + +} +?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer.php?r1=1.30&r2=1.31&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer.php diff -u /dev/null pear/Structures_DataGrid/DataGrid/Renderer.php:1.31 --- /dev/null Thu Mar 16 12:37:20 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer.php Thu Mar 16 12:37:20 2006 @@ -0,0 +1,829 @@ +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2005 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.0 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Andrew Nagy <asnagy@webitecture.org> | +// | Olivier Guilyardi <olivier@samalyse.com> | +// +----------------------------------------------------------------------+ +// +// $Id: Renderer.php,v 1.31 2006/03/16 12:37:20 olivierg Exp $ + +require_once 'PHP/Compat/Function/http_build_query.php'; + +/** + * Base class of all Renderer drivers + * + * Recognized options : + * + * - buildHeader : whether to build the header (default : true) + * - buildFooter : whether to build the footer (default : true) + * - fillWithEmptyRows : ensures that all pages have the same number of + * rows (default : false) + * - numberAlign : whether to right-align numeric values (default : true) + * - defaultCellValue : what value to put by default into empty cells + * - defaultColumnValues : per-column default cell value. This is an array + * of the form : array(fieldName => value, ...) + * - disableColumnSorting : by default sorting is enabled on all columns. With this + * option it is possible to disable sorting on specific columns. + * This is an array of the form : array(fieldName, ...). + * This option only affects drivers that support sorting. + * - encoding : the content encoding. If the mbstring extension is + * present the default value is set from + * mb_internal_encoding(), otherwise it is ISO-8859-1 + * - extraVars : variables to be added to the generated HTTP queries + * - excludeVars : variables to be removed to the generated HTTP queries + * + * --- DRIVER INTERFACE --- + * + * Methods (none required) : + * - Constructor + * - setContainer() + * - getContainer() + * - init() + * - defaultCellFormatter() + * - buildHeader() + * - buildBody() + * - buildFooter() + * - finalize() + * - flatten() + * - render() + * + * Properties (read-only) : + * - $_columns + * - $_records + * - $_columnsNum + * - $_recordsNum + * - $_totalRecordsNum + * - $_currentSort + * - $_page + * - $_pageLimit + * - $_requestPrefix + * - $_sortableFields + * - $_options + * + * Options that drivers should handle : + * - encoding + * - fillWithEmptyRows + * - numberAlign + * + * @version $Revision: 1.31 $ + * @author Olivier Guilyardi <olivier@samalyse.com> + * @access public + * @package Structures_DataGrid + * @category Structures + * @abstract + */ +class Structures_DataGrid_Renderer +{ + /** + * Columns' fields names and labels + * + * Drivers can read the content of this property but must not change it. + * + * @var array Structure: + * array(<columnIndex> => array(field => <fieldName>, + * label=> <label>), ...) + * Where <columnIndex> is zero-based + * @access protected + */ + var $_columns = array(); + + /** + * Records content + * + * Drivers can read the content of this property but must not change it. + * + * @var array Structure: + * array( + * <rowIndex> => array( + * <columnIndex> => array (<cellValue>, ...), + * ...), + * ...) + * Where <rowIndex> and <columnIndex> are zero-based + * @access protected + */ + var $_records = array(); + + /** + * Fields/directions the data is currently sorted by + * + * Drivers can read the content of this property but must not change it. + * + * @var array Structure: array (fieldName => direction, ....) + * @access protected + */ + var $_currentSort = array(); + + /** + * Number of columns + * @var int + * @access protected + */ + var $_columnsNum; + + /** + * Number of records in the current page + * + * Drivers can read the content of this property but must not change it. + * + * @var int + * @access protected + */ + var $_recordsNum; + + /** + * Total number of records as reported by the datasource + * + * Drivers can read the content of this property but must not change it. + * + * @var int + * @access protected + */ + var $_totalRecordsNum; + + /** + * Current page + * + * Drivers can read the content of this property but must not change it. + * + * @var int + * @access protected + */ + var $_page = 1; + + /** + * Number of records per page + * + * Drivers can read the content of this property but must not change it. + * + * @var int + * @access protected + */ + var $_pageLimit = null; + + /** + * GET/POST/Cookie parameters prefix + * + * Drivers can read the content of this property but must not change it. + * + * @var string + * @access protected + */ + var $_requestPrefix = ''; + + /** + * Which fields the datagrid may be sorted by + * + * Drivers can read the content of this property but must not change it. + * + * @var array Field names + * @access protected + */ + var $_sortableFields = array(); + + /** + * Common and driver-specific options + * + * Drivers can read the content of this property but must not change it. + * + * @var array + * @access protected + * @see Structures_DataGrid_Renderer::setOption() + * @see Structures_DataGrid_Renderer::_addDefaultOptions() + */ + var $_options = array(); + + /** + * Columns objects + * + * Beware : this is a private property, it is not meant to be accessed + * by drivers. Use the $_columns property instead + * + * @var array + * @access private + * @see Structures_DataGrid_Renderer::_columns + */ + var $_columnObjects = array(); + + /** + * Whether the datagrid has been built or not + * @var bool + * @access private + * @see Structures_DataGrid_Renderer::isBuilt() + */ + var $_isBuilt = false; + + /** + * Cache for the GET parameters that are common to all sorting http queries + * + * @var array + * @access private + * @see Structures_DataGrid_Renderer::buildSortingHttpQuery() + */ + var $_sortingHttpQueryCommon = null; + + /** + * Instantiate the driver and set default options and features + * + * Drivers may overload this method in order to change/add default options. + * + * @access public + * @see Structures_DataGrid_Renderer::_addDefaultOptions() + */ + function Structures_DataGrid_Renderer() + { + $this->_options = array( + + /* Options that the drivers may/should handle */ + 'encoding' => function_exists('mb_internal_encoding') + ? mb_internal_encoding() : 'ISO-8859-1', + 'fillWithEmptyRows' => false, + 'numberAlign' => true, + 'extraVars' => array(), + 'excludeVars' => array(), + + /* Options that must not be accessed by drivers */ + 'buildHeader' => true, + 'buildFooter' => true, + 'defaultCellValue' => null, + 'defaultColumnValues' => array(), + 'disableColumnSorting' => array(), + + ); + + } + + /** + * Adds some default options. + * + * This method is meant to be called by drivers. It allows adding some + * default options. + * + * @access protected + * @param array $options An associative array of the from: + * array(optionName => optionValue, ...) + * @return void + * @see Structures_DataGrid_Renderer::setOption() + */ + function _addDefaultOptions($options) + { + $this->_options = array_merge($this->_options, $options); + } + + /** + * Set options + * + * @param mixed $options An associative array of the form : + * array("option_name" => "option_value",...) + * @access public + */ + function setOptions($options) + { + $this->_options = array_merge($this->_options, $options); + } + + /** + * 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 + * + * @var array + * @param array $spec Form: array (fieldName => direction, ....) + * @access public + */ + function setCurrentSorting($spec) + { + $this->_currentSort = $spec; + } + + /** + * 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; + } + + /** + * Attach a container object + * + * Drivers that provide support for the Structures_DataGrid::fill() method + * must implement this method. + * + * @abstract + * @param object Container of the class supported by the driver + * @access public + * @return mixed True or PEAR_Error + */ + function setContainer(&$container) + { + return $this->_noSupport(__FUNCTION__); + } + + /** + * Return the container used by the driver + * + * Drivers should implement this method when they have some kind of support + * for rendering containers. + * + * @abstract + * @return object Container of the class supported by the driver + * or PEAR_Error + * @access public + */ + function &getContainer() + { + return $this->_noSupport(__FUNCTION__); + } + + /** + * Create or/and prepare the container + * + * Drivers may optionally 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 should also be done. + * + * @abstract + * @access protected + */ + function init() + { + } + + /** + * Build the header + * + * Drivers may optionally implement this method. + * + * @abstract + * + * @param array $columns Columns' fields names and labels (This is a + * convenient reference to the $_columns protected + * property) + * @access protected + * @return void + */ + function buildHeader(&$columns) + { + } + + /** + * Build the body + * + * Drivers may overload() this method, if buildRow() and buildEmptyRow() + * are not flexible enough. + * + * @access protected + * @return void + */ + function buildBody() + { + for ($row = 0; $row < $this->_recordsNum; $row++) { + $this->buildRow($row,$this->_records[$row]); + } + + if ($this->_options['fillWithEmptyRows'] && !is_null($this->_pageLimit)) { + for ($row = $this->_recordsNum; $row < $this->_pageLimit; $row++) { + $this->buildEmptyRow($row); + } + } + } + + /** + * Build a body row + * + * This is a very simple method for drivers to build a row. + * For more flexibility, drivers should overload buildBody() + * + * @param int $index Row index (zero-based) + * @param array $data Record data. + * Structure: array(0 => <value0>, 1 => <value1>, ...) + * @return void + * @access protected + * @abstract + */ + function buildRow($index,$data) + { + } + + /** + * Build an empty row + * + * Drivers must overload this method if they need to do something with + * empty rows that remain at the end of the body. + * + * This method will only be called if the "fillWithEmptyRows" option is + * enabled. + * + * @param int $index Row index (zero-based) + * @return void + * @access protected + * @abstract + */ + function buildEmptyRow($index) + { + } + + /** + * 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 may optionally implement this method. + * + * This method is meant to retrieve final output from the container. + * + * Usually the container is an object (ex: HTMLTable instance), + * and the final output a string. + * + * The driver knows how to retrieve such final output from a given + * container (ex: HTMLTable::toHTML()), and this is where to do it. + * + * Sometimes the container may not be an object, but the final output + * itself. In this case, this method should simply return the container. + * + * This method mustn't output anything directly to the standard output. + * + * @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 + * + * Drivers must not overload this method. Pre and post-build operations + * can be performed in init() and finalize() + * + * @access public + * @return void + */ + function build() + { + $this->_columns = array(); + foreach ($this->_columnObjects as $index => $column) + { + if (!is_null($column->orderBy)) { + $field = $column->orderBy; + if (!in_array($field,$this->_sortableFields) and + !in_array($field, $this->_options['disableColumnSorting']) + ) { + $this->_sortableFields[] = $field; + } + } else if (!is_null($column->fieldName)) { + $field = $column->fieldName; + } else { + $field = $column->columnName; + } + + $label = $column->columnName; + + if (isset($this->_options['defaultColumnValues'][$field])) { + $column->setAutoFillValue($this->_options['defaultColumnValues'][$field]); + } else if (!is_null($this->_options['defaultCellValue'])) { + $column->setAutoFillValue($this->_options['defaultCellValue']); + } + + if (isset($column->attribs) && + strtolower(get_class($this)) == 'structures_datagrid_renderer_htmltable') + { + if (!array_key_exists($field, $this->_options['columnAttributes'])) { + $this->_options['columnAttributes'][$field] = array(); + } + $this->_options['columnAttributes'][$field] = + array_merge($this->_options['columnAttributes'][$field], + $column->attribs); + } + + $this->_columns[$index] = compact('field','label'); + } + + $this->_columnsNum = count($this->_columns); + $this->_recordsNum = count($this->_records); + + $this->init(); + + if (is_null($this->_pageLimit)) { + $this->_pageLimit = $this->_recordsNum; + } + + for ($rec = 0; $rec < $this->_recordsNum; $rec++) { + $content = array(); + foreach ($this->_columnObjects as $column) { + $content[] = $this->recordToCell($column, $this->_records[$rec]); + } + $this->_records[$rec] = $content; + } + + if ($this->_options['buildHeader']) { + $this->buildHeader($this->_columns); + } + + $this->buildBody(); + + if ($this->_options['buildFooter']) { + $this->buildFooter(); + } + + $this->finalize(); + + $this->_isBuilt = true; + } + + /** + * Returns the output from the renderer (e.g. HTML table, XLS object, ...) + * + * Drivers must not overload this method. Output generation has to be + * implemented in flatten(). + * + * @access public + * @return mixed The output from the renderer + */ + function getOutput() + { + if ($this->_isImplemented('flatten')) { + $this->_isBuilt or $this->build(); + return $this->flatten(); + } else { + return $this->_noSupport(__FUNCTION__); + } + } + + /** + * Render to the standard output + * + * This method may be overloaded by renderer drivers in order to prepare + * writing to the standard output (like calling header(), etc...). + * + * @access public + * @return mixed True or a PEAR_Error + */ + function render() + { + if ($this->_isImplemented('flatten')) { + $this->_isBuilt or $this->build(); + echo $this->flatten(); + } else { + $this->build(); + } + } + + /** + * Return an error related to an unsupported public method + * + * When a given public method is not implemented/supported by the driver + * it must return a PEAR_Error object with code DATAGRID_ERROR_UNSUPPORTED. + * This is a helper method for generating such PEAR_Error objects. + * + * Example: + * + * <code> + * function anUnsupportedMethod() + * { + * return $this->_noSupport(__FUNCTION__); + * } + * </code> + * + * @param string $method The name of the unsupported method + * @return object PEAR_Error with code DATAGRID_ERROR_UNSUPPORTED + * @access protected + */ + function _noSupport($method) + { + return new PEAR_Error("The renderer driver class \"" .get_class($this). + "\" does not support the $method() method", + DATAGRID_ERROR_UNSUPPORTED); + } + + /** + * Sets the rendered status. This can be used to "flush the cache" in case + * you need to render the datagrid twice with the second time having changes + * + * This is quite an obsolete method... + * + * @access public + * @param bool $status The rendered status of the DataGrid + */ + function setRendered($status = false) + { + if (!$status) { + $this->_isBuilt = false; + } + /* What are we supposed to do with $status = true ? */ + } + + /** + * Set the HTTP Request prefix + * + * @param string $prefix The prefix string + * @return void + * @access 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 = ''; + if (isset($column->formatter) and !empty($column->formatter)) { + $value = $column->formatter($record); + } else if (isset($column->fieldName) and isset($record[$column->fieldName])) { + $value = $this->defaultCellFormatter($record[$column->fieldName]); + } + + if (empty($value) and !is_null($column->autoFillValue)) { + $value = $column->autoFillValue; + } + + return $value; + } + + /** + * Query the grid build status + * + * @return bool Whether the grid has already been built or not + * @access public + */ + function isBuilt() + { + return $this->_isBuilt; + } + + /** + * Build an HTTP query for sorting a given column + * + * This is a handy method that most drivers can use in order to build + * the HTTP queries that are used to sort columns. + * + * It takes the global "extraVars", "excludeVars" options as well as the + * $_requestPrefix property into account and can also convert the ampersand + * to XML/HTML entities according to the "encoding" option. + * + * @param $field Sort field name + * @param $direciton Sort direction + * @param $convertAmpersand Whether to convert ampersands to XML/HTML + * compliant entities + * @param $extraParameters Optional extra HTTP parameters + * @return string Query string of the + * @access protected + * + */ + function _buildSortingHttpQuery($field, $direction, $convertAmpersand = false, + $extraParameters = array()) + { + $prefix = $this->_requestPrefix; + + if (is_null($this->_sortingHttpQueryCommon)) { + // Build and cache the list of common get parameters + $this->_sortingHttpQueryCommon = $this->_options['extraVars']; + $ignore = $this->_options['excludeVars']; + $ignore[] = $prefix . 'orderBy'; + $ignore[] = $prefix . 'direction'; + foreach ($extraParameters as $var => $value) { + $ignore[] = $prefix . $var; + } + foreach ($_GET as $key => $val) { + if (!in_array ($key, $ignore)) { + $this->_sortingHttpQueryCommon[$key] = $val; + } + } + } + + // Build list of GET variables + $get = array(); + $get[$prefix . 'orderBy'] = $field; + $get[$prefix . 'direction'] = $direction; + foreach ($extraParameters as $var => $value) { + $get[$prefix . $var] = $value; + } + + // Merge common and column-specific GET variables + $get = array_merge($this->_sortingHttpQueryCommon, $get); + + // Build query + if ($convertAmpersand and ini_get('arg_separator.output') == '&') { + $query = htmlentities(http_build_query($get),ENT_QUOTES, + $this->_options['encoding']); + } else { + $query = http_build_query($get); + } + + return $query; + } + + /** + * Detect whether a method is implemented a child class + * + * This method is able to detect if a given method is implemented in the + * driver (child class) even if it is declared in the root class. + * + * @param $method Method name + * @param $class The class to scan (Internal use) + * @return bool + * @access protected + */ + function _isImplemented($method, $class = null) + { + if (is_null($class)) { + $class = get_class($this); + } + + $parent = get_parent_class ($class); + + if (!$parent) { + return false; + } else { + $methods = get_class_methods($class); + if (in_array ($method, $methods)) { + return true; + } else { + return $this->_isImplemented($method, $parent); + } + } + } + +} + +?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/Array.php?r1=1.18&r2=1.19&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/Array.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/Array.php:1.18 pear/Structures_DataGrid/DataGrid/DataSource/Array.php:1.19 --- pear/Structures_DataGrid/DataGrid/DataSource/Array.php:1.18 Wed Feb 15 20:49:07 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/Array.php Thu Mar 16 12:37:20 2006 @@ -17,16 +17,16 @@ // | Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: Array.php,v 1.18 2006/02/15 20:49:07 wiesemann Exp $ +// $Id: Array.php,v 1.19 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** * Array Data Source Driver * * This class is a data source driver for a 2D Array * - * @version $Revision: 1.18 $ + * @version $Revision: 1.19 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @author Andrew Nagy <asnagy@webitecture.org> * @access public @@ -34,7 +34,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_Array - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * The array @@ -46,7 +46,7 @@ function Structures_DataGrid_DataSource_Array() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); } /** @@ -149,4 +149,4 @@ } } -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php?r1=1.4&r2=1.5&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php:1.4 pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php:1.5 --- pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php:1.4 Sat Jan 14 13:34:05 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/DBQuery.php Thu Mar 16 12:37:20 2006 @@ -17,10 +17,10 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DBQuery.php,v 1.4 2006/01/14 13:34:05 wiesemann Exp $ +// $Id: DBQuery.php,v 1.5 2006/03/16 12:37:20 olivierg Exp $ require_once 'DB.php'; -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** @@ -28,7 +28,7 @@ * * This class is a data source driver for the PEAR::DB object * - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ * @author Andrew S. Nagy <asnagy@php.net> * @author Mark Wiesemann <wiesemann@php.net> * @access public @@ -36,7 +36,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_DBQuery - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * Reference to the PEAR::DB object @@ -77,7 +77,7 @@ */ function Structures_DataGrid_DataSource_DBQuery() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); } /** http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php?r1=1.5&r2=1.6&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.5 pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.6 --- pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.5 Wed Dec 21 11:10:13 2005 +++ pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php Thu Mar 16 12:37:20 2006 @@ -17,16 +17,16 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DBTable.php,v 1.5 2005/12/21 11:10:13 wiesemann Exp $ +// $Id: DBTable.php,v 1.6 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** * PEAR::DB_Table Data Source Driver * * This class is a data source driver for the PEAR::DB_Table object * -* @version $Revision: 1.5 $ +* @version $Revision: 1.6 $ * @author Andrew S. Nagy <asnagy@php.net> * @author Mark Wiesemann <wiesemann@php.net> * @access public @@ -34,7 +34,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_DBTable - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * Reference to the Result object returned by DB_Table @@ -75,7 +75,7 @@ */ function Structures_DataGrid_DataSource_DBTable() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); $this->_addDefaultOptions(array('where' => null)); } @@ -186,4 +186,4 @@ } -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php?r1=1.26&r2=1.27&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.26 pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.27 --- pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.26 Thu Mar 16 01:05:52 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php Thu Mar 16 12:37:20 2006 @@ -17,9 +17,9 @@ // | Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: DataObject.php,v 1.26 2006/03/16 01:05:52 olivierg Exp $ +// $Id: DataObject.php,v 1.27 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** * PEAR::DB_DataObject Data Source Driver @@ -38,7 +38,7 @@ * same kind of information as the "fields" options. If the "fields" * option is set, this one will not be used. Default : "fb_fieldsToRender". * - * @version $Revision: 1.26 $ + * @version $Revision: 1.27 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @author Andrew Nagy <asnagy@webitecture.org> * @access public @@ -46,7 +46,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_DataObject - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * Reference to the DataObject @@ -75,7 +75,7 @@ */ function Structures_DataGrid_DataSource_DataObject() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); $this->_addDefaultOptions(array( 'use_private_vars' => false, http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php:1.1 pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php:1.2 --- pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php:1.1 Sat Jan 14 13:34:46 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/MDB2.php Thu Mar 16 12:37:20 2006 @@ -17,10 +17,10 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: MDB2.php,v 1.1 2006/01/14 13:34:46 wiesemann Exp $ +// $Id: MDB2.php,v 1.2 2006/03/16 12:37:20 olivierg Exp $ require_once 'MDB2.php'; -require_once 'Structures/DataGrid/DataSource/Common.php'; +require_once 'Structures/DataGrid/DataSource.php'; /** @@ -28,7 +28,7 @@ * * This class is a data source driver for the PEAR::MDB2 object * - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @author Andrew S. Nagy <asnagy@php.net> * @author Mark Wiesemann <wiesemann@php.net> * @access public @@ -36,7 +36,7 @@ * @category Structures */ class Structures_DataGrid_DataSource_MDB2 - extends Structures_DataGrid_DataSource_Common + extends Structures_DataGrid_DataSource { /** * Reference to the PEAR::MDB2 object @@ -77,7 +77,7 @@ */ function Structures_DataGrid_DataSource_MDB2() { - parent::Structures_DataGrid_DataSource_Common(); + parent::Structures_DataGrid_DataSource(); } /** http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Record/DataObject.php?r1=1.10&r2=1.11&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Record/DataObject.php diff -u pear/Structures_DataGrid/DataGrid/Record/DataObject.php:1.10 pear/Structures_DataGrid/DataGrid/Record/DataObject.php:1.11 --- pear/Structures_DataGrid/DataGrid/Record/DataObject.php:1.10 Mon Jan 10 15:17:34 2005 +++ pear/Structures_DataGrid/DataGrid/Record/DataObject.php Thu Mar 16 12:37:20 2006 @@ -16,14 +16,14 @@ // | Author: Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: DataObject.php,v 1.10 2005/01/10 15:17:34 asnagy Exp $ +// $Id: DataObject.php,v 1.11 2006/03/16 12:37:20 olivierg Exp $ require_once 'Structures/DataGrid/Record.php'; /** * Structures_DataGrid_Record_DataObject Class * - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @access public * @package Structures_DataGrid @@ -49,7 +49,7 @@ function setRecord($data) { - if (strtolower(is_subclass_of($data, 'db_dataobject'))) { + if (is_subclass_of($data, 'db_dataobject')) { parent::setRecord($data->toArray()); } else { return new PEAR_Error('Invalid data type. ' . http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/CSV.php?r1=1.12&r2=1.13&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/CSV.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/CSV.php:1.12 pear/Structures_DataGrid/DataGrid/Renderer/CSV.php:1.13 --- pear/Structures_DataGrid/DataGrid/Renderer/CSV.php:1.12 Tue Feb 28 10:53:25 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/CSV.php Thu Mar 16 12:37:20 2006 @@ -18,9 +18,9 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: CSV.php,v 1.12 2006/02/28 10:53:25 wiesemann Exp $ +// $Id: CSV.php,v 1.13 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; /** * Structures_DataGrid_Renderer_CSV Class @@ -34,7 +34,7 @@ * - useQuotes: (bool) Whether or not to encapuslate the values with quotes * (default: false) * - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -42,7 +42,7 @@ * @package Structures_DataGrid * @category Structures */ -class Structures_DataGrid_Renderer_CSV extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_CSV extends Structures_DataGrid_Renderer { /** @@ -54,7 +54,7 @@ */ function Structures_DataGrid_Renderer_CSV() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'delimiter' => ',', http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/Console.php?r1=1.6&r2=1.7&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/Console.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.6 pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.7 --- pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.6 Mon Mar 13 17:33:36 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/Console.php Thu Mar 16 12:37:20 2006 @@ -18,15 +18,15 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Console.php,v 1.6 2006/03/13 17:33:36 wiesemann Exp $ +// $Id: Console.php,v 1.7 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; require_once 'Console/Table.php'; /** * Structures_DataGrid_Renderer_Console Class * - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -34,7 +34,7 @@ * @package Structures_DataGrid * @category Structures */ -class Structures_DataGrid_Renderer_Console extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_Console extends Structures_DataGrid_Renderer { /** @@ -46,7 +46,7 @@ */ function Structures_DataGrid_Renderer_Console() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); } /** http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php?r1=1.93&r2=1.94&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.93 pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.94 --- pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php:1.93 Thu Mar 16 12:23:57 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/HTMLTable.php Thu Mar 16 12:37:20 2006 @@ -18,9 +18,9 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: HTMLTable.php,v 1.93 2006/03/16 12:23:57 olivierg Exp $ +// $Id: HTMLTable.php,v 1.94 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; require_once 'HTML/Table.php'; /** @@ -51,7 +51,7 @@ * - sortingResetsPaging: whether sorting HTTP queries reset paging * (default : true) * - * @version $Revision: 1.93 $ + * @version $Revision: 1.94 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -59,7 +59,7 @@ * @package Structures_DataGrid * @category Structures */ -class Structures_DataGrid_Renderer_HTMLTable extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_HTMLTable extends Structures_DataGrid_Renderer { /** * Rendering container @@ -101,7 +101,7 @@ */ function Structures_DataGrid_Renderer_HTMLTable() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'evenRowAttributes' => array(), http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/XLS.php?r1=1.26&r2=1.27&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/XLS.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.26 pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.27 --- pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.26 Sat Feb 25 09:58:45 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/XLS.php Thu Mar 16 12:37:20 2006 @@ -18,9 +18,9 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: XLS.php,v 1.26 2006/02/25 09:58:45 wiesemann Exp $ +// $Id: XLS.php,v 1.27 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; require_once 'Spreadsheet/Excel/Writer.php'; /** @@ -40,7 +40,7 @@ * (true = send to browser, false = write to a file) * (default: true) * - * @version $Revision: 1.26 $ + * @version $Revision: 1.27 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -48,7 +48,7 @@ * @package Structures_DataGrid * @category Structures */ -class Structures_DataGrid_Renderer_XLS extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_XLS extends Structures_DataGrid_Renderer { // FIXME: refactoring incomplete // FIXME: remove $_workbook, use $_container (?) @@ -75,7 +75,7 @@ */ function Structures_DataGrid_Renderer_XLS() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'headerFormat' => 0, http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/XML.php?r1=1.21&r2=1.22&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/XML.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/XML.php:1.21 pear/Structures_DataGrid/DataGrid/Renderer/XML.php:1.22 --- pear/Structures_DataGrid/DataGrid/Renderer/XML.php:1.21 Tue Feb 28 11:02:10 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/XML.php Thu Mar 16 12:37:20 2006 @@ -18,15 +18,15 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: XML.php,v 1.21 2006/02/28 11:02:10 wiesemann Exp $ +// $Id: XML.php,v 1.22 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; require_once 'XML/Util.php'; /** * Structures_DataGrid_Renderer_XML Class * - * @version $Revision: 1.21 $ + * @version $Revision: 1.22 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -41,7 +41,7 @@ * - rowTag: (string) The name of the tag for each row (without brackets) * (default: 'Row') */ -class Structures_DataGrid_Renderer_XML extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_XML extends Structures_DataGrid_Renderer { /** @@ -53,7 +53,7 @@ */ function Structures_DataGrid_Renderer_XML() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'outerTag' => 'DataGrid', http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/XUL.php?r1=1.19&r2=1.20&diff_format=u Index: pear/Structures_DataGrid/DataGrid/Renderer/XUL.php diff -u pear/Structures_DataGrid/DataGrid/Renderer/XUL.php:1.19 pear/Structures_DataGrid/DataGrid/Renderer/XUL.php:1.20 --- pear/Structures_DataGrid/DataGrid/Renderer/XUL.php:1.19 Thu Mar 16 01:05:52 2006 +++ pear/Structures_DataGrid/DataGrid/Renderer/XUL.php Thu Mar 16 12:37:20 2006 @@ -18,9 +18,9 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: XUL.php,v 1.19 2006/03/16 01:05:52 olivierg Exp $ +// $Id: XUL.php,v 1.20 2006/03/16 12:37:20 olivierg Exp $ -require_once 'Structures/DataGrid/Renderer/Common.php'; +require_once 'Structures/DataGrid/Renderer.php'; //require_once 'XML/XUL.php'; require_once 'XML/Util.php'; @@ -61,7 +61,7 @@ * - selfPath: (string) The complete path for sorting and paging links * (default: $_SERVER['PHP_SELF']) * - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -70,7 +70,7 @@ * @category Structures * @todo Implement PEAR::XML_XUL upon maturity */ -class Structures_DataGrid_Renderer_XUL extends Structures_DataGrid_Renderer_Common +class Structures_DataGrid_Renderer_XUL extends Structures_DataGrid_Renderer { /** * The generated XUL data @@ -88,7 +88,7 @@ */ function Structures_DataGrid_Renderer_XUL() { - parent::Structures_DataGrid_Renderer_Common(); + parent::Structures_DataGrid_Renderer(); $this->_addDefaultOptions( array( 'selfPath' => $_SERVER['PHP_SELF']