@@ -39,7 +39,7 @@ |
||
39 | 39 | { |
40 | 40 | if(($id=$this->getID())==='') |
41 | 41 | throw new TConfigurationException('content_id_required'); |
42 | - $this->getTemplateControl()->registerContent($id,$this); |
|
42 | + $this->getTemplateControl()->registerContent($id, $this); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 |
@@ -101,8 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $this->setSelectedIndex($index); |
103 | 103 | return $this->_dataChanged=true; |
104 | - } |
|
105 | - else |
|
104 | + } else |
|
106 | 105 | return false; |
107 | 106 | } |
108 | 107 | if(!is_array($selections)) |
@@ -124,8 +123,7 @@ discard block |
||
124 | 123 | break; |
125 | 124 | } |
126 | 125 | } |
127 | - } |
|
128 | - else |
|
126 | + } else |
|
129 | 127 | $flag=true; |
130 | 128 | if($flag) |
131 | 129 | { |
@@ -133,13 +131,11 @@ discard block |
||
133 | 131 | $this->_dataChanged=true; |
134 | 132 | } |
135 | 133 | return $flag; |
136 | - } |
|
137 | - else if($this->getSelectedIndex()!==-1) |
|
134 | + } else if($this->getSelectedIndex()!==-1) |
|
138 | 135 | { |
139 | 136 | $this->clearSelection(); |
140 | 137 | return $this->_dataChanged=true; |
141 | - } |
|
142 | - else |
|
138 | + } else |
|
143 | 139 | return false; |
144 | 140 | } |
145 | 141 |
@@ -225,13 +225,13 @@ |
||
225 | 225 | */ |
226 | 226 | public function getIsValid() |
227 | 227 | { |
228 | - return $this->_isValid; |
|
228 | + return $this->_isValid; |
|
229 | 229 | } |
230 | 230 | /** |
231 | 231 | * @param bool wether this control is valid. |
232 | 232 | */ |
233 | 233 | public function setIsValid($value) |
234 | 234 | { |
235 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
235 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | \ No newline at end of file |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | protected function addAttributesToRender($writer) |
46 | 46 | { |
47 | 47 | $rows=$this->getRows(); |
48 | - $writer->addAttribute('size',"$rows"); |
|
48 | + $writer->addAttribute('size', "$rows"); |
|
49 | 49 | if($this->getSelectionMode()===TListSelectionMode::Multiple) |
50 | - $writer->addAttribute('name',$this->getUniqueID().'[]'); |
|
50 | + $writer->addAttribute('name', $this->getUniqueID().'[]'); |
|
51 | 51 | else |
52 | - $writer->addAttribute('name',$this->getUniqueID()); |
|
52 | + $writer->addAttribute('name', $this->getUniqueID()); |
|
53 | 53 | parent::addAttributesToRender($writer); |
54 | 54 | } |
55 | 55 | |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | * @param array the input data collection |
83 | 83 | * @return boolean whether the data of the component has been changed |
84 | 84 | */ |
85 | - public function loadPostData($key,$values) |
|
85 | + public function loadPostData($key, $values) |
|
86 | 86 | { |
87 | 87 | if(!$this->getEnabled(true)) |
88 | 88 | return false; |
89 | 89 | $this->ensureDataBound(); |
90 | - $selections=isset($values[$key])?$values[$key]:null; |
|
90 | + $selections=isset($values[$key]) ? $values[$key] : null; |
|
91 | 91 | if($selections!==null) |
92 | 92 | { |
93 | 93 | $items=$this->getItems(); |
94 | 94 | if($this->getSelectionMode()===TListSelectionMode::Single) |
95 | 95 | { |
96 | - $selection=is_array($selections)?$selections[0]:$selections; |
|
97 | - $index=$items->findIndexByValue($selection,false); |
|
96 | + $selection=is_array($selections) ? $selections[0] : $selections; |
|
97 | + $index=$items->findIndexByValue($selection, false); |
|
98 | 98 | if($this->getSelectedIndex()!==$index) |
99 | 99 | { |
100 | 100 | $this->setSelectedIndex($index); |
@@ -107,14 +107,14 @@ discard block |
||
107 | 107 | $selections=array($selections); |
108 | 108 | $list=array(); |
109 | 109 | foreach($selections as $selection) |
110 | - $list[]=$items->findIndexByValue($selection,false); |
|
110 | + $list[]=$items->findIndexByValue($selection, false); |
|
111 | 111 | $list2=$this->getSelectedIndices(); |
112 | 112 | $n=count($list); |
113 | 113 | $flag=false; |
114 | 114 | if($n===count($list2)) |
115 | 115 | { |
116 | - sort($list,SORT_NUMERIC); |
|
117 | - for($i=0;$i<$n;++$i) |
|
116 | + sort($list, SORT_NUMERIC); |
|
117 | + for($i=0; $i < $n; ++$i) |
|
118 | 118 | { |
119 | 119 | if($list[$i]!==$list2[$i]) |
120 | 120 | { |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | public function setRows($value) |
188 | 188 | { |
189 | 189 | $value=TPropertyValue::ensureInteger($value); |
190 | - if($value<=0) |
|
190 | + if($value <= 0) |
|
191 | 191 | $value=4; |
192 | 192 | $this->setViewState('Rows', $value, 4); |
193 | 193 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function setSelectionMode($value) |
207 | 207 | { |
208 | - $this->setViewState('SelectionMode',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TListSelectionMode'),TListSelectionMode::Single); |
|
208 | + $this->setViewState('SelectionMode', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TListSelectionMode'), TListSelectionMode::Single); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -125,7 +125,7 @@ |
||
125 | 125 | /** |
126 | 126 | * Returns the value to be validated. |
127 | 127 | * This methid is required by \Prado\Web\UI\IValidatable interface. |
128 | - * @return mixed the value of the property to be validated. |
|
128 | + * @return string the value of the property to be validated. |
|
129 | 129 | */ |
130 | 130 | public function getValidationPropertyValue() |
131 | 131 | { |
@@ -57,9 +57,9 @@ |
||
57 | 57 | * @param array the input data collection |
58 | 58 | * @return boolean whether the data of the control has been changed |
59 | 59 | */ |
60 | - public function loadPostData($key,$values) |
|
60 | + public function loadPostData($key, $values) |
|
61 | 61 | { |
62 | - $value=isset($values[$key])?$values[$key]:''; |
|
62 | + $value=isset($values[$key]) ? $values[$key] : ''; |
|
63 | 63 | $oldSelection=$this->getSelectedIndex(); |
64 | 64 | $this->ensureDataBound(); |
65 | 65 | foreach($this->getItems() as $index=>$item) |
@@ -37,7 +37,7 @@ |
||
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Creates a control used for repetition (used as a template). |
40 | - * @return TControl the control to be repeated |
|
40 | + * @return TRadioButtonItem the control to be repeated |
|
41 | 41 | */ |
42 | 42 | protected function createRepeatedControl() |
43 | 43 | { |
@@ -518,16 +518,14 @@ |
||
518 | 518 | { |
519 | 519 | $this->setIsValid(true); |
520 | 520 | $this->onValidationSuccess(); |
521 | - } |
|
522 | - else |
|
521 | + } else |
|
523 | 522 | { |
524 | 523 | if($target) |
525 | 524 | $target->setIsValid(false); |
526 | 525 | $this->setIsValid(false); |
527 | 526 | $this->onValidationError(); |
528 | 527 | } |
529 | - } |
|
530 | - else |
|
528 | + } else |
|
531 | 529 | { |
532 | 530 | $this->evaluateIsValid(); |
533 | 531 | $this->setIsValid(true); |
@@ -185,6 +185,7 @@ discard block |
||
185 | 185 | * TBaseValidator::$_clientClass, be sure to update the corresponding |
186 | 186 | * "Javascript/validation3.js" file as well. |
187 | 187 | * @param TControl control to validate. |
188 | + * @param \Prado\Web\UI\TControl $control |
|
188 | 189 | * @return string control type for client-side validation. |
189 | 190 | */ |
190 | 191 | private function getClientControlClass($control) |
@@ -263,7 +264,7 @@ discard block |
||
263 | 264 | /** |
264 | 265 | * Update the ControlToValidate component's css class depending |
265 | 266 | * if the ControlCssClass property is set, and whether this is valid. |
266 | - * @return boolean true if change, false otherwise. |
|
267 | + * @return boolean|null true if change, false otherwise. |
|
267 | 268 | */ |
268 | 269 | protected function updateControlCssClass() |
269 | 270 | { |
@@ -388,6 +389,7 @@ discard block |
||
388 | 389 | * The ID path is the dot-connected IDs of the controls reaching from |
389 | 390 | * the validator's naming container to the target control. |
390 | 391 | * @param string the ID path |
392 | + * @param string $value |
|
391 | 393 | */ |
392 | 394 | public function setControlToValidate($value) |
393 | 395 | { |
@@ -476,7 +478,7 @@ discard block |
||
476 | 478 | } |
477 | 479 | |
478 | 480 | /** |
479 | - * @return TControl control to be validated. Null if no control is found. |
|
481 | + * @return \Prado\Web\UI\TControl control to be validated. Null if no control is found. |
|
480 | 482 | * @throws TConfigurationException if {@link getControlToValidate |
481 | 483 | * ControlToValidate} is empty or does not point to a valid control |
482 | 484 | */ |
@@ -553,6 +555,7 @@ discard block |
||
553 | 555 | |
554 | 556 | /** |
555 | 557 | * @param string the css class that is applied to the control being validated in case the validation fails |
558 | + * @param string $value |
|
556 | 559 | */ |
557 | 560 | public function setControlCssClass($value) |
558 | 561 | { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * them specially. |
95 | 95 | * @var array list of control class names |
96 | 96 | */ |
97 | - private static $_clientClass = array('THtmlArea', 'THtmlArea4', 'TDatePicker', 'TListBox', 'TCheckBoxList'); |
|
97 | + private static $_clientClass=array('THtmlArea', 'THtmlArea4', 'TDatePicker', 'TListBox', 'TCheckBoxList'); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Constructor. |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | $display=$this->getDisplay(); |
140 | 140 | $visible=$this->getEnabled(true) && !$this->getIsValid(); |
141 | 141 | if($display===TValidatorDisplayStyle::None || (!$visible && $display===TValidatorDisplayStyle::Dynamic)) |
142 | - $writer->addStyleAttribute('display','none'); |
|
142 | + $writer->addStyleAttribute('display', 'none'); |
|
143 | 143 | else if(!$visible) |
144 | - $writer->addStyleAttribute('visibility','hidden'); |
|
145 | - $writer->addAttribute('id',$this->getClientID()); |
|
144 | + $writer->addStyleAttribute('visibility', 'hidden'); |
|
145 | + $writer->addAttribute('id', $this->getClientID()); |
|
146 | 146 | parent::addAttributesToRender($writer); |
147 | 147 | $this->renderClientControlScript($writer); |
148 | 148 | } |
@@ -153,29 +153,29 @@ discard block |
||
153 | 153 | */ |
154 | 154 | protected function getClientScriptOptions() |
155 | 155 | { |
156 | - $control = $this->getValidationTarget(); |
|
157 | - $options['ID'] = $this->getClientID(); |
|
158 | - $options['FormID'] = $this->getPage()->getForm()->getClientID(); |
|
159 | - $options['Display'] = $this->getDisplay(); |
|
160 | - $options['ErrorMessage'] = $this->getErrorMessage(); |
|
156 | + $control=$this->getValidationTarget(); |
|
157 | + $options['ID']=$this->getClientID(); |
|
158 | + $options['FormID']=$this->getPage()->getForm()->getClientID(); |
|
159 | + $options['Display']=$this->getDisplay(); |
|
160 | + $options['ErrorMessage']=$this->getErrorMessage(); |
|
161 | 161 | if($this->getFocusOnError()) |
162 | 162 | { |
163 | - $options['FocusOnError'] = $this->getFocusOnError(); |
|
164 | - $options['FocusElementID'] = $this->getFocusElementID(); |
|
163 | + $options['FocusOnError']=$this->getFocusOnError(); |
|
164 | + $options['FocusElementID']=$this->getFocusElementID(); |
|
165 | 165 | } |
166 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
166 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
167 | 167 | if($control) |
168 | - $options['ControlToValidate'] = $control->getClientID(); |
|
169 | - $options['ControlCssClass'] = $this->getControlCssClass(); |
|
168 | + $options['ControlToValidate']=$control->getClientID(); |
|
169 | + $options['ControlCssClass']=$this->getControlCssClass(); |
|
170 | 170 | |
171 | - $options['ControlType'] = $this->getClientControlClass($control); |
|
172 | - $options['Enabled'] = $this->getEnabled(true); |
|
171 | + $options['ControlType']=$this->getClientControlClass($control); |
|
172 | + $options['Enabled']=$this->getEnabled(true); |
|
173 | 173 | |
174 | 174 | //get date format from date picker target control |
175 | 175 | if($control instanceof TDatePicker) |
176 | - $options['DateFormat'] = $control->getDateFormat(); |
|
176 | + $options['DateFormat']=$control->getDateFormat(); |
|
177 | 177 | |
178 | - $options = array_merge($options,$this->getClientSide()->getOptions()->toArray()); |
|
178 | + $options=array_merge($options, $this->getClientSide()->getOptions()->toArray()); |
|
179 | 179 | |
180 | 180 | return $options; |
181 | 181 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | foreach(self::$_clientClass as $type) |
193 | 193 | if($control instanceof $type) |
194 | 194 | return $type; |
195 | - $reflectionClass = new \ReflectionClass($control); |
|
195 | + $reflectionClass=new \ReflectionClass($control); |
|
196 | 196 | return $reflectionClass->getShortName(); |
197 | 197 | } |
198 | 198 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | public function getClientSide() |
216 | 216 | { |
217 | 217 | if($this->_clientSide===null) |
218 | - $this->_clientSide = $this->createClientSide(); |
|
218 | + $this->_clientSide=$this->createClientSide(); |
|
219 | 219 | return $this->_clientSide; |
220 | 220 | } |
221 | 221 | |
@@ -235,15 +235,15 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function renderClientControlScript($writer) |
237 | 237 | { |
238 | - $scripts = $this->getPage()->getClientScript(); |
|
239 | - if ($this->getEnableClientScript()) |
|
238 | + $scripts=$this->getPage()->getClientScript(); |
|
239 | + if($this->getEnableClientScript()) |
|
240 | 240 | $scripts->registerPradoScript('validator'); |
241 | 241 | $formID=$this->getPage()->getForm()->getClientID(); |
242 | - $scriptKey = "TBaseValidator:$formID"; |
|
242 | + $scriptKey="TBaseValidator:$formID"; |
|
243 | 243 | if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) |
244 | 244 | { |
245 | - $manager['FormID'] = $formID; |
|
246 | - $options = TJavaScript::encode($manager); |
|
245 | + $manager['FormID']=$formID; |
|
246 | + $options=TJavaScript::encode($manager); |
|
247 | 247 | $scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); |
248 | 248 | } |
249 | 249 | if($this->getEnableClientScript()) |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * Override parent implementation to update the control CSS Class before |
255 | 255 | * the validated control is rendered |
256 | 256 | */ |
257 | - public function onPreRender ($param) |
|
257 | + public function onPreRender($param) |
|
258 | 258 | { |
259 | 259 | parent::onPreRender($param); |
260 | 260 | $this->updateControlCssClass(); |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | $control=$this->getValidationTarget(); |
273 | 273 | if($control instanceof TWebControl) |
274 | 274 | { |
275 | - $class = preg_replace ('/ '.preg_quote($cssClass).'/', '',$control->getCssClass()); |
|
275 | + $class=preg_replace('/ '.preg_quote($cssClass).'/', '', $control->getCssClass()); |
|
276 | 276 | if(!$this->getIsValid()) |
277 | 277 | { |
278 | - $class .= ' '.$cssClass; |
|
278 | + $class.=' '.$cssClass; |
|
279 | 279 | $control->setCssClass($class); |
280 | - } elseif ($control->getIsValid()) |
|
280 | + } elseif($control->getIsValid()) |
|
281 | 281 | $control->setCssClass($class); |
282 | 282 | } |
283 | 283 | } |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | */ |
289 | 289 | protected function registerClientScriptValidator() |
290 | 290 | { |
291 | - $key = 'prado:'.$this->getClientID(); |
|
291 | + $key='prado:'.$this->getClientID(); |
|
292 | 292 | if(!$this->getPage()->getClientScript()->isEndScriptRegistered($key)) |
293 | 293 | { |
294 | - $options = TJavaScript::encode($this->getClientScriptOptions()); |
|
295 | - $script = 'new '.$this->getClientClassName().'('.$options.');'; |
|
294 | + $options=TJavaScript::encode($this->getClientScriptOptions()); |
|
295 | + $script='new '.$this->getClientClassName().'('.$options.');'; |
|
296 | 296 | $this->getPage()->getClientScript()->registerEndScript($key, $script); |
297 | 297 | } |
298 | 298 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function setForControl($value) |
313 | 313 | { |
314 | - throw new TNotSupportedException('basevalidator_forcontrol_unsupported',get_class($this)); |
|
314 | + throw new TNotSupportedException('basevalidator_forcontrol_unsupported', get_class($this)); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function getDisplay() |
333 | 333 | { |
334 | - return $this->getViewState('Display',TValidatorDisplayStyle::Fixed); |
|
334 | + return $this->getViewState('Display', TValidatorDisplayStyle::Fixed); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function setDisplay($value) |
341 | 341 | { |
342 | - $this->setViewState('Display',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TValidatorDisplayStyle'),TValidatorDisplayStyle::Fixed); |
|
342 | + $this->setViewState('Display', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TValidatorDisplayStyle'), TValidatorDisplayStyle::Fixed); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public function getEnableClientScript() |
349 | 349 | { |
350 | - return $this->getViewState('EnableClientScript',true); |
|
350 | + return $this->getViewState('EnableClientScript', true); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function setEnableClientScript($value) |
357 | 357 | { |
358 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
358 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function getErrorMessage() |
365 | 365 | { |
366 | - return $this->getViewState('ErrorMessage',''); |
|
366 | + return $this->getViewState('ErrorMessage', ''); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function setErrorMessage($value) |
374 | 374 | { |
375 | - $this->setViewState('ErrorMessage',$value,''); |
|
375 | + $this->setViewState('ErrorMessage', $value, ''); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | public function getControlToValidate() |
382 | 382 | { |
383 | - return $this->getViewState('ControlToValidate',''); |
|
383 | + return $this->getViewState('ControlToValidate', ''); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function setControlToValidate($value) |
393 | 393 | { |
394 | - $this->setViewState('ControlToValidate',$value,''); |
|
394 | + $this->setViewState('ControlToValidate', $value, ''); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | */ |
400 | 400 | public function getFocusOnError() |
401 | 401 | { |
402 | - return $this->getViewState('FocusOnError',false); |
|
402 | + return $this->getViewState('FocusOnError', false); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | */ |
408 | 408 | public function setFocusOnError($value) |
409 | 409 | { |
410 | - $this->setViewState('FocusOnError',TPropertyValue::ensureBoolean($value),false); |
|
410 | + $this->setViewState('FocusOnError', TPropertyValue::ensureBoolean($value), false); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
@@ -417,13 +417,13 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function getFocusElementID() |
419 | 419 | { |
420 | - if(($id=$this->getViewState('FocusElementID',''))==='') |
|
420 | + if(($id=$this->getViewState('FocusElementID', ''))==='') |
|
421 | 421 | { |
422 | 422 | $target=$this->getValidationTarget(); |
423 | 423 | /* Workaround: TCheckBoxList and TRadioButtonList nests the actual |
424 | 424 | * inputs inside a table; we ensure the first input gets focused |
425 | 425 | */ |
426 | - if($target instanceof TCheckBoxList && $target->getItemCount()>0) |
|
426 | + if($target instanceof TCheckBoxList && $target->getItemCount() > 0) |
|
427 | 427 | { |
428 | 428 | $id=$target->getClientID().'_c0'; |
429 | 429 | } else { |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | */ |
448 | 448 | public function getValidationGroup() |
449 | 449 | { |
450 | - return $this->getViewState('ValidationGroup',''); |
|
450 | + return $this->getViewState('ValidationGroup', ''); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | */ |
456 | 456 | public function setValidationGroup($value) |
457 | 457 | { |
458 | - $this->setViewState('ValidationGroup',$value,''); |
|
458 | + $this->setViewState('ValidationGroup', $value, ''); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null) |
486 | 486 | return $control; |
487 | 487 | else |
488 | - throw new TConfigurationException('basevalidator_controltovalidate_invalid',get_class($this)); |
|
488 | + throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this)); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | if($control instanceof \Prado\Web\UI\IValidatable) |
500 | 500 | return $control->getValidationPropertyValue(); |
501 | 501 | else |
502 | - throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this)); |
|
502 | + throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this)); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | */ |
549 | 549 | public function getControlCssClass() |
550 | 550 | { |
551 | - return $this->getViewState('ControlCssClass',''); |
|
551 | + return $this->getViewState('ControlCssClass', ''); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | */ |
557 | 557 | public function setControlCssClass($value) |
558 | 558 | { |
559 | - $this->setViewState('ControlCssClass',$value,''); |
|
559 | + $this->setViewState('ControlCssClass', $value, ''); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | /** |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | */ |
572 | 572 | public function onValidationSuccess() |
573 | 573 | { |
574 | - $this->raiseEvent('OnValidationSuccess',$this,null); |
|
574 | + $this->raiseEvent('OnValidationSuccess', $this, null); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | */ |
580 | 580 | public function onValidationError() |
581 | 581 | { |
582 | - $this->raiseEvent('OnValidationError',$this,null); |
|
582 | + $this->raiseEvent('OnValidationError', $this, null); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | /** |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | */ |
591 | 591 | public function onValidate() |
592 | 592 | { |
593 | - $this->raiseEvent('OnValidate',$this,null); |
|
593 | + $this->raiseEvent('OnValidate', $this, null); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | public function onPreRender($param) |
106 | 106 | { |
107 | 107 | parent::onPreRender($param); |
108 | - $scripts = preg_split('/,|\s+/', $this->getPradoScripts()); |
|
109 | - $cs = $this->getPage()->getClientScript(); |
|
108 | + $scripts=preg_split('/,|\s+/', $this->getPradoScripts()); |
|
109 | + $cs=$this->getPage()->getClientScript(); |
|
110 | 110 | foreach($scripts as $script) |
111 | 111 | { |
112 | - if(($script = trim($script))!=='') |
|
112 | + if(($script=trim($script))!=='') |
|
113 | 113 | $cs->registerPradoScript($script); |
114 | 114 | } |
115 | 115 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function render($writer) |
124 | 124 | { |
125 | - if ($this->getFlushScriptFiles()) |
|
125 | + if($this->getFlushScriptFiles()) |
|
126 | 126 | $this->getPage()->getClientScript()->flushScriptFiles($writer, $this); |
127 | 127 | $this->renderCustomScriptFile($writer); |
128 | 128 | $this->renderCustomScript($writer); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function renderCustomScriptFile($writer) |
136 | 136 | { |
137 | - if(($scriptUrl = $this->getScriptUrl())!=='') |
|
137 | + if(($scriptUrl=$this->getScriptUrl())!=='') |
|
138 | 138 | $writer->write("<script type=\"text/javascript\" src=\"$scriptUrl\"></script>\n"); |
139 | 139 | } |
140 | 140 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function processText($text) |
53 | 53 | { |
54 | - $result = Parsedown::instance()->parse($text); |
|
54 | + $result=Parsedown::instance()->parse($text); |
|
55 | 55 | return preg_replace_callback( |
56 | 56 | '/<pre><code class="language-(\w+)">((.|\n)*?)<\\/code><\\/pre>/im', |
57 | 57 | array($this, 'highlightCode'), $result); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | protected function highlightCode($matches) |
66 | 66 | { |
67 | - $text = html_entity_decode($matches[2],ENT_QUOTES,'UTF-8'); |
|
67 | + $text=html_entity_decode($matches[2], ENT_QUOTES, 'UTF-8'); |
|
68 | 68 | $this->setLanguage($matches[1]); |
69 | 69 | return parent::processText($text); |
70 | 70 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function getMinSelection() |
78 | 78 | { |
79 | - return $this->getViewState('MinSelection',-1); |
|
79 | + return $this->getViewState('MinSelection', -1); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function setMinSelection($value) |
86 | 86 | { |
87 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
87 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
88 | 88 | $value=-1; |
89 | - $this->setViewState('MinSelection',$value,-1); |
|
89 | + $this->setViewState('MinSelection', $value, -1); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function getMaxSelection() |
96 | 96 | { |
97 | - return $this->getViewState('MaxSelection',-1); |
|
97 | + return $this->getViewState('MaxSelection', -1); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function setMaxSelection($value) |
104 | 104 | { |
105 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
105 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
106 | 106 | $value=-1; |
107 | - $this->setViewState('MaxSelection',$value,-1); |
|
107 | + $this->setViewState('MaxSelection', $value, -1); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getRequiredSelections() |
115 | 115 | { |
116 | - return $this->getViewState('RequiredSelections',''); |
|
116 | + return $this->getViewState('RequiredSelections', ''); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function setRequiredSelections($value) |
124 | 124 | { |
125 | - $this->setViewState('RequiredSelections',$value,''); |
|
125 | + $this->setViewState('RequiredSelections', $value, ''); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -135,28 +135,28 @@ discard block |
||
135 | 135 | { |
136 | 136 | $control=$this->getValidationTarget(); |
137 | 137 | |
138 | - $exists = true; |
|
139 | - $values = $this->getSelection($control); |
|
140 | - $count = count($values); |
|
141 | - $required = $this->getRequiredValues(); |
|
138 | + $exists=true; |
|
139 | + $values=$this->getSelection($control); |
|
140 | + $count=count($values); |
|
141 | + $required=$this->getRequiredValues(); |
|
142 | 142 | |
143 | 143 | //if required, check the values |
144 | 144 | if(!empty($required)) |
145 | 145 | { |
146 | - if($count < count($required) ) |
|
146 | + if($count < count($required)) |
|
147 | 147 | return false; |
148 | 148 | foreach($required as $require) |
149 | - $exists = $exists && in_array($require, $values); |
|
149 | + $exists=$exists && in_array($require, $values); |
|
150 | 150 | } |
151 | 151 | |
152 | - $min = $this->getMinSelection(); |
|
153 | - $max = $this->getMaxSelection(); |
|
152 | + $min=$this->getMinSelection(); |
|
153 | + $max=$this->getMaxSelection(); |
|
154 | 154 | |
155 | - if($min !== -1 && $max !== -1) |
|
155 | + if($min!==-1 && $max!==-1) |
|
156 | 156 | return $exists && $count >= $min && $count <= $max; |
157 | - else if($min === -1 && $max !== -1) |
|
157 | + else if($min===-1 && $max!==-1) |
|
158 | 158 | return $exists && $count <= $max; |
159 | - else if($min !== -1 && $max === -1) |
|
159 | + else if($min!==-1 && $max===-1) |
|
160 | 160 | return $exists && $count >= $min; |
161 | 161 | else |
162 | 162 | return $exists; |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | protected function getSelection($control) |
170 | 170 | { |
171 | - $values = array(); |
|
171 | + $values=array(); |
|
172 | 172 | |
173 | 173 | //get the data |
174 | 174 | foreach($control->getItems() as $item) |
175 | 175 | { |
176 | 176 | if($item->getSelected()) |
177 | - $values[] = $item->getValue(); |
|
177 | + $values[]=$item->getValue(); |
|
178 | 178 | } |
179 | 179 | return $values; |
180 | 180 | } |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | */ |
185 | 185 | protected function getRequiredValues() |
186 | 186 | { |
187 | - $required = array(); |
|
188 | - $string = $this->getRequiredSelections(); |
|
187 | + $required=array(); |
|
188 | + $string=$this->getRequiredSelections(); |
|
189 | 189 | if(!empty($string)) |
190 | - $required = preg_split('/,\s*/', $string); |
|
190 | + $required=preg_split('/,\s*/', $string); |
|
191 | 191 | return $required; |
192 | 192 | } |
193 | 193 | |
@@ -197,26 +197,26 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function getClientScriptOptions() |
199 | 199 | { |
200 | - $options = parent::getClientScriptOptions(); |
|
201 | - $control = $this->getValidationTarget(); |
|
200 | + $options=parent::getClientScriptOptions(); |
|
201 | + $control=$this->getValidationTarget(); |
|
202 | 202 | |
203 | 203 | if(!$control instanceof TListControl) |
204 | 204 | { |
205 | 205 | throw new TConfigurationException( |
206 | 206 | 'listcontrolvalidator_invalid_control', |
207 | - $this->getID(),$this->getControlToValidate(), get_class($control)); |
|
207 | + $this->getID(), $this->getControlToValidate(), get_class($control)); |
|
208 | 208 | } |
209 | 209 | |
210 | - $min = $this->getMinSelection(); |
|
211 | - $max = $this->getMaxSelection(); |
|
212 | - if($min !== -1) |
|
213 | - $options['Min']= $min; |
|
214 | - if($max !== -1) |
|
215 | - $options['Max']= $max; |
|
216 | - $required = $this->getRequiredSelections(); |
|
210 | + $min=$this->getMinSelection(); |
|
211 | + $max=$this->getMaxSelection(); |
|
212 | + if($min!==-1) |
|
213 | + $options['Min']=$min; |
|
214 | + if($max!==-1) |
|
215 | + $options['Max']=$max; |
|
216 | + $required=$this->getRequiredSelections(); |
|
217 | 217 | if(strlen($required) > 0) |
218 | - $options['Required']= $required; |
|
219 | - $options['TotalItems'] = $control->getItemCount(); |
|
218 | + $options['Required']=$required; |
|
219 | + $options['TotalItems']=$control->getItemCount(); |
|
220 | 220 | |
221 | 221 | return $options; |
222 | 222 | } |
@@ -163,6 +163,7 @@ |
||
163 | 163 | |
164 | 164 | /** |
165 | 165 | * @param TListControl control to validate |
166 | + * @param \Prado\Web\UI\TControl $control |
|
166 | 167 | * @return array number of selected values and its values. |
167 | 168 | */ |
168 | 169 | protected function getSelection($control) |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getText() |
38 | 38 | { |
39 | - return $this->getViewState('Text',''); |
|
39 | + return $this->getViewState('Text', ''); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function setText($value) |
47 | 47 | { |
48 | - $this->setViewState('Text',TPropertyValue::ensureString($value),''); |
|
48 | + $this->setViewState('Text', TPropertyValue::ensureString($value), ''); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function getEncode() |
81 | 81 | { |
82 | - return $this->getViewState('Encode',false); |
|
82 | + return $this->getViewState('Encode', false); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function setEncode($value) |
89 | 89 | { |
90 | - $this->setViewState('Encode',TPropertyValue::ensureBoolean($value),false); |
|
90 | + $this->setViewState('Encode', TPropertyValue::ensureBoolean($value), false); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -106,8 +106,7 @@ |
||
106 | 106 | $writer->write(THttpUtility::htmlEncode($text)); |
107 | 107 | else |
108 | 108 | $writer->write($text); |
109 | - } |
|
110 | - else |
|
109 | + } else |
|
111 | 110 | parent::render($writer); |
112 | 111 | } |
113 | 112 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function getRegularExpression() |
64 | 64 | { |
65 | - return $this->getViewState('RegularExpression',''); |
|
65 | + return $this->getViewState('RegularExpression', ''); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function setRegularExpression($value) |
72 | 72 | { |
73 | - $this->setViewState('RegularExpression',$value,''); |
|
73 | + $this->setViewState('RegularExpression', $value, ''); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | { |
85 | 85 | if(($value=$this->getValidationValue($this->getValidationTarget()))==='') |
86 | 86 | return true; |
87 | - if(($expression=addcslashes($this->getRegularExpression(),"/"))!=='') |
|
87 | + if(($expression=addcslashes($this->getRegularExpression(), "/"))!=='') |
|
88 | 88 | { |
89 | - $mods = $this->getPatternModifiers(); |
|
90 | - return preg_match("/^$expression\$/{$mods}",$value); |
|
89 | + $mods=$this->getPatternModifiers(); |
|
90 | + return preg_match("/^$expression\$/{$mods}", $value); |
|
91 | 91 | } |
92 | 92 | else |
93 | 93 | return true; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function getClientScriptOptions() |
135 | 135 | { |
136 | - $options = parent::getClientScriptOptions(); |
|
136 | + $options=parent::getClientScriptOptions(); |
|
137 | 137 | $options['ValidationExpression']=$this->getRegularExpression(); |
138 | 138 | $options['PatternModifiers']=$this->getClientSidePatternModifiers(); |
139 | 139 | return $options; |
@@ -85,8 +85,7 @@ |
||
85 | 85 | { |
86 | 86 | $mods = $this->getPatternModifiers(); |
87 | 87 | return preg_match("/^$expression\$/{$mods}",$value); |
88 | - } |
|
89 | - else |
|
88 | + } else |
|
90 | 89 | return true; |
91 | 90 | } |
92 | 91 |