1 | <?php |
||
2 | |||
3 | /** |
||
4 | * OverhangLibrary.php |
||
5 | * |
||
6 | * Adapter for the Overhang 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\Overhang; |
||
16 | |||
17 | use Jaxon\App\Dialog\Library\DialogLibraryTrait; |
||
18 | use Jaxon\App\Dialog\MessageInterface; |
||
19 | use Jaxon\App\Dialog\QuestionInterface; |
||
20 | |||
21 | class OverhangLibrary implements MessageInterface, QuestionInterface |
||
22 | { |
||
23 | use DialogLibraryTrait; |
||
24 | |||
25 | /** |
||
26 | * @const The library name |
||
27 | */ |
||
28 | const NAME = 'overhang'; |
||
29 | |||
30 | /** |
||
31 | * @inheritDoc |
||
32 | */ |
||
33 | public function getName(): string |
||
34 | { |
||
35 | return self::NAME; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @inheritDoc |
||
40 | */ |
||
41 | public function getSubdir(): string |
||
42 | { |
||
43 | return 'overhang'; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @inheritDoc |
||
48 | */ |
||
49 | public function getVersion(): string |
||
50 | { |
||
51 | return 'latest'; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @inheritDoc |
||
56 | */ |
||
57 | public function getJs(): string |
||
58 | { |
||
59 | return $this->helper()->getJsCode('overhang.min.js'); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @inheritDoc |
||
64 | */ |
||
65 | public function getCss(): string |
||
66 | { |
||
67 | return $this->helper()->getCssCode('overhang.min.css'); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @inheritDoc |
||
72 | */ |
||
73 | public function getScript(): string |
||
74 | { |
||
75 | return $this->helper()->render('overhang/alert.js'); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @inheritDoc |
||
80 | */ |
||
81 | public function getReadyScript(): string |
||
82 | { |
||
83 | return $this->helper()->render('overhang/ready.js.php'); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Print an alert message. |
||
88 | * |
||
89 | * @param string $sMessage The text of the message |
||
90 | * @param string $sTitle The title of the message |
||
91 | * @param string $sType The type of the message |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | protected function alert(string $sMessage, string $sTitle, string $sType): string |
||
0 ignored issues
–
show
|
|||
96 | { |
||
97 | if($this->returnCode()) |
||
98 | { |
||
99 | return "$('body').overhang({message:" . $sMessage . ", type:'" . $sType . "'})"; |
||
100 | } |
||
101 | $aOptions = ['message' => $sMessage, 'type' => $sType]; |
||
102 | // Show the alert |
||
103 | $this->addCommand(['cmd' => 'overhang.alert'], $aOptions); |
||
104 | return ''; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * @inheritDoc |
||
109 | */ |
||
110 | public function success(string $sMessage, string $sTitle = ''): string |
||
111 | { |
||
112 | return $this->alert($sMessage, $sTitle, 'success'); |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * @inheritDoc |
||
117 | */ |
||
118 | public function info(string $sMessage, string $sTitle = ''): string |
||
119 | { |
||
120 | return $this->alert($sMessage, $sTitle, 'info'); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * @inheritDoc |
||
125 | */ |
||
126 | public function warning(string $sMessage, string $sTitle = ''): string |
||
127 | { |
||
128 | return $this->alert($sMessage, $sTitle, 'warn'); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @inheritDoc |
||
133 | */ |
||
134 | public function error(string $sMessage, string $sTitle = ''): string |
||
135 | { |
||
136 | return $this->alert($sMessage, $sTitle, 'error'); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * @inheritDoc |
||
141 | */ |
||
142 | public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string |
||
143 | { |
||
144 | if(!$sNoScript) |
||
145 | { |
||
146 | return "jaxon.dialogs.overhang.confirm(" . $sQuestion . ",function(){" . $sYesScript . ";})"; |
||
147 | } |
||
148 | else |
||
149 | { |
||
150 | return "jaxon.dialogs.overhang.confirm(" . $sQuestion . ",function(){" . $sYesScript . ";},function(){" . $sNoScript . ";})"; |
||
151 | } |
||
152 | } |
||
153 | } |
||
154 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.