1 | <?php |
||
2 | |||
3 | /** |
||
4 | * NotifyLibrary.php |
||
5 | * |
||
6 | * Adapter for the Notify library. |
||
7 | * |
||
8 | * @package jaxon-dialogs |
||
9 | * @author Thierry Feuzeu <[email protected]> |
||
10 | * @copyright 2016 Thierry Feuzeu <[email protected]> |
||
11 | * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
||
12 | * @link https://github.com/jaxon-php/jaxon-dialogs |
||
13 | */ |
||
14 | |||
15 | namespace Jaxon\Dialogs\Notify; |
||
16 | |||
17 | use Jaxon\App\Dialog\Library\DialogLibraryTrait; |
||
18 | use Jaxon\App\Dialog\MessageInterface; |
||
19 | |||
20 | class NotifyLibrary implements MessageInterface |
||
21 | { |
||
22 | use DialogLibraryTrait; |
||
23 | |||
24 | /** |
||
25 | * @const The library name |
||
26 | */ |
||
27 | const NAME = 'notify'; |
||
28 | |||
29 | /** |
||
30 | * @inheritDoc |
||
31 | */ |
||
32 | public function getName(): string |
||
33 | { |
||
34 | return self::NAME; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @inheritDoc |
||
39 | */ |
||
40 | public function getSubdir(): string |
||
41 | { |
||
42 | return 'notify'; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @inheritDoc |
||
47 | */ |
||
48 | public function getVersion(): string |
||
49 | { |
||
50 | return '0.4.2'; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @inheritDoc |
||
55 | */ |
||
56 | public function getJs(): string |
||
57 | { |
||
58 | return $this->helper()->getJsCode('notify.js'); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @inheritDoc |
||
63 | */ |
||
64 | public function getScript(): string |
||
65 | { |
||
66 | return $this->helper()->render('notify/alert.js'); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @inheritDoc |
||
71 | */ |
||
72 | public function getReadyScript(): string |
||
73 | { |
||
74 | return $this->helper()->render('notify/ready.js.php'); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Print an alert message. |
||
79 | * |
||
80 | * @param string $sMessage The text of the message |
||
81 | * @param string $sTitle The title of the message |
||
82 | * @param string $sClass The type of the message |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | protected function alert(string $sMessage, string $sTitle, string $sClass): string |
||
0 ignored issues
–
show
|
|||
87 | { |
||
88 | if($this->returnCode()) |
||
89 | { |
||
90 | return "$.notify(" . $sMessage . ", {className:'" . $sClass . "', position:'top center'})"; |
||
91 | } |
||
92 | $aOptions = array('message' => $sMessage, 'className' => $sClass); |
||
93 | // Show the alert |
||
94 | $this->addCommand(array('cmd' => 'notify.alert'), $aOptions); |
||
95 | return ''; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @inheritDoc |
||
100 | */ |
||
101 | public function success(string $sMessage, string $sTitle = ''): string |
||
102 | { |
||
103 | return $this->alert($sMessage, $sTitle, 'success'); |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * @inheritDoc |
||
108 | */ |
||
109 | public function info(string $sMessage, string $sTitle = ''): string |
||
110 | { |
||
111 | return $this->alert($sMessage, $sTitle, 'info'); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @inheritDoc |
||
116 | */ |
||
117 | public function warning(string $sMessage, string $sTitle = ''): string |
||
118 | { |
||
119 | return $this->alert($sMessage, $sTitle, 'warn'); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * @inheritDoc |
||
124 | */ |
||
125 | public function error(string $sMessage, string $sTitle = ''): string |
||
126 | { |
||
127 | return $this->alert($sMessage, $sTitle, 'error'); |
||
128 | } |
||
129 | } |
||
130 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.