1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Dialogs.php - Shows alert and confirm dialogs |
5
|
|
|
* |
6
|
|
|
* @author Thierry Feuzeu <[email protected]> |
7
|
|
|
* @copyright 2019 Thierry Feuzeu <[email protected]> |
8
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
9
|
|
|
* @link https://github.com/jaxon-php/jaxon-core |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Jaxon\Dialog; |
13
|
|
|
|
14
|
|
|
use Jaxon\Jaxon; |
15
|
|
|
use Jaxon\Plugin\Package; |
16
|
|
|
use Jaxon\Config\Config; |
17
|
|
|
|
18
|
|
|
class Dialog |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Javascript confirm function |
22
|
|
|
* |
23
|
|
|
* @var Jaxon\Dialog\Interfaces\Confirm |
24
|
|
|
*/ |
25
|
|
|
private $xConfirm; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Default javascript confirm function |
29
|
|
|
* |
30
|
|
|
* @var Jaxon\Dialog\Confirm |
31
|
|
|
*/ |
32
|
|
|
private $xDefaultConfirm; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Javascript alert function |
36
|
|
|
* |
37
|
|
|
* @var Jaxon\Dialog\Interfaces\Alert |
38
|
|
|
*/ |
39
|
|
|
private $xAlert; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Default javascript alert function |
43
|
|
|
* |
44
|
|
|
* @var Jaxon\Dialog\Alert |
45
|
|
|
*/ |
46
|
|
|
private $xDefaultAlert; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* The constructor |
50
|
|
|
*/ |
51
|
|
|
public function __construct() |
52
|
|
|
{ |
53
|
|
|
// Javascript confirm function |
54
|
|
|
$this->xConfirm = null; |
55
|
|
|
$this->xDefaultConfirm = new Confirm(); |
|
|
|
|
56
|
|
|
|
57
|
|
|
// Javascript alert function |
58
|
|
|
$this->xAlert = null; |
59
|
|
|
$this->xDefaultAlert = new Alert(); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Set the javascript confirm function |
64
|
|
|
* |
65
|
|
|
* @param Jaxon\Dialog\Interfaces\Confirm $xConfirm The javascript confirm function |
66
|
|
|
* |
67
|
|
|
* @return void |
68
|
|
|
*/ |
69
|
|
|
public function setConfirm(Interfaces\Confirm $xConfirm) |
70
|
|
|
{ |
71
|
|
|
$this->xConfirm = $xConfirm; |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get the javascript confirm function |
76
|
|
|
* |
77
|
|
|
* @return Jaxon\Dialog\Interfaces\Confirm |
78
|
|
|
*/ |
79
|
|
|
public function getConfirm() |
80
|
|
|
{ |
81
|
|
|
return (($this->xConfirm) ? $this->xConfirm : $this->xDefaultConfirm); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get the default javascript confirm function |
86
|
|
|
* |
87
|
|
|
* @return Jaxon\Dialog\Confirm |
88
|
|
|
*/ |
89
|
|
|
public function getDefaultConfirm() |
90
|
|
|
{ |
91
|
|
|
return $this->xDefaultConfirm; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Get the script which makes a call only if the user answers yes to the given question |
96
|
|
|
* |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
|
|
public function confirm($question, $yesScript, $noScript) |
100
|
|
|
{ |
101
|
|
|
return $this->getConfirm()->confirm($question, $yesScript, $noScript); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Set the javascript alert function |
106
|
|
|
* |
107
|
|
|
* @param Jaxon\Dialog\Interfaces\Alert $xAlert The javascript alert function |
108
|
|
|
* |
109
|
|
|
* @return void |
110
|
|
|
*/ |
111
|
|
|
public function setAlert(Interfaces\Alert $xAlert) |
112
|
|
|
{ |
113
|
|
|
$this->xAlert = $xAlert; |
|
|
|
|
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Get the javascript alert function |
118
|
|
|
* |
119
|
|
|
* @return Jaxon\Dialog\Interfaces\Alert |
120
|
|
|
*/ |
121
|
|
|
public function getAlert() |
122
|
|
|
{ |
123
|
|
|
return (($this->xAlert) ? $this->xAlert : $this->xDefaultAlert); |
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Get the default javascript alert function |
128
|
|
|
* |
129
|
|
|
* @return Jaxon\Dialog\Alert |
130
|
|
|
*/ |
131
|
|
|
public function getDefaultAlert() |
132
|
|
|
{ |
133
|
|
|
return $this->xDefaultAlert; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..