|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* XDialogLibrary.php |
|
5
|
|
|
* |
|
6
|
|
|
* Adapter for the XDialog library. |
|
7
|
|
|
* |
|
8
|
|
|
* @package jaxon-dialogs |
|
9
|
|
|
* @author Thierry Feuzeu <[email protected]> |
|
10
|
|
|
* @copyright 2022 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\XDialog; |
|
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 XDialogLibrary 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 = 'xdialog'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @inheritDoc |
|
37
|
|
|
*/ |
|
38
|
|
|
public function getName(): string |
|
39
|
|
|
{ |
|
40
|
|
|
return self::NAME; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @inheritDoc |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getUri(): string |
|
47
|
|
|
{ |
|
48
|
|
|
return 'https://cdn.jsdelivr.net/gh/xxjapp/xdialog@3'; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @inheritDoc |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getCss(): string |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->helper()->getCssCode('xdialog.min.css'); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @inheritDoc |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getJs(): string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->helper()->getJsCode('xdialog.min.js'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @inheritDoc |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getScript(): string |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->helper()->render('xdialog/alert.js'); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @inheritDoc |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getReadyScript(): string |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->helper()->render('xdialog/ready.js.php'); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @inheritDoc |
|
85
|
|
|
*/ |
|
86
|
|
|
public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []) |
|
87
|
|
|
{ |
|
88
|
|
|
$aOptions['title'] = $sTitle; |
|
89
|
|
|
$aOptions['body'] = $sContent; |
|
90
|
|
|
$aOptions['buttons'] = []; |
|
91
|
|
|
foreach($aButtons as $aButton) |
|
92
|
|
|
{ |
|
93
|
|
|
if($aButton['click'] === 'close') |
|
94
|
|
|
{ |
|
95
|
|
|
$aOptions['buttons']['cancel'] = $aButton['title']; |
|
96
|
|
|
$aOptions['oncancel'] = 'jaxon.dialogs.xdialog.hide()'; |
|
97
|
|
|
} |
|
98
|
|
|
else |
|
99
|
|
|
{ |
|
100
|
|
|
$aOptions['buttons']['ok'] = $aButton['title']; |
|
101
|
|
|
$aOptions['onok'] = $aButton['click']; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
// Assign dialog content |
|
106
|
|
|
$this->addCommand('xdialog.show', $aOptions); |
|
|
|
|
|
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @inheritDoc |
|
111
|
|
|
*/ |
|
112
|
|
|
public function hide() |
|
113
|
|
|
{ |
|
114
|
|
|
$this->addCommand('xdialog.hide', []); |
|
|
|
|
|
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @inheritDoc |
|
119
|
|
|
*/ |
|
120
|
|
|
protected function alert(string $sMessage, string $sTitle, string $sType) |
|
121
|
|
|
{ |
|
122
|
|
|
$this->addCommand("xdialog.$sType", ['body' => $sMessage, 'title' => $sTitle]); |
|
|
|
|
|
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
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