|
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
|
|
|
* The constructor |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct() |
|
25
|
|
|
{ |
|
26
|
|
|
parent::__construct('jAlert', '4.5.1'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @inheritDoc |
|
31
|
|
|
*/ |
|
32
|
|
|
public function getJs(): string |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->xHelper->getJsCode('jAlert.min.js'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @inheritDoc |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getCss(): string |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->xHelper->getCssCode('jAlert.css'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @inheritDoc |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getScript(): string |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->xHelper->render('jalert/alert.js'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @inheritDoc |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getReadyScript(): string |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->xHelper->render('jalert/ready.js.php'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Print an alert message. |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $sContent The text of the message |
|
65
|
|
|
* @param string $sTitle The title of the message |
|
66
|
|
|
* @param string $sTheme The type of the message |
|
67
|
|
|
* |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function alert(string $sContent, string $sTitle, string $sTheme): string |
|
71
|
|
|
{ |
|
72
|
|
|
if(!$sTitle) |
|
73
|
|
|
{ |
|
74
|
|
|
$sTitle = ' '; |
|
75
|
|
|
} |
|
76
|
|
|
if($this->returnCode()) |
|
77
|
|
|
{ |
|
78
|
|
|
return "$.jAlert({content:" . $sContent . ", title:'" . $sTitle . "', theme:'" . $sTheme . "'})"; |
|
79
|
|
|
} |
|
80
|
|
|
$this->addCommand(array('cmd' => 'jalert.alert'), array('content' => $sContent, 'title' => $sTitle, 'theme' => $sTheme)); |
|
81
|
|
|
return ''; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @inheritDoc |
|
86
|
|
|
*/ |
|
87
|
|
|
public function success(string $sMessage, string $sTitle = ''): string |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->alert($sMessage, $sTitle, 'green'); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @inheritDoc |
|
94
|
|
|
*/ |
|
95
|
|
|
public function info(string $sMessage, string $sTitle = ''): string |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->alert($sMessage, $sTitle, 'blue'); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @inheritDoc |
|
102
|
|
|
*/ |
|
103
|
|
|
public function warning(string $sMessage, string $sTitle = ''): string |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->alert($sMessage, $sTitle, 'yellow'); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @inheritDoc |
|
110
|
|
|
*/ |
|
111
|
|
|
public function error(string $sMessage, string $sTitle = ''): string |
|
112
|
|
|
{ |
|
113
|
|
|
return $this->alert($sMessage, $sTitle, 'red'); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @inheritDoc |
|
118
|
|
|
*/ |
|
119
|
|
|
public function confirm(string $sQuestion, string $sYesScript, string $sNoScript): string |
|
120
|
|
|
{ |
|
121
|
|
|
$sTitle = $this->xHelper->getQuestionTitle(); |
|
122
|
|
|
if(!$sNoScript) |
|
123
|
|
|
{ |
|
124
|
|
|
return "jaxon.dialogs.jalert.confirm(" . $sQuestion . ",'" . $sTitle . "',function(){" . $sYesScript . ";})"; |
|
125
|
|
|
} |
|
126
|
|
|
else |
|
127
|
|
|
{ |
|
128
|
|
|
return "jaxon.dialogs.jalert.confirm(" . $sQuestion . ",'" . $sTitle . "',function(){" . $sYesScript . ";},function(){" . $sNoScript . ";})"; |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
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