cvs: pear /Structures_DataGrid DataGrid.php /Structures_DataGrid/DataGrid DataSource.php Renderer.php
| From: | Olivier Guilyardi | Date: | Thu, 16 Mar 2006 13:07:05 +0000 |
| Subject: | cvs: pear /Structures_DataGrid DataGrid.php /Structures_DataGrid/DataGrid DataSource.php Renderer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39123@lists.php.net to get a copy of this message | ||
olivierg Thu Mar 16 13:07:05 2006 UTC
Modified files:
/pear/Structures_DataGrid DataGrid.php
/pear/Structures_DataGrid/DataGrid DataSource.php Renderer.php
Log:
Added handy option(s) setters
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid.php?r1=1.46&r2=1.47&diff_format=u
Index: pear/Structures_DataGrid/DataGrid.php
diff -u pear/Structures_DataGrid/DataGrid.php:1.46 pear/Structures_DataGrid/DataGrid.php:1.47
--- pear/Structures_DataGrid/DataGrid.php:1.46 Thu Mar 16 12:54:02 2006
+++ pear/Structures_DataGrid/DataGrid.php Thu Mar 16 13:07:05 2006
@@ -18,7 +18,7 @@
// | Mark Wiesemann <wiesemann@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: DataGrid.php,v 1.46 2006/03/16 12:54:02 olivierg Exp $
+// $Id: DataGrid.php,v 1.47 2006/03/16 13:07:05 olivierg Exp $
require_once 'PEAR.php';
@@ -75,7 +75,7 @@
* ?>
* </code>
*
- * @version $Revision: 1.46 $
+ * @version $Revision: 1.47 $
* @author Andrew S. Nagy <asnagy@webitecture.org>
* @author Olivier Guilyardi <olivier@samalyse.com>
* @author Mark Wiesemann <wiesemann@php.net>
@@ -572,7 +572,7 @@
*/
function getRecordCount()
{
- if (!is_null($this->_dataSource)) {
+ if (isset($this->_dataSource)) {
return $this->_dataSource->count();
} else {
return count($this->recordSet);
@@ -739,7 +739,7 @@
*/
function fetchDataSource()
{
- if ($this->_dataSource != null) {
+ if (isset($this->_dataSource)) {
// Determine Page
$page = $this->page ? $this->page - 1 : 0;
@@ -815,7 +815,7 @@
function sortRecordSet($sortBy, $direction = 'ASC')
{
$this->sortSpec = array($sortBy => $direction);
- if ($this->_dataSource) {
+ if (isset($this->_dataSource)) {
$this->_dataSource->sort($sortBy, $direction);
} else {
$this->_sortCallbackField = $sortBy;
@@ -1024,6 +1024,58 @@
}
}
+ /**
+ * Set a single renderer option
+ *
+ * @param string $name Option name
+ * @param mixed $value Option value
+ * @access public
+ */
+ function setRendererOption($name,$value)
+ {
+ $this->setRendererOptions(array($name => $value));
+ }
+
+ /**
+ * Set multiple renderer options
+ *
+ * @param array $options An associative array of the form :
+ * array("option_name" =>
"option_value",...)
+ * @access public
+ */
+ function setRendererOptions($options)
+ {
+ isset($this->_renderer) or $this->setRenderer(DATAGRID_RENDER_DEFAULT);
+ $this->_renderer->setOptions($options);
+ }
+
+ /**
+ * Set a single datasource option
+ *
+ * @param string $name Option name
+ * @param mixed $value Option value
+ * @access public
+ */
+ function setDataSourceOption($name,$value)
+ {
+ return $this->setDataSourceOptions(array($name => $value));
+ }
+
+ /**
+ * Set multiple datasource options
+ *
+ * @param array $options An associative array of the form :
+ * array("option_name" =>
"option_value",...)
+ * @access public
+ */
+ function setDataSourceOptions($options)
+ {
+ if (isset($this->_dataSource)) {
+ $this->_dataSource->setOptions($options);
+ } else {
+ return PEAR::raiseError('Unable to set options ; No datasource loaded.');
+ }
+ }
}
?>
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/DataSource.php?r1=1.15&r2=1.16&diff_format=u
Index: pear/Structures_DataGrid/DataGrid/DataSource.php
diff -u pear/Structures_DataGrid/DataGrid/DataSource.php:1.15
pear/Structures_DataGrid/DataGrid/DataSource.php:1.16
--- pear/Structures_DataGrid/DataGrid/DataSource.php:1.15 Thu Mar 16 12:54:02 2006
+++ pear/Structures_DataGrid/DataGrid/DataSource.php Thu Mar 16 13:07:05 2006
@@ -17,7 +17,7 @@
// | Andrew Nagy <asnagy@webitecture.org> |
// +----------------------------------------------------------------------+
//
-// $Id: DataSource.php,v 1.15 2006/03/16 12:54:02 olivierg Exp $
+// $Id: DataSource.php,v 1.16 2006/03/16 13:07:05 olivierg Exp $
/**
@@ -177,6 +177,18 @@
}
/**
+ * Set a single option
+ *
+ * @param string $name Option name
+ * @param mixed $value Option value
+ * @access public
+ */
+ function setOption($name, $value)
+ {
+ $this->_options[$name] = $value;
+ }
+
+ /**
* Generate columns if options are properly set
*
* Note : must be called after fetch()
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer.php?r1=1.32&r2=1.33&diff_format=u
Index: pear/Structures_DataGrid/DataGrid/Renderer.php
diff -u pear/Structures_DataGrid/DataGrid/Renderer.php:1.32
pear/Structures_DataGrid/DataGrid/Renderer.php:1.33
--- pear/Structures_DataGrid/DataGrid/Renderer.php:1.32 Thu Mar 16 12:54:02 2006
+++ pear/Structures_DataGrid/DataGrid/Renderer.php Thu Mar 16 13:07:05 2006
@@ -17,7 +17,7 @@
// | Olivier Guilyardi <olivier@samalyse.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Renderer.php,v 1.32 2006/03/16 12:54:02 olivierg Exp $
+// $Id: Renderer.php,v 1.33 2006/03/16 13:07:05 olivierg Exp $
require_once 'PHP/Compat/Function/http_build_query.php';
@@ -77,7 +77,7 @@
* - fillWithEmptyRows
* - numberAlign
*
- * @version $Revision: 1.32 $
+ * @version $Revision: 1.33 $
* @author Olivier Guilyardi <olivier@samalyse.com>
* @access public
* @package Structures_DataGrid
@@ -282,7 +282,7 @@
}
/**
- * Set options
+ * Set multiple options
*
* @param mixed $options An associative array of the form :
* array("option_name" =>
"option_value",...)
@@ -294,6 +294,18 @@
}
/**
+ * Set a single option
+ *
+ * @param string $name Option name
+ * @param mixed $value Option value
+ * @access public
+ */
+ function setOption($name, $value)
+ {
+ $this->_options[$name] = $value;
+ }
+
+ /**
* Provide columns and records data
*
* @param array $columns Array of Structures_DataGrid_Column objects