cvs: pear /Structures_DataGrid DataGrid.php

From: Date: Sat, 17 Jun 2006 09:53:22 +0000
Subject: cvs: pear /Structures_DataGrid DataGrid.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-40778@lists.php.net to get a copy of this message
wiesemann Sat Jun 17 09:53:22 2006 UTC Modified files: /pear/Structures_DataGrid DataGrid.php Log: - make _detectRendererType() more clear and readable (thanks to Michel D'Hooge for the code) http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid.php?r1=1.79&r2=1.80&diff_format=u Index: pear/Structures_DataGrid/DataGrid.php diff -u pear/Structures_DataGrid/DataGrid.php:1.79 pear/Structures_DataGrid/DataGrid.php:1.80 --- pear/Structures_DataGrid/DataGrid.php:1.79 Sat Jun 17 09:37:29 2006 +++ pear/Structures_DataGrid/DataGrid.php Sat Jun 17 09:53:22 2006 @@ -18,7 +18,7 @@ // | Mark Wiesemann <wiesemann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DataGrid.php,v 1.79 2006/06/17 09:37:29 wiesemann Exp $ +// $Id: DataGrid.php,v 1.80 2006/06/17 09:53:22 wiesemann Exp $ require_once 'PEAR.php'; @@ -74,7 +74,7 @@ * ?> * </code> * - * @version $Revision: 1.79 $ + * @version $Revision: 1.80 $ * @author Andrew S. Nagy <asnagy@webitecture.org> * @author Olivier Guilyardi <olivier@samalyse.com> * @author Mark Wiesemann <wiesemann@php.net> @@ -186,7 +186,21 @@ * @var string * @access private */ - var $_requestPrefix = ''; + var $_requestPrefix = ''; + + /** + * Possible renderer types and their equivalent renderer constants + * @var array + * @access private + */ + var $_rendererTypes = array( + 'html_table' => DATAGRID_RENDER_TABLE, + 'smarty' => DATAGRID_RENDER_SMARTY, + 'spreadsheet_excel_writer_workbook' => DATAGRID_RENDER_XLS, + 'console_table' => DATAGRID_RENDER_CONSOLE, + 'pager_common' => DATAGRID_RENDER_PAGER, + 'html_quickform' => DATAGRID_RENDER_SORTFORM + ); /** * Constructor @@ -1235,25 +1249,11 @@ */ function _detectRendererType(&$container) { - if (is_a($container, 'html_table') - or is_subclass_of($container, 'html_table')) { - return DATAGRID_RENDER_TABLE; - } else if (is_a($container, 'smarty') - or is_subclass_of($container, 'smarty')) { - return DATAGRID_RENDER_SMARTY; - } else if (is_a($container, 'spreadsheet_excel_writer_workbook') - or is_subclass_of($container, - 'spreadsheet_excel_writer_workbook')) { - return DATAGRID_RENDER_XLS; - } else if (is_a($container, 'console_table') - or is_subclass_of($container, - 'console_table')) { - return DATAGRID_RENDER_CONSOLE; - } else if (is_a($container, 'pager_common') - or is_subclass_of($container, - 'pager_common')) { - return DATAGRID_RENDER_PAGER; - } + foreach ($this->_rendererTypes as $class => $type) { + if (is_a($container, $class)) { + return $type; + } + } return null; }

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