cvs: pear /Structures_DataGrid/DataGrid/DataSource DataObject.php

From: Date: Tue, 18 Jan 2005 17:44:35 +0000
Subject: cvs: pear /Structures_DataGrid/DataGrid/DataSource DataObject.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-28665@lists.php.net to get a copy of this message
asnagy Tue Jan 18 12:44:35 2005 EDT Modified files: /pear/Structures_DataGrid/DataGrid/DataSource DataObject.php Log: Added a "fields filter" to remove private variables from being printed in the datagrid. Added extra options for FormBuilder - Bug #3140 http://cvs.php.net/diff.php/pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php?r1=1.16&r2=1.17&ty=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.16 pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.17 --- pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.16 Mon Jan 10 17:33:23 2005 +++ pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php Tue Jan 18 12:44:34 2005 @@ -17,7 +17,7 @@ // | Andrew Nagy <asnagy@webitecture.org> | // +----------------------------------------------------------------------+ // -// $Id: DataObject.php,v 1.16 2005/01/10 22:33:23 asnagy Exp $ +// $Id: DataObject.php,v 1.17 2005/01/18 17:44:34 asnagy Exp $ require_once 'Structures/DataGrid/DataSource.php'; @@ -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.16 $ + * @version $Revision: 1.17 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @author Andrew Nagy <asnagy@webitecture.org> * @access public @@ -112,22 +112,29 @@ if ($this->_options['formbuilder_integration']) { if (isset($this->_dataobject->fb_preDefOrder)) { $ordered = array(); - foreach ($this->_dataobject->fb_preDefOrder as $orderField) { - if (in_array($orderField, $mergeOptions['fields'])) { + foreach ($this->_dataobject->fb_preDefOrder as + $orderField) { + if (in_array($orderField, + $mergeOptions['fields'])) { $ordered[] = $orderField; } } - $mergeOptions['fields'] = array_merge($ordered, array_diff($mergeOptions['fields'], $ordered)); + $mergeOptions['fields'] = + array_merge($ordered, + array_diff($mergeOptions['fields'], + $ordered)); } foreach ($mergeOptions['fields'] as $num => $field) { - if (strstr($field, '__tripleLink_') || strstr($field, '__crossLink_') || strstr($field, '__reverseLink_')) { + if (strstr($field, '__tripleLink_') || + strstr($field, '__crossLink_') || + strstr($field, '__reverseLink_')) { unset($mergeOptions['fields'][$num]); } } } } else { //$mergeOptions['fields'] = array_keys($this->_dataobject->toArray()); - $mergeOptions['fields'] = array_filter(array_keys(get_object_vars($this->_dataobject)), 'fieldsFilter'); + $mergeOptions['fields'] = array_filter(array_keys(get_object_vars($this->_dataobject)), array(&$this, '_fieldsFilter')); } } @@ -211,8 +218,10 @@ // REPLACE ME WITH ABOVE $vars = get_object_vars($this->_dataobject); - $keys = array_filter(array_keys($vars), '_fieldsFilter'); - $fieldList = array_filter(get_object_vars($this->_dataobject), '_fieldsFilter'); + $keys = array_filter(array_keys($vars), + array(&$this, '_fieldsFilter')); + $fieldList = array_filter(get_object_vars($this->_dataobject), + array(&$this, '_fieldsFilter')); } // Build Fields @@ -228,7 +237,8 @@ // Get Linked FormBuilder Fields if ($this->_options['formbuilder_integration']) { foreach (array_keys($rec) as $field) { - if (isset($links[$field]) && $linkedDo =& $this->_dataobject->getLink($field)) { + if (isset($links[$field]) && + $linkedDo =& $this->_dataobject->getLink($field)) { $rec[$field] = DB_DataObject_FormBuilder::getDataObjectString($linkedDo); } } @@ -281,12 +291,15 @@ } // This function is temporary until DB_DO bug #1315 is fixed + // This removeds and variables from the DataObject that begins with _ or fb_ function _fieldsFilter($value) { if (substr($value, 0, 1) == '_') { return false; } else if (substr($value, 0, 3) == 'fb_') { return false; + } else if ($value == 'N') { + return false; } else { return true; }

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