@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * o 'True' or 'Revert' : The draggable will revert to it's original position |
| 54 | 54 | * o 'False' or 'None' : The draggable won't revert to it's original position |
| 55 | 55 | * o 'Failure' : The draggable will only revert if it's dropped on a non droppable area |
| 56 | - * @return TDraggableRevertOption true to revert |
|
| 56 | + * @return string true to revert |
|
| 57 | 57 | */ |
| 58 | 58 | public function getRevert() |
| 59 | 59 | { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Determine if the element should be constrainted in one direction or not |
| 121 | - * @return CDraggableConstraint |
|
| 121 | + * @return string |
|
| 122 | 122 | */ |
| 123 | 123 | public function getConstraint() |
| 124 | 124 | { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * Set the handle id or css class |
| 33 | 33 | * @param string |
| 34 | 34 | */ |
| 35 | - public function setHandle ($value) |
|
| 35 | + public function setHandle($value) |
|
| 36 | 36 | { |
| 37 | 37 | $this->setViewState('DragHandle', TPropertyValue::ensureString($value), null); |
| 38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * Get the handle id or css class |
| 42 | 42 | * @return string |
| 43 | 43 | */ |
| 44 | - public function getHandle () |
|
| 44 | + public function getHandle() |
|
| 45 | 45 | { |
| 46 | 46 | return $this->getViewState('DragHandle', null); |
| 47 | 47 | } |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function setRevert($value) |
| 73 | 73 | { |
| 74 | - if (strcasecmp($value,'true')==0 || $value===true) |
|
| 74 | + if(strcasecmp($value, 'true')==0 || $value===true) |
|
| 75 | 75 | $value=TDraggableRevertOptions::Revert; |
| 76 | - elseif (strcasecmp($value,'false')==0 || $value===false) |
|
| 76 | + elseif(strcasecmp($value, 'false')==0 || $value===false) |
|
| 77 | 77 | $value=TDraggableRevertOptions::None; |
| 78 | 78 | $this->setViewState('Revert', TPropertyValue::ensureEnum($value, 'TDraggableRevertOptions'), true); |
| 79 | 79 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return TDraggableGhostingOption to clone the element |
| 92 | 92 | */ |
| 93 | - public function getGhosting () |
|
| 93 | + public function getGhosting() |
|
| 94 | 94 | { |
| 95 | 95 | return $this->getViewState('Ghosting', TDraggableGhostingOptions::None); |
| 96 | 96 | } |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | * o "False" or "None" means no Ghosting options |
| 108 | 108 | * |
| 109 | 109 | */ |
| 110 | - public function setGhosting ($value) |
|
| 110 | + public function setGhosting($value) |
|
| 111 | 111 | { |
| 112 | - if (strcasecmp($value,'true')==0 || $value===true) |
|
| 112 | + if(strcasecmp($value, 'true')==0 || $value===true) |
|
| 113 | 113 | $value=TDraggableGhostingOptions::Ghosting; |
| 114 | - elseif (strcasecmp($value,'false')==0 || $value===false) |
|
| 114 | + elseif(strcasecmp($value, 'false')==0 || $value===false) |
|
| 115 | 115 | $value=TDraggableGhostingOptions::None; |
| 116 | 116 | $this->setViewState('Ghosting', TPropertyValue::ensureEnum($value, 'TDraggableGhostingOptions'), TDraggableGhostingOptions::None); |
| 117 | 117 | } |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | parent::addAttributesToRender($writer); |
| 155 | 155 | |
| 156 | 156 | $cs=$this->getPage()->getClientScript(); |
| 157 | - if ($this->getGhosting()==TDraggableGhostingOptions::SuperGhosting) |
|
| 157 | + if($this->getGhosting()==TDraggableGhostingOptions::SuperGhosting) |
|
| 158 | 158 | $cs->registerPradoScript('dragdropextra'); |
| 159 | 159 | else |
| 160 | 160 | $cs->registerPradoScript('dragdrop'); |
| 161 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 161 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 162 | 162 | $options=TJavascript::encode($this->getPostBackOptions()); |
| 163 | 163 | $class=$this->getClientClassName(); |
| 164 | 164 | $code="new {$class}('{$this->getClientId()}', {$options}) "; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * This method overrides the parent implementation. |
| 171 | 171 | * @return string the javascript class name |
| 172 | 172 | */ |
| 173 | - protected function getClientClassName () |
|
| 173 | + protected function getClientClassName() |
|
| 174 | 174 | { |
| 175 | 175 | return 'Draggable'; |
| 176 | 176 | } |
@@ -181,17 +181,17 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | protected function getPostBackOptions() |
| 183 | 183 | { |
| 184 | - $options['ID'] = $this->getClientID(); |
|
| 184 | + $options['ID']=$this->getClientID(); |
|
| 185 | 185 | |
| 186 | - if (($handle=$this->getHandle())!== null) $options['handle']=$handle; |
|
| 187 | - if (($revert=$this->getRevert())===TDraggableRevertOptions::None) |
|
| 186 | + if(($handle=$this->getHandle())!==null) $options['handle']=$handle; |
|
| 187 | + if(($revert=$this->getRevert())===TDraggableRevertOptions::None) |
|
| 188 | 188 | $options['revert']=false; |
| 189 | - elseif ($revert==TDraggableRevertOptions::Revert) |
|
| 189 | + elseif($revert==TDraggableRevertOptions::Revert) |
|
| 190 | 190 | $options['revert']=true; |
| 191 | 191 | else |
| 192 | 192 | $options['revert']=strtolower($revert); |
| 193 | - if (($constraint=$this->getConstraint())!==TDraggableConstraint::None) $options['constraint']=strtolower($constraint); |
|
| 194 | - switch ($this->getGhosting()) |
|
| 193 | + if(($constraint=$this->getConstraint())!==TDraggableConstraint::None) $options['constraint']=strtolower($constraint); |
|
| 194 | + switch($this->getGhosting()) |
|
| 195 | 195 | { |
| 196 | 196 | case TDraggableGhostingOptions::SuperGhosting: |
| 197 | 197 | $options['superghosting']=true; |
@@ -127,7 +127,6 @@ |
||
| 127 | 127 | * Raises the onDrop event. |
| 128 | 128 | * The drop parameters are encapsulated into a {@link TDropContainerEventParameter} |
| 129 | 129 | * |
| 130 | - * @param object $dropControlId |
|
| 131 | 130 | */ |
| 132 | 131 | public function onDrop ($dropParams) |
| 133 | 132 | { |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if ($this->sourcepath === NULL) |
| 59 | 59 | { |
| 60 | 60 | $this->sourcepath = $sourcepath; |
| 61 | - } |
|
| 62 | - else |
|
| 61 | + } else |
|
| 63 | 62 | { |
| 64 | 63 | $this->sourcepath->append($sourcepath); |
| 65 | 64 | } |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @param object $dropControlId |
| 139 | 139 | */ |
| 140 | - public function onDrop ($dropParams) |
|
| 140 | + public function onDrop($dropParams) |
|
| 141 | 141 | { |
| 142 | - $this->raiseEvent('OnDrop', $this, new TDropContainerEventParameter ($dropParams)); |
|
| 142 | + $this->raiseEvent('OnDrop', $this, new TDropContainerEventParameter($dropParams)); |
|
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | protected function getPostBackOptions() |
| 163 | 163 | { |
| 164 | - $options['ID'] = $this->getClientID(); |
|
| 165 | - $options['EventTarget'] = $this->getUniqueID(); |
|
| 164 | + $options['ID']=$this->getClientID(); |
|
| 165 | + $options['EventTarget']=$this->getUniqueID(); |
|
| 166 | 166 | |
| 167 | - $options['accept'] = $this->getAcceptCssClass(); |
|
| 168 | - $options['hoverclass'] = $this->getHoverCssClass(); |
|
| 167 | + $options['accept']=$this->getAcceptCssClass(); |
|
| 168 | + $options['hoverclass']=$this->getHoverCssClass(); |
|
| 169 | 169 | return $options; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | protected function addAttributesToRender($writer) |
| 198 | 198 | { |
| 199 | 199 | parent::addAttributesToRender($writer); |
| 200 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 200 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 201 | 201 | |
| 202 | 202 | $this->getPage()->getClientScript()->registerPradoScript('dragdrop'); |
| 203 | 203 | $this->getActiveControl()->registerCallbackClientScript( |
@@ -210,9 +210,9 @@ discard block |
||
| 210 | 210 | * child controls. This container will be a TActivePanel, in order to allow user |
| 211 | 211 | * to update its content on callback. |
| 212 | 212 | */ |
| 213 | - public function createChildControls () |
|
| 213 | + public function createChildControls() |
|
| 214 | 214 | { |
| 215 | - if ($this->_container===null) |
|
| 215 | + if($this->_container===null) |
|
| 216 | 216 | { |
| 217 | 217 | $this->_container=Prado::CreateComponent('System.Web.UI.ActiveControls.TActivePanel'); |
| 218 | 218 | $this->_container->setId($this->getId(false).'_content'); |
@@ -238,17 +238,17 @@ discard block |
||
| 238 | 238 | * is defered until OnPreRender event is raised. |
| 239 | 239 | * @param THtmlWriter html writer |
| 240 | 240 | */ |
| 241 | - public function render ($writer) |
|
| 241 | + public function render($writer) |
|
| 242 | 242 | { |
| 243 | 243 | if($this->getHasPreRendered()) |
| 244 | 244 | { |
| 245 | 245 | parent::render($writer); |
| 246 | 246 | if($this->getActiveControl()->canUpdateClientSide()) |
| 247 | - $this->getPage()->getCallbackClient()->replaceContent($this->_container,$writer); |
|
| 247 | + $this->getPage()->getCallbackClient()->replaceContent($this->_container, $writer); |
|
| 248 | 248 | } |
| 249 | 249 | else |
| 250 | 250 | { |
| 251 | - $this->getPage()->getAdapter()->registerControlToRender($this->_container,$writer); |
|
| 251 | + $this->getPage()->getAdapter()->registerControlToRender($this->_container, $writer); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | } |
@@ -92,6 +92,8 @@ discard block |
||
| 92 | 92 | * Calls the client-side static method for this control class. |
| 93 | 93 | * @param string static method name |
| 94 | 94 | * @param mixed method parmaeter |
| 95 | + * @param string $func |
|
| 96 | + * @param boolean $value |
|
| 95 | 97 | */ |
| 96 | 98 | protected function callClientFunction($func,$value) |
| 97 | 99 | { |
@@ -239,6 +241,7 @@ discard block |
||
| 239 | 241 | * Raised when editing the content is requsted to be loaded from the |
| 240 | 242 | * server side. |
| 241 | 243 | * @param TCallbackEventParameter event parameter to be passed to the event handlers |
| 244 | + * @param TCallbackEventParameter $param |
|
| 242 | 245 | */ |
| 243 | 246 | public function onLoadingText($param) |
| 244 | 247 | { |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if ($this->sourcepath === NULL) |
| 59 | 59 | { |
| 60 | 60 | $this->sourcepath = $sourcepath; |
| 61 | - } |
|
| 62 | - else |
|
| 61 | + } else |
|
| 63 | 62 | { |
| 64 | 63 | $this->sourcepath->append($sourcepath); |
| 65 | 64 | } |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function setDisplayTextBox($value) |
| 76 | 76 | { |
| 77 | - $value = TPropertyValue::ensureBoolean($value); |
|
| 78 | - $this->setViewState('DisplayTextBox', $value,false); |
|
| 77 | + $value=TPropertyValue::ensureBoolean($value); |
|
| 78 | + $this->setViewState('DisplayTextBox', $value, false); |
|
| 79 | 79 | if($this->getActiveControl()->canUpdateClientSide()) |
| 80 | - $this->callClientFunction('setDisplayTextBox',$value); |
|
| 80 | + $this->callClientFunction('setDisplayTextBox', $value); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | * @param string static method name |
| 94 | 94 | * @param mixed method parmaeter |
| 95 | 95 | */ |
| 96 | - protected function callClientFunction($func,$value) |
|
| 96 | + protected function callClientFunction($func, $value) |
|
| 97 | 97 | { |
| 98 | - $client = $this->getPage()->getCallbackClient(); |
|
| 99 | - $code = $this->getClientClassName().'.'.$func; |
|
| 100 | - $client->callClientFunction($code,array($this,$value)); |
|
| 98 | + $client=$this->getPage()->getCallbackClient(); |
|
| 99 | + $code=$this->getClientClassName().'.'.$func; |
|
| 100 | + $client->callClientFunction($code, array($this, $value)); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function getExternalControlID() |
| 123 | 123 | { |
| 124 | - $extID = $this->getEditTriggerControlID(); |
|
| 124 | + $extID=$this->getEditTriggerControlID(); |
|
| 125 | 125 | if($extID===null) return ''; |
| 126 | - if(($control = $this->findControl($extID))!==null) |
|
| 126 | + if(($control=$this->findControl($extID))!==null) |
|
| 127 | 127 | return $control->getClientID(); |
| 128 | 128 | return $extID; |
| 129 | 129 | } |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function setText($value) |
| 137 | 137 | { |
| 138 | - if(TTextBox::getText() === $value) |
|
| 138 | + if(TTextBox::getText()===$value) |
|
| 139 | 139 | return; |
| 140 | 140 | |
| 141 | 141 | TTextBox::setText($value); |
| 142 | 142 | if($this->getActiveControl()->canUpdateClientSide()) |
| 143 | 143 | { |
| 144 | - $client = $this->getPage()->getCallbackClient(); |
|
| 144 | + $client=$this->getPage()->getCallbackClient(); |
|
| 145 | 145 | $client->update($this->getLabelClientID(), $value); |
| 146 | 146 | $client->setValue($this, $value); |
| 147 | 147 | } |
@@ -152,14 +152,14 @@ discard block |
||
| 152 | 152 | * @param boolean value |
| 153 | 153 | * @since 3.1.2 |
| 154 | 154 | */ |
| 155 | - public function setReadOnly ($value) |
|
| 155 | + public function setReadOnly($value) |
|
| 156 | 156 | { |
| 157 | 157 | $value=TPropertyValue::ensureBoolean($value); |
| 158 | - if(TTextBox::getReadOnly() === $value) |
|
| 158 | + if(TTextBox::getReadOnly()===$value) |
|
| 159 | 159 | return; |
| 160 | 160 | |
| 161 | 161 | TTextBox::setReadOnly($value); |
| 162 | - if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 162 | + if($this->getActiveControl()->canUpdateClientSide()) |
|
| 163 | 163 | { |
| 164 | 164 | $this->callClientFunction('setReadOnly', $value); |
| 165 | 165 | } |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function onCallback($param) |
| 204 | 204 | { |
| 205 | - $action = $param->getCallbackParameter(); |
|
| 206 | - if(is_array($action) && $action[0] === '__InlineEditor_loadExternalText__') |
|
| 205 | + $action=$param->getCallbackParameter(); |
|
| 206 | + if(is_array($action) && $action[0]==='__InlineEditor_loadExternalText__') |
|
| 207 | 207 | { |
| 208 | - $parameter = new TCallbackEventParameter($this->getResponse(), $action[1]); |
|
| 208 | + $parameter=new TCallbackEventParameter($this->getResponse(), $action[1]); |
|
| 209 | 209 | $this->onLoadingText($parameter); |
| 210 | 210 | } |
| 211 | 211 | $this->raiseEvent('OnCallback', $this, $param); |
@@ -216,26 +216,26 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | protected function getPostBackOptions() |
| 218 | 218 | { |
| 219 | - $options = parent::getPostBackOptions(); |
|
| 220 | - $options['ID'] = $this->getLabelClientID(); |
|
| 221 | - $options['TextBoxID'] = $this->getClientID(); |
|
| 222 | - $options['ExternalControl'] = $this->getExternalControlID(); |
|
| 223 | - $options['AutoHide'] = $this->getAutoHideTextBox() == false ? '' : true; |
|
| 224 | - $options['AutoPostBack'] = $this->getAutoPostBack() == false ? '' : true; |
|
| 225 | - $options['Columns'] = $this->getColumns(); |
|
| 219 | + $options=parent::getPostBackOptions(); |
|
| 220 | + $options['ID']=$this->getLabelClientID(); |
|
| 221 | + $options['TextBoxID']=$this->getClientID(); |
|
| 222 | + $options['ExternalControl']=$this->getExternalControlID(); |
|
| 223 | + $options['AutoHide']=$this->getAutoHideTextBox()==false ? '' : true; |
|
| 224 | + $options['AutoPostBack']=$this->getAutoPostBack()==false ? '' : true; |
|
| 225 | + $options['Columns']=$this->getColumns(); |
|
| 226 | 226 | if($this->getTextMode()==='MultiLine') |
| 227 | 227 | { |
| 228 | - $options['Rows'] = $this->getRows(); |
|
| 229 | - $options['Wrap'] = $this->getWrap()== false ? '' : true; |
|
| 228 | + $options['Rows']=$this->getRows(); |
|
| 229 | + $options['Wrap']=$this->getWrap()==false ? '' : true; |
|
| 230 | 230 | } |
| 231 | 231 | else |
| 232 | 232 | { |
| 233 | - $length = $this->getMaxLength(); |
|
| 234 | - $options['MaxLength'] = $length > 0 ? $length : ''; |
|
| 233 | + $length=$this->getMaxLength(); |
|
| 234 | + $options['MaxLength']=$length > 0 ? $length : ''; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | if($this->hasEventHandler('OnLoadingText')) |
| 238 | - $options['LoadTextOnEdit'] = true; |
|
| 238 | + $options['LoadTextOnEdit']=true; |
|
| 239 | 239 | |
| 240 | 240 | $options['ReadOnly']=$this->getReadOnly(); |
| 241 | 241 | return $options; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public function onLoadingText($param) |
| 250 | 250 | { |
| 251 | - $this->raiseEvent('OnLoadingText',$this,$param); |
|
| 251 | + $this->raiseEvent('OnLoadingText', $this, $param); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | { |
| 268 | 268 | //calls the TWebControl to avoid rendering other attribute normally render for a textbox. |
| 269 | 269 | TWebControl::addAttributesToRender($writer); |
| 270 | - $writer->addAttribute('id',$this->getLabelClientID()); |
|
| 270 | + $writer->addAttribute('id', $this->getLabelClientID()); |
|
| 271 | 271 | $this->getActiveControl()->registerCallbackClientScript( |
| 272 | 272 | $this->getClientClassName(), $this->getPostBackOptions()); |
| 273 | 273 | } |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * @return array list of trigger callback options. |
|
| 59 | + * @return string list of trigger callback options. |
|
| 60 | 60 | */ |
| 61 | 61 | protected function getTriggerOptions() |
| 62 | 62 | { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected function getTargetControl() |
| 46 | 46 | { |
| 47 | - $id = $this->getControlID(); |
|
| 47 | + $id=$this->getControlID(); |
|
| 48 | 48 | if(($control=$this->findControl($id)) instanceof TControl) |
| 49 | 49 | return $control->getClientID(); |
| 50 | 50 | if($id==='') |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | protected function getTriggerOptions() |
| 62 | 62 | { |
| 63 | - $options['ID'] = $this->getClientID(); |
|
| 64 | - $options['EventTarget'] = $this->getUniqueID(); |
|
| 65 | - $options['ControlID'] = $this->getTargetControl(); |
|
| 63 | + $options['ID']=$this->getClientID(); |
|
| 64 | + $options['EventTarget']=$this->getUniqueID(); |
|
| 65 | + $options['ControlID']=$this->getTargetControl(); |
|
| 66 | 66 | return $options; |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -158,6 +158,9 @@ |
||
| 158 | 158 | $this->triggerClientMethod('close'); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | + /** |
|
| 162 | + * @param string $method |
|
| 163 | + */ |
|
| 161 | 164 | private function triggerClientMethod($method) |
| 162 | 165 | { |
| 163 | 166 | $cs = $this->getPage()->getClientScript(); |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if ($this->sourcepath === NULL) |
| 59 | 59 | { |
| 60 | 60 | $this->sourcepath = $sourcepath; |
| 61 | - } |
|
| 62 | - else |
|
| 61 | + } else |
|
| 63 | 62 | { |
| 64 | 63 | $this->sourcepath->append($sourcepath); |
| 65 | 64 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function getOptions() |
| 70 | 70 | { |
| 71 | - if (($options=$this->getViewState('JuiOptions'))===null) |
|
| 71 | + if(($options=$this->getViewState('JuiOptions'))===null) |
|
| 72 | 72 | { |
| 73 | 73 | $options=new TJuiControlOptions($this); |
| 74 | 74 | $this->setViewState('JuiOptions', $options); |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function getPostBackOptions() |
| 101 | 101 | { |
| 102 | - $options = $this->getOptions()->toArray(); |
|
| 102 | + $options=$this->getOptions()->toArray(); |
|
| 103 | 103 | // always make the dialog a child of the form, or its inner inputs won't be collected |
| 104 | 104 | if(!isset($options['appendTo'])) |
| 105 | - $options['appendTo'] = 'form:first'; |
|
| 105 | + $options['appendTo']='form:first'; |
|
| 106 | 106 | |
| 107 | 107 | foreach($this->getControls() as $control) |
| 108 | 108 | if($control instanceof TJuiDialogButton) |
| 109 | - $options['buttons'][] = $control->getPostBackOptions(); |
|
| 109 | + $options['buttons'][]=$control->getPostBackOptions(); |
|
| 110 | 110 | |
| 111 | 111 | return $options; |
| 112 | 112 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | parent::addAttributesToRender($writer); |
| 121 | 121 | |
| 122 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 122 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 123 | 123 | $options=TJavascript::encode($this->getPostBackOptions()); |
| 124 | 124 | $cs=$this->getPage()->getClientScript(); |
| 125 | 125 | $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");"; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * Raises the OnCreate event |
| 141 | 141 | * @param object $params event parameters |
| 142 | 142 | */ |
| 143 | - public function onOpen ($params) |
|
| 143 | + public function onOpen($params) |
|
| 144 | 144 | { |
| 145 | 145 | $this->raiseEvent('OnOpen', $this, $params); |
| 146 | 146 | } |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | private function triggerClientMethod($method) |
| 165 | 165 | { |
| 166 | - $cs = $this->getPage()->getClientScript(); |
|
| 167 | - $code = "jQuery(document).ready(function() { jQuery('#".$this->getClientId()."').dialog('".$method."'); })"; |
|
| 166 | + $cs=$this->getPage()->getClientScript(); |
|
| 167 | + $code="jQuery(document).ready(function() { jQuery('#".$this->getClientId()."').dialog('".$method."'); })"; |
|
| 168 | 168 | $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | return array( |
| 245 | 245 | 'text' => $this->getText(), |
| 246 | 246 | 'click' => new TJavaScriptLiteral("function(){new Prado.Callback('".$this->getUniqueID()."', 'onClick');}" |
| 247 | - )) ; |
|
| 247 | + )); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | public function getText() |
| 254 | 254 | { |
| 255 | - return $this->getViewState('Text',''); |
|
| 255 | + return $this->getViewState('Text', ''); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -260,14 +260,14 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function setText($value) |
| 262 | 262 | { |
| 263 | - $this->setViewState('Text',$value,''); |
|
| 263 | + $this->setViewState('Text', $value, ''); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
| 267 | 267 | * Raises the OnClick event |
| 268 | 268 | * @param object $params event parameters |
| 269 | 269 | */ |
| 270 | - public function onClick ($params) |
|
| 270 | + public function onClick($params) |
|
| 271 | 271 | { |
| 272 | 272 | $this->raiseEvent('OnClick', $this, $params); |
| 273 | 273 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public function raiseCallbackEvent($param) |
| 281 | 281 | { |
| 282 | - if($param->CallbackParameter === 'onClick') |
|
| 282 | + if($param->CallbackParameter==='onClick') |
|
| 283 | 283 | $this->onClick($param); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | /** |
| 77 | 77 | * This method creates the template object for the given class |
| 78 | 78 | * |
| 79 | - * @param string $p_class The class to create the template from |
|
| 79 | + * @param string $parentClass |
|
| 80 | 80 | * @return void |
| 81 | 81 | * @throws TConfigurationException if a template control directive is invalid |
| 82 | 82 | */ |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function createChildControls() |
| 45 | 45 | { |
| 46 | - if(null === ($_template = $this->getTemplate())) { |
|
| 46 | + if(null===($_template=$this->getTemplate())) { |
|
| 47 | 47 | return $this->doCreateChildControlsFor(get_class($this)); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function doCreateChildControlsFor($parentClass) |
| 68 | 68 | { |
| 69 | - if(false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) { |
|
| 69 | + if(false!==($_parentClass=get_parent_class($parentClass)) && 'TTemplateControl'!=$_parentClass) { |
|
| 70 | 70 | $this->doCreateChildControlsFor($_parentClass); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function doTemplateForClass($parentClass) |
| 84 | 84 | { |
| 85 | - if(null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
| 85 | + if(null!==($_template=$this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
| 86 | 86 | foreach($_template->getDirective() as $_name => $_value) { |
| 87 | 87 | if(!is_string($_value)) { |
| 88 | 88 | throw new TConfigurationException('templatecontrol_directive_invalid', get_class(this), $_name); |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function getIsSourceTemplateControl() |
| 107 | 107 | { |
| 108 | - if(null !== ($_template = $this->getTemplate())) { |
|
| 108 | + if(null!==($_template=$this->getTemplate())) { |
|
| 109 | 109 | return $_template->getIsSourceTemplate(); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - return ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName(get_parent_class($this))) |
|
| 112 | + return ($_template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_parent_class($this))) |
|
| 113 | 113 | ? $_template->getIsSourceTemplate() |
| 114 | 114 | : false; |
| 115 | 115 | } |
@@ -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='') |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function getTokenImageTheme() |
| 73 | 73 | { |
| 74 | - return $this->getViewState('TokenImageTheme',0); |
|
| 74 | + return $this->getViewState('TokenImageTheme', 0); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | public function setTokenImageTheme($value) |
| 91 | 91 | { |
| 92 | 92 | $value=TPropertyValue::ensureInteger($value); |
| 93 | - if($value>=0 && $value<=63) |
|
| 94 | - $this->setViewState('TokenImageTheme',$value,0); |
|
| 93 | + if($value >= 0 && $value <= 63) |
|
| 94 | + $this->setViewState('TokenImageTheme', $value, 0); |
|
| 95 | 95 | else |
| 96 | - throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63); |
|
| 96 | + throw new TConfigurationException('captcha_tokenimagetheme_invalid', 0, 63); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function getTokenFontSize() |
| 103 | 103 | { |
| 104 | - return $this->getViewState('TokenFontSize',30); |
|
| 104 | + return $this->getViewState('TokenFontSize', 30); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | public function setTokenFontSize($value) |
| 114 | 114 | { |
| 115 | 115 | $value=TPropertyValue::ensureInteger($value); |
| 116 | - if($value>=20 && $value<=100) |
|
| 117 | - $this->setViewState('TokenFontSize',$value,30); |
|
| 116 | + if($value >= 20 && $value <= 100) |
|
| 117 | + $this->setViewState('TokenFontSize', $value, 30); |
|
| 118 | 118 | else |
| 119 | - throw new TConfigurationException('captcha_tokenfontsize_invalid',20,100); |
|
| 119 | + throw new TConfigurationException('captcha_tokenfontsize_invalid', 20, 100); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function getMinTokenLength() |
| 126 | 126 | { |
| 127 | - return $this->getViewState('MinTokenLength',4); |
|
| 127 | + return $this->getViewState('MinTokenLength', 4); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | public function setMinTokenLength($value) |
| 134 | 134 | { |
| 135 | 135 | $length=TPropertyValue::ensureInteger($value); |
| 136 | - if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH) |
|
| 137 | - $this->setViewState('MinTokenLength',$length,4); |
|
| 136 | + if($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH) |
|
| 137 | + $this->setViewState('MinTokenLength', $length, 4); |
|
| 138 | 138 | else |
| 139 | - throw new TConfigurationException('captcha_mintokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH); |
|
| 139 | + throw new TConfigurationException('captcha_mintokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function getMaxTokenLength() |
| 146 | 146 | { |
| 147 | - return $this->getViewState('MaxTokenLength',6); |
|
| 147 | + return $this->getViewState('MaxTokenLength', 6); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | public function setMaxTokenLength($value) |
| 154 | 154 | { |
| 155 | 155 | $length=TPropertyValue::ensureInteger($value); |
| 156 | - if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH) |
|
| 157 | - $this->setViewState('MaxTokenLength',$length,6); |
|
| 156 | + if($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH) |
|
| 157 | + $this->setViewState('MaxTokenLength', $length, 6); |
|
| 158 | 158 | else |
| 159 | - throw new TConfigurationException('captcha_maxtokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH); |
|
| 159 | + throw new TConfigurationException('captcha_maxtokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function getCaseSensitive() |
| 166 | 166 | { |
| 167 | - return $this->getViewState('CaseSensitive',true); |
|
| 167 | + return $this->getViewState('CaseSensitive', true); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function setCaseSensitive($value) |
| 174 | 174 | { |
| 175 | - $this->setViewState('CaseSensitive',TPropertyValue::ensureBoolean($value),true); |
|
| 175 | + $this->setViewState('CaseSensitive', TPropertyValue::ensureBoolean($value), true); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function getTokenAlphabet() |
| 182 | 182 | { |
| 183 | - return $this->getViewState('TokenAlphabet','234578adefhijmnrtABDEFGHJLMNRT'); |
|
| 183 | + return $this->getViewState('TokenAlphabet', '234578adefhijmnrtABDEFGHJLMNRT'); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function setTokenAlphabet($value) |
| 190 | 190 | { |
| 191 | - if(strlen($value)<2) |
|
| 191 | + if(strlen($value) < 2) |
|
| 192 | 192 | throw new TConfigurationException('captcha_tokenalphabet_invalid'); |
| 193 | - $this->setViewState('TokenAlphabet',$value,'234578adefhijmnrtABDEFGHJLMNRT'); |
|
| 193 | + $this->setViewState('TokenAlphabet', $value, '234578adefhijmnrtABDEFGHJLMNRT'); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function getTokenExpiry() |
| 200 | 200 | { |
| 201 | - return $this->getViewState('TokenExpiry',600); |
|
| 201 | + return $this->getViewState('TokenExpiry', 600); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function setTokenExpiry($value) |
| 208 | 208 | { |
| 209 | - $this->setViewState('TokenExpiry',TPropertyValue::ensureInteger($value),600); |
|
| 209 | + $this->setViewState('TokenExpiry', TPropertyValue::ensureInteger($value), 600); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | public function getChangingTokenBackground() |
| 216 | 216 | { |
| 217 | - return $this->getViewState('ChangingTokenBackground',false); |
|
| 217 | + return $this->getViewState('ChangingTokenBackground', false); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public function setChangingTokenBackground($value) |
| 224 | 224 | { |
| 225 | - $this->setViewState('ChangingTokenBackground',TPropertyValue::ensureBoolean($value),false); |
|
| 225 | + $this->setViewState('ChangingTokenBackground', TPropertyValue::ensureBoolean($value), false); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function getTestLimit() |
| 232 | 232 | { |
| 233 | - return $this->getViewState('TestLimit',5); |
|
| 233 | + return $this->getViewState('TestLimit', 5); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public function setTestLimit($value) |
| 240 | 240 | { |
| 241 | - $this->setViewState('TestLimit',TPropertyValue::ensureInteger($value),5); |
|
| 241 | + $this->setViewState('TestLimit', TPropertyValue::ensureInteger($value), 5); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public function getIsTokenExpired() |
| 248 | 248 | { |
| 249 | - if(($expiry=$this->getTokenExpiry())>0 && ($start=$this->getViewState('TokenGenerated',0))>0) |
|
| 250 | - return $expiry+$start<time(); |
|
| 249 | + if(($expiry=$this->getTokenExpiry()) > 0 && ($start=$this->getViewState('TokenGenerated', 0)) > 0) |
|
| 250 | + return $expiry + $start < time(); |
|
| 251 | 251 | else |
| 252 | 252 | return false; |
| 253 | 253 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | public function getPublicKey() |
| 259 | 259 | { |
| 260 | - if(($publicKey=$this->getViewState('PublicKey',''))==='') |
|
| 260 | + if(($publicKey=$this->getViewState('PublicKey', ''))==='') |
|
| 261 | 261 | { |
| 262 | 262 | $publicKey=$this->generateRandomKey(); |
| 263 | 263 | $this->setPublicKey($publicKey); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | public function setPublicKey($value) |
| 272 | 272 | { |
| 273 | - $this->setViewState('PublicKey',$value,''); |
|
| 273 | + $this->setViewState('PublicKey', $value, ''); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function getToken() |
| 280 | 280 | { |
| 281 | - return $this->generateToken($this->getPublicKey(),$this->getPrivateKey(),$this->getTokenAlphabet(),$this->getTokenLength(),$this->getCaseSensitive()); |
|
| 281 | + return $this->generateToken($this->getPublicKey(), $this->getPrivateKey(), $this->getTokenAlphabet(), $this->getTokenLength(), $this->getCaseSensitive()); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | { |
| 291 | 291 | $minLength=$this->getMinTokenLength(); |
| 292 | 292 | $maxLength=$this->getMaxTokenLength(); |
| 293 | - if($minLength>$maxLength) |
|
| 294 | - $tokenLength=rand($maxLength,$minLength); |
|
| 295 | - else if($minLength<$maxLength) |
|
| 296 | - $tokenLength=rand($minLength,$maxLength); |
|
| 293 | + if($minLength > $maxLength) |
|
| 294 | + $tokenLength=rand($maxLength, $minLength); |
|
| 295 | + else if($minLength < $maxLength) |
|
| 296 | + $tokenLength=rand($minLength, $maxLength); |
|
| 297 | 297 | else |
| 298 | 298 | $tokenLength=$minLength; |
| 299 | - $this->setViewState('TokenLength',$tokenLength); |
|
| 299 | + $this->setViewState('TokenLength', $tokenLength); |
|
| 300 | 300 | } |
| 301 | 301 | return $tokenLength; |
| 302 | 302 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | $fileName=$this->generatePrivateKeyFile(); |
| 312 | 312 | $content=file_get_contents($fileName); |
| 313 | 313 | $matches=array(); |
| 314 | - if(preg_match("/privateKey='(.*?)'/ms",$content,$matches)>0) |
|
| 314 | + if(preg_match("/privateKey='(.*?)'/ms", $content, $matches) > 0) |
|
| 315 | 315 | $this->_privateKey=$matches[1]; |
| 316 | 316 | else |
| 317 | 317 | throw new TConfigurationException('captcha_privatekey_unknown'); |
@@ -326,18 +326,18 @@ discard block |
||
| 326 | 326 | */ |
| 327 | 327 | public function validate($input) |
| 328 | 328 | { |
| 329 | - $number=$this->getViewState('TestNumber',0); |
|
| 329 | + $number=$this->getViewState('TestNumber', 0); |
|
| 330 | 330 | if(!$this->_validated) |
| 331 | 331 | { |
| 332 | - $this->setViewState('TestNumber',++$number); |
|
| 332 | + $this->setViewState('TestNumber', ++$number); |
|
| 333 | 333 | $this->_validated=true; |
| 334 | 334 | } |
| 335 | - if($this->getIsTokenExpired() || (($limit=$this->getTestLimit())>0 && $number>$limit)) |
|
| 335 | + if($this->getIsTokenExpired() || (($limit=$this->getTestLimit()) > 0 && $number > $limit)) |
|
| 336 | 336 | { |
| 337 | 337 | $this->regenerateToken(); |
| 338 | 338 | return false; |
| 339 | 339 | } |
| 340 | - return ($this->getToken()===($this->getCaseSensitive()?$input:strtoupper($input))); |
|
| 340 | + return ($this->getToken()===($this->getCaseSensitive() ? $input : strtoupper($input))); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $this->setPublicKey(''); |
| 352 | 352 | $this->clearViewState('TokenGenerated'); |
| 353 | 353 | $this->clearViewState('RandomSeed'); |
| 354 | - $this->clearViewState('TestNumber',0); |
|
| 354 | + $this->clearViewState('TestNumber', 0); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | parent::onPreRender($param); |
| 364 | 364 | if(!self::checkRequirements()) |
| 365 | 365 | throw new TConfigurationException('captcha_imagettftext_required'); |
| 366 | - if(!$this->getViewState('TokenGenerated',0)) |
|
| 366 | + if(!$this->getViewState('TokenGenerated', 0)) |
|
| 367 | 367 | { |
| 368 | 368 | $manager=$this->getApplication()->getAssetManager(); |
| 369 | 369 | $manager->publishFilePath($this->getFontFile()); |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | $url.='?options='.urlencode($this->getTokenImageOptions()); |
| 372 | 372 | $this->setImageUrl($url); |
| 373 | 373 | |
| 374 | - $this->setViewState('TokenGenerated',time()); |
|
| 374 | + $this->setViewState('TokenGenerated', time()); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | */ |
| 381 | 381 | protected function getTokenImageOptions() |
| 382 | 382 | { |
| 383 | - $privateKey=$this->getPrivateKey(); // call this method to ensure private key is generated |
|
| 383 | + $privateKey=$this->getPrivateKey(); // call this method to ensure private key is generated |
|
| 384 | 384 | $token=$this->getToken(); |
| 385 | 385 | $options=array(); |
| 386 | 386 | $options['publicKey']=$this->getPublicKey(); |
@@ -389,12 +389,12 @@ discard block |
||
| 389 | 389 | $options['alphabet']=$this->getTokenAlphabet(); |
| 390 | 390 | $options['fontSize']=$this->getTokenFontSize(); |
| 391 | 391 | $options['theme']=$this->getTokenImageTheme(); |
| 392 | - if(($randomSeed=$this->getViewState('RandomSeed',0))===0) |
|
| 392 | + if(($randomSeed=$this->getViewState('RandomSeed', 0))===0) |
|
| 393 | 393 | { |
| 394 | - $randomSeed=(int)(microtime()*1000000); |
|
| 395 | - $this->setViewState('RandomSeed',$randomSeed); |
|
| 394 | + $randomSeed=(int) (microtime() * 1000000); |
|
| 395 | + $this->setViewState('RandomSeed', $randomSeed); |
|
| 396 | 396 | } |
| 397 | - $options['randomSeed']=$this->getChangingTokenBackground()?0:$randomSeed; |
|
| 397 | + $options['randomSeed']=$this->getChangingTokenBackground() ? 0 : $randomSeed; |
|
| 398 | 398 | $str=serialize($options); |
| 399 | 399 | return base64_encode(md5($privateKey.$str).$str); |
| 400 | 400 | } |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | $content="<?php |
| 429 | 429 | \$privateKey='$key'; |
| 430 | 430 | ?>"; |
| 431 | - file_put_contents($fileName,$content); |
|
| 431 | + file_put_contents($fileName, $content); |
|
| 432 | 432 | } |
| 433 | 433 | return $fileName; |
| 434 | 434 | } |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | * @param boolean whether the token is case sensitive |
| 450 | 450 | * @return string the token generated. |
| 451 | 451 | */ |
| 452 | - protected function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive) |
|
| 452 | + protected function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive) |
|
| 453 | 453 | { |
| 454 | - $token=substr($this->hash2string(md5($publicKey.$privateKey),$alphabet).$this->hash2string(md5($privateKey.$publicKey),$alphabet),0,$tokenLength); |
|
| 455 | - return $caseSensitive?$token:strtoupper($token); |
|
| 454 | + $token=substr($this->hash2string(md5($publicKey.$privateKey), $alphabet).$this->hash2string(md5($privateKey.$publicKey), $alphabet), 0, $tokenLength); |
|
| 455 | + return $caseSensitive ? $token : strtoupper($token); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -461,20 +461,20 @@ discard block |
||
| 461 | 461 | * @param string the alphabet used to represent the converted string. If empty, it means '234578adefhijmnrtwyABDEFGHIJLMNQRTWY', which excludes those confusing characters. |
| 462 | 462 | * @return string the converted string |
| 463 | 463 | */ |
| 464 | - protected function hash2string($hex,$alphabet='') |
|
| 464 | + protected function hash2string($hex, $alphabet='') |
|
| 465 | 465 | { |
| 466 | - if(strlen($alphabet)<2) |
|
| 466 | + if(strlen($alphabet) < 2) |
|
| 467 | 467 | $alphabet='234578adefhijmnrtABDEFGHJLMNQRT'; |
| 468 | 468 | $hexLength=strlen($hex); |
| 469 | 469 | $base=strlen($alphabet); |
| 470 | 470 | $result=''; |
| 471 | - for($i=0;$i<$hexLength;$i+=6) |
|
| 471 | + for($i=0; $i < $hexLength; $i+=6) |
|
| 472 | 472 | { |
| 473 | - $number=hexdec(substr($hex,$i,6)); |
|
| 473 | + $number=hexdec(substr($hex, $i, 6)); |
|
| 474 | 474 | while($number) |
| 475 | 475 | { |
| 476 | - $result.=$alphabet[$number%$base]; |
|
| 477 | - $number=floor($number/$base); |
|
| 476 | + $result.=$alphabet[$number % $base]; |
|
| 477 | + $number=floor($number / $base); |
|
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | 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 | } |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if ($this->sourcepath === NULL) |
| 59 | 59 | { |
| 60 | 60 | $this->sourcepath = $sourcepath; |
| 61 | - } |
|
| 62 | - else |
|
| 61 | + } else |
|
| 63 | 62 | { |
| 64 | 63 | $this->sourcepath->append($sourcepath); |
| 65 | 64 | } |