1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* DialogLibraryInterface.php - Adapter for the jAlert 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\JAlert; |
14
|
|
|
|
15
|
|
|
use Jaxon\Ui\Dialog\Library\AbstractDialogLibrary; |
|
|
|
|
16
|
|
|
use Jaxon\Ui\Dialog\MessageInterface; |
|
|
|
|
17
|
|
|
use Jaxon\Ui\Dialog\QuestionInterface; |
|
|
|
|
18
|
|
|
|
19
|
|
|
class JAlertLibrary extends AbstractDialogLibrary implements MessageInterface, QuestionInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @const The library name |
23
|
|
|
*/ |
24
|
|
|
const NAME = 'jalert'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @inheritDoc |
28
|
|
|
*/ |
29
|
|
|
public function getName(): string |
30
|
|
|
{ |
31
|
|
|
return self::NAME; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @inheritDoc |
36
|
|
|
*/ |
37
|
|
|
public function getSubdir(): string |
38
|
|
|
{ |
39
|
|
|
return 'jAlert'; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @inheritDoc |
44
|
|
|
*/ |
45
|
|
|
public function getVersion(): string |
46
|
|
|
{ |
47
|
|
|
return '4.5.1'; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @inheritDoc |
52
|
|
|
*/ |
53
|
|
|
public function getJs(): string |
54
|
|
|
{ |
55
|
|
|
return $this->xHelper->getJsCode('jAlert.min.js'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @inheritDoc |
60
|
|
|
*/ |
61
|
|
|
public function getCss(): string |
62
|
|
|
{ |
63
|
|
|
return $this->xHelper->getCssCode('jAlert.css'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @inheritDoc |
68
|
|
|
*/ |
69
|
|
|
public function getScript(): string |
70
|
|
|
{ |
71
|
|
|
return $this->xHelper->render('jalert/alert.js'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @inheritDoc |
76
|
|
|
*/ |
77
|
|
|
public function getReadyScript(): string |
78
|
|
|
{ |
79
|
|
|
return $this->xHelper->render('jalert/ready.js.php'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Print an alert message. |
84
|
|
|
* |
85
|
|
|
* @param string $sContent The text of the message |
86
|
|
|
* @param string $sTitle The title of the message |
87
|
|
|
* @param string $sTheme The type of the message |
88
|
|
|
* |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
protected function alert(string $sContent, string $sTitle, string $sTheme): string |
92
|
|
|
{ |
93
|
|
|
if(!$sTitle) |
94
|
|
|
{ |
95
|
|
|
$sTitle = ' '; |
96
|
|
|
} |
97
|
|
|
if($this->returnCode()) |
98
|
|
|
{ |
99
|
|
|
return "$.jAlert({content:" . $sContent . ", title:'" . $sTitle . "', theme:'" . $sTheme . "'})"; |
100
|
|
|
} |
101
|
|
|
$this->addCommand(array('cmd' => 'jalert.alert'), array('content' => $sContent, 'title' => $sTitle, 'theme' => $sTheme)); |
102
|
|
|
return ''; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @inheritDoc |
107
|
|
|
*/ |
108
|
|
|
public function success(string $sMessage, string $sTitle = ''): string |
109
|
|
|
{ |
110
|
|
|
return $this->alert($sMessage, $sTitle, 'green'); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @inheritDoc |
115
|
|
|
*/ |
116
|
|
|
public function info(string $sMessage, string $sTitle = ''): string |
117
|
|
|
{ |
118
|
|
|
return $this->alert($sMessage, $sTitle, 'blue'); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @inheritDoc |
123
|
|
|
*/ |
124
|
|
|
public function warning(string $sMessage, string $sTitle = ''): string |
125
|
|
|
{ |
126
|
|
|
return $this->alert($sMessage, $sTitle, 'yellow'); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @inheritDoc |
131
|
|
|
*/ |
132
|
|
|
public function error(string $sMessage, string $sTitle = ''): string |
133
|
|
|
{ |
134
|
|
|
return $this->alert($sMessage, $sTitle, 'red'); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @inheritDoc |
139
|
|
|
*/ |
140
|
|
|
public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string |
141
|
|
|
{ |
142
|
|
|
$sTitle = $this->xHelper->getQuestionTitle(); |
143
|
|
|
if(!$sNoScript) |
144
|
|
|
{ |
145
|
|
|
return "jaxon.dialogs.jalert.confirm(" . $sQuestion . ",'" . $sTitle . "',function(){" . $sYesScript . ";})"; |
146
|
|
|
} |
147
|
|
|
else |
148
|
|
|
{ |
149
|
|
|
return "jaxon.dialogs.jalert.confirm(" . $sQuestion . ",'" . $sTitle . "',function(){" . $sYesScript . ";},function(){" . $sNoScript . ";})"; |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|
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