@@ -179,7 +179,7 @@ |
||
179 | 179 | * Returns the value of the TSlider control. |
180 | 180 | * This method is required by {@link IDataRenderer}. |
181 | 181 | * It is the same as {@link getValue()}. |
182 | - * @return string the value of the TSlider control. |
|
182 | + * @return double the value of the TSlider control. |
|
183 | 183 | * @see getValue |
184 | 184 | */ |
185 | 185 | public function getData() |
@@ -189,8 +189,7 @@ discard block |
||
189 | 189 | return file_put_contents($fileName,file_get_contents($this->_localName))!==false; |
190 | 190 | else |
191 | 191 | return false; |
192 | - } |
|
193 | - else |
|
192 | + } else |
|
194 | 193 | return false; |
195 | 194 | } |
196 | 195 | |
@@ -211,8 +210,7 @@ discard block |
||
211 | 210 | $this->_errorCode=$_FILES[$key]['error']; |
212 | 211 | $this->_localName=$_FILES[$key]['tmp_name']; |
213 | 212 | return $this->_dataChanged=true; |
214 | - } |
|
215 | - else |
|
213 | + } else |
|
216 | 214 | return false; |
217 | 215 | } |
218 | 216 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setDirection($value) |
78 | 78 | { |
79 | - $this->setViewState('Direction', TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TSliderDirection'),TSliderDirection::Horizontal); |
|
79 | + $this->setViewState('Direction', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TSliderDirection'), TSliderDirection::Horizontal); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getCssUrl() |
86 | 86 | { |
87 | - return $this->getViewState('CssUrl',''); |
|
87 | + return $this->getViewState('CssUrl', ''); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function setCssUrl($value) |
94 | 94 | { |
95 | - $this->setViewState('CssUrl',TPropertyValue::ensureString($value),''); |
|
95 | + $this->setViewState('CssUrl', TPropertyValue::ensureString($value), ''); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function getMaxValue() |
102 | 102 | { |
103 | - return $this->getViewState('MaxValue',100.0); |
|
103 | + return $this->getViewState('MaxValue', 100.0); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function setMaxValue($value) |
110 | 110 | { |
111 | - $this->setViewState('MaxValue', TPropertyValue::ensureFloat($value),100.0); |
|
111 | + $this->setViewState('MaxValue', TPropertyValue::ensureFloat($value), 100.0); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function getMinValue() |
118 | 118 | { |
119 | - return $this->getViewState('MinValue',0.0); |
|
119 | + return $this->getViewState('MinValue', 0.0); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function setMinValue($value) |
126 | 126 | { |
127 | - $this->setViewState('MinValue', TPropertyValue::ensureFloat($value),0.0); |
|
127 | + $this->setViewState('MinValue', TPropertyValue::ensureFloat($value), 0.0); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * @return boolean wether to display a progress indicator or not. Defaults to true. |
152 | 152 | */ |
153 | - public function getProgressIndicator () |
|
153 | + public function getProgressIndicator() |
|
154 | 154 | { |
155 | 155 | return $this->getViewState('ProgressIndicator', true); |
156 | 156 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * @param boolean wether to display a progress indicator or not. Defaults to true. |
160 | 160 | */ |
161 | - public function setProgressIndicator ($value) |
|
161 | + public function setProgressIndicator($value) |
|
162 | 162 | { |
163 | 163 | $this->setViewState('ProgressIndicator', TPropertyValue::ensureBoolean($value), true); |
164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getValue() |
169 | 169 | { |
170 | - return $this->getViewState('Value',0.0); |
|
170 | + return $this->getViewState('Value', 0.0); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function setValue($value) |
177 | 177 | { |
178 | - $this->setViewState('Value', TPropertyValue::ensureFloat($value),0.0); |
|
178 | + $this->setViewState('Value', TPropertyValue::ensureFloat($value), 0.0); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function getAutoPostBack() |
229 | 229 | { |
230 | - return $this->getViewState('AutoPostBack',false); |
|
230 | + return $this->getViewState('AutoPostBack', false); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function setAutoPostBack($value) |
240 | 240 | { |
241 | - $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),false); |
|
241 | + $this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), false); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function onValueChanged($param) |
285 | 285 | { |
286 | - $this->raiseEvent('OnValueChanged',$this,$param); |
|
286 | + $this->raiseEvent('OnValueChanged', $this, $param); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | * @param array the input data collection |
294 | 294 | * @return boolean whether the data of the component has been changed |
295 | 295 | */ |
296 | - public function loadPostData($key,$values) |
|
296 | + public function loadPostData($key, $values) |
|
297 | 297 | { |
298 | - $value=(float)$values[$this->getClientID().'_1']; |
|
298 | + $value=(float) $values[$this->getClientID().'_1']; |
|
299 | 299 | if($this->getValue()!==$value) |
300 | 300 | { |
301 | 301 | $this->setValue($value); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | public function getClientSide() |
320 | 320 | { |
321 | 321 | if($this->_clientScript===null) |
322 | - $this->_clientScript = $this->createClientScript(); |
|
322 | + $this->_clientScript=$this->createClientScript(); |
|
323 | 323 | return $this->_clientScript; |
324 | 324 | } |
325 | 325 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | /** |
335 | 335 | * @return string the HTML tag name for slider. Defaults to div. |
336 | 336 | */ |
337 | - public function getTagName () |
|
337 | + public function getTagName() |
|
338 | 338 | { |
339 | 339 | return "div"; |
340 | 340 | } |
@@ -346,10 +346,10 @@ discard block |
||
346 | 346 | protected function addAttributesToRender($writer) |
347 | 347 | { |
348 | 348 | parent::addAttributesToRender($writer); |
349 | - $writer->addAttribute('id',$this->getClientID()); |
|
350 | - if ($this->getCssClass()==='') |
|
349 | + $writer->addAttribute('id', $this->getClientID()); |
|
350 | + if($this->getCssClass()==='') |
|
351 | 351 | { |
352 | - $class=($this->getDirection()==TSliderDirection::Horizontal)?'HorizontalSlider':'VerticalSlider'; |
|
352 | + $class=($this->getDirection()==TSliderDirection::Horizontal) ? 'HorizontalSlider' : 'VerticalSlider'; |
|
353 | 353 | $writer->addAttribute('class', 'Slider '.$class); |
354 | 354 | } |
355 | 355 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $writer->addAttribute('id', $this->getClientID().'_track'); |
366 | 366 | $writer->renderBeginTag('div'); |
367 | 367 | // Render the 'Progress Indicator' |
368 | - if ($this->getProgressIndicator()) |
|
368 | + if($this->getProgressIndicator()) |
|
369 | 369 | { |
370 | 370 | $writer->addAttribute('class', 'Progress'); |
371 | 371 | $writer->addAttribute('id', $this->getClientID().'_progress'); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * This method is invoked right before the control rendering, if the control is visible. |
403 | 403 | * @param mixed event parameter |
404 | 404 | */ |
405 | - public function onPreRender ($param) |
|
405 | + public function onPreRender($param) |
|
406 | 406 | { |
407 | 407 | parent::onPreRender($param); |
408 | 408 | $this->registerStyleSheet(); |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $url=$manager->publishFilePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'TSlider'); |
425 | 425 | $url.='/TSlider.css'; |
426 | 426 | } |
427 | - $this->getPage()->getClientScript()->registerStyleSheetFile($url,$url); |
|
427 | + $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -433,12 +433,12 @@ discard block |
||
433 | 433 | protected function registerSliderClientScript() |
434 | 434 | { |
435 | 435 | $page=$this->getPage(); |
436 | - $cs = $page->getClientScript(); |
|
436 | + $cs=$page->getClientScript(); |
|
437 | 437 | $cs->registerPradoScript("slider"); |
438 | 438 | $id=$this->getClientID(); |
439 | - $cs->registerHiddenField($id.'_1',$this->getValue()); |
|
439 | + $cs->registerHiddenField($id.'_1', $this->getValue()); |
|
440 | 440 | $page->registerRequiresPostData($this); |
441 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getSliderOptions()); |
|
441 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getSliderOptions()); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -448,30 +448,30 @@ discard block |
||
448 | 448 | protected function getSliderOptions() |
449 | 449 | { |
450 | 450 | // PostBack Options : |
451 | - $options['ID'] = $this->getClientID(); |
|
452 | - $options['EventTarget'] = $this->getUniqueID(); |
|
453 | - $options['AutoPostBack'] = $this->getAutoPostBack(); |
|
451 | + $options['ID']=$this->getClientID(); |
|
452 | + $options['EventTarget']=$this->getUniqueID(); |
|
453 | + $options['AutoPostBack']=$this->getAutoPostBack(); |
|
454 | 454 | |
455 | 455 | // Slider Control options |
456 | 456 | $minValue=$this->getMinValue(); |
457 | 457 | $maxValue=$this->getMaxValue(); |
458 | - $options['axis'] = strtolower($this->getDirection()); |
|
459 | - $options['maximum'] = $maxValue; |
|
460 | - $options['minimum'] = $minValue; |
|
461 | - $options['range'] = array($minValue, $maxValue); |
|
462 | - $options['sliderValue'] = $this->getValue(); |
|
463 | - $options['disabled'] = !$this->getEnabled(); |
|
458 | + $options['axis']=strtolower($this->getDirection()); |
|
459 | + $options['maximum']=$maxValue; |
|
460 | + $options['minimum']=$minValue; |
|
461 | + $options['range']=array($minValue, $maxValue); |
|
462 | + $options['sliderValue']=$this->getValue(); |
|
463 | + $options['disabled']=!$this->getEnabled(); |
|
464 | 464 | $values=$this->getValues(); |
465 | - if (!empty($values)) |
|
465 | + if(!empty($values)) |
|
466 | 466 | { |
467 | 467 | // Values are provided. Check if min/max are present in them |
468 | - if (!in_array($minValue, $values)) $values[]=$minValue; |
|
469 | - if (!in_array($maxValue, $values)) $values[]=$maxValue; |
|
468 | + if(!in_array($minValue, $values)) $values[]=$minValue; |
|
469 | + if(!in_array($maxValue, $values)) $values[]=$maxValue; |
|
470 | 470 | // Remove all values outsize the range [min..max] |
471 | - foreach ($values as $idx=>$value) |
|
471 | + foreach($values as $idx=>$value) |
|
472 | 472 | { |
473 | - if ($value < $minValue) unset ($values[$idx]); |
|
474 | - if ($value > $maxValue) unset ($values[$idx]); |
|
473 | + if($value < $minValue) unset ($values[$idx]); |
|
474 | + if($value > $maxValue) unset ($values[$idx]); |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | else |
@@ -479,19 +479,19 @@ discard block |
||
479 | 479 | // Values are not provided, generate automatically using stepsize |
480 | 480 | $step=$this->getStepSize(); |
481 | 481 | // We want at most self::MAX_STEPS values, so, change the step if necessary |
482 | - if (($maxValue-$minValue)/$step > self::MAX_STEPS) |
|
482 | + if(($maxValue - $minValue) / $step > self::MAX_STEPS) |
|
483 | 483 | { |
484 | - $step=($maxValue-$minValue)/self::MAX_STEPS; |
|
484 | + $step=($maxValue - $minValue) / self::MAX_STEPS; |
|
485 | 485 | } |
486 | 486 | $values=array(); |
487 | - for ($i=$minValue;$i<=$maxValue;$i+=$step) |
|
487 | + for($i=$minValue; $i <= $maxValue; $i+=$step) |
|
488 | 488 | $values[]=$i; |
489 | 489 | // Add max if it's not in the array because of step |
490 | - if (!in_array($maxValue, $values)) $values[]=$maxValue; |
|
490 | + if(!in_array($maxValue, $values)) $values[]=$maxValue; |
|
491 | 491 | } |
492 | - $options['values'] = $values; |
|
492 | + $options['values']=$values; |
|
493 | 493 | if($this->_clientScript!==null) |
494 | - $options = array_merge($options,$this->_clientScript->getOptions()->toArray()); |
|
494 | + $options=array_merge($options, $this->_clientScript->getOptions()->toArray()); |
|
495 | 495 | return $options; |
496 | 496 | } |
497 | 497 | } |
498 | 498 | \ No newline at end of file |
@@ -144,6 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @param string table caption |
147 | + * @param string $value |
|
147 | 148 | */ |
148 | 149 | public function setCaption($value) |
149 | 150 | { |
@@ -160,6 +161,7 @@ discard block |
||
160 | 161 | |
161 | 162 | /** |
162 | 163 | * @param TTableCaptionAlign table caption alignment. |
164 | + * @param TTableCaptionAlign $value |
|
163 | 165 | */ |
164 | 166 | public function setCaptionAlign($value) |
165 | 167 | { |
@@ -306,8 +306,7 @@ discard block |
||
306 | 306 | { |
307 | 307 | if($index===0 && $currentSection===TTableRowSection::Header) |
308 | 308 | $writer->renderBeginTag('thead'); |
309 | - } |
|
310 | - else |
|
309 | + } else |
|
311 | 310 | { |
312 | 311 | if($currentSection===TTableRowSection::Header) |
313 | 312 | { |
@@ -318,8 +317,7 @@ discard block |
||
318 | 317 | else |
319 | 318 | $writer->renderBeginTag('tfoot'); |
320 | 319 | $currentSection=$section; |
321 | - } |
|
322 | - else if($currentSection===TTableRowSection::Body) |
|
320 | + } else if($currentSection===TTableRowSection::Body) |
|
323 | 321 | { |
324 | 322 | $writer->renderEndTag(); |
325 | 323 | if($section===TTableRowSection::Footer) |
@@ -327,16 +325,14 @@ discard block |
||
327 | 325 | else |
328 | 326 | throw new TConfigurationException('table_tablesection_outoforder'); |
329 | 327 | $currentSection=$section; |
330 | - } |
|
331 | - else // Footer |
|
328 | + } else // Footer |
|
332 | 329 | throw new TConfigurationException('table_tablesection_outoforder'); |
333 | 330 | } |
334 | 331 | $row->renderControl($writer); |
335 | 332 | $writer->writeLine(); |
336 | 333 | } |
337 | 334 | $writer->renderEndTag(); |
338 | - } |
|
339 | - else |
|
335 | + } else |
|
340 | 336 | { |
341 | 337 | $writer->writeLine(); |
342 | 338 | foreach($this->getControls() as $row) |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | if(($border=$this->getBorderWidth())==='') |
110 | 110 | $border=1; |
111 | 111 | else |
112 | - $border=(int)$border; |
|
112 | + $border=(int) $border; |
|
113 | 113 | } |
114 | 114 | } |
115 | - $writer->addAttribute('border',"$border"); |
|
115 | + $writer->addAttribute('border', "$border"); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function getCaption() |
140 | 140 | { |
141 | - return $this->getViewState('Caption',''); |
|
141 | + return $this->getViewState('Caption', ''); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function setCaption($value) |
148 | 148 | { |
149 | - $this->setViewState('Caption',$value,''); |
|
149 | + $this->setViewState('Caption', $value, ''); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function getCaptionAlign() |
156 | 156 | { |
157 | - return $this->getViewState('CaptionAlign',TTableCaptionAlign::NotSet); |
|
157 | + return $this->getViewState('CaptionAlign', TTableCaptionAlign::NotSet); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function setCaptionAlign($value) |
164 | 164 | { |
165 | - $this->setViewState('CaptionAlign',TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TTableCaptionAlign'),TTableCaptionAlign::NotSet); |
|
165 | + $this->setViewState('CaptionAlign', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TTableCaptionAlign'), TTableCaptionAlign::NotSet); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | if(($caption=$this->getCaption())!=='') |
272 | 272 | { |
273 | 273 | if(($align=$this->getCaptionAlign())!==TTableCaptionAlign::NotSet) |
274 | - $writer->addAttribute('align',strtolower($align)); |
|
274 | + $writer->addAttribute('align', strtolower($align)); |
|
275 | 275 | $writer->renderBeginTag('caption'); |
276 | 276 | $writer->write($caption); |
277 | 277 | $writer->renderEndTag(); |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | { |
311 | 311 | if($currentSection===TTableRowSection::Header) |
312 | 312 | { |
313 | - if($index>0) |
|
313 | + if($index > 0) |
|
314 | 314 | $writer->renderEndTag(); |
315 | 315 | if($section===TTableRowSection::Body) |
316 | 316 | $writer->renderBeginTag('tbody'); |
@@ -118,7 +118,7 @@ |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | - * @return ITemplate the item template |
|
121 | + * @return string the item template |
|
122 | 122 | */ |
123 | 123 | public function getItemTemplate() |
124 | 124 | { |
@@ -197,8 +197,7 @@ discard block |
||
197 | 197 | $classPath=$this->getItemRenderer(); |
198 | 198 | $template=$this->_itemTemplate; |
199 | 199 | } |
200 | - } |
|
201 | - else |
|
200 | + } else |
|
202 | 201 | { |
203 | 202 | $template=$this->_itemTemplate; |
204 | 203 | $classPath=$this->getItemRenderer(); |
@@ -214,13 +213,11 @@ discard block |
||
214 | 213 | } |
215 | 214 | if($control instanceof IDataRenderer) |
216 | 215 | $control->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); |
217 | - } |
|
218 | - else if($template!==null) |
|
216 | + } else if($template!==null) |
|
219 | 217 | $template->instantiateIn($cell); |
220 | 218 | else if($itemType!==TListItemType::EditItem) |
221 | 219 | $cell->setText(' '); |
222 | - } |
|
223 | - else if($itemType===TListItemType::Header) |
|
220 | + } else if($itemType===TListItemType::Header) |
|
224 | 221 | { |
225 | 222 | if(($classPath=$this->getHeaderRenderer())!=='') |
226 | 223 | $this->initializeHeaderCell($cell,$columnIndex); |
@@ -228,8 +225,7 @@ discard block |
||
228 | 225 | $this->_headerTemplate->instantiateIn($cell); |
229 | 226 | else |
230 | 227 | $this->initializeHeaderCell($cell,$columnIndex); |
231 | - } |
|
232 | - else if($itemType===TListItemType::Footer) |
|
228 | + } else if($itemType===TListItemType::Footer) |
|
233 | 229 | { |
234 | 230 | if(($classPath=$this->getFooterRenderer())!=='') |
235 | 231 | $this->initializeFooterCell($cell,$columnIndex); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getItemRenderer() |
55 | 55 | { |
56 | - return $this->getViewState('ItemRenderer',''); |
|
56 | + return $this->getViewState('ItemRenderer', ''); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function setItemRenderer($value) |
71 | 71 | { |
72 | - $this->setViewState('ItemRenderer',$value,''); |
|
72 | + $this->setViewState('ItemRenderer', $value, ''); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getEditItemRenderer() |
80 | 80 | { |
81 | - return $this->getViewState('EditItemRenderer',''); |
|
81 | + return $this->getViewState('EditItemRenderer', ''); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function setEditItemRenderer($value) |
96 | 96 | { |
97 | - $this->setViewState('EditItemRenderer',$value,''); |
|
97 | + $this->setViewState('EditItemRenderer', $value, ''); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | if($value instanceof ITemplate || $value===null) |
115 | 115 | $this->_editItemTemplate=$value; |
116 | 116 | else |
117 | - throw new TInvalidDataTypeException('templatecolumn_template_required','EditItemTemplate'); |
|
117 | + throw new TInvalidDataTypeException('templatecolumn_template_required', 'EditItemTemplate'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | if($value instanceof ITemplate || $value===null) |
135 | 135 | $this->_itemTemplate=$value; |
136 | 136 | else |
137 | - throw new TInvalidDataTypeException('templatecolumn_template_required','ItemTemplate'); |
|
137 | + throw new TInvalidDataTypeException('templatecolumn_template_required', 'ItemTemplate'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | if($value instanceof ITemplate || $value===null) |
155 | 155 | $this->_headerTemplate=$value; |
156 | 156 | else |
157 | - throw new TInvalidDataTypeException('templatecolumn_template_required','HeaderTemplate'); |
|
157 | + throw new TInvalidDataTypeException('templatecolumn_template_required', 'HeaderTemplate'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | if($value instanceof ITemplate || $value===null) |
175 | 175 | $this->_footerTemplate=$value; |
176 | 176 | else |
177 | - throw new TInvalidDataTypeException('templatecolumn_template_required','FooterTemplate'); |
|
177 | + throw new TInvalidDataTypeException('templatecolumn_template_required', 'FooterTemplate'); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param integer the index to the Columns property that the cell resides in. |
187 | 187 | * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem) |
188 | 188 | */ |
189 | - public function initializeCell($cell,$columnIndex,$itemType) |
|
189 | + public function initializeCell($cell, $columnIndex, $itemType) |
|
190 | 190 | { |
191 | 191 | if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) |
192 | 192 | { |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $control->setItemType($itemType); |
214 | 214 | } |
215 | 215 | if($control instanceof IDataRenderer) |
216 | - $control->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); |
|
216 | + $control->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn')); |
|
217 | 217 | } |
218 | 218 | else if($template!==null) |
219 | 219 | $template->instantiateIn($cell); |
@@ -223,20 +223,20 @@ discard block |
||
223 | 223 | else if($itemType===TListItemType::Header) |
224 | 224 | { |
225 | 225 | if(($classPath=$this->getHeaderRenderer())!=='') |
226 | - $this->initializeHeaderCell($cell,$columnIndex); |
|
226 | + $this->initializeHeaderCell($cell, $columnIndex); |
|
227 | 227 | else if($this->_headerTemplate!==null) |
228 | 228 | $this->_headerTemplate->instantiateIn($cell); |
229 | 229 | else |
230 | - $this->initializeHeaderCell($cell,$columnIndex); |
|
230 | + $this->initializeHeaderCell($cell, $columnIndex); |
|
231 | 231 | } |
232 | 232 | else if($itemType===TListItemType::Footer) |
233 | 233 | { |
234 | 234 | if(($classPath=$this->getFooterRenderer())!=='') |
235 | - $this->initializeFooterCell($cell,$columnIndex); |
|
235 | + $this->initializeFooterCell($cell, $columnIndex); |
|
236 | 236 | else if($this->_footerTemplate!==null) |
237 | 237 | $this->_footerTemplate->instantiateIn($cell); |
238 | 238 | else |
239 | - $this->initializeFooterCell($cell,$columnIndex); |
|
239 | + $this->initializeFooterCell($cell, $columnIndex); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * This method is invoked when datagrid performs databinding. |
246 | 246 | * It populates the content of the cell with the relevant data from data source. |
247 | 247 | */ |
248 | - public function dataBindColumn($sender,$param) |
|
248 | + public function dataBindColumn($sender, $param) |
|
249 | 249 | { |
250 | 250 | $item=$sender->getNamingContainer(); |
251 | 251 | $sender->setData($item->getData()); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * Returns the value to be validated. |
239 | 239 | * This methid is required by IValidatable interface. |
240 | - * @return mixed the value of the property to be validated. |
|
240 | + * @return string the value of the property to be validated. |
|
241 | 241 | */ |
242 | 242 | public function getValidationPropertyValue() |
243 | 243 | { |
@@ -342,6 +342,7 @@ discard block |
||
342 | 342 | * An automatic postback to the server will occur whenever the user |
343 | 343 | * modifies the text in the TTextBox control and then tabs out of the component. |
344 | 344 | * @param boolean the value indicating if postback automatically |
345 | + * @param boolean $value |
|
345 | 346 | */ |
346 | 347 | public function setAutoPostBack($value) |
347 | 348 | { |
@@ -425,6 +426,7 @@ discard block |
||
425 | 426 | |
426 | 427 | /** |
427 | 428 | * @param boolean whether the textbox is read only |
429 | + * @param boolean $value |
|
428 | 430 | */ |
429 | 431 | public function setReadOnly($value) |
430 | 432 | { |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function getIsValid() |
253 | 253 | { |
254 | - return $this->_isValid; |
|
254 | + return $this->_isValid; |
|
255 | 255 | } |
256 | 256 | /** |
257 | 257 | * @param bool wether this control is valid. |
258 | 258 | */ |
259 | 259 | public function setIsValid($value) |
260 | 260 | { |
261 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
261 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | |
330 | 330 | /** |
331 | 331 | * @return boolean a value indicating whether an automatic postback to the server |
332 | - * will occur whenever the user modifies the text in the TTextBox control and |
|
333 | - * then tabs out of the component. Defaults to false. |
|
332 | + * will occur whenever the user modifies the text in the TTextBox control and |
|
333 | + * then tabs out of the component. Defaults to false. |
|
334 | 334 | */ |
335 | 335 | public function getAutoPostBack() |
336 | 336 | { |
@@ -189,8 +189,7 @@ discard block |
||
189 | 189 | return file_put_contents($fileName,file_get_contents($this->_localName))!==false; |
190 | 190 | else |
191 | 191 | return false; |
192 | - } |
|
193 | - else |
|
192 | + } else |
|
194 | 193 | return false; |
195 | 194 | } |
196 | 195 | |
@@ -211,8 +210,7 @@ discard block |
||
211 | 210 | $this->_errorCode=$_FILES[$key]['error']; |
212 | 211 | $this->_localName=$_FILES[$key]['tmp_name']; |
213 | 212 | return $this->_dataChanged=true; |
214 | - } |
|
215 | - else |
|
213 | + } else |
|
216 | 214 | return false; |
217 | 215 | } |
218 | 216 |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function getTagName() |
83 | 83 | { |
84 | - return ($this->getTextMode()==='MultiLine')?'textarea':'input'; |
|
84 | + return ($this->getTextMode()==='MultiLine') ? 'textarea' : 'input'; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function getEnableClientScript() |
91 | 91 | { |
92 | - return $this->getViewState('EnableClientScript',true); |
|
92 | + return $this->getViewState('EnableClientScript', true); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function setEnableClientScript($value) |
99 | 99 | { |
100 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
100 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -110,106 +110,106 @@ discard block |
||
110 | 110 | $page=$this->getPage(); |
111 | 111 | $page->ensureRenderInForm($this); |
112 | 112 | if(($uid=$this->getUniqueID())!=='') |
113 | - $writer->addAttribute('name',$uid); |
|
113 | + $writer->addAttribute('name', $uid); |
|
114 | 114 | if(($textMode=$this->getTextMode())===TTextBoxMode::MultiLine) |
115 | 115 | { |
116 | - if(($rows=$this->getRows())<=0) |
|
116 | + if(($rows=$this->getRows()) <= 0) |
|
117 | 117 | $rows=self::DEFAULT_ROWS; |
118 | - if(($cols=$this->getColumns())<=0) |
|
118 | + if(($cols=$this->getColumns()) <= 0) |
|
119 | 119 | $cols=self::DEFAULT_COLUMNS; |
120 | - $writer->addAttribute('rows',"$rows"); |
|
121 | - $writer->addAttribute('cols',"$cols"); |
|
120 | + $writer->addAttribute('rows', "$rows"); |
|
121 | + $writer->addAttribute('cols', "$cols"); |
|
122 | 122 | if(!$this->getWrap()) |
123 | - $writer->addAttribute('wrap','off'); |
|
123 | + $writer->addAttribute('wrap', 'off'); |
|
124 | 124 | } |
125 | 125 | else |
126 | 126 | { |
127 | 127 | switch($textMode) |
128 | 128 | { |
129 | 129 | case TTextBoxMode::Password: |
130 | - $writer->addAttribute('type','password'); |
|
130 | + $writer->addAttribute('type', 'password'); |
|
131 | 131 | break; |
132 | 132 | case TTextBoxMode::Color: |
133 | - $writer->addAttribute('type','color'); |
|
133 | + $writer->addAttribute('type', 'color'); |
|
134 | 134 | break; |
135 | 135 | case TTextBoxMode::Date: |
136 | - $writer->addAttribute('type','date'); |
|
136 | + $writer->addAttribute('type', 'date'); |
|
137 | 137 | break; |
138 | 138 | case TTextBoxMode::Datetime: |
139 | - $writer->addAttribute('type','datetime'); |
|
139 | + $writer->addAttribute('type', 'datetime'); |
|
140 | 140 | break; |
141 | 141 | case TTextBoxMode::DatetimeLocal: |
142 | - $writer->addAttribute('type','datetime-local'); |
|
142 | + $writer->addAttribute('type', 'datetime-local'); |
|
143 | 143 | break; |
144 | 144 | case TTextBoxMode::Email: |
145 | - $writer->addAttribute('type','email'); |
|
145 | + $writer->addAttribute('type', 'email'); |
|
146 | 146 | break; |
147 | 147 | case TTextBoxMode::Month: |
148 | - $writer->addAttribute('type','month'); |
|
148 | + $writer->addAttribute('type', 'month'); |
|
149 | 149 | break; |
150 | 150 | case TTextBoxMode::Number: |
151 | - $writer->addAttribute('type','number'); |
|
151 | + $writer->addAttribute('type', 'number'); |
|
152 | 152 | break; |
153 | 153 | case TTextBoxMode::Range: |
154 | - $writer->addAttribute('type','range'); |
|
154 | + $writer->addAttribute('type', 'range'); |
|
155 | 155 | break; |
156 | 156 | case TTextBoxMode::Search: |
157 | - $writer->addAttribute('type','search'); |
|
157 | + $writer->addAttribute('type', 'search'); |
|
158 | 158 | break; |
159 | 159 | case TTextBoxMode::Tel: |
160 | - $writer->addAttribute('type','tel'); |
|
160 | + $writer->addAttribute('type', 'tel'); |
|
161 | 161 | break; |
162 | 162 | case TTextBoxMode::Time: |
163 | - $writer->addAttribute('type','time'); |
|
163 | + $writer->addAttribute('type', 'time'); |
|
164 | 164 | break; |
165 | 165 | case TTextBoxMode::Url: |
166 | - $writer->addAttribute('type','url'); |
|
166 | + $writer->addAttribute('type', 'url'); |
|
167 | 167 | break; |
168 | 168 | case TTextBoxMode::Week: |
169 | - $writer->addAttribute('type','week'); |
|
169 | + $writer->addAttribute('type', 'week'); |
|
170 | 170 | break; |
171 | 171 | case TTextBoxMode::SingleLine: |
172 | 172 | default: |
173 | - $writer->addAttribute('type','text'); |
|
173 | + $writer->addAttribute('type', 'text'); |
|
174 | 174 | break; |
175 | 175 | } |
176 | 176 | |
177 | - if(($text=$this->getText())!=='' && ($textMode !== TTextBoxMode::Password || $this->getPersistPassword())) |
|
178 | - $writer->addAttribute('value',$text); |
|
177 | + if(($text=$this->getText())!=='' && ($textMode!==TTextBoxMode::Password || $this->getPersistPassword())) |
|
178 | + $writer->addAttribute('value', $text); |
|
179 | 179 | |
180 | 180 | if(($act=$this->getAutoCompleteType())!=='None') |
181 | 181 | { |
182 | 182 | if($act==='Disabled') |
183 | - $writer->addAttribute('autocomplete','off'); |
|
183 | + $writer->addAttribute('autocomplete', 'off'); |
|
184 | 184 | else if($act==='Search') |
185 | - $writer->addAttribute('vcard_name','search'); |
|
185 | + $writer->addAttribute('vcard_name', 'search'); |
|
186 | 186 | else if($act==='HomeCountryRegion') |
187 | - $writer->addAttribute('vcard_name','HomeCountry'); |
|
187 | + $writer->addAttribute('vcard_name', 'HomeCountry'); |
|
188 | 188 | else if($act==='BusinessCountryRegion') |
189 | - $writer->addAttribute('vcard_name','BusinessCountry'); |
|
189 | + $writer->addAttribute('vcard_name', 'BusinessCountry'); |
|
190 | 190 | else |
191 | 191 | { |
192 | - if(strpos($act,'Business')===0) |
|
193 | - $act='Business'.'.'.substr($act,8); |
|
194 | - else if(strpos($act,'Home')===0) |
|
195 | - $act='Home'.'.'.substr($act,4); |
|
196 | - $writer->addAttribute('vcard_name','vCard.'.$act); |
|
192 | + if(strpos($act, 'Business')===0) |
|
193 | + $act='Business'.'.'.substr($act, 8); |
|
194 | + else if(strpos($act, 'Home')===0) |
|
195 | + $act='Home'.'.'.substr($act, 4); |
|
196 | + $writer->addAttribute('vcard_name', 'vCard.'.$act); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - if(($cols=$this->getColumns())>0) |
|
201 | - $writer->addAttribute('size',"$cols"); |
|
202 | - if(($maxLength=$this->getMaxLength())>0) |
|
203 | - $writer->addAttribute('maxlength',"$maxLength"); |
|
200 | + if(($cols=$this->getColumns()) > 0) |
|
201 | + $writer->addAttribute('size', "$cols"); |
|
202 | + if(($maxLength=$this->getMaxLength()) > 0) |
|
203 | + $writer->addAttribute('maxlength', "$maxLength"); |
|
204 | 204 | } |
205 | 205 | if($this->getReadOnly()) |
206 | - $writer->addAttribute('readonly','readonly'); |
|
206 | + $writer->addAttribute('readonly', 'readonly'); |
|
207 | 207 | $isEnabled=$this->getEnabled(true); |
208 | 208 | if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled' |
209 | - $writer->addAttribute('disabled','disabled'); |
|
209 | + $writer->addAttribute('disabled', 'disabled'); |
|
210 | 210 | if($isEnabled |
211 | 211 | && $this->getEnableClientScript() |
212 | - && ( $this->getAutoPostBack() || $textMode===TTextBoxMode::SingleLine) |
|
212 | + && ($this->getAutoPostBack() || $textMode===TTextBoxMode::SingleLine) |
|
213 | 213 | && $page->getClientSupportsJavaScript()) |
214 | 214 | { |
215 | 215 | $this->renderClientControlScript($writer); |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | */ |
223 | 223 | protected function renderClientControlScript($writer) |
224 | 224 | { |
225 | - $writer->addAttribute('id',$this->getClientID()); |
|
226 | - $cs = $this->getPage()->getClientScript(); |
|
227 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
225 | + $writer->addAttribute('id', $this->getClientID()); |
|
226 | + $cs=$this->getPage()->getClientScript(); |
|
227 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function getPostBackOptions() |
245 | 245 | { |
246 | - $options['ID'] = $this->getClientID(); |
|
247 | - $options['EventTarget'] = $this->getUniqueID(); |
|
248 | - $options['AutoPostBack'] = $this->getAutoPostBack(); |
|
249 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
250 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
251 | - $options['TextMode'] = $this->getTextMode(); |
|
246 | + $options['ID']=$this->getClientID(); |
|
247 | + $options['EventTarget']=$this->getUniqueID(); |
|
248 | + $options['AutoPostBack']=$this->getAutoPostBack(); |
|
249 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
250 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
251 | + $options['TextMode']=$this->getTextMode(); |
|
252 | 252 | return $options; |
253 | 253 | } |
254 | 254 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param array the input data collection |
260 | 260 | * @return boolean whether the data of the component has been changed |
261 | 261 | */ |
262 | - public function loadPostData($key,$values) |
|
262 | + public function loadPostData($key, $values) |
|
263 | 263 | { |
264 | 264 | $value=$values[$key]; |
265 | 265 | if($this->getAutoTrim()) |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function onTextChanged($param) |
322 | 322 | { |
323 | - $this->raiseEvent('OnTextChanged',$this,$param); |
|
323 | + $this->raiseEvent('OnTextChanged', $this, $param); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function getAutoCompleteType() |
366 | 366 | { |
367 | - return $this->getViewState('AutoCompleteType',TTextBoxAutoCompleteType::None); |
|
367 | + return $this->getViewState('AutoCompleteType', TTextBoxAutoCompleteType::None); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function setAutoCompleteType($value) |
375 | 375 | { |
376 | - $this->setViewState('AutoCompleteType',TPropertyValue::ensureEnum($value,'TTextBoxAutoCompleteType'),TTextBoxAutoCompleteType::None); |
|
376 | + $this->setViewState('AutoCompleteType', TPropertyValue::ensureEnum($value, 'TTextBoxAutoCompleteType'), TTextBoxAutoCompleteType::None); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | */ |
384 | 384 | public function getAutoPostBack() |
385 | 385 | { |
386 | - return $this->getViewState('AutoPostBack',false); |
|
386 | + return $this->getViewState('AutoPostBack', false); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function setAutoPostBack($value) |
396 | 396 | { |
397 | - $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),false); |
|
397 | + $this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), false); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function getAutoTrim() |
404 | 404 | { |
405 | - return $this->getViewState('AutoTrim',false); |
|
405 | + return $this->getViewState('AutoTrim', false); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | */ |
412 | 412 | public function setAutoTrim($value) |
413 | 413 | { |
414 | - $this->setViewState('AutoTrim',TPropertyValue::ensureBoolean($value),false); |
|
414 | + $this->setViewState('AutoTrim', TPropertyValue::ensureBoolean($value), false); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function getCausesValidation() |
421 | 421 | { |
422 | - return $this->getViewState('CausesValidation',true); |
|
422 | + return $this->getViewState('CausesValidation', true); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | */ |
428 | 428 | public function setCausesValidation($value) |
429 | 429 | { |
430 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
430 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | */ |
436 | 436 | public function getColumns() |
437 | 437 | { |
438 | - return $this->getViewState('Columns',0); |
|
438 | + return $this->getViewState('Columns', 0); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | */ |
445 | 445 | public function setColumns($value) |
446 | 446 | { |
447 | - $this->setViewState('Columns',TPropertyValue::ensureInteger($value),0); |
|
447 | + $this->setViewState('Columns', TPropertyValue::ensureInteger($value), 0); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | public function getMaxLength() |
454 | 454 | { |
455 | - return $this->getViewState('MaxLength',0); |
|
455 | + return $this->getViewState('MaxLength', 0); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | */ |
462 | 462 | public function setMaxLength($value) |
463 | 463 | { |
464 | - $this->setViewState('MaxLength',TPropertyValue::ensureInteger($value),0); |
|
464 | + $this->setViewState('MaxLength', TPropertyValue::ensureInteger($value), 0); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | */ |
470 | 470 | public function getReadOnly() |
471 | 471 | { |
472 | - return $this->getViewState('ReadOnly',false); |
|
472 | + return $this->getViewState('ReadOnly', false); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | */ |
478 | 478 | public function setReadOnly($value) |
479 | 479 | { |
480 | - $this->setViewState('ReadOnly',TPropertyValue::ensureBoolean($value),false); |
|
480 | + $this->setViewState('ReadOnly', TPropertyValue::ensureBoolean($value), false); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | */ |
486 | 486 | public function getRows() |
487 | 487 | { |
488 | - return $this->getViewState('Rows',self::DEFAULT_ROWS); |
|
488 | + return $this->getViewState('Rows', self::DEFAULT_ROWS); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public function setRows($value) |
496 | 496 | { |
497 | - $this->setViewState('Rows',TPropertyValue::ensureInteger($value),self::DEFAULT_ROWS); |
|
497 | + $this->setViewState('Rows', TPropertyValue::ensureInteger($value), self::DEFAULT_ROWS); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | */ |
503 | 503 | public function getPersistPassword() |
504 | 504 | { |
505 | - return $this->getViewState('PersistPassword',false); |
|
505 | + return $this->getViewState('PersistPassword', false); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | */ |
511 | 511 | public function setPersistPassword($value) |
512 | 512 | { |
513 | - $this->setViewState('PersistPassword',TPropertyValue::ensureBoolean($value),false); |
|
513 | + $this->setViewState('PersistPassword', TPropertyValue::ensureBoolean($value), false); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | */ |
519 | 519 | public function getText() |
520 | 520 | { |
521 | - return $this->getViewState('Text',''); |
|
521 | + return $this->getViewState('Text', ''); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | */ |
528 | 528 | public function setText($value) |
529 | 529 | { |
530 | - $this->setViewState('Text',TPropertyValue::ensureString($value),''); |
|
531 | - $this->_safeText = null; |
|
530 | + $this->setViewState('Text', TPropertyValue::ensureString($value), ''); |
|
531 | + $this->_safeText=null; |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | protected function getSafeTextParser() |
574 | 574 | { |
575 | 575 | if(!self::$_safeTextParser) |
576 | - self::$_safeTextParser= new TSafeHtmlParser; |
|
576 | + self::$_safeTextParser=new TSafeHtmlParser; |
|
577 | 577 | return self::$_safeTextParser; |
578 | 578 | } |
579 | 579 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | */ |
583 | 583 | public function getTextMode() |
584 | 584 | { |
585 | - return $this->getViewState('TextMode',TTextBoxMode::SingleLine); |
|
585 | + return $this->getViewState('TextMode', TTextBoxMode::SingleLine); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | */ |
593 | 593 | public function setTextMode($value) |
594 | 594 | { |
595 | - $this->setViewState('TextMode',TPropertyValue::ensureEnum($value,'TTextBoxMode'),TTextBoxMode::SingleLine); |
|
595 | + $this->setViewState('TextMode', TPropertyValue::ensureEnum($value, 'TTextBoxMode'), TTextBoxMode::SingleLine); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | */ |
601 | 601 | public function getValidationGroup() |
602 | 602 | { |
603 | - return $this->getViewState('ValidationGroup',''); |
|
603 | + return $this->getViewState('ValidationGroup', ''); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | */ |
609 | 609 | public function setValidationGroup($value) |
610 | 610 | { |
611 | - $this->setViewState('ValidationGroup',$value,''); |
|
611 | + $this->setViewState('ValidationGroup', $value, ''); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | */ |
617 | 617 | public function getWrap() |
618 | 618 | { |
619 | - return $this->getViewState('Wrap',true); |
|
619 | + return $this->getViewState('Wrap', true); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -625,6 +625,6 @@ discard block |
||
625 | 625 | */ |
626 | 626 | public function setWrap($value) |
627 | 627 | { |
628 | - $this->setViewState('Wrap',TPropertyValue::ensureBoolean($value),true); |
|
628 | + $this->setViewState('Wrap', TPropertyValue::ensureBoolean($value), true); |
|
629 | 629 | } |
630 | 630 | } |
@@ -157,6 +157,7 @@ |
||
157 | 157 | * Processes a text string. |
158 | 158 | * This method is required by the parent class. |
159 | 159 | * @param string text string to be processed |
160 | + * @param string $text |
|
160 | 161 | * @return string the processed text result |
161 | 162 | */ |
162 | 163 | public function processText($text) |
@@ -19,19 +19,19 @@ |
||
19 | 19 | // BC trick : only define constants if Text/Highlighter.php |
20 | 20 | // is not yet included |
21 | 21 | if (!defined('HL_NUMBERS_LI')) { |
22 | - /**#@+ |
|
22 | + /**#@+ |
|
23 | 23 | * Constant for use with $options['numbers'] |
24 | 24 | */ |
25 | - /** |
|
26 | - * use numbered list, deprecated, use HL_NUMBERS_OL instaed |
|
27 | - * @deprecated |
|
28 | - */ |
|
29 | - define ('HL_NUMBERS_LI' , 1); |
|
30 | - /** |
|
31 | - * Use 2-column table with line numbers in left column and code in right column. |
|
32 | - */ |
|
33 | - define ('HL_NUMBERS_TABLE' , 2); |
|
34 | - /**#@-*/ |
|
25 | + /** |
|
26 | + * use numbered list, deprecated, use HL_NUMBERS_OL instaed |
|
27 | + * @deprecated |
|
28 | + */ |
|
29 | + define ('HL_NUMBERS_LI' , 1); |
|
30 | + /** |
|
31 | + * Use 2-column table with line numbers in left column and code in right column. |
|
32 | + */ |
|
33 | + define ('HL_NUMBERS_TABLE' , 2); |
|
34 | + /**#@-*/ |
|
35 | 35 | } |
36 | 36 | |
37 | 37 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | // BC trick : only define constants if Text/Highlighter.php |
20 | 20 | // is not yet included |
21 | -if (!defined('HL_NUMBERS_LI')) { |
|
21 | +if(!defined('HL_NUMBERS_LI')) { |
|
22 | 22 | /**#@+ |
23 | 23 | * Constant for use with $options['numbers'] |
24 | 24 | */ |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | * use numbered list, deprecated, use HL_NUMBERS_OL instaed |
27 | 27 | * @deprecated |
28 | 28 | */ |
29 | - define ('HL_NUMBERS_LI' , 1); |
|
29 | + define('HL_NUMBERS_LI', 1); |
|
30 | 30 | /** |
31 | 31 | * Use 2-column table with line numbers in left column and code in right column. |
32 | 32 | */ |
33 | - define ('HL_NUMBERS_TABLE' , 2); |
|
33 | + define('HL_NUMBERS_TABLE', 2); |
|
34 | 34 | /**#@-*/ |
35 | 35 | } |
36 | 36 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function setLineNumberStyle($value) |
134 | 134 | { |
135 | - $this->setViewState('LineNumberStyle', TPropertyValue::ensureEnum($value,'TTextHighlighterLineNumberStyle')); |
|
135 | + $this->setViewState('LineNumberStyle', TPropertyValue::ensureEnum($value, 'TTextHighlighterLineNumberStyle')); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | protected function registerStyleSheet() |
169 | 169 | { |
170 | 170 | $cs=$this->getPage()->getClientScript(); |
171 | - $cssFile=Prado::getPathOfNamespace('Prado\\Vendor\\TextHighlighter\\highlight','.css'); |
|
171 | + $cssFile=Prado::getPathOfNamespace('Prado\\Vendor\\TextHighlighter\\highlight', '.css'); |
|
172 | 172 | $cssKey='prado:TTextHighlighter:'.$cssFile; |
173 | 173 | if(!$cs->isStyleSheetFileRegistered($cssKey)) |
174 | 174 | $cs->registerStyleSheetFile($cssKey, $this->publishFilePath($cssFile)); |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | return ('<pre>'.htmlentities(trim($text)).'</pre>'); |
195 | 195 | |
196 | 196 | $options["use_language"]=true; |
197 | - $options["tabsize"] = $this->getTabSize(); |
|
198 | - if ($this->getShowLineNumbers()) |
|
199 | - $options["numbers"] = self::$_lineNumberStyle[$this->getLineNumberStyle()]; |
|
197 | + $options["tabsize"]=$this->getTabSize(); |
|
198 | + if($this->getShowLineNumbers()) |
|
199 | + $options["numbers"]=self::$_lineNumberStyle[$this->getLineNumberStyle()]; |
|
200 | 200 | $highlighter->setRenderer(new Text_Highlighter_Renderer_Html($options)); |
201 | 201 | return $highlighter->highlight(trim($text)); |
202 | 202 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function getHeaderTemplate() |
208 | 208 | { |
209 | - $id = $this->getClientID(); |
|
209 | + $id=$this->getClientID(); |
|
210 | 210 | return TJavaScript::renderScriptBlock("new Prado.WebUI.TTextHighlighter('{$id}');"); |
211 | 211 | } |
212 | 212 |
@@ -185,8 +185,7 @@ |
||
185 | 185 | try |
186 | 186 | { |
187 | 187 | $highlighter=Text_Highlighter::factory($this->getLanguage()); |
188 | - } |
|
189 | - catch(\Exception $e) |
|
188 | + } catch(\Exception $e) |
|
190 | 189 | { |
191 | 190 | $highlighter=false; |
192 | 191 | } |
@@ -113,6 +113,7 @@ |
||
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @param string button caption |
116 | + * @param string $value |
|
116 | 117 | */ |
117 | 118 | public function setButtonText($value) |
118 | 119 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function getImageUrl() |
91 | 91 | { |
92 | - return $this->_imageUrl===null?'':$this->_imageUrl; |
|
92 | + return $this->_imageUrl===null ? '' : $this->_imageUrl; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getButtonText() |
107 | 107 | { |
108 | - return $this->_buttonText===null?'':$this->_buttonText; |
|
108 | + return $this->_buttonText===null ? '' : $this->_buttonText; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getButtonType() |
123 | 123 | { |
124 | - return $this->_buttonType===null? TWizardNavigationButtonType::Button :$this->_buttonType; |
|
124 | + return $this->_buttonType===null ? TWizardNavigationButtonType::Button : $this->_buttonType; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function setButtonType($value) |
131 | 131 | { |
132 | - $this->_buttonType=TPropertyValue::ensureEnum($value,'Prado\\Web\\UI\\WebControls\\TWizardNavigationButtonType'); |
|
132 | + $this->_buttonType=TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TWizardNavigationButtonType'); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -207,6 +207,10 @@ |
||
207 | 207 | return $code; |
208 | 208 | } |
209 | 209 | |
210 | + /** |
|
211 | + * @param string $classname |
|
212 | + * @param string $toString |
|
213 | + */ |
|
210 | 214 | protected function generateClass($properties, $tablename, $classname, $toString) |
211 | 215 | { |
212 | 216 | $props = implode("\n", $properties); |
@@ -14,206 +14,206 @@ discard block |
||
14 | 14 | class TWsatARGenerator extends TWsatBaseGenerator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Class name prefix |
|
19 | - */ |
|
20 | - private $_clasPrefix; |
|
21 | - |
|
22 | - /** |
|
23 | - * Class name sufix |
|
24 | - */ |
|
25 | - private $_classSufix; |
|
26 | - |
|
27 | - /** |
|
28 | - * all table relations array |
|
29 | - */ |
|
30 | - private $_relations; |
|
31 | - |
|
32 | - /** |
|
33 | - * unquote chars |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - private $uqChars = array('[', ']', '"', '`', "'"); |
|
37 | - |
|
38 | - function __construct() |
|
39 | - { |
|
40 | - parent::__construct(); |
|
41 | - } |
|
42 | - |
|
43 | - public function setClasPrefix($_clas_prefix) |
|
44 | - { |
|
45 | - $this->_clasPrefix = $_clas_prefix; |
|
46 | - } |
|
47 | - |
|
48 | - public function setClassSufix($_clas_sufix) |
|
49 | - { |
|
50 | - $this->_classSufix = $_clas_sufix; |
|
51 | - } |
|
17 | + /** |
|
18 | + * Class name prefix |
|
19 | + */ |
|
20 | + private $_clasPrefix; |
|
21 | + |
|
22 | + /** |
|
23 | + * Class name sufix |
|
24 | + */ |
|
25 | + private $_classSufix; |
|
26 | + |
|
27 | + /** |
|
28 | + * all table relations array |
|
29 | + */ |
|
30 | + private $_relations; |
|
31 | + |
|
32 | + /** |
|
33 | + * unquote chars |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + private $uqChars = array('[', ']', '"', '`', "'"); |
|
37 | + |
|
38 | + function __construct() |
|
39 | + { |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | + |
|
43 | + public function setClasPrefix($_clas_prefix) |
|
44 | + { |
|
45 | + $this->_clasPrefix = $_clas_prefix; |
|
46 | + } |
|
47 | + |
|
48 | + public function setClassSufix($_clas_sufix) |
|
49 | + { |
|
50 | + $this->_classSufix = $_clas_sufix; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | //----------------------------------------------------------------------------- |
54 | - // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
|
55 | - public function generate($tableName) |
|
56 | - { |
|
57 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
58 | - $this->_commonGenerate($tableName, $tableInfo); |
|
59 | - } |
|
60 | - |
|
61 | - public function generateAll() |
|
62 | - { |
|
63 | - foreach ($this->getAllTableNames() as $tableName) |
|
64 | - { |
|
65 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
66 | - if (!empty($this->_relations)) |
|
67 | - { |
|
68 | - // Cancel generation of M-M relationships middle table |
|
69 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
70 | - continue; |
|
71 | - } |
|
72 | - $this->_commonGenerate($tableName, $tableInfo); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - public function buildRelations() |
|
77 | - { |
|
78 | - $this->_relations = array(); |
|
79 | - foreach ($this->getAllTableNames() as $table_name) |
|
80 | - { |
|
81 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
82 | - $pks = $tableInfo->getPrimaryKeys(); |
|
83 | - $fks = $tableInfo->getForeignKeys(); |
|
84 | - |
|
85 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
86 | - { |
|
87 | - $table_name_mm = $fks[0]["table"]; |
|
88 | - $table_name_mm2 = $fks[1]["table"]; |
|
89 | - |
|
90 | - $this->_relations[$table_name_mm][] = array( |
|
91 | - "prop_name" => strtolower($table_name_mm2), |
|
92 | - "rel_type" => "self::MANY_TO_MANY", |
|
93 | - "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
|
94 | - "prop_ref" => $table_name |
|
95 | - ); |
|
96 | - |
|
97 | - $this->_relations[$table_name_mm2][] = array( |
|
98 | - "prop_name" => strtolower($table_name_mm), |
|
99 | - "rel_type" => "self::MANY_TO_MANY", |
|
100 | - "ref_class_name" => $this->_getProperClassName($table_name_mm), |
|
101 | - "prop_ref" => $table_name |
|
102 | - ); |
|
103 | - continue; |
|
104 | - } |
|
105 | - foreach ($fks as $fk_data)//1-M relationships |
|
106 | - { |
|
107 | - $owner_table = $fk_data["table"]; |
|
108 | - $slave_table = $table_name; |
|
109 | - $fk_prop = key($fk_data["keys"]); |
|
110 | - |
|
111 | - $this->_relations[$owner_table][] = array( |
|
112 | - "prop_name" => strtolower($slave_table), |
|
113 | - "rel_type" => "self::HAS_MANY", |
|
114 | - "ref_class_name" => $this->_getProperClassName($slave_table), |
|
115 | - "prop_ref" => $fk_prop |
|
116 | - ); |
|
117 | - |
|
118 | - $this->_relations[$slave_table][] = array( |
|
119 | - "prop_name" => strtolower($owner_table), |
|
120 | - "rel_type" => "self::BELONGS_TO", |
|
121 | - "ref_class_name" => $this->_getProperClassName($owner_table), |
|
122 | - "prop_ref" => $fk_prop |
|
123 | - ); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
54 | + // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
|
55 | + public function generate($tableName) |
|
56 | + { |
|
57 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
58 | + $this->_commonGenerate($tableName, $tableInfo); |
|
59 | + } |
|
60 | + |
|
61 | + public function generateAll() |
|
62 | + { |
|
63 | + foreach ($this->getAllTableNames() as $tableName) |
|
64 | + { |
|
65 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
66 | + if (!empty($this->_relations)) |
|
67 | + { |
|
68 | + // Cancel generation of M-M relationships middle table |
|
69 | + if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
70 | + continue; |
|
71 | + } |
|
72 | + $this->_commonGenerate($tableName, $tableInfo); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + public function buildRelations() |
|
77 | + { |
|
78 | + $this->_relations = array(); |
|
79 | + foreach ($this->getAllTableNames() as $table_name) |
|
80 | + { |
|
81 | + $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
82 | + $pks = $tableInfo->getPrimaryKeys(); |
|
83 | + $fks = $tableInfo->getForeignKeys(); |
|
84 | + |
|
85 | + if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
86 | + { |
|
87 | + $table_name_mm = $fks[0]["table"]; |
|
88 | + $table_name_mm2 = $fks[1]["table"]; |
|
89 | + |
|
90 | + $this->_relations[$table_name_mm][] = array( |
|
91 | + "prop_name" => strtolower($table_name_mm2), |
|
92 | + "rel_type" => "self::MANY_TO_MANY", |
|
93 | + "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
|
94 | + "prop_ref" => $table_name |
|
95 | + ); |
|
96 | + |
|
97 | + $this->_relations[$table_name_mm2][] = array( |
|
98 | + "prop_name" => strtolower($table_name_mm), |
|
99 | + "rel_type" => "self::MANY_TO_MANY", |
|
100 | + "ref_class_name" => $this->_getProperClassName($table_name_mm), |
|
101 | + "prop_ref" => $table_name |
|
102 | + ); |
|
103 | + continue; |
|
104 | + } |
|
105 | + foreach ($fks as $fk_data)//1-M relationships |
|
106 | + { |
|
107 | + $owner_table = $fk_data["table"]; |
|
108 | + $slave_table = $table_name; |
|
109 | + $fk_prop = key($fk_data["keys"]); |
|
110 | + |
|
111 | + $this->_relations[$owner_table][] = array( |
|
112 | + "prop_name" => strtolower($slave_table), |
|
113 | + "rel_type" => "self::HAS_MANY", |
|
114 | + "ref_class_name" => $this->_getProperClassName($slave_table), |
|
115 | + "prop_ref" => $fk_prop |
|
116 | + ); |
|
117 | + |
|
118 | + $this->_relations[$slave_table][] = array( |
|
119 | + "prop_name" => strtolower($owner_table), |
|
120 | + "rel_type" => "self::BELONGS_TO", |
|
121 | + "ref_class_name" => $this->_getProperClassName($owner_table), |
|
122 | + "prop_ref" => $fk_prop |
|
123 | + ); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | 128 | // </editor-fold> |
129 | 129 | //----------------------------------------------------------------------------- |
130 | - // <editor-fold defaultstate="collapsed" desc="Common Methods"> |
|
131 | - |
|
132 | - private function _commonGenerate($tableName, $tableInfo) |
|
133 | - { |
|
134 | - if (count($tableInfo->getColumns()) === 0) |
|
135 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
136 | - else |
|
137 | - { |
|
138 | - $properties = array(); |
|
139 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | - $properties[] = $this->generateProperty($field, $metadata); |
|
141 | - $toString = $this->_buildSmartToString($tableInfo); |
|
142 | - } |
|
143 | - |
|
144 | - $clasName = $this->_getProperClassName($tableName); |
|
145 | - $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | - $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
147 | - file_put_contents($output, $class); |
|
148 | - } |
|
149 | - |
|
150 | - private function _getProperClassName($tableName) |
|
151 | - { |
|
152 | - $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
153 | - $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
154 | - return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
155 | - } |
|
130 | + // <editor-fold defaultstate="collapsed" desc="Common Methods"> |
|
131 | + |
|
132 | + private function _commonGenerate($tableName, $tableInfo) |
|
133 | + { |
|
134 | + if (count($tableInfo->getColumns()) === 0) |
|
135 | + throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
136 | + else |
|
137 | + { |
|
138 | + $properties = array(); |
|
139 | + foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | + $properties[] = $this->generateProperty($field, $metadata); |
|
141 | + $toString = $this->_buildSmartToString($tableInfo); |
|
142 | + } |
|
143 | + |
|
144 | + $clasName = $this->_getProperClassName($tableName); |
|
145 | + $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | + $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
147 | + file_put_contents($output, $class); |
|
148 | + } |
|
149 | + |
|
150 | + private function _getProperClassName($tableName) |
|
151 | + { |
|
152 | + $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
153 | + $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
154 | + return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | //----------------------------------------------------------------------------- |
158 | 158 | |
159 | - protected function generateProperty($field, $metadata) |
|
160 | - { |
|
161 | - $prop = ''; |
|
162 | - $name = '$' . $field; |
|
163 | - |
|
164 | - /* TODO use in version 2.0 */ |
|
165 | - // $type = $column->getPHPType(); |
|
166 | - |
|
167 | - $prop .= "\tpublic $name;"; |
|
168 | - return $prop; |
|
169 | - } |
|
170 | - |
|
171 | - private function _renderRelations($tablename) |
|
172 | - { |
|
173 | - if (!isset($this->_relations[$tablename])) |
|
174 | - return ""; |
|
175 | - |
|
176 | - $code = "\tpublic static \$RELATIONS = array ("; |
|
177 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
179 | - |
|
180 | - $code = substr($code, 0, -1); |
|
181 | - $code .= "\n\t);"; |
|
182 | - return $code; |
|
183 | - } |
|
184 | - |
|
185 | - private function _buildSmartToString($tableInfo) |
|
186 | - { |
|
187 | - $code = "\tpublic function __toString() {"; |
|
188 | - $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
189 | - try |
|
190 | - { |
|
191 | - foreach ($tableInfo->getColumns() as $column) |
|
192 | - { |
|
193 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
196 | - { |
|
197 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
198 | - break; |
|
199 | - } |
|
200 | - } |
|
201 | - } catch (Exception $ex) |
|
202 | - { |
|
203 | - Prado::trace($ex->getMessage()); |
|
204 | - } |
|
205 | - $code .= "\n\t\treturn \$this->$property;"; |
|
206 | - $code .= "\n\t}"; |
|
207 | - return $code; |
|
208 | - } |
|
209 | - |
|
210 | - protected function generateClass($properties, $tablename, $classname, $toString) |
|
211 | - { |
|
212 | - $props = implode("\n", $properties); |
|
213 | - $relations = $this->_renderRelations($tablename); |
|
214 | - $date = date('Y-m-d h:i:s'); |
|
215 | - $env_user = getenv("username"); |
|
216 | - return <<<EOD |
|
159 | + protected function generateProperty($field, $metadata) |
|
160 | + { |
|
161 | + $prop = ''; |
|
162 | + $name = '$' . $field; |
|
163 | + |
|
164 | + /* TODO use in version 2.0 */ |
|
165 | + // $type = $column->getPHPType(); |
|
166 | + |
|
167 | + $prop .= "\tpublic $name;"; |
|
168 | + return $prop; |
|
169 | + } |
|
170 | + |
|
171 | + private function _renderRelations($tablename) |
|
172 | + { |
|
173 | + if (!isset($this->_relations[$tablename])) |
|
174 | + return ""; |
|
175 | + |
|
176 | + $code = "\tpublic static \$RELATIONS = array ("; |
|
177 | + foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | + $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
179 | + |
|
180 | + $code = substr($code, 0, -1); |
|
181 | + $code .= "\n\t);"; |
|
182 | + return $code; |
|
183 | + } |
|
184 | + |
|
185 | + private function _buildSmartToString($tableInfo) |
|
186 | + { |
|
187 | + $code = "\tpublic function __toString() {"; |
|
188 | + $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
189 | + try |
|
190 | + { |
|
191 | + foreach ($tableInfo->getColumns() as $column) |
|
192 | + { |
|
193 | + if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | + $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | + elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
196 | + { |
|
197 | + $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
198 | + break; |
|
199 | + } |
|
200 | + } |
|
201 | + } catch (Exception $ex) |
|
202 | + { |
|
203 | + Prado::trace($ex->getMessage()); |
|
204 | + } |
|
205 | + $code .= "\n\t\treturn \$this->$property;"; |
|
206 | + $code .= "\n\t}"; |
|
207 | + return $code; |
|
208 | + } |
|
209 | + |
|
210 | + protected function generateClass($properties, $tablename, $classname, $toString) |
|
211 | + { |
|
212 | + $props = implode("\n", $properties); |
|
213 | + $relations = $this->_renderRelations($tablename); |
|
214 | + $date = date('Y-m-d h:i:s'); |
|
215 | + $env_user = getenv("username"); |
|
216 | + return <<<EOD |
|
217 | 217 | <?php |
218 | 218 | /** |
219 | 219 | * Auto generated by PRADO - WSAT on $date. |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $toString |
235 | 235 | } |
236 | 236 | EOD; |
237 | - } |
|
237 | + } |
|
238 | 238 | |
239 | 239 | // </editor-fold> |
240 | 240 | } |
241 | 241 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * unquote chars |
34 | 34 | * @var array |
35 | 35 | */ |
36 | - private $uqChars = array('[', ']', '"', '`', "'"); |
|
36 | + private $uqChars=array('[', ']', '"', '`', "'"); |
|
37 | 37 | |
38 | 38 | function __construct() |
39 | 39 | { |
@@ -42,31 +42,31 @@ discard block |
||
42 | 42 | |
43 | 43 | public function setClasPrefix($_clas_prefix) |
44 | 44 | { |
45 | - $this->_clasPrefix = $_clas_prefix; |
|
45 | + $this->_clasPrefix=$_clas_prefix; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function setClassSufix($_clas_sufix) |
49 | 49 | { |
50 | - $this->_classSufix = $_clas_sufix; |
|
50 | + $this->_classSufix=$_clas_sufix; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | //----------------------------------------------------------------------------- |
54 | 54 | // <editor-fold defaultstate="collapsed" desc="Main APIs"> |
55 | 55 | public function generate($tableName) |
56 | 56 | { |
57 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
57 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
58 | 58 | $this->_commonGenerate($tableName, $tableInfo); |
59 | 59 | } |
60 | 60 | |
61 | 61 | public function generateAll() |
62 | 62 | { |
63 | - foreach ($this->getAllTableNames() as $tableName) |
|
63 | + foreach($this->getAllTableNames() as $tableName) |
|
64 | 64 | { |
65 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
66 | - if (!empty($this->_relations)) |
|
65 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
66 | + if(!empty($this->_relations)) |
|
67 | 67 | { |
68 | 68 | // Cancel generation of M-M relationships middle table |
69 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
69 | + if(count($tableInfo->getPrimaryKeys())===2 && count($tableInfo->getColumns())===2)//M-M relationships |
|
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | $this->_commonGenerate($tableName, $tableInfo); |
@@ -75,26 +75,26 @@ discard block |
||
75 | 75 | |
76 | 76 | public function buildRelations() |
77 | 77 | { |
78 | - $this->_relations = array(); |
|
79 | - foreach ($this->getAllTableNames() as $table_name) |
|
78 | + $this->_relations=array(); |
|
79 | + foreach($this->getAllTableNames() as $table_name) |
|
80 | 80 | { |
81 | - $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
|
82 | - $pks = $tableInfo->getPrimaryKeys(); |
|
83 | - $fks = $tableInfo->getForeignKeys(); |
|
81 | + $tableInfo=$this->_dbMetaData->getTableInfo($table_name); |
|
82 | + $pks=$tableInfo->getPrimaryKeys(); |
|
83 | + $fks=$tableInfo->getForeignKeys(); |
|
84 | 84 | |
85 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
85 | + if(count($pks)===2 && count($tableInfo->getColumns())===2)//M-M relationships |
|
86 | 86 | { |
87 | - $table_name_mm = $fks[0]["table"]; |
|
88 | - $table_name_mm2 = $fks[1]["table"]; |
|
87 | + $table_name_mm=$fks[0]["table"]; |
|
88 | + $table_name_mm2=$fks[1]["table"]; |
|
89 | 89 | |
90 | - $this->_relations[$table_name_mm][] = array( |
|
90 | + $this->_relations[$table_name_mm][]=array( |
|
91 | 91 | "prop_name" => strtolower($table_name_mm2), |
92 | 92 | "rel_type" => "self::MANY_TO_MANY", |
93 | 93 | "ref_class_name" => $this->_getProperClassName($table_name_mm2), |
94 | 94 | "prop_ref" => $table_name |
95 | 95 | ); |
96 | 96 | |
97 | - $this->_relations[$table_name_mm2][] = array( |
|
97 | + $this->_relations[$table_name_mm2][]=array( |
|
98 | 98 | "prop_name" => strtolower($table_name_mm), |
99 | 99 | "rel_type" => "self::MANY_TO_MANY", |
100 | 100 | "ref_class_name" => $this->_getProperClassName($table_name_mm), |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | ); |
103 | 103 | continue; |
104 | 104 | } |
105 | - foreach ($fks as $fk_data)//1-M relationships |
|
105 | + foreach($fks as $fk_data)//1-M relationships |
|
106 | 106 | { |
107 | - $owner_table = $fk_data["table"]; |
|
108 | - $slave_table = $table_name; |
|
109 | - $fk_prop = key($fk_data["keys"]); |
|
107 | + $owner_table=$fk_data["table"]; |
|
108 | + $slave_table=$table_name; |
|
109 | + $fk_prop=key($fk_data["keys"]); |
|
110 | 110 | |
111 | - $this->_relations[$owner_table][] = array( |
|
111 | + $this->_relations[$owner_table][]=array( |
|
112 | 112 | "prop_name" => strtolower($slave_table), |
113 | 113 | "rel_type" => "self::HAS_MANY", |
114 | 114 | "ref_class_name" => $this->_getProperClassName($slave_table), |
115 | 115 | "prop_ref" => $fk_prop |
116 | 116 | ); |
117 | 117 | |
118 | - $this->_relations[$slave_table][] = array( |
|
118 | + $this->_relations[$slave_table][]=array( |
|
119 | 119 | "prop_name" => strtolower($owner_table), |
120 | 120 | "rel_type" => "self::BELONGS_TO", |
121 | 121 | "ref_class_name" => $this->_getProperClassName($owner_table), |
@@ -131,88 +131,88 @@ discard block |
||
131 | 131 | |
132 | 132 | private function _commonGenerate($tableName, $tableInfo) |
133 | 133 | { |
134 | - if (count($tableInfo->getColumns()) === 0) |
|
135 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
134 | + if(count($tableInfo->getColumns())===0) |
|
135 | + throw new Exception("Unable to find table or view $tableName in ".$this->_dbMetaData->getDbConnection()->getConnectionString()."."); |
|
136 | 136 | else |
137 | 137 | { |
138 | - $properties = array(); |
|
139 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
140 | - $properties[] = $this->generateProperty($field, $metadata); |
|
141 | - $toString = $this->_buildSmartToString($tableInfo); |
|
138 | + $properties=array(); |
|
139 | + foreach($tableInfo->getColumns() as $field => $metadata) |
|
140 | + $properties[]=$this->generateProperty($field, $metadata); |
|
141 | + $toString=$this->_buildSmartToString($tableInfo); |
|
142 | 142 | } |
143 | 143 | |
144 | - $clasName = $this->_getProperClassName($tableName); |
|
145 | - $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | - $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
144 | + $clasName=$this->_getProperClassName($tableName); |
|
145 | + $class=$this->generateClass($properties, $tableName, $clasName, $toString); |
|
146 | + $output=$this->_opFile.DIRECTORY_SEPARATOR.$clasName.".php"; |
|
147 | 147 | file_put_contents($output, $class); |
148 | 148 | } |
149 | 149 | |
150 | 150 | private function _getProperClassName($tableName) |
151 | 151 | { |
152 | - $table_name_words = str_replace("_", " ", strtolower($tableName)); |
|
153 | - $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
|
154 | - return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
152 | + $table_name_words=str_replace("_", " ", strtolower($tableName)); |
|
153 | + $final_conversion=str_replace(" ", "", ucwords($table_name_words)); |
|
154 | + return $this->_clasPrefix.$final_conversion.$this->_classSufix; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | //----------------------------------------------------------------------------- |
158 | 158 | |
159 | 159 | protected function generateProperty($field, $metadata) |
160 | 160 | { |
161 | - $prop = ''; |
|
162 | - $name = '$' . $field; |
|
161 | + $prop=''; |
|
162 | + $name='$'.$field; |
|
163 | 163 | |
164 | 164 | /* TODO use in version 2.0 */ |
165 | 165 | // $type = $column->getPHPType(); |
166 | 166 | |
167 | - $prop .= "\tpublic $name;"; |
|
167 | + $prop.="\tpublic $name;"; |
|
168 | 168 | return $prop; |
169 | 169 | } |
170 | 170 | |
171 | 171 | private function _renderRelations($tablename) |
172 | 172 | { |
173 | - if (!isset($this->_relations[$tablename])) |
|
173 | + if(!isset($this->_relations[$tablename])) |
|
174 | 174 | return ""; |
175 | 175 | |
176 | - $code = "\tpublic static \$RELATIONS = array ("; |
|
177 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
178 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
176 | + $code="\tpublic static \$RELATIONS = array ("; |
|
177 | + foreach($this->_relations[$tablename] as $rel_data) |
|
178 | + $code.="\n\t\t'".$rel_data["prop_name"]."' => array(".$rel_data["rel_type"].", '".$rel_data["ref_class_name"]."', '".$rel_data["prop_ref"]."'),"; |
|
179 | 179 | |
180 | - $code = substr($code, 0, -1); |
|
181 | - $code .= "\n\t);"; |
|
180 | + $code=substr($code, 0, -1); |
|
181 | + $code.="\n\t);"; |
|
182 | 182 | return $code; |
183 | 183 | } |
184 | 184 | |
185 | 185 | private function _buildSmartToString($tableInfo) |
186 | 186 | { |
187 | - $code = "\tpublic function __toString() {"; |
|
188 | - $property = "throw new THttpException(500, 'Not implemented yet.');"; |
|
187 | + $code="\tpublic function __toString() {"; |
|
188 | + $property="throw new THttpException(500, 'Not implemented yet.');"; |
|
189 | 189 | try |
190 | 190 | { |
191 | - foreach ($tableInfo->getColumns() as $column) |
|
191 | + foreach($tableInfo->getColumns() as $column) |
|
192 | 192 | { |
193 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
193 | + if(isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
194 | + $property=str_replace($this->uqChars, "", $column->ColumnName); |
|
195 | + elseif($column->PdoType==PDO::PARAM_STR && $column->DBType!="date") |
|
196 | 196 | { |
197 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
197 | + $property=str_replace($this->uqChars, "", $column->ColumnName); |
|
198 | 198 | break; |
199 | 199 | } |
200 | 200 | } |
201 | - } catch (Exception $ex) |
|
201 | + } catch(Exception $ex) |
|
202 | 202 | { |
203 | 203 | Prado::trace($ex->getMessage()); |
204 | 204 | } |
205 | - $code .= "\n\t\treturn \$this->$property;"; |
|
206 | - $code .= "\n\t}"; |
|
205 | + $code.="\n\t\treturn \$this->$property;"; |
|
206 | + $code.="\n\t}"; |
|
207 | 207 | return $code; |
208 | 208 | } |
209 | 209 | |
210 | 210 | protected function generateClass($properties, $tablename, $classname, $toString) |
211 | 211 | { |
212 | - $props = implode("\n", $properties); |
|
213 | - $relations = $this->_renderRelations($tablename); |
|
214 | - $date = date('Y-m-d h:i:s'); |
|
215 | - $env_user = getenv("username"); |
|
212 | + $props=implode("\n", $properties); |
|
213 | + $relations=$this->_renderRelations($tablename); |
|
214 | + $date=date('Y-m-d h:i:s'); |
|
215 | + $env_user=getenv("username"); |
|
216 | 216 | return <<<EOD |
217 | 217 | <?php |
218 | 218 | /** |
@@ -44,6 +44,10 @@ discard block |
||
44 | 44 | |
45 | 45 | //--------------------------------------------------------------------- |
46 | 46 | // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
47 | + |
|
48 | + /** |
|
49 | + * @param integer $viewType |
|
50 | + */ |
|
47 | 51 | public function generate($tableName, $viewType) |
48 | 52 | { |
49 | 53 | switch ($viewType) |
@@ -141,6 +145,10 @@ discard block |
||
141 | 145 | // </editor-fold> |
142 | 146 | //--------------------------------------------------------------------- |
143 | 147 | // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
148 | + |
|
149 | + /** |
|
150 | + * @param string $classname |
|
151 | + */ |
|
144 | 152 | private function generateClass($classname) |
145 | 153 | { |
146 | 154 | $date = date('Y-m-d h:i:s'); |
@@ -14,138 +14,138 @@ discard block |
||
14 | 14 | class TWsatScaffoldingGenerator extends TWsatBaseGenerator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Const View Types for generation |
|
19 | - */ |
|
20 | - const LIST_TYPE = 0; |
|
21 | - const ADD_TYPE = 1; |
|
22 | - const SHOW_TYPE = 2; |
|
23 | - |
|
24 | - /** |
|
25 | - * Bootstrap option |
|
26 | - */ |
|
27 | - private $_bootstrap; |
|
28 | - |
|
29 | - function __construct() |
|
30 | - { |
|
31 | - parent::__construct(); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Generates CRUD Operations for a single DB table |
|
36 | - * @param type $tableName |
|
37 | - */ |
|
38 | - public function generateCRUD($tableName) |
|
39 | - { |
|
40 | - $this->generate($tableName, self::ADD_TYPE); |
|
41 | - $this->generate($tableName, self::LIST_TYPE); |
|
42 | - $this->generate($tableName, self::SHOW_TYPE); |
|
43 | - } |
|
44 | - |
|
45 | - //--------------------------------------------------------------------- |
|
46 | - // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
|
47 | - public function generate($tableName, $viewType) |
|
48 | - { |
|
49 | - switch ($viewType) |
|
50 | - { |
|
51 | - default: |
|
52 | - case self::LIST_TYPE: |
|
53 | - $unitName = "list" . ucfirst($tableName); |
|
54 | - break; |
|
55 | - |
|
56 | - case self::ADD_TYPE: |
|
57 | - $unitName = "add" . ucfirst($tableName); |
|
58 | - break; |
|
59 | - |
|
60 | - case self::SHOW_TYPE: |
|
61 | - $unitName = "show" . ucfirst($tableName); |
|
62 | - break; |
|
63 | - } |
|
64 | - |
|
65 | - $class = $this->generateClass($unitName); |
|
66 | - $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
67 | - file_put_contents($outputClass, $class); |
|
68 | - |
|
69 | - $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
70 | - $page = $this->generatePage($tableName, $viewType); |
|
71 | - file_put_contents($outputPage, $page); |
|
72 | - } |
|
73 | - |
|
74 | - private function generatePage($tableName, $type, $tContentId = "Content") |
|
75 | - { |
|
76 | - $pageContent = $this->getPageContent($tableName, $type); |
|
77 | - return <<<EOD |
|
17 | + /** |
|
18 | + * Const View Types for generation |
|
19 | + */ |
|
20 | + const LIST_TYPE = 0; |
|
21 | + const ADD_TYPE = 1; |
|
22 | + const SHOW_TYPE = 2; |
|
23 | + |
|
24 | + /** |
|
25 | + * Bootstrap option |
|
26 | + */ |
|
27 | + private $_bootstrap; |
|
28 | + |
|
29 | + function __construct() |
|
30 | + { |
|
31 | + parent::__construct(); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Generates CRUD Operations for a single DB table |
|
36 | + * @param type $tableName |
|
37 | + */ |
|
38 | + public function generateCRUD($tableName) |
|
39 | + { |
|
40 | + $this->generate($tableName, self::ADD_TYPE); |
|
41 | + $this->generate($tableName, self::LIST_TYPE); |
|
42 | + $this->generate($tableName, self::SHOW_TYPE); |
|
43 | + } |
|
44 | + |
|
45 | + //--------------------------------------------------------------------- |
|
46 | + // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
|
47 | + public function generate($tableName, $viewType) |
|
48 | + { |
|
49 | + switch ($viewType) |
|
50 | + { |
|
51 | + default: |
|
52 | + case self::LIST_TYPE: |
|
53 | + $unitName = "list" . ucfirst($tableName); |
|
54 | + break; |
|
55 | + |
|
56 | + case self::ADD_TYPE: |
|
57 | + $unitName = "add" . ucfirst($tableName); |
|
58 | + break; |
|
59 | + |
|
60 | + case self::SHOW_TYPE: |
|
61 | + $unitName = "show" . ucfirst($tableName); |
|
62 | + break; |
|
63 | + } |
|
64 | + |
|
65 | + $class = $this->generateClass($unitName); |
|
66 | + $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
67 | + file_put_contents($outputClass, $class); |
|
68 | + |
|
69 | + $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
70 | + $page = $this->generatePage($tableName, $viewType); |
|
71 | + file_put_contents($outputPage, $page); |
|
72 | + } |
|
73 | + |
|
74 | + private function generatePage($tableName, $type, $tContentId = "Content") |
|
75 | + { |
|
76 | + $pageContent = $this->getPageContent($tableName, $type); |
|
77 | + return <<<EOD |
|
78 | 78 | <com:TContent ID="$tContentId"> |
79 | 79 | |
80 | 80 | $pageContent |
81 | 81 | |
82 | 82 | </com:TContent> |
83 | 83 | EOD; |
84 | - } |
|
85 | - |
|
86 | - private function getPageContent($tableName, $type) |
|
87 | - { |
|
88 | - $code = ""; |
|
89 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
90 | - switch ($type) |
|
91 | - { |
|
92 | - case self::LIST_TYPE: |
|
93 | - break; |
|
94 | - case self::ADD_TYPE: |
|
95 | - foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
96 | - { |
|
97 | - if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
98 | - { |
|
99 | - $code .= $this->generateControl($colMetadata); |
|
100 | - $code .= $this->generateValidators($colMetadata); |
|
101 | - $code .= "\n"; |
|
102 | - } |
|
103 | - } |
|
104 | - foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
105 | - { |
|
106 | - $colField = $this->eq($colMetadata["table"]); |
|
107 | - $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
108 | - $code .= "\n"; |
|
109 | - // TWsatBaseGenerator::pr($tableInfo); |
|
110 | - } |
|
111 | - $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
112 | - |
|
113 | - case self::SHOW_TYPE: |
|
114 | - break; |
|
115 | - } |
|
116 | - return $code; |
|
117 | - } |
|
118 | - |
|
119 | - private function generateControl($colMetadata) |
|
120 | - { |
|
121 | - $controlType = "TTextBox"; |
|
122 | - switch ($colMetadata->DbType) |
|
123 | - { |
|
84 | + } |
|
85 | + |
|
86 | + private function getPageContent($tableName, $type) |
|
87 | + { |
|
88 | + $code = ""; |
|
89 | + $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
90 | + switch ($type) |
|
91 | + { |
|
92 | + case self::LIST_TYPE: |
|
93 | + break; |
|
94 | + case self::ADD_TYPE: |
|
95 | + foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
96 | + { |
|
97 | + if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
98 | + { |
|
99 | + $code .= $this->generateControl($colMetadata); |
|
100 | + $code .= $this->generateValidators($colMetadata); |
|
101 | + $code .= "\n"; |
|
102 | + } |
|
103 | + } |
|
104 | + foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
105 | + { |
|
106 | + $colField = $this->eq($colMetadata["table"]); |
|
107 | + $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
108 | + $code .= "\n"; |
|
109 | + // TWsatBaseGenerator::pr($tableInfo); |
|
110 | + } |
|
111 | + $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
112 | + |
|
113 | + case self::SHOW_TYPE: |
|
114 | + break; |
|
115 | + } |
|
116 | + return $code; |
|
117 | + } |
|
118 | + |
|
119 | + private function generateControl($colMetadata) |
|
120 | + { |
|
121 | + $controlType = "TTextBox"; |
|
122 | + switch ($colMetadata->DbType) |
|
123 | + { |
|
124 | 124 | |
125 | - } |
|
126 | - $controlId = $colMetadata->ColumnId; |
|
127 | - return "\t<com:$controlType ID=\"$controlId\" />\n"; |
|
128 | - } |
|
129 | - |
|
130 | - private function generateValidators($colMetadata) |
|
131 | - { |
|
132 | - $controlId = $colMetadata->ColumnId; |
|
133 | - $code = ""; |
|
134 | - if (!$colMetadata->AllowNull) |
|
135 | - { |
|
136 | - $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
137 | - } |
|
138 | - return $code; |
|
139 | - } |
|
125 | + } |
|
126 | + $controlId = $colMetadata->ColumnId; |
|
127 | + return "\t<com:$controlType ID=\"$controlId\" />\n"; |
|
128 | + } |
|
129 | + |
|
130 | + private function generateValidators($colMetadata) |
|
131 | + { |
|
132 | + $controlId = $colMetadata->ColumnId; |
|
133 | + $code = ""; |
|
134 | + if (!$colMetadata->AllowNull) |
|
135 | + { |
|
136 | + $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
137 | + } |
|
138 | + return $code; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | // </editor-fold> |
142 | - //--------------------------------------------------------------------- |
|
143 | - // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
|
144 | - private function generateClass($classname) |
|
145 | - { |
|
146 | - $date = date('Y-m-d h:i:s'); |
|
147 | - $env_user = getenv("username"); |
|
148 | - return <<<EOD |
|
142 | + //--------------------------------------------------------------------- |
|
143 | + // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
|
144 | + private function generateClass($classname) |
|
145 | + { |
|
146 | + $date = date('Y-m-d h:i:s'); |
|
147 | + $env_user = getenv("username"); |
|
148 | + return <<<EOD |
|
149 | 149 | <?php |
150 | 150 | /** |
151 | 151 | * Auto generated by PRADO - WSAT on $date. |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | } |
158 | 158 | EOD; |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | 161 | // </editor-fold> |
162 | 162 | } |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Const View Types for generation |
19 | 19 | */ |
20 | - const LIST_TYPE = 0; |
|
21 | - const ADD_TYPE = 1; |
|
22 | - const SHOW_TYPE = 2; |
|
20 | + const LIST_TYPE=0; |
|
21 | + const ADD_TYPE=1; |
|
22 | + const SHOW_TYPE=2; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Bootstrap option |
@@ -46,34 +46,34 @@ discard block |
||
46 | 46 | // <editor-fold defaultstate="collapsed" desc="Page Generation"> |
47 | 47 | public function generate($tableName, $viewType) |
48 | 48 | { |
49 | - switch ($viewType) |
|
49 | + switch($viewType) |
|
50 | 50 | { |
51 | 51 | default: |
52 | 52 | case self::LIST_TYPE: |
53 | - $unitName = "list" . ucfirst($tableName); |
|
53 | + $unitName="list".ucfirst($tableName); |
|
54 | 54 | break; |
55 | 55 | |
56 | 56 | case self::ADD_TYPE: |
57 | - $unitName = "add" . ucfirst($tableName); |
|
57 | + $unitName="add".ucfirst($tableName); |
|
58 | 58 | break; |
59 | 59 | |
60 | 60 | case self::SHOW_TYPE: |
61 | - $unitName = "show" . ucfirst($tableName); |
|
61 | + $unitName="show".ucfirst($tableName); |
|
62 | 62 | break; |
63 | 63 | } |
64 | 64 | |
65 | - $class = $this->generateClass($unitName); |
|
66 | - $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
65 | + $class=$this->generateClass($unitName); |
|
66 | + $outputClass=$this->_opFile.DIRECTORY_SEPARATOR.$unitName.".php"; |
|
67 | 67 | file_put_contents($outputClass, $class); |
68 | 68 | |
69 | - $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
70 | - $page = $this->generatePage($tableName, $viewType); |
|
69 | + $outputPage=$this->_opFile.DIRECTORY_SEPARATOR.$unitName.".page"; |
|
70 | + $page=$this->generatePage($tableName, $viewType); |
|
71 | 71 | file_put_contents($outputPage, $page); |
72 | 72 | } |
73 | 73 | |
74 | - private function generatePage($tableName, $type, $tContentId = "Content") |
|
74 | + private function generatePage($tableName, $type, $tContentId="Content") |
|
75 | 75 | { |
76 | - $pageContent = $this->getPageContent($tableName, $type); |
|
76 | + $pageContent=$this->getPageContent($tableName, $type); |
|
77 | 77 | return <<<EOD |
78 | 78 | <com:TContent ID="$tContentId"> |
79 | 79 | |
@@ -85,30 +85,30 @@ discard block |
||
85 | 85 | |
86 | 86 | private function getPageContent($tableName, $type) |
87 | 87 | { |
88 | - $code = ""; |
|
89 | - $tableInfo = $this->_dbMetaData->getTableInfo($tableName); |
|
90 | - switch ($type) |
|
88 | + $code=""; |
|
89 | + $tableInfo=$this->_dbMetaData->getTableInfo($tableName); |
|
90 | + switch($type) |
|
91 | 91 | { |
92 | 92 | case self::LIST_TYPE: |
93 | 93 | break; |
94 | 94 | case self::ADD_TYPE: |
95 | - foreach ($tableInfo->getColumns() as $colField => $colMetadata) |
|
95 | + foreach($tableInfo->getColumns() as $colField => $colMetadata) |
|
96 | 96 | { |
97 | - if (!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
97 | + if(!$colMetadata->IsPrimaryKey && !$colMetadata->IsForeignKey) |
|
98 | 98 | { |
99 | - $code .= $this->generateControl($colMetadata); |
|
100 | - $code .= $this->generateValidators($colMetadata); |
|
101 | - $code .= "\n"; |
|
99 | + $code.=$this->generateControl($colMetadata); |
|
100 | + $code.=$this->generateValidators($colMetadata); |
|
101 | + $code.="\n"; |
|
102 | 102 | } |
103 | 103 | } |
104 | - foreach ($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
104 | + foreach($tableInfo->getForeignKeys() as $colField => $colMetadata) |
|
105 | 105 | { |
106 | - $colField = $this->eq($colMetadata["table"]); |
|
107 | - $code .= "\t<com:TTextBox ID=$colField />\n"; |
|
108 | - $code .= "\n"; |
|
106 | + $colField=$this->eq($colMetadata["table"]); |
|
107 | + $code.="\t<com:TTextBox ID=$colField />\n"; |
|
108 | + $code.="\n"; |
|
109 | 109 | // TWsatBaseGenerator::pr($tableInfo); |
110 | 110 | } |
111 | - $code .= "\t<com:TButton Text=\"Accept\" />\n"; |
|
111 | + $code.="\t<com:TButton Text=\"Accept\" />\n"; |
|
112 | 112 | |
113 | 113 | case self::SHOW_TYPE: |
114 | 114 | break; |
@@ -118,22 +118,22 @@ discard block |
||
118 | 118 | |
119 | 119 | private function generateControl($colMetadata) |
120 | 120 | { |
121 | - $controlType = "TTextBox"; |
|
122 | - switch ($colMetadata->DbType) |
|
121 | + $controlType="TTextBox"; |
|
122 | + switch($colMetadata->DbType) |
|
123 | 123 | { |
124 | 124 | |
125 | 125 | } |
126 | - $controlId = $colMetadata->ColumnId; |
|
126 | + $controlId=$colMetadata->ColumnId; |
|
127 | 127 | return "\t<com:$controlType ID=\"$controlId\" />\n"; |
128 | 128 | } |
129 | 129 | |
130 | 130 | private function generateValidators($colMetadata) |
131 | 131 | { |
132 | - $controlId = $colMetadata->ColumnId; |
|
133 | - $code = ""; |
|
134 | - if (!$colMetadata->AllowNull) |
|
132 | + $controlId=$colMetadata->ColumnId; |
|
133 | + $code=""; |
|
134 | + if(!$colMetadata->AllowNull) |
|
135 | 135 | { |
136 | - $code .= "\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
136 | + $code.="\t<com:TRequiredFieldValidator ControlToValidate=$controlId ValidationGroup=\"addGroup\" Text=\"Field $controlId is required.\" Display=\"Dynamic\" />\n"; |
|
137 | 137 | } |
138 | 138 | return $code; |
139 | 139 | } |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | // <editor-fold defaultstate="collapsed" desc="Code Behind Generation"> |
144 | 144 | private function generateClass($classname) |
145 | 145 | { |
146 | - $date = date('Y-m-d h:i:s'); |
|
147 | - $env_user = getenv("username"); |
|
146 | + $date=date('Y-m-d h:i:s'); |
|
147 | + $env_user=getenv("username"); |
|
148 | 148 | return <<<EOD |
149 | 149 | <?php |
150 | 150 | /** |
@@ -289,7 +289,7 @@ |
||
289 | 289 | |
290 | 290 | // check for authentication expiration |
291 | 291 | $isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() && |
292 | - ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time(); |
|
292 | + ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time(); |
|
293 | 293 | |
294 | 294 | // try authenticating through cookie if possible |
295 | 295 | if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired)) |
@@ -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 | } |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | if(is_string($this->_userManager)) |
95 | 95 | { |
96 | 96 | if(($users=$application->getModule($this->_userManager))===null) |
97 | - throw new TConfigurationException('authmanager_usermanager_inexistent',$this->_userManager); |
|
97 | + throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager); |
|
98 | 98 | if(!($users instanceof IUserManager)) |
99 | - throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager); |
|
99 | + throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
|
100 | 100 | $this->_userManager=$users; |
101 | 101 | } |
102 | - $application->attachEventHandler('OnAuthentication',array($this,'doAuthentication')); |
|
103 | - $application->attachEventHandler('OnEndRequest',array($this,'leave')); |
|
104 | - $application->attachEventHandler('OnAuthorization',array($this,'doAuthorization')); |
|
102 | + $application->attachEventHandler('OnAuthentication', array($this, 'doAuthentication')); |
|
103 | + $application->attachEventHandler('OnEndRequest', array($this, 'leave')); |
|
104 | + $application->attachEventHandler('OnAuthorization', array($this, 'doAuthorization')); |
|
105 | 105 | $this->_initialized=true; |
106 | 106 | } |
107 | 107 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | if($this->_initialized) |
123 | 123 | throw new TInvalidOperationException('authmanager_usermanager_unchangeable'); |
124 | 124 | if(!is_string($provider) && !($provider instanceof IUserManager)) |
125 | - throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager); |
|
125 | + throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
|
126 | 126 | $this->_userManager=$provider; |
127 | 127 | } |
128 | 128 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param mixed sender of the Authentication event |
153 | 153 | * @param mixed event parameter |
154 | 154 | */ |
155 | - public function doAuthentication($sender,$param) |
|
155 | + public function doAuthentication($sender, $param) |
|
156 | 156 | { |
157 | 157 | $this->onAuthenticate($param); |
158 | 158 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param mixed sender of the Authorization event |
169 | 169 | * @param mixed event parameter |
170 | 170 | */ |
171 | - public function doAuthorization($sender,$param) |
|
171 | + public function doAuthorization($sender, $param) |
|
172 | 172 | { |
173 | 173 | if(!$this->_skipAuthorization) |
174 | 174 | { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param mixed sender of the event |
184 | 184 | * @param mixed event parameter |
185 | 185 | */ |
186 | - public function leave($sender,$param) |
|
186 | + public function leave($sender, $param) |
|
187 | 187 | { |
188 | 188 | $application=$this->getApplication(); |
189 | 189 | if($application->getResponse()->getStatusCode()===401) |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function setReturnUrl($value) |
231 | 231 | { |
232 | - $this->getSession()->add($this->getReturnUrlVarName(),$value); |
|
232 | + $this->getSession()->add($this->getReturnUrlVarName(), $value); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | $user=$this->_userManager->getUser(null)->loadFromString($sessionInfo); |
289 | 289 | |
290 | 290 | // check for authentication expiration |
291 | - $isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() && |
|
292 | - ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time(); |
|
291 | + $isAuthExpired=$this->_authExpire > 0 && !$user->getIsGuest() && |
|
292 | + ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime < time(); |
|
293 | 293 | |
294 | 294 | // try authenticating through cookie if possible |
295 | 295 | if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired)) |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $user=$user2; |
303 | 303 | $this->updateSessionUser($user); |
304 | 304 | // user is restored from cookie, auth may not expire |
305 | - $isAuthExpired = false; |
|
305 | + $isAuthExpired=false; |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | // event handler gets a chance to do further auth work |
319 | 319 | if($this->hasEventHandler('OnAuthenticate')) |
320 | - $this->raiseEvent('OnAuthenticate',$this,$application); |
|
320 | + $this->raiseEvent('OnAuthenticate', $this, $application); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | { |
330 | 330 | $this->logout(); |
331 | 331 | if($this->hasEventHandler('OnAuthExpire')) |
332 | - $this->raiseEvent('OnAuthExpire',$this,$param); |
|
332 | + $this->raiseEvent('OnAuthExpire', $this, $param); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | { |
344 | 344 | $application=$this->getApplication(); |
345 | 345 | if($this->hasEventHandler('OnAuthorize')) |
346 | - $this->raiseEvent('OnAuthorize',$this,$application); |
|
347 | - if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(),$application->getRequest()->getRequestType(),$application->getRequest()->getUserHostAddress())) |
|
346 | + $this->raiseEvent('OnAuthorize', $this, $application); |
|
347 | + if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress())) |
|
348 | 348 | { |
349 | 349 | $application->getResponse()->setStatusCode(401); |
350 | 350 | $application->completeRequest(); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | if(($session=$this->getSession())===null) |
384 | 384 | throw new TConfigurationException('authmanager_session_required'); |
385 | 385 | else |
386 | - $session->add($this->getUserKey(),$user->saveToString()); |
|
386 | + $session->add($this->getUserKey(), $user->saveToString()); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
@@ -411,19 +411,19 @@ discard block |
||
411 | 411 | * @param integer number of seconds that automatic login will remain effective. If 0, it means user logs out when session ends. This parameter is added since 3.1.1. |
412 | 412 | * @return boolean if login is successful |
413 | 413 | */ |
414 | - public function login($username,$password,$expire=0) |
|
414 | + public function login($username, $password, $expire=0) |
|
415 | 415 | { |
416 | - if($this->_userManager->validateUser($username,$password)) |
|
416 | + if($this->_userManager->validateUser($username, $password)) |
|
417 | 417 | { |
418 | 418 | if(($user=$this->_userManager->getUser($username))===null) |
419 | 419 | return false; |
420 | 420 | $this->updateSessionUser($user); |
421 | 421 | $this->getApplication()->setUser($user); |
422 | 422 | |
423 | - if($expire>0) |
|
423 | + if($expire > 0) |
|
424 | 424 | { |
425 | - $cookie=new THttpCookie($this->getUserKey(),''); |
|
426 | - $cookie->setExpire(time()+$expire); |
|
425 | + $cookie=new THttpCookie($this->getUserKey(), ''); |
|
426 | + $cookie->setExpire(time() + $expire); |
|
427 | 427 | $this->_userManager->saveUserToCookie($cookie); |
428 | 428 | $this->getResponse()->getCookies()->add($cookie); |
429 | 429 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | $session->destroy(); |
447 | 447 | if($this->getAllowAutoLogin()) |
448 | 448 | { |
449 | - $cookie=new THttpCookie($this->getUserKey(),''); |
|
449 | + $cookie=new THttpCookie($this->getUserKey(), ''); |
|
450 | 450 | $this->getResponse()->getCookies()->add($cookie); |
451 | 451 | } |
452 | 452 | } |
@@ -228,6 +228,7 @@ discard block |
||
228 | 228 | /** |
229 | 229 | * Sets the URL that the browser should be redirected to when login succeeds. |
230 | 230 | * @param string the URL to be redirected to. |
231 | + * @param string $value |
|
231 | 232 | */ |
232 | 233 | public function setReturnUrl($value) |
233 | 234 | { |
@@ -376,6 +377,7 @@ discard block |
||
376 | 377 | /** |
377 | 378 | * Updates the user data stored in session. |
378 | 379 | * @param IUser user object |
380 | + * @param TUser $user |
|
379 | 381 | * @throws new TConfigurationException if session module is not loaded. |
380 | 382 | */ |
381 | 383 | public function updateSessionUser($user) |