|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* TJuiDialog class file. |
|
4
|
|
|
* |
|
5
|
|
|
* @author David Otto <ottodavid[at]gmx[dot]net> |
|
6
|
|
|
* @link https://github.com/pradosoft/prado |
|
7
|
|
|
* @copyright Copyright © 2013-2015 PradoSoft |
|
8
|
|
|
* @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9
|
|
|
* @package Prado\Web\UI\JuiControls |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Prado\Web\UI\JuiControls; |
|
13
|
|
|
|
|
14
|
|
|
use Prado\Web\UI\TControl; |
|
15
|
|
|
use Prado\Web\UI\ActiveControls\ICallbackEventHandler; |
|
16
|
|
|
use Prado\Web\UI\ActiveControls\IActiveControl; |
|
17
|
|
|
use Prado\Web\UI\ActiveControls\TActiveControlAdapter; |
|
18
|
|
|
use Prado\Web\Javascripts\TJavaScriptLiteral; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* TJuiDialogButton class |
|
22
|
|
|
* |
|
23
|
|
|
* This button must be child of a TJuiDialog. It can be used to bind an callback |
|
24
|
|
|
* to the buttons of the dialog. |
|
25
|
|
|
* |
|
26
|
|
|
* <code> |
|
27
|
|
|
* <com:TJuiDialog> * > |
|
28
|
|
|
* Text |
|
29
|
|
|
* <com:TJuiDialogButton Text="Ok" OnClick="Ok" /> |
|
30
|
|
|
* |
|
31
|
|
|
* </com:TJuiDialog> |
|
32
|
|
|
* </code> |
|
33
|
|
|
* |
|
34
|
|
|
* @author David Otto <ottodavid[at]gmx[dot]net> |
|
35
|
|
|
* @package Prado\Web\UI\JuiControls |
|
36
|
|
|
* @since 3.3 |
|
37
|
|
|
*/ |
|
38
|
|
|
class TJuiDialogButton extends TControl implements ICallbackEventHandler, IActiveControl |
|
39
|
|
|
{ |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Creates a new callback control, sets the adapter to |
|
43
|
|
|
* TActiveControlAdapter. If you override this class, be sure to set the |
|
44
|
|
|
* adapter appropriately by, for example, by calling this constructor. |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct() |
|
47
|
|
|
{ |
|
48
|
|
|
parent::__construct(); |
|
49
|
|
|
$this->setAdapter(new TActiveControlAdapter($this)); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return TBaseActiveCallbackControl standard callback control options. |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getActiveControl() |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->getAdapter()->getBaseActiveControl(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Array containing defined javascript options |
|
62
|
|
|
* @return array |
|
|
|
|
|
|
63
|
|
|
*/ |
|
64
|
|
|
public function getPostBackOptions() |
|
65
|
|
|
{ |
|
66
|
|
|
return array( |
|
67
|
|
|
'text' => $this->getText(), |
|
68
|
|
|
'click' => new TJavaScriptLiteral("function(){new Prado.Callback('".$this->getUniqueID()."', 'onClick');}" |
|
69
|
|
|
)) ; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return string caption of the button |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getText() |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->getViewState('Text',''); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param string caption of the button |
|
82
|
|
|
*/ |
|
83
|
|
|
public function setText($value) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->setViewState('Text',$value,''); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Raises the OnClick event |
|
90
|
|
|
* @param object $params event parameters |
|
91
|
|
|
*/ |
|
92
|
|
|
public function onClick ($params) |
|
93
|
|
|
{ |
|
94
|
|
|
$this->raiseEvent('OnClick', $this, $params); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Raises callback event. |
|
99
|
|
|
* raises the appropriate event(s) (e.g. OnClick) |
|
100
|
|
|
* @param TCallbackEventParameter the parameter associated with the callback event |
|
101
|
|
|
*/ |
|
102
|
|
|
public function raiseCallbackEvent($param) |
|
103
|
|
|
{ |
|
104
|
|
|
if($param->CallbackParameter === 'onClick') |
|
105
|
|
|
$this->onClick($param); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
} |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.