HTML_Table
[ class tree: HTML_Table ] [ index: HTML_Table ] [ all elements ]

Class: HTML_Table

Source Location: /HTML_Table-1.8.3/Table.php

Class Overview

HTML_Common
   |
   --HTML_Table

PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2005-2006 The PHP Group

Methods


Inherited Variables

Inherited Methods


Class Details

[line 95]
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.

  • Lots of customization options.
  • Tables can be modified at any time.
  • The logic is the same as standard HTML editors.
  • Handles col and rowspans.
  • 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



[ Top ]


Method Detail

HTML_Table (Constructor)   [line 174]

HTML_Table HTML_Table( [array $attributes = null], [int $tabOffset = 0], [bool $useTGroups = false])

Class constructor
  • Access: public

Parameters:

array   $attributes     Associative array of table tag attributes
int   $tabOffset     Tab offset of the table
bool   $useTGroups     Whether to use <thead>, <tfoot> and <tbody> or not

[ Top ]

addBody   [line 257]

int addBody( [mixed $attributes = null])

Adds a table body and returns the body identifier
  • Access: public

Parameters:

mixed   $attributes     (optional) Associative array or string of table body attributes

[ Top ]

addCol   [line 824]

int addCol( [array $contents = null], [mixed $attributes = null], [string $type = 'td'], [int $body = 0])

Adds a table column and returns the column identifier
  • Throws: PEAR_Error
  • Access: public

Parameters:

array   $contents     (optional) Must be a indexed array of valid cell contents
mixed   $attributes     (optional) Associative array or string of table row attributes
string   $type     (optional) Cell type either 'th' or 'td'
int   $body     (optional) The index of the body to use.

[ Top ]

addRow   [line 691]

int addRow( [array $contents = null], [mixed $attributes = null], [string $type = 'td'], [bool $inTR = false], [int $body = 0])

Adds a table row and returns the row identifier
  • Throws: PEAR_Error
  • Access: public

Parameters:

array   $contents     (optional) Must be a indexed array of valid cell contents
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.
string   $type     (optional) Cell type either 'th' or 'td'
bool   $inTR     false if attributes are to be applied in TD tags; true if attributes are to ībe applied in TR tag
int   $body     (optional) The index of the body to use.

[ Top ]

altRowAttributes   [line 788]

void altRowAttributes( int $start, mixed $attributes1, mixed $attributes2, [bool $inTR = false], [int $firstAttributes = 1], [int $body = null])

Alternates the row attributes starting at $start
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $start     Row index of row in which alternating begins
mixed   $attributes1     Associative array or string of table row attributes
mixed   $attributes2     Associative array or string of table row attributes
bool   $inTR     false if attributes are to be applied in TD tags; true if attributes are to be applied in TR tag
int   $firstAttributes     (optional) Which attributes should be applied to the first row, 1 or 2.
int   $body     (optional) The index of the body to set. Pass null to set for all bodies.

[ Top ]

apiVersion   [line 191]

double apiVersion( )

Returns the API version
  • Deprecated:
  • Access: public

[ Top ]

getAutoFill   [line 358]

mixed getAutoFill( [int $body = null])

Returns the autoFill value
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $body     (optional) The index of the body to get. Pass null to get the default for new bodies.

[ Top ]

getAutoGrow   [line 403]

mixed getAutoGrow( [int $body = null])

Returns the autoGrow value
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $body     (optional) The index of the body to get. Pass null to get the default for new bodies.

[ Top ]

getBody   [line 241]

object &getBody( [int $body = 0])

Returns the HTML_Table_Storage object for the specified <tbody>

(or the whole table if <t{head|foot|body}> is not used)

  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $body     (optional) The index of the body to return.

[ Top ]

getCellAttributes   [line 594]

array getCellAttributes( int $row, int $col, [int $body = 0])

Returns the attributes for a given cell
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
int   $col     Column index
int   $body     (optional) The index of the body to get.

[ Top ]

getCellContents   [line 643]

mixed getCellContents( int $row, int $col, [int $body = 0])

Returns the cell contents for an existing cell
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
int   $col     Column index
int   $body     (optional) The index of the body to get.

[ Top ]

getColCount   [line 486]

int getColCount( [int $row = null], [int $body = 0])

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.

  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index to serve for cols count
int   $body     (optional) The index of the body to get.

[ Top ]

getFooter   [line 219]

object &getFooter( )

Returns the HTML_Table_Storage object for <tfoot>
  • Access: public

[ Top ]

getHeader   [line 201]

object &getHeader( )

Returns the HTML_Table_Storage object for <thead>
  • Access: public

[ Top ]

getRowAttributes   [line 761]

array getRowAttributes( int $row, [int $body = 0])

Returns the attributes for a given row as contained in the TR tag
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
int   $body     (optional) The index of the body to get.

[ Top ]

getRowCount   [line 457]

int getRowCount( [int $body = null])

Returns the number of rows in the table
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $body     (optional) The index of the body to get. Pass null to get the total number of rows in all bodies.

[ Top ]

setAllAttributes   [line 892]

void setAllAttributes( [mixed $attributes = null], [int $body = null])

Sets the attributes for all cells
  • Throws: PEAR_Error
  • Access: public

Parameters:

mixed   $attributes     (optional) Associative array or string of table row attributes
int   $body     (optional) The index of the body to set. Pass null to set for all bodies.

[ Top ]

setAutoFill   [line 334]

void setAutoFill( mixed $fill, [int $body = null])

Sets the autoFill value
  • Throws: PEAR_Error
  • Access: public

Parameters:

mixed   $fill     Whether autoFill should be enabled or not
int   $body     (optional) The index of the body to set. Pass null to set for all bodies.

[ Top ]

setAutoGrow   [line 379]

void setAutoGrow( bool $grow, [int $body = null])

Sets the autoGrow value
  • Throws: PEAR_Error
  • Access: public

Parameters:

bool   $grow     Whether autoGrow should be enabled or not
int   $body     (optional) The index of the body to set. Pass null to set for all bodies.

[ Top ]

setCaption   [line 300]

void setCaption( string $caption, [mixed $attributes = null])

Sets the table caption
  • Access: public

Parameters:

string   $caption     
mixed   $attributes     Associative array or string of table row attributes

[ Top ]

setCellAttributes   [line 550]

void setCellAttributes( int $row, int $col, mixed $attributes, [int $body = 0])

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.

  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
int   $col     Column index
mixed   $attributes     Associative array or string of table row attributes
int   $body     (optional) The index of the body to set.

[ Top ]

setCellContents   [line 622]

void setCellContents( int $row, int $col, mixed $contents, [string $type = 'TD'], [int $body = 0])

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.

  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
int   $col     Column index
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
string   $type     (optional) Cell type either 'TH' or 'TD'
int   $body     (optional) The index of the body to set.

[ Top ]

setColAttributes   [line 843]

void setColAttributes( int $col, [mixed $attributes = null], [int $body = null])

Sets the column attributes for an existing column
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $col     Column index
mixed   $attributes     (optional) Associative array or string of table row attributes
int   $body     (optional) The index of the body to set. Pass null to set for all bodies.

[ Top ]

setColCount   [line 439]

void setColCount( int $cols, [int $body = 0])

Sets the number of columns in the table
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $cols     The number of columns
int   $body     (optional) The index of the body to set.

[ Top ]

setColGroup   [line 315]

void setColGroup( [mixed $colgroup = null], [mixed $attributes = null])

Sets the table columns group specifications, or removes existing ones.
  • Author: Laurent Laville (pear at laurent-laville dot org)
  • Access: public

Parameters:

mixed   $colgroup     (optional) Columns attributes
mixed   $attributes     (optional) Associative array or string of table row attributes

[ Top ]

setColType   [line 521]

void setColType( int $col, string $type, [int $body = null])

Sets a columns type 'TH' or 'TD'
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $col     Column index
string   $type     'TH' or 'TD'
int   $body     (optional) The index of the body to set. Pass null to set for all bodies.

[ Top ]

setHeaderContents   [line 663]

void setHeaderContents( int $row, int $col, mixed $contents, [mixed $attributes = null], [int $body = 0])

Sets the contents of a header cell
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     
int   $col     
mixed   $contents     
mixed   $attributes     Associative array or string of table row attributes
int   $body     (optional) The index of the body to set.

[ Top ]

setRowAttributes   [line 716]

void setRowAttributes( int $row, mixed $attributes, [bool $inTR = false], [int $body = 0])

Sets the row attributes for an existing row
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
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.
bool   $inTR     false if attributes are to be applied in TD tags; true if attributes are to be applied in TR tag
int   $body     (optional) The index of the body to set.

[ Top ]

setRowCount   [line 423]

void setRowCount( int $rows, [int $body = 0])

Sets the number of rows in the table body
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $rows     The number of rows
int   $body     (optional) The index of the body to set.

[ Top ]

setRowType   [line 503]

void setRowType( int $row, string $type, [int $body = 0])

Sets a rows type 'TH' or 'TD'
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
string   $type     'TH' or 'TD'
int   $body     (optional) The index of the body to set.

[ Top ]

toHtml   [line 936]

string toHtml( )

Returns the table structure as HTML
  • Access: public

[ Top ]

updateAllAttributes   [line 916]

void updateAllAttributes( [mixed $attributes = null], [int $body = null])

Updates the attributes for all cells
  • Throws: PEAR_Error
  • Access: public

Parameters:

mixed   $attributes     (optional) Associative array or string of table row attributes
int   $body     (optional) The index of the body to set. Pass null to set for all bodies.

[ Top ]

updateCellAttributes   [line 573]

void updateCellAttributes( int $row, int $col, mixed $attributes, [int $body = 0])

Updates the cell attributes passed but leaves other existing attributes

intact

  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
int   $col     Column index
mixed   $attributes     Associative array or string of table row attributes
int   $body     (optional) The index of the body to set.

[ Top ]

updateColAttributes   [line 868]

void updateColAttributes( int $col, [mixed $attributes = null], [int $body = null])

Updates the column attributes for an existing column
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $col     Column index
mixed   $attributes     (optional) Associative array or string of table row attributes
int   $body     (optional) The index of the body to set. Pass null to set for all bodies.

[ Top ]

updateRowAttributes   [line 740]

void updateRowAttributes( int $row, [mixed $attributes = null], [bool $inTR = false], [int $body = 0])

Updates the row attributes for an existing row
  • Throws: PEAR_Error
  • Access: public

Parameters:

int   $row     Row index
mixed   $attributes     Associative array or string of table row attributes
bool   $inTR     false if attributes are to be applied in TD tags; true if attributes are to be applied in TR tag
int   $body     (optional) The index of the body to set.

[ Top ]

__toString   [line 1040]

string __toString( )

Returns the table structure as HTML
  • Access: public

[ Top ]


Documentation generated on Mon, 05 Apr 2010 21:30:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.