@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function setAlternateText($value) |
| 60 | 60 | { |
| 61 | - if(parent::getAlternateText() === $value) |
|
| 61 | + if(parent::getAlternateText()===$value) |
|
| 62 | 62 | return; |
| 63 | 63 | |
| 64 | 64 | parent::setAlternateText($value); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function setImageAlign($value) |
| 77 | 77 | { |
| 78 | - if(parent::getImageAlign() === $value) |
|
| 78 | + if(parent::getImageAlign()===$value) |
|
| 79 | 79 | return; |
| 80 | 80 | |
| 81 | 81 | parent::setImageAlign($value); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function setImageUrl($value) |
| 90 | 90 | { |
| 91 | - if(parent::getImageUrl() === $value) |
|
| 91 | + if(parent::getImageUrl()===$value) |
|
| 92 | 92 | return; |
| 93 | 93 | |
| 94 | 94 | parent::setImageUrl($value); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function setDescriptionUrl($value) |
| 103 | 103 | { |
| 104 | - if(parent::getDescriptionUrl() === $value) |
|
| 104 | + if(parent::getDescriptionUrl()===$value) |
|
| 105 | 105 | return; |
| 106 | 106 | |
| 107 | 107 | parent::setDescriptionUrl($value); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | protected function addAttributesToRender($writer) |
| 152 | 152 | { |
| 153 | 153 | parent::addAttributesToRender($writer); |
| 154 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 154 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 155 | 155 | $this->getActiveControl()->registerCallbackClientScript( |
| 156 | 156 | $this->getClientClassName(), $this->getPostBackOptions()); |
| 157 | 157 | } |
@@ -48,6 +48,7 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * Sets the alternative text to be displayed in the TImage when the image is unavailable. |
| 50 | 50 | * @param string the alternative text |
| 51 | + * @param string $value |
|
| 51 | 52 | */ |
| 52 | 53 | public function setAlternateText($value) |
| 53 | 54 | { |
@@ -78,6 +79,7 @@ discard block |
||
| 78 | 79 | |
| 79 | 80 | /** |
| 80 | 81 | * @param string the URL of the image file |
| 82 | + * @param string $value |
|
| 81 | 83 | */ |
| 82 | 84 | public function setImageUrl($value) |
| 83 | 85 | { |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | { |
| 405 | 405 | if ($needSpan=$this->getSpanNeeded()) |
| 406 | 406 | { |
| 407 | - $writer->addAttribute('id', $this->getClientId()); |
|
| 408 | - $writer->renderBeginTag('span'); |
|
| 407 | + $writer->addAttribute('id', $this->getClientId()); |
|
| 408 | + $writer->renderBeginTag('span'); |
|
| 409 | 409 | } |
| 410 | 410 | if($this->getItemCount()>0) |
| 411 | 411 | { |
@@ -463,14 +463,14 @@ discard block |
||
| 463 | 463 | */ |
| 464 | 464 | public function getIsValid() |
| 465 | 465 | { |
| 466 | - return $this->_isValid; |
|
| 466 | + return $this->_isValid; |
|
| 467 | 467 | } |
| 468 | 468 | /** |
| 469 | 469 | * @param bool wether this control is valid. |
| 470 | 470 | */ |
| 471 | 471 | public function setIsValid($value) |
| 472 | 472 | { |
| 473 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 473 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Creates a control used for repetition (used as a template). |
| 62 | - * @return TControl the control to be repeated |
|
| 62 | + * @return TCheckBoxItem the control to be repeated |
|
| 63 | 63 | */ |
| 64 | 64 | protected function createRepeatedControl() |
| 65 | 65 | { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * This method overrides the parent implementation so that it always returns |
| 72 | 72 | * the checkbox list itself (because the checkbox list does not have child controls.) |
| 73 | 73 | * @param string control ID |
| 74 | - * @return TControl control being found |
|
| 74 | + * @return \Prado\Web\UI\TControl|null control being found |
|
| 75 | 75 | */ |
| 76 | 76 | public function findControl($id, $real=false) |
| 77 | 77 | { |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | - * @return string the direction of traversing the list, defaults to 'Vertical' |
|
| 148 | + * @return TRepeatDirection the direction of traversing the list, defaults to 'Vertical' |
|
| 149 | 149 | */ |
| 150 | 150 | public function getRepeatDirection() |
| 151 | 151 | { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | - * @return string how the list should be displayed, using table or using line breaks. Defaults to 'Table'. |
|
| 164 | + * @return TRepeatLayout how the list should be displayed, using table or using line breaks. Defaults to 'Table'. |
|
| 165 | 165 | */ |
| 166 | 166 | public function getRepeatLayout() |
| 167 | 167 | { |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | /** |
| 441 | 441 | * Returns the value to be validated. |
| 442 | 442 | * This methid is required by \Prado\Web\UI\IValidatable interface. |
| 443 | - * @return mixed the value of the property to be validated. |
|
| 443 | + * @return string the value of the property to be validated. |
|
| 444 | 444 | */ |
| 445 | 445 | public function getValidationPropertyValue() |
| 446 | 446 | { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function findControl($id, $real=false) |
| 77 | 77 | { |
| 78 | - if ($real===true) |
|
| 78 | + if($real===true) |
|
| 79 | 79 | return parent::findControl($id); |
| 80 | 80 | return $this; |
| 81 | 81 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function getTextAlign() |
| 105 | 105 | { |
| 106 | - return $this->getViewState('TextAlign',TTextAlign::Right); |
|
| 106 | + return $this->getViewState('TextAlign', TTextAlign::Right); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function setTextAlign($value) |
| 113 | 113 | { |
| 114 | - $this->setViewState('TextAlign',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TTextAlign'),TTextAlign::Right); |
|
| 114 | + $this->setViewState('TextAlign', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TTextAlign'), TTextAlign::Right); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function getRepeatInfo() |
| 122 | 122 | { |
| 123 | - if(($repeatInfo=$this->getViewState('RepeatInfo',null))===null) |
|
| 123 | + if(($repeatInfo=$this->getViewState('RepeatInfo', null))===null) |
|
| 124 | 124 | { |
| 125 | 125 | $repeatInfo=new TRepeatInfo; |
| 126 | - $this->setViewState('RepeatInfo',$repeatInfo,null); |
|
| 126 | + $this->setViewState('RepeatInfo', $repeatInfo, null); |
|
| 127 | 127 | } |
| 128 | 128 | return $repeatInfo; |
| 129 | 129 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | public function setEnabled($value) |
| 253 | 253 | { |
| 254 | 254 | parent::setEnabled($value); |
| 255 | - $value = !TPropertyValue::ensureBoolean($value); |
|
| 255 | + $value=!TPropertyValue::ensureBoolean($value); |
|
| 256 | 256 | // if this is an active control, |
| 257 | 257 | // and it's a callback, |
| 258 | 258 | // and we can update clientside, |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | $this->getPage()->getIsCallBack() && |
| 262 | 262 | $this->getActiveControl()->canUpdateClientSide()) |
| 263 | 263 | { |
| 264 | - $items = $this->getItems(); |
|
| 265 | - $cs = $this->getPage()->getCallbackClient(); |
|
| 266 | - $baseClientID = $this->getClientID().'_c'; |
|
| 264 | + $items=$this->getItems(); |
|
| 265 | + $cs=$this->getPage()->getCallbackClient(); |
|
| 266 | + $baseClientID=$this->getClientID().'_c'; |
|
| 267 | 267 | foreach($items as $index=>$item) |
| 268 | 268 | { |
| 269 | 269 | $cs->setAttribute($baseClientID.$index, 'disabled', $value); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param integer index of the item being rendered |
| 279 | 279 | * @return null |
| 280 | 280 | */ |
| 281 | - public function generateItemStyle($itemType,$index) |
|
| 281 | + public function generateItemStyle($itemType, $index) |
|
| 282 | 282 | { |
| 283 | 283 | return null; |
| 284 | 284 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @param string item type (Header,Footer,Item,AlternatingItem,SelectedItem,EditItem,Separator,Pager) |
| 292 | 292 | * @param integer zero-based index of the item in the item list |
| 293 | 293 | */ |
| 294 | - public function renderItem($writer,$repeatInfo,$itemType,$index) |
|
| 294 | + public function renderItem($writer, $repeatInfo, $itemType, $index) |
|
| 295 | 295 | { |
| 296 | 296 | $repeatedControl=$this->_repeatedControl; |
| 297 | 297 | $item=$this->getItems()->itemAt($index); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | $repeatedControl->setID("c$index"); |
| 303 | 303 | $repeatedControl->setText($item->getText()); |
| 304 | 304 | $repeatedControl->setChecked($item->getSelected()); |
| 305 | - $repeatedControl->setAttribute('value',$item->getValue()); |
|
| 305 | + $repeatedControl->setAttribute('value', $item->getValue()); |
|
| 306 | 306 | $repeatedControl->setEnabled($this->_isEnabled && $item->getEnabled()); |
| 307 | 307 | $repeatedControl->setEnableClientScript(false); |
| 308 | 308 | $repeatedControl->renderControl($writer); |
@@ -315,13 +315,13 @@ discard block |
||
| 315 | 315 | * @param array the input data collection |
| 316 | 316 | * @return boolean whether the data of the control has been changed |
| 317 | 317 | */ |
| 318 | - public function loadPostData($key,$values) |
|
| 318 | + public function loadPostData($key, $values) |
|
| 319 | 319 | { |
| 320 | 320 | if($this->getEnabled(true)) |
| 321 | 321 | { |
| 322 | - $index=(int)substr($key,strlen($this->getUniqueID())+2); |
|
| 322 | + $index=(int) substr($key, strlen($this->getUniqueID()) + 2); |
|
| 323 | 323 | $this->ensureDataBound(); |
| 324 | - if($index>=0 && $index<$this->getItemCount()) |
|
| 324 | + if($index >= 0 && $index < $this->getItemCount()) |
|
| 325 | 325 | { |
| 326 | 326 | $item=$this->getItems()->itemAt($index); |
| 327 | 327 | if($item->getEnabled()) |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $this->_repeatedControl->setValidationGroup($this->getValidationGroup()); |
| 370 | 370 | $page=$this->getPage(); |
| 371 | 371 | $n=$this->getItemCount(); |
| 372 | - for($i=0;$i<$n;++$i) |
|
| 372 | + for($i=0; $i < $n; ++$i) |
|
| 373 | 373 | { |
| 374 | 374 | $this->_repeatedControl->setID("c$i"); |
| 375 | 375 | $page->registerRequiresPostData($this->_repeatedControl); |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | * |
| 382 | 382 | *@return boolean true if we need a span |
| 383 | 383 | */ |
| 384 | - protected function getSpanNeeded () |
|
| 384 | + protected function getSpanNeeded() |
|
| 385 | 385 | { |
| 386 | 386 | return $this->getRepeatLayout()===TRepeatLayout::Raw; |
| 387 | 387 | } |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | public function render($writer) |
| 395 | 395 | { |
| 396 | - if ($needSpan=$this->getSpanNeeded()) |
|
| 396 | + if($needSpan=$this->getSpanNeeded()) |
|
| 397 | 397 | { |
| 398 | 398 | $writer->addAttribute('id', $this->getClientId()); |
| 399 | 399 | $writer->renderBeginTag('span'); |
| 400 | 400 | } |
| 401 | - if($this->getItemCount()>0) |
|
| 401 | + if($this->getItemCount() > 0) |
|
| 402 | 402 | { |
| 403 | 403 | $this->_isEnabled=$this->getEnabled(true); |
| 404 | 404 | $repeatInfo=$this->getRepeatInfo(); |
@@ -410,11 +410,11 @@ discard block |
||
| 410 | 410 | $this->setAccessKey(''); |
| 411 | 411 | $this->setTabIndex(0); |
| 412 | 412 | $this->addAttributesToRender($writer); |
| 413 | - $repeatInfo->renderRepeater($writer,$this); |
|
| 413 | + $repeatInfo->renderRepeater($writer, $this); |
|
| 414 | 414 | $this->setAccessKey($accessKey); |
| 415 | 415 | $this->setTabIndex($tabIndex); |
| 416 | 416 | } |
| 417 | - if ($needSpan) |
|
| 417 | + if($needSpan) |
|
| 418 | 418 | $writer->renderEndTag(); |
| 419 | 419 | |
| 420 | 420 | //checkbox skipped the client control script in addAttributesToRender |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | protected function getPostBackOptions() |
| 482 | 482 | { |
| 483 | - $options['ID'] = $this->getClientID(); |
|
| 484 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
| 485 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
| 486 | - $options['ListName'] = $this->getUniqueID(); |
|
| 487 | - $options['ItemCount'] = $this->getItemCount(); |
|
| 483 | + $options['ID']=$this->getClientID(); |
|
| 484 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
| 485 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
| 486 | + $options['ListName']=$this->getUniqueID(); |
|
| 487 | + $options['ItemCount']=$this->getItemCount(); |
|
| 488 | 488 | return $options; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -29,82 +29,82 @@ |
||
| 29 | 29 | |
| 30 | 30 | class TReCaptcha2Validator extends TBaseValidator |
| 31 | 31 | { |
| 32 | - protected $_isvalid = null; |
|
| 32 | + protected $_isvalid = null; |
|
| 33 | 33 | |
| 34 | - protected function getClientClassName() |
|
| 35 | - { |
|
| 36 | - return 'Prado.WebUI.TReCaptcha2Validator'; |
|
| 37 | - } |
|
| 38 | - public function getEnableClientScript() |
|
| 39 | - { |
|
| 40 | - return true; |
|
| 41 | - } |
|
| 42 | - protected function getCaptchaControl() |
|
| 43 | - { |
|
| 44 | - $control = $this->getValidationTarget(); |
|
| 45 | - if (!$control) |
|
| 46 | - throw new Exception('No target control specified for TReCaptcha2Validator'); |
|
| 47 | - if (!($control instanceof TReCaptcha2)) |
|
| 48 | - throw new Exception('TReCaptcha2Validator only works with TReCaptcha2 controls'); |
|
| 49 | - return $control; |
|
| 50 | - } |
|
| 51 | - public function getClientScriptOptions() |
|
| 52 | - { |
|
| 53 | - $options = parent::getClientScriptOptions(); |
|
| 54 | - $options['ResponseFieldName'] = $this->getCaptchaControl()->getResponseFieldName(); |
|
| 55 | - return $options; |
|
| 56 | - } |
|
| 57 | - /** |
|
| 58 | - * This method overrides the parent's implementation. |
|
| 59 | - * The validation succeeds if the input control has the same value |
|
| 60 | - * as the one displayed in the corresponding RECAPTCHA control. |
|
| 61 | - * |
|
| 62 | - * @return boolean whether the validation succeeds |
|
| 63 | - */ |
|
| 64 | - protected function evaluateIsValid() |
|
| 65 | - { |
|
| 66 | - // check validity only once (if trying to evaulate multiple times, all redundant checks would fail) |
|
| 67 | - if (is_null($this->_isvalid)) |
|
| 68 | - { |
|
| 69 | - $control = $this->getCaptchaControl(); |
|
| 70 | - $this->_isvalid = $control->validate(); |
|
| 71 | - } |
|
| 72 | - return ($this->_isvalid==true); |
|
| 73 | - } |
|
| 74 | - public function onPreRender($param) |
|
| 75 | - { |
|
| 76 | - parent::onPreRender($param); |
|
| 34 | + protected function getClientClassName() |
|
| 35 | + { |
|
| 36 | + return 'Prado.WebUI.TReCaptcha2Validator'; |
|
| 37 | + } |
|
| 38 | + public function getEnableClientScript() |
|
| 39 | + { |
|
| 40 | + return true; |
|
| 41 | + } |
|
| 42 | + protected function getCaptchaControl() |
|
| 43 | + { |
|
| 44 | + $control = $this->getValidationTarget(); |
|
| 45 | + if (!$control) |
|
| 46 | + throw new Exception('No target control specified for TReCaptcha2Validator'); |
|
| 47 | + if (!($control instanceof TReCaptcha2)) |
|
| 48 | + throw new Exception('TReCaptcha2Validator only works with TReCaptcha2 controls'); |
|
| 49 | + return $control; |
|
| 50 | + } |
|
| 51 | + public function getClientScriptOptions() |
|
| 52 | + { |
|
| 53 | + $options = parent::getClientScriptOptions(); |
|
| 54 | + $options['ResponseFieldName'] = $this->getCaptchaControl()->getResponseFieldName(); |
|
| 55 | + return $options; |
|
| 56 | + } |
|
| 57 | + /** |
|
| 58 | + * This method overrides the parent's implementation. |
|
| 59 | + * The validation succeeds if the input control has the same value |
|
| 60 | + * as the one displayed in the corresponding RECAPTCHA control. |
|
| 61 | + * |
|
| 62 | + * @return boolean whether the validation succeeds |
|
| 63 | + */ |
|
| 64 | + protected function evaluateIsValid() |
|
| 65 | + { |
|
| 66 | + // check validity only once (if trying to evaulate multiple times, all redundant checks would fail) |
|
| 67 | + if (is_null($this->_isvalid)) |
|
| 68 | + { |
|
| 69 | + $control = $this->getCaptchaControl(); |
|
| 70 | + $this->_isvalid = $control->validate(); |
|
| 71 | + } |
|
| 72 | + return ($this->_isvalid==true); |
|
| 73 | + } |
|
| 74 | + public function onPreRender($param) |
|
| 75 | + { |
|
| 76 | + parent::onPreRender($param); |
|
| 77 | 77 | |
| 78 | - $cs = $this->Page->getClientScript(); |
|
| 79 | - $cs->registerPradoScript('validator'); |
|
| 78 | + $cs = $this->Page->getClientScript(); |
|
| 79 | + $cs->registerPradoScript('validator'); |
|
| 80 | 80 | |
| 81 | - // communicate validation status to the client side |
|
| 82 | - $value = $this->_isvalid===false ? '0' : '1'; |
|
| 83 | - $cs->registerHiddenField($this->getClientID().'_1',$value); |
|
| 81 | + // communicate validation status to the client side |
|
| 82 | + $value = $this->_isvalid===false ? '0' : '1'; |
|
| 83 | + $cs->registerHiddenField($this->getClientID().'_1',$value); |
|
| 84 | 84 | |
| 85 | - // update validator display |
|
| 86 | - if ($control = $this->getValidationTarget()) |
|
| 87 | - { |
|
| 88 | - $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
| 85 | + // update validator display |
|
| 86 | + if ($control = $this->getValidationTarget()) |
|
| 87 | + { |
|
| 88 | + $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
| 89 | 89 | |
| 90 | - $cs->registerEndScript($this->getClientID().'::validate', implode(' ',array( |
|
| 91 | - // this function will be used to update the validator |
|
| 92 | - 'function '.$fn.'(valid)', |
|
| 93 | - '{', |
|
| 94 | - ' jQuery('.TJavaScript::quoteString('#'.$this->getClientID().'_1').').val(valid);', |
|
| 95 | - ' Prado.Validation.validateControl('.TJavaScript::quoteString($control->ClientID).'); ', |
|
| 96 | - '}', |
|
| 97 | - '', |
|
| 98 | - // update the validator to the result if we're in a callback |
|
| 99 | - // (if we're in initial rendering or a postback then the result will be rendered directly to the page html anyway) |
|
| 100 | - $this->Page->IsCallback ? $fn.'('.$value.');' : '', |
|
| 101 | - '', |
|
| 102 | - // install event handler that clears the validation error when user changes the captcha response field |
|
| 103 | - 'jQuery("#'.$control->getClientID().'").on("change", '.TJavaScript::quoteString('#'.$control->getResponseFieldName()).', function() { ', |
|
| 104 | - $fn.'("1");', |
|
| 105 | - '});', |
|
| 106 | - ))); |
|
| 107 | - } |
|
| 108 | - } |
|
| 90 | + $cs->registerEndScript($this->getClientID().'::validate', implode(' ',array( |
|
| 91 | + // this function will be used to update the validator |
|
| 92 | + 'function '.$fn.'(valid)', |
|
| 93 | + '{', |
|
| 94 | + ' jQuery('.TJavaScript::quoteString('#'.$this->getClientID().'_1').').val(valid);', |
|
| 95 | + ' Prado.Validation.validateControl('.TJavaScript::quoteString($control->ClientID).'); ', |
|
| 96 | + '}', |
|
| 97 | + '', |
|
| 98 | + // update the validator to the result if we're in a callback |
|
| 99 | + // (if we're in initial rendering or a postback then the result will be rendered directly to the page html anyway) |
|
| 100 | + $this->Page->IsCallback ? $fn.'('.$value.');' : '', |
|
| 101 | + '', |
|
| 102 | + // install event handler that clears the validation error when user changes the captcha response field |
|
| 103 | + 'jQuery("#'.$control->getClientID().'").on("change", '.TJavaScript::quoteString('#'.$control->getResponseFieldName()).', function() { ', |
|
| 104 | + $fn.'("1");', |
|
| 105 | + '});', |
|
| 106 | + ))); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | } |
| 110 | 110 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | class TReCaptcha2Validator extends TBaseValidator |
| 31 | 31 | { |
| 32 | - protected $_isvalid = null; |
|
| 32 | + protected $_isvalid=null; |
|
| 33 | 33 | |
| 34 | 34 | protected function getClientClassName() |
| 35 | 35 | { |
@@ -41,17 +41,17 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | protected function getCaptchaControl() |
| 43 | 43 | { |
| 44 | - $control = $this->getValidationTarget(); |
|
| 45 | - if (!$control) |
|
| 44 | + $control=$this->getValidationTarget(); |
|
| 45 | + if(!$control) |
|
| 46 | 46 | throw new Exception('No target control specified for TReCaptcha2Validator'); |
| 47 | - if (!($control instanceof TReCaptcha2)) |
|
| 47 | + if(!($control instanceof TReCaptcha2)) |
|
| 48 | 48 | throw new Exception('TReCaptcha2Validator only works with TReCaptcha2 controls'); |
| 49 | 49 | return $control; |
| 50 | 50 | } |
| 51 | 51 | public function getClientScriptOptions() |
| 52 | 52 | { |
| 53 | - $options = parent::getClientScriptOptions(); |
|
| 54 | - $options['ResponseFieldName'] = $this->getCaptchaControl()->getResponseFieldName(); |
|
| 53 | + $options=parent::getClientScriptOptions(); |
|
| 54 | + $options['ResponseFieldName']=$this->getCaptchaControl()->getResponseFieldName(); |
|
| 55 | 55 | return $options; |
| 56 | 56 | } |
| 57 | 57 | /** |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | protected function evaluateIsValid() |
| 65 | 65 | { |
| 66 | 66 | // check validity only once (if trying to evaulate multiple times, all redundant checks would fail) |
| 67 | - if (is_null($this->_isvalid)) |
|
| 67 | + if(is_null($this->_isvalid)) |
|
| 68 | 68 | { |
| 69 | - $control = $this->getCaptchaControl(); |
|
| 70 | - $this->_isvalid = $control->validate(); |
|
| 69 | + $control=$this->getCaptchaControl(); |
|
| 70 | + $this->_isvalid=$control->validate(); |
|
| 71 | 71 | } |
| 72 | 72 | return ($this->_isvalid==true); |
| 73 | 73 | } |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | parent::onPreRender($param); |
| 77 | 77 | |
| 78 | - $cs = $this->Page->getClientScript(); |
|
| 78 | + $cs=$this->Page->getClientScript(); |
|
| 79 | 79 | $cs->registerPradoScript('validator'); |
| 80 | 80 | |
| 81 | 81 | // communicate validation status to the client side |
| 82 | - $value = $this->_isvalid===false ? '0' : '1'; |
|
| 83 | - $cs->registerHiddenField($this->getClientID().'_1',$value); |
|
| 82 | + $value=$this->_isvalid===false ? '0' : '1'; |
|
| 83 | + $cs->registerHiddenField($this->getClientID().'_1', $value); |
|
| 84 | 84 | |
| 85 | 85 | // update validator display |
| 86 | - if ($control = $this->getValidationTarget()) |
|
| 86 | + if($control=$this->getValidationTarget()) |
|
| 87 | 87 | { |
| 88 | - $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
| 88 | + $fn='captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
| 89 | 89 | |
| 90 | - $cs->registerEndScript($this->getClientID().'::validate', implode(' ',array( |
|
| 90 | + $cs->registerEndScript($this->getClientID().'::validate', implode(' ', array( |
|
| 91 | 91 | // this function will be used to update the validator |
| 92 | 92 | 'function '.$fn.'(valid)', |
| 93 | 93 | '{', |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function getMediaType() |
| 84 | 84 | { |
| 85 | - return $this->getViewState('MediaType',''); |
|
| 85 | + return $this->getViewState('MediaType', ''); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function setMediaType($value) |
| 92 | 92 | { |
| 93 | - $this->setViewState('MediaType',$value,''); |
|
| 93 | + $this->setViewState('MediaType', $value, ''); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -100,17 +100,17 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function onPreRender($param) |
| 102 | 102 | { |
| 103 | - $cs = $this->getPage()->getClientScript(); |
|
| 103 | + $cs=$this->getPage()->getClientScript(); |
|
| 104 | 104 | |
| 105 | - $styles = preg_split('/,|\s+/', $this->getPradoStyles()); |
|
| 105 | + $styles=preg_split('/,|\s+/', $this->getPradoStyles()); |
|
| 106 | 106 | foreach($styles as $style) |
| 107 | 107 | { |
| 108 | - if(($style = trim($style))!=='') |
|
| 108 | + if(($style=trim($style))!=='') |
|
| 109 | 109 | $cs->registerPradoStyle($style); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | if(($url=$this->getStyleSheetUrl())!=='') |
| 113 | - $cs->registerStyleSheetFile($url,$url,$this->getMediaType()); |
|
| 113 | + $cs->registerStyleSheetFile($url, $url, $this->getMediaType()); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | */ |
| 74 | 74 | public function __construct($style=null) |
| 75 | 75 | { |
| 76 | - parent::__construct(); |
|
| 76 | + parent::__construct(); |
|
| 77 | 77 | if($style!==null) |
| 78 | 78 | $this->copyFrom($style); |
| 79 | 79 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | - * @return TDisplayStyle display style |
|
| 231 | + * @return string display style |
|
| 232 | 232 | */ |
| 233 | 233 | public function getDisplayStyle() |
| 234 | 234 | { |
@@ -285,6 +285,7 @@ discard block |
||
| 285 | 285 | * Sets custom style fields from a string. |
| 286 | 286 | * Custom style fields will be overwritten by style fields explicitly defined. |
| 287 | 287 | * @param string the custom style of the control |
| 288 | + * @param string $value |
|
| 288 | 289 | */ |
| 289 | 290 | public function setCustomStyle($value) |
| 290 | 291 | { |
@@ -304,6 +305,8 @@ discard block |
||
| 304 | 305 | * Style fields set by this method will overwrite those set by {@link setCustomStyle}. |
| 305 | 306 | * @param string style field name |
| 306 | 307 | * @param string style field value |
| 308 | + * @param string $name |
|
| 309 | + * @param string $value |
|
| 307 | 310 | */ |
| 308 | 311 | public function setStyleField($name,$value) |
| 309 | 312 | { |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | protected function _getZappableSleepProps(&$exprops) |
| 54 | 54 | { |
| 55 | 55 | parent::_getZappableSleepProps($exprops); |
| 56 | - if ($this->_fields===array()) |
|
| 57 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_fields"; |
|
| 56 | + if($this->_fields===array()) |
|
| 57 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_fields"; |
|
| 58 | 58 | if($this->_font===null) |
| 59 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_font"; |
|
| 59 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_font"; |
|
| 60 | 60 | if($this->_class===null) |
| 61 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_class"; |
|
| 62 | - if ($this->_customStyle===null) |
|
| 63 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_customStyle"; |
|
| 64 | - if ($this->_displayStyle==='Fixed') |
|
| 65 | - $exprops[] = "\0Prado\Web\UI\WebControls\TStyle\0_displayStyle"; |
|
| 61 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_class"; |
|
| 62 | + if($this->_customStyle===null) |
|
| 63 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_customStyle"; |
|
| 64 | + if($this->_displayStyle==='Fixed') |
|
| 65 | + $exprops[]="\0Prado\Web\UI\WebControls\TStyle\0_displayStyle"; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public function __clone() |
| 83 | 83 | { |
| 84 | 84 | if($this->_font!==null) |
| 85 | - $this->_font = clone($this->_font); |
|
| 85 | + $this->_font=clone($this->_font); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function getBackColor() |
| 92 | 92 | { |
| 93 | - return isset($this->_fields['background-color'])?$this->_fields['background-color']:''; |
|
| 93 | + return isset($this->_fields['background-color']) ? $this->_fields['background-color'] : ''; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function getBorderColor() |
| 111 | 111 | { |
| 112 | - return isset($this->_fields['border-color'])?$this->_fields['border-color']:''; |
|
| 112 | + return isset($this->_fields['border-color']) ? $this->_fields['border-color'] : ''; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function getBorderStyle() |
| 130 | 130 | { |
| 131 | - return isset($this->_fields['border-style'])?$this->_fields['border-style']:''; |
|
| 131 | + return isset($this->_fields['border-style']) ? $this->_fields['border-style'] : ''; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function getBorderWidth() |
| 150 | 150 | { |
| 151 | - return isset($this->_fields['border-width'])?$this->_fields['border-width']:''; |
|
| 151 | + return isset($this->_fields['border-width']) ? $this->_fields['border-width'] : ''; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | public function getCssClass() |
| 169 | 169 | { |
| 170 | - return $this->_class===null?'':$this->_class; |
|
| 170 | + return $this->_class===null ? '' : $this->_class; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function hasFont() |
| 203 | 203 | { |
| 204 | - return $this->_font !== null; |
|
| 204 | + return $this->_font!==null; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -209,20 +209,20 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function setDisplayStyle($value) |
| 211 | 211 | { |
| 212 | - $this->_displayStyle = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDisplayStyle'); |
|
| 212 | + $this->_displayStyle=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDisplayStyle'); |
|
| 213 | 213 | switch($this->_displayStyle) |
| 214 | 214 | { |
| 215 | 215 | case TDisplayStyle::None: |
| 216 | - $this->_fields['display'] = 'none'; |
|
| 216 | + $this->_fields['display']='none'; |
|
| 217 | 217 | break; |
| 218 | 218 | case TDisplayStyle::Dynamic: |
| 219 | - $this->_fields['display'] = ''; //remove the display property |
|
| 219 | + $this->_fields['display']=''; //remove the display property |
|
| 220 | 220 | break; |
| 221 | 221 | case TDisplayStyle::Fixed: |
| 222 | - $this->_fields['visibility'] = 'visible'; |
|
| 222 | + $this->_fields['visibility']='visible'; |
|
| 223 | 223 | break; |
| 224 | 224 | case TDisplayStyle::Hidden: |
| 225 | - $this->_fields['visibility'] = 'hidden'; |
|
| 225 | + $this->_fields['visibility']='hidden'; |
|
| 226 | 226 | break; |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function getForeColor() |
| 242 | 242 | { |
| 243 | - return isset($this->_fields['color'])?$this->_fields['color']:''; |
|
| 243 | + return isset($this->_fields['color']) ? $this->_fields['color'] : ''; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public function getHeight() |
| 261 | 261 | { |
| 262 | - return isset($this->_fields['height'])?$this->_fields['height']:''; |
|
| 262 | + return isset($this->_fields['height']) ? $this->_fields['height'] : ''; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function getCustomStyle() |
| 280 | 280 | { |
| 281 | - return $this->_customStyle===null?'':$this->_customStyle; |
|
| 281 | + return $this->_customStyle===null ? '' : $this->_customStyle; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | public function getStyleField($name) |
| 298 | 298 | { |
| 299 | - return isset($this->_fields[$name])?$this->_fields[$name]:''; |
|
| 299 | + return isset($this->_fields[$name]) ? $this->_fields[$name] : ''; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * @param string style field name |
| 306 | 306 | * @param string style field value |
| 307 | 307 | */ |
| 308 | - public function setStyleField($name,$value) |
|
| 308 | + public function setStyleField($name, $value) |
|
| 309 | 309 | { |
| 310 | 310 | $this->_fields[$name]=$value; |
| 311 | 311 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | public function getWidth() |
| 334 | 334 | { |
| 335 | - return isset($this->_fields['width'])?$this->_fields['width']:''; |
|
| 335 | + return isset($this->_fields['width']) ? $this->_fields['width'] : ''; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | { |
| 365 | 365 | if($style instanceof TStyle) |
| 366 | 366 | { |
| 367 | - $this->_fields=array_merge($this->_fields,$style->_fields); |
|
| 367 | + $this->_fields=array_merge($this->_fields, $style->_fields); |
|
| 368 | 368 | if($style->_class!==null) |
| 369 | 369 | $this->_class=$style->_class; |
| 370 | 370 | if($style->_customStyle!==null) |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | { |
| 385 | 385 | if($style instanceof TStyle) |
| 386 | 386 | { |
| 387 | - $this->_fields=array_merge($style->_fields,$this->_fields); |
|
| 387 | + $this->_fields=array_merge($style->_fields, $this->_fields); |
|
| 388 | 388 | if($this->_class===null) |
| 389 | 389 | $this->_class=$style->_class; |
| 390 | 390 | if($this->_customStyle===null) |
@@ -402,18 +402,18 @@ discard block |
||
| 402 | 402 | { |
| 403 | 403 | if($this->_customStyle!==null) |
| 404 | 404 | { |
| 405 | - foreach(explode(';',$this->_customStyle) as $style) |
|
| 405 | + foreach(explode(';', $this->_customStyle) as $style) |
|
| 406 | 406 | { |
| 407 | - $arr=explode(':',$style,2); |
|
| 407 | + $arr=explode(':', $style, 2); |
|
| 408 | 408 | if(isset($arr[1]) && trim($arr[0])!=='') |
| 409 | - $writer->addStyleAttribute(trim($arr[0]),trim($arr[1])); |
|
| 409 | + $writer->addStyleAttribute(trim($arr[0]), trim($arr[1])); |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | $writer->addStyleAttributes($this->_fields); |
| 413 | 413 | if($this->_font!==null) |
| 414 | 414 | $this->_font->addAttributesToRender($writer); |
| 415 | 415 | if($this->_class!==null) |
| 416 | - $writer->addAttribute('class',$this->_class); |
|
| 416 | + $writer->addAttribute('class', $this->_class); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * @param string a key identifying a value to be cached |
| 112 | - * @return sring a key generated from the provided key which ensures the uniqueness across applications |
|
| 112 | + * @return string a key generated from the provided key which ensures the uniqueness across applications |
|
| 113 | 113 | */ |
| 114 | 114 | protected function generateUniqueKey($key) |
| 115 | 115 | { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @param mixed the value to be cached |
| 144 | 144 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 145 | 145 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid. |
| 146 | - * @return boolean true if the value is successfully stored into cache, false otherwise |
|
| 146 | + * @return null|boolean true if the value is successfully stored into cache, false otherwise |
|
| 147 | 147 | */ |
| 148 | 148 | public function set($id,$value,$expire=0,$dependency=null) |
| 149 | 149 | { |
@@ -201,6 +201,7 @@ discard block |
||
| 201 | 201 | * in {@link get()} already. So only the implementation of data retrieval |
| 202 | 202 | * is needed. |
| 203 | 203 | * @param string a unique key identifying the cached value |
| 204 | + * @param string $key |
|
| 204 | 205 | * @return string the value stored in cache, false if the value is not in the cache or expired. |
| 205 | 206 | */ |
| 206 | 207 | abstract protected function getValue($key); |
@@ -215,6 +216,8 @@ discard block |
||
| 215 | 216 | * @param string the key identifying the value to be cached |
| 216 | 217 | * @param string the value to be cached |
| 217 | 218 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 219 | + * @param string $key |
|
| 220 | + * @param integer $expire |
|
| 218 | 221 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 219 | 222 | */ |
| 220 | 223 | abstract protected function setValue($key,$value,$expire); |
@@ -229,6 +232,8 @@ discard block |
||
| 229 | 232 | * @param string the key identifying the value to be cached |
| 230 | 233 | * @param string the value to be cached |
| 231 | 234 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 235 | + * @param string $key |
|
| 236 | + * @param integer $expire |
|
| 232 | 237 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 233 | 238 | */ |
| 234 | 239 | abstract protected function addValue($key,$value,$expire); |
@@ -237,6 +242,7 @@ discard block |
||
| 237 | 242 | * Deletes a value with the specified key from cache |
| 238 | 243 | * This method should be implemented by child classes to delete the data from actual cache storage. |
| 239 | 244 | * @param string the key of the value to be deleted |
| 245 | + * @param string $key |
|
| 240 | 246 | * @return boolean if no error happens during deletion |
| 241 | 247 | */ |
| 242 | 248 | abstract protected function deleteValue($key); |
@@ -280,7 +286,7 @@ discard block |
||
| 280 | 286 | * Deletes the value with the specified key from cache |
| 281 | 287 | * This method is required by the interface \ArrayAccess. |
| 282 | 288 | * @param string the key of the value to be deleted |
| 283 | - * @return boolean if no error happens during deletion |
|
| 289 | + * @return boolean|null if no error happens during deletion |
|
| 284 | 290 | */ |
| 285 | 291 | public function offsetUnset($id) |
| 286 | 292 | { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | if($this->getApplication()->getCache()===null) |
| 68 | 68 | $this->getApplication()->setCache($this); |
| 69 | 69 | else |
| 70 | - throw new TConfigurationException('cache_primary_duplicated',get_class($this)); |
|
| 70 | + throw new TConfigurationException('cache_primary_duplicated', get_class($this)); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid. |
| 146 | 146 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 147 | 147 | */ |
| 148 | - public function set($id,$value,$expire=0,$dependency=null) |
|
| 148 | + public function set($id, $value, $expire=0, $dependency=null) |
|
| 149 | 149 | { |
| 150 | - if(empty($value) && $expire === 0) |
|
| 150 | + if(empty($value) && $expire===0) |
|
| 151 | 151 | $this->delete($id); |
| 152 | 152 | else |
| 153 | 153 | { |
| 154 | - $data=array($value,$dependency); |
|
| 155 | - return $this->setValue($this->generateUniqueKey($id),$data,$expire); |
|
| 154 | + $data=array($value, $dependency); |
|
| 155 | + return $this->setValue($this->generateUniqueKey($id), $data, $expire); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid. |
| 166 | 166 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 167 | 167 | */ |
| 168 | - public function add($id,$value,$expire=0,$dependency=null) |
|
| 168 | + public function add($id, $value, $expire=0, $dependency=null) |
|
| 169 | 169 | { |
| 170 | - if(empty($value) && $expire === 0) |
|
| 170 | + if(empty($value) && $expire===0) |
|
| 171 | 171 | return false; |
| 172 | - $data=array($value,$dependency); |
|
| 173 | - return $this->addValue($this->generateUniqueKey($id),$data,$expire); |
|
| 172 | + $data=array($value, $dependency); |
|
| 173 | + return $this->addValue($this->generateUniqueKey($id), $data, $expire); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 218 | 218 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 219 | 219 | */ |
| 220 | - abstract protected function setValue($key,$value,$expire); |
|
| 220 | + abstract protected function setValue($key, $value, $expire); |
|
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | 223 | * Stores a value identified by a key into cache if the cache does not contain this key. |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
| 232 | 232 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 233 | 233 | */ |
| 234 | - abstract protected function addValue($key,$value,$expire); |
|
| 234 | + abstract protected function addValue($key, $value, $expire); |
|
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * Deletes a value with the specified key from cache |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function offsetExists($id) |
| 251 | 251 | { |
| 252 | - return $this->get($id) !== false; |
|
| 252 | + return $this->get($id)!==false; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -123,6 +123,7 @@ discard block |
||
| 123 | 123 | * By default, it always returns true, meaning the file should be checked. |
| 124 | 124 | * You may override this method to check only certain files. |
| 125 | 125 | * @param string the name of the file that may be checked for dependency. |
| 126 | + * @param string $fileName |
|
| 126 | 127 | * @return boolean whether this file should be checked. |
| 127 | 128 | */ |
| 128 | 129 | protected function validateFile($fileName) |
@@ -136,6 +137,7 @@ discard block |
||
| 136 | 137 | * By default, it always returns true, meaning the subdirectory should be checked. |
| 137 | 138 | * You may override this method to check only certain subdirectories. |
| 138 | 139 | * @param string the name of the subdirectory that may be checked for dependency. |
| 140 | + * @param string $directory |
|
| 139 | 141 | * @return boolean whether this subdirectory should be checked. |
| 140 | 142 | */ |
| 141 | 143 | protected function validateDirectory($directory) |
@@ -149,6 +151,7 @@ discard block |
||
| 149 | 151 | * {@link setRecursiveCheck RecursiveCheck} is set true. |
| 150 | 152 | * @param string the directory name |
| 151 | 153 | * @param int level of the recursion |
| 154 | + * @param string $directory |
|
| 152 | 155 | * @return array list of file modification time indexed by the file path |
| 153 | 156 | */ |
| 154 | 157 | protected function generateTimestamps($directory,$level=0) |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function setDirectory($directory) |
| 64 | 64 | { |
| 65 | 65 | if(($path=realpath($directory))===false || !is_dir($path)) |
| 66 | - throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory); |
|
| 66 | + throw new TInvalidDataValueException('directorycachedependency_directory_invalid', $directory); |
|
| 67 | 67 | $this->_directory=$path; |
| 68 | 68 | $this->_timestamps=$this->generateTimestamps($path); |
| 69 | 69 | } |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | * @param int level of the recursion |
| 152 | 152 | * @return array list of file modification time indexed by the file path |
| 153 | 153 | */ |
| 154 | - protected function generateTimestamps($directory,$level=0) |
|
| 154 | + protected function generateTimestamps($directory, $level=0) |
|
| 155 | 155 | { |
| 156 | 156 | if(($dir=opendir($directory))===false) |
| 157 | - throw new TIOException('directorycachedependency_directory_invalid',$directory); |
|
| 157 | + throw new TIOException('directorycachedependency_directory_invalid', $directory); |
|
| 158 | 158 | $timestamps=array(); |
| 159 | 159 | while(($file=readdir($dir))!==false) |
| 160 | 160 | { |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | continue; |
| 164 | 164 | else if(is_dir($path)) |
| 165 | 165 | { |
| 166 | - if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) |
|
| 167 | - $timestamps=array_merge($this->generateTimestamps($path,$level+1)); |
|
| 166 | + if(($this->_recursiveLevel < 0 || $level < $this->_recursiveLevel) && $this->validateDirectory($path)) |
|
| 167 | + $timestamps=array_merge($this->generateTimestamps($path, $level + 1)); |
|
| 168 | 168 | } |
| 169 | 169 | else if($this->validateFile($path)) |
| 170 | 170 | $timestamps[$path]=filemtime($path); |
@@ -532,8 +532,7 @@ |
||
| 532 | 532 | { |
| 533 | 533 | if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) |
| 534 | 534 | $timestamps=array_merge($this->generateTimestamps($path,$level+1)); |
| 535 | - } |
|
| 536 | - else if($this->validateFile($path)) |
|
| 535 | + } else if($this->validateFile($path)) |
|
| 537 | 536 | $timestamps[$path]=filemtime($path); |
| 538 | 537 | } |
| 539 | 538 | closedir($dir); |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * @return Iterator iterator |
|
| 51 | + * @return TDummyDataSourceIterator iterator |
|
| 52 | 52 | */ |
| 53 | 53 | public function getIterator() |
| 54 | 54 | { |
@@ -68,6 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @param mixed original data source |
| 71 | + * @param \Traversable $value |
|
| 71 | 72 | */ |
| 72 | 73 | public function setDataSource($value) |
| 73 | 74 | { |
@@ -93,6 +94,7 @@ discard block |
||
| 93 | 94 | |
| 94 | 95 | /** |
| 95 | 96 | * @param integer number of items in each page |
| 97 | + * @param integer $value |
|
| 96 | 98 | */ |
| 97 | 99 | public function setPageSize($value) |
| 98 | 100 | { |
@@ -112,6 +114,7 @@ discard block |
||
| 112 | 114 | |
| 113 | 115 | /** |
| 114 | 116 | * @param integer current page index |
| 117 | + * @param integer $value |
|
| 115 | 118 | */ |
| 116 | 119 | public function setCurrentPageIndex($value) |
| 117 | 120 | { |
@@ -130,6 +133,7 @@ discard block |
||
| 130 | 133 | |
| 131 | 134 | /** |
| 132 | 135 | * @param boolean whether to allow paging |
| 136 | + * @param boolean $value |
|
| 133 | 137 | */ |
| 134 | 138 | public function setAllowPaging($value) |
| 135 | 139 | { |
@@ -146,6 +150,7 @@ discard block |
||
| 146 | 150 | |
| 147 | 151 | /** |
| 148 | 152 | * @param boolean whether to allow custom paging |
| 153 | + * @param boolean $value |
|
| 149 | 154 | */ |
| 150 | 155 | public function setAllowCustomPaging($value) |
| 151 | 156 | { |
@@ -162,6 +167,7 @@ discard block |
||
| 162 | 167 | |
| 163 | 168 | /** |
| 164 | 169 | * @param integer user-assigned number of items in data source |
| 170 | + * @param integer $value |
|
| 165 | 171 | */ |
| 166 | 172 | public function setVirtualItemCount($value) |
| 167 | 173 | { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function setPageSize($value) |
| 98 | 98 | { |
| 99 | - if(($value=TPropertyValue::ensureInteger($value))>0) |
|
| 99 | + if(($value=TPropertyValue::ensureInteger($value)) > 0) |
|
| 100 | 100 | $this->_pageSize=$value; |
| 101 | 101 | else |
| 102 | 102 | throw new TInvalidDataValueException('pageddatasource_pagesize_invalid'); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function setCurrentPageIndex($value) |
| 117 | 117 | { |
| 118 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
| 118 | + if(($value=TPropertyValue::ensureInteger($value)) < 0) |
|
| 119 | 119 | $value=0; |
| 120 | 120 | $this->_currentPageIndex=$value; |
| 121 | 121 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | public function setVirtualItemCount($value) |
| 167 | 167 | { |
| 168 | - if(($value=TPropertyValue::ensureInteger($value))>=0) |
|
| 168 | + if(($value=TPropertyValue::ensureInteger($value)) >= 0) |
|
| 169 | 169 | $this->_virtualCount=$value; |
| 170 | 170 | else |
| 171 | 171 | throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid'); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | if(!$this->_allowPaging) |
| 182 | 182 | return $this->getDataSourceCount(); |
| 183 | 183 | if(!$this->_allowCustomPaging && $this->getIsLastPage()) |
| 184 | - return $this->getDataSourceCount()-$this->getFirstIndexInPage(); |
|
| 184 | + return $this->getDataSourceCount() - $this->getFirstIndexInPage(); |
|
| 185 | 185 | return $this->_pageSize; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | if($this->_dataSource===null) |
| 204 | 204 | return 0; |
| 205 | 205 | $count=$this->getDataSourceCount(); |
| 206 | - if(!$this->_allowPaging || $count<=0) |
|
| 206 | + if(!$this->_allowPaging || $count <= 0) |
|
| 207 | 207 | return 1; |
| 208 | - return (int)(($count+$this->_pageSize-1)/$this->_pageSize); |
|
| 208 | + return (int) (($count + $this->_pageSize - 1) / $this->_pageSize); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | public function getIsLastPage() |
| 226 | 226 | { |
| 227 | 227 | if($this->_allowPaging) |
| 228 | - return $this->_currentPageIndex===$this->getPageCount()-1; |
|
| 228 | + return $this->_currentPageIndex===$this->getPageCount() - 1; |
|
| 229 | 229 | else |
| 230 | 230 | return true; |
| 231 | 231 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | public function getFirstIndexInPage() |
| 238 | 238 | { |
| 239 | 239 | if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging) |
| 240 | - return $this->_currentPageIndex*$this->_pageSize; |
|
| 240 | + return $this->_currentPageIndex * $this->_pageSize; |
|
| 241 | 241 | else |
| 242 | 242 | return 0; |
| 243 | 243 | } |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | public function getIterator() |
| 262 | 262 | { |
| 263 | 263 | if($this->_dataSource instanceof TList) |
| 264 | - return new TPagedListIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount()); |
|
| 264 | + return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount()); |
|
| 265 | 265 | else if($this->_dataSource instanceof TMap) |
| 266 | - return new TPagedMapIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount()); |
|
| 266 | + return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount()); |
|
| 267 | 267 | else |
| 268 | 268 | return null; |
| 269 | 269 | } |