@@ -70,7 +70,7 @@ |
||
70 | 70 | /** |
71 | 71 | * Javascript client class for this control. |
72 | 72 | * This method overrides the parent implementation. |
73 | - * @return null no javascript class name. |
|
73 | + * @return string no javascript class name. |
|
74 | 74 | */ |
75 | 75 | protected function getClientClassName() |
76 | 76 | { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected function createListItemCollection() |
64 | 64 | { |
65 | - $collection = new TActiveListItemCollection; |
|
65 | + $collection=new TActiveListItemCollection; |
|
66 | 66 | $collection->setControl($this); |
67 | 67 | return $collection; |
68 | 68 | } |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function setSelectionMode($value) |
87 | 87 | { |
88 | - if(parent::getSelectionMode() === $value) |
|
88 | + if(parent::getSelectionMode()===$value) |
|
89 | 89 | return; |
90 | 90 | |
91 | 91 | parent::setSelectionMode($value); |
92 | - $multiple = $this->getIsMultiSelect(); |
|
93 | - $id = $this->getUniqueID(); $multi_id = $id.'[]'; |
|
92 | + $multiple=$this->getIsMultiSelect(); |
|
93 | + $id=$this->getUniqueID(); $multi_id=$id.'[]'; |
|
94 | 94 | if($this->getActiveControl()->canUpdateClientSide()) |
95 | 95 | { |
96 | - $client = $this->getPage()->getCallbackClient(); |
|
96 | + $client=$this->getPage()->getCallbackClient(); |
|
97 | 97 | $client->setAttribute($this, 'multiple', $multiple ? 'multiple' : false); |
98 | 98 | $client->setAttribute($this, 'name', $multiple ? $multi_id : $id); |
99 | 99 | } |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | protected function addAttributesToRender($writer) |
147 | 147 | { |
148 | 148 | parent::addAttributesToRender($writer); |
149 | - $writer->addAttribute('id',$this->getClientID()); |
|
150 | - if ($this->getAutoPostBack()) |
|
149 | + $writer->addAttribute('id', $this->getClientID()); |
|
150 | + if($this->getAutoPostBack()) |
|
151 | 151 | $this->getActiveControl()->registerCallbackClientScript( |
152 | 152 | $this->getClientClassName(), $this->getPostBackOptions()); |
153 | 153 | } |
@@ -99,6 +99,7 @@ |
||
99 | 99 | * Calls the client-side static method for this control class. |
100 | 100 | * @param string static method name |
101 | 101 | * @param mixed method parmaeter |
102 | + * @param string $func |
|
102 | 103 | */ |
103 | 104 | protected function callClientFunction($func,$value) |
104 | 105 | { |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function setReadOnly($value) |
82 | 82 | { |
83 | - if(parent::getReadOnly() === $value) |
|
83 | + if(parent::getReadOnly()===$value) |
|
84 | 84 | return; |
85 | 85 | |
86 | 86 | parent::setReadOnly($value); |
87 | - $value = $this->getReadOnly(); |
|
88 | - $this->callClientFunction('setReadOnly',$value); |
|
87 | + $value=$this->getReadOnly(); |
|
88 | + $this->callClientFunction('setReadOnly', $value); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function setRating($value) |
95 | 95 | { |
96 | - if(parent::getRating() === $value) |
|
96 | + if(parent::getRating()===$value) |
|
97 | 97 | return; |
98 | 98 | |
99 | 99 | parent::setRating($value); |
100 | - $value = $this->getRating(); |
|
101 | - $this->callClientFunction('setRating',$value); |
|
100 | + $value=$this->getRating(); |
|
101 | + $this->callClientFunction('setRating', $value); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param string static method name |
107 | 107 | * @param mixed method parmaeter |
108 | 108 | */ |
109 | - protected function callClientFunction($func,$value) |
|
109 | + protected function callClientFunction($func, $value) |
|
110 | 110 | { |
111 | 111 | if($this->getActiveControl()->canUpdateClientSide()) |
112 | 112 | { |
113 | - $client = $this->getPage()->getCallbackClient(); |
|
114 | - $code = 'Prado.Registry[\''.$this->ClientID.'\'].'.$func.'('.$value.')'; |
|
115 | - $client->evaluateScript($code,array($value)); |
|
113 | + $client=$this->getPage()->getCallbackClient(); |
|
114 | + $code='Prado.Registry[\''.$this->ClientID.'\'].'.$func.'('.$value.')'; |
|
115 | + $client->evaluateScript($code, array($value)); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function setCaption($value) |
123 | 123 | { |
124 | - if(parent::getCaption() === $value) |
|
124 | + if(parent::getCaption()===$value) |
|
125 | 125 | return; |
126 | 126 | |
127 | 127 | parent::setCaption($value); |
128 | 128 | // if it's an active control, this should not be needed. |
129 | - $this->callClientFunction('setCaption',$value); |
|
129 | + $this->callClientFunction('setCaption', $value); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -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; |
@@ -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 | } |
@@ -12,7 +12,6 @@ |
||
12 | 12 | namespace Prado\Web\UI\JuiControls; |
13 | 13 | |
14 | 14 | use Prado\Exceptions\TNotSupportedException; |
15 | -use Prado\Web\Javascripts\TJavaScript; |
|
16 | 15 | use Prado\Web\UI\ActiveControls\ICallbackEventHandler; |
17 | 16 | use Prado\Web\UI\ActiveControls\TActivePanel; |
18 | 17 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function getOptions() |
74 | 74 | { |
75 | - if (($options=$this->getViewState('JuiOptions'))===null) |
|
75 | + if(($options=$this->getViewState('JuiOptions'))===null) |
|
76 | 76 | { |
77 | 77 | $options=new TJuiControlOptions($this); |
78 | 78 | $this->setViewState('JuiOptions', $options); |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function getPostBackOptions() |
105 | 105 | { |
106 | - $options = $this->getOptions()->toArray(); |
|
106 | + $options=$this->getOptions()->toArray(); |
|
107 | 107 | // always make the dialog a child of the form, or its inner inputs won't be collected |
108 | 108 | if(!isset($options['appendTo'])) |
109 | - $options['appendTo'] = 'form:first'; |
|
109 | + $options['appendTo']='form:first'; |
|
110 | 110 | |
111 | 111 | foreach($this->getControls() as $control) |
112 | 112 | if($control instanceof TJuiDialogButton) |
113 | - $options['buttons'][] = $control->getPostBackOptions(); |
|
113 | + $options['buttons'][]=$control->getPostBackOptions(); |
|
114 | 114 | |
115 | 115 | return $options; |
116 | 116 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | parent::addAttributesToRender($writer); |
125 | 125 | |
126 | - $writer->addAttribute('id',$this->getClientID()); |
|
126 | + $writer->addAttribute('id', $this->getClientID()); |
|
127 | 127 | $options=TJavascript::encode($this->getPostBackOptions()); |
128 | 128 | $cs=$this->getPage()->getClientScript(); |
129 | 129 | $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");"; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * Raises the OnCreate event |
145 | 145 | * @param object $params event parameters |
146 | 146 | */ |
147 | - public function onOpen ($params) |
|
147 | + public function onOpen($params) |
|
148 | 148 | { |
149 | 149 | $this->raiseEvent('OnOpen', $this, $params); |
150 | 150 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | |
168 | 168 | private function triggerClientMethod($method) |
169 | 169 | { |
170 | - $cs = $this->getPage()->getClientScript(); |
|
171 | - $code = "jQuery(document).ready(function() { jQuery('#".$this->getClientId()."').dialog('".$method."'); })"; |
|
170 | + $cs=$this->getPage()->getClientScript(); |
|
171 | + $code="jQuery(document).ready(function() { jQuery('#".$this->getClientId()."').dialog('".$method."'); })"; |
|
172 | 172 | $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); |
173 | 173 | } |
174 | 174 |
@@ -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; |