anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00277
[Branch ~uws/anewt/anewt.uws] Rev 1792: [renderer/grid] Add title param to cell renderer constructor
------------------------------------------------------------
revno: 1792
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt
timestamp: Sat 2010-10-02 20:38:38 +0200
message:
[renderer/grid] Add title param to cell renderer constructor
This makes setting titles for custom cell renderers easier.
Also don't force column and cell renderer titles to be
strings, since any renderable object (e.g. DOM nodes) will
do. And while at it: also a few cosmetic cleanups.
modified:
renderer/grid/cell.lib.php
renderer/grid/column.lib.php
--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws
Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription
=== modified file 'renderer/grid/cell.lib.php'
--- renderer/grid/cell.lib.php 2009-08-02 16:32:09 +0000
+++ renderer/grid/cell.lib.php 2010-10-02 18:38:38 +0000
@@ -23,14 +23,18 @@
* \param $id
* The id for this cell renderer. It will be used to match against the row
* data in the grid.
+ *
+ * \param $title
+ * The title for this cell renderer. Optional, defaults to
+ * <code>null</code>.
*/
- function __construct($id)
+ function __construct($id, $title=null)
{
assert('is_string($id)');
$this->id = $id;
$this->_seed(array(
- 'title' => null,
+ 'title' => $title,
));
}
@@ -171,14 +175,19 @@
*
* \param $initial_value
* The initial value for the counter. Defaults to 1, but can be changed
- * e.g. paginated grid listings.
+ * e.g. paginated grid listings. Set this to <code>null</code> to use the
+ * default and you want to specify a <code>$title</code> (next parameter).
+ *
+ * \param $title
+ * The title for this cell renderer. Optional, defaults to
+ * <code>null</code>.
*/
- function AnewtGridCellRendererCount($id, $initial_value=null)
+ function __construct($id, $initial_value=1, $title=null)
{
if (is_null($initial_value))
$initial_value = 1;
- parent::__construct($id);
+ parent::__construct($id, $title);
assert('is_int($initial_value)');
$this->_value = $initial_value;
}
@@ -227,11 +236,21 @@
* Cell renderer id
*
* \param $format
- * Date formatting string in strftime syntax
+ * Date formatting string in strftime syntax. Set this to
+ * <code>null</code> to use the default and you want to specify
+ * a <code>$title</code> (next parameter).
+ *
+ * \param $title
+ * The title for this cell renderer. Optional, defaults to
+ * <code>null</code>.
*/
- function AnewtGridCellRendererDate($id, $format='%c')
+ function __construct($id, $format='%c', $title=null)
{
- parent::__construct($id);
+ if (is_null($format))
+ $format = '%c';
+
+ parent::__construct($id, $title);
+
assert('is_string($format)');
$this->_format = $format;
}
=== modified file 'renderer/grid/column.lib.php'
--- renderer/grid/column.lib.php 2009-08-02 16:32:09 +0000
+++ renderer/grid/column.lib.php 2010-10-02 18:38:38 +0000
@@ -42,21 +42,23 @@
function __construct($column_id, $title=null, $order=null, $visible=null)
{
/* Set defaults */
- if (is_null($title)) $title = '';
- if (is_null($visible)) $visible = true;
+ if (is_null($title))
+ $title = '';
+
+ if (is_null($visible))
+ $visible = true;
/* Sanity checks */
assert('is_string($column_id)');
- assert('is_string($title)');
assert('is_null($order) || is_int($order)');
assert('is_bool($visible)');
/* Store settings */
$this->id = $column_id;
$this->_seed(array(
- 'title' => $title,
- 'order' => $order,
- 'visible' => $visible,
+ 'title' => $title,
+ 'order' => $order,
+ 'visible' => $visible,
'highlight' => false,
));
}
@@ -72,6 +74,7 @@
function add_cell_renderer($cell_renderer)
{
assert('$cell_renderer instanceof AnewtGridCellRenderer');
+
/* Back-reference to the column object (needed for highlighting when
* rendering */
$cell_renderer->_column = $this;