1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MessageTrait.php - Default methods for alert messages. |
5
|
|
|
* |
6
|
|
|
* @package jaxon-core |
|
|
|
|
7
|
|
|
* @author Thierry Feuzeu <[email protected]> |
8
|
|
|
* @copyright 2024 Thierry Feuzeu <[email protected]> |
9
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
10
|
|
|
* @link https://github.com/jaxon-php/jaxon-core |
11
|
|
|
*/ |
|
|
|
|
12
|
|
|
|
13
|
|
|
namespace Jaxon\App\Dialog\Library; |
14
|
|
|
|
15
|
|
|
trait MessageTrait |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Print an alert message. |
19
|
|
|
* |
20
|
|
|
* @param string $sContent The text of the message |
21
|
|
|
* @param string $sTitle The title of the message |
|
|
|
|
22
|
|
|
* @param string $sType The type of the message |
|
|
|
|
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
abstract protected function alert(string $sContent, string $sTitle, string $sType); |
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Show a success message. |
30
|
|
|
* |
31
|
|
|
* @param string $sMessage The text of the message |
|
|
|
|
32
|
|
|
* @param string $sTitle The title of the message |
|
|
|
|
33
|
|
|
* |
34
|
|
|
* @return void |
35
|
|
|
*/ |
36
|
|
|
public function success(string $sMessage, string $sTitle = '') |
37
|
|
|
{ |
38
|
|
|
return $this->alert($sMessage, $sTitle, 'success'); |
|
|
|
|
39
|
|
|
} |
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Show an information message. |
43
|
|
|
* |
44
|
|
|
* @param string $sMessage The text of the message |
|
|
|
|
45
|
|
|
* @param string $sTitle The title of the message |
|
|
|
|
46
|
|
|
* |
47
|
|
|
* @return void |
48
|
|
|
*/ |
49
|
|
|
public function info(string $sMessage, string $sTitle = '') |
50
|
|
|
{ |
51
|
|
|
return $this->alert($sMessage, $sTitle, 'info'); |
|
|
|
|
52
|
|
|
} |
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Show a warning message. |
56
|
|
|
* |
57
|
|
|
* @param string $sMessage The text of the message |
|
|
|
|
58
|
|
|
* @param string $sTitle The title of the message |
|
|
|
|
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
public function warning(string $sMessage, string $sTitle = '') |
63
|
|
|
{ |
64
|
|
|
return $this->alert($sMessage, $sTitle, 'warning'); |
|
|
|
|
65
|
|
|
} |
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Show an error message. |
69
|
|
|
* |
70
|
|
|
* @param string $sMessage The text of the message |
|
|
|
|
71
|
|
|
* @param string $sTitle The title of the message |
|
|
|
|
72
|
|
|
* |
73
|
|
|
* @return void |
74
|
|
|
*/ |
75
|
|
|
public function error(string $sMessage, string $sTitle = '') |
76
|
|
|
{ |
77
|
|
|
return $this->alert($sMessage, $sTitle, 'error'); |
|
|
|
|
78
|
|
|
} |
|
|
|
|
79
|
|
|
} |
80
|
|
|
|