| @@ 476-498 (lines=23) @@ | ||
| 473 | * @return int |
|
| 474 | * @access public |
|
| 475 | */ |
|
| 476 | function addRow($contents = null, $attributes = null, $type = 'td', |
|
| 477 | $inTR = false) |
|
| 478 | { |
|
| 479 | if (isset($contents) && !is_array($contents)) { |
|
| 480 | return PEAR::raiseError('First parameter to HTML_Table::addRow ' . |
|
| 481 | 'must be an array'); |
|
| 482 | } |
|
| 483 | if (is_null($contents)) { |
|
| 484 | $contents = array(); |
|
| 485 | } |
|
| 486 | ||
| 487 | $type = strtolower($type); |
|
| 488 | $row = $this->_rows++; |
|
| 489 | foreach ($contents as $col => $content) { |
|
| 490 | if ($type == 'td') { |
|
| 491 | $this->setCellContents($row, $col, $content); |
|
| 492 | } elseif ($type == 'th') { |
|
| 493 | $this->setHeaderContents($row, $col, $content); |
|
| 494 | } |
|
| 495 | } |
|
| 496 | $this->setRowAttributes($row, $attributes, $inTR); |
|
| 497 | return $row; |
|
| 498 | } |
|
| 499 | ||
| 500 | /** |
|
| 501 | * Sets the row attributes for an existing row |
|
| @@ 620-641 (lines=22) @@ | ||
| 617 | * @return int |
|
| 618 | * @access public |
|
| 619 | */ |
|
| 620 | function addCol($contents = null, $attributes = null, $type = 'td') |
|
| 621 | { |
|
| 622 | if (isset($contents) && !is_array($contents)) { |
|
| 623 | return PEAR::raiseError('First parameter to HTML_Table::addCol ' . |
|
| 624 | 'must be an array'); |
|
| 625 | } |
|
| 626 | if (is_null($contents)) { |
|
| 627 | $contents = array(); |
|
| 628 | } |
|
| 629 | ||
| 630 | $type = strtolower($type); |
|
| 631 | $col = $this->_cols++; |
|
| 632 | foreach ($contents as $row => $content) { |
|
| 633 | if ($type == 'td') { |
|
| 634 | $this->setCellContents($row, $col, $content); |
|
| 635 | } elseif ($type == 'th') { |
|
| 636 | $this->setHeaderContents($row, $col, $content); |
|
| 637 | } |
|
| 638 | } |
|
| 639 | $this->setColAttributes($col, $attributes); |
|
| 640 | return $col; |
|
| 641 | } |
|
| 642 | ||
| 643 | /** |
|
| 644 | * Sets the column attributes for an existing column |
|