cvs: pear /Structures_DataGrid/DataGrid/DataSource Common.php
| From: | Olivier Guilyardi | Date: | Thu, 02 Mar 2006 00:52:17 +0000 |
| Subject: | cvs: pear /Structures_DataGrid/DataGrid/DataSource Common.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38823@lists.php.net to get a copy of this message | ||
olivierg Thu Mar 2 00:52:17 2006 UTC
Modified files:
/pear/Structures_DataGrid/DataGrid/DataSource Common.php
Log:
Added "driver features" and multiple field sorting abstract support
- new methods : _addFeatures(), getFeatures(), hasFeature()
- the fetch() and sort() docblocks have been updated about the multiple field
sorting.
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource/Common.php?r1=1.5&r2=1.6&diff_format=u
Index: pear/Structures_DataGrid/DataGrid/DataSource/Common.php
diff -u pear/Structures_DataGrid/DataGrid/DataSource/Common.php:1.5
pear/Structures_DataGrid/DataGrid/DataSource/Common.php:1.6
--- pear/Structures_DataGrid/DataGrid/DataSource/Common.php:1.5 Wed Mar 1 23:39:33 2006
+++ pear/Structures_DataGrid/DataGrid/DataSource/Common.php Thu Mar 2 00:52:16 2006
@@ -17,7 +17,7 @@
// | Andrew Nagy <asnagy@webitecture.org> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.5 2006/03/01 23:39:33 olivierg Exp $
+// $Id: Common.php,v 1.6 2006/03/02 00:52:16 olivierg Exp $
/**
@@ -107,6 +107,14 @@
var $_options = array();
/**
+ * Special driver features
+ *
+ * @var array
+ * @access protected
+ */
+ var $_features = array();
+
+ /**
* Constructor
*
*/
@@ -115,17 +123,18 @@
$this->_options = array('generate_columns' => false,
'labels' => array(),
'fields' => array());
+
+ $this->_features = array('multiSort' => false);
}
/**
* Adds some default options.
*
* This method is meant to be called by drivers. It allows adding some
- * default options. Additionally to setting default values the options
- * names (keys) are used by setOptions() to validate its input.
+ * default options.
*
* @access protected
- * @param array $options An associative array of the from:
+ * @param array $options An associative array of the form:
* array(optionName => optionValue, ...)
* @return void
* @see Structures_DataGrid_DataSource_Common::_setOption
@@ -136,6 +145,22 @@
}
/**
+ * 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 _addFeatures($features)
+ {
+ $this->_features = array_merge($this->_features, $features);
+ }
+
+ /**
* Set options
*
* @param mixed $options An associative array of the form :
@@ -192,19 +217,24 @@
* When overloaded this method must return a 2D array of records
* on success or a PEAR_Error object on failure.
*
- * FIXME: Why is there these $sortField and $sortDir parameters ? This
- * is redundant with the sort() method.
- *
* @abstract
* @param integer $offset Limit offset (starting from 0)
* @param integer $len Limit length
- * @param string $sortField Field to sort by
+ * @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, $sortField=null, $sortDir='ASC')
+ 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");
}
@@ -236,13 +266,18 @@
* Note : must be called before fetch()
*
* @abstract
- * @param string $sortField Field to sort by
+ * @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($sortField, $sortDir = null)
+ function sort($sortSpec, $sortDir = null)
{
return new PEAR_Error("No data source driver loaded");
}
@@ -268,8 +303,30 @@
/**#@-*/
// 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()