@@ -21,9 +21,24 @@ discard block |
||
21 | 21 | */ |
22 | 22 | interface IJuiOptions |
23 | 23 | { |
24 | + /** |
|
25 | + * @return string |
|
26 | + */ |
|
24 | 27 | public function getWidget(); |
28 | + |
|
29 | + /** |
|
30 | + * @return string |
|
31 | + */ |
|
25 | 32 | public function getWidgetID(); |
33 | + |
|
34 | + /** |
|
35 | + * @return TJuiControlOptions |
|
36 | + */ |
|
26 | 37 | public function getOptions(); |
38 | + |
|
39 | + /** |
|
40 | + * @return string[] |
|
41 | + */ |
|
27 | 42 | public function getValidOptions(); |
28 | 43 | public function getValidEvents(); |
29 | 44 | } |
@@ -139,7 +154,7 @@ discard block |
||
139 | 154 | |
140 | 155 | /** |
141 | 156 | * Only serialize the options itself, not the corresponding parent control. |
142 | - * @return mixed array with the names of all variables of that object that should be serialized. |
|
157 | + * @return string[] array with the names of all variables of that object that should be serialized. |
|
143 | 158 | */ |
144 | 159 | public function __sleep() { |
145 | 160 | return array('_options'); |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TJuiControlOptions class file. |
|
4 | - * |
|
5 | - * @author Fabio Bas <[email protected]> |
|
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 System.Web.UI.JuiControls |
|
10 | - */ |
|
3 | + * TJuiControlOptions class file. |
|
4 | + * |
|
5 | + * @author Fabio Bas <[email protected]> |
|
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 System.Web.UI.JuiControls |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * IJuiOptions interface |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function __construct($control) |
63 | 63 | { |
64 | - $this->setControl($control); |
|
64 | + $this->setControl($control); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function setControl($control) |
73 | 73 | { |
74 | 74 | if(!$control instanceof IJuiOptions) |
75 | - throw new THttpException(500,'juioptions_control_invalid',$control->ID); |
|
75 | + throw new THttpException(500,'juioptions_control_invalid',$control->ID); |
|
76 | 76 | $this->_control=$control; |
77 | 77 | } |
78 | 78 |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function setControl($control) |
73 | 73 | { |
74 | - if(!$control instanceof IJuiOptions) |
|
75 | - throw new THttpException(500,'juioptions_control_invalid',$control->ID); |
|
76 | - $this->_control=$control; |
|
74 | + if (!$control instanceof IJuiOptions) |
|
75 | + throw new THttpException(500, 'juioptions_control_invalid', $control->ID); |
|
76 | + $this->_control = $control; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -83,27 +83,27 @@ discard block |
||
83 | 83 | * @param mixed option value. |
84 | 84 | * @throws THttpException |
85 | 85 | */ |
86 | - public function __set($name,$value) |
|
86 | + public function __set($name, $value) |
|
87 | 87 | { |
88 | - if($this->_options===null) |
|
89 | - $this->_options=array(); |
|
88 | + if ($this->_options === null) |
|
89 | + $this->_options = array(); |
|
90 | 90 | |
91 | - foreach($this->_control->getValidOptions() as $option) |
|
91 | + foreach ($this->_control->getValidOptions() as $option) |
|
92 | 92 | { |
93 | - if(0 == strcasecmp($name, $option)) |
|
93 | + if (0 == strcasecmp($name, $option)) |
|
94 | 94 | { |
95 | 95 | $low = strtolower($value); |
96 | - if($low === 'null') |
|
96 | + if ($low === 'null') |
|
97 | 97 | { |
98 | 98 | $this->_options[$option] = null; |
99 | - } elseif($low === 'true') { |
|
99 | + } elseif ($low === 'true') { |
|
100 | 100 | $this->_options[$option] = true; |
101 | - } elseif($low === 'false') { |
|
101 | + } elseif ($low === 'false') { |
|
102 | 102 | $this->_options[$option] = false; |
103 | - } elseif(is_numeric($value)) { |
|
103 | + } elseif (is_numeric($value)) { |
|
104 | 104 | // trick to get float or integer automatically when needed |
105 | 105 | $this->_options[$option] = $value + 0; |
106 | - } elseif(substr($low,0,8)=='function') { |
|
106 | + } elseif (substr($low, 0, 8) == 'function') { |
|
107 | 107 | $this->_options[$option] = new TJavaScriptLiteral($value); |
108 | 108 | } else { |
109 | 109 | $this->_options[$option] = $value; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - throw new TConfigurationException('juioptions_option_invalid',$this->_control->ID, $name); |
|
115 | + throw new TConfigurationException('juioptions_option_invalid', $this->_control->ID, $name); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function __get($name) |
125 | 125 | { |
126 | - if($this->_options===null) |
|
127 | - $this->_options=array(); |
|
126 | + if ($this->_options === null) |
|
127 | + $this->_options = array(); |
|
128 | 128 | |
129 | - foreach($this->_control->getValidOptions() as $option) |
|
129 | + foreach ($this->_control->getValidOptions() as $option) |
|
130 | 130 | { |
131 | - if(0 == strcasecmp($name, $option) && isset($this->_options[$option])) |
|
131 | + if (0 == strcasecmp($name, $option) && isset($this->_options[$option])) |
|
132 | 132 | { |
133 | 133 | return $this->_options[$option]; |
134 | 134 | } |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function toArray() |
152 | 152 | { |
153 | - $ret= ($this->_options===null) ? array() : $this->_options; |
|
153 | + $ret = ($this->_options === null) ? array() : $this->_options; |
|
154 | 154 | |
155 | - foreach($this->_control->getValidEvents() as $event) |
|
156 | - if($this->_control->hasEventHandler('on'.$event)) |
|
157 | - $ret[$event]=new TJavaScriptLiteral("function( event, ui ) { Prado.JuiCallback(".TJavascript::encode($this->_control->getUniqueID()).", ".TJavascript::encode($event).", event, ui, this); }"); |
|
155 | + foreach ($this->_control->getValidEvents() as $event) |
|
156 | + if ($this->_control->hasEventHandler('on' . $event)) |
|
157 | + $ret[$event] = new TJavaScriptLiteral("function( event, ui ) { Prado.JuiCallback(" . TJavascript::encode($this->_control->getUniqueID()) . ", " . TJavascript::encode($event) . ", event, ui, this); }"); |
|
158 | 158 | |
159 | 159 | return $ret; |
160 | 160 | } |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function raiseCallbackEvent($param) |
167 | 167 | { |
168 | - $callbackParam=$param->CallbackParameter; |
|
169 | - if(isset($callbackParam->event)) |
|
168 | + $callbackParam = $param->CallbackParameter; |
|
169 | + if (isset($callbackParam->event)) |
|
170 | 170 | { |
171 | - $eventName = 'On'.ucfirst($callbackParam->event); |
|
172 | - if($this->_control->hasEventHandler($eventName)) |
|
171 | + $eventName = 'On' . ucfirst($callbackParam->event); |
|
172 | + if ($this->_control->hasEventHandler($eventName)) |
|
173 | 173 | { |
174 | - $this->_control->$eventName( new TJuiEventParameter( |
|
174 | + $this->_control->$eventName(new TJuiEventParameter( |
|
175 | 175 | $this->_control->getResponse(), |
176 | 176 | isset($callbackParam->ui) ? $callbackParam->ui : null) |
177 | 177 | ); |
@@ -71,8 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function setControl($control) |
73 | 73 | { |
74 | - if(!$control instanceof IJuiOptions) |
|
75 | - throw new THttpException(500,'juioptions_control_invalid',$control->ID); |
|
74 | + if(!$control instanceof IJuiOptions) { |
|
75 | + throw new THttpException(500,'juioptions_control_invalid',$control->ID); |
|
76 | + } |
|
76 | 77 | $this->_control=$control; |
77 | 78 | } |
78 | 79 | |
@@ -85,8 +86,9 @@ discard block |
||
85 | 86 | */ |
86 | 87 | public function __set($name,$value) |
87 | 88 | { |
88 | - if($this->_options===null) |
|
89 | - $this->_options=array(); |
|
89 | + if($this->_options===null) { |
|
90 | + $this->_options=array(); |
|
91 | + } |
|
90 | 92 | |
91 | 93 | foreach($this->_control->getValidOptions() as $option) |
92 | 94 | { |
@@ -123,8 +125,9 @@ discard block |
||
123 | 125 | */ |
124 | 126 | public function __get($name) |
125 | 127 | { |
126 | - if($this->_options===null) |
|
127 | - $this->_options=array(); |
|
128 | + if($this->_options===null) { |
|
129 | + $this->_options=array(); |
|
130 | + } |
|
128 | 131 | |
129 | 132 | foreach($this->_control->getValidOptions() as $option) |
130 | 133 | { |
@@ -152,9 +155,10 @@ discard block |
||
152 | 155 | { |
153 | 156 | $ret= ($this->_options===null) ? array() : $this->_options; |
154 | 157 | |
155 | - foreach($this->_control->getValidEvents() as $event) |
|
156 | - if($this->_control->hasEventHandler('on'.$event)) |
|
158 | + foreach($this->_control->getValidEvents() as $event) { |
|
159 | + if($this->_control->hasEventHandler('on'.$event)) |
|
157 | 160 | $ret[$event]=new TJavaScriptLiteral("function( event, ui ) { Prado.JuiCallback(".TJavascript::encode($this->_control->getUniqueID()).", ".TJavascript::encode($event).", event, ui, this); }"); |
161 | + } |
|
158 | 162 | |
159 | 163 | return $ret; |
160 | 164 | } |
@@ -158,6 +158,9 @@ |
||
158 | 158 | $this->triggerClientMethod('close'); |
159 | 159 | } |
160 | 160 | |
161 | + /** |
|
162 | + * @param string $method |
|
163 | + */ |
|
161 | 164 | private function triggerClientMethod($method) |
162 | 165 | { |
163 | 166 | $cs = $this->getPage()->getClientScript(); |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 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 System.Web.UI.JuiControls |
|
10 | - */ |
|
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 System.Web.UI.JuiControls |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); |
13 | 13 | Prado::using('System.Web.UI.ActiveControls.TActivePanel'); |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getOptions() |
70 | 70 | { |
71 | - if (($options=$this->getViewState('JuiOptions'))===null) |
|
71 | + if (($options = $this->getViewState('JuiOptions')) === null) |
|
72 | 72 | { |
73 | - $options=new TJuiControlOptions($this); |
|
73 | + $options = new TJuiControlOptions($this); |
|
74 | 74 | $this->setViewState('JuiOptions', $options); |
75 | 75 | } |
76 | 76 | return $options; |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | { |
102 | 102 | $options = $this->getOptions()->toArray(); |
103 | 103 | |
104 | - foreach($this->getControls() as $control) |
|
105 | - if($control instanceof TJuiDialogButton) |
|
104 | + foreach ($this->getControls() as $control) |
|
105 | + if ($control instanceof TJuiDialogButton) |
|
106 | 106 | $options['buttons'][] = $control->getPostBackOptions(); |
107 | 107 | |
108 | 108 | return $options; |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | { |
117 | 117 | parent::addAttributesToRender($writer); |
118 | 118 | |
119 | - $writer->addAttribute('id',$this->getClientID()); |
|
120 | - $options=TJavascript::encode($this->getPostBackOptions()); |
|
121 | - $cs=$this->getPage()->getClientScript(); |
|
122 | - $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");"; |
|
119 | + $writer->addAttribute('id', $this->getClientID()); |
|
120 | + $options = TJavascript::encode($this->getPostBackOptions()); |
|
121 | + $cs = $this->getPage()->getClientScript(); |
|
122 | + $code = "jQuery('#" . $this->getWidgetID() . "')." . $this->getWidget() . "(" . $options . ");"; |
|
123 | 123 | $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); |
124 | 124 | } |
125 | 125 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * Raises the OnCreate event |
138 | 138 | * @param object $params event parameters |
139 | 139 | */ |
140 | - public function onOpen ($params) |
|
140 | + public function onOpen($params) |
|
141 | 141 | { |
142 | 142 | $this->raiseEvent('OnOpen', $this, $params); |
143 | 143 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | private function triggerClientMethod($method) |
162 | 162 | { |
163 | 163 | $cs = $this->getPage()->getClientScript(); |
164 | - $code = "jQuery(document).ready(function() { jQuery('#".$this->getClientId()."').dialog('".$method."'); })"; |
|
164 | + $code = "jQuery(document).ready(function() { jQuery('#" . $this->getClientId() . "').dialog('" . $method . "'); })"; |
|
165 | 165 | $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); |
166 | 166 | } |
167 | 167 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function render($writer) |
184 | 184 | { |
185 | - if($this->getHasPreRendered() && $this->getActiveControl()->canUpdateClientSide()) |
|
185 | + if ($this->getHasPreRendered() && $this->getActiveControl()->canUpdateClientSide()) |
|
186 | 186 | { |
187 | 187 | parent::renderContents($writer); |
188 | 188 | $this->getPage()->getCallbackClient()->replaceContent($this, $writer, false); |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | { |
241 | 241 | return array( |
242 | 242 | 'text' => $this->getText(), |
243 | - 'click' => new TJavaScriptLiteral("function(){new Prado.Callback('".$this->getUniqueID()."', 'onClick');}" |
|
244 | - )) ; |
|
243 | + 'click' => new TJavaScriptLiteral("function(){new Prado.Callback('" . $this->getUniqueID() . "', 'onClick');}" |
|
244 | + )); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | public function getText() |
251 | 251 | { |
252 | - return $this->getViewState('Text',''); |
|
252 | + return $this->getViewState('Text', ''); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function setText($value) |
259 | 259 | { |
260 | - $this->setViewState('Text',$value,''); |
|
260 | + $this->setViewState('Text', $value, ''); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | 264 | * Raises the OnClick event |
265 | 265 | * @param object $params event parameters |
266 | 266 | */ |
267 | - public function onClick ($params) |
|
267 | + public function onClick($params) |
|
268 | 268 | { |
269 | 269 | $this->raiseEvent('OnClick', $this, $params); |
270 | 270 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function raiseCallbackEvent($param) |
278 | 278 | { |
279 | - if($param->CallbackParameter === 'onClick') |
|
279 | + if ($param->CallbackParameter === 'onClick') |
|
280 | 280 | $this->onClick($param); |
281 | 281 | } |
282 | 282 |
@@ -101,9 +101,10 @@ discard block |
||
101 | 101 | { |
102 | 102 | $options = $this->getOptions()->toArray(); |
103 | 103 | |
104 | - foreach($this->getControls() as $control) |
|
105 | - if($control instanceof TJuiDialogButton) |
|
104 | + foreach($this->getControls() as $control) { |
|
105 | + if($control instanceof TJuiDialogButton) |
|
106 | 106 | $options['buttons'][] = $control->getPostBackOptions(); |
107 | + } |
|
107 | 108 | |
108 | 109 | return $options; |
109 | 110 | } |
@@ -186,9 +187,9 @@ discard block |
||
186 | 187 | { |
187 | 188 | parent::renderContents($writer); |
188 | 189 | $this->getPage()->getCallbackClient()->replaceContent($this, $writer, false); |
190 | + } else { |
|
191 | + parent::render($writer); |
|
189 | 192 | } |
190 | - else |
|
191 | - parent::render($writer); |
|
192 | 193 | } |
193 | 194 | } |
194 | 195 | |
@@ -276,8 +277,9 @@ discard block |
||
276 | 277 | */ |
277 | 278 | public function raiseCallbackEvent($param) |
278 | 279 | { |
279 | - if($param->CallbackParameter === 'onClick') |
|
280 | - $this->onClick($param); |
|
280 | + if($param->CallbackParameter === 'onClick') { |
|
281 | + $this->onClick($param); |
|
282 | + } |
|
281 | 283 | } |
282 | 284 | |
283 | 285 | } |
284 | 286 | \ No newline at end of file |
@@ -317,6 +317,9 @@ |
||
317 | 317 | { |
318 | 318 | private $_template; |
319 | 319 | |
320 | + /** |
|
321 | + * @param string $template |
|
322 | + */ |
|
320 | 323 | public function __construct($template) |
321 | 324 | { |
322 | 325 | $this->_template = $template; |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TJuiSortable class file. |
|
4 | - * |
|
5 | - * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> |
|
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 System.Web.UI.JuiControls |
|
10 | - */ |
|
3 | + * TJuiSortable class file. |
|
4 | + * |
|
5 | + * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> |
|
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 System.Web.UI.JuiControls |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); |
13 | 13 | Prado::using('System.Web.UI.ActiveControls.TActivePanel'); |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getOptions() |
73 | 73 | { |
74 | - if (($options=$this->getViewState('JuiOptions'))===null) |
|
74 | + if (($options = $this->getViewState('JuiOptions')) === null) |
|
75 | 75 | { |
76 | - $options=new TJuiControlOptions($this); |
|
76 | + $options = new TJuiControlOptions($this); |
|
77 | 77 | $this->setViewState('JuiOptions', $options); |
78 | 78 | } |
79 | 79 | return $options; |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | { |
105 | 105 | $options = $this->getOptions()->toArray(); |
106 | 106 | // overload some events to add information about the items order |
107 | - foreach($options as $event => $implementation) |
|
107 | + foreach ($options as $event => $implementation) |
|
108 | 108 | { |
109 | - if($event=='sort' || $event=='stop') |
|
110 | - $options[$event]=new TJavaScriptLiteral('function( event, ui ) { ui.index = jQuery(this).sortable(\'toArray\'); Prado.JuiCallback('.TJavascript::encode($this->getUniqueID()).', \''.$event.'\', event, ui, this); }'); |
|
109 | + if ($event == 'sort' || $event == 'stop') |
|
110 | + $options[$event] = new TJavaScriptLiteral('function( event, ui ) { ui.index = jQuery(this).sortable(\'toArray\'); Prado.JuiCallback(' . TJavascript::encode($this->getUniqueID()) . ', \'' . $event . '\', event, ui, this); }'); |
|
111 | 111 | } |
112 | 112 | return $options; |
113 | 113 | } |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | protected function addAttributesToRender($writer) |
120 | 120 | { |
121 | 121 | parent::addAttributesToRender($writer); |
122 | - $writer->addAttribute('id',$this->getClientID()); |
|
123 | - $options=TJavascript::encode($this->getPostBackOptions()); |
|
124 | - $cs=$this->getPage()->getClientScript(); |
|
125 | - $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");"; |
|
122 | + $writer->addAttribute('id', $this->getClientID()); |
|
123 | + $options = TJavascript::encode($this->getPostBackOptions()); |
|
124 | + $cs = $this->getPage()->getClientScript(); |
|
125 | + $code = "jQuery('#" . $this->getWidgetID() . "')." . $this->getWidget() . "(" . $options . ");"; |
|
126 | 126 | $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); |
127 | 127 | } |
128 | 128 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * Raises the OnActivate event |
141 | 141 | * @param object $params event parameters |
142 | 142 | */ |
143 | - public function onActivate ($params) |
|
143 | + public function onActivate($params) |
|
144 | 144 | { |
145 | 145 | $this->raiseEvent('OnActivate', $this, $params); |
146 | 146 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * Raises the OnBeforeStop event |
150 | 150 | * @param object $params event parameters |
151 | 151 | */ |
152 | - public function onBeforeStop ($params) |
|
152 | + public function onBeforeStop($params) |
|
153 | 153 | { |
154 | 154 | $this->raiseEvent('OnBeforeStop', $this, $params); |
155 | 155 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * Raises the OnChange event |
159 | 159 | * @param object $params event parameters |
160 | 160 | */ |
161 | - public function onChange ($params) |
|
161 | + public function onChange($params) |
|
162 | 162 | { |
163 | 163 | $this->raiseEvent('OnChange', $this, $params); |
164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * Raises the OnCreate event |
168 | 168 | * @param object $params event parameters |
169 | 169 | */ |
170 | - public function onCreate ($params) |
|
170 | + public function onCreate($params) |
|
171 | 171 | { |
172 | 172 | $this->raiseEvent('OnCreate', $this, $params); |
173 | 173 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * Raises the OnDeactivate event |
177 | 177 | * @param object $params event parameters |
178 | 178 | */ |
179 | - public function onDeactivate ($params) |
|
179 | + public function onDeactivate($params) |
|
180 | 180 | { |
181 | 181 | $this->raiseEvent('OnDeactivate', $this, $params); |
182 | 182 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * Raises the OnOut event |
186 | 186 | * @param object $params event parameters |
187 | 187 | */ |
188 | - public function onOut ($params) |
|
188 | + public function onOut($params) |
|
189 | 189 | { |
190 | 190 | $this->raiseEvent('OnOut', $this, $params); |
191 | 191 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * Raises the OnOver event |
195 | 195 | * @param object $params event parameters |
196 | 196 | */ |
197 | - public function onOver ($params) |
|
197 | + public function onOver($params) |
|
198 | 198 | { |
199 | 199 | $this->raiseEvent('OnOver', $this, $params); |
200 | 200 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * Raises the OnReceive event |
204 | 204 | * @param object $params event parameters |
205 | 205 | */ |
206 | - public function onReceive ($params) |
|
206 | + public function onReceive($params) |
|
207 | 207 | { |
208 | 208 | $this->raiseEvent('OnReceive', $this, $params); |
209 | 209 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * Raises the OnRemove event |
213 | 213 | * @param object $params event parameters |
214 | 214 | */ |
215 | - public function onRemove ($params) |
|
215 | + public function onRemove($params) |
|
216 | 216 | { |
217 | 217 | $this->raiseEvent('OnRemove', $this, $params); |
218 | 218 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * Raises the OnSort event |
222 | 222 | * @param object $params event parameters |
223 | 223 | */ |
224 | - public function onSort ($params) |
|
224 | + public function onSort($params) |
|
225 | 225 | { |
226 | 226 | $this->raiseEvent('OnSort', $this, $params); |
227 | 227 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * Raises the OnStart event |
231 | 231 | * @param object $params event parameters |
232 | 232 | */ |
233 | - public function onStart ($params) |
|
233 | + public function onStart($params) |
|
234 | 234 | { |
235 | 235 | $this->raiseEvent('OnStart', $this, $params); |
236 | 236 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * Raises the OnStop event |
240 | 240 | * @param object $params event parameters |
241 | 241 | */ |
242 | - public function OnStop ($params) |
|
242 | + public function OnStop($params) |
|
243 | 243 | { |
244 | 244 | $this->raiseEvent('OnStop', $this, $params); |
245 | 245 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * Raises the OnUpdate event |
249 | 249 | * @param object $params event parameters |
250 | 250 | */ |
251 | - public function onUpdate ($params) |
|
251 | + public function onUpdate($params) |
|
252 | 252 | { |
253 | 253 | $this->raiseEvent('OnUpdate', $this, $params); |
254 | 254 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | /** |
257 | 257 | * @var ITemplate template for repeater items |
258 | 258 | */ |
259 | - private $_repeater=null; |
|
259 | + private $_repeater = null; |
|
260 | 260 | |
261 | 261 | /** |
262 | 262 | * @param array data source for Sortables. |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | public function dataBind() |
274 | 274 | { |
275 | 275 | parent::dataBind(); |
276 | - if($this->getPage()->getIsCallback()) |
|
276 | + if ($this->getPage()->getIsCallback()) |
|
277 | 277 | $this->renderSortables($this->getResponse()->createHtmlWriter()); |
278 | 278 | } |
279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function getSortables() |
284 | 284 | { |
285 | - if($this->_repeater===null) |
|
285 | + if ($this->_repeater === null) |
|
286 | 286 | $this->_repeater = $this->createRepeater(); |
287 | 287 | return $this->_repeater; |
288 | 288 | } |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | protected function createRepeater() |
294 | 294 | { |
295 | 295 | $repeater = Prado::createComponent('System.Web.UI.WebControls.TRepeater'); |
296 | - $repeater->setHeaderTemplate(new TJuiSortableTemplate('<ul id="'.$this->getWidgetID().'">')); |
|
296 | + $repeater->setHeaderTemplate(new TJuiSortableTemplate('<ul id="' . $this->getWidgetID() . '">')); |
|
297 | 297 | $repeater->setFooterTemplate(new TJuiSortableTemplate('</ul>')); |
298 | - $repeater->setItemTemplate(new TTemplate('<li id="<%# $this->ItemIndex %>"><%# $this->Data %></li>',null)); |
|
298 | + $repeater->setItemTemplate(new TTemplate('<li id="<%# $this->ItemIndex %>"><%# $this->Data %></li>', null)); |
|
299 | 299 | $repeater->setEmptyTemplate(new TJuiSortableTemplate('<ul></ul>')); |
300 | 300 | $this->getControls()->add($repeater); |
301 | 301 | return $repeater; |
@@ -106,8 +106,9 @@ discard block |
||
106 | 106 | // overload some events to add information about the items order |
107 | 107 | foreach($options as $event => $implementation) |
108 | 108 | { |
109 | - if($event=='sort' || $event=='stop') |
|
110 | - $options[$event]=new TJavaScriptLiteral('function( event, ui ) { ui.index = jQuery(this).sortable(\'toArray\'); Prado.JuiCallback('.TJavascript::encode($this->getUniqueID()).', \''.$event.'\', event, ui, this); }'); |
|
109 | + if($event=='sort' || $event=='stop') { |
|
110 | + $options[$event]=new TJavaScriptLiteral('function( event, ui ) { ui.index = jQuery(this).sortable(\'toArray\'); Prado.JuiCallback('.TJavascript::encode($this->getUniqueID()).', \''.$event.'\', event, ui, this); }'); |
|
111 | + } |
|
111 | 112 | } |
112 | 113 | return $options; |
113 | 114 | } |
@@ -273,8 +274,9 @@ discard block |
||
273 | 274 | public function dataBind() |
274 | 275 | { |
275 | 276 | parent::dataBind(); |
276 | - if($this->getPage()->getIsCallback()) |
|
277 | - $this->renderSortables($this->getResponse()->createHtmlWriter()); |
|
277 | + if($this->getPage()->getIsCallback()) { |
|
278 | + $this->renderSortables($this->getResponse()->createHtmlWriter()); |
|
279 | + } |
|
278 | 280 | } |
279 | 281 | |
280 | 282 | /** |
@@ -282,8 +284,9 @@ discard block |
||
282 | 284 | */ |
283 | 285 | public function getSortables() |
284 | 286 | { |
285 | - if($this->_repeater===null) |
|
286 | - $this->_repeater = $this->createRepeater(); |
|
287 | + if($this->_repeater===null) { |
|
288 | + $this->_repeater = $this->createRepeater(); |
|
289 | + } |
|
287 | 290 | return $this->_repeater; |
288 | 291 | } |
289 | 292 |
@@ -215,6 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | /** |
217 | 217 | * @param string javascript package path. |
218 | + * @param string $base |
|
218 | 219 | * @return array tuple($path,$url). |
219 | 220 | */ |
220 | 221 | protected function getPackagePathUrl($base) |
@@ -496,6 +497,8 @@ discard block |
||
496 | 497 | * @param string a unique key identifying the hidden field |
497 | 498 | * @param string|array hidden field value, if the value is an array, every element |
498 | 499 | * in the array will be rendered as a hidden field value. |
500 | + * @param string $name |
|
501 | + * @param string $value |
|
499 | 502 | */ |
500 | 503 | public function registerHiddenField($name,$value) |
501 | 504 | { |
@@ -735,6 +738,7 @@ discard block |
||
735 | 738 | |
736 | 739 | /** |
737 | 740 | * @param THtmlWriter writer for the rendering purpose |
741 | + * @param boolean $initial |
|
738 | 742 | */ |
739 | 743 | protected function renderHiddenFieldsInt($writer, $initial) |
740 | 744 | { |
@@ -799,6 +803,7 @@ discard block |
||
799 | 803 | * javascript statements. |
800 | 804 | * @param string option name |
801 | 805 | * @param string javascript statements. |
806 | + * @param string $name |
|
802 | 807 | */ |
803 | 808 | protected function setFunction($name, $code) |
804 | 809 | { |
@@ -808,6 +813,7 @@ discard block |
||
808 | 813 | } |
809 | 814 | |
810 | 815 | /** |
816 | + * @param string $name |
|
811 | 817 | * @return string gets a particular option, null if not set. |
812 | 818 | */ |
813 | 819 | protected function getOption($name) |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * directory containing Prado javascript files |
27 | 27 | */ |
28 | - const SCRIPT_PATH='Web/Javascripts/source'; |
|
28 | + const SCRIPT_PATH = 'Web/Javascripts/source'; |
|
29 | 29 | /** |
30 | 30 | * file containing javascript packages and their cross dependencies |
31 | 31 | */ |
32 | - const PACKAGES_FILE='Web/Javascripts/packages.php'; |
|
32 | + const PACKAGES_FILE = 'Web/Javascripts/packages.php'; |
|
33 | 33 | /** |
34 | 34 | * @var TPage page who owns this manager |
35 | 35 | */ |
@@ -37,39 +37,39 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var array registered hidden fields, indexed by hidden field names |
39 | 39 | */ |
40 | - private $_hiddenFields=array(); |
|
40 | + private $_hiddenFields = array(); |
|
41 | 41 | /** |
42 | 42 | * @var array javascript blocks to be rendered at the beginning of the form |
43 | 43 | */ |
44 | - private $_beginScripts=array(); |
|
44 | + private $_beginScripts = array(); |
|
45 | 45 | /** |
46 | 46 | * @var array javascript blocks to be rendered at the end of the form |
47 | 47 | */ |
48 | - private $_endScripts=array(); |
|
48 | + private $_endScripts = array(); |
|
49 | 49 | /** |
50 | 50 | * @var array javascript files to be rendered in the form |
51 | 51 | */ |
52 | - private $_scriptFiles=array(); |
|
52 | + private $_scriptFiles = array(); |
|
53 | 53 | /** |
54 | 54 | * @var array javascript files to be rendered in page head section |
55 | 55 | */ |
56 | - private $_headScriptFiles=array(); |
|
56 | + private $_headScriptFiles = array(); |
|
57 | 57 | /** |
58 | 58 | * @var array javascript blocks to be rendered in page head section |
59 | 59 | */ |
60 | - private $_headScripts=array(); |
|
60 | + private $_headScripts = array(); |
|
61 | 61 | /** |
62 | 62 | * @var array CSS files |
63 | 63 | */ |
64 | - private $_styleSheetFiles=array(); |
|
64 | + private $_styleSheetFiles = array(); |
|
65 | 65 | /** |
66 | 66 | * @var array CSS declarations |
67 | 67 | */ |
68 | - private $_styleSheets=array(); |
|
68 | + private $_styleSheets = array(); |
|
69 | 69 | /** |
70 | 70 | * @var array registered PRADO script libraries |
71 | 71 | */ |
72 | - private $_registeredPradoScripts=array(); |
|
72 | + private $_registeredPradoScripts = array(); |
|
73 | 73 | /** |
74 | 74 | * Client-side javascript library dependencies, loads from PACKAGES_FILE; |
75 | 75 | * @var array |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | private $_renderedHiddenFields; |
85 | 85 | |
86 | - private $_renderedScriptFiles=array(); |
|
86 | + private $_renderedScriptFiles = array(); |
|
87 | 87 | |
88 | 88 | private $_expandedPradoScripts; |
89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function __construct(TPage $owner) |
95 | 95 | { |
96 | - $this->_page=$owner; |
|
96 | + $this->_page = $owner; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | public function registerPradoScript($name) |
125 | 125 | { |
126 | 126 | $this->registerPradoScriptInternal($name); |
127 | - $params=func_get_args(); |
|
128 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoScript',$params); |
|
127 | + $params = func_get_args(); |
|
128 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoScript', $params); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,27 +134,27 @@ discard block |
||
134 | 134 | protected function registerPradoScriptInternal($name) |
135 | 135 | { |
136 | 136 | // $this->checkIfNotInRender(); |
137 | - if(!isset($this->_registeredPradoScripts[$name])) |
|
137 | + if (!isset($this->_registeredPradoScripts[$name])) |
|
138 | 138 | { |
139 | - if(self::$_pradoScripts === null) |
|
139 | + if (self::$_pradoScripts === null) |
|
140 | 140 | { |
141 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
142 | - list($packages,$deps)= include($packageFile); |
|
141 | + $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::PACKAGES_FILE; |
|
142 | + list($packages, $deps) = include($packageFile); |
|
143 | 143 | self::$_pradoScripts = $deps; |
144 | 144 | self::$_pradoPackages = $packages; |
145 | 145 | } |
146 | 146 | |
147 | 147 | if (isset(self::$_pradoScripts[$name])) |
148 | - $this->_registeredPradoScripts[$name]=true; |
|
148 | + $this->_registeredPradoScripts[$name] = true; |
|
149 | 149 | else |
150 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
150 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
151 | 151 | |
152 | - if(($packages=array_keys($this->_registeredPradoScripts))!==array()) |
|
152 | + if (($packages = array_keys($this->_registeredPradoScripts)) !== array()) |
|
153 | 153 | { |
154 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
155 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
156 | - $packagesUrl=array(); |
|
157 | - $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
154 | + $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH; |
|
155 | + list($path, $baseUrl) = $this->getPackagePathUrl($base); |
|
156 | + $packagesUrl = array(); |
|
157 | + $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
|
158 | 158 | foreach ($packages as $p) |
159 | 159 | { |
160 | 160 | foreach (self::$_pradoScripts[$p] as $dep) |
@@ -163,29 +163,29 @@ discard block |
||
163 | 163 | if (!isset($this->_expandedPradoScripts[$script])) |
164 | 164 | { |
165 | 165 | $this->_expandedPradoScripts[$script] = true; |
166 | - if($isDebug) |
|
166 | + if ($isDebug) |
|
167 | 167 | { |
168 | - if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
|
169 | - $packagesUrl[]=$url; |
|
168 | + if (!in_array($url = $baseUrl . '/' . $script, $packagesUrl)) |
|
169 | + $packagesUrl[] = $url; |
|
170 | 170 | } else { |
171 | - if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl)) |
|
171 | + if (!in_array($url = $baseUrl . '/min/' . $script, $packagesUrl)) |
|
172 | 172 | { |
173 | - if(!is_file($filePath=$path.'/min/'.$script)) |
|
173 | + if (!is_file($filePath = $path . '/min/' . $script)) |
|
174 | 174 | { |
175 | - $dirPath=dirname($filePath); |
|
176 | - if(!is_dir($dirPath)) |
|
175 | + $dirPath = dirname($filePath); |
|
176 | + if (!is_dir($dirPath)) |
|
177 | 177 | mkdir($dirPath, PRADO_CHMOD, true); |
178 | - file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$script))); |
|
178 | + file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base . '/' . $script))); |
|
179 | 179 | chmod($filePath, PRADO_CHMOD); |
180 | 180 | } |
181 | - $packagesUrl[]=$url; |
|
181 | + $packagesUrl[] = $url; |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
187 | - foreach($packagesUrl as $url) |
|
188 | - $this->registerScriptFile($url,$url); |
|
187 | + foreach ($packagesUrl as $url) |
|
188 | + $this->registerScriptFile($url, $url); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function getPradoScriptAssetUrl() |
197 | 197 | { |
198 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
198 | + $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH; |
|
199 | 199 | $assets = Prado::getApplication()->getAssetManager(); |
200 | 200 | return $assets->getPublishedUrl($base); |
201 | 201 | } |
@@ -220,16 +220,16 @@ discard block |
||
220 | 220 | protected function getPackagePathUrl($base) |
221 | 221 | { |
222 | 222 | $assets = Prado::getApplication()->getAssetManager(); |
223 | - if(strpos($base, $assets->getBaseUrl())===false) |
|
223 | + if (strpos($base, $assets->getBaseUrl()) === false) |
|
224 | 224 | { |
225 | - if(($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
225 | + if (($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
226 | 226 | $base = $dir; |
227 | 227 | } |
228 | 228 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
229 | 229 | } |
230 | 230 | else |
231 | 231 | { |
232 | - return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
|
232 | + return array($assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param array additional callback options |
240 | 240 | * @return string javascript statement that creates a new callback request. |
241 | 241 | */ |
242 | - public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null) |
|
242 | + public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options = null) |
|
243 | 243 | { |
244 | 244 | $options = !is_array($options) ? array() : $options; |
245 | 245 | $class = new ReflectionClass($callbackHandler); |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function registerCallbackControl($class, $options) |
260 | 260 | { |
261 | - $optionString=TJavaScript::encode($options); |
|
262 | - $code="new {$class}({$optionString});"; |
|
263 | - $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
|
261 | + $optionString = TJavaScript::encode($options); |
|
262 | + $code = "new {$class}({$optionString});"; |
|
263 | + $this->_endScripts[sprintf('%08X', crc32($code))] = $code; |
|
264 | 264 | $this->registerPradoScriptInternal('ajax'); |
265 | 265 | |
266 | - $params=func_get_args(); |
|
267 | - $this->_page->registerCachingAction('Page.ClientScript','registerCallbackControl',$params); |
|
266 | + $params = func_get_args(); |
|
267 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerCallbackControl', $params); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -273,21 +273,21 @@ discard block |
||
273 | 273 | * @param string javascript class responsible for the control being registered for postback |
274 | 274 | * @param array postback options |
275 | 275 | */ |
276 | - public function registerPostBackControl($class,$options) |
|
276 | + public function registerPostBackControl($class, $options) |
|
277 | 277 | { |
278 | - if($class === null) { |
|
278 | + if ($class === null) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | - if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
|
282 | - $options['FormID']=$form->getClientID(); |
|
283 | - $optionString=TJavaScript::encode($options); |
|
284 | - $code="new {$class}({$optionString});"; |
|
281 | + if (!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
282 | + $options['FormID'] = $form->getClientID(); |
|
283 | + $optionString = TJavaScript::encode($options); |
|
284 | + $code = "new {$class}({$optionString});"; |
|
285 | 285 | |
286 | - $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
|
286 | + $this->_endScripts[sprintf('%08X', crc32($code))] = $code; |
|
287 | 287 | $this->registerPradoScriptInternal('prado'); |
288 | 288 | |
289 | - $params=func_get_args(); |
|
290 | - $this->_page->registerCachingAction('Page.ClientScript','registerPostBackControl',$params); |
|
289 | + $params = func_get_args(); |
|
290 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPostBackControl', $params); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -298,23 +298,23 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function registerDefaultButton($panel, $button) |
300 | 300 | { |
301 | - $panelID=is_string($panel)?$panel:$panel->getUniqueID(); |
|
301 | + $panelID = is_string($panel) ? $panel : $panel->getUniqueID(); |
|
302 | 302 | |
303 | - if(is_string($button)) |
|
304 | - $buttonID=$button; |
|
303 | + if (is_string($button)) |
|
304 | + $buttonID = $button; |
|
305 | 305 | else |
306 | 306 | { |
307 | 307 | $button->setIsDefaultButton(true); |
308 | - $buttonID=$button->getUniqueID(); |
|
308 | + $buttonID = $button->getUniqueID(); |
|
309 | 309 | } |
310 | 310 | $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
311 | 311 | $code = "new Prado.WebUI.DefaultButton($options);"; |
312 | 312 | |
313 | - $this->_endScripts['prado:'.$panelID]=$code; |
|
313 | + $this->_endScripts['prado:' . $panelID] = $code; |
|
314 | 314 | $this->registerPradoScriptInternal('prado'); |
315 | 315 | |
316 | - $params=array($panelID,$buttonID); |
|
317 | - $this->_page->registerCachingAction('Page.ClientScript','registerDefaultButton',$params); |
|
316 | + $params = array($panelID, $buttonID); |
|
317 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | public function registerFocusControl($target) |
340 | 340 | { |
341 | 341 | $this->registerPradoScriptInternal('jquery'); |
342 | - if($target instanceof TControl) |
|
343 | - $target=$target->getClientID(); |
|
344 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
|
342 | + if ($target instanceof TControl) |
|
343 | + $target = $target->getClientID(); |
|
344 | + $this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();'; |
|
345 | 345 | |
346 | - $params=func_get_args(); |
|
347 | - $this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params); |
|
346 | + $params = func_get_args(); |
|
347 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -369,15 +369,15 @@ discard block |
||
369 | 369 | * @param string URL to the CSS file |
370 | 370 | * @param string media type of the CSS (such as 'print', 'screen', etc.). Defaults to empty, meaning the CSS applies to all media types. |
371 | 371 | */ |
372 | - public function registerStyleSheetFile($key,$url,$media='') |
|
372 | + public function registerStyleSheetFile($key, $url, $media = '') |
|
373 | 373 | { |
374 | - if($media==='') |
|
375 | - $this->_styleSheetFiles[$key]=$url; |
|
374 | + if ($media === '') |
|
375 | + $this->_styleSheetFiles[$key] = $url; |
|
376 | 376 | else |
377 | - $this->_styleSheetFiles[$key]=array($url,$media); |
|
377 | + $this->_styleSheetFiles[$key] = array($url, $media); |
|
378 | 378 | |
379 | - $params=func_get_args(); |
|
380 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); |
|
379 | + $params = func_get_args(); |
|
380 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -385,12 +385,12 @@ discard block |
||
385 | 385 | * @param string a unique key identifying the CSS block |
386 | 386 | * @param string CSS block |
387 | 387 | */ |
388 | - public function registerStyleSheet($key,$css,$media='') |
|
388 | + public function registerStyleSheet($key, $css, $media = '') |
|
389 | 389 | { |
390 | - $this->_styleSheets[$key]=$css; |
|
390 | + $this->_styleSheets[$key] = $css; |
|
391 | 391 | |
392 | - $params=func_get_args(); |
|
393 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheet',$params); |
|
392 | + $params = func_get_args(); |
|
393 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheet', $params); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | $this->_styleSheetFiles) |
406 | 406 | ); |
407 | 407 | |
408 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
409 | - if (substr($url,strlen($url)-4)=='.css') |
|
408 | + foreach (Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
409 | + if (substr($url, strlen($url) - 4) == '.css') |
|
410 | 410 | $stylesheets[] = $url; |
411 | 411 | |
412 | 412 | $stylesheets = array_unique($stylesheets); |
@@ -428,13 +428,13 @@ discard block |
||
428 | 428 | * @param string a unique key identifying the file |
429 | 429 | * @param string URL to the javascript file |
430 | 430 | */ |
431 | - public function registerHeadScriptFile($key,$url) |
|
431 | + public function registerHeadScriptFile($key, $url) |
|
432 | 432 | { |
433 | 433 | $this->checkIfNotInRender(); |
434 | - $this->_headScriptFiles[$key]=$url; |
|
434 | + $this->_headScriptFiles[$key] = $url; |
|
435 | 435 | |
436 | - $params=func_get_args(); |
|
437 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScriptFile',$params); |
|
436 | + $params = func_get_args(); |
|
437 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScriptFile', $params); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -442,13 +442,13 @@ discard block |
||
442 | 442 | * @param string a unique key identifying the script block |
443 | 443 | * @param string javascript block |
444 | 444 | */ |
445 | - public function registerHeadScript($key,$script) |
|
445 | + public function registerHeadScript($key, $script) |
|
446 | 446 | { |
447 | 447 | $this->checkIfNotInRender(); |
448 | - $this->_headScripts[$key]=$script; |
|
448 | + $this->_headScripts[$key] = $script; |
|
449 | 449 | |
450 | - $params=func_get_args(); |
|
451 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScript',$params); |
|
450 | + $params = func_get_args(); |
|
451 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScript', $params); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | */ |
459 | 459 | public function registerScriptFile($key, $url) |
460 | 460 | { |
461 | - $this->_scriptFiles[$key]=$url; |
|
461 | + $this->_scriptFiles[$key] = $url; |
|
462 | 462 | |
463 | - $params=func_get_args(); |
|
464 | - $this->_page->registerCachingAction('Page.ClientScript','registerScriptFile',$params); |
|
463 | + $params = func_get_args(); |
|
464 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerScriptFile', $params); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -469,13 +469,13 @@ discard block |
||
469 | 469 | * @param string a unique key identifying the script block |
470 | 470 | * @param string javascript block |
471 | 471 | */ |
472 | - public function registerBeginScript($key,$script) |
|
472 | + public function registerBeginScript($key, $script) |
|
473 | 473 | { |
474 | 474 | $this->checkIfNotInRender(); |
475 | - $this->_beginScripts[$key]=$script; |
|
475 | + $this->_beginScripts[$key] = $script; |
|
476 | 476 | |
477 | - $params=func_get_args(); |
|
478 | - $this->_page->registerCachingAction('Page.ClientScript','registerBeginScript',$params); |
|
477 | + $params = func_get_args(); |
|
478 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerBeginScript', $params); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | * @param string a unique key identifying the script block |
484 | 484 | * @param string javascript block |
485 | 485 | */ |
486 | - public function registerEndScript($key,$script) |
|
486 | + public function registerEndScript($key, $script) |
|
487 | 487 | { |
488 | - $this->_endScripts[$key]=$script; |
|
488 | + $this->_endScripts[$key] = $script; |
|
489 | 489 | |
490 | - $params=func_get_args(); |
|
491 | - $this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params); |
|
490 | + $params = func_get_args(); |
|
491 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerEndScript', $params); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | * @param string|array hidden field value, if the value is an array, every element |
498 | 498 | * in the array will be rendered as a hidden field value. |
499 | 499 | */ |
500 | - public function registerHiddenField($name,$value) |
|
500 | + public function registerHiddenField($name, $value) |
|
501 | 501 | { |
502 | - $this->_hiddenFields[$name]=$value; |
|
502 | + $this->_hiddenFields[$name] = $value; |
|
503 | 503 | |
504 | - $params=func_get_args(); |
|
505 | - $this->_page->registerCachingAction('Page.ClientScript','registerHiddenField',$params); |
|
504 | + $params = func_get_args(); |
|
505 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHiddenField', $params); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -598,13 +598,13 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public function renderStyleSheetFiles($writer) |
600 | 600 | { |
601 | - $str=''; |
|
602 | - foreach($this->_styleSheetFiles as $url) |
|
601 | + $str = ''; |
|
602 | + foreach ($this->_styleSheetFiles as $url) |
|
603 | 603 | { |
604 | - if(is_array($url)) |
|
605 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
604 | + if (is_array($url)) |
|
605 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
606 | 606 | else |
607 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
607 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
608 | 608 | } |
609 | 609 | $writer->write($str); |
610 | 610 | } |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | */ |
615 | 615 | public function renderStyleSheets($writer) |
616 | 616 | { |
617 | - if(count($this->_styleSheets)) |
|
618 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
617 | + if (count($this->_styleSheets)) |
|
618 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | */ |
624 | 624 | public function renderHeadScriptFiles($writer) |
625 | 625 | { |
626 | - $this->renderScriptFiles($writer,$this->_headScriptFiles); |
|
626 | + $this->renderScriptFiles($writer, $this->_headScriptFiles); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | /** |
@@ -647,13 +647,13 @@ discard block |
||
647 | 647 | public function markScriptFileAsRendered($url) |
648 | 648 | { |
649 | 649 | $this->_renderedScriptFiles[$url] = $url; |
650 | - $params=func_get_args(); |
|
651 | - $this->_page->registerCachingAction('Page.ClientScript','markScriptFileAsRendered',$params); |
|
650 | + $params = func_get_args(); |
|
651 | + $this->_page->registerCachingAction('Page.ClientScript', 'markScriptFileAsRendered', $params); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | protected function renderScriptFiles($writer, Array $scripts) |
655 | 655 | { |
656 | - foreach($scripts as $script) |
|
656 | + foreach ($scripts as $script) |
|
657 | 657 | { |
658 | 658 | $writer->write(TJavaScript::renderScriptFile($script)); |
659 | 659 | $this->markScriptFileAsRendered($script); |
@@ -670,10 +670,10 @@ discard block |
||
670 | 670 | */ |
671 | 671 | public function renderAllPendingScriptFiles($writer) |
672 | 672 | { |
673 | - if(!empty($this->_scriptFiles)) |
|
673 | + if (!empty($this->_scriptFiles)) |
|
674 | 674 | { |
675 | - $addedScripts = array_diff($this->_scriptFiles,$this->getRenderedScriptFiles()); |
|
676 | - $this->renderScriptFiles($writer,$addedScripts); |
|
675 | + $addedScripts = array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
|
676 | + $this->renderScriptFiles($writer, $addedScripts); |
|
677 | 677 | } |
678 | 678 | } |
679 | 679 | |
@@ -711,12 +711,12 @@ discard block |
||
711 | 711 | |
712 | 712 | public function renderHiddenFieldsBegin($writer) |
713 | 713 | { |
714 | - $this->renderHiddenFieldsInt($writer,true); |
|
714 | + $this->renderHiddenFieldsInt($writer, true); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | public function renderHiddenFieldsEnd($writer) |
718 | 718 | { |
719 | - $this->renderHiddenFieldsInt($writer,false); |
|
719 | + $this->renderHiddenFieldsInt($writer, false); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | /** |
@@ -724,9 +724,9 @@ discard block |
||
724 | 724 | * @param THtmlWriter writer for the rendering purpose |
725 | 725 | * @param TControl the control forcing the flush (used only in error messages) |
726 | 726 | */ |
727 | - public function flushScriptFiles($writer, $control=null) |
|
727 | + public function flushScriptFiles($writer, $control = null) |
|
728 | 728 | { |
729 | - if(!$this->_page->getIsCallback()) |
|
729 | + if (!$this->_page->getIsCallback()) |
|
730 | 730 | { |
731 | 731 | $this->_page->ensureRenderInForm($control); |
732 | 732 | $this->renderAllPendingScriptFiles($writer); |
@@ -739,24 +739,24 @@ discard block |
||
739 | 739 | protected function renderHiddenFieldsInt($writer, $initial) |
740 | 740 | { |
741 | 741 | if ($initial) $this->_renderedHiddenFields = array(); |
742 | - $str=''; |
|
743 | - foreach($this->_hiddenFields as $name=>$value) |
|
742 | + $str = ''; |
|
743 | + foreach ($this->_hiddenFields as $name=>$value) |
|
744 | 744 | { |
745 | - if (in_array($name,$this->_renderedHiddenFields)) continue; |
|
746 | - $id=strtr($name,':','_'); |
|
747 | - if(is_array($value)) |
|
745 | + if (in_array($name, $this->_renderedHiddenFields)) continue; |
|
746 | + $id = strtr($name, ':', '_'); |
|
747 | + if (is_array($value)) |
|
748 | 748 | { |
749 | - foreach($value as $v) |
|
750 | - $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
749 | + foreach ($value as $v) |
|
750 | + $str .= '<input type="hidden" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
751 | 751 | } |
752 | 752 | else |
753 | 753 | { |
754 | - $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
754 | + $str .= '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
755 | 755 | } |
756 | 756 | $this->_renderedHiddenFields[] = $name; |
757 | 757 | } |
758 | - if($str!=='') |
|
759 | - $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
758 | + if ($str !== '') |
|
759 | + $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | public function getHiddenFields() |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | */ |
803 | 803 | protected function setFunction($name, $code) |
804 | 804 | { |
805 | - if(!TJavaScript::isJsLiteral($code)) |
|
805 | + if (!TJavaScript::isJsLiteral($code)) |
|
806 | 806 | $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
807 | 807 | $this->setOption($name, $code); |
808 | 808 | } |
@@ -144,10 +144,11 @@ discard block |
||
144 | 144 | self::$_pradoPackages = $packages; |
145 | 145 | } |
146 | 146 | |
147 | - if (isset(self::$_pradoScripts[$name])) |
|
148 | - $this->_registeredPradoScripts[$name]=true; |
|
149 | - else |
|
150 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
147 | + if (isset(self::$_pradoScripts[$name])) { |
|
148 | + $this->_registeredPradoScripts[$name]=true; |
|
149 | + } else { |
|
150 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
151 | + } |
|
151 | 152 | |
152 | 153 | if(($packages=array_keys($this->_registeredPradoScripts))!==array()) |
153 | 154 | { |
@@ -159,22 +160,25 @@ discard block |
||
159 | 160 | { |
160 | 161 | foreach (self::$_pradoScripts[$p] as $dep) |
161 | 162 | { |
162 | - foreach (self::$_pradoPackages[$dep] as $script) |
|
163 | - if (!isset($this->_expandedPradoScripts[$script])) |
|
163 | + foreach (self::$_pradoPackages[$dep] as $script) { |
|
164 | + if (!isset($this->_expandedPradoScripts[$script])) |
|
164 | 165 | { |
165 | 166 | $this->_expandedPradoScripts[$script] = true; |
167 | + } |
|
166 | 168 | if($isDebug) |
167 | 169 | { |
168 | - if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
|
169 | - $packagesUrl[]=$url; |
|
170 | + if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) { |
|
171 | + $packagesUrl[]=$url; |
|
172 | + } |
|
170 | 173 | } else { |
171 | 174 | if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl)) |
172 | 175 | { |
173 | 176 | if(!is_file($filePath=$path.'/min/'.$script)) |
174 | 177 | { |
175 | 178 | $dirPath=dirname($filePath); |
176 | - if(!is_dir($dirPath)) |
|
177 | - mkdir($dirPath, PRADO_CHMOD, true); |
|
179 | + if(!is_dir($dirPath)) { |
|
180 | + mkdir($dirPath, PRADO_CHMOD, true); |
|
181 | + } |
|
178 | 182 | file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$script))); |
179 | 183 | chmod($filePath, PRADO_CHMOD); |
180 | 184 | } |
@@ -184,8 +188,9 @@ discard block |
||
184 | 188 | } |
185 | 189 | } |
186 | 190 | } |
187 | - foreach($packagesUrl as $url) |
|
188 | - $this->registerScriptFile($url,$url); |
|
191 | + foreach($packagesUrl as $url) { |
|
192 | + $this->registerScriptFile($url,$url); |
|
193 | + } |
|
189 | 194 | } |
190 | 195 | } |
191 | 196 | } |
@@ -226,8 +231,7 @@ discard block |
||
226 | 231 | $base = $dir; |
227 | 232 | } |
228 | 233 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
229 | - } |
|
230 | - else |
|
234 | + } else |
|
231 | 235 | { |
232 | 236 | return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
233 | 237 | } |
@@ -278,8 +282,9 @@ discard block |
||
278 | 282 | if($class === null) { |
279 | 283 | return; |
280 | 284 | } |
281 | - if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
|
282 | - $options['FormID']=$form->getClientID(); |
|
285 | + if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) { |
|
286 | + $options['FormID']=$form->getClientID(); |
|
287 | + } |
|
283 | 288 | $optionString=TJavaScript::encode($options); |
284 | 289 | $code="new {$class}({$optionString});"; |
285 | 290 | |
@@ -300,9 +305,9 @@ discard block |
||
300 | 305 | { |
301 | 306 | $panelID=is_string($panel)?$panel:$panel->getUniqueID(); |
302 | 307 | |
303 | - if(is_string($button)) |
|
304 | - $buttonID=$button; |
|
305 | - else |
|
308 | + if(is_string($button)) { |
|
309 | + $buttonID=$button; |
|
310 | + } else |
|
306 | 311 | { |
307 | 312 | $button->setIsDefaultButton(true); |
308 | 313 | $buttonID=$button->getUniqueID(); |
@@ -339,8 +344,9 @@ discard block |
||
339 | 344 | public function registerFocusControl($target) |
340 | 345 | { |
341 | 346 | $this->registerPradoScriptInternal('jquery'); |
342 | - if($target instanceof TControl) |
|
343 | - $target=$target->getClientID(); |
|
347 | + if($target instanceof TControl) { |
|
348 | + $target=$target->getClientID(); |
|
349 | + } |
|
344 | 350 | $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
345 | 351 | |
346 | 352 | $params=func_get_args(); |
@@ -371,10 +377,11 @@ discard block |
||
371 | 377 | */ |
372 | 378 | public function registerStyleSheetFile($key,$url,$media='') |
373 | 379 | { |
374 | - if($media==='') |
|
375 | - $this->_styleSheetFiles[$key]=$url; |
|
376 | - else |
|
377 | - $this->_styleSheetFiles[$key]=array($url,$media); |
|
380 | + if($media==='') { |
|
381 | + $this->_styleSheetFiles[$key]=$url; |
|
382 | + } else { |
|
383 | + $this->_styleSheetFiles[$key]=array($url,$media); |
|
384 | + } |
|
378 | 385 | |
379 | 386 | $params=func_get_args(); |
380 | 387 | $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); |
@@ -405,9 +412,10 @@ discard block |
||
405 | 412 | $this->_styleSheetFiles) |
406 | 413 | ); |
407 | 414 | |
408 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
409 | - if (substr($url,strlen($url)-4)=='.css') |
|
415 | + foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) { |
|
416 | + if (substr($url,strlen($url)-4)=='.css') |
|
410 | 417 | $stylesheets[] = $url; |
418 | + } |
|
411 | 419 | |
412 | 420 | $stylesheets = array_unique($stylesheets); |
413 | 421 | |
@@ -601,10 +609,11 @@ discard block |
||
601 | 609 | $str=''; |
602 | 610 | foreach($this->_styleSheetFiles as $url) |
603 | 611 | { |
604 | - if(is_array($url)) |
|
605 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
606 | - else |
|
607 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
612 | + if(is_array($url)) { |
|
613 | + $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
614 | + } else { |
|
615 | + $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
616 | + } |
|
608 | 617 | } |
609 | 618 | $writer->write($str); |
610 | 619 | } |
@@ -614,8 +623,9 @@ discard block |
||
614 | 623 | */ |
615 | 624 | public function renderStyleSheets($writer) |
616 | 625 | { |
617 | - if(count($this->_styleSheets)) |
|
618 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
626 | + if(count($this->_styleSheets)) { |
|
627 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
628 | + } |
|
619 | 629 | } |
620 | 630 | |
621 | 631 | /** |
@@ -738,25 +748,30 @@ discard block |
||
738 | 748 | */ |
739 | 749 | protected function renderHiddenFieldsInt($writer, $initial) |
740 | 750 | { |
741 | - if ($initial) $this->_renderedHiddenFields = array(); |
|
751 | + if ($initial) { |
|
752 | + $this->_renderedHiddenFields = array(); |
|
753 | + } |
|
742 | 754 | $str=''; |
743 | 755 | foreach($this->_hiddenFields as $name=>$value) |
744 | 756 | { |
745 | - if (in_array($name,$this->_renderedHiddenFields)) continue; |
|
757 | + if (in_array($name,$this->_renderedHiddenFields)) { |
|
758 | + continue; |
|
759 | + } |
|
746 | 760 | $id=strtr($name,':','_'); |
747 | 761 | if(is_array($value)) |
748 | 762 | { |
749 | - foreach($value as $v) |
|
750 | - $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
751 | - } |
|
752 | - else |
|
763 | + foreach($value as $v) { |
|
764 | + $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
765 | + } |
|
766 | + } else |
|
753 | 767 | { |
754 | 768 | $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
755 | 769 | } |
756 | 770 | $this->_renderedHiddenFields[] = $name; |
757 | 771 | } |
758 | - if($str!=='') |
|
759 | - $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
772 | + if($str!=='') { |
|
773 | + $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
774 | + } |
|
760 | 775 | } |
761 | 776 | |
762 | 777 | public function getHiddenFields() |
@@ -769,8 +784,9 @@ discard block |
||
769 | 784 | */ |
770 | 785 | protected function checkIfNotInRender() |
771 | 786 | { |
772 | - if ($form = $this->_page->InFormRender) |
|
773 | - throw new Exception('Operation invalid when page is already rendering'); |
|
787 | + if ($form = $this->_page->InFormRender) { |
|
788 | + throw new Exception('Operation invalid when page is already rendering'); |
|
789 | + } |
|
774 | 790 | } |
775 | 791 | } |
776 | 792 | |
@@ -802,8 +818,9 @@ discard block |
||
802 | 818 | */ |
803 | 819 | protected function setFunction($name, $code) |
804 | 820 | { |
805 | - if(!TJavaScript::isJsLiteral($code)) |
|
806 | - $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
821 | + if(!TJavaScript::isJsLiteral($code)) { |
|
822 | + $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
823 | + } |
|
807 | 824 | $this->setOption($name, $code); |
808 | 825 | } |
809 | 826 | |
@@ -812,10 +829,11 @@ discard block |
||
812 | 829 | */ |
813 | 830 | protected function getOption($name) |
814 | 831 | { |
815 | - if ($this->_options) |
|
816 | - return $this->_options->itemAt($name); |
|
817 | - else |
|
818 | - return null; |
|
832 | + if ($this->_options) { |
|
833 | + return $this->_options->itemAt($name); |
|
834 | + } else { |
|
835 | + return null; |
|
836 | + } |
|
819 | 837 | } |
820 | 838 | |
821 | 839 | /** |
@@ -832,8 +850,9 @@ discard block |
||
832 | 850 | */ |
833 | 851 | public function getOptions() |
834 | 852 | { |
835 | - if (!$this->_options) |
|
836 | - $this->_options = Prado::createComponent('System.Collections.TMap'); |
|
853 | + if (!$this->_options) { |
|
854 | + $this->_options = Prado::createComponent('System.Collections.TMap'); |
|
855 | + } |
|
837 | 856 | return $this->_options; |
838 | 857 | } |
839 | 858 |
@@ -261,6 +261,7 @@ discard block |
||
261 | 261 | * Sets the page for a control. |
262 | 262 | * Only framework developers should use this method. |
263 | 263 | * @param TPage the page that contains this control |
264 | + * @param TPage $page |
|
264 | 265 | */ |
265 | 266 | public function setPage($page) |
266 | 267 | { |
@@ -542,6 +543,7 @@ discard block |
||
542 | 543 | |
543 | 544 | /** |
544 | 545 | * @param boolean whether the control is visible |
546 | + * @param boolean $value |
|
545 | 547 | */ |
546 | 548 | public function setVisible($value) |
547 | 549 | { |
@@ -609,6 +611,7 @@ discard block |
||
609 | 611 | } |
610 | 612 | |
611 | 613 | /** |
614 | + * @param string $name |
|
612 | 615 | * @return boolean whether the named attribute exists |
613 | 616 | */ |
614 | 617 | public function hasAttribute($name) |
@@ -620,6 +623,7 @@ discard block |
||
620 | 623 | } |
621 | 624 | |
622 | 625 | /** |
626 | + * @param string $name |
|
623 | 627 | * @return string attribute value, null if attribute does not exist |
624 | 628 | */ |
625 | 629 | public function getAttribute($name) |
@@ -634,6 +638,7 @@ discard block |
||
634 | 638 | * Sets a custom control attribute. |
635 | 639 | * @param string attribute name |
636 | 640 | * @param string value of the attribute |
641 | + * @param string $name |
|
637 | 642 | */ |
638 | 643 | public function setAttribute($name,$value) |
639 | 644 | { |
@@ -671,6 +676,7 @@ discard block |
||
671 | 676 | |
672 | 677 | /** |
673 | 678 | * @param boolean set whether to enable viewstate |
679 | + * @param boolean $value |
|
674 | 680 | */ |
675 | 681 | public function setEnableViewState($value) |
676 | 682 | { |
@@ -687,6 +693,7 @@ discard block |
||
687 | 693 | * that must be kept in controlstate. |
688 | 694 | * @param string the name of the controlstate value to be returned |
689 | 695 | * @param mixed the default value. If $key is not found in controlstate, $defaultValue will be returned |
696 | + * @param string $key |
|
690 | 697 | * @return mixed the controlstate value corresponding to $key |
691 | 698 | */ |
692 | 699 | protected function getControlState($key,$defaultValue=null) |
@@ -703,6 +710,8 @@ discard block |
||
703 | 710 | * @param string the name of the controlstate value |
704 | 711 | * @param mixed the controlstate value to be set |
705 | 712 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from controlstate |
713 | + * @param string $key |
|
714 | + * @param integer $defaultValue |
|
706 | 715 | */ |
707 | 716 | protected function setControlState($key,$value,$defaultValue=null) |
708 | 717 | { |
@@ -726,6 +735,7 @@ discard block |
||
726 | 735 | * When it is false, data saved via setViewState() will not be persisted. |
727 | 736 | * By default, it is true, meaning data will be persisted across postbacks. |
728 | 737 | * @param boolean whether data should be persisted |
738 | + * @param boolean $enabled |
|
729 | 739 | */ |
730 | 740 | public function trackViewState($enabled) |
731 | 741 | { |
@@ -764,6 +774,7 @@ discard block |
||
764 | 774 | * @param string the name of the viewstate value |
765 | 775 | * @param mixed the viewstate value to be set |
766 | 776 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from the viewstate. |
777 | + * @param string $key |
|
767 | 778 | */ |
768 | 779 | public function setViewState($key,$value,$defaultValue=null) |
769 | 780 | { |
@@ -788,6 +799,7 @@ discard block |
||
788 | 799 | /** |
789 | 800 | * Clears a viewstate value. |
790 | 801 | * @param string the name of the viewstate value to be cleared |
802 | + * @param string $key |
|
791 | 803 | */ |
792 | 804 | public function clearViewState($key) |
793 | 805 | { |
@@ -893,6 +905,7 @@ discard block |
||
893 | 905 | * Sets a value indicating whether child controls are created. |
894 | 906 | * If false, any existing child controls will be cleared up. |
895 | 907 | * @param boolean whether child controls are created |
908 | + * @param boolean $value |
|
896 | 909 | */ |
897 | 910 | final protected function setChildControlsCreated($value) |
898 | 911 | { |
@@ -983,6 +996,7 @@ discard block |
||
983 | 996 | * Finds all child and grand-child controls that are of the specified type. |
984 | 997 | * @param string the class name |
985 | 998 | * @param boolean whether the type comparison is strict or not. If false, controls of the parent classes of the specified class will also be returned. |
999 | + * @param string $type |
|
986 | 1000 | * @return array list of controls found |
987 | 1001 | */ |
988 | 1002 | public function findControlsByType($type,$strict=true) |
@@ -1117,6 +1131,7 @@ discard block |
||
1117 | 1131 | * A component with explicit ID on a template will be registered to |
1118 | 1132 | * the template owner. This method allows you to obtain this component |
1119 | 1133 | * with the ID. |
1134 | + * @param string $name |
|
1120 | 1135 | * @return mixed the named registered object. Null if object is not found. |
1121 | 1136 | */ |
1122 | 1137 | public function getRegisteredObject($name) |
@@ -1174,6 +1189,7 @@ discard block |
||
1174 | 1189 | * Control lifecycles will be caught up during the addition. |
1175 | 1190 | * Only framework developers should use this method. |
1176 | 1191 | * @param TControl the new child control |
1192 | + * @param TControl $control |
|
1177 | 1193 | */ |
1178 | 1194 | public function addedControl($control) |
1179 | 1195 | { |
@@ -1219,6 +1235,7 @@ discard block |
||
1219 | 1235 | * Removes a control from the child collection of the control. |
1220 | 1236 | * Only framework developers should use this method. |
1221 | 1237 | * @param TControl the child control removed |
1238 | + * @param TControl $control |
|
1222 | 1239 | */ |
1223 | 1240 | public function removedControl($control) |
1224 | 1241 | { |
@@ -1470,6 +1487,7 @@ discard block |
||
1470 | 1487 | * @param string name of the broadcast event |
1471 | 1488 | * @param TControl sender of the event |
1472 | 1489 | * @param TBroadcastEventParameter event parameter |
1490 | + * @param TBroadcastEventParameter $param |
|
1473 | 1491 | */ |
1474 | 1492 | private function broadcastEventInternal($name,$sender,$param) |
1475 | 1493 | { |
@@ -1694,6 +1712,7 @@ discard block |
||
1694 | 1712 | * Clears the cached UniqueID. |
1695 | 1713 | * If $recursive=true, all children's cached UniqueID will be cleared as well. |
1696 | 1714 | * @param boolean whether the clearing is recursive. |
1715 | + * @param boolean $recursive |
|
1697 | 1716 | */ |
1698 | 1717 | private function clearCachedUniqueID($recursive) |
1699 | 1718 | { |
@@ -1731,6 +1750,7 @@ discard block |
||
1731 | 1750 | * Updates the list of the controls whose IDs are managed by the specified naming container. |
1732 | 1751 | * @param TControl the naming container |
1733 | 1752 | * @param TControlCollection list of controls |
1753 | + * @param TControl $container |
|
1734 | 1754 | * @throws TInvalidDataValueException if a control's ID is not unique within its naming container. |
1735 | 1755 | */ |
1736 | 1756 | private function fillNameTable($container,$controls) |
@@ -1900,6 +1920,7 @@ discard block |
||
1900 | 1920 | * The implementation of this function should raise appropriate event(s) (e.g. OnClick, OnCommand) |
1901 | 1921 | * indicating the component is responsible for the postback event. |
1902 | 1922 | * @param string the parameter associated with the postback event |
1923 | + * @return void |
|
1903 | 1924 | */ |
1904 | 1925 | public function raisePostBackEvent($param); |
1905 | 1926 | } |
@@ -1928,6 +1949,7 @@ discard block |
||
1928 | 1949 | * Raises postdata changed event. |
1929 | 1950 | * The implementation of this function should raise appropriate event(s) (e.g. OnTextChanged) |
1930 | 1951 | * indicating the control data is changed. |
1952 | + * @return void |
|
1931 | 1953 | */ |
1932 | 1954 | public function raisePostDataChangedEvent(); |
1933 | 1955 | /** |
@@ -1961,6 +1983,7 @@ discard block |
||
1961 | 1983 | public function getIsValid(); |
1962 | 1984 | /** |
1963 | 1985 | * @param boolean whether the validator validates successfully |
1986 | + * @return void |
|
1964 | 1987 | */ |
1965 | 1988 | public function setIsValid($value); |
1966 | 1989 | /** |
@@ -1969,6 +1992,7 @@ discard block |
||
1969 | 1992 | public function getErrorMessage(); |
1970 | 1993 | /** |
1971 | 1994 | * @param string error message for the validation |
1995 | + * @return void |
|
1972 | 1996 | */ |
1973 | 1997 | public function setErrorMessage($value); |
1974 | 1998 | } |
@@ -2036,6 +2060,7 @@ discard block |
||
2036 | 2060 | /** |
2037 | 2061 | * Applies this theme to the specified control. |
2038 | 2062 | * @param TControl the control to be applied with this theme |
2063 | + * @return boolean |
|
2039 | 2064 | */ |
2040 | 2065 | public function applySkin($control); |
2041 | 2066 | } |
@@ -2057,6 +2082,7 @@ discard block |
||
2057 | 2082 | * Content in the template will be instantiated as components and text strings |
2058 | 2083 | * and passed to the specified parent control. |
2059 | 2084 | * @param TControl the parent control |
2085 | + * @return void |
|
2060 | 2086 | */ |
2061 | 2087 | public function instantiateIn($parent); |
2062 | 2088 | } |
@@ -2081,6 +2107,8 @@ discard block |
||
2081 | 2107 | |
2082 | 2108 | /** |
2083 | 2109 | * @param string caption of the button |
2110 | + * @param string $value |
|
2111 | + * @return void |
|
2084 | 2112 | */ |
2085 | 2113 | public function setText($value); |
2086 | 2114 | |
@@ -2091,6 +2119,7 @@ discard block |
||
2091 | 2119 | |
2092 | 2120 | /** |
2093 | 2121 | * @param boolean whether postback event trigger by this button will cause input validation |
2122 | + * @return void |
|
2094 | 2123 | */ |
2095 | 2124 | public function setCausesValidation($value); |
2096 | 2125 | |
@@ -2101,6 +2130,7 @@ discard block |
||
2101 | 2130 | |
2102 | 2131 | /** |
2103 | 2132 | * @param string the command name associated with the {@link onCommand OnCommand} event. |
2133 | + * @return void |
|
2104 | 2134 | */ |
2105 | 2135 | public function setCommandName($value); |
2106 | 2136 | |
@@ -2111,6 +2141,7 @@ discard block |
||
2111 | 2141 | |
2112 | 2142 | /** |
2113 | 2143 | * @param string the parameter associated with the {@link onCommand OnCommand} event. |
2144 | + * @return void |
|
2114 | 2145 | */ |
2115 | 2146 | public function setCommandParameter($value); |
2116 | 2147 | |
@@ -2121,23 +2152,27 @@ discard block |
||
2121 | 2152 | |
2122 | 2153 | /** |
2123 | 2154 | * @param string the group of validators which the button causes validation upon postback |
2155 | + * @return void |
|
2124 | 2156 | */ |
2125 | 2157 | public function setValidationGroup($value); |
2126 | 2158 | |
2127 | 2159 | /** |
2128 | 2160 | * Raises <b>OnClick</b> event. |
2129 | 2161 | * @param TEventParameter event parameter to be passed to the event handlers |
2162 | + * @return void |
|
2130 | 2163 | */ |
2131 | 2164 | public function onClick($param); |
2132 | 2165 | |
2133 | 2166 | /** |
2134 | 2167 | * Raises <b>OnCommand</b> event. |
2135 | 2168 | * @param TCommandEventParameter event parameter to be passed to the event handlers |
2169 | + * @return void |
|
2136 | 2170 | */ |
2137 | 2171 | public function onCommand($param); |
2138 | 2172 | |
2139 | 2173 | /** |
2140 | 2174 | * @param boolean set by a panel to register this button as the default button for the panel. |
2175 | + * @return void |
|
2141 | 2176 | */ |
2142 | 2177 | public function setIsDefaultButton($value); |
2143 | 2178 |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TControl, TControlCollection, TEventParameter and INamingContainer class file |
|
4 | - * |
|
5 | - * @author Qiang Xue <[email protected]> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Web.UI |
|
10 | - */ |
|
3 | + * TControl, TControlCollection, TEventParameter and INamingContainer class file |
|
4 | + * |
|
5 | + * @author Qiang Xue <[email protected]> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Web.UI |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Includes TAttributeCollection and TControlAdapter class |
@@ -71,61 +71,61 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * format of control ID |
73 | 73 | */ |
74 | - const ID_FORMAT='/^[a-zA-Z_]\\w*$/'; |
|
74 | + const ID_FORMAT = '/^[a-zA-Z_]\\w*$/'; |
|
75 | 75 | /** |
76 | 76 | * separator char between IDs in a UniqueID |
77 | 77 | */ |
78 | - const ID_SEPARATOR='$'; |
|
78 | + const ID_SEPARATOR = '$'; |
|
79 | 79 | /** |
80 | 80 | * separator char between IDs in a ClientID |
81 | 81 | */ |
82 | - const CLIENT_ID_SEPARATOR='_'; |
|
82 | + const CLIENT_ID_SEPARATOR = '_'; |
|
83 | 83 | /** |
84 | 84 | * prefix to an ID automatically generated |
85 | 85 | */ |
86 | - const AUTOMATIC_ID_PREFIX='ctl'; |
|
86 | + const AUTOMATIC_ID_PREFIX = 'ctl'; |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * the stage of lifecycles that the control is currently at |
90 | 90 | */ |
91 | - const CS_CONSTRUCTED=0; |
|
92 | - const CS_CHILD_INITIALIZED=1; |
|
93 | - const CS_INITIALIZED=2; |
|
94 | - const CS_STATE_LOADED=3; |
|
95 | - const CS_LOADED=4; |
|
96 | - const CS_PRERENDERED=5; |
|
91 | + const CS_CONSTRUCTED = 0; |
|
92 | + const CS_CHILD_INITIALIZED = 1; |
|
93 | + const CS_INITIALIZED = 2; |
|
94 | + const CS_STATE_LOADED = 3; |
|
95 | + const CS_LOADED = 4; |
|
96 | + const CS_PRERENDERED = 5; |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * State bits. |
100 | 100 | */ |
101 | - const IS_ID_SET=0x01; |
|
102 | - const IS_DISABLE_VIEWSTATE=0x02; |
|
103 | - const IS_SKIN_APPLIED=0x04; |
|
104 | - const IS_STYLESHEET_APPLIED=0x08; |
|
105 | - const IS_DISABLE_THEMING=0x10; |
|
106 | - const IS_CHILD_CREATED=0x20; |
|
107 | - const IS_CREATING_CHILD=0x40; |
|
101 | + const IS_ID_SET = 0x01; |
|
102 | + const IS_DISABLE_VIEWSTATE = 0x02; |
|
103 | + const IS_SKIN_APPLIED = 0x04; |
|
104 | + const IS_STYLESHEET_APPLIED = 0x08; |
|
105 | + const IS_DISABLE_THEMING = 0x10; |
|
106 | + const IS_CHILD_CREATED = 0x20; |
|
107 | + const IS_CREATING_CHILD = 0x40; |
|
108 | 108 | |
109 | 109 | /** |
110 | 110 | * Indexes for the rare fields. |
111 | 111 | * In order to save memory, rare fields will only be created if they are needed. |
112 | 112 | */ |
113 | - const RF_CONTROLS=0; // child controls |
|
114 | - const RF_CHILD_STATE=1; // child state field |
|
115 | - const RF_NAMED_CONTROLS=2; // list of controls whose namingcontainer is this control |
|
116 | - const RF_NAMED_CONTROLS_ID=3; // counter for automatic id |
|
117 | - const RF_SKIN_ID=4; // skin ID |
|
118 | - const RF_DATA_BINDINGS=5; // data bindings |
|
119 | - const RF_EVENTS=6; // event handlers |
|
120 | - const RF_CONTROLSTATE=7; // controlstate |
|
121 | - const RF_NAMED_OBJECTS=8; // controls declared with ID on template |
|
122 | - const RF_ADAPTER=9; // adapter |
|
123 | - const RF_AUTO_BINDINGS=10; // auto data bindings |
|
113 | + const RF_CONTROLS = 0; // child controls |
|
114 | + const RF_CHILD_STATE = 1; // child state field |
|
115 | + const RF_NAMED_CONTROLS = 2; // list of controls whose namingcontainer is this control |
|
116 | + const RF_NAMED_CONTROLS_ID = 3; // counter for automatic id |
|
117 | + const RF_SKIN_ID = 4; // skin ID |
|
118 | + const RF_DATA_BINDINGS = 5; // data bindings |
|
119 | + const RF_EVENTS = 6; // event handlers |
|
120 | + const RF_CONTROLSTATE = 7; // controlstate |
|
121 | + const RF_NAMED_OBJECTS = 8; // controls declared with ID on template |
|
122 | + const RF_ADAPTER = 9; // adapter |
|
123 | + const RF_AUTO_BINDINGS = 10; // auto data bindings |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @var string control ID |
127 | 127 | */ |
128 | - private $_id=''; |
|
128 | + private $_id = ''; |
|
129 | 129 | /** |
130 | 130 | * @var string control unique ID |
131 | 131 | */ |
@@ -149,27 +149,27 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * @var array viewstate data |
151 | 151 | */ |
152 | - private $_viewState=array(); |
|
152 | + private $_viewState = array(); |
|
153 | 153 | /** |
154 | 154 | * @var array temporary state (usually set in template) |
155 | 155 | */ |
156 | - private $_tempState=array(); |
|
156 | + private $_tempState = array(); |
|
157 | 157 | /** |
158 | 158 | * @var boolean whether we should keep state in viewstate |
159 | 159 | */ |
160 | - private $_trackViewState=true; |
|
160 | + private $_trackViewState = true; |
|
161 | 161 | /** |
162 | 162 | * @var integer the current stage of the control lifecycles |
163 | 163 | */ |
164 | - private $_stage=0; |
|
164 | + private $_stage = 0; |
|
165 | 165 | /** |
166 | 166 | * @var integer representation of the state bits |
167 | 167 | */ |
168 | - private $_flags=0; |
|
168 | + private $_flags = 0; |
|
169 | 169 | /** |
170 | 170 | * @var array a collection of rare control data |
171 | 171 | */ |
172 | - private $_rf=array(); |
|
172 | + private $_rf = array(); |
|
173 | 173 | |
174 | 174 | /** |
175 | 175 | * Returns a property value by name or a control by ID. |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function __get($name) |
191 | 191 | { |
192 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
192 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
193 | 193 | return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
194 | 194 | else |
195 | 195 | return parent::__get($name); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function getAdapter() |
210 | 210 | { |
211 | - return isset($this->_rf[self::RF_ADAPTER])?$this->_rf[self::RF_ADAPTER]:null; |
|
211 | + return isset($this->_rf[self::RF_ADAPTER]) ? $this->_rf[self::RF_ADAPTER] : null; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function setAdapter(TControlAdapter $adapter) |
218 | 218 | { |
219 | - $this->_rf[self::RF_ADAPTER]=$adapter; |
|
219 | + $this->_rf[self::RF_ADAPTER] = $adapter; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function getNamingContainer() |
234 | 234 | { |
235 | - if(!$this->_namingContainer && $this->_parent) |
|
235 | + if (!$this->_namingContainer && $this->_parent) |
|
236 | 236 | { |
237 | - if($this->_parent instanceof INamingContainer) |
|
238 | - $this->_namingContainer=$this->_parent; |
|
237 | + if ($this->_parent instanceof INamingContainer) |
|
238 | + $this->_namingContainer = $this->_parent; |
|
239 | 239 | else |
240 | - $this->_namingContainer=$this->_parent->getNamingContainer(); |
|
240 | + $this->_namingContainer = $this->_parent->getNamingContainer(); |
|
241 | 241 | } |
242 | 242 | return $this->_namingContainer; |
243 | 243 | } |
@@ -247,12 +247,12 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function getPage() |
249 | 249 | { |
250 | - if(!$this->_page) |
|
250 | + if (!$this->_page) |
|
251 | 251 | { |
252 | - if($this->_parent) |
|
253 | - $this->_page=$this->_parent->getPage(); |
|
254 | - else if($this->_tplControl) |
|
255 | - $this->_page=$this->_tplControl->getPage(); |
|
252 | + if ($this->_parent) |
|
253 | + $this->_page = $this->_parent->getPage(); |
|
254 | + else if ($this->_tplControl) |
|
255 | + $this->_page = $this->_tplControl->getPage(); |
|
256 | 256 | } |
257 | 257 | return $this->_page; |
258 | 258 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function setPage($page) |
266 | 266 | { |
267 | - $this->_page=$page; |
|
267 | + $this->_page = $page; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function setTemplateControl($control) |
276 | 276 | { |
277 | - $this->_tplControl=$control; |
|
277 | + $this->_tplControl = $control; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function getTemplateControl() |
284 | 284 | { |
285 | - if(!$this->_tplControl && $this->_parent) |
|
286 | - $this->_tplControl=$this->_parent->getTemplateControl(); |
|
285 | + if (!$this->_tplControl && $this->_parent) |
|
286 | + $this->_tplControl = $this->_parent->getTemplateControl(); |
|
287 | 287 | return $this->_tplControl; |
288 | 288 | } |
289 | 289 | |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function getSourceTemplateControl() |
296 | 296 | { |
297 | - $control=$this; |
|
298 | - while(($control instanceof TControl) && ($control=$control->getTemplateControl())!==null) |
|
297 | + $control = $this; |
|
298 | + while (($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null) |
|
299 | 299 | { |
300 | - if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
300 | + if (($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
301 | 301 | return $control; |
302 | 302 | } |
303 | 303 | return $this->getPage(); |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | */ |
325 | 325 | protected function setControlStage($value) |
326 | 326 | { |
327 | - $this->_stage=$value; |
|
327 | + $this->_stage = $value; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | * @param boolean whether to hide automatically generated ID |
335 | 335 | * @return string the ID of the control |
336 | 336 | */ |
337 | - public function getID($hideAutoID=true) |
|
337 | + public function getID($hideAutoID = true) |
|
338 | 338 | { |
339 | - if($hideAutoID) |
|
339 | + if ($hideAutoID) |
|
340 | 340 | return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
341 | 341 | else |
342 | 342 | return $this->_id; |
@@ -348,12 +348,12 @@ discard block |
||
348 | 348 | */ |
349 | 349 | public function setID($id) |
350 | 350 | { |
351 | - if(!preg_match(self::ID_FORMAT,$id)) |
|
352 | - throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id); |
|
353 | - $this->_id=$id; |
|
351 | + if (!preg_match(self::ID_FORMAT, $id)) |
|
352 | + throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id); |
|
353 | + $this->_id = $id; |
|
354 | 354 | $this->_flags |= self::IS_ID_SET; |
355 | 355 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
356 | - if($this->_namingContainer) |
|
356 | + if ($this->_namingContainer) |
|
357 | 357 | $this->_namingContainer->clearNameTable(); |
358 | 358 | } |
359 | 359 | |
@@ -366,17 +366,17 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function getUniqueID() |
368 | 368 | { |
369 | - if($this->_uid==='' || $this->_uid===null) // need to build the UniqueID |
|
369 | + if ($this->_uid === '' || $this->_uid === null) // need to build the UniqueID |
|
370 | 370 | { |
371 | - $this->_uid=''; // set to not-null, so that clearCachedUniqueID() may take action |
|
372 | - if($namingContainer=$this->getNamingContainer()) |
|
371 | + $this->_uid = ''; // set to not-null, so that clearCachedUniqueID() may take action |
|
372 | + if ($namingContainer = $this->getNamingContainer()) |
|
373 | 373 | { |
374 | - if($this->getPage()===$namingContainer) |
|
375 | - return ($this->_uid=$this->_id); |
|
376 | - else if(($prefix=$namingContainer->getUniqueID())==='') |
|
374 | + if ($this->getPage() === $namingContainer) |
|
375 | + return ($this->_uid = $this->_id); |
|
376 | + else if (($prefix = $namingContainer->getUniqueID()) === '') |
|
377 | 377 | return $this->_id; |
378 | 378 | else |
379 | - return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id); |
|
379 | + return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id); |
|
380 | 380 | } |
381 | 381 | else // no naming container |
382 | 382 | return $this->_id; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function getClientID() |
404 | 404 | { |
405 | - return strtr($this->getUniqueID(),self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR); |
|
405 | + return strtr($this->getUniqueID(), self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public static function convertUniqueIdToClientId($uniqueID) |
414 | 414 | { |
415 | - return strtr($uniqueID,self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR); |
|
415 | + return strtr($uniqueID, self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | */ |
421 | 421 | public function getSkinID() |
422 | 422 | { |
423 | - return isset($this->_rf[self::RF_SKIN_ID])?$this->_rf[self::RF_SKIN_ID]:''; |
|
423 | + return isset($this->_rf[self::RF_SKIN_ID]) ? $this->_rf[self::RF_SKIN_ID] : ''; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function setSkinID($value) |
431 | 431 | { |
432 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED) |
|
433 | - throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this)); |
|
432 | + if (($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED) |
|
433 | + throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this)); |
|
434 | 434 | else |
435 | - $this->_rf[self::RF_SKIN_ID]=$value; |
|
435 | + $this->_rf[self::RF_SKIN_ID] = $value; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | */ |
451 | 451 | public function getEnableTheming() |
452 | 452 | { |
453 | - if($this->_flags & self::IS_DISABLE_THEMING) |
|
453 | + if ($this->_flags & self::IS_DISABLE_THEMING) |
|
454 | 454 | return false; |
455 | 455 | else |
456 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
456 | + return $this->_parent ? $this->_parent->getEnableTheming() : true; |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -462,9 +462,9 @@ discard block |
||
462 | 462 | */ |
463 | 463 | public function setEnableTheming($value) |
464 | 464 | { |
465 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
466 | - throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID()); |
|
467 | - else if(TPropertyValue::ensureBoolean($value)) |
|
465 | + if ($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
466 | + throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID()); |
|
467 | + else if (TPropertyValue::ensureBoolean($value)) |
|
468 | 468 | $this->_flags &= ~self::IS_DISABLE_THEMING; |
469 | 469 | else |
470 | 470 | $this->_flags |= self::IS_DISABLE_THEMING; |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function getCustomData() |
481 | 481 | { |
482 | - return $this->getViewState('CustomData',null); |
|
482 | + return $this->getViewState('CustomData', null); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | */ |
490 | 490 | public function setCustomData($value) |
491 | 491 | { |
492 | - $this->setViewState('CustomData',$value,null); |
|
492 | + $this->setViewState('CustomData', $value, null); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | */ |
498 | 498 | public function getHasControls() |
499 | 499 | { |
500 | - return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount()>0; |
|
500 | + return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount() > 0; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public function getControls() |
507 | 507 | { |
508 | - if(!isset($this->_rf[self::RF_CONTROLS])) |
|
509 | - $this->_rf[self::RF_CONTROLS]=$this->createControlCollection(); |
|
508 | + if (!isset($this->_rf[self::RF_CONTROLS])) |
|
509 | + $this->_rf[self::RF_CONTROLS] = $this->createControlCollection(); |
|
510 | 510 | return $this->_rf[self::RF_CONTROLS]; |
511 | 511 | } |
512 | 512 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | */ |
518 | 518 | protected function createControlCollection() |
519 | 519 | { |
520 | - return $this->getAllowChildControls()?new TControlCollection($this):new TEmptyControlCollection($this); |
|
520 | + return $this->getAllowChildControls() ? new TControlCollection($this) : new TEmptyControlCollection($this); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | * @param boolean whether the parents should also be checked if visible |
528 | 528 | * @return boolean whether the control is visible (default=true). |
529 | 529 | */ |
530 | - public function getVisible($checkParents=true) |
|
530 | + public function getVisible($checkParents = true) |
|
531 | 531 | { |
532 | - if($checkParents) |
|
532 | + if ($checkParents) |
|
533 | 533 | { |
534 | - for($control=$this;$control;$control=$control->_parent) |
|
535 | - if(!$control->getVisible(false)) |
|
534 | + for ($control = $this; $control; $control = $control->_parent) |
|
535 | + if (!$control->getVisible(false)) |
|
536 | 536 | return false; |
537 | 537 | return true; |
538 | 538 | } |
539 | 539 | else |
540 | - return $this->getViewState('Visible',true); |
|
540 | + return $this->getViewState('Visible', true); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | /** |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | */ |
546 | 546 | public function setVisible($value) |
547 | 547 | { |
548 | - $this->setViewState('Visible',TPropertyValue::ensureBoolean($value),true); |
|
548 | + $this->setViewState('Visible', TPropertyValue::ensureBoolean($value), true); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | * @param boolean whether the parents should also be checked enabled |
559 | 559 | * @return boolean whether the control is enabled. |
560 | 560 | */ |
561 | - public function getEnabled($checkParents=false) |
|
561 | + public function getEnabled($checkParents = false) |
|
562 | 562 | { |
563 | - if($checkParents) |
|
563 | + if ($checkParents) |
|
564 | 564 | { |
565 | - for($control=$this;$control;$control=$control->_parent) |
|
566 | - if(!$control->getViewState('Enabled',true)) |
|
565 | + for ($control = $this; $control; $control = $control->_parent) |
|
566 | + if (!$control->getViewState('Enabled', true)) |
|
567 | 567 | return false; |
568 | 568 | return true; |
569 | 569 | } |
570 | 570 | else |
571 | - return $this->getViewState('Enabled',true); |
|
571 | + return $this->getViewState('Enabled', true); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | */ |
577 | 577 | public function setEnabled($value) |
578 | 578 | { |
579 | - $this->setViewState('Enabled',TPropertyValue::ensureBoolean($value),true); |
|
579 | + $this->setViewState('Enabled', TPropertyValue::ensureBoolean($value), true); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | */ |
585 | 585 | public function getHasAttributes() |
586 | 586 | { |
587 | - if($attributes=$this->getViewState('Attributes',null)) |
|
588 | - return $attributes->getCount()>0; |
|
587 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
588 | + return $attributes->getCount() > 0; |
|
589 | 589 | else |
590 | 590 | return false; |
591 | 591 | } |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public function getAttributes() |
600 | 600 | { |
601 | - if($attributes=$this->getViewState('Attributes',null)) |
|
601 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
602 | 602 | return $attributes; |
603 | 603 | else |
604 | 604 | { |
605 | - $attributes=new TAttributeCollection; |
|
606 | - $this->setViewState('Attributes',$attributes,null); |
|
605 | + $attributes = new TAttributeCollection; |
|
606 | + $this->setViewState('Attributes', $attributes, null); |
|
607 | 607 | return $attributes; |
608 | 608 | } |
609 | 609 | } |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | */ |
614 | 614 | public function hasAttribute($name) |
615 | 615 | { |
616 | - if($attributes=$this->getViewState('Attributes',null)) |
|
616 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
617 | 617 | return $attributes->contains($name); |
618 | 618 | else |
619 | 619 | return false; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function getAttribute($name) |
626 | 626 | { |
627 | - if($attributes=$this->getViewState('Attributes',null)) |
|
627 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
628 | 628 | return $attributes->itemAt($name); |
629 | 629 | else |
630 | 630 | return null; |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | * @param string attribute name |
636 | 636 | * @param string value of the attribute |
637 | 637 | */ |
638 | - public function setAttribute($name,$value) |
|
638 | + public function setAttribute($name, $value) |
|
639 | 639 | { |
640 | - $this->getAttributes()->add($name,$value); |
|
640 | + $this->getAttributes()->add($name, $value); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | */ |
648 | 648 | public function removeAttribute($name) |
649 | 649 | { |
650 | - if($attributes=$this->getViewState('Attributes',null)) |
|
650 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
651 | 651 | return $attributes->remove($name); |
652 | 652 | else |
653 | 653 | return null; |
@@ -656,12 +656,12 @@ discard block |
||
656 | 656 | /** |
657 | 657 | * @return boolean whether viewstate is enabled |
658 | 658 | */ |
659 | - public function getEnableViewState($checkParents=false) |
|
659 | + public function getEnableViewState($checkParents = false) |
|
660 | 660 | { |
661 | - if($checkParents) |
|
661 | + if ($checkParents) |
|
662 | 662 | { |
663 | - for($control=$this;$control!==null;$control=$control->getParent()) |
|
664 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
663 | + for ($control = $this; $control !== null; $control = $control->getParent()) |
|
664 | + if ($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
665 | 665 | return false; |
666 | 666 | return true; |
667 | 667 | } |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | */ |
675 | 675 | public function setEnableViewState($value) |
676 | 676 | { |
677 | - if(TPropertyValue::ensureBoolean($value)) |
|
677 | + if (TPropertyValue::ensureBoolean($value)) |
|
678 | 678 | $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
679 | 679 | else |
680 | 680 | $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | * @param mixed the default value. If $key is not found in controlstate, $defaultValue will be returned |
690 | 690 | * @return mixed the controlstate value corresponding to $key |
691 | 691 | */ |
692 | - protected function getControlState($key,$defaultValue=null) |
|
692 | + protected function getControlState($key, $defaultValue = null) |
|
693 | 693 | { |
694 | - return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue; |
|
694 | + return isset($this->_rf[self::RF_CONTROLSTATE][$key]) ? $this->_rf[self::RF_CONTROLSTATE][$key] : $defaultValue; |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -704,12 +704,12 @@ discard block |
||
704 | 704 | * @param mixed the controlstate value to be set |
705 | 705 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from controlstate |
706 | 706 | */ |
707 | - protected function setControlState($key,$value,$defaultValue=null) |
|
707 | + protected function setControlState($key, $value, $defaultValue = null) |
|
708 | 708 | { |
709 | - if($value===$defaultValue) |
|
709 | + if ($value === $defaultValue) |
|
710 | 710 | unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
711 | 711 | else |
712 | - $this->_rf[self::RF_CONTROLSTATE][$key]=$value; |
|
712 | + $this->_rf[self::RF_CONTROLSTATE][$key] = $value; |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | */ |
730 | 730 | public function trackViewState($enabled) |
731 | 731 | { |
732 | - $this->_trackViewState=TPropertyValue::ensureBoolean($enabled); |
|
732 | + $this->_trackViewState = TPropertyValue::ensureBoolean($enabled); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -741,14 +741,14 @@ discard block |
||
741 | 741 | * @param mixed the default value. If $key is not found in viewstate, $defaultValue will be returned |
742 | 742 | * @return mixed the viewstate value corresponding to $key |
743 | 743 | */ |
744 | - public function getViewState($key,$defaultValue=null) |
|
744 | + public function getViewState($key, $defaultValue = null) |
|
745 | 745 | { |
746 | - if(isset($this->_viewState[$key])) |
|
747 | - return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue; |
|
748 | - else if(isset($this->_tempState[$key])) |
|
746 | + if (isset($this->_viewState[$key])) |
|
747 | + return $this->_viewState[$key] !== null ? $this->_viewState[$key] : $defaultValue; |
|
748 | + else if (isset($this->_tempState[$key])) |
|
749 | 749 | { |
750 | - if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
751 | - $this->_viewState[$key]=$this->_tempState[$key]; |
|
750 | + if (is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
751 | + $this->_viewState[$key] = $this->_tempState[$key]; |
|
752 | 752 | return $this->_tempState[$key]; |
753 | 753 | } |
754 | 754 | else |
@@ -765,23 +765,23 @@ discard block |
||
765 | 765 | * @param mixed the viewstate value to be set |
766 | 766 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from the viewstate. |
767 | 767 | */ |
768 | - public function setViewState($key,$value,$defaultValue=null) |
|
768 | + public function setViewState($key, $value, $defaultValue = null) |
|
769 | 769 | { |
770 | - if($this->_trackViewState) |
|
770 | + if ($this->_trackViewState) |
|
771 | 771 | { |
772 | 772 | unset($this->_tempState[$key]); |
773 | - if($value===$defaultValue) |
|
773 | + if ($value === $defaultValue) |
|
774 | 774 | unset($this->_viewState[$key]); |
775 | 775 | else |
776 | - $this->_viewState[$key]=$value; |
|
776 | + $this->_viewState[$key] = $value; |
|
777 | 777 | } |
778 | 778 | else |
779 | 779 | { |
780 | 780 | unset($this->_viewState[$key]); |
781 | - if($value===$defaultValue) |
|
781 | + if ($value === $defaultValue) |
|
782 | 782 | unset($this->_tempState[$key]); |
783 | 783 | else |
784 | - $this->_tempState[$key]=$value; |
|
784 | + $this->_tempState[$key] = $value; |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
@@ -801,9 +801,9 @@ discard block |
||
801 | 801 | * @param string the property name, or property path |
802 | 802 | * @param string the expression |
803 | 803 | */ |
804 | - public function bindProperty($name,$expression) |
|
804 | + public function bindProperty($name, $expression) |
|
805 | 805 | { |
806 | - $this->_rf[self::RF_DATA_BINDINGS][$name]=$expression; |
|
806 | + $this->_rf[self::RF_DATA_BINDINGS][$name] = $expression; |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -823,9 +823,9 @@ discard block |
||
823 | 823 | * @param string the property name, or property path |
824 | 824 | * @param string the expression |
825 | 825 | */ |
826 | - public function autoBindProperty($name,$expression) |
|
826 | + public function autoBindProperty($name, $expression) |
|
827 | 827 | { |
828 | - $this->_rf[self::RF_AUTO_BINDINGS][$name]=$expression; |
|
828 | + $this->_rf[self::RF_AUTO_BINDINGS][$name] = $expression; |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | /** |
@@ -843,13 +843,13 @@ discard block |
||
843 | 843 | */ |
844 | 844 | protected function dataBindProperties() |
845 | 845 | { |
846 | - Prado::trace("Data bind properties",'System.Web.UI.TControl'); |
|
847 | - if(isset($this->_rf[self::RF_DATA_BINDINGS])) |
|
846 | + Prado::trace("Data bind properties", 'System.Web.UI.TControl'); |
|
847 | + if (isset($this->_rf[self::RF_DATA_BINDINGS])) |
|
848 | 848 | { |
849 | - if(($context=$this->getTemplateControl())===null) |
|
850 | - $context=$this; |
|
851 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) |
|
852 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
849 | + if (($context = $this->getTemplateControl()) === null) |
|
850 | + $context = $this; |
|
851 | + foreach ($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) |
|
852 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -858,12 +858,12 @@ discard block |
||
858 | 858 | */ |
859 | 859 | protected function autoDataBindProperties() |
860 | 860 | { |
861 | - if(isset($this->_rf[self::RF_AUTO_BINDINGS])) |
|
861 | + if (isset($this->_rf[self::RF_AUTO_BINDINGS])) |
|
862 | 862 | { |
863 | - if(($context=$this->getTemplateControl())===null) |
|
864 | - $context=$this; |
|
865 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) |
|
866 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
863 | + if (($context = $this->getTemplateControl()) === null) |
|
864 | + $context = $this; |
|
865 | + foreach ($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) |
|
866 | + $this->setSubProperty($property, $context->evaluateExpression($expression)); |
|
867 | 867 | } |
868 | 868 | } |
869 | 869 | |
@@ -872,11 +872,11 @@ discard block |
||
872 | 872 | */ |
873 | 873 | protected function dataBindChildren() |
874 | 874 | { |
875 | - Prado::trace("dataBindChildren()",'System.Web.UI.TControl'); |
|
876 | - if(isset($this->_rf[self::RF_CONTROLS])) |
|
875 | + Prado::trace("dataBindChildren()", 'System.Web.UI.TControl'); |
|
876 | + if (isset($this->_rf[self::RF_CONTROLS])) |
|
877 | 877 | { |
878 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
879 | - if($control instanceof IBindable) |
|
878 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
879 | + if ($control instanceof IBindable) |
|
880 | 880 | $control->dataBind(); |
881 | 881 | } |
882 | 882 | } |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | */ |
887 | 887 | final protected function getChildControlsCreated() |
888 | 888 | { |
889 | - return ($this->_flags & self::IS_CHILD_CREATED)!==0; |
|
889 | + return ($this->_flags & self::IS_CHILD_CREATED) !== 0; |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | /** |
@@ -896,11 +896,11 @@ discard block |
||
896 | 896 | */ |
897 | 897 | final protected function setChildControlsCreated($value) |
898 | 898 | { |
899 | - if($value) |
|
899 | + if ($value) |
|
900 | 900 | $this->_flags |= self::IS_CHILD_CREATED; |
901 | 901 | else |
902 | 902 | { |
903 | - if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
903 | + if ($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
904 | 904 | $this->getControls()->clear(); |
905 | 905 | $this->_flags &= ~self::IS_CHILD_CREATED; |
906 | 906 | } |
@@ -913,19 +913,19 @@ discard block |
||
913 | 913 | */ |
914 | 914 | public function ensureChildControls() |
915 | 915 | { |
916 | - if(!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD)) |
|
916 | + if (!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD)) |
|
917 | 917 | { |
918 | 918 | try |
919 | 919 | { |
920 | 920 | $this->_flags |= self::IS_CREATING_CHILD; |
921 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
921 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
922 | 922 | $this->_rf[self::RF_ADAPTER]->createChildControls(); |
923 | 923 | else |
924 | 924 | $this->createChildControls(); |
925 | 925 | $this->_flags &= ~self::IS_CREATING_CHILD; |
926 | 926 | $this->_flags |= self::IS_CHILD_CREATED; |
927 | 927 | } |
928 | - catch(Exception $e) |
|
928 | + catch (Exception $e) |
|
929 | 929 | { |
930 | 930 | $this->_flags &= ~self::IS_CREATING_CHILD; |
931 | 931 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -957,22 +957,22 @@ discard block |
||
957 | 957 | */ |
958 | 958 | public function findControl($id) |
959 | 959 | { |
960 | - $id=strtr($id,'.',self::ID_SEPARATOR); |
|
961 | - $container=($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
|
962 | - if(!$container || !$container->getHasControls()) |
|
960 | + $id = strtr($id, '.', self::ID_SEPARATOR); |
|
961 | + $container = ($this instanceof INamingContainer) ? $this : $this->getNamingContainer(); |
|
962 | + if (!$container || !$container->getHasControls()) |
|
963 | 963 | return null; |
964 | - if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
|
964 | + if (!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
|
965 | 965 | { |
966 | - $container->_rf[self::RF_NAMED_CONTROLS]=array(); |
|
967 | - $container->fillNameTable($container,$container->_rf[self::RF_CONTROLS]); |
|
966 | + $container->_rf[self::RF_NAMED_CONTROLS] = array(); |
|
967 | + $container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]); |
|
968 | 968 | } |
969 | - if(($pos=strpos($id,self::ID_SEPARATOR))===false) |
|
970 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
969 | + if (($pos = strpos($id, self::ID_SEPARATOR)) === false) |
|
970 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id]) ? $container->_rf[self::RF_NAMED_CONTROLS][$id] : null; |
|
971 | 971 | else |
972 | 972 | { |
973 | - $cid=substr($id,0,$pos); |
|
974 | - $sid=substr($id,$pos+1); |
|
975 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
973 | + $cid = substr($id, 0, $pos); |
|
974 | + $sid = substr($id, $pos + 1); |
|
975 | + if (isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
976 | 976 | return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
977 | 977 | else |
978 | 978 | return null; |
@@ -985,17 +985,17 @@ discard block |
||
985 | 985 | * @param boolean whether the type comparison is strict or not. If false, controls of the parent classes of the specified class will also be returned. |
986 | 986 | * @return array list of controls found |
987 | 987 | */ |
988 | - public function findControlsByType($type,$strict=true) |
|
988 | + public function findControlsByType($type, $strict = true) |
|
989 | 989 | { |
990 | - $controls=array(); |
|
991 | - if($this->getHasControls()) |
|
990 | + $controls = array(); |
|
991 | + if ($this->getHasControls()) |
|
992 | 992 | { |
993 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
993 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
994 | 994 | { |
995 | - if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type)))) |
|
996 | - $controls[]=$control; |
|
997 | - if(($control instanceof TControl) && $control->getHasControls()) |
|
998 | - $controls=array_merge($controls,$control->findControlsByType($type,$strict)); |
|
995 | + if (is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type)))) |
|
996 | + $controls[] = $control; |
|
997 | + if (($control instanceof TControl) && $control->getHasControls()) |
|
998 | + $controls = array_merge($controls, $control->findControlsByType($type, $strict)); |
|
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | return $controls; |
@@ -1012,16 +1012,16 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | public function findControlsByID($id) |
1014 | 1014 | { |
1015 | - $controls=array(); |
|
1016 | - if($this->getHasControls()) |
|
1015 | + $controls = array(); |
|
1016 | + if ($this->getHasControls()) |
|
1017 | 1017 | { |
1018 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1018 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1019 | 1019 | { |
1020 | - if($control instanceof TControl) |
|
1020 | + if ($control instanceof TControl) |
|
1021 | 1021 | { |
1022 | - if($control->_id===$id) |
|
1023 | - $controls[]=$control; |
|
1024 | - $controls=array_merge($controls,$control->findControlsByID($id)); |
|
1022 | + if ($control->_id === $id) |
|
1023 | + $controls[] = $control; |
|
1024 | + $controls = array_merge($controls, $control->findControlsByID($id)); |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | } |
@@ -1046,11 +1046,11 @@ discard block |
||
1046 | 1046 | * @param object object to be declared |
1047 | 1047 | * @see __get |
1048 | 1048 | */ |
1049 | - public function registerObject($name,$object) |
|
1049 | + public function registerObject($name, $object) |
|
1050 | 1050 | { |
1051 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1052 | - throw new TInvalidOperationException('control_object_reregistered',$name); |
|
1053 | - $this->_rf[self::RF_NAMED_OBJECTS][$name]=$object; |
|
1051 | + if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1052 | + throw new TInvalidOperationException('control_object_reregistered', $name); |
|
1053 | + $this->_rf[self::RF_NAMED_OBJECTS][$name] = $object; |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | /** |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | */ |
1122 | 1122 | public function getRegisteredObject($name) |
1123 | 1123 | { |
1124 | - return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null; |
|
1124 | + return isset($this->_rf[self::RF_NAMED_OBJECTS][$name]) ? $this->_rf[self::RF_NAMED_OBJECTS][$name] : null; |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | /** |
@@ -1163,10 +1163,10 @@ discard block |
||
1163 | 1163 | */ |
1164 | 1164 | final protected function isDescendentOf($ancestor) |
1165 | 1165 | { |
1166 | - $control=$this; |
|
1167 | - while($control!==$ancestor && $control->_parent) |
|
1168 | - $control=$control->_parent; |
|
1169 | - return $control===$ancestor; |
|
1166 | + $control = $this; |
|
1167 | + while ($control !== $ancestor && $control->_parent) |
|
1168 | + $control = $control->_parent; |
|
1169 | + return $control === $ancestor; |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | 1172 | /** |
@@ -1177,38 +1177,38 @@ discard block |
||
1177 | 1177 | */ |
1178 | 1178 | public function addedControl($control) |
1179 | 1179 | { |
1180 | - if($control->_parent) |
|
1180 | + if ($control->_parent) |
|
1181 | 1181 | $control->_parent->getControls()->remove($control); |
1182 | - $control->_parent=$this; |
|
1183 | - $control->_page=$this->getPage(); |
|
1184 | - $namingContainer=($this instanceof INamingContainer)?$this:$this->_namingContainer; |
|
1185 | - if($namingContainer) |
|
1182 | + $control->_parent = $this; |
|
1183 | + $control->_page = $this->getPage(); |
|
1184 | + $namingContainer = ($this instanceof INamingContainer) ? $this : $this->_namingContainer; |
|
1185 | + if ($namingContainer) |
|
1186 | 1186 | { |
1187 | - $control->_namingContainer=$namingContainer; |
|
1188 | - if($control->_id==='') |
|
1187 | + $control->_namingContainer = $namingContainer; |
|
1188 | + if ($control->_id === '') |
|
1189 | 1189 | $control->generateAutomaticID(); |
1190 | 1190 | else |
1191 | 1191 | $namingContainer->clearNameTable(); |
1192 | 1192 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
1193 | 1193 | } |
1194 | 1194 | |
1195 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
1195 | + if ($this->_stage >= self::CS_CHILD_INITIALIZED) |
|
1196 | 1196 | { |
1197 | 1197 | $control->initRecursive($namingContainer); |
1198 | - if($this->_stage>=self::CS_STATE_LOADED) |
|
1198 | + if ($this->_stage >= self::CS_STATE_LOADED) |
|
1199 | 1199 | { |
1200 | - if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
|
1200 | + if (isset($this->_rf[self::RF_CHILD_STATE][$control->_id])) |
|
1201 | 1201 | { |
1202 | - $state=$this->_rf[self::RF_CHILD_STATE][$control->_id]; |
|
1202 | + $state = $this->_rf[self::RF_CHILD_STATE][$control->_id]; |
|
1203 | 1203 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
1204 | 1204 | } |
1205 | 1205 | else |
1206 | - $state=null; |
|
1207 | - $control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
1208 | - if($this->_stage>=self::CS_LOADED) |
|
1206 | + $state = null; |
|
1207 | + $control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
1208 | + if ($this->_stage >= self::CS_LOADED) |
|
1209 | 1209 | { |
1210 | 1210 | $control->loadRecursive(); |
1211 | - if($this->_stage>=self::CS_PRERENDERED) |
|
1211 | + if ($this->_stage >= self::CS_PRERENDERED) |
|
1212 | 1212 | $control->preRenderRecursive(); |
1213 | 1213 | } |
1214 | 1214 | } |
@@ -1222,16 +1222,16 @@ discard block |
||
1222 | 1222 | */ |
1223 | 1223 | public function removedControl($control) |
1224 | 1224 | { |
1225 | - if($this->_namingContainer) |
|
1225 | + if ($this->_namingContainer) |
|
1226 | 1226 | $this->_namingContainer->clearNameTable(); |
1227 | 1227 | $control->unloadRecursive(); |
1228 | - $control->_parent=null; |
|
1229 | - $control->_page=null; |
|
1230 | - $control->_namingContainer=null; |
|
1231 | - $control->_tplControl=null; |
|
1228 | + $control->_parent = null; |
|
1229 | + $control->_page = null; |
|
1230 | + $control->_namingContainer = null; |
|
1231 | + $control->_tplControl = null; |
|
1232 | 1232 | //$control->_stage=self::CS_CONSTRUCTED; |
1233 | - if(!($control->_flags & self::IS_ID_SET)) |
|
1234 | - $control->_id=''; |
|
1233 | + if (!($control->_flags & self::IS_ID_SET)) |
|
1234 | + $control->_id = ''; |
|
1235 | 1235 | else |
1236 | 1236 | unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
1237 | 1237 | $control->clearCachedUniqueID(true); |
@@ -1242,39 +1242,39 @@ discard block |
||
1242 | 1242 | * Only framework developers should use this method. |
1243 | 1243 | * @param TControl the naming container control |
1244 | 1244 | */ |
1245 | - protected function initRecursive($namingContainer=null) |
|
1245 | + protected function initRecursive($namingContainer = null) |
|
1246 | 1246 | { |
1247 | 1247 | $this->ensureChildControls(); |
1248 | - if($this->getHasControls()) |
|
1248 | + if ($this->getHasControls()) |
|
1249 | 1249 | { |
1250 | - if($this instanceof INamingContainer) |
|
1251 | - $namingContainer=$this; |
|
1252 | - $page=$this->getPage(); |
|
1253 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1250 | + if ($this instanceof INamingContainer) |
|
1251 | + $namingContainer = $this; |
|
1252 | + $page = $this->getPage(); |
|
1253 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1254 | 1254 | { |
1255 | - if($control instanceof TControl) |
|
1255 | + if ($control instanceof TControl) |
|
1256 | 1256 | { |
1257 | - $control->_namingContainer=$namingContainer; |
|
1258 | - $control->_page=$page; |
|
1259 | - if($control->_id==='' && $namingContainer) |
|
1257 | + $control->_namingContainer = $namingContainer; |
|
1258 | + $control->_page = $page; |
|
1259 | + if ($control->_id === '' && $namingContainer) |
|
1260 | 1260 | $control->generateAutomaticID(); |
1261 | 1261 | $control->initRecursive($namingContainer); |
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | } |
1265 | - if($this->_stage<self::CS_INITIALIZED) |
|
1265 | + if ($this->_stage < self::CS_INITIALIZED) |
|
1266 | 1266 | { |
1267 | - $this->_stage=self::CS_CHILD_INITIALIZED; |
|
1268 | - if(($page=$this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
|
1267 | + $this->_stage = self::CS_CHILD_INITIALIZED; |
|
1268 | + if (($page = $this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED)) |
|
1269 | 1269 | { |
1270 | 1270 | $page->applyControlSkin($this); |
1271 | 1271 | $this->_flags |= self::IS_SKIN_APPLIED; |
1272 | 1272 | } |
1273 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1273 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1274 | 1274 | $this->_rf[self::RF_ADAPTER]->onInit(null); |
1275 | 1275 | else |
1276 | 1276 | $this->onInit(null); |
1277 | - $this->_stage=self::CS_INITIALIZED; |
|
1277 | + $this->_stage = self::CS_INITIALIZED; |
|
1278 | 1278 | } |
1279 | 1279 | } |
1280 | 1280 | |
@@ -1284,23 +1284,23 @@ discard block |
||
1284 | 1284 | */ |
1285 | 1285 | protected function loadRecursive() |
1286 | 1286 | { |
1287 | - if($this->_stage<self::CS_LOADED) |
|
1287 | + if ($this->_stage < self::CS_LOADED) |
|
1288 | 1288 | { |
1289 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1289 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1290 | 1290 | $this->_rf[self::RF_ADAPTER]->onLoad(null); |
1291 | 1291 | else |
1292 | 1292 | $this->onLoad(null); |
1293 | 1293 | } |
1294 | - if($this->getHasControls()) |
|
1294 | + if ($this->getHasControls()) |
|
1295 | 1295 | { |
1296 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1296 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1297 | 1297 | { |
1298 | - if($control instanceof TControl) |
|
1298 | + if ($control instanceof TControl) |
|
1299 | 1299 | $control->loadRecursive(); |
1300 | 1300 | } |
1301 | 1301 | } |
1302 | - if($this->_stage<self::CS_LOADED) |
|
1303 | - $this->_stage=self::CS_LOADED; |
|
1302 | + if ($this->_stage < self::CS_LOADED) |
|
1303 | + $this->_stage = self::CS_LOADED; |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | /** |
@@ -1311,24 +1311,24 @@ discard block |
||
1311 | 1311 | { |
1312 | 1312 | $this->autoDataBindProperties(); |
1313 | 1313 | |
1314 | - if($this->getVisible(false)) |
|
1314 | + if ($this->getVisible(false)) |
|
1315 | 1315 | { |
1316 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1316 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1317 | 1317 | $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
1318 | 1318 | else |
1319 | 1319 | $this->onPreRender(null); |
1320 | - if($this->getHasControls()) |
|
1320 | + if ($this->getHasControls()) |
|
1321 | 1321 | { |
1322 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1322 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1323 | 1323 | { |
1324 | - if($control instanceof TControl) |
|
1324 | + if ($control instanceof TControl) |
|
1325 | 1325 | $control->preRenderRecursive(); |
1326 | - else if($control instanceof TCompositeLiteral) |
|
1326 | + else if ($control instanceof TCompositeLiteral) |
|
1327 | 1327 | $control->evaluateDynamicContent(); |
1328 | 1328 | } |
1329 | 1329 | } |
1330 | 1330 | } |
1331 | - $this->_stage=self::CS_PRERENDERED; |
|
1331 | + $this->_stage = self::CS_PRERENDERED; |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | /** |
@@ -1337,15 +1337,15 @@ discard block |
||
1337 | 1337 | */ |
1338 | 1338 | protected function unloadRecursive() |
1339 | 1339 | { |
1340 | - if(!($this->_flags & self::IS_ID_SET)) |
|
1341 | - $this->_id=''; |
|
1342 | - if($this->getHasControls()) |
|
1340 | + if (!($this->_flags & self::IS_ID_SET)) |
|
1341 | + $this->_id = ''; |
|
1342 | + if ($this->getHasControls()) |
|
1343 | 1343 | { |
1344 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1345 | - if($control instanceof TControl) |
|
1344 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1345 | + if ($control instanceof TControl) |
|
1346 | 1346 | $control->unloadRecursive(); |
1347 | 1347 | } |
1348 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1348 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1349 | 1349 | $this->_rf[self::RF_ADAPTER]->onUnload(null); |
1350 | 1350 | else |
1351 | 1351 | $this->onUnload(null); |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | */ |
1361 | 1361 | public function onInit($param) |
1362 | 1362 | { |
1363 | - $this->raiseEvent('OnInit',$this,$param); |
|
1363 | + $this->raiseEvent('OnInit', $this, $param); |
|
1364 | 1364 | } |
1365 | 1365 | |
1366 | 1366 | /** |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | */ |
1373 | 1373 | public function onLoad($param) |
1374 | 1374 | { |
1375 | - $this->raiseEvent('OnLoad',$this,$param); |
|
1375 | + $this->raiseEvent('OnLoad', $this, $param); |
|
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | /** |
@@ -1382,8 +1382,8 @@ discard block |
||
1382 | 1382 | */ |
1383 | 1383 | public function onDataBinding($param) |
1384 | 1384 | { |
1385 | - Prado::trace("onDataBinding()",'System.Web.UI.TControl'); |
|
1386 | - $this->raiseEvent('OnDataBinding',$this,$param); |
|
1385 | + Prado::trace("onDataBinding()", 'System.Web.UI.TControl'); |
|
1386 | + $this->raiseEvent('OnDataBinding', $this, $param); |
|
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | */ |
1397 | 1397 | public function onUnload($param) |
1398 | 1398 | { |
1399 | - $this->raiseEvent('OnUnload',$this,$param); |
|
1399 | + $this->raiseEvent('OnUnload', $this, $param); |
|
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | /** |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | */ |
1409 | 1409 | public function onPreRender($param) |
1410 | 1410 | { |
1411 | - $this->raiseEvent('OnPreRender',$this,$param); |
|
1411 | + $this->raiseEvent('OnPreRender', $this, $param); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | /** |
@@ -1418,12 +1418,12 @@ discard block |
||
1418 | 1418 | * @param TEventParameter event parameter |
1419 | 1419 | * @see bubbleEvent |
1420 | 1420 | */ |
1421 | - protected function raiseBubbleEvent($sender,$param) |
|
1421 | + protected function raiseBubbleEvent($sender, $param) |
|
1422 | 1422 | { |
1423 | - $control=$this; |
|
1424 | - while($control=$control->_parent) |
|
1423 | + $control = $this; |
|
1424 | + while ($control = $control->_parent) |
|
1425 | 1425 | { |
1426 | - if($control->bubbleEvent($sender,$param)) |
|
1426 | + if ($control->bubbleEvent($sender, $param)) |
|
1427 | 1427 | break; |
1428 | 1428 | } |
1429 | 1429 | } |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | * @return boolean true if the event bubbling is handled and no more bubbling. |
1438 | 1438 | * @see raiseBubbleEvent |
1439 | 1439 | */ |
1440 | - public function bubbleEvent($sender,$param) |
|
1440 | + public function bubbleEvent($sender, $param) |
|
1441 | 1441 | { |
1442 | 1442 | return false; |
1443 | 1443 | } |
@@ -1458,10 +1458,10 @@ discard block |
||
1458 | 1458 | * @param TControl sender of this event |
1459 | 1459 | * @param TEventParameter event parameter |
1460 | 1460 | */ |
1461 | - public function broadcastEvent($name,$sender,$param) |
|
1461 | + public function broadcastEvent($name, $sender, $param) |
|
1462 | 1462 | { |
1463 | - $rootControl=(($page=$this->getPage())===null)?$this:$page; |
|
1464 | - $rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param)); |
|
1463 | + $rootControl = (($page = $this->getPage()) === null) ? $this : $page; |
|
1464 | + $rootControl->broadcastEventInternal($name, $sender, new TBroadcastEventParameter($name, $param)); |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | /** |
@@ -1471,18 +1471,18 @@ discard block |
||
1471 | 1471 | * @param TControl sender of the event |
1472 | 1472 | * @param TBroadcastEventParameter event parameter |
1473 | 1473 | */ |
1474 | - private function broadcastEventInternal($name,$sender,$param) |
|
1474 | + private function broadcastEventInternal($name, $sender, $param) |
|
1475 | 1475 | { |
1476 | - if($this->hasEvent($name)) |
|
1477 | - $this->raiseEvent($name,$sender,$param->getParameter()); |
|
1478 | - if($this instanceof IBroadcastEventReceiver) |
|
1479 | - $this->broadcastEventReceived($sender,$param); |
|
1480 | - if($this->getHasControls()) |
|
1476 | + if ($this->hasEvent($name)) |
|
1477 | + $this->raiseEvent($name, $sender, $param->getParameter()); |
|
1478 | + if ($this instanceof IBroadcastEventReceiver) |
|
1479 | + $this->broadcastEventReceived($sender, $param); |
|
1480 | + if ($this->getHasControls()) |
|
1481 | 1481 | { |
1482 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1482 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1483 | 1483 | { |
1484 | - if($control instanceof TControl) |
|
1485 | - $control->broadcastEventInternal($name,$sender,$param); |
|
1484 | + if ($control instanceof TControl) |
|
1485 | + $control->broadcastEventInternal($name, $sender, $param); |
|
1486 | 1486 | } |
1487 | 1487 | } |
1488 | 1488 | } |
@@ -1504,22 +1504,22 @@ discard block |
||
1504 | 1504 | * @param callback callback invoked before traversing child controls. If null, it is ignored. |
1505 | 1505 | * @param callback callback invoked after traversing child controls. If null, it is ignored. |
1506 | 1506 | */ |
1507 | - protected function traverseChildControls($param,$preCallback=null,$postCallback=null) |
|
1507 | + protected function traverseChildControls($param, $preCallback = null, $postCallback = null) |
|
1508 | 1508 | { |
1509 | - if($preCallback!==null) |
|
1510 | - call_user_func($preCallback,$this,$param); |
|
1511 | - if($this->getHasControls()) |
|
1509 | + if ($preCallback !== null) |
|
1510 | + call_user_func($preCallback, $this, $param); |
|
1511 | + if ($this->getHasControls()) |
|
1512 | 1512 | { |
1513 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1513 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1514 | 1514 | { |
1515 | - if($control instanceof TControl) |
|
1515 | + if ($control instanceof TControl) |
|
1516 | 1516 | { |
1517 | - $control->traverseChildControls($param,$preCallback,$postCallback); |
|
1517 | + $control->traverseChildControls($param, $preCallback, $postCallback); |
|
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | } |
1521 | - if($postCallback!==null) |
|
1522 | - call_user_func($postCallback,$this,$param); |
|
1521 | + if ($postCallback !== null) |
|
1522 | + call_user_func($postCallback, $this, $param); |
|
1523 | 1523 | } |
1524 | 1524 | |
1525 | 1525 | /** |
@@ -1529,9 +1529,9 @@ discard block |
||
1529 | 1529 | */ |
1530 | 1530 | public function renderControl($writer) |
1531 | 1531 | { |
1532 | - if($this instanceof IActiveControl || $this->getVisible(false)) |
|
1532 | + if ($this instanceof IActiveControl || $this->getVisible(false)) |
|
1533 | 1533 | { |
1534 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1534 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1535 | 1535 | $this->_rf[self::RF_ADAPTER]->render($writer); |
1536 | 1536 | else |
1537 | 1537 | $this->render($writer); |
@@ -1558,15 +1558,15 @@ discard block |
||
1558 | 1558 | */ |
1559 | 1559 | public function renderChildren($writer) |
1560 | 1560 | { |
1561 | - if($this->getHasControls()) |
|
1561 | + if ($this->getHasControls()) |
|
1562 | 1562 | { |
1563 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1563 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1564 | 1564 | { |
1565 | - if(is_string($control)) |
|
1565 | + if (is_string($control)) |
|
1566 | 1566 | $writer->write($control); |
1567 | - else if($control instanceof TControl) |
|
1567 | + else if ($control instanceof TControl) |
|
1568 | 1568 | $control->renderControl($writer); |
1569 | - else if($control instanceof IRenderable) |
|
1569 | + else if ($control instanceof IRenderable) |
|
1570 | 1570 | $control->render($writer); |
1571 | 1571 | } |
1572 | 1572 | } |
@@ -1596,47 +1596,47 @@ discard block |
||
1596 | 1596 | * @param array the collection of the state |
1597 | 1597 | * @param boolean whether the viewstate should be loaded |
1598 | 1598 | */ |
1599 | - protected function loadStateRecursive(&$state,$needViewState=true) |
|
1599 | + protected function loadStateRecursive(&$state, $needViewState = true) |
|
1600 | 1600 | { |
1601 | - if(is_array($state)) |
|
1601 | + if (is_array($state)) |
|
1602 | 1602 | { |
1603 | 1603 | // A null state means the stateful properties all take default values. |
1604 | 1604 | // So if the state is enabled, we have to assign the null value. |
1605 | - $needViewState=($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
1606 | - if(isset($state[1])) |
|
1605 | + $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
1606 | + if (isset($state[1])) |
|
1607 | 1607 | { |
1608 | - $this->_rf[self::RF_CONTROLSTATE]=&$state[1]; |
|
1608 | + $this->_rf[self::RF_CONTROLSTATE] = &$state[1]; |
|
1609 | 1609 | unset($state[1]); |
1610 | 1610 | } |
1611 | 1611 | else |
1612 | 1612 | unset($this->_rf[self::RF_CONTROLSTATE]); |
1613 | - if($needViewState) |
|
1613 | + if ($needViewState) |
|
1614 | 1614 | { |
1615 | - if(isset($state[0])) |
|
1616 | - $this->_viewState=&$state[0]; |
|
1615 | + if (isset($state[0])) |
|
1616 | + $this->_viewState = &$state[0]; |
|
1617 | 1617 | else |
1618 | - $this->_viewState=array(); |
|
1618 | + $this->_viewState = array(); |
|
1619 | 1619 | } |
1620 | 1620 | unset($state[0]); |
1621 | - if($this->getHasControls()) |
|
1621 | + if ($this->getHasControls()) |
|
1622 | 1622 | { |
1623 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1623 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1624 | 1624 | { |
1625 | - if($control instanceof TControl) |
|
1625 | + if ($control instanceof TControl) |
|
1626 | 1626 | { |
1627 | - if(isset($state[$control->_id])) |
|
1627 | + if (isset($state[$control->_id])) |
|
1628 | 1628 | { |
1629 | - $control->loadStateRecursive($state[$control->_id],$needViewState); |
|
1629 | + $control->loadStateRecursive($state[$control->_id], $needViewState); |
|
1630 | 1630 | unset($state[$control->_id]); |
1631 | 1631 | } |
1632 | 1632 | } |
1633 | 1633 | } |
1634 | 1634 | } |
1635 | - if(!empty($state)) |
|
1636 | - $this->_rf[self::RF_CHILD_STATE]=&$state; |
|
1635 | + if (!empty($state)) |
|
1636 | + $this->_rf[self::RF_CHILD_STATE] = &$state; |
|
1637 | 1637 | } |
1638 | - $this->_stage=self::CS_STATE_LOADED; |
|
1639 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1638 | + $this->_stage = self::CS_STATE_LOADED; |
|
1639 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1640 | 1640 | $this->_rf[self::RF_ADAPTER]->loadState(); |
1641 | 1641 | else |
1642 | 1642 | $this->loadState(); |
@@ -1648,29 +1648,29 @@ discard block |
||
1648 | 1648 | * @param boolean whether the viewstate should be saved |
1649 | 1649 | * @return array the collection of the control state (including its children's state). |
1650 | 1650 | */ |
1651 | - protected function &saveStateRecursive($needViewState=true) |
|
1651 | + protected function &saveStateRecursive($needViewState = true) |
|
1652 | 1652 | { |
1653 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1653 | + if (isset($this->_rf[self::RF_ADAPTER])) |
|
1654 | 1654 | $this->_rf[self::RF_ADAPTER]->saveState(); |
1655 | 1655 | else |
1656 | 1656 | $this->saveState(); |
1657 | - $needViewState=($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
1658 | - $state=array(); |
|
1659 | - if($this->getHasControls()) |
|
1657 | + $needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
|
1658 | + $state = array(); |
|
1659 | + if ($this->getHasControls()) |
|
1660 | 1660 | { |
1661 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1661 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1662 | 1662 | { |
1663 | - if($control instanceof TControl) |
|
1663 | + if ($control instanceof TControl) |
|
1664 | 1664 | { |
1665 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1666 | - $state[$control->_id]=$tmp; |
|
1665 | + if (count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1666 | + $state[$control->_id] = $tmp; |
|
1667 | 1667 | } |
1668 | 1668 | } |
1669 | 1669 | } |
1670 | - if($needViewState && !empty($this->_viewState)) |
|
1671 | - $state[0]=&$this->_viewState; |
|
1672 | - if(isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1673 | - $state[1]=&$this->_rf[self::RF_CONTROLSTATE]; |
|
1670 | + if ($needViewState && !empty($this->_viewState)) |
|
1671 | + $state[0] = &$this->_viewState; |
|
1672 | + if (isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1673 | + $state[1] = &$this->_rf[self::RF_CONTROLSTATE]; |
|
1674 | 1674 | return $state; |
1675 | 1675 | } |
1676 | 1676 | |
@@ -1681,13 +1681,13 @@ discard block |
||
1681 | 1681 | */ |
1682 | 1682 | public function applyStyleSheetSkin($page) |
1683 | 1683 | { |
1684 | - if($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
|
1684 | + if ($page && !($this->_flags & self::IS_STYLESHEET_APPLIED)) |
|
1685 | 1685 | { |
1686 | 1686 | $page->applyControlStyleSheet($this); |
1687 | 1687 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
1688 | 1688 | } |
1689 | - else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1690 | - throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
|
1689 | + else if ($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1690 | + throw new TInvalidOperationException('control_stylesheet_applied', get_class($this)); |
|
1691 | 1691 | } |
1692 | 1692 | |
1693 | 1693 | /** |
@@ -1697,13 +1697,13 @@ discard block |
||
1697 | 1697 | */ |
1698 | 1698 | private function clearCachedUniqueID($recursive) |
1699 | 1699 | { |
1700 | - if($recursive && $this->_uid!==null && isset($this->_rf[self::RF_CONTROLS])) |
|
1700 | + if ($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS])) |
|
1701 | 1701 | { |
1702 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1703 | - if($control instanceof TControl) |
|
1702 | + foreach ($this->_rf[self::RF_CONTROLS] as $control) |
|
1703 | + if ($control instanceof TControl) |
|
1704 | 1704 | $control->clearCachedUniqueID($recursive); |
1705 | 1705 | } |
1706 | - $this->_uid=null; |
|
1706 | + $this->_uid = null; |
|
1707 | 1707 | } |
1708 | 1708 | |
1709 | 1709 | /** |
@@ -1712,10 +1712,10 @@ discard block |
||
1712 | 1712 | private function generateAutomaticID() |
1713 | 1713 | { |
1714 | 1714 | $this->_flags &= ~self::IS_ID_SET; |
1715 | - if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1716 | - $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0; |
|
1717 | - $id=$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
|
1718 | - $this->_id=self::AUTOMATIC_ID_PREFIX . $id; |
|
1715 | + if (!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1716 | + $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0; |
|
1717 | + $id = $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
|
1718 | + $this->_id = self::AUTOMATIC_ID_PREFIX . $id; |
|
1719 | 1719 | $this->_namingContainer->clearNameTable(); |
1720 | 1720 | } |
1721 | 1721 | |
@@ -1733,21 +1733,21 @@ discard block |
||
1733 | 1733 | * @param TControlCollection list of controls |
1734 | 1734 | * @throws TInvalidDataValueException if a control's ID is not unique within its naming container. |
1735 | 1735 | */ |
1736 | - private function fillNameTable($container,$controls) |
|
1736 | + private function fillNameTable($container, $controls) |
|
1737 | 1737 | { |
1738 | - foreach($controls as $control) |
|
1738 | + foreach ($controls as $control) |
|
1739 | 1739 | { |
1740 | - if($control instanceof TControl) |
|
1740 | + if ($control instanceof TControl) |
|
1741 | 1741 | { |
1742 | - if($control->_id!=='') |
|
1742 | + if ($control->_id !== '') |
|
1743 | 1743 | { |
1744 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1745 | - throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id); |
|
1744 | + if (isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1745 | + throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id); |
|
1746 | 1746 | else |
1747 | - $container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control; |
|
1747 | + $container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control; |
|
1748 | 1748 | } |
1749 | - if(!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1750 | - $this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]); |
|
1749 | + if (!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1750 | + $this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]); |
|
1751 | 1751 | } |
1752 | 1752 | } |
1753 | 1753 | } |
@@ -1777,10 +1777,10 @@ discard block |
||
1777 | 1777 | * @param TControl the control that owns this collection. |
1778 | 1778 | * @param boolean whether the list is read-only |
1779 | 1779 | */ |
1780 | - public function __construct(TControl $owner,$readOnly=false) |
|
1780 | + public function __construct(TControl $owner, $readOnly = false) |
|
1781 | 1781 | { |
1782 | - $this->_o=$owner; |
|
1783 | - parent::__construct(null,$readOnly); |
|
1782 | + $this->_o = $owner; |
|
1783 | + parent::__construct(null, $readOnly); |
|
1784 | 1784 | } |
1785 | 1785 | |
1786 | 1786 | /** |
@@ -1799,15 +1799,15 @@ discard block |
||
1799 | 1799 | * @param mixed new item |
1800 | 1800 | * @throws TInvalidDataTypeException if the item to be inserted is neither a string nor a TControl. |
1801 | 1801 | */ |
1802 | - public function insertAt($index,$item) |
|
1802 | + public function insertAt($index, $item) |
|
1803 | 1803 | { |
1804 | - if($item instanceof TControl) |
|
1804 | + if ($item instanceof TControl) |
|
1805 | 1805 | { |
1806 | - parent::insertAt($index,$item); |
|
1806 | + parent::insertAt($index, $item); |
|
1807 | 1807 | $this->_o->addedControl($item); |
1808 | 1808 | } |
1809 | - else if(is_string($item) || ($item instanceof IRenderable)) |
|
1810 | - parent::insertAt($index,$item); |
|
1809 | + else if (is_string($item) || ($item instanceof IRenderable)) |
|
1810 | + parent::insertAt($index, $item); |
|
1811 | 1811 | else |
1812 | 1812 | throw new TInvalidDataTypeException('controlcollection_control_required'); |
1813 | 1813 | } |
@@ -1821,8 +1821,8 @@ discard block |
||
1821 | 1821 | */ |
1822 | 1822 | public function removeAt($index) |
1823 | 1823 | { |
1824 | - $item=parent::removeAt($index); |
|
1825 | - if($item instanceof TControl) |
|
1824 | + $item = parent::removeAt($index); |
|
1825 | + if ($item instanceof TControl) |
|
1826 | 1826 | $this->_o->removedControl($item); |
1827 | 1827 | return $item; |
1828 | 1828 | } |
@@ -1833,7 +1833,7 @@ discard block |
||
1833 | 1833 | public function clear() |
1834 | 1834 | { |
1835 | 1835 | parent::clear(); |
1836 | - if($this->_o instanceof INamingContainer) |
|
1836 | + if ($this->_o instanceof INamingContainer) |
|
1837 | 1837 | $this->_o->clearNamingContainer(); |
1838 | 1838 | } |
1839 | 1839 | } |
@@ -1856,7 +1856,7 @@ discard block |
||
1856 | 1856 | */ |
1857 | 1857 | public function __construct(TControl $owner) |
1858 | 1858 | { |
1859 | - parent::__construct($owner,true); |
|
1859 | + parent::__construct($owner, true); |
|
1860 | 1860 | } |
1861 | 1861 | |
1862 | 1862 | /** |
@@ -1865,10 +1865,10 @@ discard block |
||
1865 | 1865 | * @param integer the speicified position. |
1866 | 1866 | * @param mixed new item |
1867 | 1867 | */ |
1868 | - public function insertAt($index,$item) |
|
1868 | + public function insertAt($index, $item) |
|
1869 | 1869 | { |
1870 | - if(!is_string($item)) // string is possible if property tag is used. we simply ignore it in this case |
|
1871 | - parent::insertAt($index,$item); // this will generate an exception in parent implementation |
|
1870 | + if (!is_string($item)) // string is possible if property tag is used. we simply ignore it in this case |
|
1871 | + parent::insertAt($index, $item); // this will generate an exception in parent implementation |
|
1872 | 1872 | } |
1873 | 1873 | } |
1874 | 1874 | |
@@ -1923,7 +1923,7 @@ discard block |
||
1923 | 1923 | * @param array the input data collection |
1924 | 1924 | * @return boolean whether the data of the control has been changed |
1925 | 1925 | */ |
1926 | - public function loadPostData($key,$values); |
|
1926 | + public function loadPostData($key, $values); |
|
1927 | 1927 | /** |
1928 | 1928 | * Raises postdata changed event. |
1929 | 1929 | * The implementation of this function should raise appropriate event(s) (e.g. OnTextChanged) |
@@ -2019,7 +2019,7 @@ discard block |
||
2019 | 2019 | * @param TControl sender of the event |
2020 | 2020 | * @param TBroadCastEventParameter event parameter |
2021 | 2021 | */ |
2022 | - public function broadcastEventReceived($sender,$param); |
|
2022 | + public function broadcastEventReceived($sender, $param); |
|
2023 | 2023 | } |
2024 | 2024 | |
2025 | 2025 | /** |
@@ -2192,10 +2192,10 @@ discard block |
||
2192 | 2192 | * @param string name of the broadcast event |
2193 | 2193 | * @param mixed parameter of the broadcast event |
2194 | 2194 | */ |
2195 | - public function __construct($name='',$parameter=null) |
|
2195 | + public function __construct($name = '', $parameter = null) |
|
2196 | 2196 | { |
2197 | - $this->_name=$name; |
|
2198 | - $this->_param=$parameter; |
|
2197 | + $this->_name = $name; |
|
2198 | + $this->_param = $parameter; |
|
2199 | 2199 | } |
2200 | 2200 | |
2201 | 2201 | /** |
@@ -2211,7 +2211,7 @@ discard block |
||
2211 | 2211 | */ |
2212 | 2212 | public function setName($value) |
2213 | 2213 | { |
2214 | - $this->_name=$value; |
|
2214 | + $this->_name = $value; |
|
2215 | 2215 | } |
2216 | 2216 | |
2217 | 2217 | /** |
@@ -2227,7 +2227,7 @@ discard block |
||
2227 | 2227 | */ |
2228 | 2228 | public function setParameter($value) |
2229 | 2229 | { |
2230 | - $this->_param=$value; |
|
2230 | + $this->_param = $value; |
|
2231 | 2231 | } |
2232 | 2232 | } |
2233 | 2233 | |
@@ -2253,10 +2253,10 @@ discard block |
||
2253 | 2253 | * @param string name of the command |
2254 | 2254 | * @param string parameter of the command |
2255 | 2255 | */ |
2256 | - public function __construct($name='',$parameter='') |
|
2256 | + public function __construct($name = '', $parameter = '') |
|
2257 | 2257 | { |
2258 | - $this->_name=$name; |
|
2259 | - $this->_param=$parameter; |
|
2258 | + $this->_name = $name; |
|
2259 | + $this->_param = $parameter; |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | 2262 | /** |
@@ -2289,14 +2289,14 @@ discard block |
||
2289 | 2289 | */ |
2290 | 2290 | class TCompositeLiteral extends TComponent implements IRenderable, IBindable |
2291 | 2291 | { |
2292 | - const TYPE_EXPRESSION=0; |
|
2293 | - const TYPE_STATEMENTS=1; |
|
2294 | - const TYPE_DATABINDING=2; |
|
2295 | - private $_container=null; |
|
2296 | - private $_items=array(); |
|
2297 | - private $_expressions=array(); |
|
2298 | - private $_statements=array(); |
|
2299 | - private $_bindings=array(); |
|
2292 | + const TYPE_EXPRESSION = 0; |
|
2293 | + const TYPE_STATEMENTS = 1; |
|
2294 | + const TYPE_DATABINDING = 2; |
|
2295 | + private $_container = null; |
|
2296 | + private $_items = array(); |
|
2297 | + private $_expressions = array(); |
|
2298 | + private $_statements = array(); |
|
2299 | + private $_bindings = array(); |
|
2300 | 2300 | |
2301 | 2301 | /** |
2302 | 2302 | * Constructor. |
@@ -2304,23 +2304,23 @@ discard block |
||
2304 | 2304 | */ |
2305 | 2305 | public function __construct($items) |
2306 | 2306 | { |
2307 | - $this->_items=array(); |
|
2308 | - $this->_expressions=array(); |
|
2309 | - $this->_statements=array(); |
|
2310 | - foreach($items as $id=>$item) |
|
2307 | + $this->_items = array(); |
|
2308 | + $this->_expressions = array(); |
|
2309 | + $this->_statements = array(); |
|
2310 | + foreach ($items as $id=>$item) |
|
2311 | 2311 | { |
2312 | - if(is_array($item)) |
|
2312 | + if (is_array($item)) |
|
2313 | 2313 | { |
2314 | - if($item[0]===self::TYPE_EXPRESSION) |
|
2315 | - $this->_expressions[$id]=$item[1]; |
|
2316 | - else if($item[0]===self::TYPE_STATEMENTS) |
|
2317 | - $this->_statements[$id]=$item[1]; |
|
2318 | - else if($item[0]===self::TYPE_DATABINDING) |
|
2319 | - $this->_bindings[$id]=$item[1]; |
|
2320 | - $this->_items[$id]=''; |
|
2314 | + if ($item[0] === self::TYPE_EXPRESSION) |
|
2315 | + $this->_expressions[$id] = $item[1]; |
|
2316 | + else if ($item[0] === self::TYPE_STATEMENTS) |
|
2317 | + $this->_statements[$id] = $item[1]; |
|
2318 | + else if ($item[0] === self::TYPE_DATABINDING) |
|
2319 | + $this->_bindings[$id] = $item[1]; |
|
2320 | + $this->_items[$id] = ''; |
|
2321 | 2321 | } |
2322 | 2322 | else |
2323 | - $this->_items[$id]=$item; |
|
2323 | + $this->_items[$id] = $item; |
|
2324 | 2324 | } |
2325 | 2325 | } |
2326 | 2326 | |
@@ -2337,7 +2337,7 @@ discard block |
||
2337 | 2337 | */ |
2338 | 2338 | public function setContainer(TComponent $value) |
2339 | 2339 | { |
2340 | - $this->_container=$value; |
|
2340 | + $this->_container = $value; |
|
2341 | 2341 | } |
2342 | 2342 | |
2343 | 2343 | /** |
@@ -2345,11 +2345,11 @@ discard block |
||
2345 | 2345 | */ |
2346 | 2346 | public function evaluateDynamicContent() |
2347 | 2347 | { |
2348 | - $context=$this->_container===null?$this:$this->_container; |
|
2349 | - foreach($this->_expressions as $id=>$expression) |
|
2350 | - $this->_items[$id]=$context->evaluateExpression($expression); |
|
2351 | - foreach($this->_statements as $id=>$statement) |
|
2352 | - $this->_items[$id]=$context->evaluateStatements($statement); |
|
2348 | + $context = $this->_container === null ? $this : $this->_container; |
|
2349 | + foreach ($this->_expressions as $id=>$expression) |
|
2350 | + $this->_items[$id] = $context->evaluateExpression($expression); |
|
2351 | + foreach ($this->_statements as $id=>$statement) |
|
2352 | + $this->_items[$id] = $context->evaluateStatements($statement); |
|
2353 | 2353 | } |
2354 | 2354 | |
2355 | 2355 | /** |
@@ -2358,9 +2358,9 @@ discard block |
||
2358 | 2358 | */ |
2359 | 2359 | public function dataBind() |
2360 | 2360 | { |
2361 | - $context=$this->_container===null?$this:$this->_container; |
|
2362 | - foreach($this->_bindings as $id=>$binding) |
|
2363 | - $this->_items[$id]=$context->evaluateExpression($binding); |
|
2361 | + $context = $this->_container === null ? $this : $this->_container; |
|
2362 | + foreach ($this->_bindings as $id=>$binding) |
|
2363 | + $this->_items[$id] = $context->evaluateExpression($binding); |
|
2364 | 2364 | } |
2365 | 2365 | |
2366 | 2366 | /** |
@@ -2370,7 +2370,7 @@ discard block |
||
2370 | 2370 | */ |
2371 | 2371 | public function render($writer) |
2372 | 2372 | { |
2373 | - $writer->write(implode('',$this->_items)); |
|
2373 | + $writer->write(implode('', $this->_items)); |
|
2374 | 2374 | } |
2375 | 2375 | } |
2376 | 2376 |
@@ -189,10 +189,11 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function __get($name) |
191 | 191 | { |
192 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
193 | - return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
|
194 | - else |
|
195 | - return parent::__get($name); |
|
192 | + if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
193 | + return $this->_rf[self::RF_NAMED_OBJECTS][$name]; |
|
194 | + } else { |
|
195 | + return parent::__get($name); |
|
196 | + } |
|
196 | 197 | } |
197 | 198 | |
198 | 199 | /** |
@@ -234,10 +235,11 @@ discard block |
||
234 | 235 | { |
235 | 236 | if(!$this->_namingContainer && $this->_parent) |
236 | 237 | { |
237 | - if($this->_parent instanceof INamingContainer) |
|
238 | - $this->_namingContainer=$this->_parent; |
|
239 | - else |
|
240 | - $this->_namingContainer=$this->_parent->getNamingContainer(); |
|
238 | + if($this->_parent instanceof INamingContainer) { |
|
239 | + $this->_namingContainer=$this->_parent; |
|
240 | + } else { |
|
241 | + $this->_namingContainer=$this->_parent->getNamingContainer(); |
|
242 | + } |
|
241 | 243 | } |
242 | 244 | return $this->_namingContainer; |
243 | 245 | } |
@@ -249,10 +251,11 @@ discard block |
||
249 | 251 | { |
250 | 252 | if(!$this->_page) |
251 | 253 | { |
252 | - if($this->_parent) |
|
253 | - $this->_page=$this->_parent->getPage(); |
|
254 | - else if($this->_tplControl) |
|
255 | - $this->_page=$this->_tplControl->getPage(); |
|
254 | + if($this->_parent) { |
|
255 | + $this->_page=$this->_parent->getPage(); |
|
256 | + } else if($this->_tplControl) { |
|
257 | + $this->_page=$this->_tplControl->getPage(); |
|
258 | + } |
|
256 | 259 | } |
257 | 260 | return $this->_page; |
258 | 261 | } |
@@ -282,8 +285,9 @@ discard block |
||
282 | 285 | */ |
283 | 286 | public function getTemplateControl() |
284 | 287 | { |
285 | - if(!$this->_tplControl && $this->_parent) |
|
286 | - $this->_tplControl=$this->_parent->getTemplateControl(); |
|
288 | + if(!$this->_tplControl && $this->_parent) { |
|
289 | + $this->_tplControl=$this->_parent->getTemplateControl(); |
|
290 | + } |
|
287 | 291 | return $this->_tplControl; |
288 | 292 | } |
289 | 293 | |
@@ -297,8 +301,9 @@ discard block |
||
297 | 301 | $control=$this; |
298 | 302 | while(($control instanceof TControl) && ($control=$control->getTemplateControl())!==null) |
299 | 303 | { |
300 | - if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) |
|
301 | - return $control; |
|
304 | + if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) { |
|
305 | + return $control; |
|
306 | + } |
|
302 | 307 | } |
303 | 308 | return $this->getPage(); |
304 | 309 | } |
@@ -336,10 +341,11 @@ discard block |
||
336 | 341 | */ |
337 | 342 | public function getID($hideAutoID=true) |
338 | 343 | { |
339 | - if($hideAutoID) |
|
340 | - return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
|
341 | - else |
|
342 | - return $this->_id; |
|
344 | + if($hideAutoID) { |
|
345 | + return ($this->_flags & self::IS_ID_SET) ? $this->_id : ''; |
|
346 | + } else { |
|
347 | + return $this->_id; |
|
348 | + } |
|
343 | 349 | } |
344 | 350 | |
345 | 351 | /** |
@@ -348,13 +354,15 @@ discard block |
||
348 | 354 | */ |
349 | 355 | public function setID($id) |
350 | 356 | { |
351 | - if(!preg_match(self::ID_FORMAT,$id)) |
|
352 | - throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id); |
|
357 | + if(!preg_match(self::ID_FORMAT,$id)) { |
|
358 | + throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id); |
|
359 | + } |
|
353 | 360 | $this->_id=$id; |
354 | 361 | $this->_flags |= self::IS_ID_SET; |
355 | 362 | $this->clearCachedUniqueID($this instanceof INamingContainer); |
356 | - if($this->_namingContainer) |
|
357 | - $this->_namingContainer->clearNameTable(); |
|
363 | + if($this->_namingContainer) { |
|
364 | + $this->_namingContainer->clearNameTable(); |
|
365 | + } |
|
358 | 366 | } |
359 | 367 | |
360 | 368 | /** |
@@ -366,23 +374,28 @@ discard block |
||
366 | 374 | */ |
367 | 375 | public function getUniqueID() |
368 | 376 | { |
369 | - if($this->_uid==='' || $this->_uid===null) // need to build the UniqueID |
|
377 | + if($this->_uid==='' || $this->_uid===null) { |
|
378 | + // need to build the UniqueID |
|
370 | 379 | { |
371 | - $this->_uid=''; // set to not-null, so that clearCachedUniqueID() may take action |
|
380 | + $this->_uid=''; |
|
381 | + } |
|
382 | + // set to not-null, so that clearCachedUniqueID() may take action |
|
372 | 383 | if($namingContainer=$this->getNamingContainer()) |
373 | 384 | { |
374 | - if($this->getPage()===$namingContainer) |
|
375 | - return ($this->_uid=$this->_id); |
|
376 | - else if(($prefix=$namingContainer->getUniqueID())==='') |
|
377 | - return $this->_id; |
|
378 | - else |
|
379 | - return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id); |
|
380 | - } |
|
381 | - else // no naming container |
|
385 | + if($this->getPage()===$namingContainer) { |
|
386 | + return ($this->_uid=$this->_id); |
|
387 | + } else if(($prefix=$namingContainer->getUniqueID())==='') { |
|
388 | + return $this->_id; |
|
389 | + } else { |
|
390 | + return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id); |
|
391 | + } |
|
392 | + } else { |
|
393 | + // no naming container |
|
382 | 394 | return $this->_id; |
395 | + } |
|
396 | + } else { |
|
397 | + return $this->_uid; |
|
383 | 398 | } |
384 | - else |
|
385 | - return $this->_uid; |
|
386 | 399 | } |
387 | 400 | |
388 | 401 | /** |
@@ -429,10 +442,11 @@ discard block |
||
429 | 442 | */ |
430 | 443 | public function setSkinID($value) |
431 | 444 | { |
432 | - if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED) |
|
433 | - throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this)); |
|
434 | - else |
|
435 | - $this->_rf[self::RF_SKIN_ID]=$value; |
|
445 | + if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED) { |
|
446 | + throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this)); |
|
447 | + } else { |
|
448 | + $this->_rf[self::RF_SKIN_ID]=$value; |
|
449 | + } |
|
436 | 450 | } |
437 | 451 | |
438 | 452 | /** |
@@ -450,10 +464,11 @@ discard block |
||
450 | 464 | */ |
451 | 465 | public function getEnableTheming() |
452 | 466 | { |
453 | - if($this->_flags & self::IS_DISABLE_THEMING) |
|
454 | - return false; |
|
455 | - else |
|
456 | - return $this->_parent?$this->_parent->getEnableTheming():true; |
|
467 | + if($this->_flags & self::IS_DISABLE_THEMING) { |
|
468 | + return false; |
|
469 | + } else { |
|
470 | + return $this->_parent?$this->_parent->getEnableTheming():true; |
|
471 | + } |
|
457 | 472 | } |
458 | 473 | |
459 | 474 | /** |
@@ -462,12 +477,13 @@ discard block |
||
462 | 477 | */ |
463 | 478 | public function setEnableTheming($value) |
464 | 479 | { |
465 | - if($this->_stage>=self::CS_CHILD_INITIALIZED) |
|
466 | - throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID()); |
|
467 | - else if(TPropertyValue::ensureBoolean($value)) |
|
468 | - $this->_flags &= ~self::IS_DISABLE_THEMING; |
|
469 | - else |
|
470 | - $this->_flags |= self::IS_DISABLE_THEMING; |
|
480 | + if($this->_stage>=self::CS_CHILD_INITIALIZED) { |
|
481 | + throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID()); |
|
482 | + } else if(TPropertyValue::ensureBoolean($value)) { |
|
483 | + $this->_flags &= ~self::IS_DISABLE_THEMING; |
|
484 | + } else { |
|
485 | + $this->_flags |= self::IS_DISABLE_THEMING; |
|
486 | + } |
|
471 | 487 | } |
472 | 488 | |
473 | 489 | /** |
@@ -505,8 +521,9 @@ discard block |
||
505 | 521 | */ |
506 | 522 | public function getControls() |
507 | 523 | { |
508 | - if(!isset($this->_rf[self::RF_CONTROLS])) |
|
509 | - $this->_rf[self::RF_CONTROLS]=$this->createControlCollection(); |
|
524 | + if(!isset($this->_rf[self::RF_CONTROLS])) { |
|
525 | + $this->_rf[self::RF_CONTROLS]=$this->createControlCollection(); |
|
526 | + } |
|
510 | 527 | return $this->_rf[self::RF_CONTROLS]; |
511 | 528 | } |
512 | 529 | |
@@ -531,13 +548,14 @@ discard block |
||
531 | 548 | { |
532 | 549 | if($checkParents) |
533 | 550 | { |
534 | - for($control=$this;$control;$control=$control->_parent) |
|
535 | - if(!$control->getVisible(false)) |
|
551 | + for($control=$this;$control;$control=$control->_parent) { |
|
552 | + if(!$control->getVisible(false)) |
|
536 | 553 | return false; |
554 | + } |
|
537 | 555 | return true; |
556 | + } else { |
|
557 | + return $this->getViewState('Visible',true); |
|
538 | 558 | } |
539 | - else |
|
540 | - return $this->getViewState('Visible',true); |
|
541 | 559 | } |
542 | 560 | |
543 | 561 | /** |
@@ -562,13 +580,14 @@ discard block |
||
562 | 580 | { |
563 | 581 | if($checkParents) |
564 | 582 | { |
565 | - for($control=$this;$control;$control=$control->_parent) |
|
566 | - if(!$control->getViewState('Enabled',true)) |
|
583 | + for($control=$this;$control;$control=$control->_parent) { |
|
584 | + if(!$control->getViewState('Enabled',true)) |
|
567 | 585 | return false; |
586 | + } |
|
568 | 587 | return true; |
588 | + } else { |
|
589 | + return $this->getViewState('Enabled',true); |
|
569 | 590 | } |
570 | - else |
|
571 | - return $this->getViewState('Enabled',true); |
|
572 | 591 | } |
573 | 592 | |
574 | 593 | /** |
@@ -584,10 +603,11 @@ discard block |
||
584 | 603 | */ |
585 | 604 | public function getHasAttributes() |
586 | 605 | { |
587 | - if($attributes=$this->getViewState('Attributes',null)) |
|
588 | - return $attributes->getCount()>0; |
|
589 | - else |
|
590 | - return false; |
|
606 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
607 | + return $attributes->getCount()>0; |
|
608 | + } else { |
|
609 | + return false; |
|
610 | + } |
|
591 | 611 | } |
592 | 612 | |
593 | 613 | /** |
@@ -598,9 +618,9 @@ discard block |
||
598 | 618 | */ |
599 | 619 | public function getAttributes() |
600 | 620 | { |
601 | - if($attributes=$this->getViewState('Attributes',null)) |
|
602 | - return $attributes; |
|
603 | - else |
|
621 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
622 | + return $attributes; |
|
623 | + } else |
|
604 | 624 | { |
605 | 625 | $attributes=new TAttributeCollection; |
606 | 626 | $this->setViewState('Attributes',$attributes,null); |
@@ -613,10 +633,11 @@ discard block |
||
613 | 633 | */ |
614 | 634 | public function hasAttribute($name) |
615 | 635 | { |
616 | - if($attributes=$this->getViewState('Attributes',null)) |
|
617 | - return $attributes->contains($name); |
|
618 | - else |
|
619 | - return false; |
|
636 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
637 | + return $attributes->contains($name); |
|
638 | + } else { |
|
639 | + return false; |
|
640 | + } |
|
620 | 641 | } |
621 | 642 | |
622 | 643 | /** |
@@ -624,10 +645,11 @@ discard block |
||
624 | 645 | */ |
625 | 646 | public function getAttribute($name) |
626 | 647 | { |
627 | - if($attributes=$this->getViewState('Attributes',null)) |
|
628 | - return $attributes->itemAt($name); |
|
629 | - else |
|
630 | - return null; |
|
648 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
649 | + return $attributes->itemAt($name); |
|
650 | + } else { |
|
651 | + return null; |
|
652 | + } |
|
631 | 653 | } |
632 | 654 | |
633 | 655 | /** |
@@ -647,10 +669,11 @@ discard block |
||
647 | 669 | */ |
648 | 670 | public function removeAttribute($name) |
649 | 671 | { |
650 | - if($attributes=$this->getViewState('Attributes',null)) |
|
651 | - return $attributes->remove($name); |
|
652 | - else |
|
653 | - return null; |
|
672 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
673 | + return $attributes->remove($name); |
|
674 | + } else { |
|
675 | + return null; |
|
676 | + } |
|
654 | 677 | } |
655 | 678 | |
656 | 679 | /** |
@@ -660,13 +683,14 @@ discard block |
||
660 | 683 | { |
661 | 684 | if($checkParents) |
662 | 685 | { |
663 | - for($control=$this;$control!==null;$control=$control->getParent()) |
|
664 | - if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
686 | + for($control=$this;$control!==null;$control=$control->getParent()) { |
|
687 | + if($control->_flags & self::IS_DISABLE_VIEWSTATE) |
|
665 | 688 | return false; |
689 | + } |
|
666 | 690 | return true; |
691 | + } else { |
|
692 | + return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
|
667 | 693 | } |
668 | - else |
|
669 | - return !($this->_flags & self::IS_DISABLE_VIEWSTATE); |
|
670 | 694 | } |
671 | 695 | |
672 | 696 | /** |
@@ -674,10 +698,11 @@ discard block |
||
674 | 698 | */ |
675 | 699 | public function setEnableViewState($value) |
676 | 700 | { |
677 | - if(TPropertyValue::ensureBoolean($value)) |
|
678 | - $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
|
679 | - else |
|
680 | - $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
|
701 | + if(TPropertyValue::ensureBoolean($value)) { |
|
702 | + $this->_flags &= ~self::IS_DISABLE_VIEWSTATE; |
|
703 | + } else { |
|
704 | + $this->_flags |= self::IS_DISABLE_VIEWSTATE; |
|
705 | + } |
|
681 | 706 | } |
682 | 707 | |
683 | 708 | /** |
@@ -706,10 +731,11 @@ discard block |
||
706 | 731 | */ |
707 | 732 | protected function setControlState($key,$value,$defaultValue=null) |
708 | 733 | { |
709 | - if($value===$defaultValue) |
|
710 | - unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
|
711 | - else |
|
712 | - $this->_rf[self::RF_CONTROLSTATE][$key]=$value; |
|
734 | + if($value===$defaultValue) { |
|
735 | + unset($this->_rf[self::RF_CONTROLSTATE][$key]); |
|
736 | + } else { |
|
737 | + $this->_rf[self::RF_CONTROLSTATE][$key]=$value; |
|
738 | + } |
|
713 | 739 | } |
714 | 740 | |
715 | 741 | /** |
@@ -743,16 +769,17 @@ discard block |
||
743 | 769 | */ |
744 | 770 | public function getViewState($key,$defaultValue=null) |
745 | 771 | { |
746 | - if(isset($this->_viewState[$key])) |
|
747 | - return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue; |
|
748 | - else if(isset($this->_tempState[$key])) |
|
772 | + if(isset($this->_viewState[$key])) { |
|
773 | + return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue; |
|
774 | + } else if(isset($this->_tempState[$key])) |
|
749 | 775 | { |
750 | - if(is_object($this->_tempState[$key]) && $this->_trackViewState) |
|
751 | - $this->_viewState[$key]=$this->_tempState[$key]; |
|
776 | + if(is_object($this->_tempState[$key]) && $this->_trackViewState) { |
|
777 | + $this->_viewState[$key]=$this->_tempState[$key]; |
|
778 | + } |
|
752 | 779 | return $this->_tempState[$key]; |
780 | + } else { |
|
781 | + return $defaultValue; |
|
753 | 782 | } |
754 | - else |
|
755 | - return $defaultValue; |
|
756 | 783 | } |
757 | 784 | |
758 | 785 | /** |
@@ -770,18 +797,19 @@ discard block |
||
770 | 797 | if($this->_trackViewState) |
771 | 798 | { |
772 | 799 | unset($this->_tempState[$key]); |
773 | - if($value===$defaultValue) |
|
774 | - unset($this->_viewState[$key]); |
|
775 | - else |
|
776 | - $this->_viewState[$key]=$value; |
|
777 | - } |
|
778 | - else |
|
800 | + if($value===$defaultValue) { |
|
801 | + unset($this->_viewState[$key]); |
|
802 | + } else { |
|
803 | + $this->_viewState[$key]=$value; |
|
804 | + } |
|
805 | + } else |
|
779 | 806 | { |
780 | 807 | unset($this->_viewState[$key]); |
781 | - if($value===$defaultValue) |
|
782 | - unset($this->_tempState[$key]); |
|
783 | - else |
|
784 | - $this->_tempState[$key]=$value; |
|
808 | + if($value===$defaultValue) { |
|
809 | + unset($this->_tempState[$key]); |
|
810 | + } else { |
|
811 | + $this->_tempState[$key]=$value; |
|
812 | + } |
|
785 | 813 | } |
786 | 814 | } |
787 | 815 | |
@@ -846,10 +874,12 @@ discard block |
||
846 | 874 | Prado::trace("Data bind properties",'System.Web.UI.TControl'); |
847 | 875 | if(isset($this->_rf[self::RF_DATA_BINDINGS])) |
848 | 876 | { |
849 | - if(($context=$this->getTemplateControl())===null) |
|
850 | - $context=$this; |
|
851 | - foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) |
|
852 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
877 | + if(($context=$this->getTemplateControl())===null) { |
|
878 | + $context=$this; |
|
879 | + } |
|
880 | + foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) { |
|
881 | + $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
882 | + } |
|
853 | 883 | } |
854 | 884 | } |
855 | 885 | |
@@ -860,10 +890,12 @@ discard block |
||
860 | 890 | { |
861 | 891 | if(isset($this->_rf[self::RF_AUTO_BINDINGS])) |
862 | 892 | { |
863 | - if(($context=$this->getTemplateControl())===null) |
|
864 | - $context=$this; |
|
865 | - foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) |
|
866 | - $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
893 | + if(($context=$this->getTemplateControl())===null) { |
|
894 | + $context=$this; |
|
895 | + } |
|
896 | + foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) { |
|
897 | + $this->setSubProperty($property,$context->evaluateExpression($expression)); |
|
898 | + } |
|
867 | 899 | } |
868 | 900 | } |
869 | 901 | |
@@ -875,9 +907,10 @@ discard block |
||
875 | 907 | Prado::trace("dataBindChildren()",'System.Web.UI.TControl'); |
876 | 908 | if(isset($this->_rf[self::RF_CONTROLS])) |
877 | 909 | { |
878 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
879 | - if($control instanceof IBindable) |
|
910 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
911 | + if($control instanceof IBindable) |
|
880 | 912 | $control->dataBind(); |
913 | + } |
|
881 | 914 | } |
882 | 915 | } |
883 | 916 | |
@@ -896,12 +929,13 @@ discard block |
||
896 | 929 | */ |
897 | 930 | final protected function setChildControlsCreated($value) |
898 | 931 | { |
899 | - if($value) |
|
900 | - $this->_flags |= self::IS_CHILD_CREATED; |
|
901 | - else |
|
932 | + if($value) { |
|
933 | + $this->_flags |= self::IS_CHILD_CREATED; |
|
934 | + } else |
|
902 | 935 | { |
903 | - if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) |
|
904 | - $this->getControls()->clear(); |
|
936 | + if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) { |
|
937 | + $this->getControls()->clear(); |
|
938 | + } |
|
905 | 939 | $this->_flags &= ~self::IS_CHILD_CREATED; |
906 | 940 | } |
907 | 941 | } |
@@ -918,14 +952,14 @@ discard block |
||
918 | 952 | try |
919 | 953 | { |
920 | 954 | $this->_flags |= self::IS_CREATING_CHILD; |
921 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
922 | - $this->_rf[self::RF_ADAPTER]->createChildControls(); |
|
923 | - else |
|
924 | - $this->createChildControls(); |
|
955 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
956 | + $this->_rf[self::RF_ADAPTER]->createChildControls(); |
|
957 | + } else { |
|
958 | + $this->createChildControls(); |
|
959 | + } |
|
925 | 960 | $this->_flags &= ~self::IS_CREATING_CHILD; |
926 | 961 | $this->_flags |= self::IS_CHILD_CREATED; |
927 | - } |
|
928 | - catch(Exception $e) |
|
962 | + } catch(Exception $e) |
|
929 | 963 | { |
930 | 964 | $this->_flags &= ~self::IS_CREATING_CHILD; |
931 | 965 | $this->_flags |= self::IS_CHILD_CREATED; |
@@ -959,23 +993,25 @@ discard block |
||
959 | 993 | { |
960 | 994 | $id=strtr($id,'.',self::ID_SEPARATOR); |
961 | 995 | $container=($this instanceof INamingContainer)?$this:$this->getNamingContainer(); |
962 | - if(!$container || !$container->getHasControls()) |
|
963 | - return null; |
|
996 | + if(!$container || !$container->getHasControls()) { |
|
997 | + return null; |
|
998 | + } |
|
964 | 999 | if(!isset($container->_rf[self::RF_NAMED_CONTROLS])) |
965 | 1000 | { |
966 | 1001 | $container->_rf[self::RF_NAMED_CONTROLS]=array(); |
967 | 1002 | $container->fillNameTable($container,$container->_rf[self::RF_CONTROLS]); |
968 | 1003 | } |
969 | - if(($pos=strpos($id,self::ID_SEPARATOR))===false) |
|
970 | - return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
971 | - else |
|
1004 | + if(($pos=strpos($id,self::ID_SEPARATOR))===false) { |
|
1005 | + return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null; |
|
1006 | + } else |
|
972 | 1007 | { |
973 | 1008 | $cid=substr($id,0,$pos); |
974 | 1009 | $sid=substr($id,$pos+1); |
975 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) |
|
976 | - return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
|
977 | - else |
|
978 | - return null; |
|
1010 | + if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) { |
|
1011 | + return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid); |
|
1012 | + } else { |
|
1013 | + return null; |
|
1014 | + } |
|
979 | 1015 | } |
980 | 1016 | } |
981 | 1017 | |
@@ -992,10 +1028,12 @@ discard block |
||
992 | 1028 | { |
993 | 1029 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
994 | 1030 | { |
995 | - if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type)))) |
|
996 | - $controls[]=$control; |
|
997 | - if(($control instanceof TControl) && $control->getHasControls()) |
|
998 | - $controls=array_merge($controls,$control->findControlsByType($type,$strict)); |
|
1031 | + if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type)))) { |
|
1032 | + $controls[]=$control; |
|
1033 | + } |
|
1034 | + if(($control instanceof TControl) && $control->getHasControls()) { |
|
1035 | + $controls=array_merge($controls,$control->findControlsByType($type,$strict)); |
|
1036 | + } |
|
999 | 1037 | } |
1000 | 1038 | } |
1001 | 1039 | return $controls; |
@@ -1019,8 +1057,9 @@ discard block |
||
1019 | 1057 | { |
1020 | 1058 | if($control instanceof TControl) |
1021 | 1059 | { |
1022 | - if($control->_id===$id) |
|
1023 | - $controls[]=$control; |
|
1060 | + if($control->_id===$id) { |
|
1061 | + $controls[]=$control; |
|
1062 | + } |
|
1024 | 1063 | $controls=array_merge($controls,$control->findControlsByID($id)); |
1025 | 1064 | } |
1026 | 1065 | } |
@@ -1048,8 +1087,9 @@ discard block |
||
1048 | 1087 | */ |
1049 | 1088 | public function registerObject($name,$object) |
1050 | 1089 | { |
1051 | - if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) |
|
1052 | - throw new TInvalidOperationException('control_object_reregistered',$name); |
|
1090 | + if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) { |
|
1091 | + throw new TInvalidOperationException('control_object_reregistered',$name); |
|
1092 | + } |
|
1053 | 1093 | $this->_rf[self::RF_NAMED_OBJECTS][$name]=$object; |
1054 | 1094 | } |
1055 | 1095 | |
@@ -1164,8 +1204,9 @@ discard block |
||
1164 | 1204 | final protected function isDescendentOf($ancestor) |
1165 | 1205 | { |
1166 | 1206 | $control=$this; |
1167 | - while($control!==$ancestor && $control->_parent) |
|
1168 | - $control=$control->_parent; |
|
1207 | + while($control!==$ancestor && $control->_parent) { |
|
1208 | + $control=$control->_parent; |
|
1209 | + } |
|
1169 | 1210 | return $control===$ancestor; |
1170 | 1211 | } |
1171 | 1212 | |
@@ -1177,18 +1218,20 @@ discard block |
||
1177 | 1218 | */ |
1178 | 1219 | public function addedControl($control) |
1179 | 1220 | { |
1180 | - if($control->_parent) |
|
1181 | - $control->_parent->getControls()->remove($control); |
|
1221 | + if($control->_parent) { |
|
1222 | + $control->_parent->getControls()->remove($control); |
|
1223 | + } |
|
1182 | 1224 | $control->_parent=$this; |
1183 | 1225 | $control->_page=$this->getPage(); |
1184 | 1226 | $namingContainer=($this instanceof INamingContainer)?$this:$this->_namingContainer; |
1185 | 1227 | if($namingContainer) |
1186 | 1228 | { |
1187 | 1229 | $control->_namingContainer=$namingContainer; |
1188 | - if($control->_id==='') |
|
1189 | - $control->generateAutomaticID(); |
|
1190 | - else |
|
1191 | - $namingContainer->clearNameTable(); |
|
1230 | + if($control->_id==='') { |
|
1231 | + $control->generateAutomaticID(); |
|
1232 | + } else { |
|
1233 | + $namingContainer->clearNameTable(); |
|
1234 | + } |
|
1192 | 1235 | $control->clearCachedUniqueID($control instanceof INamingContainer); |
1193 | 1236 | } |
1194 | 1237 | |
@@ -1201,15 +1244,16 @@ discard block |
||
1201 | 1244 | { |
1202 | 1245 | $state=$this->_rf[self::RF_CHILD_STATE][$control->_id]; |
1203 | 1246 | unset($this->_rf[self::RF_CHILD_STATE][$control->_id]); |
1247 | + } else { |
|
1248 | + $state=null; |
|
1204 | 1249 | } |
1205 | - else |
|
1206 | - $state=null; |
|
1207 | 1250 | $control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1208 | 1251 | if($this->_stage>=self::CS_LOADED) |
1209 | 1252 | { |
1210 | 1253 | $control->loadRecursive(); |
1211 | - if($this->_stage>=self::CS_PRERENDERED) |
|
1212 | - $control->preRenderRecursive(); |
|
1254 | + if($this->_stage>=self::CS_PRERENDERED) { |
|
1255 | + $control->preRenderRecursive(); |
|
1256 | + } |
|
1213 | 1257 | } |
1214 | 1258 | } |
1215 | 1259 | } |
@@ -1222,18 +1266,20 @@ discard block |
||
1222 | 1266 | */ |
1223 | 1267 | public function removedControl($control) |
1224 | 1268 | { |
1225 | - if($this->_namingContainer) |
|
1226 | - $this->_namingContainer->clearNameTable(); |
|
1269 | + if($this->_namingContainer) { |
|
1270 | + $this->_namingContainer->clearNameTable(); |
|
1271 | + } |
|
1227 | 1272 | $control->unloadRecursive(); |
1228 | 1273 | $control->_parent=null; |
1229 | 1274 | $control->_page=null; |
1230 | 1275 | $control->_namingContainer=null; |
1231 | 1276 | $control->_tplControl=null; |
1232 | 1277 | //$control->_stage=self::CS_CONSTRUCTED; |
1233 | - if(!($control->_flags & self::IS_ID_SET)) |
|
1234 | - $control->_id=''; |
|
1235 | - else |
|
1236 | - unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
|
1278 | + if(!($control->_flags & self::IS_ID_SET)) { |
|
1279 | + $control->_id=''; |
|
1280 | + } else { |
|
1281 | + unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]); |
|
1282 | + } |
|
1237 | 1283 | $control->clearCachedUniqueID(true); |
1238 | 1284 | } |
1239 | 1285 | |
@@ -1247,8 +1293,9 @@ discard block |
||
1247 | 1293 | $this->ensureChildControls(); |
1248 | 1294 | if($this->getHasControls()) |
1249 | 1295 | { |
1250 | - if($this instanceof INamingContainer) |
|
1251 | - $namingContainer=$this; |
|
1296 | + if($this instanceof INamingContainer) { |
|
1297 | + $namingContainer=$this; |
|
1298 | + } |
|
1252 | 1299 | $page=$this->getPage(); |
1253 | 1300 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1254 | 1301 | { |
@@ -1256,8 +1303,9 @@ discard block |
||
1256 | 1303 | { |
1257 | 1304 | $control->_namingContainer=$namingContainer; |
1258 | 1305 | $control->_page=$page; |
1259 | - if($control->_id==='' && $namingContainer) |
|
1260 | - $control->generateAutomaticID(); |
|
1306 | + if($control->_id==='' && $namingContainer) { |
|
1307 | + $control->generateAutomaticID(); |
|
1308 | + } |
|
1261 | 1309 | $control->initRecursive($namingContainer); |
1262 | 1310 | } |
1263 | 1311 | } |
@@ -1270,10 +1318,11 @@ discard block |
||
1270 | 1318 | $page->applyControlSkin($this); |
1271 | 1319 | $this->_flags |= self::IS_SKIN_APPLIED; |
1272 | 1320 | } |
1273 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1274 | - $this->_rf[self::RF_ADAPTER]->onInit(null); |
|
1275 | - else |
|
1276 | - $this->onInit(null); |
|
1321 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1322 | + $this->_rf[self::RF_ADAPTER]->onInit(null); |
|
1323 | + } else { |
|
1324 | + $this->onInit(null); |
|
1325 | + } |
|
1277 | 1326 | $this->_stage=self::CS_INITIALIZED; |
1278 | 1327 | } |
1279 | 1328 | } |
@@ -1286,21 +1335,24 @@ discard block |
||
1286 | 1335 | { |
1287 | 1336 | if($this->_stage<self::CS_LOADED) |
1288 | 1337 | { |
1289 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1290 | - $this->_rf[self::RF_ADAPTER]->onLoad(null); |
|
1291 | - else |
|
1292 | - $this->onLoad(null); |
|
1338 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1339 | + $this->_rf[self::RF_ADAPTER]->onLoad(null); |
|
1340 | + } else { |
|
1341 | + $this->onLoad(null); |
|
1342 | + } |
|
1293 | 1343 | } |
1294 | 1344 | if($this->getHasControls()) |
1295 | 1345 | { |
1296 | 1346 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1297 | 1347 | { |
1298 | - if($control instanceof TControl) |
|
1299 | - $control->loadRecursive(); |
|
1348 | + if($control instanceof TControl) { |
|
1349 | + $control->loadRecursive(); |
|
1350 | + } |
|
1300 | 1351 | } |
1301 | 1352 | } |
1302 | - if($this->_stage<self::CS_LOADED) |
|
1303 | - $this->_stage=self::CS_LOADED; |
|
1353 | + if($this->_stage<self::CS_LOADED) { |
|
1354 | + $this->_stage=self::CS_LOADED; |
|
1355 | + } |
|
1304 | 1356 | } |
1305 | 1357 | |
1306 | 1358 | /** |
@@ -1313,18 +1365,20 @@ discard block |
||
1313 | 1365 | |
1314 | 1366 | if($this->getVisible(false)) |
1315 | 1367 | { |
1316 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1317 | - $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
|
1318 | - else |
|
1319 | - $this->onPreRender(null); |
|
1368 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1369 | + $this->_rf[self::RF_ADAPTER]->onPreRender(null); |
|
1370 | + } else { |
|
1371 | + $this->onPreRender(null); |
|
1372 | + } |
|
1320 | 1373 | if($this->getHasControls()) |
1321 | 1374 | { |
1322 | 1375 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1323 | 1376 | { |
1324 | - if($control instanceof TControl) |
|
1325 | - $control->preRenderRecursive(); |
|
1326 | - else if($control instanceof TCompositeLiteral) |
|
1327 | - $control->evaluateDynamicContent(); |
|
1377 | + if($control instanceof TControl) { |
|
1378 | + $control->preRenderRecursive(); |
|
1379 | + } else if($control instanceof TCompositeLiteral) { |
|
1380 | + $control->evaluateDynamicContent(); |
|
1381 | + } |
|
1328 | 1382 | } |
1329 | 1383 | } |
1330 | 1384 | } |
@@ -1337,18 +1391,21 @@ discard block |
||
1337 | 1391 | */ |
1338 | 1392 | protected function unloadRecursive() |
1339 | 1393 | { |
1340 | - if(!($this->_flags & self::IS_ID_SET)) |
|
1341 | - $this->_id=''; |
|
1394 | + if(!($this->_flags & self::IS_ID_SET)) { |
|
1395 | + $this->_id=''; |
|
1396 | + } |
|
1342 | 1397 | if($this->getHasControls()) |
1343 | 1398 | { |
1344 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1345 | - if($control instanceof TControl) |
|
1399 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
1400 | + if($control instanceof TControl) |
|
1346 | 1401 | $control->unloadRecursive(); |
1402 | + } |
|
1403 | + } |
|
1404 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1405 | + $this->_rf[self::RF_ADAPTER]->onUnload(null); |
|
1406 | + } else { |
|
1407 | + $this->onUnload(null); |
|
1347 | 1408 | } |
1348 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1349 | - $this->_rf[self::RF_ADAPTER]->onUnload(null); |
|
1350 | - else |
|
1351 | - $this->onUnload(null); |
|
1352 | 1409 | } |
1353 | 1410 | |
1354 | 1411 | /** |
@@ -1423,8 +1480,9 @@ discard block |
||
1423 | 1480 | $control=$this; |
1424 | 1481 | while($control=$control->_parent) |
1425 | 1482 | { |
1426 | - if($control->bubbleEvent($sender,$param)) |
|
1427 | - break; |
|
1483 | + if($control->bubbleEvent($sender,$param)) { |
|
1484 | + break; |
|
1485 | + } |
|
1428 | 1486 | } |
1429 | 1487 | } |
1430 | 1488 | |
@@ -1473,16 +1531,19 @@ discard block |
||
1473 | 1531 | */ |
1474 | 1532 | private function broadcastEventInternal($name,$sender,$param) |
1475 | 1533 | { |
1476 | - if($this->hasEvent($name)) |
|
1477 | - $this->raiseEvent($name,$sender,$param->getParameter()); |
|
1478 | - if($this instanceof IBroadcastEventReceiver) |
|
1479 | - $this->broadcastEventReceived($sender,$param); |
|
1534 | + if($this->hasEvent($name)) { |
|
1535 | + $this->raiseEvent($name,$sender,$param->getParameter()); |
|
1536 | + } |
|
1537 | + if($this instanceof IBroadcastEventReceiver) { |
|
1538 | + $this->broadcastEventReceived($sender,$param); |
|
1539 | + } |
|
1480 | 1540 | if($this->getHasControls()) |
1481 | 1541 | { |
1482 | 1542 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1483 | 1543 | { |
1484 | - if($control instanceof TControl) |
|
1485 | - $control->broadcastEventInternal($name,$sender,$param); |
|
1544 | + if($control instanceof TControl) { |
|
1545 | + $control->broadcastEventInternal($name,$sender,$param); |
|
1546 | + } |
|
1486 | 1547 | } |
1487 | 1548 | } |
1488 | 1549 | } |
@@ -1506,8 +1567,9 @@ discard block |
||
1506 | 1567 | */ |
1507 | 1568 | protected function traverseChildControls($param,$preCallback=null,$postCallback=null) |
1508 | 1569 | { |
1509 | - if($preCallback!==null) |
|
1510 | - call_user_func($preCallback,$this,$param); |
|
1570 | + if($preCallback!==null) { |
|
1571 | + call_user_func($preCallback,$this,$param); |
|
1572 | + } |
|
1511 | 1573 | if($this->getHasControls()) |
1512 | 1574 | { |
1513 | 1575 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
@@ -1518,8 +1580,9 @@ discard block |
||
1518 | 1580 | } |
1519 | 1581 | } |
1520 | 1582 | } |
1521 | - if($postCallback!==null) |
|
1522 | - call_user_func($postCallback,$this,$param); |
|
1583 | + if($postCallback!==null) { |
|
1584 | + call_user_func($postCallback,$this,$param); |
|
1585 | + } |
|
1523 | 1586 | } |
1524 | 1587 | |
1525 | 1588 | /** |
@@ -1531,10 +1594,11 @@ discard block |
||
1531 | 1594 | { |
1532 | 1595 | if($this instanceof IActiveControl || $this->getVisible(false)) |
1533 | 1596 | { |
1534 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1535 | - $this->_rf[self::RF_ADAPTER]->render($writer); |
|
1536 | - else |
|
1537 | - $this->render($writer); |
|
1597 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1598 | + $this->_rf[self::RF_ADAPTER]->render($writer); |
|
1599 | + } else { |
|
1600 | + $this->render($writer); |
|
1601 | + } |
|
1538 | 1602 | } |
1539 | 1603 | } |
1540 | 1604 | |
@@ -1562,12 +1626,13 @@ discard block |
||
1562 | 1626 | { |
1563 | 1627 | foreach($this->_rf[self::RF_CONTROLS] as $control) |
1564 | 1628 | { |
1565 | - if(is_string($control)) |
|
1566 | - $writer->write($control); |
|
1567 | - else if($control instanceof TControl) |
|
1568 | - $control->renderControl($writer); |
|
1569 | - else if($control instanceof IRenderable) |
|
1570 | - $control->render($writer); |
|
1629 | + if(is_string($control)) { |
|
1630 | + $writer->write($control); |
|
1631 | + } else if($control instanceof TControl) { |
|
1632 | + $control->renderControl($writer); |
|
1633 | + } else if($control instanceof IRenderable) { |
|
1634 | + $control->render($writer); |
|
1635 | + } |
|
1571 | 1636 | } |
1572 | 1637 | } |
1573 | 1638 | } |
@@ -1607,15 +1672,16 @@ discard block |
||
1607 | 1672 | { |
1608 | 1673 | $this->_rf[self::RF_CONTROLSTATE]=&$state[1]; |
1609 | 1674 | unset($state[1]); |
1675 | + } else { |
|
1676 | + unset($this->_rf[self::RF_CONTROLSTATE]); |
|
1610 | 1677 | } |
1611 | - else |
|
1612 | - unset($this->_rf[self::RF_CONTROLSTATE]); |
|
1613 | 1678 | if($needViewState) |
1614 | 1679 | { |
1615 | - if(isset($state[0])) |
|
1616 | - $this->_viewState=&$state[0]; |
|
1617 | - else |
|
1618 | - $this->_viewState=array(); |
|
1680 | + if(isset($state[0])) { |
|
1681 | + $this->_viewState=&$state[0]; |
|
1682 | + } else { |
|
1683 | + $this->_viewState=array(); |
|
1684 | + } |
|
1619 | 1685 | } |
1620 | 1686 | unset($state[0]); |
1621 | 1687 | if($this->getHasControls()) |
@@ -1632,14 +1698,16 @@ discard block |
||
1632 | 1698 | } |
1633 | 1699 | } |
1634 | 1700 | } |
1635 | - if(!empty($state)) |
|
1636 | - $this->_rf[self::RF_CHILD_STATE]=&$state; |
|
1701 | + if(!empty($state)) { |
|
1702 | + $this->_rf[self::RF_CHILD_STATE]=&$state; |
|
1703 | + } |
|
1637 | 1704 | } |
1638 | 1705 | $this->_stage=self::CS_STATE_LOADED; |
1639 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1640 | - $this->_rf[self::RF_ADAPTER]->loadState(); |
|
1641 | - else |
|
1642 | - $this->loadState(); |
|
1706 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1707 | + $this->_rf[self::RF_ADAPTER]->loadState(); |
|
1708 | + } else { |
|
1709 | + $this->loadState(); |
|
1710 | + } |
|
1643 | 1711 | } |
1644 | 1712 | |
1645 | 1713 | /** |
@@ -1650,10 +1718,11 @@ discard block |
||
1650 | 1718 | */ |
1651 | 1719 | protected function &saveStateRecursive($needViewState=true) |
1652 | 1720 | { |
1653 | - if(isset($this->_rf[self::RF_ADAPTER])) |
|
1654 | - $this->_rf[self::RF_ADAPTER]->saveState(); |
|
1655 | - else |
|
1656 | - $this->saveState(); |
|
1721 | + if(isset($this->_rf[self::RF_ADAPTER])) { |
|
1722 | + $this->_rf[self::RF_ADAPTER]->saveState(); |
|
1723 | + } else { |
|
1724 | + $this->saveState(); |
|
1725 | + } |
|
1657 | 1726 | $needViewState=($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE)); |
1658 | 1727 | $state=array(); |
1659 | 1728 | if($this->getHasControls()) |
@@ -1662,15 +1731,18 @@ discard block |
||
1662 | 1731 | { |
1663 | 1732 | if($control instanceof TControl) |
1664 | 1733 | { |
1665 | - if(count($tmp = &$control->saveStateRecursive($needViewState))) |
|
1666 | - $state[$control->_id]=$tmp; |
|
1734 | + if(count($tmp = &$control->saveStateRecursive($needViewState))) { |
|
1735 | + $state[$control->_id]=$tmp; |
|
1736 | + } |
|
1667 | 1737 | } |
1668 | 1738 | } |
1669 | 1739 | } |
1670 | - if($needViewState && !empty($this->_viewState)) |
|
1671 | - $state[0]=&$this->_viewState; |
|
1672 | - if(isset($this->_rf[self::RF_CONTROLSTATE])) |
|
1673 | - $state[1]=&$this->_rf[self::RF_CONTROLSTATE]; |
|
1740 | + if($needViewState && !empty($this->_viewState)) { |
|
1741 | + $state[0]=&$this->_viewState; |
|
1742 | + } |
|
1743 | + if(isset($this->_rf[self::RF_CONTROLSTATE])) { |
|
1744 | + $state[1]=&$this->_rf[self::RF_CONTROLSTATE]; |
|
1745 | + } |
|
1674 | 1746 | return $state; |
1675 | 1747 | } |
1676 | 1748 | |
@@ -1685,9 +1757,9 @@ discard block |
||
1685 | 1757 | { |
1686 | 1758 | $page->applyControlStyleSheet($this); |
1687 | 1759 | $this->_flags |= self::IS_STYLESHEET_APPLIED; |
1760 | + } else if($this->_flags & self::IS_STYLESHEET_APPLIED) { |
|
1761 | + throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
|
1688 | 1762 | } |
1689 | - else if($this->_flags & self::IS_STYLESHEET_APPLIED) |
|
1690 | - throw new TInvalidOperationException('control_stylesheet_applied',get_class($this)); |
|
1691 | 1763 | } |
1692 | 1764 | |
1693 | 1765 | /** |
@@ -1699,9 +1771,10 @@ discard block |
||
1699 | 1771 | { |
1700 | 1772 | if($recursive && $this->_uid!==null && isset($this->_rf[self::RF_CONTROLS])) |
1701 | 1773 | { |
1702 | - foreach($this->_rf[self::RF_CONTROLS] as $control) |
|
1703 | - if($control instanceof TControl) |
|
1774 | + foreach($this->_rf[self::RF_CONTROLS] as $control) { |
|
1775 | + if($control instanceof TControl) |
|
1704 | 1776 | $control->clearCachedUniqueID($recursive); |
1777 | + } |
|
1705 | 1778 | } |
1706 | 1779 | $this->_uid=null; |
1707 | 1780 | } |
@@ -1712,8 +1785,9 @@ discard block |
||
1712 | 1785 | private function generateAutomaticID() |
1713 | 1786 | { |
1714 | 1787 | $this->_flags &= ~self::IS_ID_SET; |
1715 | - if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) |
|
1716 | - $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0; |
|
1788 | + if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) { |
|
1789 | + $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0; |
|
1790 | + } |
|
1717 | 1791 | $id=$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++; |
1718 | 1792 | $this->_id=self::AUTOMATIC_ID_PREFIX . $id; |
1719 | 1793 | $this->_namingContainer->clearNameTable(); |
@@ -1741,13 +1815,15 @@ discard block |
||
1741 | 1815 | { |
1742 | 1816 | if($control->_id!=='') |
1743 | 1817 | { |
1744 | - if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) |
|
1745 | - throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id); |
|
1746 | - else |
|
1747 | - $container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control; |
|
1818 | + if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) { |
|
1819 | + throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id); |
|
1820 | + } else { |
|
1821 | + $container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control; |
|
1822 | + } |
|
1823 | + } |
|
1824 | + if(!($control instanceof INamingContainer) && $control->getHasControls()) { |
|
1825 | + $this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]); |
|
1748 | 1826 | } |
1749 | - if(!($control instanceof INamingContainer) && $control->getHasControls()) |
|
1750 | - $this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]); |
|
1751 | 1827 | } |
1752 | 1828 | } |
1753 | 1829 | } |
@@ -1805,11 +1881,11 @@ discard block |
||
1805 | 1881 | { |
1806 | 1882 | parent::insertAt($index,$item); |
1807 | 1883 | $this->_o->addedControl($item); |
1884 | + } else if(is_string($item) || ($item instanceof IRenderable)) { |
|
1885 | + parent::insertAt($index,$item); |
|
1886 | + } else { |
|
1887 | + throw new TInvalidDataTypeException('controlcollection_control_required'); |
|
1808 | 1888 | } |
1809 | - else if(is_string($item) || ($item instanceof IRenderable)) |
|
1810 | - parent::insertAt($index,$item); |
|
1811 | - else |
|
1812 | - throw new TInvalidDataTypeException('controlcollection_control_required'); |
|
1813 | 1889 | } |
1814 | 1890 | |
1815 | 1891 | /** |
@@ -1822,8 +1898,9 @@ discard block |
||
1822 | 1898 | public function removeAt($index) |
1823 | 1899 | { |
1824 | 1900 | $item=parent::removeAt($index); |
1825 | - if($item instanceof TControl) |
|
1826 | - $this->_o->removedControl($item); |
|
1901 | + if($item instanceof TControl) { |
|
1902 | + $this->_o->removedControl($item); |
|
1903 | + } |
|
1827 | 1904 | return $item; |
1828 | 1905 | } |
1829 | 1906 | |
@@ -1833,8 +1910,9 @@ discard block |
||
1833 | 1910 | public function clear() |
1834 | 1911 | { |
1835 | 1912 | parent::clear(); |
1836 | - if($this->_o instanceof INamingContainer) |
|
1837 | - $this->_o->clearNamingContainer(); |
|
1913 | + if($this->_o instanceof INamingContainer) { |
|
1914 | + $this->_o->clearNamingContainer(); |
|
1915 | + } |
|
1838 | 1916 | } |
1839 | 1917 | } |
1840 | 1918 | |
@@ -1867,8 +1945,11 @@ discard block |
||
1867 | 1945 | */ |
1868 | 1946 | public function insertAt($index,$item) |
1869 | 1947 | { |
1870 | - if(!is_string($item)) // string is possible if property tag is used. we simply ignore it in this case |
|
1871 | - parent::insertAt($index,$item); // this will generate an exception in parent implementation |
|
1948 | + if(!is_string($item)) { |
|
1949 | + // string is possible if property tag is used. we simply ignore it in this case |
|
1950 | + parent::insertAt($index,$item); |
|
1951 | + } |
|
1952 | + // this will generate an exception in parent implementation |
|
1872 | 1953 | } |
1873 | 1954 | } |
1874 | 1955 | |
@@ -2311,16 +2392,17 @@ discard block |
||
2311 | 2392 | { |
2312 | 2393 | if(is_array($item)) |
2313 | 2394 | { |
2314 | - if($item[0]===self::TYPE_EXPRESSION) |
|
2315 | - $this->_expressions[$id]=$item[1]; |
|
2316 | - else if($item[0]===self::TYPE_STATEMENTS) |
|
2317 | - $this->_statements[$id]=$item[1]; |
|
2318 | - else if($item[0]===self::TYPE_DATABINDING) |
|
2319 | - $this->_bindings[$id]=$item[1]; |
|
2395 | + if($item[0]===self::TYPE_EXPRESSION) { |
|
2396 | + $this->_expressions[$id]=$item[1]; |
|
2397 | + } else if($item[0]===self::TYPE_STATEMENTS) { |
|
2398 | + $this->_statements[$id]=$item[1]; |
|
2399 | + } else if($item[0]===self::TYPE_DATABINDING) { |
|
2400 | + $this->_bindings[$id]=$item[1]; |
|
2401 | + } |
|
2320 | 2402 | $this->_items[$id]=''; |
2403 | + } else { |
|
2404 | + $this->_items[$id]=$item; |
|
2321 | 2405 | } |
2322 | - else |
|
2323 | - $this->_items[$id]=$item; |
|
2324 | 2406 | } |
2325 | 2407 | } |
2326 | 2408 | |
@@ -2346,10 +2428,12 @@ discard block |
||
2346 | 2428 | public function evaluateDynamicContent() |
2347 | 2429 | { |
2348 | 2430 | $context=$this->_container===null?$this:$this->_container; |
2349 | - foreach($this->_expressions as $id=>$expression) |
|
2350 | - $this->_items[$id]=$context->evaluateExpression($expression); |
|
2351 | - foreach($this->_statements as $id=>$statement) |
|
2352 | - $this->_items[$id]=$context->evaluateStatements($statement); |
|
2431 | + foreach($this->_expressions as $id=>$expression) { |
|
2432 | + $this->_items[$id]=$context->evaluateExpression($expression); |
|
2433 | + } |
|
2434 | + foreach($this->_statements as $id=>$statement) { |
|
2435 | + $this->_items[$id]=$context->evaluateStatements($statement); |
|
2436 | + } |
|
2353 | 2437 | } |
2354 | 2438 | |
2355 | 2439 | /** |
@@ -2359,8 +2443,9 @@ discard block |
||
2359 | 2443 | public function dataBind() |
2360 | 2444 | { |
2361 | 2445 | $context=$this->_container===null?$this:$this->_container; |
2362 | - foreach($this->_bindings as $id=>$binding) |
|
2363 | - $this->_items[$id]=$context->evaluateExpression($binding); |
|
2446 | + foreach($this->_bindings as $id=>$binding) { |
|
2447 | + $this->_items[$id]=$context->evaluateExpression($binding); |
|
2448 | + } |
|
2364 | 2449 | } |
2365 | 2450 | |
2366 | 2451 | /** |
@@ -86,6 +86,9 @@ discard block |
||
86 | 86 | return $this->_writer; |
87 | 87 | } |
88 | 88 | |
89 | + /** |
|
90 | + * @param TestWriter $writer |
|
91 | + */ |
|
89 | 92 | public function setWriter($writer) |
90 | 93 | { |
91 | 94 | $this->_writer = $writer; |
@@ -104,6 +107,8 @@ discard block |
||
104 | 107 | * Adds an attribute to be rendered. |
105 | 108 | * @param string name of the attribute |
106 | 109 | * @param string value of the attribute |
110 | + * @param string $name |
|
111 | + * @param string $value |
|
107 | 112 | */ |
108 | 113 | public function addAttribute($name,$value) |
109 | 114 | { |
@@ -113,6 +118,7 @@ discard block |
||
113 | 118 | /** |
114 | 119 | * Removes the named attribute from rendering |
115 | 120 | * @param string name of the attribute to be removed |
121 | + * @param string $name |
|
116 | 122 | */ |
117 | 123 | public function removeAttribute($name) |
118 | 124 | { |
@@ -133,6 +139,8 @@ discard block |
||
133 | 139 | * Adds a stylesheet attribute to be rendered |
134 | 140 | * @param string stylesheet attribute name |
135 | 141 | * @param string stylesheet attribute value |
142 | + * @param string $name |
|
143 | + * @param string $value |
|
136 | 144 | */ |
137 | 145 | public function addStyleAttribute($name,$value) |
138 | 146 | { |
@@ -142,6 +150,7 @@ discard block |
||
142 | 150 | /** |
143 | 151 | * Removes the named stylesheet attribute from rendering |
144 | 152 | * @param string name of the stylesheet attribute to be removed |
153 | + * @param string $name |
|
145 | 154 | */ |
146 | 155 | public function removeStyleAttribute($name) |
147 | 156 | { |
@@ -161,6 +170,7 @@ discard block |
||
161 | 170 | /** |
162 | 171 | * Renders a string. |
163 | 172 | * @param string string to be rendered |
173 | + * @param string $str |
|
164 | 174 | */ |
165 | 175 | public function write($str) |
166 | 176 | { |
@@ -187,6 +197,7 @@ discard block |
||
187 | 197 | /** |
188 | 198 | * Renders the openning tag. |
189 | 199 | * @param string tag name |
200 | + * @param string $tagName |
|
190 | 201 | */ |
191 | 202 | public function renderBeginTag($tagName) |
192 | 203 | { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @var array list of tags are do not need a closing tag |
41 | 41 | */ |
42 | - private static $_simpleTags=array( |
|
42 | + private static $_simpleTags = array( |
|
43 | 43 | 'area'=>true, |
44 | 44 | 'base'=>true, |
45 | 45 | 'basefont'=>true, |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * @var array list of attributes to be rendered for a tag |
60 | 60 | */ |
61 | - private $_attributes=array(); |
|
61 | + private $_attributes = array(); |
|
62 | 62 | /** |
63 | 63 | * @var array list of openning tags |
64 | 64 | */ |
65 | - private $_openTags=array(); |
|
65 | + private $_openTags = array(); |
|
66 | 66 | /** |
67 | 67 | * @var array list of style attributes |
68 | 68 | */ |
69 | - private $_styles=array(); |
|
69 | + private $_styles = array(); |
|
70 | 70 | /** |
71 | 71 | * @var ITextWriter writer |
72 | 72 | */ |
73 | - private $_writer=null; |
|
73 | + private $_writer = null; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Constructor. |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function __construct($writer) |
80 | 80 | { |
81 | - $this->_writer=$writer; |
|
81 | + $this->_writer = $writer; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | public function getWriter() |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function addAttributes($attrs) |
98 | 98 | { |
99 | - foreach($attrs as $name=>$value) |
|
100 | - $this->_attributes[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
|
99 | + foreach ($attrs as $name=>$value) |
|
100 | + $this->_attributes[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param string name of the attribute |
106 | 106 | * @param string value of the attribute |
107 | 107 | */ |
108 | - public function addAttribute($name,$value) |
|
108 | + public function addAttribute($name, $value) |
|
109 | 109 | { |
110 | - $this->_attributes[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
|
110 | + $this->_attributes[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function addStyleAttributes($attrs) |
127 | 127 | { |
128 | - foreach($attrs as $name=>$value) |
|
129 | - $this->_styles[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
|
128 | + foreach ($attrs as $name=>$value) |
|
129 | + $this->_styles[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | * @param string stylesheet attribute name |
135 | 135 | * @param string stylesheet attribute value |
136 | 136 | */ |
137 | - public function addStyleAttribute($name,$value) |
|
137 | + public function addStyleAttribute($name, $value) |
|
138 | 138 | { |
139 | - $this->_styles[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
|
139 | + $this->_styles[THttpUtility::htmlStrip($name)] = THttpUtility::htmlEncode($value); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | * Renders a string and appends a newline to it. |
172 | 172 | * @param string string to be rendered |
173 | 173 | */ |
174 | - public function writeLine($str='') |
|
174 | + public function writeLine($str = '') |
|
175 | 175 | { |
176 | - $this->_writer->write($str."\n"); |
|
176 | + $this->_writer->write($str . "\n"); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -190,29 +190,29 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function renderBeginTag($tagName) |
192 | 192 | { |
193 | - $str='<'.$tagName; |
|
194 | - foreach($this->_attributes as $name=>$value) |
|
195 | - $str.=' '.$name.'="'.$value.'"'; |
|
196 | - if(!empty($this->_styles)) |
|
193 | + $str = '<' . $tagName; |
|
194 | + foreach ($this->_attributes as $name=>$value) |
|
195 | + $str .= ' ' . $name . '="' . $value . '"'; |
|
196 | + if (!empty($this->_styles)) |
|
197 | 197 | { |
198 | - $str.=' style="'; |
|
199 | - foreach($this->_styles as $name=>$value) |
|
200 | - $str.=$name.':'.$value.';'; |
|
201 | - $str.='"'; |
|
198 | + $str .= ' style="'; |
|
199 | + foreach ($this->_styles as $name=>$value) |
|
200 | + $str .= $name . ':' . $value . ';'; |
|
201 | + $str .= '"'; |
|
202 | 202 | } |
203 | - if(isset(self::$_simpleTags[$tagName])) |
|
203 | + if (isset(self::$_simpleTags[$tagName])) |
|
204 | 204 | { |
205 | - $str.=' />'; |
|
205 | + $str .= ' />'; |
|
206 | 206 | $this->_openTags[] = ''; |
207 | 207 | } |
208 | 208 | else |
209 | 209 | { |
210 | - $str.='>'; |
|
210 | + $str .= '>'; |
|
211 | 211 | $this->_openTags[] = $tagName; |
212 | 212 | } |
213 | 213 | $this->_writer->write($str); |
214 | - $this->_attributes=array(); |
|
215 | - $this->_styles=array(); |
|
214 | + $this->_attributes = array(); |
|
215 | + $this->_styles = array(); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function renderEndTag() |
222 | 222 | { |
223 | - if(!empty($this->_openTags) && ($tagName=array_pop($this->_openTags))!=='') |
|
224 | - $this->_writer->write('</'.$tagName.'>'); |
|
223 | + if (!empty($this->_openTags) && ($tagName = array_pop($this->_openTags)) !== '') |
|
224 | + $this->_writer->write('</' . $tagName . '>'); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 |
@@ -96,8 +96,9 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function addAttributes($attrs) |
98 | 98 | { |
99 | - foreach($attrs as $name=>$value) |
|
100 | - $this->_attributes[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
|
99 | + foreach($attrs as $name=>$value) { |
|
100 | + $this->_attributes[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
|
101 | + } |
|
101 | 102 | } |
102 | 103 | |
103 | 104 | /** |
@@ -125,8 +126,9 @@ discard block |
||
125 | 126 | */ |
126 | 127 | public function addStyleAttributes($attrs) |
127 | 128 | { |
128 | - foreach($attrs as $name=>$value) |
|
129 | - $this->_styles[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
|
129 | + foreach($attrs as $name=>$value) { |
|
130 | + $this->_styles[THttpUtility::htmlStrip($name)]=THttpUtility::htmlEncode($value); |
|
131 | + } |
|
130 | 132 | } |
131 | 133 | |
132 | 134 | /** |
@@ -191,21 +193,22 @@ discard block |
||
191 | 193 | public function renderBeginTag($tagName) |
192 | 194 | { |
193 | 195 | $str='<'.$tagName; |
194 | - foreach($this->_attributes as $name=>$value) |
|
195 | - $str.=' '.$name.'="'.$value.'"'; |
|
196 | + foreach($this->_attributes as $name=>$value) { |
|
197 | + $str.=' '.$name.'="'.$value.'"'; |
|
198 | + } |
|
196 | 199 | if(!empty($this->_styles)) |
197 | 200 | { |
198 | 201 | $str.=' style="'; |
199 | - foreach($this->_styles as $name=>$value) |
|
200 | - $str.=$name.':'.$value.';'; |
|
202 | + foreach($this->_styles as $name=>$value) { |
|
203 | + $str.=$name.':'.$value.';'; |
|
204 | + } |
|
201 | 205 | $str.='"'; |
202 | 206 | } |
203 | 207 | if(isset(self::$_simpleTags[$tagName])) |
204 | 208 | { |
205 | 209 | $str.=' />'; |
206 | 210 | $this->_openTags[] = ''; |
207 | - } |
|
208 | - else |
|
211 | + } else |
|
209 | 212 | { |
210 | 213 | $str.='>'; |
211 | 214 | $this->_openTags[] = $tagName; |
@@ -220,8 +223,9 @@ discard block |
||
220 | 223 | */ |
221 | 224 | public function renderEndTag() |
222 | 225 | { |
223 | - if(!empty($this->_openTags) && ($tagName=array_pop($this->_openTags))!=='') |
|
224 | - $this->_writer->write('</'.$tagName.'>'); |
|
226 | + if(!empty($this->_openTags) && ($tagName=array_pop($this->_openTags))!=='') { |
|
227 | + $this->_writer->write('</'.$tagName.'>'); |
|
228 | + } |
|
225 | 229 | } |
226 | 230 | } |
227 | 231 |
@@ -278,6 +278,9 @@ discard block |
||
278 | 278 | $this->unloadRecursive(); |
279 | 279 | } |
280 | 280 | |
281 | + /** |
|
282 | + * @param string $enc |
|
283 | + */ |
|
281 | 284 | protected static function decodeUTF8($data, $enc) |
282 | 285 | { |
283 | 286 | if(is_array($data)) |
@@ -451,6 +454,7 @@ discard block |
||
451 | 454 | * Returns a list of registered validators. |
452 | 455 | * If validation group is specified, only the validators in that group will be returned. |
453 | 456 | * @param string validation group |
457 | + * @param string $validationGroup |
|
454 | 458 | * @return TList registered validators in the requested group. If the group is null, all validators will be returned. |
455 | 459 | */ |
456 | 460 | public function getValidators($validationGroup=null) |
@@ -562,6 +566,7 @@ discard block |
||
562 | 566 | * Applies a skin in the current theme to a control. |
563 | 567 | * This method should only be used by framework developers. |
564 | 568 | * @param TControl a control to be applied skin with |
569 | + * @param TControl $control |
|
565 | 570 | */ |
566 | 571 | public function applyControlSkin($control) |
567 | 572 | { |
@@ -856,6 +861,7 @@ discard block |
||
856 | 861 | * Processes post data. |
857 | 862 | * @param TMap post data to be processed |
858 | 863 | * @param boolean whether this method is invoked before {@link onLoad OnLoad}. |
864 | + * @param boolean $beforeLoad |
|
859 | 865 | */ |
860 | 866 | protected function processPostData($postData,$beforeLoad) |
861 | 867 | { |
@@ -981,6 +987,7 @@ discard block |
||
981 | 987 | /** |
982 | 988 | * Sets input focus on a control after the page is rendered to users. |
983 | 989 | * @param TControl|string control to receive focus, or the ID of the element on the page to receive focus |
990 | + * @param TControl $value |
|
984 | 991 | */ |
985 | 992 | public function setFocus($value) |
986 | 993 | { |
@@ -1066,6 +1073,7 @@ discard block |
||
1066 | 1073 | * Sets the state to be stored on the client side. |
1067 | 1074 | * This method should only be used by framework and control developers. |
1068 | 1075 | * @param string the state to be stored on the client side |
1076 | + * @param string $state |
|
1069 | 1077 | */ |
1070 | 1078 | public function setClientState($state) |
1071 | 1079 | { |
@@ -1185,6 +1193,8 @@ discard block |
||
1185 | 1193 | * referring to the context object (e.g. Page, Page.ClientScript). |
1186 | 1194 | * @param string method name of the context object |
1187 | 1195 | * @param array list of parameters to be passed to the action method |
1196 | + * @param string $context |
|
1197 | + * @param string $funcName |
|
1188 | 1198 | */ |
1189 | 1199 | public function registerCachingAction($context,$funcName,$funcParams) |
1190 | 1200 | { |
@@ -1230,15 +1240,18 @@ discard block |
||
1230 | 1240 | { |
1231 | 1241 | /** |
1232 | 1242 | * @param TPage the page that this persister works for |
1243 | + * @return TPage |
|
1233 | 1244 | */ |
1234 | 1245 | public function getPage(); |
1235 | 1246 | /** |
1236 | 1247 | * @param TPage the page that this persister works for |
1248 | + * @return void |
|
1237 | 1249 | */ |
1238 | 1250 | public function setPage(TPage $page); |
1239 | 1251 | /** |
1240 | 1252 | * Saves state to persistent storage. |
1241 | 1253 | * @param mixed state to be stored |
1254 | + * @return void |
|
1242 | 1255 | */ |
1243 | 1256 | public function save($state); |
1244 | 1257 | /** |
@@ -1272,6 +1285,7 @@ discard block |
||
1272 | 1285 | /** |
1273 | 1286 | * @param TPage |
1274 | 1287 | * @param mixed state data |
1288 | + * @param TPage $page |
|
1275 | 1289 | * @return string serialized data |
1276 | 1290 | */ |
1277 | 1291 | public static function serialize($page,$data) |
@@ -1291,6 +1305,7 @@ discard block |
||
1291 | 1305 | /** |
1292 | 1306 | * @param TPage |
1293 | 1307 | * @param string serialized data |
1308 | + * @param TPage $page |
|
1294 | 1309 | * @return mixed unserialized state data, null if data is corrupted |
1295 | 1310 | */ |
1296 | 1311 | public static function unserialize($page,$data) |
@@ -303,15 +303,15 @@ |
||
303 | 303 | |
304 | 304 | $this->setAdapter(new TActivePageAdapter($this)); |
305 | 305 | |
306 | - $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
307 | - if(strlen($callbackEventParameter) > 0) |
|
308 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
309 | - |
|
310 | - // Decode Callback postData from UTF-8 to current Charset |
|
311 | - if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
312 | - strtoupper($enc=$g->getCharset())!='UTF-8') |
|
313 | - foreach ($this->_postData as $k=>$v) |
|
314 | - $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
306 | + $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
307 | + if(strlen($callbackEventParameter) > 0) |
|
308 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
309 | + |
|
310 | + // Decode Callback postData from UTF-8 to current Charset |
|
311 | + if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
312 | + strtoupper($enc=$g->getCharset())!='UTF-8') |
|
313 | + foreach ($this->_postData as $k=>$v) |
|
314 | + $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
315 | 315 | |
316 | 316 | Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
317 | 317 | $this->onPreInit(null); |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * system post fields |
31 | 31 | */ |
32 | - const FIELD_POSTBACK_TARGET='PRADO_POSTBACK_TARGET'; |
|
33 | - const FIELD_POSTBACK_PARAMETER='PRADO_POSTBACK_PARAMETER'; |
|
34 | - const FIELD_LASTFOCUS='PRADO_LASTFOCUS'; |
|
35 | - const FIELD_PAGESTATE='PRADO_PAGESTATE'; |
|
36 | - const FIELD_CALLBACK_TARGET='PRADO_CALLBACK_TARGET'; |
|
37 | - const FIELD_CALLBACK_PARAMETER='PRADO_CALLBACK_PARAMETER'; |
|
32 | + const FIELD_POSTBACK_TARGET = 'PRADO_POSTBACK_TARGET'; |
|
33 | + const FIELD_POSTBACK_PARAMETER = 'PRADO_POSTBACK_PARAMETER'; |
|
34 | + const FIELD_LASTFOCUS = 'PRADO_LASTFOCUS'; |
|
35 | + const FIELD_PAGESTATE = 'PRADO_PAGESTATE'; |
|
36 | + const FIELD_CALLBACK_TARGET = 'PRADO_CALLBACK_TARGET'; |
|
37 | + const FIELD_CALLBACK_PARAMETER = 'PRADO_CALLBACK_PARAMETER'; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var array system post fields |
41 | 41 | */ |
42 | - private static $_systemPostFields=array( |
|
42 | + private static $_systemPostFields = array( |
|
43 | 43 | 'PRADO_POSTBACK_TARGET'=>true, |
44 | 44 | 'PRADO_POSTBACK_PARAMETER'=>true, |
45 | 45 | 'PRADO_LASTFOCUS'=>true, |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * @var array list of registered validators |
60 | 60 | */ |
61 | - private $_validators=array(); |
|
61 | + private $_validators = array(); |
|
62 | 62 | /** |
63 | 63 | * @var boolean if validation has been performed |
64 | 64 | */ |
65 | - private $_validated=false; |
|
65 | + private $_validated = false; |
|
66 | 66 | /** |
67 | 67 | * @var TTheme page theme |
68 | 68 | */ |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * @var array list of controls whose data have been changed due to the postback |
92 | 92 | */ |
93 | - protected $_controlsPostDataChanged=array(); |
|
93 | + protected $_controlsPostDataChanged = array(); |
|
94 | 94 | /** |
95 | 95 | * @var array list of controls that need to load post data in the current request |
96 | 96 | */ |
97 | - protected $_controlsRequiringPostData=array(); |
|
97 | + protected $_controlsRequiringPostData = array(); |
|
98 | 98 | /** |
99 | 99 | * @var array list of controls that need to load post data in the next postback |
100 | 100 | */ |
101 | - protected $_controlsRegisteredForPostData=array(); |
|
101 | + protected $_controlsRegisteredForPostData = array(); |
|
102 | 102 | /** |
103 | 103 | * @var TControl control that needs to raise postback event |
104 | 104 | */ |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | /** |
111 | 111 | * @var boolean whether the form has been rendered |
112 | 112 | */ |
113 | - protected $_formRendered=false; |
|
113 | + protected $_formRendered = false; |
|
114 | 114 | /** |
115 | 115 | * @var boolean whether the current rendering is within a form |
116 | 116 | */ |
117 | - protected $_inFormRender=false; |
|
117 | + protected $_inFormRender = false; |
|
118 | 118 | /** |
119 | 119 | * @var TControl|string the control or the ID of the element on the page to be focused when the page is sent back to user |
120 | 120 | */ |
@@ -122,24 +122,24 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * @var string page path to this page |
124 | 124 | */ |
125 | - private $_pagePath=''; |
|
125 | + private $_pagePath = ''; |
|
126 | 126 | /** |
127 | 127 | * @var boolean whether page state should be HMAC validated |
128 | 128 | */ |
129 | - private $_enableStateValidation=true; |
|
129 | + private $_enableStateValidation = true; |
|
130 | 130 | /** |
131 | 131 | * @var boolean whether page state should be encrypted |
132 | 132 | */ |
133 | - private $_enableStateEncryption=false; |
|
133 | + private $_enableStateEncryption = false; |
|
134 | 134 | /** |
135 | 135 | * @var boolean whether page state should be compressed |
136 | 136 | * @since 3.1.6 |
137 | 137 | */ |
138 | - private $_enableStateCompression=true; |
|
138 | + private $_enableStateCompression = true; |
|
139 | 139 | /** |
140 | 140 | * @var string page state persister class name |
141 | 141 | */ |
142 | - private $_statePersisterClass='System.Web.UI.TPageStatePersister'; |
|
142 | + private $_statePersisterClass = 'System.Web.UI.TPageStatePersister'; |
|
143 | 143 | /** |
144 | 144 | * @var mixed page state persister |
145 | 145 | */ |
@@ -151,15 +151,15 @@ discard block |
||
151 | 151 | /** |
152 | 152 | * @var string state string to be stored on the client side |
153 | 153 | */ |
154 | - private $_clientState=''; |
|
154 | + private $_clientState = ''; |
|
155 | 155 | /** |
156 | 156 | * @var boolean true if loading post data. |
157 | 157 | */ |
158 | - protected $_isLoadingPostData=false; |
|
158 | + protected $_isLoadingPostData = false; |
|
159 | 159 | /** |
160 | 160 | * @var boolean whether client supports javascript |
161 | 161 | */ |
162 | - private $_enableJavaScript=true; |
|
162 | + private $_enableJavaScript = true; |
|
163 | 163 | /** |
164 | 164 | * @var THtmlWriter current html render writer |
165 | 165 | */ |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function run($writer) |
183 | 183 | { |
184 | - Prado::trace("Running page life cycles",'System.Web.UI.TPage'); |
|
184 | + Prado::trace("Running page life cycles", 'System.Web.UI.TPage'); |
|
185 | 185 | $this->_writer = $writer; |
186 | 186 | |
187 | 187 | $this->determinePostBackMode(); |
188 | 188 | |
189 | - if($this->getIsPostBack()) |
|
189 | + if ($this->getIsPostBack()) |
|
190 | 190 | { |
191 | - if($this->getIsCallback()) |
|
191 | + if ($this->getIsCallback()) |
|
192 | 192 | $this->processCallbackRequest($writer); |
193 | 193 | else |
194 | 194 | $this->processPostBackRequest($writer); |
@@ -201,92 +201,92 @@ discard block |
||
201 | 201 | |
202 | 202 | protected function processNormalRequest($writer) |
203 | 203 | { |
204 | - Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
|
204 | + Prado::trace("Page onPreInit()", 'System.Web.UI.TPage'); |
|
205 | 205 | $this->onPreInit(null); |
206 | 206 | |
207 | - Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); |
|
207 | + Prado::trace("Page initRecursive()", 'System.Web.UI.TPage'); |
|
208 | 208 | $this->initRecursive(); |
209 | 209 | |
210 | - Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); |
|
210 | + Prado::trace("Page onInitComplete()", 'System.Web.UI.TPage'); |
|
211 | 211 | $this->onInitComplete(null); |
212 | 212 | |
213 | - Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); |
|
213 | + Prado::trace("Page onPreLoad()", 'System.Web.UI.TPage'); |
|
214 | 214 | $this->onPreLoad(null); |
215 | - Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); |
|
215 | + Prado::trace("Page loadRecursive()", 'System.Web.UI.TPage'); |
|
216 | 216 | $this->loadRecursive(); |
217 | - Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); |
|
217 | + Prado::trace("Page onLoadComplete()", 'System.Web.UI.TPage'); |
|
218 | 218 | $this->onLoadComplete(null); |
219 | 219 | |
220 | - Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); |
|
220 | + Prado::trace("Page preRenderRecursive()", 'System.Web.UI.TPage'); |
|
221 | 221 | $this->preRenderRecursive(); |
222 | - Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); |
|
222 | + Prado::trace("Page onPreRenderComplete()", 'System.Web.UI.TPage'); |
|
223 | 223 | $this->onPreRenderComplete(null); |
224 | 224 | |
225 | - Prado::trace("Page savePageState()",'System.Web.UI.TPage'); |
|
225 | + Prado::trace("Page savePageState()", 'System.Web.UI.TPage'); |
|
226 | 226 | $this->savePageState(); |
227 | - Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); |
|
227 | + Prado::trace("Page onSaveStateComplete()", 'System.Web.UI.TPage'); |
|
228 | 228 | $this->onSaveStateComplete(null); |
229 | 229 | |
230 | - Prado::trace("Page renderControl()",'System.Web.UI.TPage'); |
|
230 | + Prado::trace("Page renderControl()", 'System.Web.UI.TPage'); |
|
231 | 231 | $this->renderControl($writer); |
232 | - Prado::trace("Page unloadRecursive()",'System.Web.UI.TPage'); |
|
232 | + Prado::trace("Page unloadRecursive()", 'System.Web.UI.TPage'); |
|
233 | 233 | $this->unloadRecursive(); |
234 | 234 | } |
235 | 235 | |
236 | 236 | protected function processPostBackRequest($writer) |
237 | 237 | { |
238 | - Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
|
238 | + Prado::trace("Page onPreInit()", 'System.Web.UI.TPage'); |
|
239 | 239 | $this->onPreInit(null); |
240 | 240 | |
241 | - Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); |
|
241 | + Prado::trace("Page initRecursive()", 'System.Web.UI.TPage'); |
|
242 | 242 | $this->initRecursive(); |
243 | 243 | |
244 | - Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); |
|
244 | + Prado::trace("Page onInitComplete()", 'System.Web.UI.TPage'); |
|
245 | 245 | $this->onInitComplete(null); |
246 | 246 | |
247 | - $this->_restPostData=new TMap; |
|
248 | - Prado::trace("Page loadPageState()",'System.Web.UI.TPage'); |
|
247 | + $this->_restPostData = new TMap; |
|
248 | + Prado::trace("Page loadPageState()", 'System.Web.UI.TPage'); |
|
249 | 249 | $this->loadPageState(); |
250 | - Prado::trace("Page processPostData()",'System.Web.UI.TPage'); |
|
251 | - $this->processPostData($this->_postData,true); |
|
252 | - Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); |
|
250 | + Prado::trace("Page processPostData()", 'System.Web.UI.TPage'); |
|
251 | + $this->processPostData($this->_postData, true); |
|
252 | + Prado::trace("Page onPreLoad()", 'System.Web.UI.TPage'); |
|
253 | 253 | $this->onPreLoad(null); |
254 | - Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); |
|
254 | + Prado::trace("Page loadRecursive()", 'System.Web.UI.TPage'); |
|
255 | 255 | $this->loadRecursive(); |
256 | - Prado::trace("Page processPostData()",'System.Web.UI.TPage'); |
|
257 | - $this->processPostData($this->_restPostData,false); |
|
258 | - Prado::trace("Page raiseChangedEvents()",'System.Web.UI.TPage'); |
|
256 | + Prado::trace("Page processPostData()", 'System.Web.UI.TPage'); |
|
257 | + $this->processPostData($this->_restPostData, false); |
|
258 | + Prado::trace("Page raiseChangedEvents()", 'System.Web.UI.TPage'); |
|
259 | 259 | $this->raiseChangedEvents(); |
260 | - Prado::trace("Page raisePostBackEvent()",'System.Web.UI.TPage'); |
|
260 | + Prado::trace("Page raisePostBackEvent()", 'System.Web.UI.TPage'); |
|
261 | 261 | $this->raisePostBackEvent(); |
262 | - Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); |
|
262 | + Prado::trace("Page onLoadComplete()", 'System.Web.UI.TPage'); |
|
263 | 263 | $this->onLoadComplete(null); |
264 | 264 | |
265 | - Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); |
|
265 | + Prado::trace("Page preRenderRecursive()", 'System.Web.UI.TPage'); |
|
266 | 266 | $this->preRenderRecursive(); |
267 | - Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); |
|
267 | + Prado::trace("Page onPreRenderComplete()", 'System.Web.UI.TPage'); |
|
268 | 268 | $this->onPreRenderComplete(null); |
269 | 269 | |
270 | - Prado::trace("Page savePageState()",'System.Web.UI.TPage'); |
|
270 | + Prado::trace("Page savePageState()", 'System.Web.UI.TPage'); |
|
271 | 271 | $this->savePageState(); |
272 | - Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); |
|
272 | + Prado::trace("Page onSaveStateComplete()", 'System.Web.UI.TPage'); |
|
273 | 273 | $this->onSaveStateComplete(null); |
274 | 274 | |
275 | - Prado::trace("Page renderControl()",'System.Web.UI.TPage'); |
|
275 | + Prado::trace("Page renderControl()", 'System.Web.UI.TPage'); |
|
276 | 276 | $this->renderControl($writer); |
277 | - Prado::trace("Page unloadRecursive()",'System.Web.UI.TPage'); |
|
277 | + Prado::trace("Page unloadRecursive()", 'System.Web.UI.TPage'); |
|
278 | 278 | $this->unloadRecursive(); |
279 | 279 | } |
280 | 280 | |
281 | 281 | protected static function decodeUTF8($data, $enc) |
282 | 282 | { |
283 | - if(is_array($data)) |
|
283 | + if (is_array($data)) |
|
284 | 284 | { |
285 | - foreach($data as $k=>$v) |
|
286 | - $data[$k]=self::decodeUTF8($v, $enc); |
|
285 | + foreach ($data as $k=>$v) |
|
286 | + $data[$k] = self::decodeUTF8($v, $enc); |
|
287 | 287 | return $data; |
288 | - } elseif(is_string($data)) { |
|
289 | - return iconv('UTF-8',$enc.'//IGNORE',$data); |
|
288 | + } elseif (is_string($data)) { |
|
289 | + return iconv('UTF-8', $enc . '//IGNORE', $data); |
|
290 | 290 | } else { |
291 | 291 | return $data; |
292 | 292 | } |
@@ -304,38 +304,38 @@ discard block |
||
304 | 304 | $this->setAdapter(new TActivePageAdapter($this)); |
305 | 305 | |
306 | 306 | $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
307 | - if(strlen($callbackEventParameter) > 0) |
|
308 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
307 | + if (strlen($callbackEventParameter) > 0) |
|
308 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string) $callbackEventParameter); |
|
309 | 309 | |
310 | 310 | // Decode Callback postData from UTF-8 to current Charset |
311 | - if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
312 | - strtoupper($enc=$g->getCharset())!='UTF-8') |
|
311 | + if (($g = $this->getApplication()->getGlobalization(false)) !== null && |
|
312 | + strtoupper($enc = $g->getCharset()) != 'UTF-8') |
|
313 | 313 | foreach ($this->_postData as $k=>$v) |
314 | - $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
314 | + $this->_postData[$k] = self::decodeUTF8($v, $enc); |
|
315 | 315 | |
316 | - Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
|
316 | + Prado::trace("Page onPreInit()", 'System.Web.UI.TPage'); |
|
317 | 317 | $this->onPreInit(null); |
318 | 318 | |
319 | - Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); |
|
319 | + Prado::trace("Page initRecursive()", 'System.Web.UI.TPage'); |
|
320 | 320 | $this->initRecursive(); |
321 | 321 | |
322 | - Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); |
|
322 | + Prado::trace("Page onInitComplete()", 'System.Web.UI.TPage'); |
|
323 | 323 | $this->onInitComplete(null); |
324 | 324 | |
325 | - $this->_restPostData=new TMap; |
|
326 | - Prado::trace("Page loadPageState()",'System.Web.UI.TPage'); |
|
325 | + $this->_restPostData = new TMap; |
|
326 | + Prado::trace("Page loadPageState()", 'System.Web.UI.TPage'); |
|
327 | 327 | $this->loadPageState(); |
328 | - Prado::trace("Page processPostData()",'System.Web.UI.TPage'); |
|
329 | - $this->processPostData($this->_postData,true); |
|
330 | - Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); |
|
328 | + Prado::trace("Page processPostData()", 'System.Web.UI.TPage'); |
|
329 | + $this->processPostData($this->_postData, true); |
|
330 | + Prado::trace("Page onPreLoad()", 'System.Web.UI.TPage'); |
|
331 | 331 | $this->onPreLoad(null); |
332 | - Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); |
|
332 | + Prado::trace("Page loadRecursive()", 'System.Web.UI.TPage'); |
|
333 | 333 | $this->loadRecursive(); |
334 | 334 | |
335 | - Prado::trace("Page processPostData()",'System.Web.UI.TPage'); |
|
336 | - $this->processPostData($this->_restPostData,false); |
|
335 | + Prado::trace("Page processPostData()", 'System.Web.UI.TPage'); |
|
336 | + $this->processPostData($this->_restPostData, false); |
|
337 | 337 | |
338 | - Prado::trace("Page raiseChangedEvents()",'System.Web.UI.TPage'); |
|
338 | + Prado::trace("Page raiseChangedEvents()", 'System.Web.UI.TPage'); |
|
339 | 339 | $this->raiseChangedEvents(); |
340 | 340 | |
341 | 341 | |
@@ -345,17 +345,17 @@ discard block |
||
345 | 345 | Prado::trace("Page raisePostBackEvent()",'System.Web.UI.TPage'); |
346 | 346 | $this->raisePostBackEvent(); |
347 | 347 | */ |
348 | - Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); |
|
348 | + Prado::trace("Page onLoadComplete()", 'System.Web.UI.TPage'); |
|
349 | 349 | $this->onLoadComplete(null); |
350 | 350 | |
351 | - Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); |
|
351 | + Prado::trace("Page preRenderRecursive()", 'System.Web.UI.TPage'); |
|
352 | 352 | $this->preRenderRecursive(); |
353 | - Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); |
|
353 | + Prado::trace("Page onPreRenderComplete()", 'System.Web.UI.TPage'); |
|
354 | 354 | $this->onPreRenderComplete(null); |
355 | 355 | |
356 | - Prado::trace("Page savePageState()",'System.Web.UI.TPage'); |
|
356 | + Prado::trace("Page savePageState()", 'System.Web.UI.TPage'); |
|
357 | 357 | $this->savePageState(); |
358 | - Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); |
|
358 | + Prado::trace("Page onSaveStateComplete()", 'System.Web.UI.TPage'); |
|
359 | 359 | $this->onSaveStateComplete(null); |
360 | 360 | |
361 | 361 | /* |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | $this->getAdapter()->renderCallbackResponse($writer); |
366 | 366 | |
367 | - Prado::trace("Page unloadRecursive()",'System.Web.UI.TPage'); |
|
367 | + Prado::trace("Page unloadRecursive()", 'System.Web.UI.TPage'); |
|
368 | 368 | $this->unloadRecursive(); |
369 | 369 | } |
370 | 370 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function getCallbackClient() |
377 | 377 | { |
378 | - if($this->getAdapter() !== null) |
|
378 | + if ($this->getAdapter() !== null) |
|
379 | 379 | return $this->getAdapter()->getCallbackClientHandler(); |
380 | 380 | else |
381 | 381 | return new TCallbackClientScript(); |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function setForm(TForm $form) |
443 | 443 | { |
444 | - if($this->_form===null) |
|
445 | - $this->_form=$form; |
|
444 | + if ($this->_form === null) |
|
445 | + $this->_form = $form; |
|
446 | 446 | else |
447 | 447 | throw new TInvalidOperationException('page_form_duplicated'); |
448 | 448 | } |
@@ -453,17 +453,17 @@ discard block |
||
453 | 453 | * @param string validation group |
454 | 454 | * @return TList registered validators in the requested group. If the group is null, all validators will be returned. |
455 | 455 | */ |
456 | - public function getValidators($validationGroup=null) |
|
456 | + public function getValidators($validationGroup = null) |
|
457 | 457 | { |
458 | - if(!$this->_validators) |
|
459 | - $this->_validators=new TList; |
|
460 | - if(empty($validationGroup) === true) |
|
458 | + if (!$this->_validators) |
|
459 | + $this->_validators = new TList; |
|
460 | + if (empty($validationGroup) === true) |
|
461 | 461 | return $this->_validators; |
462 | 462 | else |
463 | 463 | { |
464 | - $list=new TList; |
|
465 | - foreach($this->_validators as $validator) |
|
466 | - if($validator->getValidationGroup()===$validationGroup) |
|
464 | + $list = new TList; |
|
465 | + foreach ($this->_validators as $validator) |
|
466 | + if ($validator->getValidationGroup() === $validationGroup) |
|
467 | 467 | $list->add($validator); |
468 | 468 | return $list; |
469 | 469 | } |
@@ -475,22 +475,22 @@ discard block |
||
475 | 475 | * If validation group is specified, only the validators in that group will be invoked. |
476 | 476 | * @param string validation group. If null, all validators will perform validation. |
477 | 477 | */ |
478 | - public function validate($validationGroup=null) |
|
478 | + public function validate($validationGroup = null) |
|
479 | 479 | { |
480 | - Prado::trace("Page validate()",'System.Web.UI.TPage'); |
|
481 | - $this->_validated=true; |
|
482 | - if($this->_validators && $this->_validators->getCount()) |
|
480 | + Prado::trace("Page validate()", 'System.Web.UI.TPage'); |
|
481 | + $this->_validated = true; |
|
482 | + if ($this->_validators && $this->_validators->getCount()) |
|
483 | 483 | { |
484 | - if($validationGroup===null) |
|
484 | + if ($validationGroup === null) |
|
485 | 485 | { |
486 | - foreach($this->_validators as $validator) |
|
486 | + foreach ($this->_validators as $validator) |
|
487 | 487 | $validator->validate(); |
488 | 488 | } |
489 | 489 | else |
490 | 490 | { |
491 | - foreach($this->_validators as $validator) |
|
491 | + foreach ($this->_validators as $validator) |
|
492 | 492 | { |
493 | - if($validator->getValidationGroup()===$validationGroup) |
|
493 | + if ($validator->getValidationGroup() === $validationGroup) |
|
494 | 494 | $validator->validate(); |
495 | 495 | } |
496 | 496 | } |
@@ -505,12 +505,12 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public function getIsValid() |
507 | 507 | { |
508 | - if($this->_validated) |
|
508 | + if ($this->_validated) |
|
509 | 509 | { |
510 | - if($this->_validators && $this->_validators->getCount()) |
|
510 | + if ($this->_validators && $this->_validators->getCount()) |
|
511 | 511 | { |
512 | - foreach($this->_validators as $validator) |
|
513 | - if(!$validator->getIsValid()) |
|
512 | + foreach ($this->_validators as $validator) |
|
513 | + if (!$validator->getIsValid()) |
|
514 | 514 | return false; |
515 | 515 | } |
516 | 516 | return true; |
@@ -524,8 +524,8 @@ discard block |
||
524 | 524 | */ |
525 | 525 | public function getTheme() |
526 | 526 | { |
527 | - if(is_string($this->_theme)) |
|
528 | - $this->_theme=$this->getService()->getThemeManager()->getTheme($this->_theme); |
|
527 | + if (is_string($this->_theme)) |
|
528 | + $this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme); |
|
529 | 529 | return $this->_theme; |
530 | 530 | } |
531 | 531 | |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | */ |
536 | 536 | public function setTheme($value) |
537 | 537 | { |
538 | - $this->_theme=empty($value)?null:$value; |
|
538 | + $this->_theme = empty($value) ? null : $value; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public function getStyleSheetTheme() |
546 | 546 | { |
547 | - if(is_string($this->_styleSheet)) |
|
548 | - $this->_styleSheet=$this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
547 | + if (is_string($this->_styleSheet)) |
|
548 | + $this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
549 | 549 | return $this->_styleSheet; |
550 | 550 | } |
551 | 551 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | */ |
556 | 556 | public function setStyleSheetTheme($value) |
557 | 557 | { |
558 | - $this->_styleSheet=empty($value)?null:$value; |
|
558 | + $this->_styleSheet = empty($value) ? null : $value; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | */ |
566 | 566 | public function applyControlSkin($control) |
567 | 567 | { |
568 | - if(($theme=$this->getTheme())!==null) |
|
568 | + if (($theme = $this->getTheme()) !== null) |
|
569 | 569 | $theme->applySkin($control); |
570 | 570 | } |
571 | 571 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | */ |
577 | 577 | public function applyControlStyleSheet($control) |
578 | 578 | { |
579 | - if(($theme=$this->getStyleSheetTheme())!==null) |
|
579 | + if (($theme = $this->getStyleSheetTheme()) !== null) |
|
580 | 580 | $theme->applySkin($control); |
581 | 581 | } |
582 | 582 | |
@@ -585,16 +585,16 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function getClientScript() |
587 | 587 | { |
588 | - if(!$this->_clientScript) { |
|
588 | + if (!$this->_clientScript) { |
|
589 | 589 | $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
590 | 590 | Prado::using($className); |
591 | - if(($pos=strrpos($className,'.'))!==false) |
|
592 | - $className=substr($className,$pos+1); |
|
591 | + if (($pos = strrpos($className, '.')) !== false) |
|
592 | + $className = substr($className, $pos + 1); |
|
593 | 593 | |
594 | - if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager'))) |
|
595 | - throw new THttpException(404,'page_csmanagerclass_invalid',$classPath); |
|
594 | + if (!class_exists($className, false) || ($className !== 'TClientScriptManager' && !is_subclass_of($className, 'TClientScriptManager'))) |
|
595 | + throw new THttpException(404, 'page_csmanagerclass_invalid', $classPath); |
|
596 | 596 | |
597 | - $this->_clientScript=new $className($this); |
|
597 | + $this->_clientScript = new $className($this); |
|
598 | 598 | } |
599 | 599 | return $this->_clientScript; |
600 | 600 | } |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | */ |
611 | 611 | public function onPreInit($param) |
612 | 612 | { |
613 | - $this->raiseEvent('OnPreInit',$this,$param); |
|
613 | + $this->raiseEvent('OnPreInit', $this, $param); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | */ |
624 | 624 | public function onInitComplete($param) |
625 | 625 | { |
626 | - $this->raiseEvent('OnInitComplete',$this,$param); |
|
626 | + $this->raiseEvent('OnInitComplete', $this, $param); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | /** |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | */ |
637 | 637 | public function onPreLoad($param) |
638 | 638 | { |
639 | - $this->raiseEvent('OnPreLoad',$this,$param); |
|
639 | + $this->raiseEvent('OnPreLoad', $this, $param); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | public function onLoadComplete($param) |
651 | 651 | { |
652 | - $this->raiseEvent('OnLoadComplete',$this,$param); |
|
652 | + $this->raiseEvent('OnLoadComplete', $this, $param); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -662,26 +662,26 @@ discard block |
||
662 | 662 | */ |
663 | 663 | public function onPreRenderComplete($param) |
664 | 664 | { |
665 | - $this->raiseEvent('OnPreRenderComplete',$this,$param); |
|
666 | - $cs=$this->getClientScript(); |
|
667 | - $theme=$this->getTheme(); |
|
668 | - if($theme instanceof ITheme) |
|
665 | + $this->raiseEvent('OnPreRenderComplete', $this, $param); |
|
666 | + $cs = $this->getClientScript(); |
|
667 | + $theme = $this->getTheme(); |
|
668 | + if ($theme instanceof ITheme) |
|
669 | 669 | { |
670 | - foreach($theme->getStyleSheetFiles() as $url) |
|
671 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
672 | - foreach($theme->getJavaScriptFiles() as $url) |
|
673 | - $cs->registerHeadScriptFile($url,$url); |
|
670 | + foreach ($theme->getStyleSheetFiles() as $url) |
|
671 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
672 | + foreach ($theme->getJavaScriptFiles() as $url) |
|
673 | + $cs->registerHeadScriptFile($url, $url); |
|
674 | 674 | } |
675 | - $styleSheet=$this->getStyleSheetTheme(); |
|
676 | - if($styleSheet instanceof ITheme) |
|
675 | + $styleSheet = $this->getStyleSheetTheme(); |
|
676 | + if ($styleSheet instanceof ITheme) |
|
677 | 677 | { |
678 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
679 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
680 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
681 | - $cs->registerHeadScriptFile($url,$url); |
|
678 | + foreach ($styleSheet->getStyleSheetFiles() as $url) |
|
679 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
680 | + foreach ($styleSheet->getJavaScriptFiles() as $url) |
|
681 | + $cs->registerHeadScriptFile($url, $url); |
|
682 | 682 | } |
683 | 683 | |
684 | - if($cs->getRequiresHead() && $this->getHead()===null) |
|
684 | + if ($cs->getRequiresHead() && $this->getHead() === null) |
|
685 | 685 | throw new TConfigurationException('page_head_required'); |
686 | 686 | } |
687 | 687 | |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | */ |
696 | 696 | private function getCssMediaType($url) |
697 | 697 | { |
698 | - $segs=explode('.',basename($url)); |
|
699 | - if(isset($segs[2])) |
|
700 | - return $segs[count($segs)-2]; |
|
698 | + $segs = explode('.', basename($url)); |
|
699 | + if (isset($segs[2])) |
|
700 | + return $segs[count($segs) - 2]; |
|
701 | 701 | else |
702 | 702 | return ''; |
703 | 703 | } |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | */ |
712 | 712 | public function onSaveStateComplete($param) |
713 | 713 | { |
714 | - $this->raiseEvent('OnSaveStateComplete',$this,$param); |
|
714 | + $this->raiseEvent('OnSaveStateComplete', $this, $param); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -720,9 +720,9 @@ discard block |
||
720 | 720 | */ |
721 | 721 | private function determinePostBackMode() |
722 | 722 | { |
723 | - $postData=$this->getRequest(); |
|
724 | - if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
725 | - $this->_postData=$postData; |
|
723 | + $postData = $this->getRequest(); |
|
724 | + if ($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
725 | + $this->_postData = $postData; |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | */ |
731 | 731 | public function getIsPostBack() |
732 | 732 | { |
733 | - return $this->_postData!==null; |
|
733 | + return $this->_postData !== null; |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | /** |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | public function saveState() |
750 | 750 | { |
751 | 751 | parent::saveState(); |
752 | - $this->setViewState('ControlsRequiringPostBack',$this->_controlsRegisteredForPostData,array()); |
|
752 | + $this->setViewState('ControlsRequiringPostBack', $this->_controlsRegisteredForPostData, array()); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | public function loadState() |
761 | 761 | { |
762 | 762 | parent::loadState(); |
763 | - $this->_controlsRequiringPostData=$this->getViewState('ControlsRequiringPostBack',array()); |
|
763 | + $this->_controlsRequiringPostData = $this->getViewState('ControlsRequiringPostBack', array()); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | */ |
769 | 769 | protected function loadPageState() |
770 | 770 | { |
771 | - Prado::trace("Loading state",'System.Web.UI.TPage'); |
|
772 | - $state=$this->getStatePersister()->load(); |
|
773 | - $this->loadStateRecursive($state,$this->getEnableViewState()); |
|
771 | + Prado::trace("Loading state", 'System.Web.UI.TPage'); |
|
772 | + $state = $this->getStatePersister()->load(); |
|
773 | + $this->loadStateRecursive($state, $this->getEnableViewState()); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | /** |
@@ -778,8 +778,8 @@ discard block |
||
778 | 778 | */ |
779 | 779 | protected function savePageState() |
780 | 780 | { |
781 | - Prado::trace("Saving state",'System.Web.UI.TPage'); |
|
782 | - $state=&$this->saveStateRecursive($this->getEnableViewState()); |
|
781 | + Prado::trace("Saving state", 'System.Web.UI.TPage'); |
|
782 | + $state = &$this->saveStateRecursive($this->getEnableViewState()); |
|
783 | 783 | $this->getStatePersister()->save($state); |
784 | 784 | } |
785 | 785 | |
@@ -801,11 +801,11 @@ discard block |
||
801 | 801 | */ |
802 | 802 | public function registerRequiresPostData($control) |
803 | 803 | { |
804 | - $id=is_string($control)?$control:$control->getUniqueID(); |
|
805 | - $this->_controlsRegisteredForPostData[$id]=true; |
|
806 | - $params=func_get_args(); |
|
807 | - foreach($this->getCachingStack() as $item) |
|
808 | - $item->registerAction('Page','registerRequiresPostData',array($id)); |
|
804 | + $id = is_string($control) ? $control : $control->getUniqueID(); |
|
805 | + $this->_controlsRegisteredForPostData[$id] = true; |
|
806 | + $params = func_get_args(); |
|
807 | + foreach ($this->getCachingStack() as $item) |
|
808 | + $item->registerAction('Page', 'registerRequiresPostData', array($id)); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -813,11 +813,11 @@ discard block |
||
813 | 813 | */ |
814 | 814 | public function getPostBackEventTarget() |
815 | 815 | { |
816 | - if($this->_postBackEventTarget===null && $this->_postData!==null) |
|
816 | + if ($this->_postBackEventTarget === null && $this->_postData !== null) |
|
817 | 817 | { |
818 | - $eventTarget=$this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
|
819 | - if(!empty($eventTarget)) |
|
820 | - $this->_postBackEventTarget=$this->findControl($eventTarget); |
|
818 | + $eventTarget = $this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
|
819 | + if (!empty($eventTarget)) |
|
820 | + $this->_postBackEventTarget = $this->findControl($eventTarget); |
|
821 | 821 | } |
822 | 822 | return $this->_postBackEventTarget; |
823 | 823 | } |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | */ |
829 | 829 | public function setPostBackEventTarget(TControl $control) |
830 | 830 | { |
831 | - $this->_postBackEventTarget=$control; |
|
831 | + $this->_postBackEventTarget = $control; |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | /** |
@@ -836,10 +836,10 @@ discard block |
||
836 | 836 | */ |
837 | 837 | public function getPostBackEventParameter() |
838 | 838 | { |
839 | - if($this->_postBackEventParameter===null && $this->_postData!==null) |
|
839 | + if ($this->_postBackEventParameter === null && $this->_postData !== null) |
|
840 | 840 | { |
841 | - if(($this->_postBackEventParameter=$this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER))===null) |
|
842 | - $this->_postBackEventParameter=''; |
|
841 | + if (($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null) |
|
842 | + $this->_postBackEventParameter = ''; |
|
843 | 843 | } |
844 | 844 | return $this->_postBackEventParameter; |
845 | 845 | } |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | */ |
850 | 850 | public function setPostBackEventParameter($value) |
851 | 851 | { |
852 | - $this->_postBackEventParameter=$value; |
|
852 | + $this->_postBackEventParameter = $value; |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -857,48 +857,48 @@ discard block |
||
857 | 857 | * @param TMap post data to be processed |
858 | 858 | * @param boolean whether this method is invoked before {@link onLoad OnLoad}. |
859 | 859 | */ |
860 | - protected function processPostData($postData,$beforeLoad) |
|
860 | + protected function processPostData($postData, $beforeLoad) |
|
861 | 861 | { |
862 | - $this->_isLoadingPostData=true; |
|
863 | - if($beforeLoad) |
|
864 | - $this->_restPostData=new TMap; |
|
865 | - foreach($postData as $key=>$value) |
|
862 | + $this->_isLoadingPostData = true; |
|
863 | + if ($beforeLoad) |
|
864 | + $this->_restPostData = new TMap; |
|
865 | + foreach ($postData as $key=>$value) |
|
866 | 866 | { |
867 | - if($this->isSystemPostField($key)) |
|
867 | + if ($this->isSystemPostField($key)) |
|
868 | 868 | continue; |
869 | - else if($control=$this->findControl($key)) |
|
869 | + else if ($control = $this->findControl($key)) |
|
870 | 870 | { |
871 | - if($control instanceof IPostBackDataHandler) |
|
871 | + if ($control instanceof IPostBackDataHandler) |
|
872 | 872 | { |
873 | - if($control->loadPostData($key,$postData)) |
|
874 | - $this->_controlsPostDataChanged[]=$control; |
|
873 | + if ($control->loadPostData($key, $postData)) |
|
874 | + $this->_controlsPostDataChanged[] = $control; |
|
875 | 875 | } |
876 | - else if($control instanceof IPostBackEventHandler && |
|
876 | + else if ($control instanceof IPostBackEventHandler && |
|
877 | 877 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
878 | 878 | { |
879 | - $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); // not calling setPostBackEventTarget() because the control may be removed later |
|
879 | + $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
|
880 | 880 | } |
881 | 881 | unset($this->_controlsRequiringPostData[$key]); |
882 | 882 | } |
883 | - else if($beforeLoad) |
|
884 | - $this->_restPostData->add($key,$value); |
|
883 | + else if ($beforeLoad) |
|
884 | + $this->_restPostData->add($key, $value); |
|
885 | 885 | } |
886 | 886 | |
887 | - foreach($this->_controlsRequiringPostData as $key=>$value) |
|
887 | + foreach ($this->_controlsRequiringPostData as $key=>$value) |
|
888 | 888 | { |
889 | - if($control=$this->findControl($key)) |
|
889 | + if ($control = $this->findControl($key)) |
|
890 | 890 | { |
891 | - if($control instanceof IPostBackDataHandler) |
|
891 | + if ($control instanceof IPostBackDataHandler) |
|
892 | 892 | { |
893 | - if($control->loadPostData($key,$this->_postData)) |
|
894 | - $this->_controlsPostDataChanged[]=$control; |
|
893 | + if ($control->loadPostData($key, $this->_postData)) |
|
894 | + $this->_controlsPostDataChanged[] = $control; |
|
895 | 895 | } |
896 | 896 | else |
897 | - throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key); |
|
897 | + throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
|
898 | 898 | unset($this->_controlsRequiringPostData[$key]); |
899 | 899 | } |
900 | 900 | } |
901 | - $this->_isLoadingPostData=false; |
|
901 | + $this->_isLoadingPostData = false; |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | /** |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | */ |
915 | 915 | protected function raiseChangedEvents() |
916 | 916 | { |
917 | - foreach($this->_controlsPostDataChanged as $control) |
|
917 | + foreach ($this->_controlsPostDataChanged as $control) |
|
918 | 918 | $control->raisePostDataChangedEvent(); |
919 | 919 | } |
920 | 920 | |
@@ -923,9 +923,9 @@ discard block |
||
923 | 923 | */ |
924 | 924 | protected function raisePostBackEvent() |
925 | 925 | { |
926 | - if(($postBackHandler=$this->getPostBackEventTarget())===null) |
|
926 | + if (($postBackHandler = $this->getPostBackEventTarget()) === null) |
|
927 | 927 | $this->validate(); |
928 | - else if($postBackHandler instanceof IPostBackEventHandler) |
|
928 | + else if ($postBackHandler instanceof IPostBackEventHandler) |
|
929 | 929 | $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
930 | 930 | } |
931 | 931 | |
@@ -944,8 +944,8 @@ discard block |
||
944 | 944 | */ |
945 | 945 | public function ensureRenderInForm($control) |
946 | 946 | { |
947 | - if(!$this->getIsCallback() && !$this->_inFormRender) |
|
948 | - throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null); |
|
947 | + if (!$this->getIsCallback() && !$this->_inFormRender) |
|
948 | + throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
@@ -953,11 +953,11 @@ discard block |
||
953 | 953 | */ |
954 | 954 | public function beginFormRender($writer) |
955 | 955 | { |
956 | - if($this->_formRendered) |
|
956 | + if ($this->_formRendered) |
|
957 | 957 | throw new TConfigurationException('page_form_duplicated'); |
958 | - $this->_formRendered=true; |
|
959 | - $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE,$this->getClientState()); |
|
960 | - $this->_inFormRender=true; |
|
958 | + $this->_formRendered = true; |
|
959 | + $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState()); |
|
960 | + $this->_inFormRender = true; |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | /** |
@@ -965,17 +965,17 @@ discard block |
||
965 | 965 | */ |
966 | 966 | public function endFormRender($writer) |
967 | 967 | { |
968 | - if($this->_focus) |
|
968 | + if ($this->_focus) |
|
969 | 969 | { |
970 | - if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
971 | - $focus=$this->_focus->getClientID(); |
|
970 | + if (($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
971 | + $focus = $this->_focus->getClientID(); |
|
972 | 972 | else |
973 | - $focus=$this->_focus; |
|
973 | + $focus = $this->_focus; |
|
974 | 974 | $this->getClientScript()->registerFocusControl($focus); |
975 | 975 | } |
976 | - else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) |
|
976 | + else if ($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null) |
|
977 | 977 | $this->getClientScript()->registerFocusControl($lastFocus); |
978 | - $this->_inFormRender=false; |
|
978 | + $this->_inFormRender = false; |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | /** |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | */ |
985 | 985 | public function setFocus($value) |
986 | 986 | { |
987 | - $this->_focus=$value; |
|
987 | + $this->_focus = $value; |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | /** |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | */ |
1001 | 1001 | public function setClientSupportsJavaScript($value) |
1002 | 1002 | { |
1003 | - $this->_enableJavaScript=TPropertyValue::ensureBoolean($value); |
|
1003 | + $this->_enableJavaScript = TPropertyValue::ensureBoolean($value); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /** |
@@ -1017,13 +1017,13 @@ discard block |
||
1017 | 1017 | */ |
1018 | 1018 | public function setHead(THead $value) |
1019 | 1019 | { |
1020 | - if($this->_head) |
|
1020 | + if ($this->_head) |
|
1021 | 1021 | throw new TInvalidOperationException('page_head_duplicated'); |
1022 | - $this->_head=$value; |
|
1023 | - if($this->_title!==null) |
|
1022 | + $this->_head = $value; |
|
1023 | + if ($this->_title !== null) |
|
1024 | 1024 | { |
1025 | 1025 | $this->_head->setTitle($this->_title); |
1026 | - $this->_title=null; |
|
1026 | + $this->_title = null; |
|
1027 | 1027 | } |
1028 | 1028 | } |
1029 | 1029 | |
@@ -1032,10 +1032,10 @@ discard block |
||
1032 | 1032 | */ |
1033 | 1033 | public function getTitle() |
1034 | 1034 | { |
1035 | - if($this->_head) |
|
1035 | + if ($this->_head) |
|
1036 | 1036 | return $this->_head->getTitle(); |
1037 | 1037 | else |
1038 | - return $this->_title===null ? '' : $this->_title; |
|
1038 | + return $this->_title === null ? '' : $this->_title; |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | /** |
@@ -1046,10 +1046,10 @@ discard block |
||
1046 | 1046 | */ |
1047 | 1047 | public function setTitle($value) |
1048 | 1048 | { |
1049 | - if($this->_head) |
|
1049 | + if ($this->_head) |
|
1050 | 1050 | $this->_head->setTitle($value); |
1051 | 1051 | else |
1052 | - $this->_title=$value; |
|
1052 | + $this->_title = $value; |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | /** |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | */ |
1070 | 1070 | public function setClientState($state) |
1071 | 1071 | { |
1072 | - $this->_clientState=$state; |
|
1072 | + $this->_clientState = $state; |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | /** |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | */ |
1094 | 1094 | public function setStatePersisterClass($value) |
1095 | 1095 | { |
1096 | - $this->_statePersisterClass=$value; |
|
1096 | + $this->_statePersisterClass = $value; |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | 1099 | /** |
@@ -1101,10 +1101,10 @@ discard block |
||
1101 | 1101 | */ |
1102 | 1102 | public function getStatePersister() |
1103 | 1103 | { |
1104 | - if($this->_statePersister===null) |
|
1104 | + if ($this->_statePersister === null) |
|
1105 | 1105 | { |
1106 | - $this->_statePersister=Prado::createComponent($this->_statePersisterClass); |
|
1107 | - if(!($this->_statePersister instanceof IPageStatePersister)) |
|
1106 | + $this->_statePersister = Prado::createComponent($this->_statePersisterClass); |
|
1107 | + if (!($this->_statePersister instanceof IPageStatePersister)) |
|
1108 | 1108 | throw new TInvalidDataTypeException('page_statepersister_invalid'); |
1109 | 1109 | $this->_statePersister->setPage($this); |
1110 | 1110 | } |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | */ |
1125 | 1125 | public function setEnableStateValidation($value) |
1126 | 1126 | { |
1127 | - $this->_enableStateValidation=TPropertyValue::ensureBoolean($value); |
|
1127 | + $this->_enableStateValidation = TPropertyValue::ensureBoolean($value); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | /** |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | */ |
1141 | 1141 | public function setEnableStateEncryption($value) |
1142 | 1142 | { |
1143 | - $this->_enableStateEncryption=TPropertyValue::ensureBoolean($value); |
|
1143 | + $this->_enableStateEncryption = TPropertyValue::ensureBoolean($value); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | /** |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | */ |
1159 | 1159 | public function setEnableStateCompression($value) |
1160 | 1160 | { |
1161 | - $this->_enableStateCompression=TPropertyValue::ensureBoolean($value); |
|
1161 | + $this->_enableStateCompression = TPropertyValue::ensureBoolean($value); |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | /** |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | */ |
1175 | 1175 | public function setPagePath($value) |
1176 | 1176 | { |
1177 | - $this->_pagePath=$value; |
|
1177 | + $this->_pagePath = $value; |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | /** |
@@ -1186,12 +1186,12 @@ discard block |
||
1186 | 1186 | * @param string method name of the context object |
1187 | 1187 | * @param array list of parameters to be passed to the action method |
1188 | 1188 | */ |
1189 | - public function registerCachingAction($context,$funcName,$funcParams) |
|
1189 | + public function registerCachingAction($context, $funcName, $funcParams) |
|
1190 | 1190 | { |
1191 | - if($this->_cachingStack) |
|
1191 | + if ($this->_cachingStack) |
|
1192 | 1192 | { |
1193 | - foreach($this->_cachingStack as $cache) |
|
1194 | - $cache->registerAction($context,$funcName,$funcParams); |
|
1193 | + foreach ($this->_cachingStack as $cache) |
|
1194 | + $cache->registerAction($context, $funcName, $funcParams); |
|
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1200,8 +1200,8 @@ discard block |
||
1200 | 1200 | */ |
1201 | 1201 | public function getCachingStack() |
1202 | 1202 | { |
1203 | - if(!$this->_cachingStack) |
|
1204 | - $this->_cachingStack=new TStack; |
|
1203 | + if (!$this->_cachingStack) |
|
1204 | + $this->_cachingStack = new TStack; |
|
1205 | 1205 | return $this->_cachingStack; |
1206 | 1206 | } |
1207 | 1207 | |
@@ -1274,17 +1274,17 @@ discard block |
||
1274 | 1274 | * @param mixed state data |
1275 | 1275 | * @return string serialized data |
1276 | 1276 | */ |
1277 | - public static function serialize($page,$data) |
|
1277 | + public static function serialize($page, $data) |
|
1278 | 1278 | { |
1279 | - $sm=$page->getApplication()->getSecurityManager(); |
|
1280 | - if($page->getEnableStateValidation()) |
|
1281 | - $str=$sm->hashData(serialize($data)); |
|
1279 | + $sm = $page->getApplication()->getSecurityManager(); |
|
1280 | + if ($page->getEnableStateValidation()) |
|
1281 | + $str = $sm->hashData(serialize($data)); |
|
1282 | 1282 | else |
1283 | - $str=serialize($data); |
|
1284 | - if($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
1285 | - $str=gzcompress($str); |
|
1286 | - if($page->getEnableStateEncryption()) |
|
1287 | - $str=$sm->encrypt($str); |
|
1283 | + $str = serialize($data); |
|
1284 | + if ($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
1285 | + $str = gzcompress($str); |
|
1286 | + if ($page->getEnableStateEncryption()) |
|
1287 | + $str = $sm->encrypt($str); |
|
1288 | 1288 | return base64_encode($str); |
1289 | 1289 | } |
1290 | 1290 | |
@@ -1293,21 +1293,21 @@ discard block |
||
1293 | 1293 | * @param string serialized data |
1294 | 1294 | * @return mixed unserialized state data, null if data is corrupted |
1295 | 1295 | */ |
1296 | - public static function unserialize($page,$data) |
|
1296 | + public static function unserialize($page, $data) |
|
1297 | 1297 | { |
1298 | - $str=base64_decode($data); |
|
1299 | - if($str==='') |
|
1298 | + $str = base64_decode($data); |
|
1299 | + if ($str === '') |
|
1300 | 1300 | return null; |
1301 | - if($str!==false) |
|
1301 | + if ($str !== false) |
|
1302 | 1302 | { |
1303 | - $sm=$page->getApplication()->getSecurityManager(); |
|
1304 | - if($page->getEnableStateEncryption()) |
|
1305 | - $str=$sm->decrypt($str); |
|
1306 | - if($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
1307 | - $str=@gzuncompress($str); |
|
1308 | - if($page->getEnableStateValidation()) |
|
1303 | + $sm = $page->getApplication()->getSecurityManager(); |
|
1304 | + if ($page->getEnableStateEncryption()) |
|
1305 | + $str = $sm->decrypt($str); |
|
1306 | + if ($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
1307 | + $str = @gzuncompress($str); |
|
1308 | + if ($page->getEnableStateValidation()) |
|
1309 | 1309 | { |
1310 | - if(($str=$sm->validateData($str))!==false) |
|
1310 | + if (($str = $sm->validateData($str)) !== false) |
|
1311 | 1311 | return unserialize($str); |
1312 | 1312 | } |
1313 | 1313 | else |
@@ -188,13 +188,14 @@ discard block |
||
188 | 188 | |
189 | 189 | if($this->getIsPostBack()) |
190 | 190 | { |
191 | - if($this->getIsCallback()) |
|
192 | - $this->processCallbackRequest($writer); |
|
193 | - else |
|
194 | - $this->processPostBackRequest($writer); |
|
191 | + if($this->getIsCallback()) { |
|
192 | + $this->processCallbackRequest($writer); |
|
193 | + } else { |
|
194 | + $this->processPostBackRequest($writer); |
|
195 | + } |
|
196 | + } else { |
|
197 | + $this->processNormalRequest($writer); |
|
195 | 198 | } |
196 | - else |
|
197 | - $this->processNormalRequest($writer); |
|
198 | 199 | |
199 | 200 | $this->_writer = null; |
200 | 201 | } |
@@ -282,8 +283,9 @@ discard block |
||
282 | 283 | { |
283 | 284 | if(is_array($data)) |
284 | 285 | { |
285 | - foreach($data as $k=>$v) |
|
286 | - $data[$k]=self::decodeUTF8($v, $enc); |
|
286 | + foreach($data as $k=>$v) { |
|
287 | + $data[$k]=self::decodeUTF8($v, $enc); |
|
288 | + } |
|
287 | 289 | return $data; |
288 | 290 | } elseif(is_string($data)) { |
289 | 291 | return iconv('UTF-8',$enc.'//IGNORE',$data); |
@@ -304,14 +306,16 @@ discard block |
||
304 | 306 | $this->setAdapter(new TActivePageAdapter($this)); |
305 | 307 | |
306 | 308 | $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
307 | - if(strlen($callbackEventParameter) > 0) |
|
308 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
309 | + if(strlen($callbackEventParameter) > 0) { |
|
310 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
311 | + } |
|
309 | 312 | |
310 | 313 | // Decode Callback postData from UTF-8 to current Charset |
311 | 314 | if (($g=$this->getApplication()->getGlobalization(false))!==null && |
312 | - strtoupper($enc=$g->getCharset())!='UTF-8') |
|
313 | - foreach ($this->_postData as $k=>$v) |
|
315 | + strtoupper($enc=$g->getCharset())!='UTF-8') { |
|
316 | + foreach ($this->_postData as $k=>$v) |
|
314 | 317 | $this->_postData[$k]=self::decodeUTF8($v, $enc); |
318 | + } |
|
315 | 319 | |
316 | 320 | Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
317 | 321 | $this->onPreInit(null); |
@@ -375,10 +379,11 @@ discard block |
||
375 | 379 | */ |
376 | 380 | public function getCallbackClient() |
377 | 381 | { |
378 | - if($this->getAdapter() !== null) |
|
379 | - return $this->getAdapter()->getCallbackClientHandler(); |
|
380 | - else |
|
381 | - return new TCallbackClientScript(); |
|
382 | + if($this->getAdapter() !== null) { |
|
383 | + return $this->getAdapter()->getCallbackClientHandler(); |
|
384 | + } else { |
|
385 | + return new TCallbackClientScript(); |
|
386 | + } |
|
382 | 387 | } |
383 | 388 | |
384 | 389 | /** |
@@ -441,10 +446,11 @@ discard block |
||
441 | 446 | */ |
442 | 447 | public function setForm(TForm $form) |
443 | 448 | { |
444 | - if($this->_form===null) |
|
445 | - $this->_form=$form; |
|
446 | - else |
|
447 | - throw new TInvalidOperationException('page_form_duplicated'); |
|
449 | + if($this->_form===null) { |
|
450 | + $this->_form=$form; |
|
451 | + } else { |
|
452 | + throw new TInvalidOperationException('page_form_duplicated'); |
|
453 | + } |
|
448 | 454 | } |
449 | 455 | |
450 | 456 | /** |
@@ -455,16 +461,18 @@ discard block |
||
455 | 461 | */ |
456 | 462 | public function getValidators($validationGroup=null) |
457 | 463 | { |
458 | - if(!$this->_validators) |
|
459 | - $this->_validators=new TList; |
|
460 | - if(empty($validationGroup) === true) |
|
461 | - return $this->_validators; |
|
462 | - else |
|
464 | + if(!$this->_validators) { |
|
465 | + $this->_validators=new TList; |
|
466 | + } |
|
467 | + if(empty($validationGroup) === true) { |
|
468 | + return $this->_validators; |
|
469 | + } else |
|
463 | 470 | { |
464 | 471 | $list=new TList; |
465 | - foreach($this->_validators as $validator) |
|
466 | - if($validator->getValidationGroup()===$validationGroup) |
|
472 | + foreach($this->_validators as $validator) { |
|
473 | + if($validator->getValidationGroup()===$validationGroup) |
|
467 | 474 | $list->add($validator); |
475 | + } |
|
468 | 476 | return $list; |
469 | 477 | } |
470 | 478 | } |
@@ -483,15 +491,16 @@ discard block |
||
483 | 491 | { |
484 | 492 | if($validationGroup===null) |
485 | 493 | { |
486 | - foreach($this->_validators as $validator) |
|
487 | - $validator->validate(); |
|
488 | - } |
|
489 | - else |
|
494 | + foreach($this->_validators as $validator) { |
|
495 | + $validator->validate(); |
|
496 | + } |
|
497 | + } else |
|
490 | 498 | { |
491 | 499 | foreach($this->_validators as $validator) |
492 | 500 | { |
493 | - if($validator->getValidationGroup()===$validationGroup) |
|
494 | - $validator->validate(); |
|
501 | + if($validator->getValidationGroup()===$validationGroup) { |
|
502 | + $validator->validate(); |
|
503 | + } |
|
495 | 504 | } |
496 | 505 | } |
497 | 506 | } |
@@ -509,14 +518,15 @@ discard block |
||
509 | 518 | { |
510 | 519 | if($this->_validators && $this->_validators->getCount()) |
511 | 520 | { |
512 | - foreach($this->_validators as $validator) |
|
513 | - if(!$validator->getIsValid()) |
|
521 | + foreach($this->_validators as $validator) { |
|
522 | + if(!$validator->getIsValid()) |
|
514 | 523 | return false; |
524 | + } |
|
515 | 525 | } |
516 | 526 | return true; |
527 | + } else { |
|
528 | + throw new TInvalidOperationException('page_isvalid_unknown'); |
|
517 | 529 | } |
518 | - else |
|
519 | - throw new TInvalidOperationException('page_isvalid_unknown'); |
|
520 | 530 | } |
521 | 531 | |
522 | 532 | /** |
@@ -524,8 +534,9 @@ discard block |
||
524 | 534 | */ |
525 | 535 | public function getTheme() |
526 | 536 | { |
527 | - if(is_string($this->_theme)) |
|
528 | - $this->_theme=$this->getService()->getThemeManager()->getTheme($this->_theme); |
|
537 | + if(is_string($this->_theme)) { |
|
538 | + $this->_theme=$this->getService()->getThemeManager()->getTheme($this->_theme); |
|
539 | + } |
|
529 | 540 | return $this->_theme; |
530 | 541 | } |
531 | 542 | |
@@ -544,8 +555,9 @@ discard block |
||
544 | 555 | */ |
545 | 556 | public function getStyleSheetTheme() |
546 | 557 | { |
547 | - if(is_string($this->_styleSheet)) |
|
548 | - $this->_styleSheet=$this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
558 | + if(is_string($this->_styleSheet)) { |
|
559 | + $this->_styleSheet=$this->getService()->getThemeManager()->getTheme($this->_styleSheet); |
|
560 | + } |
|
549 | 561 | return $this->_styleSheet; |
550 | 562 | } |
551 | 563 | |
@@ -565,8 +577,9 @@ discard block |
||
565 | 577 | */ |
566 | 578 | public function applyControlSkin($control) |
567 | 579 | { |
568 | - if(($theme=$this->getTheme())!==null) |
|
569 | - $theme->applySkin($control); |
|
580 | + if(($theme=$this->getTheme())!==null) { |
|
581 | + $theme->applySkin($control); |
|
582 | + } |
|
570 | 583 | } |
571 | 584 | |
572 | 585 | /** |
@@ -576,8 +589,9 @@ discard block |
||
576 | 589 | */ |
577 | 590 | public function applyControlStyleSheet($control) |
578 | 591 | { |
579 | - if(($theme=$this->getStyleSheetTheme())!==null) |
|
580 | - $theme->applySkin($control); |
|
592 | + if(($theme=$this->getStyleSheetTheme())!==null) { |
|
593 | + $theme->applySkin($control); |
|
594 | + } |
|
581 | 595 | } |
582 | 596 | |
583 | 597 | /** |
@@ -588,11 +602,13 @@ discard block |
||
588 | 602 | if(!$this->_clientScript) { |
589 | 603 | $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
590 | 604 | Prado::using($className); |
591 | - if(($pos=strrpos($className,'.'))!==false) |
|
592 | - $className=substr($className,$pos+1); |
|
605 | + if(($pos=strrpos($className,'.'))!==false) { |
|
606 | + $className=substr($className,$pos+1); |
|
607 | + } |
|
593 | 608 | |
594 | - if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager'))) |
|
595 | - throw new THttpException(404,'page_csmanagerclass_invalid',$classPath); |
|
609 | + if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager'))) { |
|
610 | + throw new THttpException(404,'page_csmanagerclass_invalid',$classPath); |
|
611 | + } |
|
596 | 612 | |
597 | 613 | $this->_clientScript=new $className($this); |
598 | 614 | } |
@@ -667,22 +683,27 @@ discard block |
||
667 | 683 | $theme=$this->getTheme(); |
668 | 684 | if($theme instanceof ITheme) |
669 | 685 | { |
670 | - foreach($theme->getStyleSheetFiles() as $url) |
|
671 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
672 | - foreach($theme->getJavaScriptFiles() as $url) |
|
673 | - $cs->registerHeadScriptFile($url,$url); |
|
686 | + foreach($theme->getStyleSheetFiles() as $url) { |
|
687 | + $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
688 | + } |
|
689 | + foreach($theme->getJavaScriptFiles() as $url) { |
|
690 | + $cs->registerHeadScriptFile($url,$url); |
|
691 | + } |
|
674 | 692 | } |
675 | 693 | $styleSheet=$this->getStyleSheetTheme(); |
676 | 694 | if($styleSheet instanceof ITheme) |
677 | 695 | { |
678 | - foreach($styleSheet->getStyleSheetFiles() as $url) |
|
679 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
680 | - foreach($styleSheet->getJavaScriptFiles() as $url) |
|
681 | - $cs->registerHeadScriptFile($url,$url); |
|
696 | + foreach($styleSheet->getStyleSheetFiles() as $url) { |
|
697 | + $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
698 | + } |
|
699 | + foreach($styleSheet->getJavaScriptFiles() as $url) { |
|
700 | + $cs->registerHeadScriptFile($url,$url); |
|
701 | + } |
|
682 | 702 | } |
683 | 703 | |
684 | - if($cs->getRequiresHead() && $this->getHead()===null) |
|
685 | - throw new TConfigurationException('page_head_required'); |
|
704 | + if($cs->getRequiresHead() && $this->getHead()===null) { |
|
705 | + throw new TConfigurationException('page_head_required'); |
|
706 | + } |
|
686 | 707 | } |
687 | 708 | |
688 | 709 | /** |
@@ -696,10 +717,11 @@ discard block |
||
696 | 717 | private function getCssMediaType($url) |
697 | 718 | { |
698 | 719 | $segs=explode('.',basename($url)); |
699 | - if(isset($segs[2])) |
|
700 | - return $segs[count($segs)-2]; |
|
701 | - else |
|
702 | - return ''; |
|
720 | + if(isset($segs[2])) { |
|
721 | + return $segs[count($segs)-2]; |
|
722 | + } else { |
|
723 | + return ''; |
|
724 | + } |
|
703 | 725 | } |
704 | 726 | |
705 | 727 | /** |
@@ -721,8 +743,9 @@ discard block |
||
721 | 743 | private function determinePostBackMode() |
722 | 744 | { |
723 | 745 | $postData=$this->getRequest(); |
724 | - if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) |
|
725 | - $this->_postData=$postData; |
|
746 | + if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) { |
|
747 | + $this->_postData=$postData; |
|
748 | + } |
|
726 | 749 | } |
727 | 750 | |
728 | 751 | /** |
@@ -804,8 +827,9 @@ discard block |
||
804 | 827 | $id=is_string($control)?$control:$control->getUniqueID(); |
805 | 828 | $this->_controlsRegisteredForPostData[$id]=true; |
806 | 829 | $params=func_get_args(); |
807 | - foreach($this->getCachingStack() as $item) |
|
808 | - $item->registerAction('Page','registerRequiresPostData',array($id)); |
|
830 | + foreach($this->getCachingStack() as $item) { |
|
831 | + $item->registerAction('Page','registerRequiresPostData',array($id)); |
|
832 | + } |
|
809 | 833 | } |
810 | 834 | |
811 | 835 | /** |
@@ -816,8 +840,9 @@ discard block |
||
816 | 840 | if($this->_postBackEventTarget===null && $this->_postData!==null) |
817 | 841 | { |
818 | 842 | $eventTarget=$this->_postData->itemAt(self::FIELD_POSTBACK_TARGET); |
819 | - if(!empty($eventTarget)) |
|
820 | - $this->_postBackEventTarget=$this->findControl($eventTarget); |
|
843 | + if(!empty($eventTarget)) { |
|
844 | + $this->_postBackEventTarget=$this->findControl($eventTarget); |
|
845 | + } |
|
821 | 846 | } |
822 | 847 | return $this->_postBackEventTarget; |
823 | 848 | } |
@@ -838,8 +863,9 @@ discard block |
||
838 | 863 | { |
839 | 864 | if($this->_postBackEventParameter===null && $this->_postData!==null) |
840 | 865 | { |
841 | - if(($this->_postBackEventParameter=$this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER))===null) |
|
842 | - $this->_postBackEventParameter=''; |
|
866 | + if(($this->_postBackEventParameter=$this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER))===null) { |
|
867 | + $this->_postBackEventParameter=''; |
|
868 | + } |
|
843 | 869 | } |
844 | 870 | return $this->_postBackEventParameter; |
845 | 871 | } |
@@ -860,28 +886,29 @@ discard block |
||
860 | 886 | protected function processPostData($postData,$beforeLoad) |
861 | 887 | { |
862 | 888 | $this->_isLoadingPostData=true; |
863 | - if($beforeLoad) |
|
864 | - $this->_restPostData=new TMap; |
|
889 | + if($beforeLoad) { |
|
890 | + $this->_restPostData=new TMap; |
|
891 | + } |
|
865 | 892 | foreach($postData as $key=>$value) |
866 | 893 | { |
867 | - if($this->isSystemPostField($key)) |
|
868 | - continue; |
|
869 | - else if($control=$this->findControl($key)) |
|
894 | + if($this->isSystemPostField($key)) { |
|
895 | + continue; |
|
896 | + } else if($control=$this->findControl($key)) |
|
870 | 897 | { |
871 | 898 | if($control instanceof IPostBackDataHandler) |
872 | 899 | { |
873 | - if($control->loadPostData($key,$postData)) |
|
874 | - $this->_controlsPostDataChanged[]=$control; |
|
875 | - } |
|
876 | - else if($control instanceof IPostBackEventHandler && |
|
900 | + if($control->loadPostData($key,$postData)) { |
|
901 | + $this->_controlsPostDataChanged[]=$control; |
|
902 | + } |
|
903 | + } else if($control instanceof IPostBackEventHandler && |
|
877 | 904 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
878 | 905 | { |
879 | 906 | $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); // not calling setPostBackEventTarget() because the control may be removed later |
880 | 907 | } |
881 | 908 | unset($this->_controlsRequiringPostData[$key]); |
909 | + } else if($beforeLoad) { |
|
910 | + $this->_restPostData->add($key,$value); |
|
882 | 911 | } |
883 | - else if($beforeLoad) |
|
884 | - $this->_restPostData->add($key,$value); |
|
885 | 912 | } |
886 | 913 | |
887 | 914 | foreach($this->_controlsRequiringPostData as $key=>$value) |
@@ -890,11 +917,12 @@ discard block |
||
890 | 917 | { |
891 | 918 | if($control instanceof IPostBackDataHandler) |
892 | 919 | { |
893 | - if($control->loadPostData($key,$this->_postData)) |
|
894 | - $this->_controlsPostDataChanged[]=$control; |
|
920 | + if($control->loadPostData($key,$this->_postData)) { |
|
921 | + $this->_controlsPostDataChanged[]=$control; |
|
922 | + } |
|
923 | + } else { |
|
924 | + throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key); |
|
895 | 925 | } |
896 | - else |
|
897 | - throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key); |
|
898 | 926 | unset($this->_controlsRequiringPostData[$key]); |
899 | 927 | } |
900 | 928 | } |
@@ -914,8 +942,9 @@ discard block |
||
914 | 942 | */ |
915 | 943 | protected function raiseChangedEvents() |
916 | 944 | { |
917 | - foreach($this->_controlsPostDataChanged as $control) |
|
918 | - $control->raisePostDataChangedEvent(); |
|
945 | + foreach($this->_controlsPostDataChanged as $control) { |
|
946 | + $control->raisePostDataChangedEvent(); |
|
947 | + } |
|
919 | 948 | } |
920 | 949 | |
921 | 950 | /** |
@@ -923,10 +952,11 @@ discard block |
||
923 | 952 | */ |
924 | 953 | protected function raisePostBackEvent() |
925 | 954 | { |
926 | - if(($postBackHandler=$this->getPostBackEventTarget())===null) |
|
927 | - $this->validate(); |
|
928 | - else if($postBackHandler instanceof IPostBackEventHandler) |
|
929 | - $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
|
955 | + if(($postBackHandler=$this->getPostBackEventTarget())===null) { |
|
956 | + $this->validate(); |
|
957 | + } else if($postBackHandler instanceof IPostBackEventHandler) { |
|
958 | + $postBackHandler->raisePostBackEvent($this->getPostBackEventParameter()); |
|
959 | + } |
|
930 | 960 | } |
931 | 961 | |
932 | 962 | /** |
@@ -944,8 +974,9 @@ discard block |
||
944 | 974 | */ |
945 | 975 | public function ensureRenderInForm($control) |
946 | 976 | { |
947 | - if(!$this->getIsCallback() && !$this->_inFormRender) |
|
948 | - throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null); |
|
977 | + if(!$this->getIsCallback() && !$this->_inFormRender) { |
|
978 | + throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null); |
|
979 | + } |
|
949 | 980 | } |
950 | 981 | |
951 | 982 | /** |
@@ -953,8 +984,9 @@ discard block |
||
953 | 984 | */ |
954 | 985 | public function beginFormRender($writer) |
955 | 986 | { |
956 | - if($this->_formRendered) |
|
957 | - throw new TConfigurationException('page_form_duplicated'); |
|
987 | + if($this->_formRendered) { |
|
988 | + throw new TConfigurationException('page_form_duplicated'); |
|
989 | + } |
|
958 | 990 | $this->_formRendered=true; |
959 | 991 | $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE,$this->getClientState()); |
960 | 992 | $this->_inFormRender=true; |
@@ -967,14 +999,15 @@ discard block |
||
967 | 999 | { |
968 | 1000 | if($this->_focus) |
969 | 1001 | { |
970 | - if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) |
|
971 | - $focus=$this->_focus->getClientID(); |
|
972 | - else |
|
973 | - $focus=$this->_focus; |
|
1002 | + if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) { |
|
1003 | + $focus=$this->_focus->getClientID(); |
|
1004 | + } else { |
|
1005 | + $focus=$this->_focus; |
|
1006 | + } |
|
974 | 1007 | $this->getClientScript()->registerFocusControl($focus); |
1008 | + } else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) { |
|
1009 | + $this->getClientScript()->registerFocusControl($lastFocus); |
|
975 | 1010 | } |
976 | - else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) |
|
977 | - $this->getClientScript()->registerFocusControl($lastFocus); |
|
978 | 1011 | $this->_inFormRender=false; |
979 | 1012 | } |
980 | 1013 | |
@@ -1017,8 +1050,9 @@ discard block |
||
1017 | 1050 | */ |
1018 | 1051 | public function setHead(THead $value) |
1019 | 1052 | { |
1020 | - if($this->_head) |
|
1021 | - throw new TInvalidOperationException('page_head_duplicated'); |
|
1053 | + if($this->_head) { |
|
1054 | + throw new TInvalidOperationException('page_head_duplicated'); |
|
1055 | + } |
|
1022 | 1056 | $this->_head=$value; |
1023 | 1057 | if($this->_title!==null) |
1024 | 1058 | { |
@@ -1032,10 +1066,11 @@ discard block |
||
1032 | 1066 | */ |
1033 | 1067 | public function getTitle() |
1034 | 1068 | { |
1035 | - if($this->_head) |
|
1036 | - return $this->_head->getTitle(); |
|
1037 | - else |
|
1038 | - return $this->_title===null ? '' : $this->_title; |
|
1069 | + if($this->_head) { |
|
1070 | + return $this->_head->getTitle(); |
|
1071 | + } else { |
|
1072 | + return $this->_title===null ? '' : $this->_title; |
|
1073 | + } |
|
1039 | 1074 | } |
1040 | 1075 | |
1041 | 1076 | /** |
@@ -1046,10 +1081,11 @@ discard block |
||
1046 | 1081 | */ |
1047 | 1082 | public function setTitle($value) |
1048 | 1083 | { |
1049 | - if($this->_head) |
|
1050 | - $this->_head->setTitle($value); |
|
1051 | - else |
|
1052 | - $this->_title=$value; |
|
1084 | + if($this->_head) { |
|
1085 | + $this->_head->setTitle($value); |
|
1086 | + } else { |
|
1087 | + $this->_title=$value; |
|
1088 | + } |
|
1053 | 1089 | } |
1054 | 1090 | |
1055 | 1091 | /** |
@@ -1104,8 +1140,9 @@ discard block |
||
1104 | 1140 | if($this->_statePersister===null) |
1105 | 1141 | { |
1106 | 1142 | $this->_statePersister=Prado::createComponent($this->_statePersisterClass); |
1107 | - if(!($this->_statePersister instanceof IPageStatePersister)) |
|
1108 | - throw new TInvalidDataTypeException('page_statepersister_invalid'); |
|
1143 | + if(!($this->_statePersister instanceof IPageStatePersister)) { |
|
1144 | + throw new TInvalidDataTypeException('page_statepersister_invalid'); |
|
1145 | + } |
|
1109 | 1146 | $this->_statePersister->setPage($this); |
1110 | 1147 | } |
1111 | 1148 | return $this->_statePersister; |
@@ -1190,8 +1227,9 @@ discard block |
||
1190 | 1227 | { |
1191 | 1228 | if($this->_cachingStack) |
1192 | 1229 | { |
1193 | - foreach($this->_cachingStack as $cache) |
|
1194 | - $cache->registerAction($context,$funcName,$funcParams); |
|
1230 | + foreach($this->_cachingStack as $cache) { |
|
1231 | + $cache->registerAction($context,$funcName,$funcParams); |
|
1232 | + } |
|
1195 | 1233 | } |
1196 | 1234 | } |
1197 | 1235 | |
@@ -1200,8 +1238,9 @@ discard block |
||
1200 | 1238 | */ |
1201 | 1239 | public function getCachingStack() |
1202 | 1240 | { |
1203 | - if(!$this->_cachingStack) |
|
1204 | - $this->_cachingStack=new TStack; |
|
1241 | + if(!$this->_cachingStack) { |
|
1242 | + $this->_cachingStack=new TStack; |
|
1243 | + } |
|
1205 | 1244 | return $this->_cachingStack; |
1206 | 1245 | } |
1207 | 1246 | |
@@ -1210,8 +1249,9 @@ discard block |
||
1210 | 1249 | */ |
1211 | 1250 | public function flushWriter() |
1212 | 1251 | { |
1213 | - if ($this->_writer) |
|
1214 | - $this->Response->write($this->_writer->flush()); |
|
1252 | + if ($this->_writer) { |
|
1253 | + $this->Response->write($this->_writer->flush()); |
|
1254 | + } |
|
1215 | 1255 | } |
1216 | 1256 | |
1217 | 1257 | } |
@@ -1277,14 +1317,17 @@ discard block |
||
1277 | 1317 | public static function serialize($page,$data) |
1278 | 1318 | { |
1279 | 1319 | $sm=$page->getApplication()->getSecurityManager(); |
1280 | - if($page->getEnableStateValidation()) |
|
1281 | - $str=$sm->hashData(serialize($data)); |
|
1282 | - else |
|
1283 | - $str=serialize($data); |
|
1284 | - if($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
1285 | - $str=gzcompress($str); |
|
1286 | - if($page->getEnableStateEncryption()) |
|
1287 | - $str=$sm->encrypt($str); |
|
1320 | + if($page->getEnableStateValidation()) { |
|
1321 | + $str=$sm->hashData(serialize($data)); |
|
1322 | + } else { |
|
1323 | + $str=serialize($data); |
|
1324 | + } |
|
1325 | + if($page->getEnableStateCompression() && extension_loaded('zlib')) { |
|
1326 | + $str=gzcompress($str); |
|
1327 | + } |
|
1328 | + if($page->getEnableStateEncryption()) { |
|
1329 | + $str=$sm->encrypt($str); |
|
1330 | + } |
|
1288 | 1331 | return base64_encode($str); |
1289 | 1332 | } |
1290 | 1333 | |
@@ -1296,22 +1339,26 @@ discard block |
||
1296 | 1339 | public static function unserialize($page,$data) |
1297 | 1340 | { |
1298 | 1341 | $str=base64_decode($data); |
1299 | - if($str==='') |
|
1300 | - return null; |
|
1342 | + if($str==='') { |
|
1343 | + return null; |
|
1344 | + } |
|
1301 | 1345 | if($str!==false) |
1302 | 1346 | { |
1303 | 1347 | $sm=$page->getApplication()->getSecurityManager(); |
1304 | - if($page->getEnableStateEncryption()) |
|
1305 | - $str=$sm->decrypt($str); |
|
1306 | - if($page->getEnableStateCompression() && extension_loaded('zlib')) |
|
1307 | - $str=@gzuncompress($str); |
|
1348 | + if($page->getEnableStateEncryption()) { |
|
1349 | + $str=$sm->decrypt($str); |
|
1350 | + } |
|
1351 | + if($page->getEnableStateCompression() && extension_loaded('zlib')) { |
|
1352 | + $str=@gzuncompress($str); |
|
1353 | + } |
|
1308 | 1354 | if($page->getEnableStateValidation()) |
1309 | 1355 | { |
1310 | - if(($str=$sm->validateData($str))!==false) |
|
1311 | - return unserialize($str); |
|
1356 | + if(($str=$sm->validateData($str))!==false) { |
|
1357 | + return unserialize($str); |
|
1358 | + } |
|
1359 | + } else { |
|
1360 | + return unserialize($str); |
|
1312 | 1361 | } |
1313 | - else |
|
1314 | - return unserialize($str); |
|
1315 | 1362 | } |
1316 | 1363 | return null; |
1317 | 1364 | } |
@@ -144,6 +144,7 @@ discard block |
||
144 | 144 | * Registers a content control. |
145 | 145 | * @param string ID of the content |
146 | 146 | * @param TContent |
147 | + * @param string $id |
|
147 | 148 | */ |
148 | 149 | public function registerContent($id,TContent $object) |
149 | 150 | { |
@@ -158,6 +159,7 @@ discard block |
||
158 | 159 | * This method should only be used by framework and control developers. |
159 | 160 | * @param string placeholder ID |
160 | 161 | * @param TContentPlaceHolder placeholder control |
162 | + * @param string $id |
|
161 | 163 | */ |
162 | 164 | public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
163 | 165 | { |
@@ -184,7 +186,7 @@ discard block |
||
184 | 186 | } |
185 | 187 | |
186 | 188 | /** |
187 | - * @return TTemplateControl|null master control associated with this control, null if none |
|
189 | + * @return TTemplateControl master control associated with this control, null if none |
|
188 | 190 | */ |
189 | 191 | public function getMaster() |
190 | 192 | { |
@@ -238,90 +238,90 @@ |
||
238 | 238 | parent::initRecursive($namingContainer); |
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Function to update view controls with data in a given AR object. |
|
243 | - * View controls and AR object need to have the same name in IDs and Attrs respectively. |
|
244 | - * @param TActiveRecord $arObj |
|
245 | - * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
246 | - * @author Daniel Sampedro <[email protected]> |
|
247 | - */ |
|
248 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
249 | - { |
|
250 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | - foreach (array_keys($objAttrs) as $key) |
|
252 | - { |
|
253 | - try |
|
254 | - { |
|
255 | - if ($key != "RELATIONS") |
|
256 | - { |
|
257 | - $control = $this->{$key}; |
|
258 | - if ($control instanceof TTextBox) |
|
259 | - $control->Text = $arObj->{$key}; |
|
260 | - elseif ($control instanceof TCheckBox) |
|
261 | - $control->Checked = (boolean) $arObj->{$key}; |
|
262 | - elseif ($control instanceof TDatePicker) |
|
263 | - $control->Date = $arObj->{$key}; |
|
264 | - } |
|
265 | - else |
|
266 | - { |
|
267 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | - { |
|
269 | - $relControl = $this->{$relKey}; |
|
270 | - switch ($relValues[0]) |
|
271 | - { |
|
272 | - case TActiveRecord::BELONGS_TO: |
|
273 | - case TActiveRecord::HAS_ONE: |
|
274 | - $relControl->Text = $arObj->{$relKey}; |
|
275 | - break; |
|
276 | - case TActiveRecord::HAS_MANY: |
|
277 | - if ($relControl instanceof TListControl) |
|
278 | - { |
|
279 | - $relControl->DataSource = $arObj->{$relKey}; |
|
280 | - $relControl->dataBind(); |
|
281 | - } |
|
282 | - break; |
|
283 | - } |
|
284 | - } |
|
285 | - break; |
|
286 | - } |
|
287 | - } |
|
288 | - catch (Exception $ex) |
|
289 | - { |
|
290 | - if ($throwExceptions) |
|
291 | - throw $ex; |
|
292 | - } |
|
293 | - } |
|
294 | - } |
|
241 | + /** |
|
242 | + * Function to update view controls with data in a given AR object. |
|
243 | + * View controls and AR object need to have the same name in IDs and Attrs respectively. |
|
244 | + * @param TActiveRecord $arObj |
|
245 | + * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
246 | + * @author Daniel Sampedro <[email protected]> |
|
247 | + */ |
|
248 | + public function tryToUpdateView($arObj, $throwExceptions = false) |
|
249 | + { |
|
250 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | + foreach (array_keys($objAttrs) as $key) |
|
252 | + { |
|
253 | + try |
|
254 | + { |
|
255 | + if ($key != "RELATIONS") |
|
256 | + { |
|
257 | + $control = $this->{$key}; |
|
258 | + if ($control instanceof TTextBox) |
|
259 | + $control->Text = $arObj->{$key}; |
|
260 | + elseif ($control instanceof TCheckBox) |
|
261 | + $control->Checked = (boolean) $arObj->{$key}; |
|
262 | + elseif ($control instanceof TDatePicker) |
|
263 | + $control->Date = $arObj->{$key}; |
|
264 | + } |
|
265 | + else |
|
266 | + { |
|
267 | + foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | + { |
|
269 | + $relControl = $this->{$relKey}; |
|
270 | + switch ($relValues[0]) |
|
271 | + { |
|
272 | + case TActiveRecord::BELONGS_TO: |
|
273 | + case TActiveRecord::HAS_ONE: |
|
274 | + $relControl->Text = $arObj->{$relKey}; |
|
275 | + break; |
|
276 | + case TActiveRecord::HAS_MANY: |
|
277 | + if ($relControl instanceof TListControl) |
|
278 | + { |
|
279 | + $relControl->DataSource = $arObj->{$relKey}; |
|
280 | + $relControl->dataBind(); |
|
281 | + } |
|
282 | + break; |
|
283 | + } |
|
284 | + } |
|
285 | + break; |
|
286 | + } |
|
287 | + } |
|
288 | + catch (Exception $ex) |
|
289 | + { |
|
290 | + if ($throwExceptions) |
|
291 | + throw $ex; |
|
292 | + } |
|
293 | + } |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * Function to try to update an AR object with data in view controls. |
|
298 | - * @param TActiveRecord $arObj |
|
299 | - * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
300 | - * @author Daniel Sampedro <[email protected]> |
|
301 | - */ |
|
302 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
303 | - { |
|
304 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | - foreach (array_keys($objAttrs) as $key) |
|
306 | - { |
|
307 | - try |
|
308 | - { |
|
309 | - if ($key == "RELATIONS") |
|
310 | - break; |
|
311 | - $control = $this->{$key}; |
|
312 | - if ($control instanceof TTextBox) |
|
313 | - $arObj->{$key} = $control->Text; |
|
314 | - elseif ($control instanceof TCheckBox) |
|
315 | - $arObj->{$key} = $control->Checked; |
|
316 | - elseif ($control instanceof TDatePicker) |
|
317 | - $arObj->{$key} = $control->Date; |
|
318 | - } |
|
319 | - catch (Exception $ex) |
|
320 | - { |
|
321 | - if ($throwExceptions) |
|
322 | - throw $ex; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
296 | + /** |
|
297 | + * Function to try to update an AR object with data in view controls. |
|
298 | + * @param TActiveRecord $arObj |
|
299 | + * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
300 | + * @author Daniel Sampedro <[email protected]> |
|
301 | + */ |
|
302 | + public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
303 | + { |
|
304 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | + foreach (array_keys($objAttrs) as $key) |
|
306 | + { |
|
307 | + try |
|
308 | + { |
|
309 | + if ($key == "RELATIONS") |
|
310 | + break; |
|
311 | + $control = $this->{$key}; |
|
312 | + if ($control instanceof TTextBox) |
|
313 | + $arObj->{$key} = $control->Text; |
|
314 | + elseif ($control instanceof TCheckBox) |
|
315 | + $arObj->{$key} = $control->Checked; |
|
316 | + elseif ($control instanceof TDatePicker) |
|
317 | + $arObj->{$key} = $control->Date; |
|
318 | + } |
|
319 | + catch (Exception $ex) |
|
320 | + { |
|
321 | + if ($throwExceptions) |
|
322 | + throw $ex; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | 326 | } |
327 | 327 |
@@ -30,32 +30,32 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * template file extension. |
32 | 32 | */ |
33 | - const EXT_TEMPLATE='.tpl'; |
|
33 | + const EXT_TEMPLATE = '.tpl'; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @var ITemplate the parsed template structure shared by the same control class |
37 | 37 | */ |
38 | - private static $_template=array(); |
|
38 | + private static $_template = array(); |
|
39 | 39 | /** |
40 | 40 | * @var ITemplate the parsed template structure specific for this control instance |
41 | 41 | */ |
42 | - private $_localTemplate=null; |
|
42 | + private $_localTemplate = null; |
|
43 | 43 | /** |
44 | 44 | * @var TTemplateControl the master control if any |
45 | 45 | */ |
46 | - private $_master=null; |
|
46 | + private $_master = null; |
|
47 | 47 | /** |
48 | 48 | * @var string master control class name |
49 | 49 | */ |
50 | - private $_masterClass=''; |
|
50 | + private $_masterClass = ''; |
|
51 | 51 | /** |
52 | 52 | * @var array list of TContent controls |
53 | 53 | */ |
54 | - private $_contents=array(); |
|
54 | + private $_contents = array(); |
|
55 | 55 | /** |
56 | 56 | * @var array list of TContentPlaceHolder controls |
57 | 57 | */ |
58 | - private $_placeholders=array(); |
|
58 | + private $_placeholders = array(); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Returns the template object associated with this control object. |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function getTemplate() |
65 | 65 | { |
66 | - if($this->_localTemplate===null) |
|
66 | + if ($this->_localTemplate === null) |
|
67 | 67 | { |
68 | - $class=get_class($this); |
|
69 | - if(!isset(self::$_template[$class])) |
|
70 | - self::$_template[$class]=$this->loadTemplate(); |
|
68 | + $class = get_class($this); |
|
69 | + if (!isset(self::$_template[$class])) |
|
70 | + self::$_template[$class] = $this->loadTemplate(); |
|
71 | 71 | return self::$_template[$class]; |
72 | 72 | } |
73 | 73 | else |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function setTemplate($value) |
84 | 84 | { |
85 | - $this->_localTemplate=$value; |
|
85 | + $this->_localTemplate = $value; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getIsSourceTemplateControl() |
94 | 94 | { |
95 | - if(($template=$this->getTemplate())!==null) |
|
95 | + if (($template = $this->getTemplate()) !== null) |
|
96 | 96 | return $template->getIsSourceTemplate(); |
97 | 97 | else |
98 | 98 | return false; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getTemplateDirectory() |
105 | 105 | { |
106 | - if(($template=$this->getTemplate())!==null) |
|
106 | + if (($template = $this->getTemplate()) !== null) |
|
107 | 107 | return $template->getContextPath(); |
108 | 108 | else |
109 | 109 | return ''; |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | */ |
116 | 116 | protected function loadTemplate() |
117 | 117 | { |
118 | - Prado::trace("Loading template ".get_class($this),'System.Web.UI.TTemplateControl'); |
|
119 | - $template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
|
118 | + Prado::trace("Loading template " . get_class($this), 'System.Web.UI.TTemplateControl'); |
|
119 | + $template = $this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
|
120 | 120 | return $template; |
121 | 121 | } |
122 | 122 | |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function createChildControls() |
129 | 129 | { |
130 | - if($tpl=$this->getTemplate()) |
|
130 | + if ($tpl = $this->getTemplate()) |
|
131 | 131 | { |
132 | - foreach($tpl->getDirective() as $name=>$value) |
|
132 | + foreach ($tpl->getDirective() as $name=>$value) |
|
133 | 133 | { |
134 | - if(is_string($value)) |
|
135 | - $this->setSubProperty($name,$value); |
|
134 | + if (is_string($value)) |
|
135 | + $this->setSubProperty($name, $value); |
|
136 | 136 | else |
137 | - throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name); |
|
137 | + throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name); |
|
138 | 138 | } |
139 | 139 | $tpl->instantiateIn($this); |
140 | 140 | } |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | * @param string ID of the content |
146 | 146 | * @param TContent |
147 | 147 | */ |
148 | - public function registerContent($id,TContent $object) |
|
148 | + public function registerContent($id, TContent $object) |
|
149 | 149 | { |
150 | - if(isset($this->_contents[$id])) |
|
151 | - throw new TConfigurationException('templatecontrol_contentid_duplicated',$id); |
|
150 | + if (isset($this->_contents[$id])) |
|
151 | + throw new TConfigurationException('templatecontrol_contentid_duplicated', $id); |
|
152 | 152 | else |
153 | - $this->_contents[$id]=$object; |
|
153 | + $this->_contents[$id] = $object; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | * @param string placeholder ID |
160 | 160 | * @param TContentPlaceHolder placeholder control |
161 | 161 | */ |
162 | - public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
|
162 | + public function registerContentPlaceHolder($id, TContentPlaceHolder $object) |
|
163 | 163 | { |
164 | - if(isset($this->_placeholders[$id])) |
|
165 | - throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id); |
|
164 | + if (isset($this->_placeholders[$id])) |
|
165 | + throw new TConfigurationException('templatecontrol_placeholderid_duplicated', $id); |
|
166 | 166 | else |
167 | - $this->_placeholders[$id]=$object; |
|
167 | + $this->_placeholders[$id] = $object; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function setMasterClass($value) |
182 | 182 | { |
183 | - $this->_masterClass=$value; |
|
183 | + $this->_masterClass = $value; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | * @param string ID of the content control |
198 | 198 | * @param TContent the content to be injected |
199 | 199 | */ |
200 | - public function injectContent($id,$content) |
|
200 | + public function injectContent($id, $content) |
|
201 | 201 | { |
202 | - if(isset($this->_placeholders[$id])) |
|
202 | + if (isset($this->_placeholders[$id])) |
|
203 | 203 | { |
204 | - $placeholder=$this->_placeholders[$id]; |
|
205 | - $controls=$placeholder->getParent()->getControls(); |
|
206 | - $loc=$controls->remove($placeholder); |
|
207 | - $controls->insertAt($loc,$content); |
|
204 | + $placeholder = $this->_placeholders[$id]; |
|
205 | + $controls = $placeholder->getParent()->getControls(); |
|
206 | + $loc = $controls->remove($placeholder); |
|
207 | + $controls->insertAt($loc, $content); |
|
208 | 208 | } |
209 | 209 | else |
210 | - throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
|
210 | + throw new TConfigurationException('templatecontrol_placeholder_inexistent', $id); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -218,23 +218,23 @@ discard block |
||
218 | 218 | * Only framework developers should use this method. |
219 | 219 | * @param TControl the naming container control |
220 | 220 | */ |
221 | - protected function initRecursive($namingContainer=null) |
|
221 | + protected function initRecursive($namingContainer = null) |
|
222 | 222 | { |
223 | 223 | $this->ensureChildControls(); |
224 | - if($this->_masterClass!=='') |
|
224 | + if ($this->_masterClass !== '') |
|
225 | 225 | { |
226 | - $master=Prado::createComponent($this->_masterClass); |
|
227 | - if(!($master instanceof TTemplateControl)) |
|
226 | + $master = Prado::createComponent($this->_masterClass); |
|
227 | + if (!($master instanceof TTemplateControl)) |
|
228 | 228 | throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid'); |
229 | - $this->_master=$master; |
|
229 | + $this->_master = $master; |
|
230 | 230 | $this->getControls()->clear(); |
231 | 231 | $this->getControls()->add($master); |
232 | 232 | $master->ensureChildControls(); |
233 | - foreach($this->_contents as $id=>$content) |
|
234 | - $master->injectContent($id,$content); |
|
233 | + foreach ($this->_contents as $id=>$content) |
|
234 | + $master->injectContent($id, $content); |
|
235 | 235 | } |
236 | - else if(!empty($this->_contents)) |
|
237 | - throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
|
236 | + else if (!empty($this->_contents)) |
|
237 | + throw new TConfigurationException('templatecontrol_mastercontrol_required', get_class($this)); |
|
238 | 238 | parent::initRecursive($namingContainer); |
239 | 239 | } |
240 | 240 |
@@ -66,12 +66,13 @@ discard block |
||
66 | 66 | if($this->_localTemplate===null) |
67 | 67 | { |
68 | 68 | $class=get_class($this); |
69 | - if(!isset(self::$_template[$class])) |
|
70 | - self::$_template[$class]=$this->loadTemplate(); |
|
69 | + if(!isset(self::$_template[$class])) { |
|
70 | + self::$_template[$class]=$this->loadTemplate(); |
|
71 | + } |
|
71 | 72 | return self::$_template[$class]; |
73 | + } else { |
|
74 | + return $this->_localTemplate; |
|
72 | 75 | } |
73 | - else |
|
74 | - return $this->_localTemplate; |
|
75 | 76 | } |
76 | 77 | |
77 | 78 | /** |
@@ -92,10 +93,11 @@ discard block |
||
92 | 93 | */ |
93 | 94 | public function getIsSourceTemplateControl() |
94 | 95 | { |
95 | - if(($template=$this->getTemplate())!==null) |
|
96 | - return $template->getIsSourceTemplate(); |
|
97 | - else |
|
98 | - return false; |
|
96 | + if(($template=$this->getTemplate())!==null) { |
|
97 | + return $template->getIsSourceTemplate(); |
|
98 | + } else { |
|
99 | + return false; |
|
100 | + } |
|
99 | 101 | } |
100 | 102 | |
101 | 103 | /** |
@@ -103,10 +105,11 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public function getTemplateDirectory() |
105 | 107 | { |
106 | - if(($template=$this->getTemplate())!==null) |
|
107 | - return $template->getContextPath(); |
|
108 | - else |
|
109 | - return ''; |
|
108 | + if(($template=$this->getTemplate())!==null) { |
|
109 | + return $template->getContextPath(); |
|
110 | + } else { |
|
111 | + return ''; |
|
112 | + } |
|
110 | 113 | } |
111 | 114 | |
112 | 115 | /** |
@@ -131,10 +134,11 @@ discard block |
||
131 | 134 | { |
132 | 135 | foreach($tpl->getDirective() as $name=>$value) |
133 | 136 | { |
134 | - if(is_string($value)) |
|
135 | - $this->setSubProperty($name,$value); |
|
136 | - else |
|
137 | - throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name); |
|
137 | + if(is_string($value)) { |
|
138 | + $this->setSubProperty($name,$value); |
|
139 | + } else { |
|
140 | + throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name); |
|
141 | + } |
|
138 | 142 | } |
139 | 143 | $tpl->instantiateIn($this); |
140 | 144 | } |
@@ -147,10 +151,11 @@ discard block |
||
147 | 151 | */ |
148 | 152 | public function registerContent($id,TContent $object) |
149 | 153 | { |
150 | - if(isset($this->_contents[$id])) |
|
151 | - throw new TConfigurationException('templatecontrol_contentid_duplicated',$id); |
|
152 | - else |
|
153 | - $this->_contents[$id]=$object; |
|
154 | + if(isset($this->_contents[$id])) { |
|
155 | + throw new TConfigurationException('templatecontrol_contentid_duplicated',$id); |
|
156 | + } else { |
|
157 | + $this->_contents[$id]=$object; |
|
158 | + } |
|
154 | 159 | } |
155 | 160 | |
156 | 161 | /** |
@@ -161,10 +166,11 @@ discard block |
||
161 | 166 | */ |
162 | 167 | public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
163 | 168 | { |
164 | - if(isset($this->_placeholders[$id])) |
|
165 | - throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id); |
|
166 | - else |
|
167 | - $this->_placeholders[$id]=$object; |
|
169 | + if(isset($this->_placeholders[$id])) { |
|
170 | + throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id); |
|
171 | + } else { |
|
172 | + $this->_placeholders[$id]=$object; |
|
173 | + } |
|
168 | 174 | } |
169 | 175 | |
170 | 176 | /** |
@@ -205,9 +211,9 @@ discard block |
||
205 | 211 | $controls=$placeholder->getParent()->getControls(); |
206 | 212 | $loc=$controls->remove($placeholder); |
207 | 213 | $controls->insertAt($loc,$content); |
214 | + } else { |
|
215 | + throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
|
208 | 216 | } |
209 | - else |
|
210 | - throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
|
211 | 217 | } |
212 | 218 | |
213 | 219 | /** |
@@ -224,17 +230,19 @@ discard block |
||
224 | 230 | if($this->_masterClass!=='') |
225 | 231 | { |
226 | 232 | $master=Prado::createComponent($this->_masterClass); |
227 | - if(!($master instanceof TTemplateControl)) |
|
228 | - throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid'); |
|
233 | + if(!($master instanceof TTemplateControl)) { |
|
234 | + throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid'); |
|
235 | + } |
|
229 | 236 | $this->_master=$master; |
230 | 237 | $this->getControls()->clear(); |
231 | 238 | $this->getControls()->add($master); |
232 | 239 | $master->ensureChildControls(); |
233 | - foreach($this->_contents as $id=>$content) |
|
234 | - $master->injectContent($id,$content); |
|
240 | + foreach($this->_contents as $id=>$content) { |
|
241 | + $master->injectContent($id,$content); |
|
242 | + } |
|
243 | + } else if(!empty($this->_contents)) { |
|
244 | + throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
|
235 | 245 | } |
236 | - else if(!empty($this->_contents)) |
|
237 | - throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
|
238 | 246 | parent::initRecursive($namingContainer); |
239 | 247 | } |
240 | 248 | |
@@ -255,14 +263,14 @@ discard block |
||
255 | 263 | if ($key != "RELATIONS") |
256 | 264 | { |
257 | 265 | $control = $this->{$key}; |
258 | - if ($control instanceof TTextBox) |
|
259 | - $control->Text = $arObj->{$key}; |
|
260 | - elseif ($control instanceof TCheckBox) |
|
261 | - $control->Checked = (boolean) $arObj->{$key}; |
|
262 | - elseif ($control instanceof TDatePicker) |
|
263 | - $control->Date = $arObj->{$key}; |
|
264 | - } |
|
265 | - else |
|
266 | + if ($control instanceof TTextBox) { |
|
267 | + $control->Text = $arObj->{$key}; |
|
268 | + } elseif ($control instanceof TCheckBox) { |
|
269 | + $control->Checked = (boolean) $arObj->{$key}; |
|
270 | + } elseif ($control instanceof TDatePicker) { |
|
271 | + $control->Date = $arObj->{$key}; |
|
272 | + } |
|
273 | + } else |
|
266 | 274 | { |
267 | 275 | foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
268 | 276 | { |
@@ -284,11 +292,11 @@ discard block |
||
284 | 292 | } |
285 | 293 | break; |
286 | 294 | } |
287 | - } |
|
288 | - catch (Exception $ex) |
|
295 | + } catch (Exception $ex) |
|
289 | 296 | { |
290 | - if ($throwExceptions) |
|
291 | - throw $ex; |
|
297 | + if ($throwExceptions) { |
|
298 | + throw $ex; |
|
299 | + } |
|
292 | 300 | } |
293 | 301 | } |
294 | 302 | } |
@@ -306,20 +314,22 @@ discard block |
||
306 | 314 | { |
307 | 315 | try |
308 | 316 | { |
309 | - if ($key == "RELATIONS") |
|
310 | - break; |
|
317 | + if ($key == "RELATIONS") { |
|
318 | + break; |
|
319 | + } |
|
311 | 320 | $control = $this->{$key}; |
312 | - if ($control instanceof TTextBox) |
|
313 | - $arObj->{$key} = $control->Text; |
|
314 | - elseif ($control instanceof TCheckBox) |
|
315 | - $arObj->{$key} = $control->Checked; |
|
316 | - elseif ($control instanceof TDatePicker) |
|
317 | - $arObj->{$key} = $control->Date; |
|
318 | - } |
|
319 | - catch (Exception $ex) |
|
321 | + if ($control instanceof TTextBox) { |
|
322 | + $arObj->{$key} = $control->Text; |
|
323 | + } elseif ($control instanceof TCheckBox) { |
|
324 | + $arObj->{$key} = $control->Checked; |
|
325 | + } elseif ($control instanceof TDatePicker) { |
|
326 | + $arObj->{$key} = $control->Date; |
|
327 | + } |
|
328 | + } catch (Exception $ex) |
|
320 | 329 | { |
321 | - if ($throwExceptions) |
|
322 | - throw $ex; |
|
330 | + if ($throwExceptions) { |
|
331 | + throw $ex; |
|
332 | + } |
|
323 | 333 | } |
324 | 334 | } |
325 | 335 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | /** |
77 | 77 | * This method creates the template object for the given class |
78 | 78 | * |
79 | - * @param string $p_class The class to create the template from |
|
79 | + * @param string $parentClass |
|
80 | 80 | * @return void |
81 | 81 | * @throws TConfigurationException if a template control directive is invalid |
82 | 82 | */ |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function createChildControls() |
45 | 45 | { |
46 | - if(null === ($_template = $this->getTemplate())) { |
|
46 | + if (null === ($_template = $this->getTemplate())) { |
|
47 | 47 | return $this->doCreateChildControlsFor(get_class($this)); |
48 | 48 | } |
49 | 49 | |
50 | - foreach($_template->getDirective() as $_name => $_value) { |
|
51 | - if(!is_string($_value)) { |
|
50 | + foreach ($_template->getDirective() as $_name => $_value) { |
|
51 | + if (!is_string($_value)) { |
|
52 | 52 | throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name); |
53 | 53 | } |
54 | 54 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function doCreateChildControlsFor($parentClass) |
68 | 68 | { |
69 | - if(false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) { |
|
69 | + if (false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) { |
|
70 | 70 | $this->doCreateChildControlsFor($_parentClass); |
71 | 71 | } |
72 | 72 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function doTemplateForClass($parentClass) |
84 | 84 | { |
85 | - if(null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
86 | - foreach($_template->getDirective() as $_name => $_value) { |
|
87 | - if(!is_string($_value)) { |
|
85 | + if (null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
86 | + foreach ($_template->getDirective() as $_name => $_value) { |
|
87 | + if (!is_string($_value)) { |
|
88 | 88 | throw new TConfigurationException('templatecontrol_directive_invalid', get_class(this), $_name); |
89 | 89 | } |
90 | 90 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getIsSourceTemplateControl() |
107 | 107 | { |
108 | - if(null !== ($_template = $this->getTemplate())) { |
|
108 | + if (null !== ($_template = $this->getTemplate())) { |
|
109 | 109 | return $_template->getIsSourceTemplate(); |
110 | 110 | } |
111 | 111 |