<?
/*
This script is a part of the ExTemplates Library
Author: Alexander Netkachev
Check the license.txt for copyright and terms.
*/
class Repeater extends TemplateBlock {
var $rows;
var $beforeRenderRow;
function Grid(&$array) {
$this->content = &$array;
$this->visible = true;
$this->beforeRenderRow = '';
}
function render() {
$header = & $this->getControl('Header');
$footer = & $this->getControl('Footer');
$row = & $this->getControl('Row');
$noRecords =& $this->getControl('NoRecords');
$result = '';
if ($header != null)
$result .= $header->render();
if ($row != null) {
$rowCount = count($this->rows);
if ($rowCount == 0)
$result .= $noRecords->render();
else {
for ($i = 0; $i < $rowCount; $i++) {
if ($this->beforeRenderRow != '') {
$funcName = $this->beforeRenderRow;
$funcName(&$row, &$this->rows[$i]);
}
$result .= $row->render();
}
}
}
if ($footer != null)
$result .= $footer->render();
return $result;
}
function setRows(&$rows) {
$this->rows = &$rows;
}
}
?>