blob: cc9392a1ad673ff6de7517e722bcd788261013b9 (
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
|
<?php
/* Icinga Web 2 | (c) 2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Setup;
use RecursiveIteratorIterator;
class RequirementsRenderer extends RecursiveIteratorIterator
{
public function beginIteration(): void
{
$this->tags[] = '<ul class="requirements">';
}
public function endIteration(): void
{
$this->tags[] = '</ul>';
}
public function beginChildren(): void
{
$this->tags[] = '<li>';
$currentSet = $this->getSubIterator();
$state = $currentSet->getState() ? 'fulfilled' : ($currentSet->isOptional() ? 'not-available' : 'missing');
$this->tags[] = '<ul class="set-state ' . $state . '">';
}
public function endChildren(): void
{
$this->tags[] = '</ul>';
$this->tags[] = '</li>';
}
public function render()
{
foreach ($this as $requirement) {
$this->tags[] = '<li class="clearfix">';
$this->tags[] = '<div class="title"><h2>' . $requirement->getTitle() . '</h2></div>';
$this->tags[] = '<div class="description">';
$descriptions = $requirement->getDescriptions();
if (count($descriptions) > 1) {
$this->tags[] = '<ul>';
foreach ($descriptions as $d) {
$this->tags[] = '<li>' . $d . '</li>';
}
$this->tags[] = '</ul>';
} elseif (! empty($descriptions)) {
$this->tags[] = $descriptions[0];
}
$this->tags[] = '</div>';
$this->tags[] = '<div class="state ' . ($requirement->getState() ? 'fulfilled' : (
$requirement->isOptional() ? 'not-available' : 'missing'
)) . '">' . $requirement->getStateText() . '</div>';
$this->tags[] = '</li>';
}
return implode("\n", $this->tags);
}
public function __toString()
{
return $this->render();
}
}
|