cvs: pear /Structures_DataGrid DataGrid.php /Structures_DataGrid/DataGrid/Renderer Console.php XLS.php
| From: | Olivier Guilyardi | Date: | Fri, 17 Mar 2006 21:37:01 +0000 |
| Subject: | cvs: pear /Structures_DataGrid DataGrid.php /Structures_DataGrid/DataGrid/Renderer Console.php XLS.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39169@lists.php.net to get a copy of this message | ||
olivierg Fri Mar 17 21:37:01 2006 UTC
Modified files:
/pear/Structures_DataGrid DataGrid.php
/pear/Structures_DataGrid/DataGrid/Renderer Console.php XLS.php
Log:
Added Console_Table rendering container detection
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid.php?r1=1.51&r2=1.52&diff_format=u
Index: pear/Structures_DataGrid/DataGrid.php
diff -u pear/Structures_DataGrid/DataGrid.php:1.51 pear/Structures_DataGrid/DataGrid.php:1.52
--- pear/Structures_DataGrid/DataGrid.php:1.51 Fri Mar 17 21:04:01 2006
+++ pear/Structures_DataGrid/DataGrid.php Fri Mar 17 21:37:01 2006
@@ -18,7 +18,7 @@
// | Mark Wiesemann <wiesemann@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: DataGrid.php,v 1.51 2006/03/17 21:04:01 olivierg Exp $
+// $Id: DataGrid.php,v 1.52 2006/03/17 21:37:01 olivierg Exp $
require_once 'PEAR.php';
@@ -75,7 +75,7 @@
* ?>
* </code>
*
- * @version $Revision: 1.51 $
+ * @version $Revision: 1.52 $
* @author Andrew S. Nagy <asnagy@webitecture.org>
* @author Olivier Guilyardi <olivier@samalyse.com>
* @author Mark Wiesemann <wiesemann@php.net>
@@ -989,15 +989,21 @@
*/
function _detectRendererType(&$container)
{
- if (is_a($container, 'html_table') or is_subclass_of($container,
'html_table')) {
+ 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')) {
+ } 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;
- } // FIXME: and so on...
+ } else if (is_a($container, 'console_table')
+ or is_subclass_of($container,
+ 'console_table')) {
+ return DATAGRID_RENDER_CONSOLE;
+ }
return null;
}
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/Console.php?r1=1.7&r2=1.8&diff_format=u
Index: pear/Structures_DataGrid/DataGrid/Renderer/Console.php
diff -u pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.7
pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.8
--- pear/Structures_DataGrid/DataGrid/Renderer/Console.php:1.7 Thu Mar 16 12:37:20 2006
+++ pear/Structures_DataGrid/DataGrid/Renderer/Console.php Fri Mar 17 21:37:01 2006
@@ -18,7 +18,7 @@
// | Mark Wiesemann <wiesemann@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Console.php,v 1.7 2006/03/16 12:37:20 olivierg Exp $
+// $Id: Console.php,v 1.8 2006/03/17 21:37:01 olivierg Exp $
require_once 'Structures/DataGrid/Renderer.php';
require_once 'Console/Table.php';
@@ -26,7 +26,12 @@
/**
* Structures_DataGrid_Renderer_Console Class
*
- * @version $Revision: 1.7 $
+ * This container has container support. You can use the
+ * Structures_DataGrid::fill() method with it.
+ *
+ * It buffers output, you can use Structures_DataGrid::getOutput()
+ *
+ * @version $Revision: 1.8 $
* @author Andrew S. Nagy <asnagy@webitecture.org>
* @author Olivier Guilyardi <olivier@samalyse.com>
* @author Mark Wiesemann <wiesemann@php.net>
@@ -36,6 +41,12 @@
*/
class Structures_DataGrid_Renderer_Console extends Structures_DataGrid_Renderer
{
+ /**
+ * Console_Table container
+ * @var object
+ * @access protected
+ */
+ var $_table;
/**
* Constructor
@@ -50,14 +61,42 @@
}
/**
+ * Attach an already instantiated Console_Table object
+ *
+ * @param object $consoleTable
+ * @return mixed True or a PEAR_Error
+ * @access public
+ */
+ function setContainer(&$consoleTable)
+ {
+ $this->_table =& $consoleTable;
+ return true;
+ }
+
+ /**
+ * Return the internal Console_Table container
+ *
+ * @return object Console_Table or PEAR_Error
+ * @access public
+ */
+ function &getContainer(&$consoleTable)
+ {
+ if (!isset($this->_table)) {
+ $id = __CLASS__ . '::' . __FUNCTION__;
+ return PEAR::raiseError("$id: no Console_Table container loaded");
+ }
+ return $this->_table;
+ }
+
+ /**
* Initialize Console_Table instance if it is not already existing
*
* @access protected
*/
function init()
{
- if (is_null($this->_container)) {
- $this->_container = new Console_Table();
+ if (!isset($this->_table)) {
+ $this->_table = new Console_Table();
}
}
@@ -91,9 +130,9 @@
* @access public
* @return object Console_Table The Console_Table object for the DataGrid
*/
- function getTable()
+ function &getTable()
{
- return $this->_container;
+ return $this->getContainer();
}
/**
@@ -109,7 +148,7 @@
$columnList[] = $this->_columns[$col]['label'];
}
- $this->_container->setHeaders($columnList);
+ $this->_table->setHeaders($columnList);
}
/**
@@ -125,7 +164,7 @@
for ($col = 0; $col < $this->_columnsNum; $col++) {
$cellList[] = $this->_records[$row][$col];
}
- $this->_container->addRow($cellList);
+ $this->_table->addRow($cellList);
}
}
@@ -137,7 +176,7 @@
*/
function flatten()
{
- return $this->_container->getTable();
+ return $this->_table->getTable();
}
}
http://cvs.php.net/viewcvs.cgi/pear/Structures_DataGrid/DataGrid/Renderer/XLS.php?r1=1.28&r2=1.29&diff_format=u
Index: pear/Structures_DataGrid/DataGrid/Renderer/XLS.php
diff -u pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.28
pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.29
--- pear/Structures_DataGrid/DataGrid/Renderer/XLS.php:1.28 Fri Mar 17 21:06:51 2006
+++ pear/Structures_DataGrid/DataGrid/Renderer/XLS.php Fri Mar 17 21:37:01 2006
@@ -18,7 +18,7 @@
// | Mark Wiesemann <wiesemann@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: XLS.php,v 1.28 2006/03/17 21:06:51 olivierg Exp $
+// $Id: XLS.php,v 1.29 2006/03/17 21:37:01 olivierg Exp $
require_once 'Structures/DataGrid/Renderer.php';
require_once 'Spreadsheet/Excel/Writer.php';
@@ -91,7 +91,7 @@
* $datagrid->fill($workbook, $options);
* </code>
*
- * @version $Revision: 1.28 $
+ * @version $Revision: 1.29 $
* @author Andrew S. Nagy <asnagy@webitecture.org>
* @author Olivier Guilyardi <olivier@samalyse.com>
* @author Mark Wiesemann <wiesemann@php.net>
@@ -321,6 +321,7 @@
*/
function render()
{
+ $this->isBuilt() or $this->build();
$this->_workbook->close();
return true;
}