1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* DialogLibraryInterface.php - Adapter for the Lobibox library. |
5
|
|
|
* |
6
|
|
|
* @package jaxon-dialogs |
7
|
|
|
* @author Thierry Feuzeu <[email protected]> |
8
|
|
|
* @copyright 2016 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-dialogs |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Jaxon\Dialogs\Library\Lobibox; |
14
|
|
|
|
15
|
|
|
use Jaxon\Ui\Dialog\Library\AbstractDialogLibrary; |
|
|
|
|
16
|
|
|
use Jaxon\Ui\Dialog\ModalInterface; |
|
|
|
|
17
|
|
|
use Jaxon\Ui\Dialog\MessageInterface; |
|
|
|
|
18
|
|
|
use Jaxon\Ui\Dialog\QuestionInterface; |
|
|
|
|
19
|
|
|
|
20
|
|
|
class LobiboxLibrary extends AbstractDialogLibrary implements ModalInterface, MessageInterface, QuestionInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @const The library name |
24
|
|
|
*/ |
25
|
|
|
const NAME = 'lobibox'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @inheritDoc |
29
|
|
|
*/ |
30
|
|
|
public function getName(): string |
31
|
|
|
{ |
32
|
|
|
return self::NAME; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @inheritDoc |
37
|
|
|
*/ |
38
|
|
|
public function getSubdir(): string |
39
|
|
|
{ |
40
|
|
|
return 'lobibox'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @inheritDoc |
45
|
|
|
*/ |
46
|
|
|
public function getVersion(): string |
47
|
|
|
{ |
48
|
|
|
return '1.2.4'; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @inheritDoc |
53
|
|
|
*/ |
54
|
|
|
public function getJs(): string |
55
|
|
|
{ |
56
|
|
|
return $this->xHelper->getJsCode('lobibox.min.js'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @inheritDoc |
61
|
|
|
*/ |
62
|
|
|
public function getCss(): string |
63
|
|
|
{ |
64
|
|
|
return $this->xHelper->getCssCode('lobibox.min.css'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @inheritDoc |
69
|
|
|
*/ |
70
|
|
|
public function getScript(): string |
71
|
|
|
{ |
72
|
|
|
return $this->xHelper->render('lobibox/alert.js'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @inheritDoc |
77
|
|
|
*/ |
78
|
|
|
public function getReadyScript(): string |
79
|
|
|
{ |
80
|
|
|
return $this->xHelper->render('lobibox/ready.js.php'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @inheritDoc |
85
|
|
|
*/ |
86
|
|
|
public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []) |
87
|
|
|
{ |
88
|
|
|
// Fill the options array with the parameters |
89
|
|
|
$aOptions['title'] = $sTitle; |
90
|
|
|
$aOptions['content'] = $sContent; |
91
|
|
|
$aOptions['buttons'] = []; |
92
|
|
|
$ind = 0; |
93
|
|
|
foreach($aButtons as $button) |
94
|
|
|
{ |
95
|
|
|
$_button = [ |
96
|
|
|
'text' => $button['title'], |
97
|
|
|
'action' => $button['click'], |
98
|
|
|
'class' => $button['class'], |
99
|
|
|
]; |
100
|
|
|
// Optional attributes |
101
|
|
|
foreach($button as $attr => $value) |
102
|
|
|
{ |
103
|
|
|
if(!in_array($attr, ['title', 'class', 'click'])) |
104
|
|
|
{ |
105
|
|
|
$_button[$attr] = $value; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
$aOptions['buttons']['btn' . $ind] = $_button; |
109
|
|
|
$ind++; |
110
|
|
|
} |
111
|
|
|
// Show the modal dialog |
112
|
|
|
$this->addCommand(array('cmd' => 'lobibox.show'), $aOptions); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @inheritDoc |
117
|
|
|
*/ |
118
|
|
|
public function hide() |
119
|
|
|
{ |
120
|
|
|
// Hide the modal dialog |
121
|
|
|
$this->addCommand(array('cmd' => 'lobibox.hide'), array()); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Print an alert message. |
126
|
|
|
* |
127
|
|
|
* @param string $sMessage The text of the message |
128
|
|
|
* @param string $sTitle The title of the message |
129
|
|
|
* @param string $sType The type of the message |
130
|
|
|
* |
131
|
|
|
* @return string |
132
|
|
|
*/ |
133
|
|
|
protected function notify(string $sMessage, string $sTitle, string $sType): string |
134
|
|
|
{ |
135
|
|
|
if($this->returnCode()) |
136
|
|
|
{ |
137
|
|
|
return "Lobibox.notify('" . $sType . "', {title:'" . $sTitle . "', msg:" . $sMessage . "})"; |
138
|
|
|
} |
139
|
|
|
$aOptions = array('message' => $sMessage, 'type' => $sType, 'title' => (($sTitle) ?: false)); |
140
|
|
|
// Show the alert |
141
|
|
|
$this->addCommand(array('cmd' => 'lobibox.notify'), $aOptions); |
142
|
|
|
return ''; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @inheritDoc |
147
|
|
|
*/ |
148
|
|
|
public function success(string $sMessage, string $sTitle = ''): string |
149
|
|
|
{ |
150
|
|
|
return $this->notify($sMessage, $sTitle, 'success'); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @inheritDoc |
155
|
|
|
*/ |
156
|
|
|
public function info(string $sMessage, string $sTitle = ''): string |
157
|
|
|
{ |
158
|
|
|
return $this->notify($sMessage, $sTitle, 'info'); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @inheritDoc |
163
|
|
|
*/ |
164
|
|
|
public function warning(string $sMessage, string $sTitle = ''): string |
165
|
|
|
{ |
166
|
|
|
return $this->notify($sMessage, $sTitle, 'warning'); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @inheritDoc |
171
|
|
|
*/ |
172
|
|
|
public function error(string $sMessage, string $sTitle = ''): string |
173
|
|
|
{ |
174
|
|
|
return $this->notify($sMessage, $sTitle, 'error'); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @inheritDoc |
179
|
|
|
*/ |
180
|
|
|
public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string |
181
|
|
|
{ |
182
|
|
|
$sTitle = $this->xHelper->getQuestionTitle(); |
183
|
|
|
if(!$sNoScript) |
184
|
|
|
{ |
185
|
|
|
return "jaxon.dialogs.lobibox.confirm(" . $sQuestion . ",'" . |
186
|
|
|
$sTitle . "',function(){" . $sYesScript . ";})"; |
187
|
|
|
} |
188
|
|
|
return "jaxon.dialogs.lobibox.confirm(" . $sQuestion . ",'" . |
189
|
|
|
$sTitle . "',function(){" . $sYesScript . ";},function(){" . $sNoScript . ";})"; |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths