|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* JQueryConfirmLibrary.php |
|
5
|
|
|
* |
|
6
|
|
|
* Adapter for the JQuery-Confirm 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\JQueryConfirm; |
|
16
|
|
|
|
|
17
|
|
|
use Jaxon\App\Dialog\Library\DialogLibraryTrait; |
|
18
|
|
|
use Jaxon\App\Dialog\Library\MessageTrait; |
|
|
|
|
|
|
19
|
|
|
use Jaxon\App\Dialog\Library\QuestionTrait; |
|
|
|
|
|
|
20
|
|
|
use Jaxon\App\Dialog\ModalInterface; |
|
21
|
|
|
use Jaxon\App\Dialog\MessageInterface; |
|
22
|
|
|
use Jaxon\App\Dialog\QuestionInterface; |
|
23
|
|
|
|
|
24
|
|
|
class JQueryConfirmLibrary implements ModalInterface, MessageInterface, QuestionInterface |
|
25
|
|
|
{ |
|
26
|
|
|
use DialogLibraryTrait; |
|
27
|
|
|
use MessageTrait; |
|
28
|
|
|
use QuestionTrait; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @const The library name |
|
32
|
|
|
*/ |
|
33
|
|
|
const NAME = 'jconfirm'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @inheritDoc |
|
37
|
|
|
*/ |
|
38
|
|
|
public function getName(): string |
|
39
|
|
|
{ |
|
40
|
|
|
return self::NAME; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @inheritDoc |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getSubdir(): string |
|
47
|
|
|
{ |
|
48
|
|
|
return 'jquery-confirm'; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @inheritDoc |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getVersion(): string |
|
55
|
|
|
{ |
|
56
|
|
|
return '3.3.0'; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @inheritDoc |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getJs(): string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->helper()->getJsCode('jquery-confirm.min.js'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @inheritDoc |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getCss(): string |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->helper()->getCssCode('jquery-confirm.min.css') . ' |
|
73
|
|
|
<style> |
|
74
|
|
|
.jconfirm .jconfirm-box div.jconfirm-content-pane { |
|
75
|
|
|
margin-top: 15px; |
|
76
|
|
|
} |
|
77
|
|
|
</style> |
|
78
|
|
|
'; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @inheritDoc |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getScript(): string |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->helper()->render('jqueryconfirm/alert.js'); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @inheritDoc |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getReadyScript(): string |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->helper()->render('jqueryconfirm/ready.js.php'); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @inheritDoc |
|
99
|
|
|
*/ |
|
100
|
|
|
public function show(string $sTitle, string $sMessage, array $aButtons, array $aOptions = []) |
|
101
|
|
|
{ |
|
102
|
|
|
$aOptions['title'] = $sTitle; |
|
103
|
|
|
$aOptions['content'] = $sMessage; |
|
104
|
|
|
$aOptions['buttons'] = []; |
|
105
|
|
|
if(!array_key_exists('boxWidth', $aOptions)) |
|
106
|
|
|
{ |
|
107
|
|
|
$aOptions['useBootstrap'] = false; |
|
108
|
|
|
$aOptions['boxWidth'] = '600'; |
|
109
|
|
|
} |
|
110
|
|
|
$ind = 0; |
|
111
|
|
|
foreach($aButtons as $button) |
|
112
|
|
|
{ |
|
113
|
|
|
$_button = [ |
|
114
|
|
|
'text' => $button['title'], |
|
115
|
|
|
'btnClass' => $button['class'], |
|
116
|
|
|
'action' => $button['click'], |
|
117
|
|
|
]; |
|
118
|
|
|
// Optional attributes |
|
119
|
|
|
foreach($button as $attr => $value) |
|
120
|
|
|
{ |
|
121
|
|
|
if(!in_array($attr, ['title', 'class', 'click'])) |
|
122
|
|
|
{ |
|
123
|
|
|
$_button[$attr] = $value; |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
$aOptions['buttons']['btn' . $ind++] = $_button; |
|
127
|
|
|
} |
|
128
|
|
|
// Show dialog |
|
129
|
|
|
$this->addCommand('jconfirm.show', $aOptions); |
|
|
|
|
|
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @inheritDoc |
|
134
|
|
|
*/ |
|
135
|
|
|
public function hide() |
|
136
|
|
|
{ |
|
137
|
|
|
// Hide dialog |
|
138
|
|
|
$this->addCommand('jconfirm.hide', []); |
|
|
|
|
|
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @inheritDoc |
|
143
|
|
|
*/ |
|
144
|
|
|
protected function alert(string $sMessage, string $sTitle, string $sStdType) |
|
145
|
|
|
{ |
|
146
|
|
|
$aTypes = [ |
|
147
|
|
|
'success' => 'green', |
|
148
|
|
|
'info' => 'blue', |
|
149
|
|
|
'warning' => 'orange', |
|
150
|
|
|
'error' => 'red', |
|
151
|
|
|
]; |
|
152
|
|
|
$sIcon = "fa fa-$sStdType"; |
|
153
|
|
|
$sType = $aTypes[$sStdType] ?? $sStdType; |
|
154
|
|
|
$this->addCommand('jconfirm.alert', |
|
|
|
|
|
|
155
|
|
|
['content' => $sMessage, 'title' => $sTitle, 'type' => $sType, 'icon' => $sIcon]); |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
|
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