protected function renderVerticalContents($writer, $user)
{
$tableLayout = $this->_repeatLayout === TRepeatLayout::Table;
$hasSeparators = $user->getHasSeparators();
$itemCount = $user->getItemCount();
if ($this->_repeatColumns <= 1) {
$rows = $itemCount;
$columns = 1;
$lastColumns = 1;
} else {
$columns = $this->_repeatColumns;
$rows = (int) (($itemCount + $columns - 1) / $columns);
if ($rows == 0 && $itemCount > 0) {
$rows = 1;
}
if (($lastColumns = $itemCount % $columns) == 0) {
$lastColumns = $columns;
}
}
$totalColumns = $hasSeparators ? $columns + $columns : $columns;
if ($user->getHasHeader()) {
$this->renderHeader($writer, $user, $tableLayout, $totalColumns, false);
}
if ($tableLayout) {
$writer->renderBeginTag('tbody');
$renderedItems = 0;
for ($row = 0; $row < $rows; ++$row) {
$index = $row;
$writer->renderBeginTag('tr');
for ($col = 0; $col < $columns; ++$col) {
if ($renderedItems >= $itemCount) {
break;
}
if ($col > 0) {
$index += $rows;
if ($col - 1 >= $lastColumns) {
$index--;
}
}
if ($index >= $itemCount) {
continue;
}
$renderedItems++;
if (($style = $user->generateItemStyle('Item', $index)) !== null) {
$style->addAttributesToRender($writer);
}
$writer->renderBeginTag('td');
$user->renderItem($writer, $this, 'Item', $index);
$writer->renderEndTag();
$writer->writeLine();
if (!$hasSeparators) {
continue;
}
if ($renderedItems < $itemCount - 1) {
if ($columns == 1) {
$writer->renderEndTag();
$writer->renderBeginTag('tr');
}
if (($style = $user->generateItemStyle('Separator', $index)) !== null) {
$style->addAttributesToRender($writer);
}
$writer->renderBeginTag('td');
$user->renderItem($writer, $this, 'Separator', $index);
$writer->renderEndTag();
$writer->writeLine();
} else {
if ($columns > 1) {
$writer->write("<td></td>\n");
}
}
}
if ($row == $rows - 1) {
$restColumns = $columns - $lastColumns;
if ($hasSeparators) {
$restColumns += $restColumns;
}
for ($col = 0; $col < $restColumns; ++$col) {
$writer->write("<td></td>\n");
}
}
$writer->renderEndTag();
$writer->writeLine();
}
$writer->renderEndTag();
} else {
$renderedItems = 0;
for ($row = 0; $row < $rows; ++$row) {
$index = $row;
for ($col = 0; $col < $columns; ++$col) {
if ($renderedItems >= $itemCount) {
break;
}
if ($col > 0) {
$index += $rows;
if ($col - 1 >= $lastColumns) {
$index--;
}
}
if ($index >= $itemCount) {
continue;
}
$renderedItems++;
$user->renderItem($writer, $this, 'Item', $index);
$writer->writeLine();
if (!$hasSeparators) {
continue;
}
if ($renderedItems < $itemCount - 1) {
if ($columns == 1) {
$writer->writeBreak();
}
$user->renderItem($writer, $this, 'Separator', $index);
}
$writer->writeLine();
}
if ($row < $rows - 1 || $user->getHasFooter()) {
$writer->writeBreak();
}
}
}
if ($user->getHasFooter()) {
$this->renderFooter($writer, $user, $tableLayout, $totalColumns, false);
}
}