blob: bb95dc9b577611531c35bfbbd1beef505685e380 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
<?php
/* Icinga Web 2 | (c) 2021 Icinga GmbH | GPLv2+ */
namespace Icinga\Web;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Web\Url as iplWebUrl; //alias is needed for php5.6
use ipl\Web\Widget\Link;
/**
* Class RememberMeUserList
*
* @package Icinga\Web
*/
class RememberMeUserList extends BaseHtmlElement
{
protected $tag = 'table';
protected $defaultAttributes = [
'class' => 'common-table table-row-selectable',
'data-base-target' => '_next',
];
/**
* @var array
*/
protected $users;
/**
* @var string
*/
protected $url;
/**
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* @param string $url
*
* @return $this
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* @return array
*/
public function getUsers()
{
return $this->users;
}
/**
* @param array $users
*
* @return $this
*/
public function setUsers($users)
{
$this->users = $users;
return $this;
}
protected function assemble()
{
$thead = Html::tag('thead');
$theadRow = Html::tag('tr')
->add(Html::tag(
'th',
t('List of users who stay logged in')
));
$thead->add($theadRow);
$tbody = Html::tag('tbody');
if (empty($this->getUsers())) {
$tbody->add(Html::tag('td', t('No user found')));
} else {
foreach ($this->getUsers() as $user) {
$element = Html::tag('tr');
$link = new Link(
$user->username,
iplWebUrl::fromPath($this->getUrl())->addParams(['name' => $user->username]),
['title' => sprintf(t('Device list of %s'), $user->username)]
);
$element->add(Html::tag('td', $link));
$tbody->add($element);
}
}
$this->add($thead);
$this->add($tbody);
}
}
|