@@ -97,8 +97,7 @@ discard block |
||
97 | 97 | $this->_cachedActiveViewIndex=-1; |
98 | 98 | if($index>=0) |
99 | 99 | $this->activateView($views->itemAt($index),true); |
100 | - } |
|
101 | - else |
|
100 | + } else |
|
102 | 101 | throw new TInvalidDataValueException('multiview_activeviewindex_invalid',$index); |
103 | 102 | } |
104 | 103 | |
@@ -153,8 +152,7 @@ discard block |
||
153 | 152 | $view->onActivate(null); |
154 | 153 | $this->onActiveViewChanged(null); |
155 | 154 | } |
156 | - } |
|
157 | - else if($v->getActive()) |
|
155 | + } else if($v->getActive()) |
|
158 | 156 | { |
159 | 157 | $v->setActive(false); |
160 | 158 | if($triggerEvent) |
@@ -232,8 +230,7 @@ discard block |
||
232 | 230 | { |
233 | 231 | $this->setActiveView($view); |
234 | 232 | return true; |
235 | - } |
|
236 | - else |
|
233 | + } else |
|
237 | 234 | throw new TInvalidDataValueException('multiview_viewid_invalid', $viewID); |
238 | 235 | case self::CMD_SWITCHVIEWINDEX: |
239 | 236 | $index=TPropertyValue::ensureInteger($param->getCommandParameter()); |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getActiveViewIndex() |
82 | 82 | { |
83 | - if($this->_cachedActiveViewIndex>-1) |
|
83 | + if($this->_cachedActiveViewIndex > -1) |
|
84 | 84 | return $this->_cachedActiveViewIndex; |
85 | 85 | else |
86 | - return $this->getControlState('ActiveViewIndex',-1); |
|
86 | + return $this->getControlState('ActiveViewIndex', -1); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,21 +92,21 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function setActiveViewIndex($value) |
94 | 94 | { |
95 | - if(($index=TPropertyValue::ensureInteger($value))<0) |
|
95 | + if(($index=TPropertyValue::ensureInteger($value)) < 0) |
|
96 | 96 | $index=-1; |
97 | 97 | $views=$this->getViews(); |
98 | 98 | $count=$views->getCount(); |
99 | - if($count===0 && $this->getControlStage()<TControl::CS_CHILD_INITIALIZED) |
|
99 | + if($count===0 && $this->getControlStage() < TControl::CS_CHILD_INITIALIZED) |
|
100 | 100 | $this->_cachedActiveViewIndex=$index; |
101 | - else if($index<$count) |
|
101 | + else if($index < $count) |
|
102 | 102 | { |
103 | - $this->setControlState('ActiveViewIndex',$index,-1); |
|
103 | + $this->setControlState('ActiveViewIndex', $index, -1); |
|
104 | 104 | $this->_cachedActiveViewIndex=-1; |
105 | - if($index>=0) |
|
106 | - $this->activateView($views->itemAt($index),true); |
|
105 | + if($index >= 0) |
|
106 | + $this->activateView($views->itemAt($index), true); |
|
107 | 107 | } |
108 | 108 | else |
109 | - throw new TInvalidDataValueException('multiview_activeviewindex_invalid',$index); |
|
109 | + throw new TInvalidDataValueException('multiview_activeviewindex_invalid', $index); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | { |
118 | 118 | $index=$this->getActiveViewIndex(); |
119 | 119 | $views=$this->getViews(); |
120 | - if($index>=$views->getCount()) |
|
121 | - throw new TInvalidDataValueException('multiview_activeviewindex_invalid',$index); |
|
122 | - if($index<0) |
|
120 | + if($index >= $views->getCount()) |
|
121 | + throw new TInvalidDataValueException('multiview_activeviewindex_invalid', $index); |
|
122 | + if($index < 0) |
|
123 | 123 | return null; |
124 | 124 | $view=$views->itemAt($index); |
125 | 125 | if(!$view->getActive()) |
126 | - $this->activateView($view,false); |
|
126 | + $this->activateView($view, false); |
|
127 | 127 | return $view; |
128 | 128 | } |
129 | 129 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function setActiveView($view) |
135 | 135 | { |
136 | - if(($index=$this->getViews()->indexOf($view))>=0) |
|
136 | + if(($index=$this->getViews()->indexOf($view)) >= 0) |
|
137 | 137 | $this->setActiveViewIndex($index); |
138 | 138 | else |
139 | 139 | throw new TInvalidOperationException('multiview_view_inexistent'); |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | * @param TView the view to be activated |
146 | 146 | * @param boolean whether to trigger OnActiveViewChanged event. |
147 | 147 | */ |
148 | - protected function activateView($view,$triggerViewChangedEvent=true) |
|
148 | + protected function activateView($view, $triggerViewChangedEvent=true) |
|
149 | 149 | { |
150 | 150 | if($view->getActive()) |
151 | 151 | return; |
152 | - $triggerEvent=$triggerViewChangedEvent && ($this->getControlStage()>=\Prado\Web\UI\TControl::CS_STATE_LOADED || ($this->getPage() && !$this->getPage()->getIsPostBack())); |
|
152 | + $triggerEvent=$triggerViewChangedEvent && ($this->getControlStage() >= \Prado\Web\UI\TControl::CS_STATE_LOADED || ($this->getPage() && !$this->getPage()->getIsPostBack())); |
|
153 | 153 | foreach($this->getViews() as $v) |
154 | 154 | { |
155 | 155 | if($v===$view) |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | public function onInit($param) |
197 | 197 | { |
198 | 198 | parent::onInit($param); |
199 | - if($this->_cachedActiveViewIndex>=0) |
|
199 | + if($this->_cachedActiveViewIndex >= 0) |
|
200 | 200 | $this->setActiveViewIndex($this->_cachedActiveViewIndex); |
201 | 201 | } |
202 | 202 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function onActiveViewChanged($param) |
209 | 209 | { |
210 | - $this->raiseEvent('OnActiveViewChanged',$this,$param); |
|
210 | + $this->raiseEvent('OnActiveViewChanged', $this, $param); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | * @param mixed event parameter |
218 | 218 | * @return boolean whether this event is handled |
219 | 219 | */ |
220 | - public function bubbleEvent($sender,$param) |
|
220 | + public function bubbleEvent($sender, $param) |
|
221 | 221 | { |
222 | 222 | if(!$this->_ignoreBubbleEvents && ($param instanceof \Prado\Web\UI\TCommandEventParameter)) |
223 | 223 | { |
224 | 224 | switch($param->getCommandName()) |
225 | 225 | { |
226 | 226 | case self::CMD_NEXTVIEW: |
227 | - if(($index=$this->getActiveViewIndex())<$this->getViews()->getCount()-1) |
|
228 | - $this->setActiveViewIndex($index+1); |
|
227 | + if(($index=$this->getActiveViewIndex()) < $this->getViews()->getCount() - 1) |
|
228 | + $this->setActiveViewIndex($index + 1); |
|
229 | 229 | else |
230 | 230 | $this->setActiveViewIndex(-1); |
231 | 231 | return true; |
232 | 232 | case self::CMD_PREVIOUSVIEW: |
233 | - if(($index=$this->getActiveViewIndex())>=0) |
|
234 | - $this->setActiveViewIndex($index-1); |
|
233 | + if(($index=$this->getActiveViewIndex()) >= 0) |
|
234 | + $this->setActiveViewIndex($index - 1); |
|
235 | 235 | return true; |
236 | 236 | case self::CMD_SWITCHVIEWID: |
237 | 237 | $view=$this->findControl($viewID=$param->getCommandParameter()); |
@@ -211,8 +211,7 @@ discard block |
||
211 | 211 | $button=$this->createButton('Edit',$this->getEditText(),false,''); |
212 | 212 | $cell->getControls()->add($button); |
213 | 213 | $cell->registerObject('EditButton',$button); |
214 | - } |
|
215 | - else if($itemType===TListItemType::EditItem) |
|
214 | + } else if($itemType===TListItemType::EditItem) |
|
216 | 215 | { |
217 | 216 | $controls=$cell->getControls(); |
218 | 217 | $button=$this->createButton('Update',$this->getUpdateText(),$this->getCausesValidation(),$this->getValidationGroup()); |
@@ -222,8 +221,7 @@ discard block |
||
222 | 221 | $button=$this->createButton('Cancel',$this->getCancelText(),false,''); |
223 | 222 | $controls->add($button); |
224 | 223 | $cell->registerObject('CancelButton',$button); |
225 | - } |
|
226 | - else |
|
224 | + } else |
|
227 | 225 | parent::initializeCell($cell,$columnIndex,$itemType); |
228 | 226 | } |
229 | 227 |
@@ -233,6 +233,10 @@ |
||
233 | 233 | * @param string button caption |
234 | 234 | * @param boolean whether the button should cause validation |
235 | 235 | * @param string the validation group that the button belongs to |
236 | + * @param string $commandName |
|
237 | + * @param string $text |
|
238 | + * @param boolean $causesValidation |
|
239 | + * @param string $validationGroup |
|
236 | 240 | * @return mixed the newly created button. |
237 | 241 | */ |
238 | 242 | protected function createButton($commandName,$text,$causesValidation,$validationGroup) |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getButtonType() |
57 | 57 | { |
58 | - return $this->getViewState('ButtonType',TButtonColumnType::LinkButton); |
|
58 | + return $this->getViewState('ButtonType', TButtonColumnType::LinkButton); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function setButtonType($value) |
65 | 65 | { |
66 | - $this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TButtonColumnType'),TButtonColumnType::LinkButton); |
|
66 | + $this->setViewState('ButtonType', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TButtonColumnType'), TButtonColumnType::LinkButton); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getEditText() |
73 | 73 | { |
74 | - return $this->getViewState('EditText','Edit'); |
|
74 | + return $this->getViewState('EditText', 'Edit'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function setEditText($value) |
81 | 81 | { |
82 | - $this->setViewState('EditText',$value,'Edit'); |
|
82 | + $this->setViewState('EditText', $value, 'Edit'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function getEditImageUrl() |
89 | 89 | { |
90 | - return $this->getViewState('EditImageUrl',''); |
|
90 | + return $this->getViewState('EditImageUrl', ''); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function setEditImageUrl($value) |
97 | 97 | { |
98 | - $this->setViewState('EditImageUrl',$value,''); |
|
98 | + $this->setViewState('EditImageUrl', $value, ''); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getUpdateText() |
105 | 105 | { |
106 | - return $this->getViewState('UpdateText','Update'); |
|
106 | + return $this->getViewState('UpdateText', 'Update'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function setUpdateText($value) |
113 | 113 | { |
114 | - $this->setViewState('UpdateText',$value,'Update'); |
|
114 | + $this->setViewState('UpdateText', $value, 'Update'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getUpdateImageUrl() |
121 | 121 | { |
122 | - return $this->getViewState('UpdateImageUrl',''); |
|
122 | + return $this->getViewState('UpdateImageUrl', ''); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function setUpdateImageUrl($value) |
129 | 129 | { |
130 | - $this->setViewState('UpdateImageUrl',$value,''); |
|
130 | + $this->setViewState('UpdateImageUrl', $value, ''); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getCancelText() |
137 | 137 | { |
138 | - return $this->getViewState('CancelText','Cancel'); |
|
138 | + return $this->getViewState('CancelText', 'Cancel'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function setCancelText($value) |
145 | 145 | { |
146 | - $this->setViewState('CancelText',$value,'Cancel'); |
|
146 | + $this->setViewState('CancelText', $value, 'Cancel'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function getCancelImageUrl() |
153 | 153 | { |
154 | - return $this->getViewState('CancelImageUrl',''); |
|
154 | + return $this->getViewState('CancelImageUrl', ''); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function setCancelImageUrl($value) |
161 | 161 | { |
162 | - $this->setViewState('CancelImageUrl',$value,''); |
|
162 | + $this->setViewState('CancelImageUrl', $value, ''); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getCausesValidation() |
169 | 169 | { |
170 | - return $this->getViewState('CausesValidation',true); |
|
170 | + return $this->getViewState('CausesValidation', true); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function setCausesValidation($value) |
177 | 177 | { |
178 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
178 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function getValidationGroup() |
185 | 185 | { |
186 | - return $this->getViewState('ValidationGroup',''); |
|
186 | + return $this->getViewState('ValidationGroup', ''); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function setValidationGroup($value) |
193 | 193 | { |
194 | - $this->setViewState('ValidationGroup',$value,''); |
|
194 | + $this->setViewState('ValidationGroup', $value, ''); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -203,27 +203,27 @@ discard block |
||
203 | 203 | * @param integer the index to the Columns property that the cell resides in. |
204 | 204 | * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem) |
205 | 205 | */ |
206 | - public function initializeCell($cell,$columnIndex,$itemType) |
|
206 | + public function initializeCell($cell, $columnIndex, $itemType) |
|
207 | 207 | { |
208 | 208 | if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem) |
209 | 209 | { |
210 | - $button=$this->createButton('Edit',$this->getEditText(),false,''); |
|
210 | + $button=$this->createButton('Edit', $this->getEditText(), false, ''); |
|
211 | 211 | $cell->getControls()->add($button); |
212 | - $cell->registerObject('EditButton',$button); |
|
212 | + $cell->registerObject('EditButton', $button); |
|
213 | 213 | } |
214 | 214 | else if($itemType===TListItemType::EditItem) |
215 | 215 | { |
216 | 216 | $controls=$cell->getControls(); |
217 | - $button=$this->createButton('Update',$this->getUpdateText(),$this->getCausesValidation(),$this->getValidationGroup()); |
|
217 | + $button=$this->createButton('Update', $this->getUpdateText(), $this->getCausesValidation(), $this->getValidationGroup()); |
|
218 | 218 | $controls->add($button); |
219 | - $cell->registerObject('UpdateButton',$button); |
|
219 | + $cell->registerObject('UpdateButton', $button); |
|
220 | 220 | $controls->add(' '); |
221 | - $button=$this->createButton('Cancel',$this->getCancelText(),false,''); |
|
221 | + $button=$this->createButton('Cancel', $this->getCancelText(), false, ''); |
|
222 | 222 | $controls->add($button); |
223 | - $cell->registerObject('CancelButton',$button); |
|
223 | + $cell->registerObject('CancelButton', $button); |
|
224 | 224 | } |
225 | 225 | else |
226 | - parent::initializeCell($cell,$columnIndex,$itemType); |
|
226 | + parent::initializeCell($cell, $columnIndex, $itemType); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | * @param string the validation group that the button belongs to |
236 | 236 | * @return mixed the newly created button. |
237 | 237 | */ |
238 | - protected function createButton($commandName,$text,$causesValidation,$validationGroup) |
|
238 | + protected function createButton($commandName, $text, $causesValidation, $validationGroup) |
|
239 | 239 | { |
240 | 240 | if($this->getButtonType()===TButtonColumnType::LinkButton) |
241 | - $button= new TLinkButton; |
|
241 | + $button=new TLinkButton; |
|
242 | 242 | else if($this->getButtonType()===TButtonColumnType::PushButton) |
243 | - $button= new TButton; |
|
243 | + $button=new TButton; |
|
244 | 244 | else // image buttons |
245 | 245 | { |
246 | - $button= new TImageButton; |
|
247 | - if(strcasecmp($commandName,'Update')===0) |
|
246 | + $button=new TImageButton; |
|
247 | + if(strcasecmp($commandName, 'Update')===0) |
|
248 | 248 | $url=$this->getUpdateImageUrl(); |
249 | - else if(strcasecmp($commandName,'Cancel')===0) |
|
249 | + else if(strcasecmp($commandName, 'Cancel')===0) |
|
250 | 250 | $url=$this->getCancelImageUrl(); |
251 | 251 | else |
252 | 252 | $url=$this->getEditImageUrl(); |
@@ -106,8 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | if($this->getEnableClientScript() && $this->needPostBackScript()) |
108 | 108 | $this->renderClientControlScript($writer); |
109 | - } |
|
110 | - else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
109 | + } else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
111 | 110 | $writer->addAttribute('disabled','disabled'); |
112 | 111 | parent::addAttributesToRender($writer); |
113 | 112 | } |
@@ -141,8 +140,7 @@ discard block |
||
141 | 140 | { |
142 | 141 | $group=$this->getValidationGroup(); |
143 | 142 | return $this->getPage()->getValidators($group)->getCount()>0; |
144 | - } |
|
145 | - else |
|
143 | + } else |
|
146 | 144 | return false; |
147 | 145 | } |
148 | 146 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getEnableClientScript() |
80 | 80 | { |
81 | - return $this->getViewState('EnableClientScript',true); |
|
81 | + return $this->getViewState('EnableClientScript', true); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function setEnableClientScript($value) |
88 | 88 | { |
89 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
89 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | { |
99 | 99 | $page=$this->getPage(); |
100 | 100 | $page->ensureRenderInForm($this); |
101 | - $writer->addAttribute('type','image'); |
|
101 | + $writer->addAttribute('type', 'image'); |
|
102 | 102 | if(($uniqueID=$this->getUniqueID())!=='') |
103 | - $writer->addAttribute('name',$uniqueID); |
|
103 | + $writer->addAttribute('name', $uniqueID); |
|
104 | 104 | if($this->getEnabled(true)) |
105 | 105 | { |
106 | 106 | if($this->getEnableClientScript() && $this->needPostBackScript()) |
107 | 107 | $this->renderClientControlScript($writer); |
108 | 108 | } |
109 | 109 | else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
110 | - $writer->addAttribute('disabled','disabled'); |
|
110 | + $writer->addAttribute('disabled', 'disabled'); |
|
111 | 111 | parent::addAttributesToRender($writer); |
112 | 112 | } |
113 | 113 | |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function renderClientControlScript($writer) |
118 | 118 | { |
119 | - $writer->addAttribute('id',$this->getClientID()); |
|
120 | - $cs = $this->getPage()->getClientScript(); |
|
121 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
119 | + $writer->addAttribute('id', $this->getClientID()); |
|
120 | + $cs=$this->getPage()->getClientScript(); |
|
121 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if($this->getCausesValidation()) |
140 | 140 | { |
141 | 141 | $group=$this->getValidationGroup(); |
142 | - return $this->getPage()->getValidators($group)->getCount()>0; |
|
142 | + return $this->getPage()->getValidators($group)->getCount() > 0; |
|
143 | 143 | } |
144 | 144 | else |
145 | 145 | return false; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function setIsDefaultButton($value) |
152 | 152 | { |
153 | - $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false); |
|
153 | + $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value), false); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function getPostBackOptions() |
178 | 178 | { |
179 | - $options['ID'] = $this->getClientID(); |
|
180 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
181 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
182 | - $options['EventTarget'] = $this->getUniqueID(); |
|
179 | + $options['ID']=$this->getClientID(); |
|
180 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
181 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
182 | + $options['EventTarget']=$this->getUniqueID(); |
|
183 | 183 | |
184 | 184 | return $options; |
185 | 185 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param array the input data collection |
192 | 192 | * @return boolean whether the data of the component has been changed |
193 | 193 | */ |
194 | - public function loadPostData($key,$values) |
|
194 | + public function loadPostData($key, $values) |
|
195 | 195 | { |
196 | 196 | $uid=$this->getUniqueID(); |
197 | 197 | if(isset($values["{$uid}_x"]) && isset($values["{$uid}_y"])) |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function onClick($param) |
224 | 224 | { |
225 | - $this->raiseEvent('OnClick',$this,$param); |
|
225 | + $this->raiseEvent('OnClick', $this, $param); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function onCommand($param) |
236 | 236 | { |
237 | - $this->raiseEvent('OnCommand',$this,$param); |
|
238 | - $this->raiseBubbleEvent($this,$param); |
|
237 | + $this->raiseEvent('OnCommand', $this, $param); |
|
238 | + $this->raiseBubbleEvent($this, $param); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | { |
252 | 252 | if($this->getCausesValidation()) |
253 | 253 | $this->getPage()->validate($this->getValidationGroup()); |
254 | - $this->onClick(new TImageClickEventParameter($this->_x,$this->_y)); |
|
255 | - $this->onCommand(new \Prado\Web\UI\TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); |
|
254 | + $this->onClick(new TImageClickEventParameter($this->_x, $this->_y)); |
|
255 | + $this->onCommand(new \Prado\Web\UI\TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | */ |
271 | 271 | public function getCausesValidation() |
272 | 272 | { |
273 | - return $this->getViewState('CausesValidation',true); |
|
273 | + return $this->getViewState('CausesValidation', true); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function setCausesValidation($value) |
280 | 280 | { |
281 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
281 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function getCommandName() |
288 | 288 | { |
289 | - return $this->getViewState('CommandName',''); |
|
289 | + return $this->getViewState('CommandName', ''); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function setCommandName($value) |
296 | 296 | { |
297 | - $this->setViewState('CommandName',$value,''); |
|
297 | + $this->setViewState('CommandName', $value, ''); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function getCommandParameter() |
304 | 304 | { |
305 | - return $this->getViewState('CommandParameter',''); |
|
305 | + return $this->getViewState('CommandParameter', ''); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function setCommandParameter($value) |
312 | 312 | { |
313 | - $this->setViewState('CommandParameter',$value,''); |
|
313 | + $this->setViewState('CommandParameter', $value, ''); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function getValidationGroup() |
320 | 320 | { |
321 | - return $this->getViewState('ValidationGroup',''); |
|
321 | + return $this->getViewState('ValidationGroup', ''); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function setValidationGroup($value) |
328 | 328 | { |
329 | - $this->setViewState('ValidationGroup',$value,''); |
|
329 | + $this->setViewState('ValidationGroup', $value, ''); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -219,6 +219,7 @@ discard block |
||
219 | 219 | * If you override this method, be sure to call the parent implementation |
220 | 220 | * so that the event handler can be invoked. |
221 | 221 | * @param TImageClickEventParameter event parameter to be passed to the event handlers |
222 | + * @param TImageClickEventParameter $param |
|
222 | 223 | */ |
223 | 224 | public function onClick($param) |
224 | 225 | { |
@@ -231,6 +232,7 @@ discard block |
||
231 | 232 | * If you override this method, be sure to call the parent implementation |
232 | 233 | * so that the event handlers can be invoked. |
233 | 234 | * @param \Prado\Web\UI\TCommandEventParameter event parameter to be passed to the event handlers |
235 | + * @param \Prado\Web\UI\TCommandEventParameter $param |
|
234 | 236 | */ |
235 | 237 | public function onCommand($param) |
236 | 238 | { |
@@ -235,14 +235,12 @@ |
||
235 | 235 | { |
236 | 236 | $parameter = new TJuiAutoCompleteEventParameter($this->getResponse(), $token[0]); |
237 | 237 | $this->onSuggest($parameter); |
238 | - } |
|
239 | - else if($token[1] === '__TJuiAutoComplete_onSuggestionSelected__') |
|
238 | + } else if($token[1] === '__TJuiAutoComplete_onSuggestionSelected__') |
|
240 | 239 | { |
241 | 240 | $parameter = new TJuiAutoCompleteEventParameter($this->getResponse(), null, $token[0]); |
242 | 241 | $this->onSuggestionSelected($parameter); |
243 | 242 | } |
244 | - } |
|
245 | - else if($this->getAutoPostBack()) |
|
243 | + } else if($this->getAutoPostBack()) |
|
246 | 244 | parent::raiseCallbackEvent($param); |
247 | 245 | } |
248 | 246 |
@@ -260,6 +260,7 @@ discard block |
||
260 | 260 | * method, be sure to call the parent implementation so that the event |
261 | 261 | * handler can be invoked. |
262 | 262 | * @param TCallbackEventParameter event parameter to be passed to the event handlers |
263 | + * @param TJuiAutoCompleteEventParameter $param |
|
263 | 264 | */ |
264 | 265 | public function onSuggest($param) |
265 | 266 | { |
@@ -272,6 +273,7 @@ discard block |
||
272 | 273 | * method, be sure to call the parent implementation so that the event |
273 | 274 | * handler can be invoked. |
274 | 275 | * @param TCallbackEventParameter event parameter to be passed to the event handlers |
276 | + * @param TJuiAutoCompleteEventParameter $param |
|
275 | 277 | */ |
276 | 278 | public function onSuggestionSelected($param) |
277 | 279 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function getOptions() |
133 | 133 | { |
134 | - if (($options=$this->getViewState('JuiOptions'))===null) |
|
134 | + if(($options=$this->getViewState('JuiOptions'))===null) |
|
135 | 135 | { |
136 | 136 | $options=new TJuiControlOptions($this); |
137 | 137 | $this->setViewState('JuiOptions', $options); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function getMinChars() |
214 | 214 | { |
215 | - return $this->getViewState('minChars',''); |
|
215 | + return $this->getViewState('minChars', ''); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -236,17 +236,17 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function raiseCallbackEvent($param) |
238 | 238 | { |
239 | - $token = $param->getCallbackParameter(); |
|
240 | - if(is_array($token) && count($token) == 2) |
|
239 | + $token=$param->getCallbackParameter(); |
|
240 | + if(is_array($token) && count($token)==2) |
|
241 | 241 | { |
242 | - if($token[1] === '__TJuiAutoComplete_onSuggest__') |
|
242 | + if($token[1]==='__TJuiAutoComplete_onSuggest__') |
|
243 | 243 | { |
244 | - $parameter = new TJuiAutoCompleteEventParameter($this->getResponse(), $token[0]); |
|
244 | + $parameter=new TJuiAutoCompleteEventParameter($this->getResponse(), $token[0]); |
|
245 | 245 | $this->onSuggest($parameter); |
246 | 246 | } |
247 | - else if($token[1] === '__TJuiAutoComplete_onSuggestionSelected__') |
|
247 | + else if($token[1]==='__TJuiAutoComplete_onSuggestionSelected__') |
|
248 | 248 | { |
249 | - $parameter = new TJuiAutoCompleteEventParameter($this->getResponse(), null, $token[0]); |
|
249 | + $parameter=new TJuiAutoCompleteEventParameter($this->getResponse(), null, $token[0]); |
|
250 | 250 | $this->onSuggestionSelected($parameter); |
251 | 251 | } |
252 | 252 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | public function getResultPanel() |
304 | 304 | { |
305 | 305 | if($this->_resultPanel===null) |
306 | - $this->_resultPanel = $this->createResultPanel(); |
|
306 | + $this->_resultPanel=$this->createResultPanel(); |
|
307 | 307 | return $this->_resultPanel; |
308 | 308 | } |
309 | 309 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | protected function createResultPanel() |
314 | 314 | { |
315 | - $panel = new TPanel; |
|
315 | + $panel=new TPanel; |
|
316 | 316 | $this->getControls()->add($panel); |
317 | 317 | $panel->setID('result'); |
318 | 318 | return $panel; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | public function getSuggestions() |
325 | 325 | { |
326 | 326 | if($this->_repeater===null) |
327 | - $this->_repeater = $this->createRepeater(); |
|
327 | + $this->_repeater=$this->createRepeater(); |
|
328 | 328 | return $this->_repeater; |
329 | 329 | } |
330 | 330 | |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | */ |
334 | 334 | protected function createRepeater() |
335 | 335 | { |
336 | - $repeater = new TRepeater; |
|
337 | - $repeater->setItemTemplate(new TTemplate('<%# $this->Data %>',null)); |
|
336 | + $repeater=new TRepeater; |
|
337 | + $repeater->setItemTemplate(new TTemplate('<%# $this->Data %>', null)); |
|
338 | 338 | $this->getControls()->add($repeater); |
339 | 339 | return $repeater; |
340 | 340 | } |
@@ -376,12 +376,12 @@ discard block |
||
376 | 376 | { |
377 | 377 | $data=array(); |
378 | 378 | $items=$this->getSuggestions()->getItems(); |
379 | - $writer = new TTextWriter; |
|
380 | - for($i=0; $i<$items->Count; $i++) |
|
379 | + $writer=new TTextWriter; |
|
380 | + for($i=0; $i < $items->Count; $i++) |
|
381 | 381 | { |
382 | 382 | $items->itemAt($i)->render($writer); |
383 | 383 | $item=$writer->flush(); |
384 | - $data[]=array( 'id' => $i, 'label' => $item); |
|
384 | + $data[]=array('id' => $i, 'label' => $item); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | $this->getResponse()->getAdapter()->setResponseData($data); |
@@ -393,25 +393,25 @@ discard block |
||
393 | 393 | */ |
394 | 394 | protected function getPostBackOptions() |
395 | 395 | { |
396 | - $options = $this->getOptions()->toArray(); |
|
396 | + $options=$this->getOptions()->toArray(); |
|
397 | 397 | |
398 | - if(strlen($separator = $this->getSeparator())) |
|
399 | - $options['Separators'] = $separator; |
|
398 | + if(strlen($separator=$this->getSeparator())) |
|
399 | + $options['Separators']=$separator; |
|
400 | 400 | |
401 | 401 | if($this->getAutoPostBack()) |
402 | 402 | { |
403 | - $options = array_merge($options,parent::getPostBackOptions()); |
|
404 | - $options['AutoPostBack'] = true; |
|
403 | + $options=array_merge($options, parent::getPostBackOptions()); |
|
404 | + $options['AutoPostBack']=true; |
|
405 | 405 | } |
406 | - if(strlen($textCssClass = $this->getTextCssClass())) |
|
407 | - $options['textCssClass'] = $textCssClass; |
|
408 | - $options['minLength'] = $this->getMinChars(); |
|
409 | - $options['delay'] = $this->getFrequency()*1000.0; |
|
410 | - $options['appendTo'] = '#'.$this->getResultPanel()->getClientID(); |
|
411 | - $options['ID'] = $this->getClientID(); |
|
412 | - $options['EventTarget'] = $this->getUniqueID(); |
|
413 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
414 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
406 | + if(strlen($textCssClass=$this->getTextCssClass())) |
|
407 | + $options['textCssClass']=$textCssClass; |
|
408 | + $options['minLength']=$this->getMinChars(); |
|
409 | + $options['delay']=$this->getFrequency() * 1000.0; |
|
410 | + $options['appendTo']='#'.$this->getResultPanel()->getClientID(); |
|
411 | + $options['ID']=$this->getClientID(); |
|
412 | + $options['EventTarget']=$this->getUniqueID(); |
|
413 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
414 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
415 | 415 | return $options; |
416 | 416 | } |
417 | 417 |
@@ -79,8 +79,7 @@ |
||
79 | 79 | if($this->getHasPreRendered()) { |
80 | 80 | $this->renderDataList($writer); |
81 | 81 | if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer); |
82 | - } |
|
83 | - else { |
|
82 | + } else { |
|
84 | 83 | $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
85 | 84 | } |
86 | 85 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | parent::setDataSource($value); |
56 | 56 | if($this->getActiveControl()->canUpdateClientSide()) { |
57 | 57 | $this->renderPager(); |
58 | - $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter()); |
|
58 | + $this->getPage()->getAdapter()->registerControlToRender($this, $this->getResponse()->createHtmlWriter()); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | { |
79 | 79 | if($this->getHasPreRendered()) { |
80 | 80 | $this->renderDataList($writer); |
81 | - if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer); |
|
81 | + if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(), $writer); |
|
82 | 82 | } |
83 | 83 | else { |
84 | - $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
|
84 | + $this->getPage()->getAdapter()->registerControlToRender($this, $writer); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | { |
98 | 98 | if($item->ControlToPaginate==$this->ID) { |
99 | 99 | $writer=$this->getResponse()->createHtmlWriter(); |
100 | - $this->getPage()->getAdapter()->registerControlToRender($item,$writer); |
|
100 | + $this->getPage()->getAdapter()->registerControlToRender($item, $writer); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct() |
36 | 36 | { |
37 | - parent::__construct(); |
|
38 | - $this->setAdapter(new TActiveControlAdapter($this)); |
|
37 | + parent::__construct(); |
|
38 | + $this->setAdapter(new TActiveControlAdapter($this)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function getActiveControl() |
45 | 45 | { |
46 | - return $this->getAdapter()->getBaseActiveControl(); |
|
46 | + return $this->getAdapter()->getBaseActiveControl(); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function setDataSource($value) |
57 | 57 | { |
58 | - parent::setDataSource($value); |
|
59 | - if($this->getActiveControl()->canUpdateClientSide()) { |
|
60 | - $this->renderPager(); |
|
61 | - $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter()); |
|
62 | - } |
|
58 | + parent::setDataSource($value); |
|
59 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
60 | + $this->renderPager(); |
|
61 | + $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter()); |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | protected function getContainerID() |
70 | 70 | { |
71 | - return $this->ClientID.'_Container'; |
|
71 | + return $this->ClientID.'_Container'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function render($writer) |
81 | 81 | { |
82 | - if($this->getHasPreRendered()) { |
|
83 | - $this->renderDataList($writer); |
|
84 | - if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer); |
|
85 | - } |
|
86 | - else { |
|
87 | - $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
|
88 | - } |
|
82 | + if($this->getHasPreRendered()) { |
|
83 | + $this->renderDataList($writer); |
|
84 | + if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(),$writer); |
|
85 | + } |
|
86 | + else { |
|
87 | + $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
|
88 | + } |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | */ |
96 | 96 | private function renderPager() |
97 | 97 | { |
98 | - $pager=$this->getPage()->findControlsByType('Prado\Web\UI\ActiveControls\TActivePager', false); |
|
99 | - foreach($pager as $item) |
|
100 | - { |
|
101 | - if($item->ControlToPaginate==$this->ID) { |
|
102 | - $writer=$this->getResponse()->createHtmlWriter(); |
|
103 | - $this->getPage()->getAdapter()->registerControlToRender($item,$writer); |
|
104 | - } |
|
105 | - } |
|
98 | + $pager=$this->getPage()->findControlsByType('Prado\Web\UI\ActiveControls\TActivePager', false); |
|
99 | + foreach($pager as $item) |
|
100 | + { |
|
101 | + if($item->ControlToPaginate==$this->ID) { |
|
102 | + $writer=$this->getResponse()->createHtmlWriter(); |
|
103 | + $this->getPage()->getAdapter()->registerControlToRender($item,$writer); |
|
104 | + } |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | */ |
113 | 113 | private function renderDataList($writer) |
114 | 114 | { |
115 | - $writer->write('<span id="'.$this->getContainerID().'">'); |
|
116 | - parent::render($writer); |
|
117 | - $writer->write('</span>'); |
|
115 | + $writer->write('<span id="'.$this->getContainerID().'">'); |
|
116 | + parent::render($writer); |
|
117 | + $writer->write('</span>'); |
|
118 | 118 | } |
119 | 119 | } |
@@ -223,14 +223,12 @@ discard block |
||
223 | 223 | // this is the most secure method, file info can't be forged from client side, no matter what |
224 | 224 | $token = md5('TActiveFileUpload::Params::'.$this->ClientID.'::'+rand(1000*1000,9999*1000)); |
225 | 225 | $cache->set($token, serialize($params), 5*60); // expire in 5 minutes - the callback should arrive back in seconds, actually |
226 | - } |
|
227 | - else |
|
226 | + } else |
|
228 | 227 | if ($mgr = Prado::getApplication()->getSecurityManager()) |
229 | 228 | { |
230 | 229 | // this is a less secure method, file info can be still forged from client side, but only if attacker knows the secret application key |
231 | 230 | $token = urlencode(base64_encode($mgr->encrypt(serialize($params)))); |
232 | - } |
|
233 | - else |
|
231 | + } else |
|
234 | 232 | throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
235 | 233 | |
236 | 234 | return $token; |
@@ -244,14 +242,12 @@ discard block |
||
244 | 242 | assert($v!=''); |
245 | 243 | $cache->delete($token); // remove it from cache so it can't be used again and won't take up space either |
246 | 244 | $params = unserialize($v); |
247 | - } |
|
248 | - else |
|
245 | + } else |
|
249 | 246 | if ($mgr = Prado::getApplication()->getSecurityManager()) |
250 | 247 | { |
251 | 248 | $v = $mgr->decrypt(base64_decode(urldecode($token))); |
252 | 249 | $params = unserialize($v); |
253 | - } |
|
254 | - else |
|
250 | + } else |
|
255 | 251 | throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
256 | 252 | |
257 | 253 | assert($params instanceof TActiveFileUploadCallbackParams); |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | if ($key = $cp->targetID == $this->_target->getUniqueID()){ |
204 | 204 | |
205 | 205 | $params = $this->popParamsByToken($cp->callbackToken); |
206 | - foreach($params->files as $index => $file) |
|
207 | - { |
|
206 | + foreach($params->files as $index => $file) |
|
207 | + { |
|
208 | 208 | $_FILES[$key]['name'][$index] = stripslashes($file['fileName']); |
209 | 209 | $_FILES[$key]['size'][$index] = intval($file['fileSize']); |
210 | 210 | $_FILES[$key]['type'][$index] = $file['fileType']; |
211 | 211 | $_FILES[$key]['error'][$index] = intval($file['errorCode']); |
212 | 212 | $_FILES[$key]['tmp_name'][$index] = $file['localName']; |
213 | - } |
|
213 | + } |
|
214 | 214 | $this->loadPostData($key, null); |
215 | 215 | |
216 | 216 | $this->raiseEvent('OnFileUpload', $this, $param); |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | { |
282 | 282 | $params = new TActiveFileUploadCallbackParams; |
283 | 283 | foreach ($this->getFiles() as $file) { |
284 | - $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),'')); |
|
285 | - $file->setLocalName($localName); |
|
286 | - // tricky workaround to intercept "uploaded file too big" error: real uploads happens in onFileUpload instead |
|
287 | - $file->setErrorCode(UPLOAD_ERR_FORM_SIZE); |
|
288 | - $params->files[] = $file->toArray(); |
|
284 | + $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),'')); |
|
285 | + $file->setLocalName($localName); |
|
286 | + // tricky workaround to intercept "uploaded file too big" error: real uploads happens in onFileUpload instead |
|
287 | + $file->setErrorCode(UPLOAD_ERR_FORM_SIZE); |
|
288 | + $params->files[] = $file->toArray(); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | echo "<script language='Javascript'> |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | if ($this->getPage()->getIsCallback()) |
341 | 341 | { |
342 | 342 | foreach($this->getFiles() as $file) |
343 | - if($file->getHasFile() && file_exists($file->getLocalName())){ |
|
344 | - unlink($file->getLocalName()); |
|
343 | + if($file->getHasFile() && file_exists($file->getLocalName())){ |
|
344 | + unlink($file->getLocalName()); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | parent::onUnload($param); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | class TActiveFileUpload extends TFileUpload implements IActiveControl, ICallbackEventHandler, INamingContainer |
62 | 62 | { |
63 | - const SCRIPT_PATH = 'activefileupload'; |
|
63 | + const SCRIPT_PATH='activefileupload'; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * @var THiddenField a flag to tell which component is doing the callback. |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * TActiveControlAdapter. If you override this class, be sure to set the |
90 | 90 | * adapter appropriately by, for example, by calling this constructor. |
91 | 91 | */ |
92 | - public function __construct(){ |
|
92 | + public function __construct() { |
|
93 | 93 | parent::__construct(); |
94 | 94 | $this->setAdapter(new TActiveControlAdapter($this)); |
95 | 95 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | protected function getAssetUrl($file='') |
103 | 103 | { |
104 | - $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl(); |
|
104 | + $base=$this->getPage()->getClientScript()->getPradoScriptAssetUrl(); |
|
105 | 105 | return $base.'/'.self::SCRIPT_PATH.'/'.$file; |
106 | 106 | } |
107 | 107 | |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function onFileUpload($param) |
116 | 116 | { |
117 | - if ($this->_flag->getValue() && $this->getPage()->getIsPostBack() && $param == $this->_target->getUniqueID()){ |
|
118 | - $params = new TActiveFileUploadCallbackParams; |
|
117 | + if($this->_flag->getValue() && $this->getPage()->getIsPostBack() && $param==$this->_target->getUniqueID()) { |
|
118 | + $params=new TActiveFileUploadCallbackParams; |
|
119 | 119 | // save the files so that they will persist past the end of this return. |
120 | - foreach ($this->getFiles() as $file) { |
|
121 | - $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),'')); |
|
120 | + foreach($this->getFiles() as $file) { |
|
121 | + $localName=str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()), '')); |
|
122 | 122 | $file->saveAs($localName); |
123 | 123 | $file->setLocalName($localName); |
124 | - $params->files[] = $file->toArray(); |
|
124 | + $params->files[]=$file->toArray(); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // return some javascript to display a completion status. |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | Options = new Object(); |
130 | 130 | Options.clientID = '{$this->getClientID()}'; |
131 | 131 | Options.targetID = '{$this->_target->getUniqueID()}'; |
132 | - Options.errorCode = '" . (int)!$this->getHasAllFiles() . "'; |
|
132 | + Options.errorCode = '".(int) !$this->getHasAllFiles()."'; |
|
133 | 133 | Options.callbackToken = '{$this->pushParamsAndGetToken($params)}'; |
134 | - Options.fileName = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileName') : $this->getFileName(), JSON_HEX_APOS) . "'; |
|
135 | - Options.fileSize = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileSize') : $this->getFileSize(), JSON_HEX_APOS) . "'; |
|
136 | - Options.fileType = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileType') : $this->getFileType(), JSON_HEX_APOS) . "'; |
|
137 | - Options.errorCode = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'errorCode') : $this->getErrorCode(), JSON_HEX_APOS) . "'; |
|
134 | + Options.fileName = '".TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileName') : $this->getFileName(), JSON_HEX_APOS)."'; |
|
135 | + Options.fileSize = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileSize') : $this->getFileSize(), JSON_HEX_APOS)."'; |
|
136 | + Options.fileType = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileType') : $this->getFileType(), JSON_HEX_APOS)."'; |
|
137 | + Options.errorCode = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'errorCode') : $this->getErrorCode(), JSON_HEX_APOS)."'; |
|
138 | 138 | parent.Prado.WebUI.TActiveFileUpload.onFileUpload(Options); |
139 | 139 | </script>"; |
140 | 140 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @return string the path where the uploaded file will be stored temporarily, in namespace format |
147 | 147 | * default "Application.runtime.*" |
148 | 148 | */ |
149 | - public function getTempPath(){ |
|
149 | + public function getTempPath() { |
|
150 | 150 | return $this->getViewState('TempPath', 'Application.runtime.*'); |
151 | 151 | } |
152 | 152 | |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | * @param string the path where the uploaded file will be stored temporarily in namespace format |
155 | 155 | * default "Application.runtime.*" |
156 | 156 | */ |
157 | - public function setTempPath($value){ |
|
158 | - $this->setViewState('TempPath',$value,'Application.runtime.*'); |
|
157 | + public function setTempPath($value) { |
|
158 | + $this->setViewState('TempPath', $value, 'Application.runtime.*'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | 162 | * @return boolean a value indicating whether an automatic callback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to true. |
163 | 163 | * Note: When set to false, you will need to trigger the callback yourself. |
164 | 164 | */ |
165 | - public function getAutoPostBack(){ |
|
165 | + public function getAutoPostBack() { |
|
166 | 166 | return $this->getViewState('AutoPostBack', true); |
167 | 167 | } |
168 | 168 | |
@@ -170,28 +170,28 @@ discard block |
||
170 | 170 | * @param boolean a value indicating whether an automatic callback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to true. |
171 | 171 | * Note: When set to false, you will need to trigger the callback yourself. |
172 | 172 | */ |
173 | - public function setAutoPostBack($value){ |
|
174 | - $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),true); |
|
173 | + public function setAutoPostBack($value) { |
|
174 | + $this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), true); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | 178 | * @return string A chuck of javascript that will need to be called if {{@link getAutoPostBack AutoPostBack} is set to false} |
179 | 179 | */ |
180 | - public function getCallbackJavascript(){ |
|
180 | + public function getCallbackJavascript() { |
|
181 | 181 | return "Prado.WebUI.TActiveFileUpload.fileChanged(\"{$this->getClientID()}\")"; |
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | 185 | * @throws TInvalidDataValueException if the {@link getTempPath TempPath} is not writable. |
186 | 186 | */ |
187 | - public function onInit($sender){ |
|
187 | + public function onInit($sender) { |
|
188 | 188 | parent::onInit($sender); |
189 | 189 | |
190 | - if (!Prado::getApplication()->getCache()) |
|
191 | - if (!Prado::getApplication()->getSecurityManager()) |
|
190 | + if(!Prado::getApplication()->getCache()) |
|
191 | + if(!Prado::getApplication()->getSecurityManager()) |
|
192 | 192 | throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
193 | 193 | |
194 | - if (!is_writable(Prado::getPathOfNamespace($this->getTempPath()))){ |
|
194 | + if(!is_writable(Prado::getPathOfNamespace($this->getTempPath()))) { |
|
195 | 195 | throw new TInvalidDataValueException("activefileupload_temppath_invalid", $this->getTempPath()); |
196 | 196 | } |
197 | 197 | } |
@@ -203,18 +203,18 @@ discard block |
||
203 | 203 | * This method is mainly used by framework and control developers. |
204 | 204 | * @param TCallbackEventParameter the event parameter |
205 | 205 | */ |
206 | - public function raiseCallbackEvent($param){ |
|
207 | - $cp = $param->getCallbackParameter(); |
|
208 | - if ($key = $cp->targetID == $this->_target->getUniqueID()){ |
|
206 | + public function raiseCallbackEvent($param) { |
|
207 | + $cp=$param->getCallbackParameter(); |
|
208 | + if($key=$cp->targetID==$this->_target->getUniqueID()) { |
|
209 | 209 | |
210 | - $params = $this->popParamsByToken($cp->callbackToken); |
|
210 | + $params=$this->popParamsByToken($cp->callbackToken); |
|
211 | 211 | foreach($params->files as $index => $file) |
212 | 212 | { |
213 | - $_FILES[$key]['name'][$index] = stripslashes($file['fileName']); |
|
214 | - $_FILES[$key]['size'][$index] = intval($file['fileSize']); |
|
215 | - $_FILES[$key]['type'][$index] = $file['fileType']; |
|
216 | - $_FILES[$key]['error'][$index] = intval($file['errorCode']); |
|
217 | - $_FILES[$key]['tmp_name'][$index] = $file['localName']; |
|
213 | + $_FILES[$key]['name'][$index]=stripslashes($file['fileName']); |
|
214 | + $_FILES[$key]['size'][$index]=intval($file['fileSize']); |
|
215 | + $_FILES[$key]['type'][$index]=$file['fileType']; |
|
216 | + $_FILES[$key]['error'][$index]=intval($file['errorCode']); |
|
217 | + $_FILES[$key]['tmp_name'][$index]=$file['localName']; |
|
218 | 218 | } |
219 | 219 | $this->loadPostData($key, null); |
220 | 220 | |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | |
235 | 235 | protected function pushParamsAndGetToken(TActiveFileUploadCallbackParams $params) |
236 | 236 | { |
237 | - if ($cache = Prado::getApplication()->getCache()) |
|
237 | + if($cache=Prado::getApplication()->getCache()) |
|
238 | 238 | { |
239 | 239 | // this is the most secure method, file info can't be forged from client side, no matter what |
240 | - $token = md5('TActiveFileUpload::Params::'.$this->ClientID.'::'+rand(1000*1000,9999*1000)); |
|
241 | - $cache->set($token, serialize($params), 5*60); // expire in 5 minutes - the callback should arrive back in seconds, actually |
|
240 | + $token=md5('TActiveFileUpload::Params::'.$this->ClientID.'::'+rand(1000 * 1000, 9999 * 1000)); |
|
241 | + $cache->set($token, serialize($params), 5 * 60); // expire in 5 minutes - the callback should arrive back in seconds, actually |
|
242 | 242 | } |
243 | 243 | else |
244 | - if ($mgr = Prado::getApplication()->getSecurityManager()) |
|
244 | + if($mgr=Prado::getApplication()->getSecurityManager()) |
|
245 | 245 | { |
246 | 246 | // this is a less secure method, file info can be still forged from client side, but only if attacker knows the secret application key |
247 | - $token = urlencode(base64_encode($mgr->encrypt(serialize($params)))); |
|
247 | + $token=urlencode(base64_encode($mgr->encrypt(serialize($params)))); |
|
248 | 248 | } |
249 | 249 | else |
250 | 250 | throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | |
255 | 255 | protected function popParamsByToken($token) |
256 | 256 | { |
257 | - if ($cache = Prado::getApplication()->getCache()) |
|
257 | + if($cache=Prado::getApplication()->getCache()) |
|
258 | 258 | { |
259 | - $v = $cache->get($token); |
|
259 | + $v=$cache->get($token); |
|
260 | 260 | assert($v!=''); |
261 | 261 | $cache->delete($token); // remove it from cache so it can't be used again and won't take up space either |
262 | - $params = unserialize($v); |
|
262 | + $params=unserialize($v); |
|
263 | 263 | } |
264 | 264 | else |
265 | - if ($mgr = Prado::getApplication()->getSecurityManager()) |
|
265 | + if($mgr=Prado::getApplication()->getSecurityManager()) |
|
266 | 266 | { |
267 | - $v = $mgr->decrypt(base64_decode(urldecode($token))); |
|
268 | - $params = unserialize($v); |
|
267 | + $v=$mgr->decrypt(base64_decode(urldecode($token))); |
|
268 | + $params=unserialize($v); |
|
269 | 269 | } |
270 | 270 | else |
271 | 271 | throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
@@ -282,27 +282,27 @@ discard block |
||
282 | 282 | { |
283 | 283 | parent::onPreRender($param); |
284 | 284 | |
285 | - if(!$this->getPage()->getIsPostBack() && isset($_GET['TActiveFileUpload_InputId']) && isset($_GET['TActiveFileUpload_TargetId']) && $_GET['TActiveFileUpload_InputId'] == $this->getClientID()) |
|
285 | + if(!$this->getPage()->getIsPostBack() && isset($_GET['TActiveFileUpload_InputId']) && isset($_GET['TActiveFileUpload_TargetId']) && $_GET['TActiveFileUpload_InputId']==$this->getClientID()) |
|
286 | 286 | { |
287 | - $params = new TActiveFileUploadCallbackParams; |
|
288 | - foreach ($this->getFiles() as $file) { |
|
289 | - $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),'')); |
|
287 | + $params=new TActiveFileUploadCallbackParams; |
|
288 | + foreach($this->getFiles() as $file) { |
|
289 | + $localName=str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()), '')); |
|
290 | 290 | $file->setLocalName($localName); |
291 | 291 | // tricky workaround to intercept "uploaded file too big" error: real uploads happens in onFileUpload instead |
292 | 292 | $file->setErrorCode(UPLOAD_ERR_FORM_SIZE); |
293 | - $params->files[] = $file->toArray(); |
|
293 | + $params->files[]=$file->toArray(); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | echo "<script language='Javascript'> |
297 | 297 | Options = new Object(); |
298 | 298 | Options.clientID = '{$_GET['TActiveFileUpload_InputId']}'; |
299 | 299 | Options.targetID = '{$_GET['TActiveFileUpload_TargetId']}'; |
300 | - Options.errorCode = '" . (int)!$this->getHasAllFiles() . "'; |
|
300 | + Options.errorCode = '".(int) !$this->getHasAllFiles()."'; |
|
301 | 301 | Options.callbackToken = '{$this->pushParamsAndGetToken($params)}'; |
302 | - Options.fileName = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileName') : $this->getFileName(), JSON_HEX_APOS) . "'; |
|
303 | - Options.fileSize = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileSize') : $this->getFileSize(), JSON_HEX_APOS) . "'; |
|
304 | - Options.fileType = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileType') : $this->getFileType(), JSON_HEX_APOS) . "'; |
|
305 | - Options.errorCode = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'errorCode') : $this->getErrorCode(), JSON_HEX_APOS) . "'; |
|
302 | + Options.fileName = '".TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileName') : $this->getFileName(), JSON_HEX_APOS)."'; |
|
303 | + Options.fileSize = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileSize') : $this->getFileSize(), JSON_HEX_APOS)."'; |
|
304 | + Options.fileType = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileType') : $this->getFileType(), JSON_HEX_APOS)."'; |
|
305 | + Options.errorCode = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'errorCode') : $this->getErrorCode(), JSON_HEX_APOS)."'; |
|
306 | 306 | parent.Prado.WebUI.TActiveFileUpload.onFileUpload(Options); |
307 | 307 | </script>"; |
308 | 308 | } |
@@ -312,29 +312,29 @@ discard block |
||
312 | 312 | { |
313 | 313 | $this->getPage()->getClientScript()->registerPradoScript('activefileupload'); |
314 | 314 | |
315 | - $this->_flag = new THiddenField; |
|
315 | + $this->_flag=new THiddenField; |
|
316 | 316 | $this->_flag->setID('Flag'); |
317 | 317 | $this->getControls()->add($this->_flag); |
318 | 318 | |
319 | - $this->_busy = new TImage; |
|
319 | + $this->_busy=new TImage; |
|
320 | 320 | $this->_busy->setID('Busy'); |
321 | 321 | $this->_busy->setImageUrl($this->getAssetUrl('ActiveFileUploadIndicator.gif')); |
322 | 322 | $this->_busy->setStyle("display:none"); |
323 | 323 | $this->getControls()->add($this->_busy); |
324 | 324 | |
325 | - $this->_success = new TImage; |
|
325 | + $this->_success=new TImage; |
|
326 | 326 | $this->_success->setID('Success'); |
327 | 327 | $this->_success->setImageUrl($this->getAssetUrl('ActiveFileUploadComplete.png')); |
328 | 328 | $this->_success->setStyle("display:none"); |
329 | 329 | $this->getControls()->add($this->_success); |
330 | 330 | |
331 | - $this->_error = new TImage; |
|
331 | + $this->_error=new TImage; |
|
332 | 332 | $this->_error->setID('Error'); |
333 | 333 | $this->_error->setImageUrl($this->getAssetUrl('ActiveFileUploadError.png')); |
334 | 334 | $this->_error->setStyle("display:none"); |
335 | 335 | $this->getControls()->add($this->_error); |
336 | 336 | |
337 | - $this->_target = new TInlineFrame; |
|
337 | + $this->_target=new TInlineFrame; |
|
338 | 338 | $this->_target->setID('Target'); |
339 | 339 | $this->_target->setFrameUrl($this->getAssetUrl('ActiveFileUploadBlank.html')); |
340 | 340 | $this->_target->setStyle("width:0px; height:0px;"); |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | /** |
346 | 346 | * Removes localfile on ending of the callback. |
347 | 347 | */ |
348 | - public function onUnload($param){ |
|
349 | - if ($this->getPage()->getIsCallback()) |
|
348 | + public function onUnload($param) { |
|
349 | + if($this->getPage()->getIsCallback()) |
|
350 | 350 | { |
351 | 351 | foreach($this->getFiles() as $file) |
352 | - if($file->getHasFile() && file_exists($file->getLocalName())){ |
|
352 | + if($file->getHasFile() && file_exists($file->getLocalName())) { |
|
353 | 353 | unlink($file->getLocalName()); |
354 | 354 | } |
355 | 355 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | /** |
360 | 360 | * @return TBaseActiveCallbackControl standard callback control options. |
361 | 361 | */ |
362 | - public function getActiveControl(){ |
|
362 | + public function getActiveControl() { |
|
363 | 363 | return $this->getAdapter()->getBaseActiveControl(); |
364 | 364 | } |
365 | 365 | |
@@ -375,17 +375,17 @@ discard block |
||
375 | 375 | * Adds ID attribute, and renders the javascript for active component. |
376 | 376 | * @param THtmlWriter the writer used for the rendering purpose |
377 | 377 | */ |
378 | - public function addAttributesToRender($writer){ |
|
378 | + public function addAttributesToRender($writer) { |
|
379 | 379 | parent::addAttributesToRender($writer); |
380 | - $writer->addAttribute('id',$this->getClientID()); |
|
380 | + $writer->addAttribute('id', $this->getClientID()); |
|
381 | 381 | |
382 | - $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(),$this->getClientOptions()); |
|
382 | + $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getClientOptions()); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
386 | 386 | * @return string corresponding javascript class name for this control. |
387 | 387 | */ |
388 | - protected function getClientClassName(){ |
|
388 | + protected function getClientClassName() { |
|
389 | 389 | return 'Prado.WebUI.TActiveFileUpload'; |
390 | 390 | } |
391 | 391 | |
@@ -399,18 +399,18 @@ discard block |
||
399 | 399 | * completeID => complete client ID, |
400 | 400 | * errorID => error client ID) |
401 | 401 | */ |
402 | - protected function getClientOptions(){ |
|
403 | - $options['ID'] = $this->getClientID(); |
|
404 | - $options['EventTarget'] = $this->getUniqueID(); |
|
405 | - |
|
406 | - $options['inputID'] = $this->getClientID(); |
|
407 | - $options['flagID'] = $this->_flag->getClientID(); |
|
408 | - $options['targetID'] = $this->_target->getUniqueID(); |
|
409 | - $options['formID'] = $this->getPage()->getForm()->getClientID(); |
|
410 | - $options['indicatorID'] = $this->_busy->getClientID(); |
|
411 | - $options['completeID'] = $this->_success->getClientID(); |
|
412 | - $options['errorID'] = $this->_error->getClientID(); |
|
413 | - $options['autoPostBack'] = $this->getAutoPostBack(); |
|
402 | + protected function getClientOptions() { |
|
403 | + $options['ID']=$this->getClientID(); |
|
404 | + $options['EventTarget']=$this->getUniqueID(); |
|
405 | + |
|
406 | + $options['inputID']=$this->getClientID(); |
|
407 | + $options['flagID']=$this->_flag->getClientID(); |
|
408 | + $options['targetID']=$this->_target->getUniqueID(); |
|
409 | + $options['formID']=$this->getPage()->getForm()->getClientID(); |
|
410 | + $options['indicatorID']=$this->_busy->getClientID(); |
|
411 | + $options['completeID']=$this->_success->getClientID(); |
|
412 | + $options['errorID']=$this->_error->getClientID(); |
|
413 | + $options['autoPostBack']=$this->getAutoPostBack(); |
|
414 | 414 | return $options; |
415 | 415 | } |
416 | 416 | |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | * If true, you will not be able to save the uploaded file again. |
422 | 422 | * @return boolean true if the file saving is successful |
423 | 423 | */ |
424 | - public function saveAs($fileName,$deleteTempFile=true,$index=0){ |
|
425 | - if (($this->getErrorCode($index)===UPLOAD_ERR_OK) && (file_exists($this->getLocalName($index)))){ |
|
426 | - if ($deleteTempFile) |
|
427 | - return rename($this->getLocalName($index),$fileName); |
|
424 | + public function saveAs($fileName, $deleteTempFile=true, $index=0) { |
|
425 | + if(($this->getErrorCode($index)===UPLOAD_ERR_OK) && (file_exists($this->getLocalName($index)))) { |
|
426 | + if($deleteTempFile) |
|
427 | + return rename($this->getLocalName($index), $fileName); |
|
428 | 428 | else |
429 | - return copy($this->getLocalName($index),$fileName); |
|
429 | + return copy($this->getLocalName($index), $fileName); |
|
430 | 430 | } else |
431 | 431 | return false; |
432 | 432 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @return TImage the image displayed when an upload |
436 | 436 | * completes successfully. |
437 | 437 | */ |
438 | - public function getSuccessImage(){ |
|
438 | + public function getSuccessImage() { |
|
439 | 439 | $this->ensureChildControls(); |
440 | 440 | return $this->_success; |
441 | 441 | } |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @return TImage the image displayed when an upload |
445 | 445 | * does not complete successfully. |
446 | 446 | */ |
447 | - public function getErrorImage(){ |
|
447 | + public function getErrorImage() { |
|
448 | 448 | $this->ensureChildControls(); |
449 | 449 | return $this->_error; |
450 | 450 | } |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @return TImage the image displayed when an upload |
454 | 454 | * is in progress. |
455 | 455 | */ |
456 | - public function getBusyImage(){ |
|
456 | + public function getBusyImage() { |
|
457 | 457 | $this->ensureChildControls(); |
458 | 458 | return $this->_busy; |
459 | 459 | } |
@@ -127,8 +127,7 @@ discard block |
||
127 | 127 | $button->setCssClass($this->getButtonCssClass()); |
128 | 128 | return $button; |
129 | 129 | } |
130 | - } |
|
131 | - else if($buttonType===TPagerButtonType::ImageButton) |
|
130 | + } else if($buttonType===TPagerButtonType::ImageButton) |
|
132 | 131 | { |
133 | 132 | $button = new TActiveImageButton; |
134 | 133 | $button->setImageUrl($this->getPageImageUrl($text,$commandName)); |
@@ -136,8 +135,7 @@ discard block |
||
136 | 135 | $button->Visible = true; |
137 | 136 | else |
138 | 137 | $button->Visible = false; |
139 | - } |
|
140 | - else |
|
138 | + } else |
|
141 | 139 | { |
142 | 140 | $button=new TActiveButton; |
143 | 141 | if(!$enabled) |
@@ -197,8 +195,7 @@ discard block |
||
197 | 195 | TWebControl::render($writer); |
198 | 196 | if($this->getActiveControl()->canUpdateClientSide()) |
199 | 197 | $this->getPage()->getCallbackClient()->replaceContent($this,$writer); |
200 | - } |
|
201 | - else |
|
198 | + } else |
|
202 | 199 | { |
203 | 200 | $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
204 | 201 | } |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | ); |
104 | 104 | |
105 | 105 | $this->getControls()->add($list); |
106 | - $list->setDataSource(range(1,$this->getPageCount())); |
|
106 | + $list->setDataSource(range(1, $this->getPageCount())); |
|
107 | 107 | $list->dataBind(); |
108 | 108 | $list->setSelectedIndex($this->getCurrentPageIndex()); |
109 | 109 | $list->setAutoPostBack(true); |
110 | - $list->attachEventHandler('OnSelectedIndexChanged',array($this,'listIndexChanged')); |
|
110 | + $list->attachEventHandler('OnSelectedIndexChanged', array($this, 'listIndexChanged')); |
|
111 | 111 | $list->attachEventHandler('OnCallback', array($this, 'handleCallback')); |
112 | 112 | } |
113 | 113 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string CommandParameter corresponding to the OnCommand event of the button |
124 | 124 | * @return mixed the button instance |
125 | 125 | */ |
126 | - protected function createPagerButton($buttonType,$enabled,$text,$commandName,$commandParameter) |
|
126 | + protected function createPagerButton($buttonType, $enabled, $text, $commandName, $commandParameter) |
|
127 | 127 | { |
128 | 128 | if($buttonType===TPagerButtonType::LinkButton) |
129 | 129 | { |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | } |
140 | 140 | else if($buttonType===TPagerButtonType::ImageButton) |
141 | 141 | { |
142 | - $button = new TActiveImageButton; |
|
143 | - $button->setImageUrl($this->getPageImageUrl($text,$commandName)); |
|
142 | + $button=new TActiveImageButton; |
|
143 | + $button->setImageUrl($this->getPageImageUrl($text, $commandName)); |
|
144 | 144 | if($enabled) |
145 | - $button->Visible = true; |
|
145 | + $button->Visible=true; |
|
146 | 146 | else |
147 | - $button->Visible = false; |
|
147 | + $button->Visible=false; |
|
148 | 148 | } |
149 | 149 | else |
150 | 150 | { |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | if($buttonType===TPagerButtonType::ImageButton) |
157 | 157 | { |
158 | - $button->ImageUrl = $text; |
|
158 | + $button->ImageUrl=$text; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $button->setText($text); |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | * @param mixed $sender |
180 | 180 | * @param TCallbackEventParameter $param |
181 | 181 | */ |
182 | - public function handleCallback ($sender,$param) |
|
182 | + public function handleCallback($sender, $param) |
|
183 | 183 | { |
184 | 184 | // Update all the buttons pagers attached to the same control. |
185 | 185 | // Dropdown pagers doesn't need to be re-rendered. |
186 | 186 | $controlToPaginate=$this->getControlToPaginate(); |
187 | - foreach ($this->getNamingContainer()->findControlsByType('Prado\Web\UI\ActiveControls\TActivePager', false) as $control) |
|
187 | + foreach($this->getNamingContainer()->findControlsByType('Prado\Web\UI\ActiveControls\TActivePager', false) as $control) |
|
188 | 188 | { |
189 | - if ($control->getMode() !== TPagerMode::DropDownList && $control->getControlToPaginate()===$controlToPaginate) |
|
189 | + if($control->getMode()!==TPagerMode::DropDownList && $control->getControlToPaginate()===$controlToPaginate) |
|
190 | 190 | { |
191 | 191 | $control->render($param->getNewWriter()); |
192 | 192 | // FIXME : With some very fast machine, the getNewWriter() consecutive calls are in the same microsecond, resulting |
@@ -198,18 +198,18 @@ discard block |
||
198 | 198 | $this->onCallback($param); |
199 | 199 | } |
200 | 200 | |
201 | - public function render ($writer) |
|
201 | + public function render($writer) |
|
202 | 202 | { |
203 | 203 | if($this->getHasPreRendered()) |
204 | 204 | { |
205 | - $this->setDisplay(($this->getPageCount()==1)?TDisplayStyle::None:TDisplayStyle::Dynamic); |
|
205 | + $this->setDisplay(($this->getPageCount()==1) ?TDisplayStyle::None : TDisplayStyle::Dynamic); |
|
206 | 206 | TWebControl::render($writer); |
207 | 207 | if($this->getActiveControl()->canUpdateClientSide()) |
208 | - $this->getPage()->getCallbackClient()->replaceContent($this,$writer); |
|
208 | + $this->getPage()->getCallbackClient()->replaceContent($this, $writer); |
|
209 | 209 | } |
210 | 210 | else |
211 | 211 | { |
212 | - $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
|
212 | + $this->getPage()->getAdapter()->registerControlToRender($this, $writer); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | } |
@@ -174,14 +174,12 @@ |
||
174 | 174 | { |
175 | 175 | $parameter = new TAutoCompleteEventParameter($this->getResponse(), $token[0]); |
176 | 176 | $this->onSuggest($parameter); |
177 | - } |
|
178 | - else if($token[1] === '__TAutoComplete_onSuggestionSelected__') |
|
177 | + } else if($token[1] === '__TAutoComplete_onSuggestionSelected__') |
|
179 | 178 | { |
180 | 179 | $parameter = new TAutoCompleteEventParameter($this->getResponse(), null, $token[0]); |
181 | 180 | $this->onSuggestionSelected($parameter); |
182 | 181 | } |
183 | - } |
|
184 | - else if($this->getAutoPostBack()) |
|
182 | + } else if($this->getAutoPostBack()) |
|
185 | 183 | parent::raiseCallbackEvent($param); |
186 | 184 | } |
187 | 185 |
@@ -201,6 +201,7 @@ discard block |
||
201 | 201 | * method, be sure to call the parent implementation so that the event |
202 | 202 | * handler can be invoked. |
203 | 203 | * @param TCallbackEventParameter event parameter to be passed to the event handlers |
204 | + * @param TAutoCompleteEventParameter $param |
|
204 | 205 | */ |
205 | 206 | public function onSuggest($param) |
206 | 207 | { |
@@ -213,6 +214,7 @@ discard block |
||
213 | 214 | * method, be sure to call the parent implementation so that the event |
214 | 215 | * handler can be invoked. |
215 | 216 | * @param TCallbackEventParameter event parameter to be passed to the event handlers |
217 | + * @param TAutoCompleteEventParameter $param |
|
216 | 218 | */ |
217 | 219 | public function onSuggestionSelected($param) |
218 | 220 | { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function setFrequency($value) |
132 | 132 | { |
133 | - $this->setViewState('frequency', TPropertyValue::ensureFloat($value),''); |
|
133 | + $this->setViewState('frequency', TPropertyValue::ensureFloat($value), ''); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function getMinChars() |
140 | 140 | { |
141 | - return $this->getViewState('minChars',''); |
|
141 | + return $this->getViewState('minChars', ''); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -177,17 +177,17 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function raiseCallbackEvent($param) |
179 | 179 | { |
180 | - $token = $param->getCallbackParameter(); |
|
181 | - if(is_array($token) && count($token) == 2) |
|
180 | + $token=$param->getCallbackParameter(); |
|
181 | + if(is_array($token) && count($token)==2) |
|
182 | 182 | { |
183 | - if($token[1] === '__TAutoComplete_onSuggest__') |
|
183 | + if($token[1]==='__TAutoComplete_onSuggest__') |
|
184 | 184 | { |
185 | - $parameter = new TAutoCompleteEventParameter($this->getResponse(), $token[0]); |
|
185 | + $parameter=new TAutoCompleteEventParameter($this->getResponse(), $token[0]); |
|
186 | 186 | $this->onSuggest($parameter); |
187 | 187 | } |
188 | - else if($token[1] === '__TAutoComplete_onSuggestionSelected__') |
|
188 | + else if($token[1]==='__TAutoComplete_onSuggestionSelected__') |
|
189 | 189 | { |
190 | - $parameter = new TAutoCompleteEventParameter($this->getResponse(), null, $token[0]); |
|
190 | + $parameter=new TAutoCompleteEventParameter($this->getResponse(), null, $token[0]); |
|
191 | 191 | $this->onSuggestionSelected($parameter); |
192 | 192 | } |
193 | 193 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | public function getResultPanel() |
245 | 245 | { |
246 | 246 | if($this->_resultPanel===null) |
247 | - $this->_resultPanel = $this->createResultPanel(); |
|
247 | + $this->_resultPanel=$this->createResultPanel(); |
|
248 | 248 | return $this->_resultPanel; |
249 | 249 | } |
250 | 250 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | protected function createResultPanel() |
255 | 255 | { |
256 | - $panel = new TPanel; |
|
256 | + $panel=new TPanel; |
|
257 | 257 | $this->getControls()->add($panel); |
258 | 258 | $panel->setID('result'); |
259 | 259 | return $panel; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | public function getSuggestions() |
266 | 266 | { |
267 | 267 | if($this->_repeater===null) |
268 | - $this->_repeater = $this->createRepeater(); |
|
268 | + $this->_repeater=$this->createRepeater(); |
|
269 | 269 | return $this->_repeater; |
270 | 270 | } |
271 | 271 | |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | */ |
275 | 275 | protected function createRepeater() |
276 | 276 | { |
277 | - $repeater = new TRepeater; |
|
277 | + $repeater=new TRepeater; |
|
278 | 278 | $repeater->setHeaderTemplate(new TAutoCompleteTemplate('<ul>')); |
279 | 279 | $repeater->setFooterTemplate(new TAutoCompleteTemplate('</ul>')); |
280 | - $repeater->setItemTemplate(new TTemplate('<li><%# $this->DataItem %></li>',null)); |
|
280 | + $repeater->setItemTemplate(new TTemplate('<li><%# $this->DataItem %></li>', null)); |
|
281 | 281 | $repeater->setEmptyTemplate(new TAutoCompleteTemplate('<ul></ul>')); |
282 | 282 | $this->getControls()->add($repeater); |
283 | 283 | return $repeater; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | if($this->getActiveControl()->canUpdateClientSide()) |
322 | 322 | { |
323 | 323 | $this->getSuggestions()->render($writer); |
324 | - $boundary = $writer->getWriter()->getBoundary(); |
|
324 | + $boundary=$writer->getWriter()->getBoundary(); |
|
325 | 325 | $this->getResponse()->getAdapter()->setResponseData($boundary); |
326 | 326 | } |
327 | 327 | } |
@@ -333,29 +333,29 @@ discard block |
||
333 | 333 | { |
334 | 334 | //disallow page state update ? |
335 | 335 | //$this->getActiveControl()->getClientSide()->setEnablePageStateUpdate(false); |
336 | - $options = array(); |
|
337 | - if(strlen($string = $this->getSeparator())) |
|
336 | + $options=array(); |
|
337 | + if(strlen($string=$this->getSeparator())) |
|
338 | 338 | { |
339 | - $string = strtr($string,array('\t'=>"\t",'\n'=>"\n",'\r'=>"\r")); |
|
340 | - $token = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY); |
|
341 | - $options['tokens'] = $token; |
|
339 | + $string=strtr($string, array('\t'=>"\t", '\n'=>"\n", '\r'=>"\r")); |
|
340 | + $token=preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY); |
|
341 | + $options['tokens']=$token; |
|
342 | 342 | } |
343 | 343 | if($this->getAutoPostBack()) |
344 | 344 | { |
345 | - $options = array_merge($options,parent::getPostBackOptions()); |
|
346 | - $options['AutoPostBack'] = true; |
|
345 | + $options=array_merge($options, parent::getPostBackOptions()); |
|
346 | + $options['AutoPostBack']=true; |
|
347 | 347 | } |
348 | - if(strlen($select = $this->getTextCssClass())) |
|
349 | - $options['select'] = $select; |
|
350 | - $options['ResultPanel'] = $this->getResultPanel()->getClientID(); |
|
351 | - $options['ID'] = $this->getClientID(); |
|
352 | - $options['EventTarget'] = $this->getUniqueID(); |
|
348 | + if(strlen($select=$this->getTextCssClass())) |
|
349 | + $options['select']=$select; |
|
350 | + $options['ResultPanel']=$this->getResultPanel()->getClientID(); |
|
351 | + $options['ID']=$this->getClientID(); |
|
352 | + $options['EventTarget']=$this->getUniqueID(); |
|
353 | 353 | if(($minchars=$this->getMinChars())!=='') |
354 | - $options['minChars'] = $minchars; |
|
354 | + $options['minChars']=$minchars; |
|
355 | 355 | if(($frequency=$this->getFrequency())!=='') |
356 | - $options['frequency'] = $frequency; |
|
357 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
358 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
356 | + $options['frequency']=$frequency; |
|
357 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
358 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
359 | 359 | return $options; |
360 | 360 | } |
361 | 361 |
@@ -95,8 +95,7 @@ |
||
95 | 95 | if($this->getHasPreRendered()) { |
96 | 96 | $this->renderRepeater($writer); |
97 | 97 | if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(),$writer); |
98 | - } |
|
99 | - else { |
|
98 | + } else { |
|
100 | 99 | $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
101 | 100 | } |
102 | 101 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | parent::setDataSource($value); |
58 | 58 | if($this->getActiveControl()->canUpdateClientSide()) { |
59 | 59 | $this->renderPager(); |
60 | - $this->getPage()->getAdapter()->registerControlToRender($this,$this->getResponse()->createHtmlWriter()); |
|
60 | + $this->getPage()->getAdapter()->registerControlToRender($this, $this->getResponse()->createHtmlWriter()); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | public function render($writer) { |
95 | 95 | if($this->getHasPreRendered()) { |
96 | 96 | $this->renderRepeater($writer); |
97 | - if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(),$writer); |
|
97 | + if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(), $writer); |
|
98 | 98 | } |
99 | 99 | else { |
100 | - $this->getPage()->getAdapter()->registerControlToRender($this,$writer); |
|
100 | + $this->getPage()->getAdapter()->registerControlToRender($this, $writer); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | foreach($pager as $item) { |
112 | 112 | if($item->ControlToPaginate==$this->ID) { |
113 | 113 | $writer=$this->getResponse()->createHtmlWriter(); |
114 | - $this->getPage()->getAdapter()->registerControlToRender($item,$writer); |
|
114 | + $this->getPage()->getAdapter()->registerControlToRender($item, $writer); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param THtmlWriter writer for the rendering purpose |
124 | 124 | */ |
125 | 125 | private function renderRepeater($writer) { |
126 | - $writer->addAttribute('id',$this->getSurroundingTagID()); |
|
126 | + $writer->addAttribute('id', $this->getSurroundingTagID()); |
|
127 | 127 | $writer->renderBeginTag($this->getSurroundingTag()); |
128 | 128 | parent::render($writer); |
129 | 129 | $writer->renderEndTag(); |