-
Notifications
You must be signed in to change notification settings - Fork 5
/
DashboardPanelNotice.module
executable file
·55 lines (49 loc) · 1.65 KB
/
DashboardPanelNotice.module
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
<?php namespace Daun\Dashboard;
use function ProcessWire\__;
use function ProcessWire\wireIconMarkup;
// Include abstract panel base class
require_once dirname(__DIR__).'/Dashboard/DashboardPanel.class.php';
class DashboardPanelNotice extends DashboardPanel
{
public static function getModuleInfo()
{
return array_merge(
parent::getModuleInfo(),
[
'title' => __('Dashboard Panel: Notice', __FILE__),
'summary' => __('Display a notice with icon', __FILE__),
'author' => 'Philipp Daun',
'version' => '1.5.6',
]
);
}
public function getContent()
{
$icon = wireIconMarkup($this->icon, 'fw');
$actions = implode('', array_map(function ($url, $label) {
if ($url && $label) {
return "<a href='{$url}'>{$label}</a> ";
}
}, $this->actions, array_keys($this->actions)));
if ($this->title) {
return "<div>{$icon} <strong>{$this->title}</strong> {$this->message}</div> <div>{$actions}</div>";
} else {
return "<div>{$icon} {$this->message}</div> <div>{$actions}</div>";
}
}
public function getClassNames()
{
return [
"notice-status--{$this->status}",
];
}
public function setup()
{
parent::setup();
$this->title = $this->options['title'] ?? '';
$this->icon = $this->options['icon'] ?? '';
$this->message = $this->data['message'] ?? '';
$this->status = $this->data['status'] ?? 'notice';
$this->actions = $this->data['actions'] ?? [];
}
}