@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | |
94 | 94 | // communicate validation status to the client side |
95 | 95 | $value = $this->_isvalid === false ? '0' : '1'; |
96 | - $cs->registerHiddenField($this->getClientID() . '_1', $value); |
|
96 | + $cs->registerHiddenField($this->getClientID().'_1', $value); |
|
97 | 97 | |
98 | 98 | // update validator display |
99 | 99 | if ($control = $this->getValidationTarget()) |
100 | 100 | { |
101 | - $fn = 'captchaUpdateValidatorStatus_' . $this->getClientID(); |
|
101 | + $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
102 | 102 | |
103 | 103 | // check if we need to request a new captcha too |
104 | 104 | if ($this->Page->IsCallback) |
@@ -114,21 +114,21 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - $cs->registerEndScript($this->getClientID() . '::validate', implode(' ', [ |
|
117 | + $cs->registerEndScript($this->getClientID().'::validate', implode(' ', [ |
|
118 | 118 | // this function will be used to update the validator |
119 | - 'function ' . $fn . '(valid)', |
|
119 | + 'function '.$fn.'(valid)', |
|
120 | 120 | '{', |
121 | - ' jQuery(' . TJavaScript::quoteString('#' . $this->getClientID() . '_1') . ').val(valid);', |
|
122 | - ' Prado.Validation.validateControl(' . TJavaScript::quoteString($control->ClientID) . '); ', |
|
121 | + ' jQuery('.TJavaScript::quoteString('#'.$this->getClientID().'_1').').val(valid);', |
|
122 | + ' Prado.Validation.validateControl('.TJavaScript::quoteString($control->ClientID).'); ', |
|
123 | 123 | '}', |
124 | 124 | '', |
125 | 125 | // update the validator to the result if we're in a callback |
126 | 126 | // (if we're in initial rendering or a postback then the result will be rendered directly to the page html anyway) |
127 | - $this->Page->IsCallback ? $fn . '(' . $value . ');' : '', |
|
127 | + $this->Page->IsCallback ? $fn.'('.$value.');' : '', |
|
128 | 128 | '', |
129 | 129 | // install event handler that clears the validation error when user changes the captcha response field |
130 | - 'jQuery("#' . $control->getClientID() . '").on("keyup", ' . TJavaScript::quoteString('#' . $control->getResponseFieldName()) . ', function() { ', |
|
131 | - $fn . '("1");', |
|
130 | + 'jQuery("#'.$control->getClientID().'").on("keyup", '.TJavaScript::quoteString('#'.$control->getResponseFieldName()).', function() { ', |
|
131 | + $fn.'("1");', |
|
132 | 132 | '});', |
133 | 133 | ])); |
134 | 134 | } |
@@ -52,10 +52,12 @@ discard block |
||
52 | 52 | protected function getCaptchaControl() |
53 | 53 | { |
54 | 54 | $control = $this->getValidationTarget(); |
55 | - if (!$control) |
|
56 | - throw new Exception('No target control specified for TReCaptchaValidator'); |
|
57 | - if (!($control instanceof TReCaptcha)) |
|
58 | - throw new Exception('TReCaptchaValidator only works with TReCaptcha controls'); |
|
55 | + if (!$control) { |
|
56 | + throw new Exception('No target control specified for TReCaptchaValidator'); |
|
57 | + } |
|
58 | + if (!($control instanceof TReCaptcha)) { |
|
59 | + throw new Exception('TReCaptchaValidator only works with TReCaptcha controls'); |
|
60 | + } |
|
59 | 61 | return $control; |
60 | 62 | } |
61 | 63 | |
@@ -103,14 +105,15 @@ discard block |
||
103 | 105 | // check if we need to request a new captcha too |
104 | 106 | if ($this->Page->IsCallback) |
105 | 107 | { |
106 | - if ($control->getVisible(true)) |
|
107 | - if (null !== $this->_isvalid) |
|
108 | + if ($control->getVisible(true)) { |
|
109 | + if (null !== $this->_isvalid) |
|
108 | 110 | { |
109 | 111 | // if the response has been tested and we reach the pre-render phase |
110 | 112 | // then we need to regenerate the token, because it won't test positive |
111 | 113 | // anymore, even if solves correctly |
112 | 114 | |
113 | 115 | $control->regenerateToken(); |
116 | + } |
|
114 | 117 | } |
115 | 118 | } |
116 | 119 |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function onUnload($param) |
126 | 126 | { |
127 | - if($this->_registered && ($page = $this->getPage()) !== null) |
|
127 | + if ($this->_registered && ($page = $this->getPage()) !== null) |
|
128 | 128 | $page->getValidators()->remove($this); |
129 | 129 | $this->_registered = false; |
130 | 130 | parent::onUnload($param); |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | { |
140 | 140 | $display = $this->getDisplay(); |
141 | 141 | $visible = $this->getEnabled(true) && !$this->getIsValid(); |
142 | - if($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic)) |
|
142 | + if ($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic)) |
|
143 | 143 | $writer->addStyleAttribute('display', 'none'); |
144 | - elseif(!$visible) |
|
144 | + elseif (!$visible) |
|
145 | 145 | $writer->addStyleAttribute('visibility', 'hidden'); |
146 | 146 | $writer->addAttribute('id', $this->getClientID()); |
147 | 147 | parent::addAttributesToRender($writer); |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | $options['FormID'] = $this->getPage()->getForm()->getClientID(); |
160 | 160 | $options['Display'] = $this->getDisplay(); |
161 | 161 | $options['ErrorMessage'] = $this->getErrorMessage(); |
162 | - if($this->getFocusOnError()) |
|
162 | + if ($this->getFocusOnError()) |
|
163 | 163 | { |
164 | 164 | $options['FocusOnError'] = $this->getFocusOnError(); |
165 | 165 | $options['FocusElementID'] = $this->getFocusElementID(); |
166 | 166 | } |
167 | 167 | $options['ValidationGroup'] = $this->getValidationGroup(); |
168 | - if($control) |
|
168 | + if ($control) |
|
169 | 169 | $options['ControlToValidate'] = $control->getClientID(); |
170 | 170 | $options['ControlCssClass'] = $this->getControlCssClass(); |
171 | 171 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $options['Enabled'] = $this->getEnabled(true); |
174 | 174 | |
175 | 175 | //get date format from date picker target control |
176 | - if($control instanceof TDatePicker) |
|
176 | + if ($control instanceof TDatePicker) |
|
177 | 177 | $options['DateFormat'] = $control->getDateFormat(); |
178 | 178 | |
179 | 179 | $options = array_merge($options, $this->getClientSide()->getOptions()->toArray()); |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | private function getClientControlClass($control) |
192 | 192 | { |
193 | - foreach(self::$_clientClass as $type) |
|
194 | - if($control instanceof $type) |
|
193 | + foreach (self::$_clientClass as $type) |
|
194 | + if ($control instanceof $type) |
|
195 | 195 | return $type; |
196 | 196 | $reflectionClass = new \ReflectionClass($control); |
197 | 197 | return $reflectionClass->getShortName(); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function getClientSide() |
217 | 217 | { |
218 | - if($this->_clientSide === null) |
|
218 | + if ($this->_clientSide === null) |
|
219 | 219 | $this->_clientSide = $this->createClientSide(); |
220 | 220 | return $this->_clientSide; |
221 | 221 | } |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | $scripts->registerPradoScript('validator'); |
242 | 242 | $formID = $this->getPage()->getForm()->getClientID(); |
243 | 243 | $scriptKey = "TBaseValidator:$formID"; |
244 | - if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) |
|
244 | + if ($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) |
|
245 | 245 | { |
246 | 246 | $manager['FormID'] = $formID; |
247 | 247 | $options = TJavaScript::encode($manager); |
248 | 248 | $scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); |
249 | 249 | } |
250 | - if($this->getEnableClientScript()) |
|
250 | + if ($this->getEnableClientScript()) |
|
251 | 251 | $this->registerClientScriptValidator(); |
252 | 252 | } |
253 | 253 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * Override parent implementation to update the control CSS Class before |
256 | 256 | * the validated control is rendered |
257 | 257 | */ |
258 | - public function onPreRender ($param) |
|
258 | + public function onPreRender($param) |
|
259 | 259 | { |
260 | 260 | parent::onPreRender($param); |
261 | 261 | $this->updateControlCssClass(); |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | */ |
269 | 269 | protected function updateControlCssClass() |
270 | 270 | { |
271 | - if(($cssClass = $this->getControlCssClass()) !== '') |
|
271 | + if (($cssClass = $this->getControlCssClass()) !== '') |
|
272 | 272 | { |
273 | 273 | $control = $this->getValidationTarget(); |
274 | - if($control instanceof TWebControl) |
|
274 | + if ($control instanceof TWebControl) |
|
275 | 275 | { |
276 | - $class = preg_replace('/ ' . preg_quote($cssClass) . '/', '', $control->getCssClass()); |
|
277 | - if(!$this->getIsValid()) |
|
276 | + $class = preg_replace('/ '.preg_quote($cssClass).'/', '', $control->getCssClass()); |
|
277 | + if (!$this->getIsValid()) |
|
278 | 278 | { |
279 | - $class .= ' ' . $cssClass; |
|
279 | + $class .= ' '.$cssClass; |
|
280 | 280 | $control->setCssClass($class); |
281 | 281 | } elseif ($control->getIsValid()) |
282 | 282 | $control->setCssClass($class); |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | */ |
290 | 290 | protected function registerClientScriptValidator() |
291 | 291 | { |
292 | - $key = 'prado:' . $this->getClientID(); |
|
293 | - if(!$this->getPage()->getClientScript()->isEndScriptRegistered($key)) |
|
292 | + $key = 'prado:'.$this->getClientID(); |
|
293 | + if (!$this->getPage()->getClientScript()->isEndScriptRegistered($key)) |
|
294 | 294 | { |
295 | 295 | $options = TJavaScript::encode($this->getClientScriptOptions()); |
296 | - $script = 'new ' . $this->getClientClassName() . '(' . $options . ');'; |
|
296 | + $script = 'new '.$this->getClientClassName().'('.$options.');'; |
|
297 | 297 | $this->getPage()->getClientScript()->registerEndScript($key, $script); |
298 | 298 | } |
299 | 299 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | { |
324 | 324 | $value = TPropertyValue::ensureBoolean($value); |
325 | 325 | parent::setEnabled($value); |
326 | - if(!$value) |
|
326 | + if (!$value) |
|
327 | 327 | $this->_isValid = true; |
328 | 328 | } |
329 | 329 | |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function getFocusElementID() |
420 | 420 | { |
421 | - if(($id = $this->getViewState('FocusElementID', '')) === '') |
|
421 | + if (($id = $this->getViewState('FocusElementID', '')) === '') |
|
422 | 422 | { |
423 | 423 | $target = $this->getValidationTarget(); |
424 | 424 | /* Workaround: TCheckBoxList and TRadioButtonList nests the actual |
425 | 425 | * inputs inside a table; we ensure the first input gets focused |
426 | 426 | */ |
427 | - if($target instanceof TCheckBoxList && $target->getItemCount() > 0) |
|
427 | + if ($target instanceof TCheckBoxList && $target->getItemCount() > 0) |
|
428 | 428 | { |
429 | - $id = $target->getClientID() . '_c0'; |
|
429 | + $id = $target->getClientID().'_c0'; |
|
430 | 430 | } else { |
431 | 431 | $id = $target->getClientID(); |
432 | 432 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | */ |
484 | 484 | public function getValidationTarget() |
485 | 485 | { |
486 | - if(($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null) |
|
486 | + if (($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null) |
|
487 | 487 | return $control; |
488 | 488 | else |
489 | 489 | throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this)); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | */ |
498 | 498 | protected function getValidationValue($control) |
499 | 499 | { |
500 | - if($control instanceof \Prado\Web\UI\IValidatable) |
|
500 | + if ($control instanceof \Prado\Web\UI\IValidatable) |
|
501 | 501 | return $control->getValidationPropertyValue(); |
502 | 502 | else |
503 | 503 | throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this)); |
@@ -511,22 +511,22 @@ discard block |
||
511 | 511 | public function validate() |
512 | 512 | { |
513 | 513 | $this->onValidate(); |
514 | - if($this->getVisible(true) && $this->getEnabled(true)) |
|
514 | + if ($this->getVisible(true) && $this->getEnabled(true)) |
|
515 | 515 | { |
516 | 516 | $target = $this->getValidationTarget(); |
517 | 517 | // if the target is not a disabled web control |
518 | - if($target === null || |
|
518 | + if ($target === null || |
|
519 | 519 | ($target !== null && |
520 | 520 | !($target instanceof TWebControl && !$target->getEnabled(true)))) |
521 | 521 | { |
522 | - if($this->evaluateIsValid()) |
|
522 | + if ($this->evaluateIsValid()) |
|
523 | 523 | { |
524 | 524 | $this->setIsValid(true); |
525 | 525 | $this->onValidationSuccess(); |
526 | 526 | } |
527 | 527 | else |
528 | 528 | { |
529 | - if($target) |
|
529 | + if ($target) |
|
530 | 530 | $target->setIsValid(false); |
531 | 531 | $this->setIsValid(false); |
532 | 532 | $this->onValidationError(); |
@@ -600,9 +600,9 @@ discard block |
||
600 | 600 | */ |
601 | 601 | public function renderContents($writer) |
602 | 602 | { |
603 | - if(($text = $this->getText()) !== '') |
|
603 | + if (($text = $this->getText()) !== '') |
|
604 | 604 | $writer->write($text); |
605 | - elseif(($text = $this->getErrorMessage()) !== '') |
|
605 | + elseif (($text = $this->getErrorMessage()) !== '') |
|
606 | 606 | $writer->write($text); |
607 | 607 | else |
608 | 608 | parent::renderContents($writer); |
@@ -124,8 +124,9 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function onUnload($param) |
126 | 126 | { |
127 | - if($this->_registered && ($page = $this->getPage()) !== null) |
|
128 | - $page->getValidators()->remove($this); |
|
127 | + if($this->_registered && ($page = $this->getPage()) !== null) { |
|
128 | + $page->getValidators()->remove($this); |
|
129 | + } |
|
129 | 130 | $this->_registered = false; |
130 | 131 | parent::onUnload($param); |
131 | 132 | } |
@@ -139,10 +140,11 @@ discard block |
||
139 | 140 | { |
140 | 141 | $display = $this->getDisplay(); |
141 | 142 | $visible = $this->getEnabled(true) && !$this->getIsValid(); |
142 | - if($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic)) |
|
143 | - $writer->addStyleAttribute('display', 'none'); |
|
144 | - elseif(!$visible) |
|
145 | - $writer->addStyleAttribute('visibility', 'hidden'); |
|
143 | + if($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic)) { |
|
144 | + $writer->addStyleAttribute('display', 'none'); |
|
145 | + } elseif(!$visible) { |
|
146 | + $writer->addStyleAttribute('visibility', 'hidden'); |
|
147 | + } |
|
146 | 148 | $writer->addAttribute('id', $this->getClientID()); |
147 | 149 | parent::addAttributesToRender($writer); |
148 | 150 | $this->renderClientControlScript($writer); |
@@ -165,16 +167,18 @@ discard block |
||
165 | 167 | $options['FocusElementID'] = $this->getFocusElementID(); |
166 | 168 | } |
167 | 169 | $options['ValidationGroup'] = $this->getValidationGroup(); |
168 | - if($control) |
|
169 | - $options['ControlToValidate'] = $control->getClientID(); |
|
170 | + if($control) { |
|
171 | + $options['ControlToValidate'] = $control->getClientID(); |
|
172 | + } |
|
170 | 173 | $options['ControlCssClass'] = $this->getControlCssClass(); |
171 | 174 | |
172 | 175 | $options['ControlType'] = $this->getClientControlClass($control); |
173 | 176 | $options['Enabled'] = $this->getEnabled(true); |
174 | 177 | |
175 | 178 | //get date format from date picker target control |
176 | - if($control instanceof TDatePicker) |
|
177 | - $options['DateFormat'] = $control->getDateFormat(); |
|
179 | + if($control instanceof TDatePicker) { |
|
180 | + $options['DateFormat'] = $control->getDateFormat(); |
|
181 | + } |
|
178 | 182 | |
179 | 183 | $options = array_merge($options, $this->getClientSide()->getOptions()->toArray()); |
180 | 184 | |
@@ -190,9 +194,10 @@ discard block |
||
190 | 194 | */ |
191 | 195 | private function getClientControlClass($control) |
192 | 196 | { |
193 | - foreach(self::$_clientClass as $type) |
|
194 | - if($control instanceof $type) |
|
197 | + foreach(self::$_clientClass as $type) { |
|
198 | + if($control instanceof $type) |
|
195 | 199 | return $type; |
200 | + } |
|
196 | 201 | $reflectionClass = new \ReflectionClass($control); |
197 | 202 | return $reflectionClass->getShortName(); |
198 | 203 | } |
@@ -215,8 +220,9 @@ discard block |
||
215 | 220 | */ |
216 | 221 | public function getClientSide() |
217 | 222 | { |
218 | - if($this->_clientSide === null) |
|
219 | - $this->_clientSide = $this->createClientSide(); |
|
223 | + if($this->_clientSide === null) { |
|
224 | + $this->_clientSide = $this->createClientSide(); |
|
225 | + } |
|
220 | 226 | return $this->_clientSide; |
221 | 227 | } |
222 | 228 | |
@@ -237,8 +243,9 @@ discard block |
||
237 | 243 | public function renderClientControlScript($writer) |
238 | 244 | { |
239 | 245 | $scripts = $this->getPage()->getClientScript(); |
240 | - if ($this->getEnableClientScript()) |
|
241 | - $scripts->registerPradoScript('validator'); |
|
246 | + if ($this->getEnableClientScript()) { |
|
247 | + $scripts->registerPradoScript('validator'); |
|
248 | + } |
|
242 | 249 | $formID = $this->getPage()->getForm()->getClientID(); |
243 | 250 | $scriptKey = "TBaseValidator:$formID"; |
244 | 251 | if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) |
@@ -247,8 +254,9 @@ discard block |
||
247 | 254 | $options = TJavaScript::encode($manager); |
248 | 255 | $scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); |
249 | 256 | } |
250 | - if($this->getEnableClientScript()) |
|
251 | - $this->registerClientScriptValidator(); |
|
257 | + if($this->getEnableClientScript()) { |
|
258 | + $this->registerClientScriptValidator(); |
|
259 | + } |
|
252 | 260 | } |
253 | 261 | |
254 | 262 | /** |
@@ -278,8 +286,9 @@ discard block |
||
278 | 286 | { |
279 | 287 | $class .= ' ' . $cssClass; |
280 | 288 | $control->setCssClass($class); |
281 | - } elseif ($control->getIsValid()) |
|
282 | - $control->setCssClass($class); |
|
289 | + } elseif ($control->getIsValid()) { |
|
290 | + $control->setCssClass($class); |
|
291 | + } |
|
283 | 292 | } |
284 | 293 | } |
285 | 294 | } |
@@ -323,8 +332,9 @@ discard block |
||
323 | 332 | { |
324 | 333 | $value = TPropertyValue::ensureBoolean($value); |
325 | 334 | parent::setEnabled($value); |
326 | - if(!$value) |
|
327 | - $this->_isValid = true; |
|
335 | + if(!$value) { |
|
336 | + $this->_isValid = true; |
|
337 | + } |
|
328 | 338 | } |
329 | 339 | |
330 | 340 | /** |
@@ -483,10 +493,11 @@ discard block |
||
483 | 493 | */ |
484 | 494 | public function getValidationTarget() |
485 | 495 | { |
486 | - if(($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null) |
|
487 | - return $control; |
|
488 | - else |
|
489 | - throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this)); |
|
496 | + if(($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null) { |
|
497 | + return $control; |
|
498 | + } else { |
|
499 | + throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this)); |
|
500 | + } |
|
490 | 501 | } |
491 | 502 | |
492 | 503 | /** |
@@ -497,10 +508,11 @@ discard block |
||
497 | 508 | */ |
498 | 509 | protected function getValidationValue($control) |
499 | 510 | { |
500 | - if($control instanceof \Prado\Web\UI\IValidatable) |
|
501 | - return $control->getValidationPropertyValue(); |
|
502 | - else |
|
503 | - throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this)); |
|
511 | + if($control instanceof \Prado\Web\UI\IValidatable) { |
|
512 | + return $control->getValidationPropertyValue(); |
|
513 | + } else { |
|
514 | + throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this)); |
|
515 | + } |
|
504 | 516 | } |
505 | 517 | |
506 | 518 | /** |
@@ -523,16 +535,15 @@ discard block |
||
523 | 535 | { |
524 | 536 | $this->setIsValid(true); |
525 | 537 | $this->onValidationSuccess(); |
526 | - } |
|
527 | - else |
|
538 | + } else |
|
528 | 539 | { |
529 | - if($target) |
|
530 | - $target->setIsValid(false); |
|
540 | + if($target) { |
|
541 | + $target->setIsValid(false); |
|
542 | + } |
|
531 | 543 | $this->setIsValid(false); |
532 | 544 | $this->onValidationError(); |
533 | 545 | } |
534 | - } |
|
535 | - else |
|
546 | + } else |
|
536 | 547 | { |
537 | 548 | $this->evaluateIsValid(); |
538 | 549 | $this->setIsValid(true); |
@@ -600,11 +611,12 @@ discard block |
||
600 | 611 | */ |
601 | 612 | public function renderContents($writer) |
602 | 613 | { |
603 | - if(($text = $this->getText()) !== '') |
|
604 | - $writer->write($text); |
|
605 | - elseif(($text = $this->getErrorMessage()) !== '') |
|
606 | - $writer->write($text); |
|
607 | - else |
|
608 | - parent::renderContents($writer); |
|
614 | + if(($text = $this->getText()) !== '') { |
|
615 | + $writer->write($text); |
|
616 | + } elseif(($text = $this->getErrorMessage()) !== '') { |
|
617 | + $writer->write($text); |
|
618 | + } else { |
|
619 | + parent::renderContents($writer); |
|
620 | + } |
|
609 | 621 | } |
610 | 622 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function insertAt($index, $item) |
36 | 36 | { |
37 | - if($item instanceof TTabView) |
|
37 | + if ($item instanceof TTabView) |
|
38 | 38 | parent::insertAt($index, $item); |
39 | 39 | else |
40 | 40 | throw new TInvalidDataTypeException('tabviewcollection_tabview_required'); |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function findIndexByID($id) |
49 | 49 | { |
50 | - foreach($this as $index => $view) |
|
50 | + foreach ($this as $index => $view) |
|
51 | 51 | { |
52 | - if($view->getID(false) === $id) |
|
52 | + if ($view->getID(false) === $id) |
|
53 | 53 | return $index; |
54 | 54 | } |
55 | 55 | return -1; |
@@ -34,10 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function insertAt($index, $item) |
36 | 36 | { |
37 | - if($item instanceof TTabView) |
|
38 | - parent::insertAt($index, $item); |
|
39 | - else |
|
40 | - throw new TInvalidDataTypeException('tabviewcollection_tabview_required'); |
|
37 | + if($item instanceof TTabView) { |
|
38 | + parent::insertAt($index, $item); |
|
39 | + } else { |
|
40 | + throw new TInvalidDataTypeException('tabviewcollection_tabview_required'); |
|
41 | + } |
|
41 | 42 | } |
42 | 43 | |
43 | 44 | /** |
@@ -49,8 +50,9 @@ discard block |
||
49 | 50 | { |
50 | 51 | foreach($this as $index => $view) |
51 | 52 | { |
52 | - if($view->getID(false) === $id) |
|
53 | - return $index; |
|
53 | + if($view->getID(false) === $id) { |
|
54 | + return $index; |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | return -1; |
56 | 58 | } |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected function findCaptchaControl() |
88 | 88 | { |
89 | - if(($id = $this->getCaptchaControl()) === '') |
|
89 | + if (($id = $this->getCaptchaControl()) === '') |
|
90 | 90 | throw new TConfigurationException('captchavalidator_captchacontrol_required'); |
91 | - elseif(($control = $this->findControl($id)) === null) |
|
91 | + elseif (($control = $this->findControl($id)) === null) |
|
92 | 92 | throw new TConfigurationException('captchavalidator_captchacontrol_inexistent', $id); |
93 | - elseif(!($control instanceof TCaptcha)) |
|
93 | + elseif (!($control instanceof TCaptcha)) |
|
94 | 94 | throw new TConfigurationException('captchavalidator_captchacontrol_invalid', $id); |
95 | 95 | else |
96 | 96 | return $control; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | $options = parent::getClientScriptOptions(); |
106 | 106 | $control = $this->findCaptchaControl(); |
107 | - if($control->getCaseSensitive()) |
|
107 | + if ($control->getCaseSensitive()) |
|
108 | 108 | { |
109 | 109 | $options['TokenHash'] = $this->generateTokenHash($control->getToken()); |
110 | 110 | $options['CaseSensitive'] = true; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | private function generateTokenHash($token) |
121 | 121 | { |
122 | - for($h = 0,$i = strlen($token) - 1;$i >= 0;--$i) |
|
122 | + for ($h = 0, $i = strlen($token) - 1; $i >= 0; --$i) |
|
123 | 123 | $h += ord($token[$i]); |
124 | 124 | return $h; |
125 | 125 | } |
@@ -86,14 +86,15 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected function findCaptchaControl() |
88 | 88 | { |
89 | - if(($id = $this->getCaptchaControl()) === '') |
|
90 | - throw new TConfigurationException('captchavalidator_captchacontrol_required'); |
|
91 | - elseif(($control = $this->findControl($id)) === null) |
|
92 | - throw new TConfigurationException('captchavalidator_captchacontrol_inexistent', $id); |
|
93 | - elseif(!($control instanceof TCaptcha)) |
|
94 | - throw new TConfigurationException('captchavalidator_captchacontrol_invalid', $id); |
|
95 | - else |
|
96 | - return $control; |
|
89 | + if(($id = $this->getCaptchaControl()) === '') { |
|
90 | + throw new TConfigurationException('captchavalidator_captchacontrol_required'); |
|
91 | + } elseif(($control = $this->findControl($id)) === null) { |
|
92 | + throw new TConfigurationException('captchavalidator_captchacontrol_inexistent', $id); |
|
93 | + } elseif(!($control instanceof TCaptcha)) { |
|
94 | + throw new TConfigurationException('captchavalidator_captchacontrol_invalid', $id); |
|
95 | + } else { |
|
96 | + return $control; |
|
97 | + } |
|
97 | 98 | } |
98 | 99 | |
99 | 100 | /** |
@@ -108,8 +109,7 @@ discard block |
||
108 | 109 | { |
109 | 110 | $options['TokenHash'] = $this->generateTokenHash($control->getToken()); |
110 | 111 | $options['CaseSensitive'] = true; |
111 | - } |
|
112 | - else |
|
112 | + } else |
|
113 | 113 | { |
114 | 114 | $options['TokenHash'] = $this->generateTokenHash(strtoupper($control->getToken())); |
115 | 115 | $options['CaseSensitive'] = false; |
@@ -119,8 +119,9 @@ discard block |
||
119 | 119 | |
120 | 120 | private function generateTokenHash($token) |
121 | 121 | { |
122 | - for($h = 0,$i = strlen($token) - 1;$i >= 0;--$i) |
|
123 | - $h += ord($token[$i]); |
|
122 | + for($h = 0,$i = strlen($token) - 1;$i >= 0;--$i) { |
|
123 | + $h += ord($token[$i]); |
|
124 | + } |
|
124 | 125 | return $h; |
125 | 126 | } |
126 | 127 | } |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | public function copyFrom($style) |
97 | 97 | { |
98 | 98 | parent::copyFrom($style); |
99 | - if($style instanceof TTableStyle) |
|
99 | + if ($style instanceof TTableStyle) |
|
100 | 100 | { |
101 | - if($style->_backImageUrl !== null) |
|
101 | + if ($style->_backImageUrl !== null) |
|
102 | 102 | $this->_backImageUrl = $style->_backImageUrl; |
103 | - if($style->_horizontalAlign !== null) |
|
103 | + if ($style->_horizontalAlign !== null) |
|
104 | 104 | $this->_horizontalAlign = $style->_horizontalAlign; |
105 | - if($style->_cellPadding !== null) |
|
105 | + if ($style->_cellPadding !== null) |
|
106 | 106 | $this->_cellPadding = $style->_cellPadding; |
107 | - if($style->_cellSpacing !== null) |
|
107 | + if ($style->_cellSpacing !== null) |
|
108 | 108 | $this->_cellSpacing = $style->_cellSpacing; |
109 | - if($style->_gridLines !== null) |
|
109 | + if ($style->_gridLines !== null) |
|
110 | 110 | $this->_gridLines = $style->_gridLines; |
111 | - if($style->_borderCollapse !== null) |
|
111 | + if ($style->_borderCollapse !== null) |
|
112 | 112 | $this->_borderCollapse = $style->_borderCollapse; |
113 | 113 | } |
114 | 114 | } |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | public function mergeWith($style) |
123 | 123 | { |
124 | 124 | parent::mergeWith($style); |
125 | - if($style instanceof TTableStyle) |
|
125 | + if ($style instanceof TTableStyle) |
|
126 | 126 | { |
127 | - if($this->_backImageUrl === null && $style->_backImageUrl !== null) |
|
127 | + if ($this->_backImageUrl === null && $style->_backImageUrl !== null) |
|
128 | 128 | $this->_backImageUrl = $style->_backImageUrl; |
129 | - if($this->_horizontalAlign === null && $style->_horizontalAlign !== null) |
|
129 | + if ($this->_horizontalAlign === null && $style->_horizontalAlign !== null) |
|
130 | 130 | $this->_horizontalAlign = $style->_horizontalAlign; |
131 | - if($this->_cellPadding === null && $style->_cellPadding !== null) |
|
131 | + if ($this->_cellPadding === null && $style->_cellPadding !== null) |
|
132 | 132 | $this->_cellPadding = $style->_cellPadding; |
133 | - if($this->_cellSpacing === null && $style->_cellSpacing !== null) |
|
133 | + if ($this->_cellSpacing === null && $style->_cellSpacing !== null) |
|
134 | 134 | $this->_cellSpacing = $style->_cellSpacing; |
135 | - if($this->_gridLines === null && $style->_gridLines !== null) |
|
135 | + if ($this->_gridLines === null && $style->_gridLines !== null) |
|
136 | 136 | $this->_gridLines = $style->_gridLines; |
137 | - if($this->_borderCollapse === null && $style->_borderCollapse !== null) |
|
137 | + if ($this->_borderCollapse === null && $style->_borderCollapse !== null) |
|
138 | 138 | $this->_borderCollapse = $style->_borderCollapse; |
139 | 139 | } |
140 | 140 | } |
@@ -147,22 +147,22 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function addAttributesToRender($writer) |
149 | 149 | { |
150 | - if(($url = trim($this->getBackImageUrl())) !== '') |
|
151 | - $writer->addStyleAttribute('background-image', 'url(' . $url . ')'); |
|
150 | + if (($url = trim($this->getBackImageUrl())) !== '') |
|
151 | + $writer->addStyleAttribute('background-image', 'url('.$url.')'); |
|
152 | 152 | |
153 | - if(($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) |
|
153 | + if (($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) |
|
154 | 154 | $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
155 | 155 | |
156 | - if(($cellPadding = $this->getCellPadding()) >= 0) |
|
156 | + if (($cellPadding = $this->getCellPadding()) >= 0) |
|
157 | 157 | $writer->addAttribute('cellpadding', "$cellPadding"); |
158 | 158 | |
159 | - if(($cellSpacing = $this->getCellSpacing()) >= 0) |
|
159 | + if (($cellSpacing = $this->getCellSpacing()) >= 0) |
|
160 | 160 | $writer->addAttribute('cellspacing', "$cellSpacing"); |
161 | 161 | |
162 | - if($this->getBorderCollapse()) |
|
162 | + if ($this->getBorderCollapse()) |
|
163 | 163 | $writer->addStyleAttribute('border-collapse', 'collapse'); |
164 | 164 | |
165 | - switch($this->getGridLines()) |
|
165 | + switch ($this->getGridLines()) |
|
166 | 166 | { |
167 | 167 | case TTableGridLines::Horizontal : $writer->addAttribute('rules', 'rows'); break; |
168 | 168 | case TTableGridLines::Vertical : $writer->addAttribute('rules', 'cols'); break; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function getBackImageUrl() |
179 | 179 | { |
180 | - return $this->_backImageUrl === null?'':$this->_backImageUrl; |
|
180 | + return $this->_backImageUrl === null ? '' : $this->_backImageUrl; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function getHorizontalAlign() |
196 | 196 | { |
197 | - return $this->_horizontalAlign === null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
197 | + return $this->_horizontalAlign === null ?THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function getCellPadding() |
213 | 213 | { |
214 | - return $this->_cellPadding === null?-1:$this->_cellPadding; |
|
214 | + return $this->_cellPadding === null ?-1 : $this->_cellPadding; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function setCellPadding($value) |
222 | 222 | { |
223 | - if(($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) |
|
223 | + if (($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) |
|
224 | 224 | throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function getCellSpacing() |
231 | 231 | { |
232 | - return $this->_cellSpacing === null?-1:$this->_cellSpacing; |
|
232 | + return $this->_cellSpacing === null ?-1 : $this->_cellSpacing; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function setCellSpacing($value) |
240 | 240 | { |
241 | - if(($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) |
|
241 | + if (($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) |
|
242 | 242 | throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
243 | 243 | } |
244 | 244 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function getGridLines() |
249 | 249 | { |
250 | - return $this->_gridLines === null?TTableGridLines::None:$this->_gridLines; |
|
250 | + return $this->_gridLines === null ?TTableGridLines::None : $this->_gridLines; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function getBorderCollapse() |
267 | 267 | { |
268 | - return $this->_borderCollapse === null?false:$this->_borderCollapse; |
|
268 | + return $this->_borderCollapse === null ?false:$this->_borderCollapse; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -58,18 +58,24 @@ discard block |
||
58 | 58 | protected function _getZappableSleepProps(&$exprops) |
59 | 59 | { |
60 | 60 | parent::_getZappableSleepProps($exprops); |
61 | - if ($this->_backImageUrl === null) |
|
62 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_backImageUrl"; |
|
63 | - if ($this->_horizontalAlign === null) |
|
64 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_horizontalAlign"; |
|
65 | - if ($this->_cellPadding === null) |
|
66 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellPadding"; |
|
67 | - if ($this->_cellSpacing === null) |
|
68 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellSpacing"; |
|
69 | - if ($this->_gridLines === null) |
|
70 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_gridLines"; |
|
71 | - if ($this->_borderCollapse === null) |
|
72 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_borderCollapse"; |
|
61 | + if ($this->_backImageUrl === null) { |
|
62 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_backImageUrl"; |
|
63 | + } |
|
64 | + if ($this->_horizontalAlign === null) { |
|
65 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_horizontalAlign"; |
|
66 | + } |
|
67 | + if ($this->_cellPadding === null) { |
|
68 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellPadding"; |
|
69 | + } |
|
70 | + if ($this->_cellSpacing === null) { |
|
71 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellSpacing"; |
|
72 | + } |
|
73 | + if ($this->_gridLines === null) { |
|
74 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_gridLines"; |
|
75 | + } |
|
76 | + if ($this->_borderCollapse === null) { |
|
77 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_borderCollapse"; |
|
78 | + } |
|
73 | 79 | } |
74 | 80 | |
75 | 81 | /** |
@@ -98,18 +104,24 @@ discard block |
||
98 | 104 | parent::copyFrom($style); |
99 | 105 | if($style instanceof TTableStyle) |
100 | 106 | { |
101 | - if($style->_backImageUrl !== null) |
|
102 | - $this->_backImageUrl = $style->_backImageUrl; |
|
103 | - if($style->_horizontalAlign !== null) |
|
104 | - $this->_horizontalAlign = $style->_horizontalAlign; |
|
105 | - if($style->_cellPadding !== null) |
|
106 | - $this->_cellPadding = $style->_cellPadding; |
|
107 | - if($style->_cellSpacing !== null) |
|
108 | - $this->_cellSpacing = $style->_cellSpacing; |
|
109 | - if($style->_gridLines !== null) |
|
110 | - $this->_gridLines = $style->_gridLines; |
|
111 | - if($style->_borderCollapse !== null) |
|
112 | - $this->_borderCollapse = $style->_borderCollapse; |
|
107 | + if($style->_backImageUrl !== null) { |
|
108 | + $this->_backImageUrl = $style->_backImageUrl; |
|
109 | + } |
|
110 | + if($style->_horizontalAlign !== null) { |
|
111 | + $this->_horizontalAlign = $style->_horizontalAlign; |
|
112 | + } |
|
113 | + if($style->_cellPadding !== null) { |
|
114 | + $this->_cellPadding = $style->_cellPadding; |
|
115 | + } |
|
116 | + if($style->_cellSpacing !== null) { |
|
117 | + $this->_cellSpacing = $style->_cellSpacing; |
|
118 | + } |
|
119 | + if($style->_gridLines !== null) { |
|
120 | + $this->_gridLines = $style->_gridLines; |
|
121 | + } |
|
122 | + if($style->_borderCollapse !== null) { |
|
123 | + $this->_borderCollapse = $style->_borderCollapse; |
|
124 | + } |
|
113 | 125 | } |
114 | 126 | } |
115 | 127 | |
@@ -124,18 +136,24 @@ discard block |
||
124 | 136 | parent::mergeWith($style); |
125 | 137 | if($style instanceof TTableStyle) |
126 | 138 | { |
127 | - if($this->_backImageUrl === null && $style->_backImageUrl !== null) |
|
128 | - $this->_backImageUrl = $style->_backImageUrl; |
|
129 | - if($this->_horizontalAlign === null && $style->_horizontalAlign !== null) |
|
130 | - $this->_horizontalAlign = $style->_horizontalAlign; |
|
131 | - if($this->_cellPadding === null && $style->_cellPadding !== null) |
|
132 | - $this->_cellPadding = $style->_cellPadding; |
|
133 | - if($this->_cellSpacing === null && $style->_cellSpacing !== null) |
|
134 | - $this->_cellSpacing = $style->_cellSpacing; |
|
135 | - if($this->_gridLines === null && $style->_gridLines !== null) |
|
136 | - $this->_gridLines = $style->_gridLines; |
|
137 | - if($this->_borderCollapse === null && $style->_borderCollapse !== null) |
|
138 | - $this->_borderCollapse = $style->_borderCollapse; |
|
139 | + if($this->_backImageUrl === null && $style->_backImageUrl !== null) { |
|
140 | + $this->_backImageUrl = $style->_backImageUrl; |
|
141 | + } |
|
142 | + if($this->_horizontalAlign === null && $style->_horizontalAlign !== null) { |
|
143 | + $this->_horizontalAlign = $style->_horizontalAlign; |
|
144 | + } |
|
145 | + if($this->_cellPadding === null && $style->_cellPadding !== null) { |
|
146 | + $this->_cellPadding = $style->_cellPadding; |
|
147 | + } |
|
148 | + if($this->_cellSpacing === null && $style->_cellSpacing !== null) { |
|
149 | + $this->_cellSpacing = $style->_cellSpacing; |
|
150 | + } |
|
151 | + if($this->_gridLines === null && $style->_gridLines !== null) { |
|
152 | + $this->_gridLines = $style->_gridLines; |
|
153 | + } |
|
154 | + if($this->_borderCollapse === null && $style->_borderCollapse !== null) { |
|
155 | + $this->_borderCollapse = $style->_borderCollapse; |
|
156 | + } |
|
139 | 157 | } |
140 | 158 | } |
141 | 159 | |
@@ -147,20 +165,25 @@ discard block |
||
147 | 165 | */ |
148 | 166 | public function addAttributesToRender($writer) |
149 | 167 | { |
150 | - if(($url = trim($this->getBackImageUrl())) !== '') |
|
151 | - $writer->addStyleAttribute('background-image', 'url(' . $url . ')'); |
|
168 | + if(($url = trim($this->getBackImageUrl())) !== '') { |
|
169 | + $writer->addStyleAttribute('background-image', 'url(' . $url . ')'); |
|
170 | + } |
|
152 | 171 | |
153 | - if(($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) |
|
154 | - $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
|
172 | + if(($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) { |
|
173 | + $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
|
174 | + } |
|
155 | 175 | |
156 | - if(($cellPadding = $this->getCellPadding()) >= 0) |
|
157 | - $writer->addAttribute('cellpadding', "$cellPadding"); |
|
176 | + if(($cellPadding = $this->getCellPadding()) >= 0) { |
|
177 | + $writer->addAttribute('cellpadding', "$cellPadding"); |
|
178 | + } |
|
158 | 179 | |
159 | - if(($cellSpacing = $this->getCellSpacing()) >= 0) |
|
160 | - $writer->addAttribute('cellspacing', "$cellSpacing"); |
|
180 | + if(($cellSpacing = $this->getCellSpacing()) >= 0) { |
|
181 | + $writer->addAttribute('cellspacing', "$cellSpacing"); |
|
182 | + } |
|
161 | 183 | |
162 | - if($this->getBorderCollapse()) |
|
163 | - $writer->addStyleAttribute('border-collapse', 'collapse'); |
|
184 | + if($this->getBorderCollapse()) { |
|
185 | + $writer->addStyleAttribute('border-collapse', 'collapse'); |
|
186 | + } |
|
164 | 187 | |
165 | 188 | switch($this->getGridLines()) |
166 | 189 | { |
@@ -220,8 +243,9 @@ discard block |
||
220 | 243 | */ |
221 | 244 | public function setCellPadding($value) |
222 | 245 | { |
223 | - if(($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) |
|
224 | - throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
|
246 | + if(($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) { |
|
247 | + throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
|
248 | + } |
|
225 | 249 | } |
226 | 250 | |
227 | 251 | /** |
@@ -238,8 +262,9 @@ discard block |
||
238 | 262 | */ |
239 | 263 | public function setCellSpacing($value) |
240 | 264 | { |
241 | - if(($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) |
|
242 | - throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
|
265 | + if(($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) { |
|
266 | + throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
|
267 | + } |
|
243 | 268 | } |
244 | 269 | |
245 | 270 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function addParsedObject($object) |
91 | 91 | { |
92 | - if($object instanceof TAccordionView) |
|
92 | + if ($object instanceof TAccordionView) |
|
93 | 93 | $this->getControls()->add($object); |
94 | 94 | } |
95 | 95 | |
@@ -144,32 +144,32 @@ discard block |
||
144 | 144 | { |
145 | 145 | $activeView = null; |
146 | 146 | $views = $this->getViews(); |
147 | - if(($id = $this->getActiveViewID()) !== '') |
|
147 | + if (($id = $this->getActiveViewID()) !== '') |
|
148 | 148 | { |
149 | - if(($index = $views->findIndexByID($id)) >= 0) |
|
149 | + if (($index = $views->findIndexByID($id)) >= 0) |
|
150 | 150 | $activeView = $views->itemAt($index); |
151 | 151 | else |
152 | 152 | throw new TInvalidDataValueException('accordion_activeviewid_invalid', $id); |
153 | 153 | } |
154 | - elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
154 | + elseif (($index = $this->getActiveViewIndex()) >= 0) |
|
155 | 155 | { |
156 | - if($index < $views->getCount()) |
|
156 | + if ($index < $views->getCount()) |
|
157 | 157 | $activeView = $views->itemAt($index); |
158 | 158 | else |
159 | 159 | throw new TInvalidDataValueException('accordion_activeviewindex_invalid', $index); |
160 | 160 | } |
161 | 161 | else |
162 | 162 | { |
163 | - foreach($views as $index => $view) |
|
163 | + foreach ($views as $index => $view) |
|
164 | 164 | { |
165 | - if($view->getActive()) |
|
165 | + if ($view->getActive()) |
|
166 | 166 | { |
167 | 167 | $activeView = $view; |
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
172 | - if($activeView !== null) |
|
172 | + if ($activeView !== null) |
|
173 | 173 | $this->activateView($activeView); |
174 | 174 | return $activeView; |
175 | 175 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function setActiveView($view) |
182 | 182 | { |
183 | - if($this->getViews()->indexOf($view) >= 0) |
|
183 | + if ($this->getViews()->indexOf($view) >= 0) |
|
184 | 184 | $this->activateView($view); |
185 | 185 | else |
186 | 186 | throw new TInvalidOperationException('accordion_view_inexistent'); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | public function getCssClass() |
209 | 209 | { |
210 | 210 | $cssClass = parent::getCssClass(); |
211 | - return $cssClass === ''?'accordion':$cssClass; |
|
211 | + return $cssClass === '' ? 'accordion' : $cssClass; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function getViewStyle() |
250 | 250 | { |
251 | - if(($style = $this->getViewState('ViewStyle', null)) === null) |
|
251 | + if (($style = $this->getViewState('ViewStyle', null)) === null) |
|
252 | 252 | { |
253 | 253 | $style = new TStyle; |
254 | 254 | $style->setCssClass('accordion-view'); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function getHeaderStyle() |
280 | 280 | { |
281 | - if(($style = $this->getViewState('HeaderStyle', null)) === null) |
|
281 | + if (($style = $this->getViewState('HeaderStyle', null)) === null) |
|
282 | 282 | { |
283 | 283 | $style = new TStyle; |
284 | 284 | $style->setCssClass('accordion-header'); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function getActiveHeaderStyle() |
310 | 310 | { |
311 | - if(($style = $this->getViewState('ActiveHeaderStyle', null)) === null) |
|
311 | + if (($style = $this->getViewState('ActiveHeaderStyle', null)) === null) |
|
312 | 312 | { |
313 | 313 | $style = new TStyle; |
314 | 314 | $style->setCssClass('accordion-header-active'); |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | { |
343 | 343 | $this->setActiveViewIndex(-1); |
344 | 344 | $this->setActiveViewID(''); |
345 | - foreach($this->getViews() as $index => $v) |
|
345 | + foreach ($this->getViews() as $index => $v) |
|
346 | 346 | { |
347 | - if($view === $v) |
|
347 | + if ($view === $v) |
|
348 | 348 | { |
349 | 349 | $this->setActiveViewIndex($index); |
350 | 350 | $this->setActiveViewID($view->getID(false)); |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function loadPostData($key, $values) |
366 | 366 | { |
367 | - if(($index = $values[$this->getClientID() . '_1']) !== null) |
|
367 | + if (($index = $values[$this->getClientID().'_1']) !== null) |
|
368 | 368 | { |
369 | - $index = (int)$index; |
|
369 | + $index = (int) $index; |
|
370 | 370 | $currentIndex = $this->getActiveViewIndex(); |
371 | - if($currentIndex !== $index) |
|
371 | + if ($currentIndex !== $index) |
|
372 | 372 | { |
373 | 373 | $this->setActiveViewID(''); // clear up view ID |
374 | 374 | $this->setActiveViewIndex($index); |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | public function onPreRender($param) |
420 | 420 | { |
421 | 421 | parent::onPreRender($param); |
422 | - $this->getActiveView(); // determine the active view |
|
422 | + $this->getActiveView(); // determine the active view |
|
423 | 423 | $this->registerStyleSheet(); |
424 | 424 | } |
425 | 425 | |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | { |
433 | 433 | $url = $this->getCssUrl(); |
434 | 434 | |
435 | - if($url === '') { |
|
435 | + if ($url === '') { |
|
436 | 436 | return; |
437 | 437 | } |
438 | 438 | |
439 | - if($url === 'default') { |
|
440 | - $url = $this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'accordion.css'); |
|
439 | + if ($url === 'default') { |
|
440 | + $url = $this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'accordion.css'); |
|
441 | 441 | } |
442 | 442 | |
443 | - if($url !== '') { |
|
443 | + if ($url !== '') { |
|
444 | 444 | $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
445 | 445 | } |
446 | 446 | } |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | $cs->registerEndScript("prado:$id", $code); |
461 | 461 | // ensure an item is always active and visible |
462 | 462 | $index = $this->getActiveViewIndex(); |
463 | - if(!$this->getViews()->itemAt($index)->Visible) |
|
463 | + if (!$this->getViews()->itemAt($index)->Visible) |
|
464 | 464 | $index = 0; |
465 | - $cs->registerHiddenField($id . '_1', $index); |
|
465 | + $cs->registerHiddenField($id.'_1', $index); |
|
466 | 466 | $page->registerRequiresPostData($this); |
467 | - $page->registerRequiresPostData($id . "_1"); |
|
467 | + $page->registerRequiresPostData($id."_1"); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | if (($viewheight = $this->getViewHeight()) > 0) |
491 | 491 | $options['maxHeight'] = $viewheight; |
492 | 492 | $views = []; |
493 | - foreach($this->getViews() as $view) |
|
494 | - $views[$view->getClientID()] = $view->getVisible() ? '1': '0'; |
|
493 | + foreach ($this->getViews() as $view) |
|
494 | + $views[$view->getClientID()] = $view->getVisible() ? '1' : '0'; |
|
495 | 495 | $options['Views'] = $views; |
496 | 496 | |
497 | 497 | return $options; |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | public function renderContents($writer) |
528 | 528 | { |
529 | 529 | $views = $this->getViews(); |
530 | - if($views->getCount() > 0) |
|
530 | + if ($views->getCount() > 0) |
|
531 | 531 | { |
532 | 532 | $writer->writeLine(); |
533 | - foreach($views as $view) |
|
533 | + foreach ($views as $view) |
|
534 | 534 | { |
535 | 535 | $view->renderHeader($writer); |
536 | 536 | $view->renderControl($writer); |
@@ -89,8 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function addParsedObject($object) |
91 | 91 | { |
92 | - if($object instanceof TAccordionView) |
|
93 | - $this->getControls()->add($object); |
|
92 | + if($object instanceof TAccordionView) { |
|
93 | + $this->getControls()->add($object); |
|
94 | + } |
|
94 | 95 | } |
95 | 96 | |
96 | 97 | /** |
@@ -146,19 +147,19 @@ discard block |
||
146 | 147 | $views = $this->getViews(); |
147 | 148 | if(($id = $this->getActiveViewID()) !== '') |
148 | 149 | { |
149 | - if(($index = $views->findIndexByID($id)) >= 0) |
|
150 | - $activeView = $views->itemAt($index); |
|
151 | - else |
|
152 | - throw new TInvalidDataValueException('accordion_activeviewid_invalid', $id); |
|
153 | - } |
|
154 | - elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
150 | + if(($index = $views->findIndexByID($id)) >= 0) { |
|
151 | + $activeView = $views->itemAt($index); |
|
152 | + } else { |
|
153 | + throw new TInvalidDataValueException('accordion_activeviewid_invalid', $id); |
|
154 | + } |
|
155 | + } elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
155 | 156 | { |
156 | - if($index < $views->getCount()) |
|
157 | - $activeView = $views->itemAt($index); |
|
158 | - else |
|
159 | - throw new TInvalidDataValueException('accordion_activeviewindex_invalid', $index); |
|
160 | - } |
|
161 | - else |
|
157 | + if($index < $views->getCount()) { |
|
158 | + $activeView = $views->itemAt($index); |
|
159 | + } else { |
|
160 | + throw new TInvalidDataValueException('accordion_activeviewindex_invalid', $index); |
|
161 | + } |
|
162 | + } else |
|
162 | 163 | { |
163 | 164 | foreach($views as $index => $view) |
164 | 165 | { |
@@ -169,8 +170,9 @@ discard block |
||
169 | 170 | } |
170 | 171 | } |
171 | 172 | } |
172 | - if($activeView !== null) |
|
173 | - $this->activateView($activeView); |
|
173 | + if($activeView !== null) { |
|
174 | + $this->activateView($activeView); |
|
175 | + } |
|
174 | 176 | return $activeView; |
175 | 177 | } |
176 | 178 | |
@@ -180,10 +182,11 @@ discard block |
||
180 | 182 | */ |
181 | 183 | public function setActiveView($view) |
182 | 184 | { |
183 | - if($this->getViews()->indexOf($view) >= 0) |
|
184 | - $this->activateView($view); |
|
185 | - else |
|
186 | - throw new TInvalidOperationException('accordion_view_inexistent'); |
|
185 | + if($this->getViews()->indexOf($view) >= 0) { |
|
186 | + $this->activateView($view); |
|
187 | + } else { |
|
188 | + throw new TInvalidOperationException('accordion_view_inexistent'); |
|
189 | + } |
|
187 | 190 | } |
188 | 191 | |
189 | 192 | /** |
@@ -349,9 +352,9 @@ discard block |
||
349 | 352 | $this->setActiveViewIndex($index); |
350 | 353 | $this->setActiveViewID($view->getID(false)); |
351 | 354 | $view->setActive(true); |
355 | + } else { |
|
356 | + $v->setActive(false); |
|
352 | 357 | } |
353 | - else |
|
354 | - $v->setActive(false); |
|
355 | 358 | } |
356 | 359 | } |
357 | 360 | |
@@ -460,8 +463,9 @@ discard block |
||
460 | 463 | $cs->registerEndScript("prado:$id", $code); |
461 | 464 | // ensure an item is always active and visible |
462 | 465 | $index = $this->getActiveViewIndex(); |
463 | - if(!$this->getViews()->itemAt($index)->Visible) |
|
464 | - $index = 0; |
|
466 | + if(!$this->getViews()->itemAt($index)->Visible) { |
|
467 | + $index = 0; |
|
468 | + } |
|
465 | 469 | $cs->registerHiddenField($id . '_1', $index); |
466 | 470 | $page->registerRequiresPostData($this); |
467 | 471 | $page->registerRequiresPostData($id . "_1"); |
@@ -487,11 +491,13 @@ discard block |
||
487 | 491 | $options['HeaderCssClass'] = $this->getHeaderCssClass(); |
488 | 492 | $options['Duration'] = $this->getAnimationDuration(); |
489 | 493 | |
490 | - if (($viewheight = $this->getViewHeight()) > 0) |
|
491 | - $options['maxHeight'] = $viewheight; |
|
494 | + if (($viewheight = $this->getViewHeight()) > 0) { |
|
495 | + $options['maxHeight'] = $viewheight; |
|
496 | + } |
|
492 | 497 | $views = []; |
493 | - foreach($this->getViews() as $view) |
|
494 | - $views[$view->getClientID()] = $view->getVisible() ? '1': '0'; |
|
498 | + foreach($this->getViews() as $view) { |
|
499 | + $views[$view->getClientID()] = $view->getVisible() ? '1': '0'; |
|
500 | + } |
|
495 | 501 | $options['Views'] = $views; |
496 | 502 | |
497 | 503 | return $options; |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function initializeCell($cell, $columnIndex, $itemType) |
108 | 108 | { |
109 | - if($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::EditItem || $itemType === TListItemType::SelectedItem) |
|
109 | + if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::EditItem || $itemType === TListItemType::SelectedItem) |
|
110 | 110 | { |
111 | - if($this->getDataField() !== '') |
|
111 | + if ($this->getDataField() !== '') |
|
112 | 112 | { |
113 | - $cell->attachEventHandler('OnDataBinding', [$this,'dataBindColumn']); |
|
113 | + $cell->attachEventHandler('OnDataBinding', [$this, 'dataBindColumn']); |
|
114 | 114 | } else { |
115 | 115 | $text = $this->getText(); |
116 | - if($this->getEncode()) |
|
116 | + if ($this->getEncode()) |
|
117 | 117 | $text = THttpUtility::htmlEncode($text); |
118 | 118 | $cell->setText($text); |
119 | 119 | } |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $item = $sender->getNamingContainer(); |
133 | 133 | $data = $item->getData(); |
134 | 134 | $formatString = $this->getDataFormatString(); |
135 | - if(($field = $this->getDataField()) !== '') |
|
135 | + if (($field = $this->getDataField()) !== '') |
|
136 | 136 | $value = $this->formatDataValue($formatString, $this->getDataFieldValue($data, $field)); |
137 | 137 | else |
138 | 138 | $value = $this->formatDataValue($formatString, $data); |
139 | - if($sender instanceof TTableCell) |
|
139 | + if ($sender instanceof TTableCell) |
|
140 | 140 | { |
141 | - if($this->getEncode()) |
|
141 | + if ($this->getEncode()) |
|
142 | 142 | $value = THttpUtility::htmlEncode($value); |
143 | 143 | $sender->setText($value); |
144 | 144 | } |
@@ -113,13 +113,14 @@ discard block |
||
113 | 113 | $cell->attachEventHandler('OnDataBinding', [$this,'dataBindColumn']); |
114 | 114 | } else { |
115 | 115 | $text = $this->getText(); |
116 | - if($this->getEncode()) |
|
117 | - $text = THttpUtility::htmlEncode($text); |
|
116 | + if($this->getEncode()) { |
|
117 | + $text = THttpUtility::htmlEncode($text); |
|
118 | + } |
|
118 | 119 | $cell->setText($text); |
119 | 120 | } |
121 | + } else { |
|
122 | + parent::initializeCell($cell, $columnIndex, $itemType); |
|
120 | 123 | } |
121 | - else |
|
122 | - parent::initializeCell($cell, $columnIndex, $itemType); |
|
123 | 124 | } |
124 | 125 | |
125 | 126 | /** |
@@ -132,14 +133,16 @@ discard block |
||
132 | 133 | $item = $sender->getNamingContainer(); |
133 | 134 | $data = $item->getData(); |
134 | 135 | $formatString = $this->getDataFormatString(); |
135 | - if(($field = $this->getDataField()) !== '') |
|
136 | - $value = $this->formatDataValue($formatString, $this->getDataFieldValue($data, $field)); |
|
137 | - else |
|
138 | - $value = $this->formatDataValue($formatString, $data); |
|
136 | + if(($field = $this->getDataField()) !== '') { |
|
137 | + $value = $this->formatDataValue($formatString, $this->getDataFieldValue($data, $field)); |
|
138 | + } else { |
|
139 | + $value = $this->formatDataValue($formatString, $data); |
|
140 | + } |
|
139 | 141 | if($sender instanceof TTableCell) |
140 | 142 | { |
141 | - if($this->getEncode()) |
|
142 | - $value = THttpUtility::htmlEncode($value); |
|
143 | + if($this->getEncode()) { |
|
144 | + $value = THttpUtility::htmlEncode($value); |
|
145 | + } |
|
143 | 146 | $sender->setText($value); |
144 | 147 | } |
145 | 148 | } |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | public function loadPostData($key, $values) |
113 | 113 | { |
114 | 114 | $uniqueGroupName = $this->getUniqueGroupName(); |
115 | - $value = isset($values[$uniqueGroupName])?$values[$uniqueGroupName]:null; |
|
116 | - if($value !== null && $value === $this->getValueAttribute()) |
|
115 | + $value = isset($values[$uniqueGroupName]) ? $values[$uniqueGroupName] : null; |
|
116 | + if ($value !== null && $value === $this->getValueAttribute()) |
|
117 | 117 | { |
118 | - if(!$this->getChecked()) |
|
118 | + if (!$this->getChecked()) |
|
119 | 119 | { |
120 | 120 | $this->setChecked(true); |
121 | 121 | return true; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | else |
124 | 124 | return false; |
125 | 125 | } |
126 | - elseif($this->getChecked()) |
|
126 | + elseif ($this->getChecked()) |
|
127 | 127 | $this->setChecked(false); |
128 | 128 | return false; |
129 | 129 | } |
@@ -153,22 +153,22 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function getUniqueGroupName() |
155 | 155 | { |
156 | - if(($groupName = $this->getViewState('UniqueGroupName', '')) !== '') |
|
156 | + if (($groupName = $this->getViewState('UniqueGroupName', '')) !== '') |
|
157 | 157 | return $groupName; |
158 | - elseif(($uniqueID = $this->getUniqueID()) !== $this->_previousUniqueID || $this->_uniqueGroupName === null) |
|
158 | + elseif (($uniqueID = $this->getUniqueID()) !== $this->_previousUniqueID || $this->_uniqueGroupName === null) |
|
159 | 159 | { |
160 | 160 | $groupName = $this->getGroupName(); |
161 | 161 | $this->_previousUniqueID = $uniqueID; |
162 | - if($uniqueID !== '') |
|
162 | + if ($uniqueID !== '') |
|
163 | 163 | { |
164 | - if(($pos = strrpos($uniqueID, \Prado\Web\UI\TControl::ID_SEPARATOR)) !== false) |
|
164 | + if (($pos = strrpos($uniqueID, \Prado\Web\UI\TControl::ID_SEPARATOR)) !== false) |
|
165 | 165 | { |
166 | - if($groupName !== '') |
|
167 | - $groupName = substr($uniqueID, 0, $pos + 1) . $groupName; |
|
168 | - elseif($this->getNamingContainer() instanceof TRadioButtonList) |
|
166 | + if ($groupName !== '') |
|
167 | + $groupName = substr($uniqueID, 0, $pos + 1).$groupName; |
|
168 | + elseif ($this->getNamingContainer() instanceof TRadioButtonList) |
|
169 | 169 | $groupName = substr($uniqueID, 0, $pos); |
170 | 170 | } |
171 | - if($groupName === '') |
|
171 | + if ($groupName === '') |
|
172 | 172 | $groupName = $uniqueID; |
173 | 173 | } |
174 | 174 | $this->_uniqueGroupName = $groupName; |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | { |
208 | 208 | $group = $this->getUniqueGroupName(); |
209 | 209 | $buttons = []; |
210 | - foreach(self::$_activeButtons as $control) |
|
210 | + foreach (self::$_activeButtons as $control) |
|
211 | 211 | { |
212 | - if($control->getUniqueGroupName() === $group) |
|
212 | + if ($control->getUniqueGroupName() === $group) |
|
213 | 213 | $buttons[] = $control; |
214 | 214 | } |
215 | 215 | return $buttons; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | protected function getValueAttribute() |
222 | 222 | { |
223 | - if(($value = parent::getValueAttribute()) === '') |
|
223 | + if (($value = parent::getValueAttribute()) === '') |
|
224 | 224 | return $this->getUniqueID(); |
225 | 225 | else |
226 | 226 | return $value; |
@@ -250,20 +250,20 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function renderInputTag($writer, $clientID, $onclick) |
252 | 252 | { |
253 | - if($clientID !== '') |
|
253 | + if ($clientID !== '') |
|
254 | 254 | $writer->addAttribute('id', $clientID); |
255 | 255 | $writer->addAttribute('type', 'radio'); |
256 | 256 | $writer->addAttribute('name', $this->getUniqueGroupName()); |
257 | 257 | $writer->addAttribute('value', $this->getValueAttribute()); |
258 | - if(!empty($onclick)) |
|
258 | + if (!empty($onclick)) |
|
259 | 259 | $writer->addAttribute('onclick', $onclick); |
260 | - if($this->getChecked()) |
|
260 | + if ($this->getChecked()) |
|
261 | 261 | $writer->addAttribute('checked', 'checked'); |
262 | - if(!$this->getEnabled(true)) |
|
262 | + if (!$this->getEnabled(true)) |
|
263 | 263 | $writer->addAttribute('disabled', 'disabled'); |
264 | 264 | |
265 | 265 | $page = $this->getPage(); |
266 | - if($this->getEnabled(true) |
|
266 | + if ($this->getEnabled(true) |
|
267 | 267 | && $this->getEnableClientScript() |
268 | 268 | && $this->getAutoPostBack() |
269 | 269 | && $page->getClientSupportsJavaScript()) |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | $this->renderClientControlScript($writer); |
272 | 272 | } |
273 | 273 | |
274 | - if(($accesskey = $this->getAccessKey()) !== '') |
|
274 | + if (($accesskey = $this->getAccessKey()) !== '') |
|
275 | 275 | $writer->addAttribute('accesskey', $accesskey); |
276 | - if(($tabindex = $this->getTabIndex()) > 0) |
|
276 | + if (($tabindex = $this->getTabIndex()) > 0) |
|
277 | 277 | $writer->addAttribute('tabindex', "$tabindex"); |
278 | - if($attributes = $this->getViewState('InputAttributes', null)) |
|
278 | + if ($attributes = $this->getViewState('InputAttributes', null)) |
|
279 | 279 | $writer->addAttributes($attributes); |
280 | 280 | $writer->renderBeginTag('input'); |
281 | 281 | $writer->renderEndTag(); |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | { |
120 | 120 | $this->setChecked(true); |
121 | 121 | return true; |
122 | + } else { |
|
123 | + return false; |
|
122 | 124 | } |
123 | - else |
|
124 | - return false; |
|
125 | + } elseif($this->getChecked()) { |
|
126 | + $this->setChecked(false); |
|
125 | 127 | } |
126 | - elseif($this->getChecked()) |
|
127 | - $this->setChecked(false); |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function getUniqueGroupName() |
155 | 155 | { |
156 | - if(($groupName = $this->getViewState('UniqueGroupName', '')) !== '') |
|
157 | - return $groupName; |
|
158 | - elseif(($uniqueID = $this->getUniqueID()) !== $this->_previousUniqueID || $this->_uniqueGroupName === null) |
|
156 | + if(($groupName = $this->getViewState('UniqueGroupName', '')) !== '') { |
|
157 | + return $groupName; |
|
158 | + } elseif(($uniqueID = $this->getUniqueID()) !== $this->_previousUniqueID || $this->_uniqueGroupName === null) |
|
159 | 159 | { |
160 | 160 | $groupName = $this->getGroupName(); |
161 | 161 | $this->_previousUniqueID = $uniqueID; |
@@ -163,13 +163,15 @@ discard block |
||
163 | 163 | { |
164 | 164 | if(($pos = strrpos($uniqueID, \Prado\Web\UI\TControl::ID_SEPARATOR)) !== false) |
165 | 165 | { |
166 | - if($groupName !== '') |
|
167 | - $groupName = substr($uniqueID, 0, $pos + 1) . $groupName; |
|
168 | - elseif($this->getNamingContainer() instanceof TRadioButtonList) |
|
169 | - $groupName = substr($uniqueID, 0, $pos); |
|
166 | + if($groupName !== '') { |
|
167 | + $groupName = substr($uniqueID, 0, $pos + 1) . $groupName; |
|
168 | + } elseif($this->getNamingContainer() instanceof TRadioButtonList) { |
|
169 | + $groupName = substr($uniqueID, 0, $pos); |
|
170 | + } |
|
171 | + } |
|
172 | + if($groupName === '') { |
|
173 | + $groupName = $uniqueID; |
|
170 | 174 | } |
171 | - if($groupName === '') |
|
172 | - $groupName = $uniqueID; |
|
173 | 175 | } |
174 | 176 | $this->_uniqueGroupName = $groupName; |
175 | 177 | } |
@@ -209,8 +211,9 @@ discard block |
||
209 | 211 | $buttons = []; |
210 | 212 | foreach(self::$_activeButtons as $control) |
211 | 213 | { |
212 | - if($control->getUniqueGroupName() === $group) |
|
213 | - $buttons[] = $control; |
|
214 | + if($control->getUniqueGroupName() === $group) { |
|
215 | + $buttons[] = $control; |
|
216 | + } |
|
214 | 217 | } |
215 | 218 | return $buttons; |
216 | 219 | } |
@@ -220,10 +223,11 @@ discard block |
||
220 | 223 | */ |
221 | 224 | protected function getValueAttribute() |
222 | 225 | { |
223 | - if(($value = parent::getValueAttribute()) === '') |
|
224 | - return $this->getUniqueID(); |
|
225 | - else |
|
226 | - return $value; |
|
226 | + if(($value = parent::getValueAttribute()) === '') { |
|
227 | + return $this->getUniqueID(); |
|
228 | + } else { |
|
229 | + return $value; |
|
230 | + } |
|
227 | 231 | } |
228 | 232 | |
229 | 233 | /** |
@@ -250,17 +254,21 @@ discard block |
||
250 | 254 | */ |
251 | 255 | protected function renderInputTag($writer, $clientID, $onclick) |
252 | 256 | { |
253 | - if($clientID !== '') |
|
254 | - $writer->addAttribute('id', $clientID); |
|
257 | + if($clientID !== '') { |
|
258 | + $writer->addAttribute('id', $clientID); |
|
259 | + } |
|
255 | 260 | $writer->addAttribute('type', 'radio'); |
256 | 261 | $writer->addAttribute('name', $this->getUniqueGroupName()); |
257 | 262 | $writer->addAttribute('value', $this->getValueAttribute()); |
258 | - if(!empty($onclick)) |
|
259 | - $writer->addAttribute('onclick', $onclick); |
|
260 | - if($this->getChecked()) |
|
261 | - $writer->addAttribute('checked', 'checked'); |
|
262 | - if(!$this->getEnabled(true)) |
|
263 | - $writer->addAttribute('disabled', 'disabled'); |
|
263 | + if(!empty($onclick)) { |
|
264 | + $writer->addAttribute('onclick', $onclick); |
|
265 | + } |
|
266 | + if($this->getChecked()) { |
|
267 | + $writer->addAttribute('checked', 'checked'); |
|
268 | + } |
|
269 | + if(!$this->getEnabled(true)) { |
|
270 | + $writer->addAttribute('disabled', 'disabled'); |
|
271 | + } |
|
264 | 272 | |
265 | 273 | $page = $this->getPage(); |
266 | 274 | if($this->getEnabled(true) |
@@ -271,12 +279,15 @@ discard block |
||
271 | 279 | $this->renderClientControlScript($writer); |
272 | 280 | } |
273 | 281 | |
274 | - if(($accesskey = $this->getAccessKey()) !== '') |
|
275 | - $writer->addAttribute('accesskey', $accesskey); |
|
276 | - if(($tabindex = $this->getTabIndex()) > 0) |
|
277 | - $writer->addAttribute('tabindex', "$tabindex"); |
|
278 | - if($attributes = $this->getViewState('InputAttributes', null)) |
|
279 | - $writer->addAttributes($attributes); |
|
282 | + if(($accesskey = $this->getAccessKey()) !== '') { |
|
283 | + $writer->addAttribute('accesskey', $accesskey); |
|
284 | + } |
|
285 | + if(($tabindex = $this->getTabIndex()) > 0) { |
|
286 | + $writer->addAttribute('tabindex', "$tabindex"); |
|
287 | + } |
|
288 | + if($attributes = $this->getViewState('InputAttributes', null)) { |
|
289 | + $writer->addAttributes($attributes); |
|
290 | + } |
|
280 | 291 | $writer->renderBeginTag('input'); |
281 | 292 | $writer->renderEndTag(); |
282 | 293 | } |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | protected function addAttributesToRender($writer) |
51 | 51 | { |
52 | 52 | $isEnabled = $this->getEnabled(true); |
53 | - if($this->getEnabled() && !$isEnabled) |
|
53 | + if ($this->getEnabled() && !$isEnabled) |
|
54 | 54 | $writer->addAttribute('disabled', 'disabled'); |
55 | 55 | parent::addAttributesToRender($writer); |
56 | - if(($url = $this->getNavigateUrl()) !== '' && $isEnabled) |
|
56 | + if (($url = $this->getNavigateUrl()) !== '' && $isEnabled) |
|
57 | 57 | $writer->addAttribute('href', $url); |
58 | - if(($target = $this->getTarget()) !== '') |
|
58 | + if (($target = $this->getTarget()) !== '') |
|
59 | 59 | $writer->addAttribute('target', $target); |
60 | 60 | } |
61 | 61 | |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function renderContents($writer) |
67 | 67 | { |
68 | - if(($imageUrl = $this->getImageUrl()) === '') |
|
68 | + if (($imageUrl = $this->getImageUrl()) === '') |
|
69 | 69 | { |
70 | - if(($text = $this->getText()) !== '') |
|
70 | + if (($text = $this->getText()) !== '') |
|
71 | 71 | $writer->write(THttpUtility::htmlEncode($text)); |
72 | - elseif($this->getHasControls()) |
|
72 | + elseif ($this->getHasControls()) |
|
73 | 73 | parent::renderContents($writer); |
74 | 74 | else |
75 | 75 | $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | { |
91 | 91 | $image = new TImage; |
92 | 92 | $image->setImageUrl($imageUrl); |
93 | - if(($width = $this->getImageWidth()) !== '') |
|
93 | + if (($width = $this->getImageWidth()) !== '') |
|
94 | 94 | $image->setWidth($width); |
95 | - if(($height = $this->getImageHeight()) !== '') |
|
95 | + if (($height = $this->getImageHeight()) !== '') |
|
96 | 96 | $image->setHeight($height); |
97 | - if(($toolTip = $this->getToolTip()) !== '') |
|
97 | + if (($toolTip = $this->getToolTip()) !== '') |
|
98 | 98 | $image->setToolTip($toolTip); |
99 | - if(($text = $this->getText()) !== '') |
|
99 | + if (($text = $this->getText()) !== '') |
|
100 | 100 | $image->setAlternateText($text); |
101 | - if(($align = $this->getImageAlign()) !== '') |
|
101 | + if (($align = $this->getImageAlign()) !== '') |
|
102 | 102 | $image->setImageAlign($align); |
103 | 103 | $image->setBorderWidth('0'); |
104 | 104 | return $image; |
@@ -50,13 +50,16 @@ discard block |
||
50 | 50 | protected function addAttributesToRender($writer) |
51 | 51 | { |
52 | 52 | $isEnabled = $this->getEnabled(true); |
53 | - if($this->getEnabled() && !$isEnabled) |
|
54 | - $writer->addAttribute('disabled', 'disabled'); |
|
53 | + if($this->getEnabled() && !$isEnabled) { |
|
54 | + $writer->addAttribute('disabled', 'disabled'); |
|
55 | + } |
|
55 | 56 | parent::addAttributesToRender($writer); |
56 | - if(($url = $this->getNavigateUrl()) !== '' && $isEnabled) |
|
57 | - $writer->addAttribute('href', $url); |
|
58 | - if(($target = $this->getTarget()) !== '') |
|
59 | - $writer->addAttribute('target', $target); |
|
57 | + if(($url = $this->getNavigateUrl()) !== '' && $isEnabled) { |
|
58 | + $writer->addAttribute('href', $url); |
|
59 | + } |
|
60 | + if(($target = $this->getTarget()) !== '') { |
|
61 | + $writer->addAttribute('target', $target); |
|
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | 65 | /** |
@@ -67,14 +70,14 @@ discard block |
||
67 | 70 | { |
68 | 71 | if(($imageUrl = $this->getImageUrl()) === '') |
69 | 72 | { |
70 | - if(($text = $this->getText()) !== '') |
|
71 | - $writer->write(THttpUtility::htmlEncode($text)); |
|
72 | - elseif($this->getHasControls()) |
|
73 | - parent::renderContents($writer); |
|
74 | - else |
|
75 | - $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
|
76 | - } |
|
77 | - else |
|
73 | + if(($text = $this->getText()) !== '') { |
|
74 | + $writer->write(THttpUtility::htmlEncode($text)); |
|
75 | + } elseif($this->getHasControls()) { |
|
76 | + parent::renderContents($writer); |
|
77 | + } else { |
|
78 | + $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
|
79 | + } |
|
80 | + } else |
|
78 | 81 | { |
79 | 82 | $this->createImage($imageUrl)->renderControl($writer); |
80 | 83 | } |
@@ -90,16 +93,21 @@ discard block |
||
90 | 93 | { |
91 | 94 | $image = new TImage; |
92 | 95 | $image->setImageUrl($imageUrl); |
93 | - if(($width = $this->getImageWidth()) !== '') |
|
94 | - $image->setWidth($width); |
|
95 | - if(($height = $this->getImageHeight()) !== '') |
|
96 | - $image->setHeight($height); |
|
97 | - if(($toolTip = $this->getToolTip()) !== '') |
|
98 | - $image->setToolTip($toolTip); |
|
99 | - if(($text = $this->getText()) !== '') |
|
100 | - $image->setAlternateText($text); |
|
101 | - if(($align = $this->getImageAlign()) !== '') |
|
102 | - $image->setImageAlign($align); |
|
96 | + if(($width = $this->getImageWidth()) !== '') { |
|
97 | + $image->setWidth($width); |
|
98 | + } |
|
99 | + if(($height = $this->getImageHeight()) !== '') { |
|
100 | + $image->setHeight($height); |
|
101 | + } |
|
102 | + if(($toolTip = $this->getToolTip()) !== '') { |
|
103 | + $image->setToolTip($toolTip); |
|
104 | + } |
|
105 | + if(($text = $this->getText()) !== '') { |
|
106 | + $image->setAlternateText($text); |
|
107 | + } |
|
108 | + if(($align = $this->getImageAlign()) !== '') { |
|
109 | + $image->setImageAlign($align); |
|
110 | + } |
|
103 | 111 | $image->setBorderWidth('0'); |
104 | 112 | return $image; |
105 | 113 | } |