diff --git a/main/inc/lib/pear/HTML/Table.php b/main/inc/lib/pear/HTML/Table.php
index b973341d2c..28e9976d59 100755
--- a/main/inc/lib/pear/HTML/Table.php
+++ b/main/inc/lib/pear/HTML/Table.php
@@ -2,9 +2,11 @@
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
- * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient.
+ * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and
+ * efficient.
*
- * The PEAR::HTML_Table package provides methods for easy and efficient design of HTML tables.
+ * The PEAR::HTML_Table package provides methods for easy and efficient design
+ * of HTML tables.
* - Lots of customization options.
* - Tables can be modified at any time.
* - The logic is the same as standard HTML editors.
@@ -12,23 +14,49 @@
* - PHP code is shorter, easier to read and to maintain.
* - Tables options can be reused.
*
- * For auto filling of data and such then check out http://pear.php.net/package/HTML_Table_Matrix
+ * For auto filling of data and such then check out
+ * http://pear.php.net/package/HTML_Table_Matrix
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE:
*
- * PHP versions 4
+ * Copyright (c) 2005-2007, Adam Daniel ,
+ * Bertrand Mansion ,
+ * Mark Wiesemann
+ * All rights reserved.
*
- * LICENSE: This source file is subject to version 3.0 of the PHP license
- * that is available through the world-wide-web at the following URI:
- * http://www.php.net/license/3_0.txt. If you did not receive a copy of
- * the PHP License and are unable to obtain it through the web, please
- * send a note to license@php.net so we can mail you a copy immediately.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * 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
+ * documentation and/or other materials provided with the distribution.
+ * * 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
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
*
* @category HTML
* @package HTML_Table
* @author Adam Daniel
* @author Bertrand Mansion
- * @copyright 2005 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Table.php 9611 2006-10-20 11:47:56Z bmol $
+ * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
+ * @version CVS: $Id: Table.php,v 1.39 2007/06/25 16:44:43 wiesemann Exp $
* @link http://pear.php.net/package/HTML_Table
*/
@@ -43,7 +71,8 @@ require_once 'HTML/Table/Storage.php';
/**
* PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient.
*
- * The PEAR::HTML_Table package provides methods for easy and efficient design of HTML tables.
+ * The PEAR::HTML_Table package provides methods for easy and efficient design
+ * of HTML tables.
* - Lots of customization options.
* - Tables can be modified at any time.
* - The logic is the same as standard HTML editors.
@@ -51,26 +80,37 @@ require_once 'HTML/Table/Storage.php';
* - PHP code is shorter, easier to read and to maintain.
* - Tables options can be reused.
*
- * For auto filling of data and such then check out http://pear.php.net/package/HTML_Table_Matrix
+ * For auto filling of data and such then check out
+ * http://pear.php.net/package/HTML_Table_Matrix
*
* @category HTML
* @package HTML_Table
* @author Adam Daniel
* @author Bertrand Mansion
- * @copyright 2005 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @copyright 2005-2006 The PHP Group
+ * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version Release: @package_version@
* @link http://pear.php.net/package/HTML_Table
*/
class HTML_Table extends HTML_Common {
/**
- * Value to insert into empty cells
+ * Value to insert into empty cells. This is used as a default for
+ * newly-created tbodies.
* @var string
* @access private
*/
var $_autoFill = ' ';
+ /**
+ * Automatically adds a new row, column, or body if a given row, column, or
+ * body index does not exist.
+ * This is used as a default for newly-created tbodies.
+ * @var bool
+ * @access private
+ */
+ var $_autoGrow = true;
+
/**
* Array containing the table caption
* @var array
@@ -106,7 +146,14 @@ class HTML_Table extends HTML_Common {
* @var object
* @access private
*/
- var $_tbody = null;
+ var $_tbodies = array();
+
+ /**
+ * Number of bodies in the table
+ * @var int
+ * @access private
+ */
+ var $_tbodyCount = 0;
/**
* Whether to use , and or not
@@ -117,7 +164,8 @@ class HTML_Table extends HTML_Common {
/**
* Class constructor
- * @param array $attributes Associative array of table tag attributes
+ * @param array $attributes Associative array of table tag
+ * attributes
* @param int $tabOffset Tab offset of the table
* @param bool $useTGroups Whether to use , and
* or not
@@ -125,17 +173,12 @@ class HTML_Table extends HTML_Common {
*/
function HTML_Table($attributes = null, $tabOffset = 0, $useTGroups = false)
{
- $commonVersion = 1.7;
- if (HTML_Common::apiVersion() < $commonVersion) {
- return PEAR::raiseError('HTML_Table version ' . $this->apiVersion() . ' requires ' .
- "HTML_Common version $commonVersion or greater.", 0, PEAR_ERROR_TRIGGER);
- }
HTML_Common::HTML_Common($attributes, (int)$tabOffset);
$this->_useTGroups = (boolean)$useTGroups;
- $this->_tbody =& new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups);
+ $this->addBody();
if ($this->_useTGroups) {
- $this->_thead =& new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups);
- $this->_tfoot =& new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups);
+ $this->_thead =& new HTML_Table_Storage($tabOffset, $this->_useTGroups);
+ $this->_tfoot =& new HTML_Table_Storage($tabOffset, $this->_useTGroups);
}
}
@@ -143,6 +186,7 @@ class HTML_Table extends HTML_Common {
* Returns the API version
* @access public
* @return double
+ * @deprecated
*/
function apiVersion()
{
@@ -158,9 +202,11 @@ class HTML_Table extends HTML_Common {
{
if (is_null($this->_thead)) {
$this->_useTGroups = true;
- $this->_thead =& new HTML_Table_Storage($this->_attributes,
- $this->_tabOffset, $this->_useTGroups);
- $this->_tbody->setUseTGroups(true);
+ $this->_thead =& new HTML_Table_Storage($this->_tabOffset,
+ $this->_useTGroups);
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setUseTGroups(true);
+ }
}
return $this->_thead;
}
@@ -174,28 +220,81 @@ class HTML_Table extends HTML_Common {
{
if (is_null($this->_tfoot)) {
$this->_useTGroups = true;
- $this->_tfoot =& new HTML_Table_Storage($this->_attributes,
- $this->_tabOffset, $this->_useTGroups);
- $this->_tbody->setUseTGroups(true);
+ $this->_tfoot =& new HTML_Table_Storage($this->_tabOffset,
+ $this->_useTGroups);
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setUseTGroups(true);
+ }
}
return $this->_tfoot;
}
/**
- * Returns the HTML_Table_Storage object for
- * (or the whole table if is not used)
+ * Returns the HTML_Table_Storage object for the specified
+ * (or the whole table if is not used)
+ * @param int $body (optional) The index of the body to
+ * return.
* @access public
* @return object
+ * @throws PEAR_Error
*/
- function &getBody()
+ function &getBody($body = 0)
{
- return $this->_tbody;
+ $ret = $this->_adjustTbodyCount($body, 'getBody');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body];
+ }
+
+ /**
+ * Adds a table body and returns the body identifier
+ * @param mixed $attributes (optional) Associative array or
+ * string of table body attributes
+ * @access public
+ * @return int
+ */
+ function addBody($attributes = null)
+ {
+ if (!$this->_useTGroups && $this->_tbodyCount > 0) {
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setUseTGroups(true);
+ }
+ $this->_useTGroups = true;
+ }
+
+ $body = $this->_tbodyCount++;
+ $this->_tbodies[$body] =& new HTML_Table_Storage($this->_tabOffset,
+ $this->_useTGroups);
+ $this->_tbodies[$body]->setAutoFill($this->_autoFill);
+ $this->_tbodies[$body]->setAttributes($attributes);
+ return $body;
+ }
+
+ /**
+ * Adjusts the number of bodies
+ * @param int $body Body index
+ * @param string $method Name of calling method
+ * @access private
+ * @throws PEAR_Error
+ */
+ function _adjustTbodyCount($body, $method)
+ {
+ if ($this->_autoGrow) {
+ while ($this->_tbodyCount <= (int)$body) {
+ $this->addBody();
+ }
+ } else {
+ return PEAR::raiseError('Invalid body reference[' .
+ $body . '] in HTML_Table::' . $method);
+ }
}
/**
* Sets the table caption
* @param string $caption
- * @param mixed $attributes Associative array or string of table row attributes
+ * @param mixed $attributes Associative array or string of
+ * table row attributes
* @access public
*/
function setCaption($caption, $attributes = null)
@@ -207,9 +306,9 @@ class HTML_Table extends HTML_Common {
/**
* Sets the table columns group specifications, or removes existing ones.
*
- * @param mixed $colgroup (optional) Columns attributes
- * @param mixed $attributes (optional) Associative array or string
- * of table row attributes
+ * @param mixed $colgroup (optional) Columns attributes
+ * @param mixed $attributes (optional) Associative array or string
+ * of table row attributes
* @author Laurent Laville (pear at laurent-laville dot org)
* @access public
*/
@@ -226,72 +325,150 @@ class HTML_Table extends HTML_Common {
/**
* Sets the autoFill value
- * @param mixed $fill
+ * @param mixed $fill Whether autoFill should be enabled or not
+ * @param int $body (optional) The index of the body to set.
+ * Pass null to set for all bodies.
* @access public
+ * @throws PEAR_Error
*/
- function setAutoFill($fill)
+ function setAutoFill($fill, $body = null)
{
- $this->_tbody->setAutoFill($fill);
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'setAutoFill');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setAutoFill($fill);
+ } else {
+ $this->_autoFill = $fill;
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setAutoFill($fill);
+ }
+ }
}
/**
* Returns the autoFill value
+ * @param int $body (optional) The index of the body to get.
+ * Pass null to get the default for new bodies.
* @access public
* @return mixed
+ * @throws PEAR_Error
*/
- function getAutoFill()
+ function getAutoFill($body = null)
{
- return $this->_tbody->getAutoFill();
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'getAutoFill');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body]->getAutoFill();
+ } else {
+ return $this->_autoFill;
+ }
}
/**
* Sets the autoGrow value
- * @param bool $fill
+ * @param bool $grow Whether autoGrow should be enabled or not
+ * @param int $body (optional) The index of the body to set.
+ * Pass null to set for all bodies.
* @access public
+ * @throws PEAR_Error
*/
- function setAutoGrow($grow)
+ function setAutoGrow($grow, $body = null)
{
- $this->_tbody->setAutoGrow($grow);
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'setAutoGrow');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setAutoGrow($grow);
+ } else {
+ $this->_autoGrow = $grow;
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setAutoGrow($grow);
+ }
+ }
}
/**
* Returns the autoGrow value
+ * @param int $body (optional) The index of the body to get.
+ * Pass null to get the default for new bodies.
* @access public
* @return mixed
+ * @throws PEAR_Error
*/
- function getAutoGrow()
+ function getAutoGrow($body = null)
{
- return $this->_tbody->getAutoGrow();
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'getAutoGrow');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body]->getAutoGrow();
+ } else {
+ return $this->_autoGrow;
+ }
}
/**
- * Sets the number of rows in the table
- * @param int $rows
+ * Sets the number of rows in the table body
+ * @param int $rows The number of rows
+ * @param int $body (optional) The index of the body to set.
* @access public
+ * @throws PEAR_Error
*/
- function setRowCount($rows)
+ function setRowCount($rows, $body = 0)
{
- $this->_tbody->setRowCount($rows);
+ $ret = $this->_adjustTbodyCount($body, 'setRowCount');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setRowCount($rows);
}
/**
* Sets the number of columns in the table
- * @param int $cols
+ * @param int $cols The number of columns
+ * @param int $body (optional) The index of the body to set.
* @access public
+ * @throws PEAR_Error
*/
- function setColCount($cols)
+ function setColCount($cols, $body = 0)
{
- $this->_tbody->setColCount($cols);
+ $ret = $this->_adjustTbodyCount($body, 'setColCount');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setColCount($cols);
}
/**
* Returns the number of rows in the table
+ * @param int $body (optional) The index of the body to get.
+ * Pass null to get the total number of
+ * rows in all bodies.
* @access public
* @return int
+ * @throws PEAR_Error
*/
- function getRowCount()
+ function getRowCount($body = null)
{
- return $this->_tbody->getRowCount();
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'getRowCount');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body]->getRowCount();
+ } else {
+ $rowCount = 0;
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $rowCount += $this->_tbodies[$i]->getRowCount();
+ }
+ return $rowCount;
+ }
}
/**
@@ -300,36 +477,60 @@ class HTML_Table extends HTML_Common {
* If a row index is specified, the count will not take
* the spanned cells into account in the return value.
*
- * @param int Row index to serve for cols count
+ * @param int $row Row index to serve for cols count
+ * @param int $body (optional) The index of the body to get.
* @access public
* @return int
+ * @throws PEAR_Error
*/
- function getColCount($row = null)
+ function getColCount($row = null, $body = 0)
{
- return $this->_tbody->getColCount($row);
+ $ret = $this->_adjustTbodyCount($body, 'getColCount');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body]->getColCount($row);
}
/**
* Sets a rows type 'TH' or 'TD'
* @param int $row Row index
* @param string $type 'TH' or 'TD'
+ * @param int $body (optional) The index of the body to set.
* @access public
+ * @throws PEAR_Error
*/
-
- function setRowType($row, $type)
+ function setRowType($row, $type, $body = 0)
{
- $this->_tbody->setRowType($row, $type);
+ $ret = $this->_adjustTbodyCount($body, 'setRowType');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setRowType($row, $type);
}
/**
* Sets a columns type 'TH' or 'TD'
* @param int $col Column index
* @param string $type 'TH' or 'TD'
+ * @param int $body (optional) The index of the body to set.
+ * Pass null to set for all bodies.
* @access public
+ * @throws PEAR_Error
*/
- function setColType($col, $type)
+ function setColType($col, $type, $body = null)
{
- $this->_tbody->setColType($col, $type);
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'setColType');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setColType($col, $type);
+ } else {
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setColType($col, $type);
+ }
+ }
}
/**
@@ -338,30 +539,44 @@ class HTML_Table extends HTML_Common {
* If the given indices do not exist and autoGrow is true then the given
* row and/or col is automatically added. If autoGrow is false then an
* error is returned.
- * @param int $row Row index
- * @param int $col Column index
- * @param mixed $attributes Associative array or string of table row attributes
+ * @param int $row Row index
+ * @param int $col Column index
+ * @param mixed $attributes Associative array or string of
+ * table row attributes
+ * @param int $body (optional) The index of the body to set.
* @access public
* @throws PEAR_Error
*/
- function setCellAttributes($row, $col, $attributes)
+ function setCellAttributes($row, $col, $attributes, $body = 0)
{
- $ret = $this->_tbody->setCellAttributes($row, $col, $attributes);
+ $ret = $this->_adjustTbodyCount($body, 'setCellAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $ret = $this->_tbodies[$body]->setCellAttributes($row, $col, $attributes);
if (PEAR::isError($ret)) {
return $ret;
}
}
/**
- * Updates the cell attributes passed but leaves other existing attributes in tact
- * @param int $row Row index
- * @param int $col Column index
- * @param mixed $attributes Associative array or string of table row attributes
+ * Updates the cell attributes passed but leaves other existing attributes
+ * intact
+ * @param int $row Row index
+ * @param int $col Column index
+ * @param mixed $attributes Associative array or string of table row
+ * attributes
+ * @param int $body (optional) The index of the body to set.
* @access public
+ * @throws PEAR_Error
*/
- function updateCellAttributes($row, $col, $attributes)
+ function updateCellAttributes($row, $col, $attributes, $body = 0)
{
- $ret = $this->_tbody->updateCellAttributes($row, $col, $attributes);
+ $ret = $this->_adjustTbodyCount($body, 'updateCellAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $ret = $this->_tbodies[$body]->updateCellAttributes($row, $col, $attributes);
if (PEAR::isError($ret)) {
return $ret;
}
@@ -369,14 +584,20 @@ class HTML_Table extends HTML_Common {
/**
* Returns the attributes for a given cell
- * @param int $row Row index
- * @param int $col Column index
+ * @param int $row Row index
+ * @param int $col Column index
+ * @param int $body (optional) The index of the body to get.
* @return array
* @access public
+ * @throws PEAR_Error
*/
- function getCellAttributes($row, $col)
+ function getCellAttributes($row, $col, $body = 0)
{
- return $this->_tbody->getCellAttributes($row, $col);
+ $ret = $this->_adjustTbodyCount($body, 'getCellAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body]->getCellAttributes($row, $col);
}
/**
@@ -385,19 +606,26 @@ class HTML_Table extends HTML_Common {
* If the given indices do not exist and autoGrow is true then the given
* row and/or col is automatically added. If autoGrow is false then an
* error is returned.
- * @param int $row Row index
- * @param int $col Column index
- * @param mixed $contents May contain html or any object with a toHTML method;
- * if it is an array (with strings and/or objects), $col
- * will be used as start offset and the array elements
- * will be set to this and the following columns in $row
- * @param string $type (optional) Cell type either 'TH' or 'TD'
+ * @param int $row Row index
+ * @param int $col Column index
+ * @param mixed $contents May contain html or any object with a
+ * toHTML() method; it is an array (with
+ * strings and/or objects), $col will be
+ * used as start offset and the array
+ * elements will be set to this and the
+ * following columns in $row
+ * @param string $type (optional) Cell type either 'TH' or 'TD'
+ * @param int $body (optional) The index of the body to set.
* @access public
* @throws PEAR_Error
*/
- function setCellContents($row, $col, $contents, $type = 'TD')
+ function setCellContents($row, $col, $contents, $type = 'TD', $body = 0)
{
- $ret = $this->_tbody->setCellContents($row, $col, $contents, $type);
+ $ret = $this->_adjustTbodyCount($body, 'setCellContents');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $ret = $this->_tbodies[$body]->setCellContents($row, $col, $contents, $type);
if (PEAR::isError($ret)) {
return $ret;
}
@@ -407,59 +635,91 @@ class HTML_Table extends HTML_Common {
* Returns the cell contents for an existing cell
* @param int $row Row index
* @param int $col Column index
+ * @param int $body (optional) The index of the body to get.
* @access public
* @return mixed
+ * @throws PEAR_Error
*/
- function getCellContents($row, $col)
+ function getCellContents($row, $col, $body = 0)
{
- return $this->_tbody->getCellContents($row, $col);
+ $ret = $this->_adjustTbodyCount($body, 'getCellContents');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body]->getCellContents($row, $col);
}
/**
* Sets the contents of a header cell
- * @param int $row
- * @param int $col
- * @param mixed $contents
- * @param mixed $attributes Associative array or string of table row attributes
+ * @param int $row
+ * @param int $col
+ * @param mixed $contents
+ * @param mixed $attributes Associative array or string of
+ * table row attributes
+ * @param int $body (optional) The index of the body to set.
* @access public
+ * @throws PEAR_Error
*/
- function setHeaderContents($row, $col, $contents, $attributes = null)
+ function setHeaderContents($row, $col, $contents, $attributes = null,
+ $body = 0)
{
- $this->_tbody->setHeaderContents($row, $col, $contents, $attributes);
+ $ret = $this->_adjustTbodyCount($body, 'setHeaderContents');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setHeaderContents($row, $col, $contents, $attributes);
}
/**
* Adds a table row and returns the row identifier
- * @param array $contents (optional) Must be a indexed array of valid cell contents
- * @param mixed $attributes (optional) Associative array or string of table row attributes
- * This can also be an array of attributes, in which case the attributes
- * will be repeated in a loop.
- * @param string $type (optional) Cell type either 'th' or 'td'
- * @param bool $inTR false if attributes are to be applied in TD tags
- * true if attributes are to be applied in TR tag
+ * @param array $contents (optional) Must be a indexed array of
+ * valid cell contents
+ * @param mixed $attributes (optional) Associative array or string
+ * of table row attributes. This can also
+ * be an array of attributes, in which
+ * case the attributes will be repeated
+ * in a loop.
+ * @param string $type (optional) Cell type either 'th' or 'td'
+ * @param bool $inTR false if attributes are to be applied
+ * in TD tags; true if attributes are to
+ * �be applied in TR tag
+ * @param int $body (optional) The index of the body to use.
* @return int
* @access public
+ * @throws PEAR_Error
*/
- function addRow($contents = null, $attributes = null, $type = 'td', $inTR = false)
+ function addRow($contents = null, $attributes = null, $type = 'td',
+ $inTR = false, $body = 0)
{
- $ret = $this->_tbody->addRow($contents, $attributes, $type, $inTR);
+ $ret = $this->_adjustTbodyCount($body, 'addRow');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $ret = $this->_tbodies[$body]->addRow($contents, $attributes, $type, $inTR);
return $ret;
}
/**
* Sets the row attributes for an existing row
- * @param int $row Row index
- * @param mixed $attributes Associative array or string of table row attributes
- * This can also be an array of attributes, in which case the attributes
- * will be repeated in a loop.
- * @param bool $inTR false if attributes are to be applied in TD tags
- * true if attributes are to be applied in TR tag
+ * @param int $row Row index
+ * @param mixed $attributes Associative array or string of table row
+ * attributes. This can also be an array of
+ * attributes, in which case the attributes
+ * will be repeated in a loop.
+ * @param bool $inTR false if attributes are to be applied in
+ * TD tags; true if attributes are to be
+ * applied in TR tag
+ * @param int $body (optional) The index of the body to set.
* @access public
* @throws PEAR_Error
*/
- function setRowAttributes($row, $attributes, $inTR = false)
+ function setRowAttributes($row, $attributes, $inTR = false, $body = 0)
{
- $ret = $this->_tbody->setRowAttributes($row, $attributes, $inTR);
+ $ret = $this->_adjustTbodyCount($body, 'setRowAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $ret = $this->_tbodies[$body]->setRowAttributes($row, $attributes, $inTR);
if (PEAR::isError($ret)) {
return $ret;
}
@@ -467,16 +727,24 @@ class HTML_Table extends HTML_Common {
/**
* Updates the row attributes for an existing row
- * @param int $row Row index
- * @param mixed $attributes Associative array or string of table row attributes
- * @param bool $inTR false if attributes are to be applied in TD tags
- * true if attributes are to be applied in TR tag
+ * @param int $row Row index
+ * @param mixed $attributes Associative array or string of table row
+ * attributes
+ * @param bool $inTR false if attributes are to be applied in
+ * TD tags; true if attributes are to be
+ * applied in TR tag
+ * @param int $body (optional) The index of the body to set.
* @access public
* @throws PEAR_Error
*/
- function updateRowAttributes($row, $attributes = null, $inTR = false)
+ function updateRowAttributes($row, $attributes = null, $inTR = false,
+ $body = 0)
{
- $ret = $this->_tbody->updateRowAttributes($row, $attributes, $inTR);
+ $ret = $this->_adjustTbodyCount($body, 'updateRowAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $ret = $this->_tbodies[$body]->updateRowAttributes($row, $attributes, $inTR);
if (PEAR::isError($ret)) {
return $ret;
}
@@ -484,82 +752,180 @@ class HTML_Table extends HTML_Common {
/**
* Returns the attributes for a given row as contained in the TR tag
- * @param int $row Row index
+ * @param int $row Row index
+ * @param int $body (optional) The index of the body to get.
* @return array
* @access public
+ * @throws PEAR_Error
*/
- function getRowAttributes($row)
+ function getRowAttributes($row, $body = 0)
{
- return $this->_tbody->getRowAttributes($row);
+ $ret = $this->_adjustTbodyCount($body, 'getRowAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body]->getRowAttributes($row);
}
/**
* Alternates the row attributes starting at $start
- * @param int $start Row index of row in which alternating begins
- * @param mixed $attributes1 Associative array or string of table row attributes
- * @param mixed $attributes2 Associative array or string of table row attributes
- * @param bool $inTR false if attributes are to be applied in TD tags
- * true if attributes are to be applied in TR tag
- * @access public
+ * @param int $start Row index of row in which alternating
+ * begins
+ * @param mixed $attributes1 Associative array or string of table
+ * row attributes
+ * @param mixed $attributes2 Associative array or string of table
+ * row attributes
+ * @param bool $inTR false if attributes are to be applied
+ * in TD tags; true if attributes are to
+ * be applied in TR tag
+ * @param int $firstAttributes (optional) Which attributes should be
+ * applied to the first row, 1 or 2.
+ * @param int $body (optional) The index of the body to set.
+ * Pass null to set for all bodies.
+ * @access public
+ * @throws PEAR_Error
*/
- function altRowAttributes($start, $attributes1, $attributes2, $inTR = false)
+ function altRowAttributes($start, $attributes1, $attributes2, $inTR = false,
+ $firstAttributes = 1, $body = null)
{
- $this->_tbody->altRowAttributes($start, $attributes1, $attributes2, $inTR);
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'altRowAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->altRowAttributes($start, $attributes1,
+ $attributes2, $inTR, $firstAttributes);
+ } else {
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->altRowAttributes($start, $attributes1,
+ $attributes2, $inTR, $firstAttributes);
+ // if the tbody's row count is odd, toggle $firstAttributes to
+ // prevent the next tbody's first row from having the same
+ // attributes as this tbody's last row.
+ if ($this->_tbodies[$i]->getRowCount() % 2) {
+ $firstAttributes ^= 3;
+ }
+ }
+ }
}
/**
* Adds a table column and returns the column identifier
- * @param array $contents (optional) Must be a indexed array of valid cell contents
- * @param mixed $attributes (optional) Associative array or string of table row attributes
- * @param string $type (optional) Cell type either 'th' or 'td'
+ * @param array $contents (optional) Must be a indexed array of
+ * valid cell contents
+ * @param mixed $attributes (optional) Associative array or string
+ * of table row attributes
+ * @param string $type (optional) Cell type either 'th' or 'td'
+ * @param int $body (optional) The index of the body to use.
* @return int
* @access public
+ * @throws PEAR_Error
*/
- function addCol($contents = null, $attributes = null, $type = 'td')
+ function addCol($contents = null, $attributes = null, $type = 'td', $body = 0)
{
- return $this->_tbody->addCol($contents, $attributes, $type);
+ $ret = $this->_adjustTbodyCount($body, 'addCol');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ return $this->_tbodies[$body]->addCol($contents, $attributes, $type);
}
/**
* Sets the column attributes for an existing column
- * @param int $col Column index
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param int $col Column index
+ * @param mixed $attributes (optional) Associative array or string
+ * of table row attributes
+ * @param int $body (optional) The index of the body to set.
+ * Pass null to set for all bodies.
* @access public
+ * @throws PEAR_Error
*/
- function setColAttributes($col, $attributes = null)
+ function setColAttributes($col, $attributes = null, $body = null)
{
- $this->_tbody->setColAttributes($col, $attributes);
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'setColAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setColAttributes($col, $attributes);
+ } else {
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setColAttributes($col, $attributes);
+ }
+ }
}
/**
* Updates the column attributes for an existing column
- * @param int $col Column index
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param int $col Column index
+ * @param mixed $attributes (optional) Associative array or
+ * string of table row attributes
+ * @param int $body (optional) The index of the body to set.
+ * Pass null to set for all bodies.
* @access public
+ * @throws PEAR_Error
*/
- function updateColAttributes($col, $attributes = null)
+ function updateColAttributes($col, $attributes = null, $body = null)
{
- $this->_tbody->updateColAttributes($col, $attributes);
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'updateColAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->updateColAttributes($col, $attributes);
+ } else {
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->updateColAttributes($col, $attributes);
+ }
+ }
}
/**
* Sets the attributes for all cells
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param mixed $attributes (optional) Associative array or
+ * string of table row attributes
+ * @param int $body (optional) The index of the body to set.
+ * Pass null to set for all bodies.
* @access public
+ * @throws PEAR_Error
*/
- function setAllAttributes($attributes = null)
+ function setAllAttributes($attributes = null, $body = null)
{
- $this->_tbody->setAllAttributes($attributes);
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'setAllAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->setAllAttributes($attributes);
+ } else {
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setAllAttributes($attributes);
+ }
+ }
}
/**
* Updates the attributes for all cells
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param mixed $attributes (optional) Associative array or string
+ * of table row attributes
+ * @param int $body (optional) The index of the body to set.
+ * Pass null to set for all bodies.
* @access public
+ * @throws PEAR_Error
*/
- function updateAllAttributes($attributes = null)
+ function updateAllAttributes($attributes = null, $body = null)
{
- $this->_tbody->updateAllAttributes($attributes);
+ if (!is_null($body)) {
+ $ret = $this->_adjustTbodyCount($body, 'updateAllAttributes');
+ if (PEAR::isError($ret)) {
+ return $ret;
+ }
+ $this->_tbodies[$body]->updateAllAttributes($attributes);
+ } else {
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->updateAllAttributes($attributes);
+ }
+ }
}
/**
@@ -573,84 +939,99 @@ class HTML_Table extends HTML_Common {
$tabs = $this->_getTabs();
$tab = $this->_getTab();
$lnEnd = $this->_getLineEnd();
+ $tBodyColCounts = array();
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $tBodyColCounts[] = $this->_tbodies[$i]->getColCount();
+ }
+ $tBodyMaxColCount = 0;
+ if (count($tBodyColCounts) > 0) {
+ $tBodyMaxColCount = max($tBodyColCounts);
+ }
if ($this->_comment) {
$strHtml .= $tabs . "" . $lnEnd;
}
- $strHtml .=
- $tabs . '_getAttrString($this->_attributes) . '>' . $lnEnd;
- if (!empty($this->_caption)) {
- $attr = $this->_caption['attr'];
- $contents = $this->_caption['contents'];
- $strHtml .= $tabs . $tab . '_getAttrString($attr) . '>';
- if (is_array($contents)) {
- $contents = implode(', ', $contents);
+ if ($this->getRowCount() > 0 && $tBodyMaxColCount > 0) {
+ $strHtml .=
+ $tabs . '_getAttrString($this->_attributes) . '>' . $lnEnd;
+ if (!empty($this->_caption)) {
+ $attr = $this->_caption['attr'];
+ $contents = $this->_caption['contents'];
+ $strHtml .= $tabs . $tab . '_getAttrString($attr) . '>';
+ if (is_array($contents)) {
+ $contents = implode(', ', $contents);
+ }
+ $strHtml .= $contents;
+ $strHtml .= '' . $lnEnd;
}
- $strHtml .= $contents;
- $strHtml .= '' . $lnEnd;
- }
- if (!empty($this->_colgroup)) {
- foreach ($this->_colgroup as $g => $col) {
- $attr = $this->_colgroup[$g]['attr'];
- $contents = $this->_colgroup[$g]['contents'];
- $strHtml .= $tabs . $tab . '_getAttrString($attr) . '>';
- if (!empty($contents)) {
- $strHtml .= $lnEnd;
- if (!is_array($contents)) {
- $contents = array($contents);
- }
- foreach ($contents as $a => $colAttr) {
- $attr = $this->_parseAttributes($colAttr);
- $strHtml .= $tabs . $tab . $tab . '_getAttrString($attr) . '>' . $lnEnd;
+ if (!empty($this->_colgroup)) {
+ foreach ($this->_colgroup as $g => $col) {
+ $attr = $this->_colgroup[$g]['attr'];
+ $contents = $this->_colgroup[$g]['contents'];
+ $strHtml .= $tabs . $tab . '_getAttrString($attr) . '>';
+ if (!empty($contents)) {
+ $strHtml .= $lnEnd;
+ if (!is_array($contents)) {
+ $contents = array($contents);
+ }
+ foreach ($contents as $a => $colAttr) {
+ $attr = $this->_parseAttributes($colAttr);
+ $strHtml .= $tabs . $tab . $tab . '_getAttrString($attr) . ' />' . $lnEnd;
+ }
+ $strHtml .= $tabs . $tab;
}
- $strHtml .= $tabs . $tab;
+ $strHtml .= '' . $lnEnd;
}
- $strHtml .= '' . $lnEnd;
- }
- }
- if ($this->_useTGroups) {
- $tHeadColCount = 0;
- if ($this->_thead !== null) {
- $tHeadColCount = $this->_thead->getColCount();
- }
- $tFootColCount = 0;
- if ($this->_tfoot !== null) {
- $tFootColCount = $this->_tfoot->getColCount();
- }
- $tBodyColCount = 0;
- if ($this->_tbody !== null) {
- $tBodyColCount = $this->_tbody->getColCount();
}
- $maxColCount = max($tHeadColCount, $tFootColCount, $tBodyColCount);
- if ($this->_thead !== null) {
- $this->_thead->setColCount($maxColCount);
- if ($this->_thead->getRowCount() > 0) {
- $strHtml .= $tabs . $tab . '' . $lnEnd;
- $strHtml .= $this->_thead->toHtml($tabs, $tab);
- $strHtml .= $tabs . $tab . '' . $lnEnd;
+ if ($this->_useTGroups) {
+ $tHeadColCount = 0;
+ if ($this->_thead !== null) {
+ $tHeadColCount = $this->_thead->getColCount();
}
- }
- if ($this->_tfoot !== null) {
- $this->_tfoot->setColCount($maxColCount);
- if ($this->_tfoot->getRowCount() > 0) {
- $strHtml .= $tabs . $tab . '' . $lnEnd;
- $strHtml .= $this->_tfoot->toHtml($tabs, $tab);
- $strHtml .= $tabs . $tab . '' . $lnEnd;
+ $tFootColCount = 0;
+ if ($this->_tfoot !== null) {
+ $tFootColCount = $this->_tfoot->getColCount();
}
- }
- if ($this->_tbody !== null) {
- $this->_tbody->setColCount($maxColCount);
- if ($this->_tbody->getRowCount() > 0) {
- $strHtml .= $tabs . $tab . '' . $lnEnd;
- $strHtml .= $this->_tbody->toHtml($tabs, $tab);
- $strHtml .= $tabs . $tab . '' . $lnEnd;
+ $maxColCount = max($tHeadColCount, $tFootColCount, $tBodyMaxColCount);
+ if ($this->_thead !== null) {
+ $this->_thead->setColCount($maxColCount);
+ if ($this->_thead->getRowCount() > 0) {
+ $strHtml .= $tabs . $tab . '_getAttrString($this->_thead->_attributes) .
+ '>' . $lnEnd;
+ $strHtml .= $this->_thead->toHtml($tabs, $tab);
+ $strHtml .= $tabs . $tab . '' . $lnEnd;
+ }
+ }
+ if ($this->_tfoot !== null) {
+ $this->_tfoot->setColCount($maxColCount);
+ if ($this->_tfoot->getRowCount() > 0) {
+ $strHtml .= $tabs . $tab . '_getAttrString($this->_tfoot->_attributes) .
+ '>' . $lnEnd;
+ $strHtml .= $this->_tfoot->toHtml($tabs, $tab);
+ $strHtml .= $tabs . $tab . '' . $lnEnd;
+ }
+ }
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $this->_tbodies[$i]->setColCount($maxColCount);
+ if ($this->_tbodies[$i]->getRowCount() > 0) {
+ $strHtml .= $tabs . $tab . '_getAttrString($this->_tbodies[$i]->_attributes) .
+ '>' . $lnEnd;
+ $strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab);
+ $strHtml .= $tabs . $tab . '' . $lnEnd;
+ }
+ }
+ } else {
+ for ($i = 0; $i < $this->_tbodyCount; $i++) {
+ $strHtml .= $this->_tbodies[$i]->toHtml($tabs, $tab);
}
}
- } else {
- $strHtml .= $this->_tbody->toHtml($tabs, $tab);
+ $strHtml .= $tabs . '
' . $lnEnd;
}
- $strHtml .= $tabs . '
' . $lnEnd;
return $strHtml;
}
}
-?>
\ No newline at end of file
+
+?>
diff --git a/main/inc/lib/pear/HTML/Table/Storage.php b/main/inc/lib/pear/HTML/Table/Storage.php
index bb7cb77e60..087c2f330f 100755
--- a/main/inc/lib/pear/HTML/Table/Storage.php
+++ b/main/inc/lib/pear/HTML/Table/Storage.php
@@ -8,21 +8,45 @@
* more than one instance, it can be used for grouping the table into the
* parts ..., ... and ....
*
- * PHP versions 4
+ * PHP versions 4 and 5
*
- * LICENSE: This source file is subject to version 3.0 of the PHP license
- * that is available through the world-wide-web at the following URI:
- * http://www.php.net/license/3_0.txt. If you did not receive a copy of
- * the PHP License and are unable to obtain it through the web, please
- * send a note to license@php.net so we can mail you a copy immediately.
+ * LICENSE:
+ *
+ * Copyright (c) 2005-2007, Adam Daniel ,
+ * Bertrand Mansion ,
+ * Mark Wiesemann
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * 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
+ * documentation and/or other materials provided with the distribution.
+ * * 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
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package HTML_Table
* @author Adam Daniel
* @author Bertrand Mansion
- * @copyright 2005 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Storage.php,v 1.9 2006/09/18 20:06:45 wiesemann Exp $
+ * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
+ * @version CVS: $Id: Storage.php,v 1.16 2007/04/29 16:31:06 wiesemann Exp $
* @link http://pear.php.net/package/HTML_Table
*/
@@ -38,8 +62,8 @@
* @author Adam Daniel
* @author Bertrand Mansion
* @author Mark Wiesemann
- * @copyright 2005 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @copyright 2005-2006 The PHP Group
+ * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version Release: @package_version@
* @link http://pear.php.net/package/HTML_Table
*/
@@ -53,7 +77,8 @@ class HTML_Table_Storage extends HTML_Common {
var $_autoFill = ' ';
/**
- * Automatically adds a new row or column if a given row or column index does not exist
+ * Automatically adds a new row or column if a given row or column index
+ * does not exist
* @var bool
* @access private
*/
@@ -96,15 +121,14 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Class constructor
- * @param array $attributes Associative array of table tag attributes
* @param int $tabOffset
* @param bool $useTGroups Whether to use , and
* or not
* @access public
*/
- function HTML_Table_Storage($attributes = null, $tabOffset = 0, $useTGroups = false)
+ function HTML_Table_Storage($tabOffset = 0, $useTGroups = false)
{
- HTML_Common::HTML_Common($attributes, (int)$tabOffset);
+ HTML_Common::HTML_Common(null, (int)$tabOffset);
$this->_useTGroups = (boolean)$useTGroups;
}
@@ -257,13 +281,18 @@ class HTML_Table_Storage extends HTML_Common {
* error is returned.
* @param int $row Row index
* @param int $col Column index
- * @param mixed $attributes Associative array or string of table row attributes
+ * @param mixed $attributes Associative array or string of table
+ * row attributes
* @access public
* @throws PEAR_Error
*/
function setCellAttributes($row, $col, $attributes)
{
- if (isset($this->_structure[$row][$col]) && $this->_structure[$row][$col] == '__SPANNED__') return;
+ if ( isset($this->_structure[$row][$col])
+ && $this->_structure[$row][$col] == '__SPANNED__'
+ ) {
+ return;
+ }
$attributes = $this->_parseAttributes($attributes);
$err = $this->_adjustEnds($row, $col, 'setCellAttributes', $attributes);
if (PEAR::isError($err)) {
@@ -274,15 +303,21 @@ class HTML_Table_Storage extends HTML_Common {
}
/**
- * Updates the cell attributes passed but leaves other existing attributes in tact
+ * Updates the cell attributes passed but leaves other existing attributes
+ * intact
* @param int $row Row index
* @param int $col Column index
- * @param mixed $attributes Associative array or string of table row attributes
+ * @param mixed $attributes Associative array or string of table row
+ * attributes
* @access public
*/
function updateCellAttributes($row, $col, $attributes)
{
- if (isset($this->_structure[$row][$col]) && $this->_structure[$row][$col] == '__SPANNED__') return;
+ if ( isset($this->_structure[$row][$col])
+ && $this->_structure[$row][$col] == '__SPANNED__'
+ ) {
+ return;
+ }
$attributes = $this->_parseAttributes($attributes);
$err = $this->_adjustEnds($row, $col, 'updateCellAttributes', $attributes);
if (PEAR::isError($err)) {
@@ -301,7 +336,9 @@ class HTML_Table_Storage extends HTML_Common {
*/
function getCellAttributes($row, $col)
{
- if (isset($this->_structure[$row][$col]) && $this->_structure[$row][$col] != '__SPANNED__') {
+ if ( isset($this->_structure[$row][$col])
+ && $this->_structure[$row][$col] != '__SPANNED__'
+ ) {
return $this->_structure[$row][$col]['attr'];
} elseif (!isset($this->_structure[$row][$col])) {
return PEAR::raiseError('Invalid table cell reference[' .
@@ -318,10 +355,12 @@ class HTML_Table_Storage extends HTML_Common {
* error is returned.
* @param int $row Row index
* @param int $col Column index
- * @param mixed $contents May contain html or any object with a toHTML method;
- * if it is an array (with strings and/or objects), $col
- * will be used as start offset and the array elements
- * will be set to this and the following columns in $row
+ * @param mixed $contents May contain html or any object with a
+ * toHTML() method; if it is an array (with
+ * strings and/or objects), $col will be used
+ * as start offset and the array elements will
+ * be set to this and the following columns
+ * in $row
* @param string $type (optional) Cell type either 'TH' or 'TD'
* @access public
* @throws PEAR_Error
@@ -330,7 +369,8 @@ class HTML_Table_Storage extends HTML_Common {
{
if (is_array($contents)) {
foreach ($contents as $singleContent) {
- $ret = $this->_setSingleCellContents($row, $col, $singleContent, $type);
+ $ret = $this->_setSingleCellContents($row, $col, $singleContent,
+ $type);
if (PEAR::isError($ret)) {
return $ret;
}
@@ -352,17 +392,23 @@ class HTML_Table_Storage extends HTML_Common {
* error is returned.
* @param int $row Row index
* @param int $col Column index
- * @param mixed $contents May contain html or any object with a toHTML method;
- * if it is an array (with strings and/or objects), $col
- * will be used as start offset and the array elements
- * will be set to this and the following columns in $row
+ * @param mixed $contents May contain html or any object with a
+ * toHTML() method; if it is an array (with
+ * strings and/or objects), $col will be used
+ * as start offset and the array elements will
+ * be set to this and the following columns
+ * in $row
* @param string $type (optional) Cell type either 'TH' or 'TD'
* @access private
* @throws PEAR_Error
*/
function _setSingleCellContents($row, $col, $contents, $type = 'TD')
{
- if (isset($this->_structure[$row][$col]) && $this->_structure[$row][$col] == '__SPANNED__') return;
+ if ( isset($this->_structure[$row][$col])
+ && $this->_structure[$row][$col] == '__SPANNED__'
+ ) {
+ return;
+ }
$err = $this->_adjustEnds($row, $col, 'setCellContents');
if (PEAR::isError($err)) {
return $err;
@@ -380,7 +426,11 @@ class HTML_Table_Storage extends HTML_Common {
*/
function getCellContents($row, $col)
{
- if (isset($this->_structure[$row][$col]) && $this->_structure[$row][$col] == '__SPANNED__') return;
+ if ( isset($this->_structure[$row][$col])
+ && $this->_structure[$row][$col] == '__SPANNED__'
+ ) {
+ return;
+ }
if (!isset($this->_structure[$row][$col])) {
return PEAR::raiseError('Invalid table cell reference[' .
$row . '][' . $col . '] in HTML_Table::getCellContents');
@@ -393,7 +443,8 @@ class HTML_Table_Storage extends HTML_Common {
* @param int $row
* @param int $col
* @param mixed $contents
- * @param mixed $attributes Associative array or string of table row attributes
+ * @param mixed $attributes Associative array or string of table row
+ * attributes
* @access public
*/
function setHeaderContents($row, $col, $contents, $attributes = null)
@@ -406,20 +457,27 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Adds a table row and returns the row identifier
- * @param array $contents (optional) Must be a indexed array of valid cell contents
- * @param mixed $attributes (optional) Associative array or string of table row attributes
- * This can also be an array of attributes, in which case the attributes
- * will be repeated in a loop.
+ * @param array $contents (optional) Must be a indexed array of valid
+ * cell contents
+ * @param mixed $attributes (optional) Associative array or string of
+ * table row attributes. This can
+ * also be an array of attributes,
+ * in which case the attributes
+ * will be repeated in a loop.
* @param string $type (optional) Cell type either 'th' or 'td'
- * @param bool $inTR false if attributes are to be applied in TD tags
- * true if attributes are to be applied in TR tag
+ * @param bool $inTR false if attributes are to be
+ * applied in TD tags; true if
+ * attributes are to be applied in
+ * TR tag
* @return int
* @access public
*/
- function addRow($contents = null, $attributes = null, $type = 'td', $inTR = false)
+ function addRow($contents = null, $attributes = null, $type = 'td',
+ $inTR = false)
{
if (isset($contents) && !is_array($contents)) {
- return PEAR::raiseError('First parameter to HTML_Table::addRow must be an array');
+ return PEAR::raiseError('First parameter to HTML_Table::addRow ' .
+ 'must be an array');
}
if (is_null($contents)) {
$contents = array();
@@ -441,11 +499,13 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Sets the row attributes for an existing row
* @param int $row Row index
- * @param mixed $attributes Associative array or string of table row attributes
- * This can also be an array of attributes, in which case the attributes
- * will be repeated in a loop.
- * @param bool $inTR false if attributes are to be applied in TD tags
- * true if attributes are to be applied in TR tag
+ * @param mixed $attributes Associative array or string of table
+ * row attributes. This can also be an
+ * array of attributes, in which case the
+ * attributes will be repeated in a loop.
+ * @param bool $inTR false if attributes are to be applied
+ * in TD tags; true if attributes are to
+ * be applied in TR tag
* @access public
* @throws PEAR_Error
*/
@@ -474,9 +534,11 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Updates the row attributes for an existing row
* @param int $row Row index
- * @param mixed $attributes Associative array or string of table row attributes
- * @param bool $inTR false if attributes are to be applied in TD tags
- * true if attributes are to be applied in TR tag
+ * @param mixed $attributes Associative array or string of table
+ * row attributes
+ * @param bool $inTR false if attributes are to be applied
+ * in TD tags; true if attributes are to
+ * be applied in TR tag
* @access public
* @throws PEAR_Error
*/
@@ -518,25 +580,38 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Alternates the row attributes starting at $start
- * @param int $start Row index of row in which alternating begins
- * @param mixed $attributes1 Associative array or string of table row attributes
- * @param mixed $attributes2 Associative array or string of table row attributes
- * @param bool $inTR false if attributes are to be applied in TD tags
- * true if attributes are to be applied in TR tag
+ * @param int $start Row index of row in which alternating
+ * begins
+ * @param mixed $attributes1 Associative array or string of table
+ * row attributes
+ * @param mixed $attributes2 Associative array or string of table
+ * row attributes
+ * @param bool $inTR false if attributes are to be applied
+ * in TD tags; true if attributes are to
+ * be applied in TR tag
+ * @param int $firstAttributes (optional) Which attributes should be
+ * applied to the first row, 1 or 2.
* @access public
*/
- function altRowAttributes($start, $attributes1, $attributes2, $inTR = false)
+ function altRowAttributes($start, $attributes1, $attributes2, $inTR = false,
+ $firstAttributes = 1)
{
- for ($row = $start ; $row < $this->_rows ; $row++) {
- $attributes = ( ($row + $start) % 2 == 0 ) ? $attributes1 : $attributes2;
+ for ($row = $start; $row < $this->_rows; $row++) {
+ if (($row + $start + ($firstAttributes - 1)) % 2 == 0) {
+ $attributes = $attributes1;
+ } else {
+ $attributes = $attributes2;
+ }
$this->updateRowAttributes($row, $attributes, $inTR);
}
}
/**
* Adds a table column and returns the column identifier
- * @param array $contents (optional) Must be a indexed array of valid cell contents
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param array $contents (optional) Must be a indexed array of valid
+ * cell contents
+ * @param mixed $attributes (optional) Associative array or string of
+ * table row attributes
* @param string $type (optional) Cell type either 'th' or 'td'
* @return int
* @access public
@@ -544,7 +619,8 @@ class HTML_Table_Storage extends HTML_Common {
function addCol($contents = null, $attributes = null, $type = 'td')
{
if (isset($contents) && !is_array($contents)) {
- return PEAR::raiseError('First parameter to HTML_Table::addCol must be an array');
+ return PEAR::raiseError('First parameter to HTML_Table::addCol ' .
+ 'must be an array');
}
if (is_null($contents)) {
$contents = array();
@@ -566,7 +642,8 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Sets the column attributes for an existing column
* @param int $col Column index
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param mixed $attributes (optional) Associative array or string
+ * of table row attributes
* @access public
*/
function setColAttributes($col, $attributes = null)
@@ -585,7 +662,8 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Updates the column attributes for an existing column
* @param int $col Column index
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param mixed $attributes (optional) Associative array or string
+ * of table row attributes
* @access public
*/
function updateColAttributes($col, $attributes = null)
@@ -603,7 +681,8 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Sets the attributes for all cells
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param mixed $attributes (optional) Associative array or
+ * string of table row attributes
* @access public
*/
function setAllAttributes($attributes = null)
@@ -615,7 +694,8 @@ class HTML_Table_Storage extends HTML_Common {
/**
* Updates the attributes for all cells
- * @param mixed $attributes (optional) Associative array or string of table row attributes
+ * @param mixed $attributes (optional) Associative array or
+ * string of table row attributes
* @access public
*/
function updateAllAttributes($attributes = null)
@@ -645,53 +725,55 @@ class HTML_Table_Storage extends HTML_Common {
} else {
$extraTab = '';
}
- for ($i = 0 ; $i < $this->_rows ; $i++) {
- $attr = '';
- if (isset($this->_structure[$i]['attr'])) {
- $attr = $this->_getAttrString($this->_structure[$i]['attr']);
- }
- $strHtml .= $tabs .$tab . $extraTab . '' . $lnEnd;
- for ($j = 0 ; $j < $this->_cols ; $j++) {
- $attr = '';
- $contents = '';
- $type = 'td';
- if (isset($this->_structure[$i][$j]) && $this->_structure[$i][$j] == '__SPANNED__') {
- continue;
+ if ($this->_cols > 0) {
+ for ($i = 0 ; $i < $this->_rows ; $i++) {
+ $attr = '';
+ if (isset($this->_structure[$i]['attr'])) {
+ $attr = $this->_getAttrString($this->_structure[$i]['attr']);
}
- if (isset($this->_structure[$i][$j]['type'])) {
- $type = (strtolower($this->_structure[$i][$j]['type']) == 'th' ? 'th' : 'td');
- }
- if (isset($this->_structure[$i][$j]['attr'])) {
- $attr = $this->_structure[$i][$j]['attr'];
- }
- if (isset($this->_structure[$i][$j]['contents'])) {
- $contents = $this->_structure[$i][$j]['contents'];
- }
- $strHtml .= $tabs . $tab . $tab . $extraTab . "<$type" . $this->_getAttrString($attr) . '>';
- if (is_object($contents)) {
- // changes indent and line end settings on nested tables
- if (is_subclass_of($contents, 'html_common')) {
- $contents->setTab($tab . $extraTab);
- $contents->setTabOffset($this->_tabOffset + 3);
- $contents->_nestLevel = $this->_nestLevel + 1;
- $contents->setLineEnd($this->_getLineEnd());
+ $strHtml .= $tabs .$tab . $extraTab . '
' . $lnEnd;
+ for ($j = 0 ; $j < $this->_cols ; $j++) {
+ $attr = '';
+ $contents = '';
+ $type = 'td';
+ if (isset($this->_structure[$i][$j]) && $this->_structure[$i][$j] == '__SPANNED__') {
+ continue;
}
- if (method_exists($contents, 'toHtml')) {
- $contents = $contents->toHtml();
- } elseif (method_exists($contents, 'toString')) {
- $contents = $contents->toString();
+ if (isset($this->_structure[$i][$j]['type'])) {
+ $type = (strtolower($this->_structure[$i][$j]['type']) == 'th' ? 'th' : 'td');
}
+ if (isset($this->_structure[$i][$j]['attr'])) {
+ $attr = $this->_structure[$i][$j]['attr'];
+ }
+ if (isset($this->_structure[$i][$j]['contents'])) {
+ $contents = $this->_structure[$i][$j]['contents'];
+ }
+ $strHtml .= $tabs . $tab . $tab . $extraTab . "<$type" . $this->_getAttrString($attr) . '>';
+ if (is_object($contents)) {
+ // changes indent and line end settings on nested tables
+ if (is_subclass_of($contents, 'html_common')) {
+ $contents->setTab($tab . $extraTab);
+ $contents->setTabOffset($this->_tabOffset + 3);
+ $contents->_nestLevel = $this->_nestLevel + 1;
+ $contents->setLineEnd($this->_getLineEnd());
+ }
+ if (method_exists($contents, 'toHtml')) {
+ $contents = $contents->toHtml();
+ } elseif (method_exists($contents, 'toString')) {
+ $contents = $contents->toString();
+ }
+ }
+ if (is_array($contents)) {
+ $contents = implode(', ', $contents);
+ }
+ if (isset($this->_autoFill) && $contents === '') {
+ $contents = $this->_autoFill;
+ }
+ $strHtml .= $contents;
+ $strHtml .= "$type>" . $lnEnd;
}
- if (is_array($contents)) {
- $contents = implode(', ', $contents);
- }
- if (isset($this->_autoFill) && $contents === '') {
- $contents = $this->_autoFill;
- }
- $strHtml .= $contents;
- $strHtml .= "$type>" . $lnEnd;
+ $strHtml .= $tabs . $tab . $extraTab . '
' . $lnEnd;
}
- $strHtml .= $tabs . $tab . $extraTab . '' . $lnEnd;
}
return $strHtml;
}
@@ -784,4 +866,4 @@ class HTML_Table_Storage extends HTML_Common {
}
}
-?>
\ No newline at end of file
+?>