<?php
/**
* Title: HTML Table generator
* Description: Generates XHTML 1.0 Strict tables
* @requires The LinkedList package. The packages is used to manges rows and table cells
* @author Oddleif Halvorsen
* @version 1.0
* XHTML 1.0 strict implementation: 100%
*/
include_once("HTMLTag.php");
include_once("LinkedList.php");
class Tr extends HTMLTag{
var $columns;
var $align;
var $char;
var $charoff;
var $valign;
function Tr(){
$this->columns = new LinkedList();
}
function setAlign($align){ $this->align = $align; }
function setChar($char){ $this->char = $char; }
function setCharOff($charoff){ $this->charoff = $charoff; }
function setValign($valign){ $this->valign = $valign; }
function getAlign(){ return (isset($this->align) ? $this->align : FALSE); }
function getChar(){ return (isset($this->char) ? $this->char : FALSE); }
function getCharOff(){ return (isset($this->charoff) ? $this->charoff : FALSE); }
function getValign(){ return (isset($this->valign) ? $this->valign : FALSE); }
/**
* Sets a row header for the row.
*/
function addRowHeader($header){
if($this->columns->size() == 0)
$this->addColumn($header);
else
$this->columns->addAtPosition(0, $header);
}
/**
* Adds a new cell to the row.
* @param $column Th object || Td object
*/
function addColumn($column){
$this->columns->add($column);
}
/**
* Generates the html code for the td tag
* with all the provied attributes and table cell(s) (Th and/or Td's)
* @return The html code for the tr tag.
*/
function getHtml(){
$tr = &$this->setTrAttributes();
//inserts the table cells (th/td)
$iterator = $this->columns->iterator();
while($iterator->hasNext()){
$tmpCell = $iterator->getNext();
$tr .= $tmpCell->getHtml();
}
$tr .= "</tr>";
return $tr;
}
/**
* Sets the attributes for the table row
* @return A tr tag with attributes
*/
function setTrAttributes(){
$tr = "<tr";
if(parent::getAttributes() != FALSE)
$tr .= parent::getAttributes();
if($this->getAlign() != FALSE)
$tr .= " align=\"" . $this->getAlign() . "\"";
if($this->getChar() != FALSE)
$tr .= " char=\"" . $this->getChar() . "\"";
if($this->getCharOff() != FALSE)
$tr .= " charoff=\"" . $this->getCharOff() . "\"";
if($this->getValign() != FALSE)
$tr .= " valign=\"" . $this->getValign() . "\"";
$tr .= ">";
return $tr;
}
}
?>