ImportedrowsTable: Render complex data types in pre tag

Just like ImportsourceHookTable.

refs #1325
This commit is contained in:
Markus Frosch 2018-03-11 13:30:52 +01:00 committed by Thomas Gelf
parent d69c5a7cc7
commit 034319dbe7
1 changed files with 29 additions and 2 deletions

View File

@ -2,9 +2,12 @@
namespace Icinga\Module\Director\Web\Table;
use Icinga\Data\DataArray\ArrayDatasource;
use Icinga\Module\Director\Objects\ImportRun;
use dipl\Html\Html;
use dipl\Html\ValidHtml;
use dipl\Web\Table\SimpleQueryBasedTable;
use Icinga\Data\DataArray\ArrayDatasource;
use Icinga\Module\Director\Objects\ImportRun;
use Icinga\Module\Director\PlainObjectRenderer;
class ImportedrowsTable extends SimpleQueryBasedTable
{
@ -49,6 +52,30 @@ class ImportedrowsTable extends SimpleQueryBasedTable
return array_combine($cols, $cols);
}
public function renderRow($row)
{
// Find a better place!
if ($row === null) {
return null;
}
$tr = $this::tr();
foreach ($this->getColumnsToBeRendered() as $column) {
$td = $this::td();
if (property_exists($row, $column)) {
if (is_string($row->$column) || $row->$column instanceof ValidHtml) {
$td->setContent($row->$column);
} else {
$html = Html::tag('pre', null, PlainObjectRenderer::render($row->$column));
$td->setContent($html);
}
}
$tr->add($td);
}
return $tr;
}
public function getColumnsToBeRendered()
{
return $this->getColumns();