@@ -166,6 +166,7 @@ |
||
166 | 166 | * Otherwise, an exception will be raised. |
167 | 167 | * @param mixed data item |
168 | 168 | * @param mixed field name |
169 | + * @param string $field |
|
169 | 170 | * @return mixed data value at the specified field |
170 | 171 | * @throws TInvalidDataValueException if the data is invalid |
171 | 172 | */ |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function getDataKeyField() |
136 | 136 | { |
137 | - return $this->getViewState('DataKeyField',''); |
|
137 | + return $this->getViewState('DataKeyField', ''); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function setDataKeyField($value) |
144 | 144 | { |
145 | - $this->setViewState('DataKeyField',$value,''); |
|
145 | + $this->setViewState('DataKeyField', $value, ''); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function getDataKeys() |
152 | 152 | { |
153 | - if(($dataKeys=$this->getViewState('DataKeys',null))===null) |
|
153 | + if(($dataKeys=$this->getViewState('DataKeys', null))===null) |
|
154 | 154 | { |
155 | 155 | $dataKeys=new TList; |
156 | - $this->setViewState('DataKeys',$dataKeys,null); |
|
156 | + $this->setViewState('DataKeys', $dataKeys, null); |
|
157 | 157 | } |
158 | 158 | return $dataKeys; |
159 | 159 | } |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | * @return mixed data value at the specified field |
170 | 170 | * @throws TInvalidDataValueException if the data is invalid |
171 | 171 | */ |
172 | - protected function getDataFieldValue($data,$field) |
|
172 | + protected function getDataFieldValue($data, $field) |
|
173 | 173 | { |
174 | - return TDataFieldAccessor::getDataFieldValue($data,$field); |
|
174 | + return TDataFieldAccessor::getDataFieldValue($data, $field); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function onSelectedIndexChanged($param) |
184 | 184 | { |
185 | - $this->raiseEvent('OnSelectedIndexChanged',$this,$param); |
|
185 | + $this->raiseEvent('OnSelectedIndexChanged', $this, $param); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 |
@@ -267,6 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | /** |
269 | 269 | * @param string the public key used for generating the token. A random one will be generated if this is not set. |
270 | + * @param string $value |
|
270 | 271 | */ |
271 | 272 | public function setPublicKey($value) |
272 | 273 | { |
@@ -322,6 +323,7 @@ discard block |
||
322 | 323 | /** |
323 | 324 | * Validates a user input with the token. |
324 | 325 | * @param string user input |
326 | + * @param string $input |
|
325 | 327 | * @return boolean if the user input is not the same as the token. |
326 | 328 | */ |
327 | 329 | public function validate($input) |
@@ -447,6 +449,11 @@ discard block |
||
447 | 449 | * @param string private key |
448 | 450 | * @param integer the length of the token |
449 | 451 | * @param boolean whether the token is case sensitive |
452 | + * @param string $publicKey |
|
453 | + * @param string $privateKey |
|
454 | + * @param string $alphabet |
|
455 | + * @param integer $tokenLength |
|
456 | + * @param boolean $caseSensitive |
|
450 | 457 | * @return string the token generated. |
451 | 458 | */ |
452 | 459 | protected function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive) |
@@ -459,6 +466,7 @@ discard block |
||
459 | 466 | * Converts a hash string into a string with characters consisting of alphanumeric characters. |
460 | 467 | * @param string the hexadecimal representation of the hash string |
461 | 468 | * @param string the alphabet used to represent the converted string. If empty, it means '234578adefhijmnrtwyABDEFGHIJLMNQRTWY', which excludes those confusing characters. |
469 | + * @param string $hex |
|
462 | 470 | * @return string the converted string |
463 | 471 | */ |
464 | 472 | protected function hash2string($hex,$alphabet='') |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getTokenImageTheme() |
75 | 75 | { |
76 | - return $this->getViewState('TokenImageTheme',0); |
|
76 | + return $this->getViewState('TokenImageTheme', 0); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | public function setTokenImageTheme($value) |
93 | 93 | { |
94 | 94 | $value=TPropertyValue::ensureInteger($value); |
95 | - if($value>=0 && $value<=63) |
|
96 | - $this->setViewState('TokenImageTheme',$value,0); |
|
95 | + if($value >= 0 && $value <= 63) |
|
96 | + $this->setViewState('TokenImageTheme', $value, 0); |
|
97 | 97 | else |
98 | - throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63); |
|
98 | + throw new TConfigurationException('captcha_tokenimagetheme_invalid', 0, 63); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getTokenFontSize() |
105 | 105 | { |
106 | - return $this->getViewState('TokenFontSize',30); |
|
106 | + return $this->getViewState('TokenFontSize', 30); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | public function setTokenFontSize($value) |
116 | 116 | { |
117 | 117 | $value=TPropertyValue::ensureInteger($value); |
118 | - if($value>=20 && $value<=100) |
|
119 | - $this->setViewState('TokenFontSize',$value,30); |
|
118 | + if($value >= 20 && $value <= 100) |
|
119 | + $this->setViewState('TokenFontSize', $value, 30); |
|
120 | 120 | else |
121 | - throw new TConfigurationException('captcha_tokenfontsize_invalid',20,100); |
|
121 | + throw new TConfigurationException('captcha_tokenfontsize_invalid', 20, 100); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getMinTokenLength() |
128 | 128 | { |
129 | - return $this->getViewState('MinTokenLength',4); |
|
129 | + return $this->getViewState('MinTokenLength', 4); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | public function setMinTokenLength($value) |
136 | 136 | { |
137 | 137 | $length=TPropertyValue::ensureInteger($value); |
138 | - if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH) |
|
139 | - $this->setViewState('MinTokenLength',$length,4); |
|
138 | + if($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH) |
|
139 | + $this->setViewState('MinTokenLength', $length, 4); |
|
140 | 140 | else |
141 | - throw new TConfigurationException('captcha_mintokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH); |
|
141 | + throw new TConfigurationException('captcha_mintokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getMaxTokenLength() |
148 | 148 | { |
149 | - return $this->getViewState('MaxTokenLength',6); |
|
149 | + return $this->getViewState('MaxTokenLength', 6); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | public function setMaxTokenLength($value) |
156 | 156 | { |
157 | 157 | $length=TPropertyValue::ensureInteger($value); |
158 | - if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH) |
|
159 | - $this->setViewState('MaxTokenLength',$length,6); |
|
158 | + if($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH) |
|
159 | + $this->setViewState('MaxTokenLength', $length, 6); |
|
160 | 160 | else |
161 | - throw new TConfigurationException('captcha_maxtokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH); |
|
161 | + throw new TConfigurationException('captcha_maxtokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function getCaseSensitive() |
168 | 168 | { |
169 | - return $this->getViewState('CaseSensitive',true); |
|
169 | + return $this->getViewState('CaseSensitive', true); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function setCaseSensitive($value) |
176 | 176 | { |
177 | - $this->setViewState('CaseSensitive',TPropertyValue::ensureBoolean($value),true); |
|
177 | + $this->setViewState('CaseSensitive', TPropertyValue::ensureBoolean($value), true); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function getTokenAlphabet() |
184 | 184 | { |
185 | - return $this->getViewState('TokenAlphabet','234578adefhijmnrtABDEFGHJLMNRT'); |
|
185 | + return $this->getViewState('TokenAlphabet', '234578adefhijmnrtABDEFGHJLMNRT'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function setTokenAlphabet($value) |
192 | 192 | { |
193 | - if(strlen($value)<2) |
|
193 | + if(strlen($value) < 2) |
|
194 | 194 | throw new TConfigurationException('captcha_tokenalphabet_invalid'); |
195 | - $this->setViewState('TokenAlphabet',$value,'234578adefhijmnrtABDEFGHJLMNRT'); |
|
195 | + $this->setViewState('TokenAlphabet', $value, '234578adefhijmnrtABDEFGHJLMNRT'); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function getTokenExpiry() |
202 | 202 | { |
203 | - return $this->getViewState('TokenExpiry',600); |
|
203 | + return $this->getViewState('TokenExpiry', 600); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function setTokenExpiry($value) |
210 | 210 | { |
211 | - $this->setViewState('TokenExpiry',TPropertyValue::ensureInteger($value),600); |
|
211 | + $this->setViewState('TokenExpiry', TPropertyValue::ensureInteger($value), 600); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function getChangingTokenBackground() |
218 | 218 | { |
219 | - return $this->getViewState('ChangingTokenBackground',false); |
|
219 | + return $this->getViewState('ChangingTokenBackground', false); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function setChangingTokenBackground($value) |
226 | 226 | { |
227 | - $this->setViewState('ChangingTokenBackground',TPropertyValue::ensureBoolean($value),false); |
|
227 | + $this->setViewState('ChangingTokenBackground', TPropertyValue::ensureBoolean($value), false); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function getTestLimit() |
234 | 234 | { |
235 | - return $this->getViewState('TestLimit',5); |
|
235 | + return $this->getViewState('TestLimit', 5); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function setTestLimit($value) |
242 | 242 | { |
243 | - $this->setViewState('TestLimit',TPropertyValue::ensureInteger($value),5); |
|
243 | + $this->setViewState('TestLimit', TPropertyValue::ensureInteger($value), 5); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function getIsTokenExpired() |
250 | 250 | { |
251 | - if(($expiry=$this->getTokenExpiry())>0 && ($start=$this->getViewState('TokenGenerated',0))>0) |
|
252 | - return $expiry+$start<time(); |
|
251 | + if(($expiry=$this->getTokenExpiry()) > 0 && ($start=$this->getViewState('TokenGenerated', 0)) > 0) |
|
252 | + return $expiry + $start < time(); |
|
253 | 253 | else |
254 | 254 | return false; |
255 | 255 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public function getPublicKey() |
261 | 261 | { |
262 | - if(($publicKey=$this->getViewState('PublicKey',''))==='') |
|
262 | + if(($publicKey=$this->getViewState('PublicKey', ''))==='') |
|
263 | 263 | { |
264 | 264 | $publicKey=$this->generateRandomKey(); |
265 | 265 | $this->setPublicKey($publicKey); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function setPublicKey($value) |
274 | 274 | { |
275 | - $this->setViewState('PublicKey',$value,''); |
|
275 | + $this->setViewState('PublicKey', $value, ''); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function getToken() |
282 | 282 | { |
283 | - return $this->generateToken($this->getPublicKey(),$this->getPrivateKey(),$this->getTokenAlphabet(),$this->getTokenLength(),$this->getCaseSensitive()); |
|
283 | + return $this->generateToken($this->getPublicKey(), $this->getPrivateKey(), $this->getTokenAlphabet(), $this->getTokenLength(), $this->getCaseSensitive()); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -292,13 +292,13 @@ discard block |
||
292 | 292 | { |
293 | 293 | $minLength=$this->getMinTokenLength(); |
294 | 294 | $maxLength=$this->getMaxTokenLength(); |
295 | - if($minLength>$maxLength) |
|
296 | - $tokenLength=rand($maxLength,$minLength); |
|
297 | - else if($minLength<$maxLength) |
|
298 | - $tokenLength=rand($minLength,$maxLength); |
|
295 | + if($minLength > $maxLength) |
|
296 | + $tokenLength=rand($maxLength, $minLength); |
|
297 | + else if($minLength < $maxLength) |
|
298 | + $tokenLength=rand($minLength, $maxLength); |
|
299 | 299 | else |
300 | 300 | $tokenLength=$minLength; |
301 | - $this->setViewState('TokenLength',$tokenLength); |
|
301 | + $this->setViewState('TokenLength', $tokenLength); |
|
302 | 302 | } |
303 | 303 | return $tokenLength; |
304 | 304 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $fileName=$this->generatePrivateKeyFile(); |
314 | 314 | $content=file_get_contents($fileName); |
315 | 315 | $matches=array(); |
316 | - if(preg_match("/privateKey='(.*?)'/ms",$content,$matches)>0) |
|
316 | + if(preg_match("/privateKey='(.*?)'/ms", $content, $matches) > 0) |
|
317 | 317 | $this->_privateKey=$matches[1]; |
318 | 318 | else |
319 | 319 | throw new TConfigurationException('captcha_privatekey_unknown'); |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | */ |
329 | 329 | public function validate($input) |
330 | 330 | { |
331 | - $number=$this->getViewState('TestNumber',0); |
|
331 | + $number=$this->getViewState('TestNumber', 0); |
|
332 | 332 | if(!$this->_validated) |
333 | 333 | { |
334 | - $this->setViewState('TestNumber',++$number); |
|
334 | + $this->setViewState('TestNumber', ++$number); |
|
335 | 335 | $this->_validated=true; |
336 | 336 | } |
337 | - if($this->getIsTokenExpired() || (($limit=$this->getTestLimit())>0 && $number>$limit)) |
|
337 | + if($this->getIsTokenExpired() || (($limit=$this->getTestLimit()) > 0 && $number > $limit)) |
|
338 | 338 | { |
339 | 339 | $this->regenerateToken(); |
340 | 340 | return false; |
341 | 341 | } |
342 | - return ($this->getToken()===($this->getCaseSensitive()?$input:strtoupper($input))); |
|
342 | + return ($this->getToken()===($this->getCaseSensitive() ? $input : strtoupper($input))); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $this->setPublicKey(''); |
354 | 354 | $this->clearViewState('TokenGenerated'); |
355 | 355 | $this->clearViewState('RandomSeed'); |
356 | - $this->clearViewState('TestNumber',0); |
|
356 | + $this->clearViewState('TestNumber', 0); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | parent::onPreRender($param); |
366 | 366 | if(!self::checkRequirements()) |
367 | 367 | throw new TConfigurationException('captcha_imagettftext_required'); |
368 | - if(!$this->getViewState('TokenGenerated',0)) |
|
368 | + if(!$this->getViewState('TokenGenerated', 0)) |
|
369 | 369 | { |
370 | 370 | $manager=$this->getApplication()->getAssetManager(); |
371 | 371 | $manager->publishFilePath($this->getFontFile()); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $url.='?options='.urlencode($this->getTokenImageOptions()); |
374 | 374 | $this->setImageUrl($url); |
375 | 375 | |
376 | - $this->setViewState('TokenGenerated',time()); |
|
376 | + $this->setViewState('TokenGenerated', time()); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | protected function getTokenImageOptions() |
384 | 384 | { |
385 | - $privateKey=$this->getPrivateKey(); // call this method to ensure private key is generated |
|
385 | + $privateKey=$this->getPrivateKey(); // call this method to ensure private key is generated |
|
386 | 386 | $token=$this->getToken(); |
387 | 387 | $options=array(); |
388 | 388 | $options['publicKey']=$this->getPublicKey(); |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | $options['alphabet']=$this->getTokenAlphabet(); |
392 | 392 | $options['fontSize']=$this->getTokenFontSize(); |
393 | 393 | $options['theme']=$this->getTokenImageTheme(); |
394 | - if(($randomSeed=$this->getViewState('RandomSeed',0))===0) |
|
394 | + if(($randomSeed=$this->getViewState('RandomSeed', 0))===0) |
|
395 | 395 | { |
396 | - $randomSeed=(int)(microtime(true)*1000000); |
|
397 | - $this->setViewState('RandomSeed',$randomSeed); |
|
396 | + $randomSeed=(int) (microtime(true) * 1000000); |
|
397 | + $this->setViewState('RandomSeed', $randomSeed); |
|
398 | 398 | } |
399 | - $options['randomSeed']=$this->getChangingTokenBackground()?0:$randomSeed; |
|
399 | + $options['randomSeed']=$this->getChangingTokenBackground() ? 0 : $randomSeed; |
|
400 | 400 | $str=serialize($options); |
401 | 401 | return base64_encode(md5($privateKey.$str).$str); |
402 | 402 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $content="<?php |
431 | 431 | \$privateKey='$key'; |
432 | 432 | ?>"; |
433 | - file_put_contents($fileName,$content); |
|
433 | + file_put_contents($fileName, $content); |
|
434 | 434 | } |
435 | 435 | return $fileName; |
436 | 436 | } |
@@ -451,10 +451,10 @@ discard block |
||
451 | 451 | * @param boolean whether the token is case sensitive |
452 | 452 | * @return string the token generated. |
453 | 453 | */ |
454 | - protected function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive) |
|
454 | + protected function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive) |
|
455 | 455 | { |
456 | - $token=substr($this->hash2string(md5($publicKey.$privateKey),$alphabet).$this->hash2string(md5($privateKey.$publicKey),$alphabet),0,$tokenLength); |
|
457 | - return $caseSensitive?$token:strtoupper($token); |
|
456 | + $token=substr($this->hash2string(md5($publicKey.$privateKey), $alphabet).$this->hash2string(md5($privateKey.$publicKey), $alphabet), 0, $tokenLength); |
|
457 | + return $caseSensitive ? $token : strtoupper($token); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -463,20 +463,20 @@ discard block |
||
463 | 463 | * @param string the alphabet used to represent the converted string. If empty, it means '234578adefhijmnrtwyABDEFGHIJLMNQRTWY', which excludes those confusing characters. |
464 | 464 | * @return string the converted string |
465 | 465 | */ |
466 | - protected function hash2string($hex,$alphabet='') |
|
466 | + protected function hash2string($hex, $alphabet='') |
|
467 | 467 | { |
468 | - if(strlen($alphabet)<2) |
|
468 | + if(strlen($alphabet) < 2) |
|
469 | 469 | $alphabet='234578adefhijmnrtABDEFGHJLMNQRT'; |
470 | 470 | $hexLength=strlen($hex); |
471 | 471 | $base=strlen($alphabet); |
472 | 472 | $result=''; |
473 | - for($i=0;$i<$hexLength;$i+=6) |
|
473 | + for($i=0; $i < $hexLength; $i+=6) |
|
474 | 474 | { |
475 | - $number=hexdec(substr($hex,$i,6)); |
|
475 | + $number=hexdec(substr($hex, $i, 6)); |
|
476 | 476 | while($number) |
477 | 477 | { |
478 | - $result.=$alphabet[$number%$base]; |
|
479 | - $number=floor($number/$base); |
|
478 | + $result.=$alphabet[$number % $base]; |
|
479 | + $number=floor($number / $base); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | return $result; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * @return TCaptchaControl the CAPTCHA control to be validated against |
|
82 | + * @return TCaptcha the CAPTCHA control to be validated against |
|
83 | 83 | * @throws TConfigurationException if the CAPTCHA cannot be found according to {@link setCaptchaControl CaptchaControl} |
84 | 84 | */ |
85 | 85 | protected function findCaptchaControl() |
@@ -115,6 +115,9 @@ discard block |
||
115 | 115 | return $options; |
116 | 116 | } |
117 | 117 | |
118 | + /** |
|
119 | + * @param string $token |
|
120 | + */ |
|
118 | 121 | private function generateTokenHash($token) |
119 | 122 | { |
120 | 123 | for($h=0,$i=strlen($token)-1;$i>=0;--$i) |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function getCaptchaControl() |
52 | 52 | { |
53 | - return $this->getViewState('CaptchaControl',''); |
|
53 | + return $this->getViewState('CaptchaControl', ''); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function setCaptchaControl($value) |
63 | 63 | { |
64 | - $this->setViewState('CaptchaControl',TPropertyValue::ensureString($value),''); |
|
64 | + $this->setViewState('CaptchaControl', TPropertyValue::ensureString($value), ''); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | if(($id=$this->getCaptchaControl())==='') |
88 | 88 | throw new TConfigurationException('captchavalidator_captchacontrol_required'); |
89 | 89 | else if(($control=$this->findControl($id))===null) |
90 | - throw new TConfigurationException('captchavalidator_captchacontrol_inexistent',$id); |
|
90 | + throw new TConfigurationException('captchavalidator_captchacontrol_inexistent', $id); |
|
91 | 91 | else if(!($control instanceof TCaptcha)) |
92 | - throw new TConfigurationException('captchavalidator_captchacontrol_invalid',$id); |
|
92 | + throw new TConfigurationException('captchavalidator_captchacontrol_invalid', $id); |
|
93 | 93 | else |
94 | 94 | return $control; |
95 | 95 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | private function generateTokenHash($token) |
119 | 119 | { |
120 | - for($h=0,$i=strlen($token)-1;$i>=0;--$i) |
|
120 | + for($h=0, $i=strlen($token) - 1; $i >= 0; --$i) |
|
121 | 121 | $h+=ord($token[$i]); |
122 | 122 | return $h; |
123 | 123 | } |
@@ -107,8 +107,7 @@ |
||
107 | 107 | { |
108 | 108 | $options['TokenHash']=$this->generateTokenHash($control->getToken()); |
109 | 109 | $options['CaseSensitive']=true; |
110 | - } |
|
111 | - else |
|
110 | + } else |
|
112 | 111 | { |
113 | 112 | $options['TokenHash']=$this->generateTokenHash(strtoupper($control->getToken())); |
114 | 113 | $options['CaseSensitive']=false; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Returns the value of the property that needs validation. |
120 | - * @return mixed the property value to be validated |
|
120 | + * @return boolean the property value to be validated |
|
121 | 121 | */ |
122 | 122 | public function getValidationPropertyValue() |
123 | 123 | { |
@@ -184,6 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | /** |
186 | 186 | * @param TTextAlign the alignment of the text caption. Valid values include Left and Right. |
187 | + * @param TTextAlign $value |
|
187 | 188 | */ |
188 | 189 | public function setTextAlign($value) |
189 | 190 | { |
@@ -244,6 +245,7 @@ discard block |
||
244 | 245 | /** |
245 | 246 | * Sets a value indicating whether clicking on the checkbox will post the page. |
246 | 247 | * @param boolean whether clicking on the checkbox will post the page. |
248 | + * @param boolean $value |
|
247 | 249 | */ |
248 | 250 | public function setAutoPostBack($value) |
249 | 251 | { |
@@ -261,6 +263,7 @@ discard block |
||
261 | 263 | /** |
262 | 264 | * Sets the value indicating whether postback event trigger by this checkbox will cause input validation. |
263 | 265 | * @param boolean whether postback event trigger by this checkbox will cause input validation. |
266 | + * @param boolean $value |
|
264 | 267 | */ |
265 | 268 | public function setCausesValidation($value) |
266 | 269 | { |
@@ -277,6 +280,7 @@ discard block |
||
277 | 280 | |
278 | 281 | /** |
279 | 282 | * @param string the group of validators which the checkbox causes validation upon postback |
283 | + * @param string $value |
|
280 | 284 | */ |
281 | 285 | public function setValidationGroup($value) |
282 | 286 | { |
@@ -410,6 +414,7 @@ discard block |
||
410 | 414 | |
411 | 415 | /** |
412 | 416 | * @param boolean whether to render javascript. |
417 | + * @param boolean $value |
|
413 | 418 | */ |
414 | 419 | public function setEnableClientScript($value) |
415 | 420 | { |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function getIsValid() |
133 | 133 | { |
134 | - return $this->_isValid; |
|
134 | + return $this->_isValid; |
|
135 | 135 | } |
136 | 136 | /** |
137 | 137 | * @param bool wether this control is valid. |
138 | 138 | */ |
139 | 139 | public function setIsValid($value) |
140 | 140 | { |
141 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
141 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | public function getSurroundingTag() |
290 | 290 | { |
291 | - return 'span'; |
|
291 | + return 'span'; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function getSurroundingTagID() |
298 | 298 | { |
299 | - return $this->getSpanNeeded() ? $this->getClientID().'_parent' : $this->getClientID(); |
|
299 | + return $this->getSpanNeeded() ? $this->getClientID().'_parent' : $this->getClientID(); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | } |
327 | 327 | else |
328 | 328 | $onclick=''; |
329 | - if($needspan=$this->getSpanNeeded()) |
|
330 | - { |
|
331 | - $writer->addAttribute('id',$this->getSurroundingTagID()); |
|
332 | - $writer->renderBeginTag($this->getSurroundingTag()); |
|
333 | - } |
|
329 | + if($needspan=$this->getSpanNeeded()) |
|
330 | + { |
|
331 | + $writer->addAttribute('id',$this->getSurroundingTagID()); |
|
332 | + $writer->renderBeginTag($this->getSurroundingTag()); |
|
333 | + } |
|
334 | 334 | $clientID=$this->getClientID(); |
335 | 335 | if(($text=$this->getText())!=='') |
336 | 336 | { |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
417 | 417 | } |
418 | 418 | |
419 | - /** |
|
420 | - * Check if we need a span tag to surround this control. The span tag will be created if |
|
421 | - * the Text property is set for this control. |
|
422 | - * |
|
423 | - * @return bool wether this control needs a surrounding span tag |
|
424 | - */ |
|
425 | - protected function getSpanNeeded() { |
|
426 | - return $this->getText()!==''; |
|
427 | - } |
|
419 | + /** |
|
420 | + * Check if we need a span tag to surround this control. The span tag will be created if |
|
421 | + * the Text property is set for this control. |
|
422 | + * |
|
423 | + * @return bool wether this control needs a surrounding span tag |
|
424 | + */ |
|
425 | + protected function getSpanNeeded() { |
|
426 | + return $this->getText()!==''; |
|
427 | + } |
|
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Renders a label beside the checkbox. |
@@ -323,8 +323,7 @@ discard block |
||
323 | 323 | $writer->addAttributes($attributes); |
324 | 324 | if($value!==null) |
325 | 325 | $attributes->add('value',$value); |
326 | - } |
|
327 | - else |
|
326 | + } else |
|
328 | 327 | $onclick=''; |
329 | 328 | if($needspan=$this->getSpanNeeded()) |
330 | 329 | { |
@@ -338,14 +337,12 @@ discard block |
||
338 | 337 | { |
339 | 338 | $this->renderLabel($writer,$clientID,$text); |
340 | 339 | $this->renderInputTag($writer,$clientID,$onclick); |
341 | - } |
|
342 | - else |
|
340 | + } else |
|
343 | 341 | { |
344 | 342 | $this->renderInputTag($writer,$clientID,$onclick); |
345 | 343 | $this->renderLabel($writer,$clientID,$text); |
346 | 344 | } |
347 | - } |
|
348 | - else |
|
345 | + } else |
|
349 | 346 | $this->renderInputTag($writer,$clientID,$onclick); |
350 | 347 | if($needspan) |
351 | 348 | $writer->renderEndTag(); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param array the input data collection |
63 | 63 | * @return boolean whether the data of the control has been changed |
64 | 64 | */ |
65 | - public function loadPostData($key,$values) |
|
65 | + public function loadPostData($key, $values) |
|
66 | 66 | { |
67 | 67 | $checked=$this->getChecked(); |
68 | 68 | if($newChecked=isset($values[$key])) |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function onCheckedChanged($param) |
93 | 93 | { |
94 | - $this->raiseEvent('OnCheckedChanged',$this,$param); |
|
94 | + $this->raiseEvent('OnCheckedChanged', $this, $param); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function getText() |
152 | 152 | { |
153 | - return $this->getViewState('Text',''); |
|
153 | + return $this->getViewState('Text', ''); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function setText($value) |
161 | 161 | { |
162 | - $this->setViewState('Text',$value,''); |
|
162 | + $this->setViewState('Text', $value, ''); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getValue() |
169 | 169 | { |
170 | - return $this->getViewState('Value',''); |
|
170 | + return $this->getViewState('Value', ''); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function setValue($value) |
177 | 177 | { |
178 | - $this->setViewState('Value',TPropertyValue::ensureString($value),''); |
|
178 | + $this->setViewState('Value', TPropertyValue::ensureString($value), ''); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function getTextAlign() |
185 | 185 | { |
186 | - return $this->getViewState('TextAlign',TTextAlign::Right); |
|
186 | + return $this->getViewState('TextAlign', TTextAlign::Right); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function setTextAlign($value) |
193 | 193 | { |
194 | - $this->setViewState('TextAlign',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TTextAlign'),TTextAlign::Right); |
|
194 | + $this->setViewState('TextAlign', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TTextAlign'), TTextAlign::Right); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function getChecked() |
201 | 201 | { |
202 | - return $this->getViewState('Checked',false); |
|
202 | + return $this->getViewState('Checked', false); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function setChecked($value) |
210 | 210 | { |
211 | - $this->setViewState('Checked',TPropertyValue::ensureBoolean($value),false); |
|
211 | + $this->setViewState('Checked', TPropertyValue::ensureBoolean($value), false); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function getAutoPostBack() |
244 | 244 | { |
245 | - return $this->getViewState('AutoPostBack',false); |
|
245 | + return $this->getViewState('AutoPostBack', false); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function setAutoPostBack($value) |
253 | 253 | { |
254 | - $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),false); |
|
254 | + $this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), false); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public function getCausesValidation() |
261 | 261 | { |
262 | - return $this->getViewState('CausesValidation',true); |
|
262 | + return $this->getViewState('CausesValidation', true); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function setCausesValidation($value) |
270 | 270 | { |
271 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
271 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function getValidationGroup() |
278 | 278 | { |
279 | - return $this->getViewState('ValidationGroup',''); |
|
279 | + return $this->getViewState('ValidationGroup', ''); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function setValidationGroup($value) |
286 | 286 | { |
287 | - $this->setViewState('ValidationGroup',$value,''); |
|
287 | + $this->setViewState('ValidationGroup', $value, ''); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | if($this->getHasStyle()) |
316 | 316 | $this->getStyle()->addAttributesToRender($writer); |
317 | 317 | if(($tooltip=$this->getToolTip())!=='') |
318 | - $writer->addAttribute('title',$tooltip); |
|
318 | + $writer->addAttribute('title', $tooltip); |
|
319 | 319 | if($this->getHasAttributes()) |
320 | 320 | { |
321 | 321 | $attributes=$this->getAttributes(); |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | if($attributes->getCount()) |
327 | 327 | $writer->addAttributes($attributes); |
328 | 328 | if($value!==null) |
329 | - $attributes->add('value',$value); |
|
329 | + $attributes->add('value', $value); |
|
330 | 330 | } |
331 | 331 | else |
332 | 332 | $onclick=''; |
333 | 333 | if($needspan=$this->getSpanNeeded()) |
334 | 334 | { |
335 | - $writer->addAttribute('id',$this->getSurroundingTagID()); |
|
335 | + $writer->addAttribute('id', $this->getSurroundingTagID()); |
|
336 | 336 | $writer->renderBeginTag($this->getSurroundingTag()); |
337 | 337 | } |
338 | 338 | $clientID=$this->getClientID(); |
@@ -340,17 +340,17 @@ discard block |
||
340 | 340 | { |
341 | 341 | if($this->getTextAlign()===TTextAlign::Left) |
342 | 342 | { |
343 | - $this->renderLabel($writer,$clientID,$text); |
|
344 | - $this->renderInputTag($writer,$clientID,$onclick); |
|
343 | + $this->renderLabel($writer, $clientID, $text); |
|
344 | + $this->renderInputTag($writer, $clientID, $onclick); |
|
345 | 345 | } |
346 | 346 | else |
347 | 347 | { |
348 | - $this->renderInputTag($writer,$clientID,$onclick); |
|
349 | - $this->renderLabel($writer,$clientID,$text); |
|
348 | + $this->renderInputTag($writer, $clientID, $onclick); |
|
349 | + $this->renderLabel($writer, $clientID, $text); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | else |
353 | - $this->renderInputTag($writer,$clientID,$onclick); |
|
353 | + $this->renderInputTag($writer, $clientID, $onclick); |
|
354 | 354 | if($needspan) |
355 | 355 | $writer->renderEndTag(); |
356 | 356 | } |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | */ |
361 | 361 | public function getLabelAttributes() |
362 | 362 | { |
363 | - if($attributes=$this->getViewState('LabelAttributes',null)) |
|
363 | + if($attributes=$this->getViewState('LabelAttributes', null)) |
|
364 | 364 | return $attributes; |
365 | 365 | else |
366 | 366 | { |
367 | 367 | $attributes=new TAttributeCollection; |
368 | - $this->setViewState('LabelAttributes',$attributes,null); |
|
368 | + $this->setViewState('LabelAttributes', $attributes, null); |
|
369 | 369 | return $attributes; |
370 | 370 | } |
371 | 371 | } |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function getInputAttributes() |
377 | 377 | { |
378 | - if($attributes=$this->getViewState('InputAttributes',null)) |
|
378 | + if($attributes=$this->getViewState('InputAttributes', null)) |
|
379 | 379 | return $attributes; |
380 | 380 | else |
381 | 381 | { |
382 | 382 | $attributes=new TAttributeCollection; |
383 | - $this->setViewState('InputAttributes',$attributes,null); |
|
383 | + $this->setViewState('InputAttributes', $attributes, null); |
|
384 | 384 | return $attributes; |
385 | 385 | } |
386 | 386 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | return $value; |
395 | 395 | else |
396 | 396 | { |
397 | - $attributes=$this->getViewState('InputAttributes',null); |
|
397 | + $attributes=$this->getViewState('InputAttributes', null); |
|
398 | 398 | if($attributes && $attributes->contains('value')) |
399 | 399 | return $attributes->itemAt('value'); |
400 | 400 | else if($this->hasAttribute('value')) |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | */ |
410 | 410 | public function getEnableClientScript() |
411 | 411 | { |
412 | - return $this->getViewState('EnableClientScript',true); |
|
412 | + return $this->getViewState('EnableClientScript', true); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function setEnableClientScript($value) |
419 | 419 | { |
420 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
420 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | * @param string checkbox id |
437 | 437 | * @param string label text |
438 | 438 | */ |
439 | - protected function renderLabel($writer,$clientID,$text) |
|
439 | + protected function renderLabel($writer, $clientID, $text) |
|
440 | 440 | { |
441 | - $writer->addAttribute('for',$clientID); |
|
442 | - if($attributes=$this->getViewState('LabelAttributes',null)) |
|
441 | + $writer->addAttribute('for', $clientID); |
|
442 | + if($attributes=$this->getViewState('LabelAttributes', null)) |
|
443 | 443 | $writer->addAttributes($attributes); |
444 | 444 | $writer->renderBeginTag('label'); |
445 | 445 | $writer->write($text); |
@@ -452,21 +452,21 @@ discard block |
||
452 | 452 | * @param string checkbox id |
453 | 453 | * @param string onclick js |
454 | 454 | */ |
455 | - protected function renderInputTag($writer,$clientID,$onclick) |
|
455 | + protected function renderInputTag($writer, $clientID, $onclick) |
|
456 | 456 | { |
457 | 457 | if($clientID!=='') |
458 | - $writer->addAttribute('id',$clientID); |
|
459 | - $writer->addAttribute('type','checkbox'); |
|
458 | + $writer->addAttribute('id', $clientID); |
|
459 | + $writer->addAttribute('type', 'checkbox'); |
|
460 | 460 | if(($value=$this->getValueAttribute())!=='') |
461 | - $writer->addAttribute('value',$value); |
|
461 | + $writer->addAttribute('value', $value); |
|
462 | 462 | if(!empty($onclick)) |
463 | - $writer->addAttribute('onclick',$onclick); |
|
463 | + $writer->addAttribute('onclick', $onclick); |
|
464 | 464 | if(($uniqueID=$this->getUniqueID())!=='') |
465 | - $writer->addAttribute('name',$uniqueID); |
|
465 | + $writer->addAttribute('name', $uniqueID); |
|
466 | 466 | if($this->getChecked()) |
467 | - $writer->addAttribute('checked','checked'); |
|
467 | + $writer->addAttribute('checked', 'checked'); |
|
468 | 468 | if(!$this->getEnabled(true)) |
469 | - $writer->addAttribute('disabled','disabled'); |
|
469 | + $writer->addAttribute('disabled', 'disabled'); |
|
470 | 470 | |
471 | 471 | $page=$this->getPage(); |
472 | 472 | if($this->getEnabled(true) |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | } |
479 | 479 | |
480 | 480 | if(($accesskey=$this->getAccessKey())!=='') |
481 | - $writer->addAttribute('accesskey',$accesskey); |
|
482 | - if(($tabindex=$this->getTabIndex())>0) |
|
483 | - $writer->addAttribute('tabindex',"$tabindex"); |
|
484 | - if($attributes=$this->getViewState('InputAttributes',null)) |
|
481 | + $writer->addAttribute('accesskey', $accesskey); |
|
482 | + if(($tabindex=$this->getTabIndex()) > 0) |
|
483 | + $writer->addAttribute('tabindex', "$tabindex"); |
|
484 | + if($attributes=$this->getViewState('InputAttributes', null)) |
|
485 | 485 | $writer->addAttributes($attributes); |
486 | 486 | $writer->renderBeginTag('input'); |
487 | 487 | $writer->renderEndTag(); |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | */ |
493 | 493 | protected function renderClientControlScript($writer) |
494 | 494 | { |
495 | - $cs = $this->getPage()->getClientScript(); |
|
496 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
495 | + $cs=$this->getPage()->getClientScript(); |
|
496 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -512,10 +512,10 @@ discard block |
||
512 | 512 | */ |
513 | 513 | protected function getPostBackOptions() |
514 | 514 | { |
515 | - $options['ID'] = $this->getClientID(); |
|
516 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
517 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
518 | - $options['EventTarget'] = $this->getUniqueID(); |
|
515 | + $options['ID']=$this->getClientID(); |
|
516 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
517 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
518 | + $options['EventTarget']=$this->getUniqueID(); |
|
519 | 519 | return $options; |
520 | 520 | } |
521 | 521 | } |
522 | 522 | \ No newline at end of file |
@@ -186,6 +186,8 @@ |
||
186 | 186 | * Parse the pair of values into the appropriate value type. |
187 | 187 | * @param string value one |
188 | 188 | * @param string second value |
189 | + * @param string $value1 |
|
190 | + * @param string $value2 |
|
189 | 191 | * @return array appropriate type of the value pair, array($value1, $value2); |
190 | 192 | */ |
191 | 193 | protected function getComparisonValues($value1, $value2) |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function getDataType() |
62 | 62 | { |
63 | - return $this->getViewState('DataType',TValidationDataType::String); |
|
63 | + return $this->getViewState('DataType', TValidationDataType::String); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function setDataType($value) |
72 | 72 | { |
73 | - $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TValidationDataType'),TValidationDataType::String); |
|
73 | + $this->setViewState('DataType', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TValidationDataType'), TValidationDataType::String); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getControlToCompare() |
80 | 80 | { |
81 | - return $this->getViewState('ControlToCompare',''); |
|
81 | + return $this->getViewState('ControlToCompare', ''); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function setControlToCompare($value) |
89 | 89 | { |
90 | - $this->setViewState('ControlToCompare',$value,''); |
|
90 | + $this->setViewState('ControlToCompare', $value, ''); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getValueToCompare() |
97 | 97 | { |
98 | - return $this->getViewState('ValueToCompare',''); |
|
98 | + return $this->getViewState('ValueToCompare', ''); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function setValueToCompare($value) |
106 | 106 | { |
107 | - $this->setViewState('ValueToCompare',$value,''); |
|
107 | + $this->setViewState('ValueToCompare', $value, ''); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function getOperator() |
114 | 114 | { |
115 | - return $this->getViewState('Operator',TValidationCompareOperator::Equal); |
|
115 | + return $this->getViewState('Operator', TValidationCompareOperator::Equal); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function setOperator($value) |
123 | 123 | { |
124 | - $this->setViewState('Operator',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TValidationCompareOperator'),TValidationCompareOperator::Equal); |
|
124 | + $this->setViewState('Operator', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TValidationCompareOperator'), TValidationCompareOperator::Equal); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | else |
164 | 164 | $value2=$this->getValueToCompare(); |
165 | 165 | |
166 | - $values = $this->getComparisonValues($value, $value2); |
|
166 | + $values=$this->getComparisonValues($value, $value2); |
|
167 | 167 | switch($this->getOperator()) |
168 | 168 | { |
169 | 169 | case TValidationCompareOperator::Equal: |
170 | - return $values[0] == $values[1]; |
|
170 | + return $values[0]==$values[1]; |
|
171 | 171 | case TValidationCompareOperator::NotEqual: |
172 | - return $values[0] != $values[1]; |
|
172 | + return $values[0]!=$values[1]; |
|
173 | 173 | case TValidationCompareOperator::GreaterThan: |
174 | 174 | return $values[0] > $values[1]; |
175 | 175 | case TValidationCompareOperator::GreaterThanEqual: |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | case TValidationDataType::Float: |
199 | 199 | return array(floatval($value1), floatval($value2)); |
200 | 200 | case TValidationDataType::Date: |
201 | - $dateFormat = $this->getDateFormat(); |
|
201 | + $dateFormat=$this->getDateFormat(); |
|
202 | 202 | if($dateFormat!=='') |
203 | 203 | { |
204 | - $formatter = new TSimpleDateFormatter($dateFormat); |
|
204 | + $formatter=new TSimpleDateFormatter($dateFormat); |
|
205 | 205 | return array($formatter->parse($value1), $formatter->parse($value2)); |
206 | 206 | } |
207 | 207 | else |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | protected function getClientScriptOptions() |
218 | 218 | { |
219 | - $options = parent::getClientScriptOptions(); |
|
219 | + $options=parent::getClientScriptOptions(); |
|
220 | 220 | if(($name=$this->getControlToCompare())!=='') |
221 | 221 | { |
222 | 222 | if(($control=$this->findControl($name))!==null) |
@@ -62,9 +62,9 @@ |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | - * Sets the date format for a date validation |
|
66 | - * @param string the date format value |
|
67 | - */ |
|
65 | + * Sets the date format for a date validation |
|
66 | + * @param string the date format value |
|
67 | + */ |
|
68 | 68 | public function setDateFormat($value) |
69 | 69 | { |
70 | 70 | $this->setViewState('DateFormat', $value, ''); |
@@ -159,8 +159,7 @@ discard block |
||
159 | 159 | throw new TInvalidDataValueException('comparevalidator_controltocompare_invalid'); |
160 | 160 | if(($value2=$this->getValidationValue($control2))==='') |
161 | 161 | return false; |
162 | - } |
|
163 | - else |
|
162 | + } else |
|
164 | 163 | $value2=$this->getValueToCompare(); |
165 | 164 | |
166 | 165 | $values = $this->getComparisonValues($value, $value2); |
@@ -203,8 +202,7 @@ discard block |
||
203 | 202 | { |
204 | 203 | $formatter = new TSimpleDateFormatter($dateFormat); |
205 | 204 | return array($formatter->parse($value1), $formatter->parse($value2)); |
206 | - } |
|
207 | - else |
|
205 | + } else |
|
208 | 206 | return array(strtotime($value1), strtotime($value2)); |
209 | 207 | } |
210 | 208 | return array($value1, $value2); |
@@ -281,6 +281,7 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @param string the name of the viewstate value to be returned |
283 | 283 | * @param mixed the default value. If $key is not found in viewstate, $defaultValue will be returned |
284 | + * @param string $key |
|
284 | 285 | * @return mixed the viewstate value corresponding to $key |
285 | 286 | */ |
286 | 287 | protected function getViewState($key,$defaultValue=null) |
@@ -295,6 +296,7 @@ discard block |
||
295 | 296 | * @param string the name of the viewstate value |
296 | 297 | * @param mixed the viewstate value to be set |
297 | 298 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from the viewstate. |
299 | + * @param string $key |
|
298 | 300 | */ |
299 | 301 | protected function setViewState($key,$value,$defaultValue=null) |
300 | 302 | { |
@@ -356,6 +358,7 @@ discard block |
||
356 | 358 | * If the data is a component, the field is used as the name of a property. |
357 | 359 | * @param mixed data containing the field of value |
358 | 360 | * @param string the data field |
361 | + * @param string $field |
|
359 | 362 | * @return mixed data value at the specified field |
360 | 363 | * @throws TInvalidDataValueException if the data or the field is invalid. |
361 | 364 | */ |
@@ -515,6 +518,7 @@ discard block |
||
515 | 518 | * as the first and second parameters in {@link sprintf}. |
516 | 519 | * @param string format string |
517 | 520 | * @param mixed the data to be formatted |
521 | + * @param string $formatString |
|
518 | 522 | * @return string the formatted result |
519 | 523 | */ |
520 | 524 | protected function formatDataValue($formatString,$value) |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function setID($value) |
90 | 90 | { |
91 | - if(!preg_match(TControl::ID_FORMAT,$value)) |
|
92 | - throw new TInvalidDataValueException('datagridcolumn_id_invalid',get_class($this),$value); |
|
91 | + if(!preg_match(TControl::ID_FORMAT, $value)) |
|
92 | + throw new TInvalidDataValueException('datagridcolumn_id_invalid', get_class($this), $value); |
|
93 | 93 | $this->_id=$value; |
94 | 94 | } |
95 | 95 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function getHeaderText() |
100 | 100 | { |
101 | - return $this->getViewState('HeaderText',''); |
|
101 | + return $this->getViewState('HeaderText', ''); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function setHeaderText($value) |
108 | 108 | { |
109 | - $this->setViewState('HeaderText',$value,''); |
|
109 | + $this->setViewState('HeaderText', $value, ''); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function getHeaderImageUrl() |
116 | 116 | { |
117 | - return $this->getViewState('HeaderImageUrl',''); |
|
117 | + return $this->getViewState('HeaderImageUrl', ''); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function setHeaderImageUrl($value) |
124 | 124 | { |
125 | - $this->setViewState('HeaderImageUrl',$value,''); |
|
125 | + $this->setViewState('HeaderImageUrl', $value, ''); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function getHeaderRenderer() |
133 | 133 | { |
134 | - return $this->getViewState('HeaderRenderer',''); |
|
134 | + return $this->getViewState('HeaderRenderer', ''); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function setHeaderRenderer($value) |
148 | 148 | { |
149 | - $this->setViewState('HeaderRenderer',$value,''); |
|
149 | + $this->setViewState('HeaderRenderer', $value, ''); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function getHeaderStyle($createStyle=true) |
157 | 157 | { |
158 | - if(($style=$this->getViewState('HeaderStyle',null))===null && $createStyle) |
|
158 | + if(($style=$this->getViewState('HeaderStyle', null))===null && $createStyle) |
|
159 | 159 | { |
160 | 160 | $style=new TTableItemStyle; |
161 | - $this->setViewState('HeaderStyle',$style,null); |
|
161 | + $this->setViewState('HeaderStyle', $style, null); |
|
162 | 162 | } |
163 | 163 | return $style; |
164 | 164 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function getFooterText() |
170 | 170 | { |
171 | - return $this->getViewState('FooterText',''); |
|
171 | + return $this->getViewState('FooterText', ''); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function setFooterText($value) |
178 | 178 | { |
179 | - $this->setViewState('FooterText',$value,''); |
|
179 | + $this->setViewState('FooterText', $value, ''); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function getFooterRenderer() |
187 | 187 | { |
188 | - return $this->getViewState('FooterRenderer',''); |
|
188 | + return $this->getViewState('FooterRenderer', ''); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function setFooterRenderer($value) |
202 | 202 | { |
203 | - $this->setViewState('FooterRenderer',$value,''); |
|
203 | + $this->setViewState('FooterRenderer', $value, ''); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function getFooterStyle($createStyle=true) |
211 | 211 | { |
212 | - if(($style=$this->getViewState('FooterStyle',null))===null && $createStyle) |
|
212 | + if(($style=$this->getViewState('FooterStyle', null))===null && $createStyle) |
|
213 | 213 | { |
214 | 214 | $style=new TTableItemStyle; |
215 | - $this->setViewState('FooterStyle',$style,null); |
|
215 | + $this->setViewState('FooterStyle', $style, null); |
|
216 | 216 | } |
217 | 217 | return $style; |
218 | 218 | } |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function getItemStyle($createStyle=true) |
225 | 225 | { |
226 | - if(($style=$this->getViewState('ItemStyle',null))===null && $createStyle) |
|
226 | + if(($style=$this->getViewState('ItemStyle', null))===null && $createStyle) |
|
227 | 227 | { |
228 | 228 | $style=new TTableItemStyle; |
229 | - $this->setViewState('ItemStyle',$style,null); |
|
229 | + $this->setViewState('ItemStyle', $style, null); |
|
230 | 230 | } |
231 | 231 | return $style; |
232 | 232 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function getSortExpression() |
238 | 238 | { |
239 | - return $this->getViewState('SortExpression',''); |
|
239 | + return $this->getViewState('SortExpression', ''); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function setSortExpression($value) |
246 | 246 | { |
247 | - $this->setViewState('SortExpression',$value,''); |
|
247 | + $this->setViewState('SortExpression', $value, ''); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function getEnableCellGrouping() |
255 | 255 | { |
256 | - return $this->getViewState('EnableCellGrouping',false); |
|
256 | + return $this->getViewState('EnableCellGrouping', false); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function setEnableCellGrouping($value) |
264 | 264 | { |
265 | - $this->setViewState('EnableCellGrouping',TPropertyValue::ensureBoolean($value),false); |
|
265 | + $this->setViewState('EnableCellGrouping', TPropertyValue::ensureBoolean($value), false); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | */ |
271 | 271 | public function getVisible($checkParents=true) |
272 | 272 | { |
273 | - return $this->getViewState('Visible',true); |
|
273 | + return $this->getViewState('Visible', true); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function setVisible($value) |
280 | 280 | { |
281 | - $this->setViewState('Visible',TPropertyValue::ensureBoolean($value),true); |
|
281 | + $this->setViewState('Visible', TPropertyValue::ensureBoolean($value), true); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | * @param mixed the default value. If $key is not found in viewstate, $defaultValue will be returned |
289 | 289 | * @return mixed the viewstate value corresponding to $key |
290 | 290 | */ |
291 | - protected function getViewState($key,$defaultValue=null) |
|
291 | + protected function getViewState($key, $defaultValue=null) |
|
292 | 292 | { |
293 | - return isset($this->_viewState[$key])?$this->_viewState[$key]:$defaultValue; |
|
293 | + return isset($this->_viewState[$key]) ? $this->_viewState[$key] : $defaultValue; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param mixed the viewstate value to be set |
302 | 302 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from the viewstate. |
303 | 303 | */ |
304 | - protected function setViewState($key,$value,$defaultValue=null) |
|
304 | + protected function setViewState($key, $value, $defaultValue=null) |
|
305 | 305 | { |
306 | 306 | if($value===$defaultValue) |
307 | 307 | unset($this->_viewState[$key]); |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | * @return mixed data value at the specified field |
365 | 365 | * @throws TInvalidDataValueException if the data or the field is invalid. |
366 | 366 | */ |
367 | - protected function getDataFieldValue($data,$field) |
|
367 | + protected function getDataFieldValue($data, $field) |
|
368 | 368 | { |
369 | - return TDataFieldAccessor::getDataFieldValue($data,$field); |
|
369 | + return TDataFieldAccessor::getDataFieldValue($data, $field); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | * @param integer the index to the Columns property that the cell resides in. |
382 | 382 | * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem) |
383 | 383 | */ |
384 | - public function initializeCell($cell,$columnIndex,$itemType) |
|
384 | + public function initializeCell($cell, $columnIndex, $itemType) |
|
385 | 385 | { |
386 | 386 | if($itemType===TListItemType::Header) |
387 | - $this->initializeHeaderCell($cell,$columnIndex); |
|
387 | + $this->initializeHeaderCell($cell, $columnIndex); |
|
388 | 388 | else if($itemType===TListItemType::Footer) |
389 | - $this->initializeFooterCell($cell,$columnIndex); |
|
389 | + $this->initializeFooterCell($cell, $columnIndex); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * @param TTableCell the cell to be initialized |
415 | 415 | * @param integer the index to the Columns property that the cell resides in. |
416 | 416 | */ |
417 | - protected function initializeHeaderCell($cell,$columnIndex) |
|
417 | + protected function initializeHeaderCell($cell, $columnIndex) |
|
418 | 418 | { |
419 | 419 | $text=$this->getHeaderText(); |
420 | 420 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $sortExpression=$this->getSortExpression(); |
439 | 439 | if(($url=$this->getHeaderImageUrl())!=='') |
440 | 440 | { |
441 | - $button= new TImageButton; |
|
441 | + $button=new TImageButton; |
|
442 | 442 | $button->setImageUrl($url); |
443 | 443 | $button->setCommandName(TDataGrid::CMD_SORT); |
444 | 444 | $button->setCommandParameter($sortExpression); |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | } |
450 | 450 | else if($text!=='') |
451 | 451 | { |
452 | - $button= new TLinkButton; |
|
452 | + $button=new TLinkButton; |
|
453 | 453 | $button->setText($text); |
454 | 454 | $button->setCommandName(TDataGrid::CMD_SORT); |
455 | 455 | $button->setCommandParameter($sortExpression); |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | { |
464 | 464 | if(($url=$this->getHeaderImageUrl())!=='') |
465 | 465 | { |
466 | - $image= new TImage; |
|
466 | + $image=new TImage; |
|
467 | 467 | $image->setImageUrl($url); |
468 | 468 | if($text!=='') |
469 | 469 | $image->setAlternateText($text); |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | * @param TTableCell the cell to be initialized |
487 | 487 | * @param integer the index to the Columns property that the cell resides in. |
488 | 488 | */ |
489 | - protected function initializeFooterCell($cell,$columnIndex) |
|
489 | + protected function initializeFooterCell($cell, $columnIndex) |
|
490 | 490 | { |
491 | 491 | $text=$this->getFooterText(); |
492 | 492 | if(($classPath=$this->getFooterRenderer())!=='') |
@@ -522,13 +522,13 @@ discard block |
||
522 | 522 | * @param mixed the data to be formatted |
523 | 523 | * @return string the formatted result |
524 | 524 | */ |
525 | - protected function formatDataValue($formatString,$value) |
|
525 | + protected function formatDataValue($formatString, $value) |
|
526 | 526 | { |
527 | 527 | if($formatString==='') |
528 | 528 | return TPropertyValue::ensureString($value); |
529 | 529 | else if($formatString[0]==='#') |
530 | 530 | { |
531 | - $expression=strtr(substr($formatString,1),array('{0}'=>'$value')); |
|
531 | + $expression=strtr(substr($formatString, 1), array('{0}'=>'$value')); |
|
532 | 532 | try |
533 | 533 | { |
534 | 534 | if(eval("\$result=$expression;")===false) |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | } |
538 | 538 | catch(Exception $e) |
539 | 539 | { |
540 | - throw new TInvalidDataValueException('datagridcolumn_expression_invalid',get_class($this),$expression,$e->getMessage()); |
|
540 | + throw new TInvalidDataValueException('datagridcolumn_expression_invalid', get_class($this), $expression, $e->getMessage()); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | else |
544 | - return sprintf($formatString,$value); |
|
544 | + return sprintf($formatString, $value); |
|
545 | 545 | } |
546 | 546 | } |
547 | 547 | \ No newline at end of file |
@@ -432,8 +432,7 @@ discard block |
||
432 | 432 | } |
433 | 433 | $control->setData($text); |
434 | 434 | } |
435 | - } |
|
436 | - else if($this->getAllowSorting()) |
|
435 | + } else if($this->getAllowSorting()) |
|
437 | 436 | { |
438 | 437 | $sortExpression=$this->getSortExpression(); |
439 | 438 | if(($url=$this->getHeaderImageUrl())!=='') |
@@ -446,8 +445,7 @@ discard block |
||
446 | 445 | $button->setAlternateText($text); |
447 | 446 | $button->setCausesValidation(false); |
448 | 447 | $cell->getControls()->add($button); |
449 | - } |
|
450 | - else if($text!=='') |
|
448 | + } else if($text!=='') |
|
451 | 449 | { |
452 | 450 | $button= new TLinkButton; |
453 | 451 | $button->setText($text); |
@@ -455,11 +453,9 @@ discard block |
||
455 | 453 | $button->setCommandParameter($sortExpression); |
456 | 454 | $button->setCausesValidation(false); |
457 | 455 | $cell->getControls()->add($button); |
458 | - } |
|
459 | - else |
|
456 | + } else |
|
460 | 457 | $cell->setText(' '); |
461 | - } |
|
462 | - else |
|
458 | + } else |
|
463 | 459 | { |
464 | 460 | if(($url=$this->getHeaderImageUrl())!=='') |
465 | 461 | { |
@@ -468,8 +464,7 @@ discard block |
||
468 | 464 | if($text!=='') |
469 | 465 | $image->setAlternateText($text); |
470 | 466 | $cell->getControls()->add($image); |
471 | - } |
|
472 | - else if($text!=='') |
|
467 | + } else if($text!=='') |
|
473 | 468 | $cell->setText($text); |
474 | 469 | else |
475 | 470 | $cell->setText(' '); |
@@ -503,8 +498,7 @@ discard block |
||
503 | 498 | } |
504 | 499 | $control->setData($text); |
505 | 500 | } |
506 | - } |
|
507 | - else if($text!=='') |
|
501 | + } else if($text!=='') |
|
508 | 502 | $cell->setText($text); |
509 | 503 | else |
510 | 504 | $cell->setText(' '); |
@@ -534,13 +528,11 @@ discard block |
||
534 | 528 | if(eval("\$result=$expression;")===false) |
535 | 529 | throw new Exception(''); |
536 | 530 | return $result; |
537 | - } |
|
538 | - catch(Exception $e) |
|
531 | + } catch(Exception $e) |
|
539 | 532 | { |
540 | 533 | throw new TInvalidDataValueException('datagridcolumn_expression_invalid',get_class($this),$expression,$e->getMessage()); |
541 | 534 | } |
542 | - } |
|
543 | - else |
|
535 | + } else |
|
544 | 536 | return sprintf($formatString,$value); |
545 | 537 | } |
546 | 538 | } |
547 | 539 | \ No newline at end of file |
@@ -82,6 +82,7 @@ |
||
82 | 82 | /** |
83 | 83 | * Determine if the given value is of a particular type using RegExp. |
84 | 84 | * @param string value to check |
85 | + * @param string $value |
|
85 | 86 | * @return boolean true if value fits the type expression. |
86 | 87 | */ |
87 | 88 | protected function evaluateDataTypeCheck($value) |
@@ -62,9 +62,9 @@ |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | - * Sets the date format for a date validation |
|
66 | - * @param string the date format value |
|
67 | - */ |
|
65 | + * Sets the date format for a date validation |
|
66 | + * @param string the date format value |
|
67 | + */ |
|
68 | 68 | public function setDateFormat($value) |
69 | 69 | { |
70 | 70 | $this->setViewState('DateFormat', $value, ''); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function getDataType() |
51 | 51 | { |
52 | - return $this->getViewState('DataType','String'); |
|
52 | + return $this->getViewState('DataType', 'String'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setDataType($value) |
60 | 60 | { |
61 | - $this->setViewState('DataType',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TValidationDataType'),TValidationDataType::String); |
|
61 | + $this->setViewState('DataType', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TValidationDataType'), TValidationDataType::String); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | switch($this->getDataType()) |
93 | 93 | { |
94 | 94 | case TValidationDataType::Integer: |
95 | - return preg_match('/^[-+]?[0-9]+$/',trim($value)); |
|
95 | + return preg_match('/^[-+]?[0-9]+$/', trim($value)); |
|
96 | 96 | case TValidationDataType::Float: |
97 | - return preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value)); |
|
97 | + return preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/', trim($value)); |
|
98 | 98 | case TValidationDataType::Date: |
99 | - $dateFormat = $this->getDateFormat(); |
|
99 | + $dateFormat=$this->getDateFormat(); |
|
100 | 100 | if(strlen($dateFormat)) |
101 | 101 | { |
102 | - $formatter = new TSimpleDateFormatter($dateFormat); |
|
102 | + $formatter=new TSimpleDateFormatter($dateFormat); |
|
103 | 103 | return $formatter->isValidDate($value); |
104 | 104 | } |
105 | 105 | else |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function getClientScriptOptions() |
116 | 116 | { |
117 | - $options = parent::getClientScriptOptions(); |
|
117 | + $options=parent::getClientScriptOptions(); |
|
118 | 118 | $options['DataType']=$this->getDataType(); |
119 | 119 | if(($dateFormat=$this->getDateFormat())!=='') |
120 | 120 | $options['DateFormat']=$dateFormat; |
@@ -101,8 +101,7 @@ |
||
101 | 101 | { |
102 | 102 | $formatter = new TSimpleDateFormatter($dateFormat); |
103 | 103 | return $formatter->isValidDate($value); |
104 | - } |
|
105 | - else |
|
104 | + } else |
|
106 | 105 | return strtotime($value) > 0; |
107 | 106 | } |
108 | 107 | return true; |
@@ -55,7 +55,7 @@ |
||
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Returns an array of javascript validator options. |
58 | - * @return array javascript validator options. |
|
58 | + * @return boolean javascript validator options. |
|
59 | 59 | */ |
60 | 60 | public function evaluateIsValid() |
61 | 61 | { |
@@ -70,8 +70,7 @@ |
||
70 | 70 | { |
71 | 71 | $domain=substr($value,$pos+1); |
72 | 72 | return $domain===''?false:checkdnsrr($domain,'MX'); |
73 | - } |
|
74 | - else |
|
73 | + } else |
|
75 | 74 | return false; |
76 | 75 | } |
77 | 76 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function getRegularExpression() |
49 | 49 | { |
50 | 50 | $regex=parent::getRegularExpression(); |
51 | - return $regex===''?self::EMAIL_REGEXP:$regex; |
|
51 | + return $regex==='' ?self::EMAIL_REGEXP : $regex; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | public function evaluateIsValid() |
59 | 59 | { |
60 | 60 | $value=$this->getValidationValue($this->getValidationTarget()); |
61 | - $valid=$valid=is_string($value) && strlen($value)<=254 && parent::evaluateIsValid(); |
|
61 | + $valid=$valid=is_string($value) && strlen($value) <= 254 && parent::evaluateIsValid(); |
|
62 | 62 | |
63 | 63 | if($valid && $this->getCheckMXRecord() && function_exists('checkdnsrr')) |
64 | 64 | { |
65 | 65 | if($value!=='') |
66 | 66 | { |
67 | - if(($pos=strpos($value,'@'))!==false) |
|
67 | + if(($pos=strpos($value, '@'))!==false) |
|
68 | 68 | { |
69 | - $domain=substr($value,$pos+1); |
|
70 | - return $domain===''?false:checkdnsrr($domain,'MX'); |
|
69 | + $domain=substr($value, $pos + 1); |
|
70 | + return $domain==='' ?false:checkdnsrr($domain, 'MX'); |
|
71 | 71 | } |
72 | 72 | else |
73 | 73 | return false; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function getCheckMXRecord() |
83 | 83 | { |
84 | - return $this->getViewState('CheckMXRecord',false); |
|
84 | + return $this->getViewState('CheckMXRecord', false); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function setCheckMXRecord($value) |
92 | 92 | { |
93 | - $this->setViewState('CheckMXRecord',TPropertyValue::ensureBoolean($value),false); |
|
93 | + $this->setViewState('CheckMXRecord', TPropertyValue::ensureBoolean($value), false); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 |
@@ -49,7 +49,7 @@ |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * @return Tells whether buffering of output can continue after this point |
|
52 | + * @return boolean whether buffering of output can continue after this point |
|
53 | 53 | */ |
54 | 54 | public function getContinueBuffering() |
55 | 55 | { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function __construct() |
46 | 46 | { |
47 | 47 | parent::__construct(); |
48 | - $this->EnableViewState = false; |
|
48 | + $this->EnableViewState=false; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function setContinueBuffering($value) |
63 | 63 | { |
64 | - $this->_continueBuffering = TPropertyValue::ensureBoolean($value); |
|
64 | + $this->_continueBuffering=TPropertyValue::ensureBoolean($value); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | //$writer->write('<!-- flush -->'); |
74 | 74 | // ajax responses can't be parsed by the client side before loaded and returned completely, |
75 | 75 | // so don't bother with flushing output somewhere mid-page if refreshing in a callback |
76 | - if (!$this->Page->IsCallback) |
|
76 | + if(!$this->Page->IsCallback) |
|
77 | 77 | { |
78 | 78 | $this->Page->flushWriter(); |
79 | 79 | // $this->Application->flushOutput($this->ContinueBuffering); |