Browse files

- Request #16984: added a __toString() method, i.e. "echo $table;" is…

… now possible

  (thanks to Andreas Sjöberg)
- Bug #17073: enhanced E_STRICT compatibility
  (thanks to Andrea Bakker and Daniel O'Connor)

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Table/trunk@297540 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent b37c1bc commit e1c7a9527854a42a426de7d88bad8116ad0681d1 Mark Wiesemann committed Apr 5, 2010
View
25 Table.php
@@ -20,7 +20,7 @@
* PHP versions 4 and 5
*
* LICENSE:
- *
+ *
* Copyright (c) 2005-2007, Adam Daniel <adaniel1@eesus.jnj.com>,
* Bertrand Mansion <bmansion@mamasam.com>,
* Mark Wiesemann <wiesemann@php.net>
@@ -33,9 +33,9 @@
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
+ * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * * The names of the authors may not be used to endorse or promote products
+ * * The names of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
@@ -177,8 +177,8 @@ function HTML_Table($attributes = null, $tabOffset = 0, $useTGroups = false)
$this->_useTGroups = (boolean)$useTGroups;
$this->addBody();
if ($this->_useTGroups) {
- $this->_thead =& new HTML_Table_Storage($tabOffset, $this->_useTGroups);
- $this->_tfoot =& new HTML_Table_Storage($tabOffset, $this->_useTGroups);
+ $this->_thead = new HTML_Table_Storage($tabOffset, $this->_useTGroups);
+ $this->_tfoot = new HTML_Table_Storage($tabOffset, $this->_useTGroups);
}
}
@@ -202,7 +202,7 @@ function &getHeader()
{
if (is_null($this->_thead)) {
$this->_useTGroups = true;
- $this->_thead =& new HTML_Table_Storage($this->_tabOffset,
+ $this->_thead = new HTML_Table_Storage($this->_tabOffset,
$this->_useTGroups);
for ($i = 0; $i < $this->_tbodyCount; $i++) {
$this->_tbodies[$i]->setUseTGroups(true);
@@ -220,7 +220,7 @@ function &getFooter()
{
if (is_null($this->_tfoot)) {
$this->_useTGroups = true;
- $this->_tfoot =& new HTML_Table_Storage($this->_tabOffset,
+ $this->_tfoot = new HTML_Table_Storage($this->_tabOffset,
$this->_useTGroups);
for ($i = 0; $i < $this->_tbodyCount; $i++) {
$this->_tbodies[$i]->setUseTGroups(true);
@@ -264,7 +264,7 @@ function addBody($attributes = null)
}
$body = $this->_tbodyCount++;
- $this->_tbodies[$body] =& new HTML_Table_Storage($this->_tabOffset,
+ $this->_tbodies[$body] = new HTML_Table_Storage($this->_tabOffset,
$this->_useTGroups);
$this->_tbodies[$body]->setAutoFill($this->_autoFill);
$this->_tbodies[$body]->setAttributes($attributes);
@@ -1032,6 +1032,15 @@ function toHtml()
return $strHtml;
}
+ /**
+ * Returns the table structure as HTML
+ * @access public
+ * @return string
+ */
+ function __toString()
+ {
+ return $this->toHtml();
+ }
}
?>
View
6 docs/Table_example1.php
@@ -7,7 +7,7 @@
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width = "400"');
+$table = new HTML_Table('width = "400"');
$data[0][] = 'i am';
$data[0][] = 'i think';
@@ -25,8 +25,8 @@
$data[2][] = 'i think';
foreach($data as $key => $value) {
- $table->addRow($data[$key], array(array('bgcolor' => 'blue', 'align' => 'center'),
- array('bgcolor' => 'green'),
+ $table->addRow($data[$key], array(array('bgcolor' => 'blue', 'align' => 'center'),
+ array('bgcolor' => 'green'),
array('bgcolor' => 'red')));
}
View
2 docs/Table_example2.php
@@ -8,7 +8,7 @@
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width = "100%"');
+$table = new HTML_Table('width = "100%"');
$table->setCaption('256 colors table');
$i = $j = 0;
for ($R = 0; $R <= 255; $R += 51) {
View
11 package2.xml
@@ -44,17 +44,20 @@ For auto filling of data and such then check out http://pear.php.net/package/HTM
<date>2007-12-17</date>
<time>21:45:00</time>
<version>
- <release>1.8.2</release>
- <api>1.8.0</api>
+ <release>1.8.3</release>
+ <api>1.8.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license>New BSD</license>
<notes>
-- Bug #12705: the &lt;col&gt; tag is now XHTML compliant
- (thanks to Denny Shimkoski)
+- Request #16984: added a __toString() method, i.e. "echo $table;"
+ is now possible
+ (thanks to Andreas Sjöberg)
+- Bug #17073: enhanced E_STRICT compatibility
+ (thanks to Andrea Bakker and Daniel O'Connor)
</notes>
<contents>
<dir name="/">
View
2 tests/1.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$data[0][] = 'Test';
View
2 tests/10.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Foo';
$data[0][] = 'Bar';
View
2 tests/11.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$table->setAutoFill('N/A');
View
2 tests/12.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$table->setAutoGrow(true);
View
2 tests/13.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$data[0][] = 'Test';
$data[1][] = '';
View
2 tests/14.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Foo';
$data[0][] = 'Bar';
View
2 tests/15.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Test';
$data[0][] = 'Test';
View
2 tests/16.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Test';
$data[0][] = 'Test';
View
2 tests/17.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Test';
$data[0][] = 'Test';
View
2 tests/18.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$data[0][] = 'Test';
$data[0][] = 'Test';
View
2 tests/19.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$data[0][] = 'Test';
$data[0][] = 'Test';
View
2 tests/2.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$data[0][] = 'Test';
$data[0][] = 'Test';
View
2 tests/20.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$data[0][3] = 'Test';
$data[1][2] = 'Test';
View
2 tests/21.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$data[0][3] = 'Test';
$data[1][2] = 'Test';
View
2 tests/22.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$thead =& $table->getHeader();
$tfoot =& $table->getFooter();
View
2 tests/23.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$thead =& $table->getHeader();
$tbody =& $table->getBody();
View
2 tests/24.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$thead =& $table->getHeader();
$tfoot =& $table->getFooter();
View
2 tests/25.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$tbody =& $table->getBody();
$tfoot =& $table->getFooter();
View
2 tests/26.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$thead =& $table->getHeader();
$tfoot =& $table->getFooter();
View
2 tests/27.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table(null, null, false);
+$table = new HTML_Table(null, null, false);
$thead =& $table->getHeader();
$tfoot =& $table->getFooter();
View
2 tests/28.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table(null, null, false);
+$table = new HTML_Table(null, null, false);
$thead =& $table->getHeader();
$tfoot =& $table->getFooter();
View
2 tests/29.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$colgroup = '';
$attributes = 'span="3" class="group1"';
View
2 tests/3.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$data[0][] = 'Test';
$data[0][] = 'Test';
View
2 tests/30.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$colgroup = array('style="font-size: 120%;"', 'class="col2"', 'align="right"');
$attributes = 'span="3" class="group1"';
View
2 tests/31.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table();
+$table = new HTML_Table();
$colgroup = array('style="font-size:120%;"', 'class="col2"', 'align="right"');
$attributes = 'span="3" class="group1"';
View
2 tests/4.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Test';
$data[0][] = 'Test';
View
2 tests/5.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Foo';
$data[0][] = 'Bar';
View
2 tests/6.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Foo';
$data[0][] = 'Bar';
View
2 tests/7.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Foo';
$data[0][] = 'Bar';
View
2 tests/8.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('', 1);
+$table = new HTML_Table('', 1);
$data[0][] = 'Test';
View
2 tests/9.phpt
@@ -4,7 +4,7 @@
<?php
// $Id$
require_once 'HTML/Table.php';
-$table =& new HTML_Table('width="400"');
+$table = new HTML_Table('width="400"');
$data[0][] = 'Foo';
$data[0][] = 'Bar';

0 comments on commit e1c7a95

Please sign in to comment.