Path

ez components / documentation / api reference / trunk / consoletools


eZ Components trunk

ConsoleTools: ezcConsoleTableRow

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcConsoleTableRow

Structure representing a table row in ezcConsoleTable. [source]

Implemented Interfaces

  • Countable (internal interface)
  • Iterator (internal interface)
  • ArrayAccess (internal interface)

This class represents a row in a table object. You can access the properties of the row directly, but also access the cells of the row directly, as if the object was an array (index 0..).
 1.  // Create new table row
 2.   $row new ezcConsoleTableRow();
 3.  
 4.  // Set default format of the row's cells
 5.   $row->format 'headline';
 6.  
 7.  // On the fly create the cell no 0
 8.   $row[0]->content 'Name';
 9.  // On the fly create the cell no 1
10.   $row[1]->content 'Cellphone';
11.  
12.  // Change a setting on cell 0
13.   $row[0]->align ezcConsoleTable::ALIGN_CENTER;
14.  
15.  // Iterate through the row's cells.
16.   foreach $row as $cell )
17.  {
18.      var_dump$cell );
19.  }
20.  
21.  // Set the default align property for all cells in the row
22.   $row->align ezcConsoleTable::ALIGN_CENTER;
This class stores the rows for the ezcConsoleTable class.

Properties

mixed read/write  $align
Alignment applied to cells marked with ezcConsoleTable::ALIGN_DEFAULT.
string read/write  $borderFormat
Set the format applied to the borders of this row. See ezcConsoleOutput
string read/write  $format
Format applied to cell contents of cells marked with format "default" in this row.

Member Variables

protected array(ezcConsoleTableCell) $cells = array()
The cells of the row.
protected array(string=>mixed) $properties
Container to hold the properties

Method Summary

public ezcConsoleTableRow __construct( )
Create a new ezcConsoleProgressbarRow.
public int count( )
Returns the number of cells in the row.
public ezcConsoleTableCell current( )
Returns the currently selected cell.
public int key( )
Returns the key of the currently selected cell.
public mixed next( )
Returns the next cell and selects it or false on the last cell.
public bool offsetExists( $offset )
Returns if the given offset exists.
public ezcConsoleTableCell offsetGet( $offset )
Returns the element with the given offset.
public void offsetSet( $offset, $value )
Set the element with the given offset.
public void offsetUnset( $offset )
Unset the element with the given offset.
public ezcConsoleTableCell rewind( )
Selects the very first cell and returns it.
public ezcConsoleTableCell valid( )
Returns if the current cell is valid.

Methods

__construct

ezcConsoleTableRow __construct( )
Create a new ezcConsoleProgressbarRow.
Creates a new ezcConsoleProgressbarRow.
This method takes any number of ezcConsoleTableCell objects as parameter, which will be added as table cells to the row in their specified order.

Throws

ClassDescription
ezcBaseValueException If a parameter is not of type ezcConsoleTableCell.

count

int count( )
Returns the number of cells in the row.
This method is part of the Countable interface to allow the usage of PHP's count() function to check how many cells this row has.

current

ezcConsoleTableCell current( )
Returns the currently selected cell.
This method is part of the Iterator interface to allow acces to the cells of this row by iterating over it like an array (e.g. using foreach).

key

int key( )
Returns the key of the currently selected cell.
This method is part of the Iterator interface to allow acces to the cells of this row by iterating over it like an array (e.g. using foreach).

next

mixed next( )
Returns the next cell and selects it or false on the last cell.
This method is part of the Iterator interface to allow acces to the cells of this row by iterating over it like an array (e.g. using foreach).

offsetExists

bool offsetExists( int $offset )
Returns if the given offset exists.
This method is part of the ArrayAccess interface to allow access to the data of this object as if it was an array.

Parameters

Name Type Description
$offset int The offset to check.

Throws

ClassDescription
ezcBaseValueException If a non numeric cell ID is requested.

offsetGet

ezcConsoleTableCell offsetGet( int $offset )
Returns the element with the given offset.
This method is part of the ArrayAccess interface to allow access to the data of this object as if it was an array. In case of the ezcConsoleTableRow class this method always returns a valid cell object since it creates them on the fly, if a given item does not exist.

Parameters

Name Type Description
$offset int The offset to check.

Throws

ClassDescription
ezcBaseValueException If a non numeric cell ID is requested.

offsetSet

void offsetSet( int $offset, ezcConsoleTableCell $value )
Set the element with the given offset.
This method is part of the ArrayAccess interface to allow access to the data of this object as if it was an array.

Parameters

Name Type Description
$offset int The offset to assign an item to.
$value ezcConsoleTableCell The cell to assign.

Throws

ClassDescription
ezcBaseValueException If a non numeric cell ID is requested.
ezcBaseValueException If the provided value is not of type {@ling ezcConsoleTableCell}.

offsetUnset

void offsetUnset( int $offset )
Unset the element with the given offset.
This method is part of the ArrayAccess interface to allow access to the data of this object as if it was an array.

Parameters

Name Type Description
$offset int The offset to unset the value for.

Throws

ClassDescription
ezcBaseValueException If a non numeric cell ID is requested.

rewind

Selects the very first cell and returns it.
This method is part of the Iterator interface to allow acces to the cells of this row by iterating over it like an array (e.g. using foreach).

valid

Returns if the current cell is valid.
This method is part of the Iterator interface to allow acces to the cells of this row by iterating over it like an array (e.g. using foreach).

Last updated: Mon, 10 Nov 2008