/**
* The required files
*/
require_once(HTML_MVC_VIEW_PATH.'/ViewSimple.php');
/**
* Generates the html for a View Detail
* <code>
* Usage:
* $view = new ViewDetail($datareader,$text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
* print $view->getHtml();
* Or
* ViewDetail::display($datareader,$text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
*
* Generates a complete View Detail interface
* +---------------+
* | Text header |
* +----------------
* | head1 | data1 |
* +---------------
* | head2 | data2 |
* +---------------+
* </code>
* @package mvc
*/
class ViewDetail extends ViewSimple {
/**
* Constructor
* @param DataReader $datareader The Data Reader object
* @param String $text The text header for the table
* @param String $width The Width for the table
* @param String $class The Class
* @param String $border The Border
* @param String $cellpadding The CellSpacing
* @param String $cellspacing The CellPadding
* @param String $summary The Summary
* @param String $caption The Caption
*/
function ViewDetail($datareader,$text='',$width='',$class='',$border='',$cellpadding='',$cellspacing='',$summary='',$caption='') {
$theText = $text!=''?$text:'';
/**
* Return the content as an object
* @return Object The content as an object
*/
function newContent() {
$object = new Tr();
$numrows = $this->datareader->getNumRows();
if ($numrows > 0) {
if ($numrows>1) {
$this->text .= $this->text!=''?" ($numrows)":'';
$td = new Td('','','',"TODO More than one ...<br />\r\n");
$object->add($td);
$link = new Links(LINK_BACK);
$td = new Td('','','',$link);
$object->add($td);
}
$count = 0;
foreach($this->datareader->getRows() as $no=>$row) {
$rowcolor = Rowcolor::get($count++);
if ($count > 1) {
$td = new Td(CSS_COLOR_HEADERA);
$td->add(new Hr());
$object->add($td);
$td = new Td($rowcolor);
$td->add(new Hr());
$object->add($td);
}
$object->add($this->newRow($row,CSS_COLOR_HEADER,$rowcolor));
}
} else {
$object->add($this->newTextRow(TEXT_NO_DATA, LINK_BACK));
}
return $object;
}
/**
* Return the html
* @return String The html
*/
function getHtml() {
$html = $this->html;
$this->add($this->newContent());
// Render it
if ($this->text != '') {
$html .= $this->getTableHeader();
}
$html .= $this->getStart();
$html .= $this->getEnd();
return $html;
}
/**
* Display html
* <code>
* Usage:
* ViewDetail::display($datareader,$text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
* </code>
* @static
* @param DataReader $datareader The Data Reader object
* @param String $text The text header for the table
* @param String $width The width of the table
* @param String $class The class of the table
* @param String $border The border of the table
* @param String $cellpadding The CellSpacing
* @param String $cellspacing The CellPadding
* @param String $summary The Summary
* @param String $caption The Caption
*/
function display($datareader,$text='',$width='',$class='',$border='',$cellpadding='',$cellspacing='',$summary='',$caption='') {
$html = new ViewDetail($datareader,$text,$width,$class,$border,$cellpadding,$cellspacing,$summary,$caption);
$html->addHtml();
}
}
?>