1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Module; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* children class to create a module with metadata |
6
|
|
|
* |
7
|
|
|
* @since 4.1.0 |
8
|
|
|
* |
9
|
|
|
* @package Redaxscript |
10
|
|
|
* @category Module |
11
|
|
|
* @author Henry Ruhs |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
class Metadata extends Module |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* array of the dashboard |
18
|
|
|
* |
19
|
|
|
* @var array |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
protected static $_dashboardArray = []; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* array of the notification |
26
|
|
|
* |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
protected static $_notificationArray = []; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* get the dashboard array |
34
|
|
|
* |
35
|
|
|
* @since 4.1.0 |
36
|
|
|
* |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
|
|
|
40
|
|
|
public function getDashboardArray() : array |
41
|
|
|
{ |
42
|
|
|
return self::$_dashboardArray; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* get the notification array |
47
|
|
|
* |
48
|
|
|
* @since 4.1.0 |
49
|
|
|
* |
50
|
|
|
* @return array |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
public function getNotificationArray() : array |
54
|
|
|
{ |
55
|
|
|
return self::$_notificationArray; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* set the dashboard |
60
|
|
|
* |
61
|
|
|
* @since 4.1.0 |
62
|
|
|
* |
63
|
|
|
* @param string $content content of the dashboard |
64
|
|
|
* @param int $column column of the dashboard |
65
|
|
|
*/ |
66
|
|
|
|
67
|
|
|
public function setDashboard(string $content = null, int $column = 1) : void |
68
|
|
|
{ |
69
|
|
|
$moduleName = static::$_moduleArray['name']; |
70
|
|
|
static::$_dashboardArray[$moduleName][] = |
71
|
|
|
[ |
72
|
|
|
'content' => $content, |
73
|
|
|
'column' => $column |
74
|
|
|
]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* set the notification |
79
|
|
|
* |
80
|
|
|
* @since 4.1.0 |
81
|
|
|
* |
82
|
|
|
* @param string $type type of the notification |
83
|
|
|
* @param string|array $message message of the notification |
84
|
|
|
*/ |
85
|
|
|
|
86
|
|
|
public function setNotification(string $type = null, $message = null) : void |
87
|
|
|
{ |
88
|
|
|
$moduleName = static::$_moduleArray['name']; |
89
|
|
|
static::$_notificationArray[$type][$moduleName][] = $message; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* clear the dashboard array |
94
|
|
|
* |
95
|
|
|
* @since 4.1.0 |
96
|
|
|
*/ |
97
|
|
|
|
98
|
|
|
public function clearDashboard() : void |
99
|
|
|
{ |
100
|
|
|
$moduleName = static::$_moduleArray['name']; |
101
|
|
|
static::$_notificationArray[$moduleName] = null; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* clear the notification array |
106
|
|
|
* |
107
|
|
|
* @since 4.1.0 |
108
|
|
|
* |
109
|
|
|
* @param string $type type of the notification |
110
|
|
|
*/ |
111
|
|
|
|
112
|
|
|
public function clearNotification(string $type = null) : void |
113
|
|
|
{ |
114
|
|
|
$moduleName = static::$_moduleArray['name']; |
115
|
|
|
static::$_notificationArray[$type][$moduleName] = null; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|