/usr/share/php/HTML/Table/Storage.php is in php-html-table 1.8.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Storage class for HTML::Table data
*
* This class stores data for tables built with HTML_Table. When having
* more than one instance, it can be used for grouping the table into the
* parts <thead>...</thead>, <tfoot>...</tfoot> and <tbody>...</tbody>.
*
* 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>
* 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 <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Storage.php 234674 2007-04-29 16:31:06Z wiesemann $
* @link http://pear.php.net/package/HTML_Table
*/
/**
* Storage class for HTML::Table data
*
* This class stores data for tables built with HTML_Table. When having
* more than one instance, it can be used for grouping the table into the
* parts <thead>...</thead>, <tfoot>...</tfoot> and <tbody>...</tbody>.
*
* @category HTML
* @package HTML_Table
* @author Adam Daniel <adaniel1@eesus.jnj.com>
* @author Bertrand Mansion <bmansion@mamasam.com>
* @author Mark Wiesemann <wiesemann@php.net>
* @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_Storage extends HTML_Common {
/**
* Value to insert into empty cells
* @var string
* @access private
*/
var $_autoFill = ' ';
/**
* Automatically adds a new row or column if a given row or column index
* does not exist
* @var bool
* @access private
*/
var $_autoGrow = true;
/**
* Array containing the table structure
* @var array
* @access private
*/
var $_structure = array();
/**
* Number of rows composing in the table
* @var int
* @access private
*/
var $_rows = 0;
/**
* Number of column composing the table
* @var int
* @access private
*/
var $_cols = 0;
/**
* Tracks the level of nested tables
* @var int
* @access private
*/
var $_nestLevel = 0;
/**
* Whether to use <thead>, <tfoot> and <tbody> or not
* @var bool
* @access private
*/
var $_useTGroups = false;
/**
* Class constructor
* @param int $tabOffset
* @param bool $useTGroups Whether to use <thead>, <tfoot> and
* <tbody> or not
* @access public
*/
function HTML_Table_Storage($tabOffset = 0, $useTGroups = false)
{
HTML_Common::HTML_Common(null, (int)$tabOffset);
$this->_useTGroups = (boolean)$useTGroups;
}
/**
* Sets the useTGroups value
* @param boolean $useTGroups
* @access public
*/
function setUseTGroups($useTGroups)
{
$this->_useTGroups = $useTGroups;
}
/**
* Returns the useTGroups value
* @access public
* @return boolean
*/
function getUseTGroups()
{
return $this->_useTGroups;
}
/**
* Sets the autoFill value
* @param mixed $fill
* @access public
*/
function setAutoFill($fill)
{
$this->_autoFill = $fill;
}
/**
* Returns the autoFill value
* @access public
* @return mixed
*/
function getAutoFill()
{
return $this->_autoFill;
}
/**
* Sets the autoGrow value
* @param bool $fill
* @access public
*/
function setAutoGrow($grow)
{
$this->_autoGrow = $grow;
}
/**
* Returns the autoGrow value
* @access public
* @return mixed
*/
function getAutoGrow()
{
return $this->_autoGrow;
}
/**
* Sets the number of rows in the table
* @param int $rows
* @access public
*/
function setRowCount($rows)
{
$this->_rows = $rows;
}
/**
* Sets the number of columns in the table
* @param int $cols
* @access public
*/
function setColCount($cols)
{
$this->_cols = $cols;
}
/**
* Returns the number of rows in the table
* @access public
* @return int
*/
function getRowCount()
{
return $this->_rows;
}
/**
* Gets the number of columns in the table
*
* 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
* @access public
* @return int
*/
function getColCount($row = null)
{
if (!is_null($row)) {
$count = 0;
foreach ($this->_structure[$row] as $cell) {
if (is_array($cell)) {
$count++;
}
}
return $count;
}
return $this->_cols;
}
/**
* Sets a rows type 'TH' or 'TD'
* @param int $row Row index
* @param string $type 'TH' or 'TD'
* @access public
*/
function setRowType($row, $type)
{
for ($counter = 0; $counter < $this->_cols; $counter++) {
$this->_structure[$row][$counter]['type'] = $type;
}
}
/**
* Sets a columns type 'TH' or 'TD'
* @param int $col Column index
* @param string $type 'TH' or 'TD'
* @access public
*/
function setColType($col, $type)
{
for ($counter = 0; $counter < $this->_rows; $counter++) {
$this->_structure[$counter][$col]['type'] = $type;
}
}
/**
* Sets the cell attributes for an existing cell.
*
* 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
* @access public
* @throws PEAR_Error
*/
function setCellAttributes($row, $col, $attributes)
{
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)) {
return $err;
}
$this->_structure[$row][$col]['attr'] = $attributes;
$this->_updateSpanGrid($row, $col);
}
/**
* 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
* @access public
*/
function updateCellAttributes($row, $col, $attributes)
{
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)) {
return $err;
}
$this->_updateAttrArray($this->_structure[$row][$col]['attr'], $attributes);
$this->_updateSpanGrid($row, $col);
}
/**
* Returns the attributes for a given cell
* @param int $row Row index
* @param int $col Column index
* @return array
* @access public
*/
function getCellAttributes($row, $col)
{
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[' .
$row . '][' . $col . '] in HTML_Table::getCellAttributes');
}
return;
}
/**
* Sets the cell contents for an existing cell
*
* 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'
* @access public
* @throws PEAR_Error
*/
function setCellContents($row, $col, $contents, $type = 'TD')
{
if (is_array($contents)) {
foreach ($contents as $singleContent) {
$ret = $this->_setSingleCellContents($row, $col, $singleContent,
$type);
if (PEAR::isError($ret)) {
return $ret;
}
$col++;
}
} else {
$ret = $this->_setSingleCellContents($row, $col, $contents, $type);
if (PEAR::isError($ret)) {
return $ret;
}
}
}
/**
* Sets the cell contents for a single existing cell
*
* 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'
* @access private
* @throws PEAR_Error
*/
function _setSingleCellContents($row, $col, $contents, $type = 'TD')
{
if ( isset($this->_structure[$row][$col])
&& $this->_structure[$row][$col] == '__SPANNED__'
) {
return;
}
$err = $this->_adjustEnds($row, $col, 'setCellContents');
if (PEAR::isError($err)) {
return $err;
}
$this->_structure[$row][$col]['contents'] = $contents;
$this->_structure[$row][$col]['type'] = $type;
}
/**
* Returns the cell contents for an existing cell
* @param int $row Row index
* @param int $col Column index
* @access public
* @return mixed
*/
function getCellContents($row, $col)
{
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');
}
return $this->_structure[$row][$col]['contents'];
}
/**
* 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
* @access public
*/
function setHeaderContents($row, $col, $contents, $attributes = null)
{
$this->setCellContents($row, $col, $contents, 'TH');
if (!is_null($attributes)) {
$this->updateCellAttributes($row, $col, $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
* @return int
* @access public
*/
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');
}
if (is_null($contents)) {
$contents = array();
}
$type = strtolower($type);
$row = $this->_rows++;
foreach ($contents as $col => $content) {
if ($type == 'td') {
$this->setCellContents($row, $col, $content);
} elseif ($type == 'th') {
$this->setHeaderContents($row, $col, $content);
}
}
$this->setRowAttributes($row, $attributes, $inTR);
return $row;
}
/**
* 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
* @access public
* @throws PEAR_Error
*/
function setRowAttributes($row, $attributes, $inTR = false)
{
if (!$inTR) {
$multiAttr = $this->_isAttributesArray($attributes);
for ($i = 0; $i < $this->_cols; $i++) {
if ($multiAttr) {
$this->setCellAttributes($row, $i,
$attributes[$i - ((ceil(($i + 1) / count($attributes))) - 1) * count($attributes)]);
} else {
$this->setCellAttributes($row, $i, $attributes);
}
}
} else {
$attributes = $this->_parseAttributes($attributes);
$err = $this->_adjustEnds($row, 0, 'setRowAttributes', $attributes);
if (PEAR::isError($err)) {
return $err;
}
$this->_structure[$row]['attr'] = $attributes;
}
}
/**
* 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
* @access public
* @throws PEAR_Error
*/
function updateRowAttributes($row, $attributes = null, $inTR = false)
{
if (!$inTR) {
$multiAttr = $this->_isAttributesArray($attributes);
for ($i = 0; $i < $this->_cols; $i++) {
if ($multiAttr) {
$this->updateCellAttributes($row, $i,
$attributes[$i - ((ceil(($i + 1) / count($attributes))) - 1) * count($attributes)]);
} else {
$this->updateCellAttributes($row, $i, $attributes);
}
}
} else {
$attributes = $this->_parseAttributes($attributes);
$err = $this->_adjustEnds($row, 0, 'updateRowAttributes', $attributes);
if (PEAR::isError($err)) {
return $err;
}
$this->_updateAttrArray($this->_structure[$row]['attr'], $attributes);
}
}
/**
* Returns the attributes for a given row as contained in the TR tag
* @param int $row Row index
* @return array
* @access public
*/
function getRowAttributes($row)
{
if (isset($this->_structure[$row]['attr'])) {
return $this->_structure[$row]['attr'];
}
return;
}
/**
* 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 $firstAttributes (optional) Which attributes should be
* applied to the first row, 1 or 2.
* @access public
*/
function altRowAttributes($start, $attributes1, $attributes2, $inTR = false,
$firstAttributes = 1)
{
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 string $type (optional) Cell type either 'th' or 'td'
* @return int
* @access public
*/
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');
}
if (is_null($contents)) {
$contents = array();
}
$type = strtolower($type);
$col = $this->_cols++;
foreach ($contents as $row => $content) {
if ($type == 'td') {
$this->setCellContents($row, $col, $content);
} elseif ($type == 'th') {
$this->setHeaderContents($row, $col, $content);
}
}
$this->setColAttributes($col, $attributes);
return $col;
}
/**
* 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
* @access public
*/
function setColAttributes($col, $attributes = null)
{
$multiAttr = $this->_isAttributesArray($attributes);
for ($i = 0; $i < $this->_rows; $i++) {
if ($multiAttr) {
$this->setCellAttributes($i, $col,
$attributes[$i - ((ceil(($i + 1) / count($attributes))) - 1) * count($attributes)]);
} else {
$this->setCellAttributes($i, $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
* @access public
*/
function updateColAttributes($col, $attributes = null)
{
$multiAttr = $this->_isAttributesArray($attributes);
for ($i = 0; $i < $this->_rows; $i++) {
if ($multiAttr) {
$this->updateCellAttributes($i, $col,
$attributes[$i - ((ceil(($i + 1) / count($attributes))) - 1) * count($attributes)]);
} else {
$this->updateCellAttributes($i, $col, $attributes);
}
}
}
/**
* Sets the attributes for all cells
* @param mixed $attributes (optional) Associative array or
* string of table row attributes
* @access public
*/
function setAllAttributes($attributes = null)
{
for ($i = 0; $i < $this->_rows; $i++) {
$this->setRowAttributes($i, $attributes);
}
}
/**
* Updates the attributes for all cells
* @param mixed $attributes (optional) Associative array or
* string of table row attributes
* @access public
*/
function updateAllAttributes($attributes = null)
{
for ($i = 0; $i < $this->_rows; $i++) {
$this->updateRowAttributes($i, $attributes);
}
}
/**
* Returns the table rows as HTML
* @access public
* @return string
*/
function toHtml($tabs = null, $tab = null)
{
$strHtml = '';
if (is_null($tabs)) {
$tabs = $this->_getTabs();
}
if (is_null($tab)) {
$tab = $this->_getTab();
}
$lnEnd = $this->_getLineEnd();
if ($this->_useTGroups) {
$extraTab = $tab;
} else {
$extraTab = '';
}
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']);
}
$strHtml .= $tabs .$tab . $extraTab . '<tr'.$attr.'>' . $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 (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;
}
$strHtml .= $tabs . $tab . $extraTab . '</tr>' . $lnEnd;
}
}
return $strHtml;
}
/**
* Checks if rows or columns are spanned
* @param int $row Row index
* @param int $col Column index
* @access private
*/
function _updateSpanGrid($row, $col)
{
if (isset($this->_structure[$row][$col]['attr']['colspan'])) {
$colspan = $this->_structure[$row][$col]['attr']['colspan'];
}
if (isset($this->_structure[$row][$col]['attr']['rowspan'])) {
$rowspan = $this->_structure[$row][$col]['attr']['rowspan'];
}
if (isset($colspan)) {
for ($j = $col + 1; (($j < $this->_cols) && ($j <= ($col + $colspan - 1))); $j++) {
$this->_structure[$row][$j] = '__SPANNED__';
}
}
if (isset($rowspan)) {
for ($i = $row + 1; (($i < $this->_rows) && ($i <= ($row + $rowspan - 1))); $i++) {
$this->_structure[$i][$col] = '__SPANNED__';
}
}
if (isset($colspan) && isset($rowspan)) {
for ($i = $row + 1; (($i < $this->_rows) && ($i <= ($row + $rowspan - 1))); $i++) {
for ($j = $col + 1; (($j <= $this->_cols) && ($j <= ($col + $colspan - 1))); $j++) {
$this->_structure[$i][$j] = '__SPANNED__';
}
}
}
}
/**
* Adjusts ends (total number of rows and columns)
* @param int $row Row index
* @param int $col Column index
* @param string $method Method name of caller
* Used to populate PEAR_Error if thrown.
* @param array $attributes Assoc array of attributes
* Default is an empty array.
* @access private
* @throws PEAR_Error
*/
function _adjustEnds($row, $col, $method, $attributes = array())
{
$colspan = isset($attributes['colspan']) ? $attributes['colspan'] : 1;
$rowspan = isset($attributes['rowspan']) ? $attributes['rowspan'] : 1;
if (($row + $rowspan - 1) >= $this->_rows) {
if ($this->_autoGrow) {
$this->_rows = $row + $rowspan;
} else {
return PEAR::raiseError('Invalid table row reference[' .
$row . '] in HTML_Table::' . $method);
}
}
if (($col + $colspan - 1) >= $this->_cols) {
if ($this->_autoGrow) {
$this->_cols = $col + $colspan;
} else {
return PEAR::raiseError('Invalid table column reference[' .
$col . '] in HTML_Table::' . $method);
}
}
}
/**
* Tells if the parameter is an array of attribute arrays/strings
* @param mixed $attributes Variable to test
* @access private
* @return bool
*/
function _isAttributesArray($attributes)
{
if (is_array($attributes) && isset($attributes[0])) {
if (is_array($attributes[0]) || (is_string($attributes[0]) && count($attributes) > 1)) {
return true;
}
}
return false;
}
}
?>
|