|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This field lets you put an arbitrary message into your backend. |
|
4
|
|
|
* |
|
5
|
|
|
* <code> |
|
6
|
|
|
* Message::generic( |
|
7
|
|
|
* $content = 'your message' |
|
8
|
|
|
* ) |
|
9
|
|
|
* </code> |
|
10
|
|
|
* |
|
11
|
|
|
* or with the optional name parameter |
|
12
|
|
|
* |
|
13
|
|
|
* <code> |
|
14
|
|
|
* Message::generic( |
|
15
|
|
|
* $content = 'your message', |
|
16
|
|
|
* $CSSClass = null, |
|
17
|
|
|
* $name = 'fieldName' |
|
18
|
|
|
* ) |
|
19
|
|
|
* </code> |
|
20
|
|
|
*/ |
|
21
|
|
|
class Message |
|
|
|
|
|
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Creates a error message. |
|
25
|
|
|
* |
|
26
|
|
|
* @param string $message |
|
|
|
|
|
|
27
|
|
|
* @param string $CSSClass (optional) |
|
|
|
|
|
|
28
|
|
|
* @param string $name (optional) |
|
|
|
|
|
|
29
|
|
|
* |
|
30
|
|
|
* @return MessageBoxField |
|
31
|
|
|
*/ |
|
32
|
|
|
public static function generic($message = null, $CSSClass = null, $name = null) |
|
33
|
|
|
{ |
|
34
|
|
|
// ensure that we are having a name as well as keeping it consistent with the original behaviour |
|
35
|
|
|
if ($name == null) { |
|
|
|
|
|
|
36
|
|
|
$name = md5($message); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
return MessageBoxField::create( |
|
40
|
|
|
$name, |
|
41
|
|
|
$message |
|
42
|
|
|
)->addCSSClass($CSSClass); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Creates a error message. |
|
47
|
|
|
* |
|
48
|
|
|
* @param string $message |
|
|
|
|
|
|
49
|
|
|
* @param string $name (optional) |
|
|
|
|
|
|
50
|
|
|
* |
|
51
|
|
|
* @return MessageBoxField |
|
52
|
|
|
*/ |
|
53
|
|
|
public static function error($message = null, $name = null) |
|
54
|
|
|
{ |
|
55
|
|
|
return self::generic($message, ErrorMessage::$CSSClass, $name); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Creates a warning message. |
|
60
|
|
|
* |
|
61
|
|
|
* @param string $message |
|
|
|
|
|
|
62
|
|
|
* @param string $name (optional) |
|
|
|
|
|
|
63
|
|
|
* |
|
64
|
|
|
* @return MessageBoxField |
|
65
|
|
|
*/ |
|
66
|
|
|
public static function warning($message = null, $name = null) |
|
67
|
|
|
{ |
|
68
|
|
|
return self::generic($message, WarningMessage::$CSSClass, $name); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Creates a success message. |
|
73
|
|
|
* |
|
74
|
|
|
* @param string $message |
|
|
|
|
|
|
75
|
|
|
* @param string $name (optional) |
|
|
|
|
|
|
76
|
|
|
* |
|
77
|
|
|
* @return MessageBoxField |
|
78
|
|
|
*/ |
|
79
|
|
|
public static function success($message = null, $name = null) |
|
80
|
|
|
{ |
|
81
|
|
|
return self::generic($message, SuccessMessage::$CSSClass, $name); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Creates a notice message. |
|
86
|
|
|
* |
|
87
|
|
|
* @param string $message |
|
|
|
|
|
|
88
|
|
|
* @param string $name (optional) |
|
|
|
|
|
|
89
|
|
|
* |
|
90
|
|
|
* @return MessageBoxField |
|
91
|
|
|
*/ |
|
92
|
|
|
public static function notice($message = null, $name = null) |
|
93
|
|
|
{ |
|
94
|
|
|
return self::generic($message, NoticeMessage::$CSSClass, $name); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.