icingadb-web/library/Icingadb/Widget/ItemTable/UserTableRow.php

62 lines
1.7 KiB
PHP
Raw Normal View History

2019-10-24 08:02:04 -04:00
<?php
2020-03-13 03:38:01 -04:00
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
namespace Icinga\Module\Icingadb\Widget\ItemTable;
2019-10-24 08:02:04 -04:00
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Model\User;
use ipl\Html\Attributes;
2019-10-24 08:02:04 -04:00
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlDocument;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Stdlib\Filter;
2023-08-09 08:25:44 -04:00
use ipl\Web\Common\BaseTableRowItem;
2019-11-04 18:04:20 -05:00
use ipl\Web\Widget\Link;
2019-10-24 08:02:04 -04:00
/**
* User item of a user list. Represents one database row.
*
* @property User $item
* @property UserTable $table
*/
class UserTableRow extends BaseTableRowItem
2019-10-24 08:02:04 -04:00
{
protected $defaultAttributes = ['class' => 'user-table-row'];
2019-10-24 08:02:04 -04:00
2023-08-09 08:25:44 -04:00
protected function init(): void
{
if (isset($this->table)) {
$this->table->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name));
}
}
2019-10-24 08:02:04 -04:00
2023-08-09 08:25:44 -04:00
protected function assembleVisual(BaseHtmlElement $visual): void
{
$visual->addHtml(new HtmlElement(
'div',
Attributes::create(['class' => 'user-ball']),
Text::create($this->item->display_name[0])
));
}
2019-10-24 08:02:04 -04:00
2023-08-09 08:25:44 -04:00
protected function assembleTitle(BaseHtmlElement $title): void
2019-10-24 08:02:04 -04:00
{
$title->addHtml(
isset($this->table)
? new Link($this->item->display_name, Links::user($this->item), ['class' => 'subject'])
: new HtmlElement(
'span',
Attributes::create(['class' => 'subject']),
Text::create($this->item->display_name)
),
new HtmlElement('span', null, Text::create($this->item->name))
);
2019-10-24 08:02:04 -04:00
}
2023-08-09 08:25:44 -04:00
protected function assembleColumns(HtmlDocument $columns): void
2019-10-24 08:02:04 -04:00
{
}
}