@@ -215,6 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | /** |
217 | 217 | * @param string javascript package path. |
218 | + * @param string $base |
|
218 | 219 | * @return array tuple($path,$url). |
219 | 220 | */ |
220 | 221 | protected function getPackagePathUrl($base) |
@@ -496,6 +497,8 @@ discard block |
||
496 | 497 | * @param string a unique key identifying the hidden field |
497 | 498 | * @param string|array hidden field value, if the value is an array, every element |
498 | 499 | * in the array will be rendered as a hidden field value. |
500 | + * @param string $name |
|
501 | + * @param string $value |
|
499 | 502 | */ |
500 | 503 | public function registerHiddenField($name,$value) |
501 | 504 | { |
@@ -735,6 +738,7 @@ discard block |
||
735 | 738 | |
736 | 739 | /** |
737 | 740 | * @param THtmlWriter writer for the rendering purpose |
741 | + * @param boolean $initial |
|
738 | 742 | */ |
739 | 743 | protected function renderHiddenFieldsInt($writer, $initial) |
740 | 744 | { |
@@ -799,6 +803,7 @@ discard block |
||
799 | 803 | * javascript statements. |
800 | 804 | * @param string option name |
801 | 805 | * @param string javascript statements. |
806 | + * @param string $name |
|
802 | 807 | */ |
803 | 808 | protected function setFunction($name, $code) |
804 | 809 | { |
@@ -808,6 +813,7 @@ discard block |
||
808 | 813 | } |
809 | 814 | |
810 | 815 | /** |
816 | + * @param string $name |
|
811 | 817 | * @return string gets a particular option, null if not set. |
812 | 818 | */ |
813 | 819 | protected function getOption($name) |
@@ -226,8 +226,7 @@ discard block |
||
226 | 226 | $base = $dir; |
227 | 227 | } |
228 | 228 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
229 | - } |
|
230 | - else |
|
229 | + } else |
|
231 | 230 | { |
232 | 231 | return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
233 | 232 | } |
@@ -748,8 +747,7 @@ discard block |
||
748 | 747 | { |
749 | 748 | foreach($value as $v) |
750 | 749 | $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
751 | - } |
|
752 | - else |
|
750 | + } else |
|
753 | 751 | { |
754 | 752 | $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
755 | 753 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | { |
145 | 145 | $this->registerPradoScriptInternal($name); |
146 | 146 | $params=func_get_args(); |
147 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoScript',$params); |
|
147 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoScript', $params); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -155,39 +155,39 @@ discard block |
||
155 | 155 | // $this->checkIfNotInRender(); |
156 | 156 | if(!isset($this->_registeredPradoScripts[$name])) |
157 | 157 | { |
158 | - if(self::$_pradoScripts === null) |
|
158 | + if(self::$_pradoScripts===null) |
|
159 | 159 | { |
160 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
161 | - list($packages,$deps)= include($packageFile); |
|
162 | - self::$_pradoScripts = $deps; |
|
163 | - self::$_pradoPackages = $packages; |
|
160 | + $packageFile=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
161 | + list($packages, $deps)=include($packageFile); |
|
162 | + self::$_pradoScripts=$deps; |
|
163 | + self::$_pradoPackages=$packages; |
|
164 | 164 | } |
165 | 165 | |
166 | - if (isset(self::$_pradoScripts[$name])) |
|
166 | + if(isset(self::$_pradoScripts[$name])) |
|
167 | 167 | $this->_registeredPradoScripts[$name]=true; |
168 | 168 | else |
169 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
169 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
170 | 170 | |
171 | 171 | if(($packages=array_keys($this->_registeredPradoScripts))!==array()) |
172 | 172 | { |
173 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
174 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
173 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
174 | + list($path, $baseUrl)=$this->getPackagePathUrl($base); |
|
175 | 175 | $packagesUrl=array(); |
176 | 176 | $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
177 | - foreach ($packages as $p) |
|
177 | + foreach($packages as $p) |
|
178 | 178 | { |
179 | - foreach (self::$_pradoScripts[$p] as $dep) |
|
179 | + foreach(self::$_pradoScripts[$p] as $dep) |
|
180 | 180 | { |
181 | - foreach (self::$_pradoPackages[$dep] as $script) |
|
182 | - if (!isset($this->_expandedPradoScripts[$script])) |
|
181 | + foreach(self::$_pradoPackages[$dep] as $script) |
|
182 | + if(!isset($this->_expandedPradoScripts[$script])) |
|
183 | 183 | { |
184 | - $this->_expandedPradoScripts[$script] = true; |
|
184 | + $this->_expandedPradoScripts[$script]=true; |
|
185 | 185 | if($isDebug) |
186 | 186 | { |
187 | - if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
|
187 | + if(!in_array($url=$baseUrl.'/'.$script, $packagesUrl)) |
|
188 | 188 | $packagesUrl[]=$url; |
189 | 189 | } else { |
190 | - if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl)) |
|
190 | + if(!in_array($url=$baseUrl.'/min/'.$script, $packagesUrl)) |
|
191 | 191 | { |
192 | 192 | if(!is_file($filePath=$path.'/min/'.$script)) |
193 | 193 | { |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | } |
206 | 206 | foreach($packagesUrl as $url) |
207 | - $this->registerScriptFile($url,$url); |
|
207 | + $this->registerScriptFile($url, $url); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function getPradoScriptAssetUrl() |
216 | 216 | { |
217 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
218 | - $assets = Prado::getApplication()->getAssetManager(); |
|
217 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
218 | + $assets=Prado::getApplication()->getAssetManager(); |
|
219 | 219 | return $assets->getPublishedUrl($base); |
220 | 220 | } |
221 | 221 | |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function getScriptUrls() |
227 | 227 | { |
228 | - $scripts = array_values($this->_headScriptFiles); |
|
229 | - $scripts = array_merge($scripts, array_values($this->_scriptFiles)); |
|
230 | - $scripts = array_unique($scripts); |
|
228 | + $scripts=array_values($this->_headScriptFiles); |
|
229 | + $scripts=array_merge($scripts, array_values($this->_scriptFiles)); |
|
230 | + $scripts=array_unique($scripts); |
|
231 | 231 | |
232 | 232 | return $scripts; |
233 | 233 | } |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | */ |
239 | 239 | protected function getPackagePathUrl($base) |
240 | 240 | { |
241 | - $assets = Prado::getApplication()->getAssetManager(); |
|
241 | + $assets=Prado::getApplication()->getAssetManager(); |
|
242 | 242 | if(strpos($base, $assets->getBaseUrl())===false) |
243 | 243 | { |
244 | - if(($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
245 | - $base = $dir; |
|
244 | + if(($dir=Prado::getPathOfNameSpace($base))!==null) { |
|
245 | + $base=$dir; |
|
246 | 246 | } |
247 | 247 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | - return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
|
251 | + return array($assets->getBasePath().str_replace($assets->getBaseUrl(), '', $base), $base); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null) |
262 | 262 | { |
263 | - $options = !is_array($options) ? array() : $options; |
|
264 | - $class = new ReflectionClass($callbackHandler); |
|
265 | - $clientSide = $callbackHandler->getActiveControl()->getClientSide(); |
|
266 | - $options = array_merge($options, $clientSide->getOptions()->toArray()); |
|
267 | - $optionString = TJavaScript::encode($options); |
|
263 | + $options=!is_array($options) ? array() : $options; |
|
264 | + $class=new ReflectionClass($callbackHandler); |
|
265 | + $clientSide=$callbackHandler->getActiveControl()->getClientSide(); |
|
266 | + $options=array_merge($options, $clientSide->getOptions()->toArray()); |
|
267 | + $optionString=TJavaScript::encode($options); |
|
268 | 268 | $this->registerPradoScriptInternal('ajax'); |
269 | - $id = $callbackHandler->getUniqueID(); |
|
269 | + $id=$callbackHandler->getUniqueID(); |
|
270 | 270 | return "new Prado.CallbackRequest('{$id}',{$optionString})"; |
271 | 271 | } |
272 | 272 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $this->registerPradoScriptInternal('ajax'); |
284 | 284 | |
285 | 285 | $params=func_get_args(); |
286 | - $this->_page->registerCachingAction('Page.ClientScript','registerCallbackControl',$params); |
|
286 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerCallbackControl', $params); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @param string javascript class responsible for the control being registered for postback |
293 | 293 | * @param array postback options |
294 | 294 | */ |
295 | - public function registerPostBackControl($class,$options) |
|
295 | + public function registerPostBackControl($class, $options) |
|
296 | 296 | { |
297 | - if($class === null) { |
|
297 | + if($class===null) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | 300 | if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $this->registerPradoScriptInternal('prado'); |
307 | 307 | |
308 | 308 | $params=func_get_args(); |
309 | - $this->_page->registerCachingAction('Page.ClientScript','registerPostBackControl',$params); |
|
309 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPostBackControl', $params); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function registerDefaultButton($panel, $button) |
319 | 319 | { |
320 | - $panelID=is_string($panel)?$panel:$panel->getUniqueID(); |
|
320 | + $panelID=is_string($panel) ? $panel : $panel->getUniqueID(); |
|
321 | 321 | |
322 | 322 | if(is_string($button)) |
323 | 323 | $buttonID=$button; |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | $button->setIsDefaultButton(true); |
327 | 327 | $buttonID=$button->getUniqueID(); |
328 | 328 | } |
329 | - $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
|
330 | - $code = "new Prado.WebUI.DefaultButton($options);"; |
|
329 | + $options=TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
|
330 | + $code="new Prado.WebUI.DefaultButton($options);"; |
|
331 | 331 | |
332 | 332 | $this->_endScripts['prado:'.$panelID]=$code; |
333 | 333 | $this->registerPradoScriptInternal('prado'); |
334 | 334 | |
335 | - $params=array($panelID,$buttonID); |
|
336 | - $this->_page->registerCachingAction('Page.ClientScript','registerDefaultButton',$params); |
|
335 | + $params=array($panelID, $buttonID); |
|
336 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | */ |
344 | 344 | protected function getDefaultButtonOptions($panelID, $buttonID) |
345 | 345 | { |
346 | - $options['ID'] = TControl::convertUniqueIdToClientId($panelID); |
|
347 | - $options['Panel'] = TControl::convertUniqueIdToClientId($panelID); |
|
348 | - $options['Target'] = TControl::convertUniqueIdToClientId($buttonID); |
|
349 | - $options['EventTarget'] = $buttonID; |
|
350 | - $options['Event'] = 'click'; |
|
346 | + $options['ID']=TControl::convertUniqueIdToClientId($panelID); |
|
347 | + $options['Panel']=TControl::convertUniqueIdToClientId($panelID); |
|
348 | + $options['Target']=TControl::convertUniqueIdToClientId($buttonID); |
|
349 | + $options['EventTarget']=$buttonID; |
|
350 | + $options['Event']='click'; |
|
351 | 351 | return $options; |
352 | 352 | } |
353 | 353 | |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | $this->registerPradoScriptInternal('jquery'); |
361 | 361 | if($target instanceof TControl) |
362 | 362 | $target=$target->getClientID(); |
363 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
|
363 | + $this->_endScripts['prado:focus']='jQuery(\'#'.$target.'\').focus();'; |
|
364 | 364 | |
365 | 365 | $params=func_get_args(); |
366 | - $this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params); |
|
366 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | { |
376 | 376 | $this->registerPradoStyleInternal($name); |
377 | 377 | $params=func_get_args(); |
378 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoStyle',$params); |
|
378 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoStyle', $params); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -386,43 +386,43 @@ discard block |
||
386 | 386 | // $this->checkIfNotInRender(); |
387 | 387 | if(!isset($this->_registeredPradoStyles[$name])) |
388 | 388 | { |
389 | - $base = $this->getPradoScriptAssetUrl(); |
|
389 | + $base=$this->getPradoScriptAssetUrl(); |
|
390 | 390 | |
391 | - if(self::$_pradoStyles === null) |
|
391 | + if(self::$_pradoStyles===null) |
|
392 | 392 | { |
393 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
394 | - list($packages,$deps)= include($packageFile); |
|
395 | - self::$_pradoStyles = $deps; |
|
396 | - self::$_pradoStylePackages = $packages; |
|
393 | + $packageFile=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::CSS_PACKAGES_FILE; |
|
394 | + list($packages, $deps)=include($packageFile); |
|
395 | + self::$_pradoStyles=$deps; |
|
396 | + self::$_pradoStylePackages=$packages; |
|
397 | 397 | } |
398 | 398 | |
399 | - if (isset(self::$_pradoStyles[$name])) |
|
399 | + if(isset(self::$_pradoStyles[$name])) |
|
400 | 400 | $this->_registeredPradoStyles[$name]=true; |
401 | 401 | else |
402 | - throw new TInvalidOperationException('csmanager_pradostyle_invalid',$name); |
|
402 | + throw new TInvalidOperationException('csmanager_pradostyle_invalid', $name); |
|
403 | 403 | |
404 | 404 | if(($packages=array_keys($this->_registeredPradoStyles))!==array()) |
405 | 405 | { |
406 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
407 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
406 | + $base=Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
407 | + list($path, $baseUrl)=$this->getPackagePathUrl($base); |
|
408 | 408 | $packagesUrl=array(); |
409 | 409 | $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
410 | - foreach ($packages as $p) |
|
410 | + foreach($packages as $p) |
|
411 | 411 | { |
412 | - foreach (self::$_pradoStyles[$p] as $dep) |
|
412 | + foreach(self::$_pradoStyles[$p] as $dep) |
|
413 | 413 | { |
414 | - foreach (self::$_pradoStylePackages[$dep] as $style) |
|
415 | - if (!isset($this->_expandedPradoStyles[$style])) |
|
414 | + foreach(self::$_pradoStylePackages[$dep] as $style) |
|
415 | + if(!isset($this->_expandedPradoStyles[$style])) |
|
416 | 416 | { |
417 | - $this->_expandedPradoStyles[$style] = true; |
|
417 | + $this->_expandedPradoStyles[$style]=true; |
|
418 | 418 | // TODO minify css? |
419 | - if (!in_array($url=$baseUrl.'/'.$style,$packagesUrl)) |
|
419 | + if(!in_array($url=$baseUrl.'/'.$style, $packagesUrl)) |
|
420 | 420 | $packagesUrl[]=$url; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | } |
424 | 424 | foreach($packagesUrl as $url) |
425 | - $this->registerStyleSheetFile($url,$url); |
|
425 | + $this->registerStyleSheetFile($url, $url); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @param string URL to the CSS file |
450 | 450 | * @param string media type of the CSS (such as 'print', 'screen', etc.). Defaults to empty, meaning the CSS applies to all media types. |
451 | 451 | */ |
452 | - public function registerStyleSheetFile($key,$url,$media='') |
|
452 | + public function registerStyleSheetFile($key, $url, $media='') |
|
453 | 453 | { |
454 | 454 | if($media==='') |
455 | 455 | $this->_styleSheetFiles[$key]=$url; |
456 | 456 | else |
457 | - $this->_styleSheetFiles[$key]=array($url,$media); |
|
457 | + $this->_styleSheetFiles[$key]=array($url, $media); |
|
458 | 458 | |
459 | 459 | $params=func_get_args(); |
460 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); |
|
460 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -465,12 +465,12 @@ discard block |
||
465 | 465 | * @param string a unique key identifying the CSS block |
466 | 466 | * @param string CSS block |
467 | 467 | */ |
468 | - public function registerStyleSheet($key,$css,$media='') |
|
468 | + public function registerStyleSheet($key, $css, $media='') |
|
469 | 469 | { |
470 | 470 | $this->_styleSheets[$key]=$css; |
471 | 471 | |
472 | 472 | $params=func_get_args(); |
473 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheet',$params); |
|
473 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheet', $params); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function getStyleSheetUrls() |
481 | 481 | { |
482 | - $stylesheets = array_values( |
|
482 | + $stylesheets=array_values( |
|
483 | 483 | array_map( |
484 | 484 | create_function('$e', 'return is_array($e) ? $e[0] : $e;'), |
485 | 485 | $this->_styleSheetFiles) |
486 | 486 | ); |
487 | 487 | |
488 | 488 | foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
489 | - if (substr($url,strlen($url)-4)=='.css') |
|
490 | - $stylesheets[] = $url; |
|
489 | + if(substr($url, strlen($url) - 4)=='.css') |
|
490 | + $stylesheets[]=$url; |
|
491 | 491 | |
492 | - $stylesheets = array_unique($stylesheets); |
|
492 | + $stylesheets=array_unique($stylesheets); |
|
493 | 493 | |
494 | 494 | return $stylesheets; |
495 | 495 | } |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | * @param string a unique key identifying the file |
509 | 509 | * @param string URL to the javascript file |
510 | 510 | */ |
511 | - public function registerHeadScriptFile($key,$url) |
|
511 | + public function registerHeadScriptFile($key, $url) |
|
512 | 512 | { |
513 | 513 | $this->checkIfNotInRender(); |
514 | 514 | $this->_headScriptFiles[$key]=$url; |
515 | 515 | |
516 | 516 | $params=func_get_args(); |
517 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScriptFile',$params); |
|
517 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScriptFile', $params); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -522,13 +522,13 @@ discard block |
||
522 | 522 | * @param string a unique key identifying the script block |
523 | 523 | * @param string javascript block |
524 | 524 | */ |
525 | - public function registerHeadScript($key,$script) |
|
525 | + public function registerHeadScript($key, $script) |
|
526 | 526 | { |
527 | 527 | $this->checkIfNotInRender(); |
528 | 528 | $this->_headScripts[$key]=$script; |
529 | 529 | |
530 | 530 | $params=func_get_args(); |
531 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScript',$params); |
|
531 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScript', $params); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | $this->_scriptFiles[$key]=$url; |
542 | 542 | |
543 | 543 | $params=func_get_args(); |
544 | - $this->_page->registerCachingAction('Page.ClientScript','registerScriptFile',$params); |
|
544 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerScriptFile', $params); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -549,13 +549,13 @@ discard block |
||
549 | 549 | * @param string a unique key identifying the script block |
550 | 550 | * @param string javascript block |
551 | 551 | */ |
552 | - public function registerBeginScript($key,$script) |
|
552 | + public function registerBeginScript($key, $script) |
|
553 | 553 | { |
554 | 554 | $this->checkIfNotInRender(); |
555 | 555 | $this->_beginScripts[$key]=$script; |
556 | 556 | |
557 | 557 | $params=func_get_args(); |
558 | - $this->_page->registerCachingAction('Page.ClientScript','registerBeginScript',$params); |
|
558 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerBeginScript', $params); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -563,12 +563,12 @@ discard block |
||
563 | 563 | * @param string a unique key identifying the script block |
564 | 564 | * @param string javascript block |
565 | 565 | */ |
566 | - public function registerEndScript($key,$script) |
|
566 | + public function registerEndScript($key, $script) |
|
567 | 567 | { |
568 | 568 | $this->_endScripts[$key]=$script; |
569 | 569 | |
570 | 570 | $params=func_get_args(); |
571 | - $this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params); |
|
571 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerEndScript', $params); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | * @param string|array hidden field value, if the value is an array, every element |
578 | 578 | * in the array will be rendered as a hidden field value. |
579 | 579 | */ |
580 | - public function registerHiddenField($name,$value) |
|
580 | + public function registerHiddenField($name, $value) |
|
581 | 581 | { |
582 | 582 | $this->_hiddenFields[$name]=$value; |
583 | 583 | |
584 | 584 | $params=func_get_args(); |
585 | - $this->_page->registerCachingAction('Page.ClientScript','registerHiddenField',$params); |
|
585 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHiddenField', $params); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | public function renderStyleSheets($writer) |
696 | 696 | { |
697 | 697 | if(count($this->_styleSheets)) |
698 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
698 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n", $this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | */ |
704 | 704 | public function renderHeadScriptFiles($writer) |
705 | 705 | { |
706 | - $this->renderScriptFiles($writer,$this->_headScriptFiles); |
|
706 | + $this->renderScriptFiles($writer, $this->_headScriptFiles); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -726,9 +726,9 @@ discard block |
||
726 | 726 | |
727 | 727 | public function markScriptFileAsRendered($url) |
728 | 728 | { |
729 | - $this->_renderedScriptFiles[$url] = $url; |
|
729 | + $this->_renderedScriptFiles[$url]=$url; |
|
730 | 730 | $params=func_get_args(); |
731 | - $this->_page->registerCachingAction('Page.ClientScript','markScriptFileAsRendered',$params); |
|
731 | + $this->_page->registerCachingAction('Page.ClientScript', 'markScriptFileAsRendered', $params); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | protected function renderScriptFiles($writer, Array $scripts) |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | { |
753 | 753 | if(!empty($this->_scriptFiles)) |
754 | 754 | { |
755 | - $addedScripts = array_diff($this->_scriptFiles,$this->getRenderedScriptFiles()); |
|
756 | - $this->renderScriptFiles($writer,$addedScripts); |
|
755 | + $addedScripts=array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
|
756 | + $this->renderScriptFiles($writer, $addedScripts); |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
@@ -791,12 +791,12 @@ discard block |
||
791 | 791 | |
792 | 792 | public function renderHiddenFieldsBegin($writer) |
793 | 793 | { |
794 | - $this->renderHiddenFieldsInt($writer,true); |
|
794 | + $this->renderHiddenFieldsInt($writer, true); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | public function renderHiddenFieldsEnd($writer) |
798 | 798 | { |
799 | - $this->renderHiddenFieldsInt($writer,false); |
|
799 | + $this->renderHiddenFieldsInt($writer, false); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -818,12 +818,12 @@ discard block |
||
818 | 818 | */ |
819 | 819 | protected function renderHiddenFieldsInt($writer, $initial) |
820 | 820 | { |
821 | - if ($initial) $this->_renderedHiddenFields = array(); |
|
821 | + if($initial) $this->_renderedHiddenFields=array(); |
|
822 | 822 | $str=''; |
823 | 823 | foreach($this->_hiddenFields as $name=>$value) |
824 | 824 | { |
825 | - if (in_array($name,$this->_renderedHiddenFields)) continue; |
|
826 | - $id=strtr($name,':','_'); |
|
825 | + if(in_array($name, $this->_renderedHiddenFields)) continue; |
|
826 | + $id=strtr($name, ':', '_'); |
|
827 | 827 | if(is_array($value)) |
828 | 828 | { |
829 | 829 | foreach($value as $v) |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | { |
834 | 834 | $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
835 | 835 | } |
836 | - $this->_renderedHiddenFields[] = $name; |
|
836 | + $this->_renderedHiddenFields[]=$name; |
|
837 | 837 | } |
838 | 838 | if($str!=='') |
839 | 839 | $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | */ |
850 | 850 | protected function checkIfNotInRender() |
851 | 851 | { |
852 | - if ($form = $this->_page->InFormRender) |
|
852 | + if($form=$this->_page->InFormRender) |
|
853 | 853 | throw new Exception('Operation invalid when page is already rendering'); |
854 | 854 | } |
855 | 855 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | protected function setFunction($name, $code) |
884 | 884 | { |
885 | 885 | if(!TJavaScript::isJsLiteral($code)) |
886 | - $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
886 | + $code=TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
887 | 887 | $this->setOption($name, $code); |
888 | 888 | } |
889 | 889 | |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | */ |
893 | 893 | protected function getOption($name) |
894 | 894 | { |
895 | - if ($this->_options) |
|
895 | + if($this->_options) |
|
896 | 896 | return $this->_options->itemAt($name); |
897 | 897 | else |
898 | 898 | return null; |
@@ -912,8 +912,8 @@ discard block |
||
912 | 912 | */ |
913 | 913 | public function getOptions() |
914 | 914 | { |
915 | - if (!$this->_options) |
|
916 | - $this->_options = Prado::createComponent('System.Collections.TMap'); |
|
915 | + if(!$this->_options) |
|
916 | + $this->_options=Prado::createComponent('System.Collections.TMap'); |
|
917 | 917 | return $this->_options; |
918 | 918 | } |
919 | 919 |
@@ -278,6 +278,9 @@ discard block |
||
278 | 278 | $this->unloadRecursive(); |
279 | 279 | } |
280 | 280 | |
281 | + /** |
|
282 | + * @param string $enc |
|
283 | + */ |
|
281 | 284 | protected static function decodeUTF8($data, $enc) |
282 | 285 | { |
283 | 286 | if(is_array($data)) |
@@ -451,6 +454,7 @@ discard block |
||
451 | 454 | * Returns a list of registered validators. |
452 | 455 | * If validation group is specified, only the validators in that group will be returned. |
453 | 456 | * @param string validation group |
457 | + * @param string $validationGroup |
|
454 | 458 | * @return TList registered validators in the requested group. If the group is null, all validators will be returned. |
455 | 459 | */ |
456 | 460 | public function getValidators($validationGroup=null) |
@@ -562,6 +566,7 @@ discard block |
||
562 | 566 | * Applies a skin in the current theme to a control. |
563 | 567 | * This method should only be used by framework developers. |
564 | 568 | * @param TControl a control to be applied skin with |
569 | + * @param TControl $control |
|
565 | 570 | */ |
566 | 571 | public function applyControlSkin($control) |
567 | 572 | { |
@@ -856,6 +861,7 @@ discard block |
||
856 | 861 | * Processes post data. |
857 | 862 | * @param TMap post data to be processed |
858 | 863 | * @param boolean whether this method is invoked before {@link onLoad OnLoad}. |
864 | + * @param boolean $beforeLoad |
|
859 | 865 | */ |
860 | 866 | protected function processPostData($postData,$beforeLoad) |
861 | 867 | { |
@@ -981,6 +987,7 @@ discard block |
||
981 | 987 | /** |
982 | 988 | * Sets input focus on a control after the page is rendered to users. |
983 | 989 | * @param TControl|string control to receive focus, or the ID of the element on the page to receive focus |
990 | + * @param TControl $value |
|
984 | 991 | */ |
985 | 992 | public function setFocus($value) |
986 | 993 | { |
@@ -1066,6 +1073,7 @@ discard block |
||
1066 | 1073 | * Sets the state to be stored on the client side. |
1067 | 1074 | * This method should only be used by framework and control developers. |
1068 | 1075 | * @param string the state to be stored on the client side |
1076 | + * @param string $state |
|
1069 | 1077 | */ |
1070 | 1078 | public function setClientState($state) |
1071 | 1079 | { |
@@ -1185,6 +1193,8 @@ discard block |
||
1185 | 1193 | * referring to the context object (e.g. Page, Page.ClientScript). |
1186 | 1194 | * @param string method name of the context object |
1187 | 1195 | * @param array list of parameters to be passed to the action method |
1196 | + * @param string $context |
|
1197 | + * @param string $funcName |
|
1188 | 1198 | */ |
1189 | 1199 | public function registerCachingAction($context,$funcName,$funcParams) |
1190 | 1200 | { |
@@ -1230,15 +1240,18 @@ discard block |
||
1230 | 1240 | { |
1231 | 1241 | /** |
1232 | 1242 | * @param TPage the page that this persister works for |
1243 | + * @return TPage |
|
1233 | 1244 | */ |
1234 | 1245 | public function getPage(); |
1235 | 1246 | /** |
1236 | 1247 | * @param TPage the page that this persister works for |
1248 | + * @return void |
|
1237 | 1249 | */ |
1238 | 1250 | public function setPage(TPage $page); |
1239 | 1251 | /** |
1240 | 1252 | * Saves state to persistent storage. |
1241 | 1253 | * @param mixed state to be stored |
1254 | + * @return void |
|
1242 | 1255 | */ |
1243 | 1256 | public function save($state); |
1244 | 1257 | /** |
@@ -1272,6 +1285,7 @@ discard block |
||
1272 | 1285 | /** |
1273 | 1286 | * @param TPage |
1274 | 1287 | * @param mixed state data |
1288 | + * @param TPage $page |
|
1275 | 1289 | * @return string serialized data |
1276 | 1290 | */ |
1277 | 1291 | public static function serialize($page,$data) |
@@ -1291,6 +1305,7 @@ discard block |
||
1291 | 1305 | /** |
1292 | 1306 | * @param TPage |
1293 | 1307 | * @param string serialized data |
1308 | + * @param TPage $page |
|
1294 | 1309 | * @return mixed unserialized state data, null if data is corrupted |
1295 | 1310 | */ |
1296 | 1311 | public static function unserialize($page,$data) |
@@ -303,15 +303,15 @@ |
||
303 | 303 | |
304 | 304 | $this->setAdapter(new TActivePageAdapter($this)); |
305 | 305 | |
306 | - $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
307 | - if(strlen($callbackEventParameter) > 0) |
|
308 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
309 | - |
|
310 | - // Decode Callback postData from UTF-8 to current Charset |
|
311 | - if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
312 | - strtoupper($enc=$g->getCharset())!='UTF-8') |
|
313 | - foreach ($this->_postData as $k=>$v) |
|
314 | - $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
306 | + $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
307 | + if(strlen($callbackEventParameter) > 0) |
|
308 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
309 | + |
|
310 | + // Decode Callback postData from UTF-8 to current Charset |
|
311 | + if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
312 | + strtoupper($enc=$g->getCharset())!='UTF-8') |
|
313 | + foreach ($this->_postData as $k=>$v) |
|
314 | + $this->_postData[$k]=self::decodeUTF8($v, $enc); |
|
315 | 315 | |
316 | 316 | Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
317 | 317 | $this->onPreInit(null); |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function run($writer) |
183 | 183 | { |
184 | - Prado::trace("Running page life cycles",'System.Web.UI.TPage'); |
|
185 | - $this->_writer = $writer; |
|
184 | + Prado::trace("Running page life cycles", 'System.Web.UI.TPage'); |
|
185 | + $this->_writer=$writer; |
|
186 | 186 | |
187 | 187 | $this->determinePostBackMode(); |
188 | 188 | |
@@ -196,85 +196,85 @@ discard block |
||
196 | 196 | else |
197 | 197 | $this->processNormalRequest($writer); |
198 | 198 | |
199 | - $this->_writer = null; |
|
199 | + $this->_writer=null; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | protected function processNormalRequest($writer) |
203 | 203 | { |
204 | - Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
|
204 | + Prado::trace("Page onPreInit()", 'System.Web.UI.TPage'); |
|
205 | 205 | $this->onPreInit(null); |
206 | 206 | |
207 | - Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); |
|
207 | + Prado::trace("Page initRecursive()", 'System.Web.UI.TPage'); |
|
208 | 208 | $this->initRecursive(); |
209 | 209 | |
210 | - Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); |
|
210 | + Prado::trace("Page onInitComplete()", 'System.Web.UI.TPage'); |
|
211 | 211 | $this->onInitComplete(null); |
212 | 212 | |
213 | - Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); |
|
213 | + Prado::trace("Page onPreLoad()", 'System.Web.UI.TPage'); |
|
214 | 214 | $this->onPreLoad(null); |
215 | - Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); |
|
215 | + Prado::trace("Page loadRecursive()", 'System.Web.UI.TPage'); |
|
216 | 216 | $this->loadRecursive(); |
217 | - Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); |
|
217 | + Prado::trace("Page onLoadComplete()", 'System.Web.UI.TPage'); |
|
218 | 218 | $this->onLoadComplete(null); |
219 | 219 | |
220 | - Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); |
|
220 | + Prado::trace("Page preRenderRecursive()", 'System.Web.UI.TPage'); |
|
221 | 221 | $this->preRenderRecursive(); |
222 | - Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); |
|
222 | + Prado::trace("Page onPreRenderComplete()", 'System.Web.UI.TPage'); |
|
223 | 223 | $this->onPreRenderComplete(null); |
224 | 224 | |
225 | - Prado::trace("Page savePageState()",'System.Web.UI.TPage'); |
|
225 | + Prado::trace("Page savePageState()", 'System.Web.UI.TPage'); |
|
226 | 226 | $this->savePageState(); |
227 | - Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); |
|
227 | + Prado::trace("Page onSaveStateComplete()", 'System.Web.UI.TPage'); |
|
228 | 228 | $this->onSaveStateComplete(null); |
229 | 229 | |
230 | - Prado::trace("Page renderControl()",'System.Web.UI.TPage'); |
|
230 | + Prado::trace("Page renderControl()", 'System.Web.UI.TPage'); |
|
231 | 231 | $this->renderControl($writer); |
232 | - Prado::trace("Page unloadRecursive()",'System.Web.UI.TPage'); |
|
232 | + Prado::trace("Page unloadRecursive()", 'System.Web.UI.TPage'); |
|
233 | 233 | $this->unloadRecursive(); |
234 | 234 | } |
235 | 235 | |
236 | 236 | protected function processPostBackRequest($writer) |
237 | 237 | { |
238 | - Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
|
238 | + Prado::trace("Page onPreInit()", 'System.Web.UI.TPage'); |
|
239 | 239 | $this->onPreInit(null); |
240 | 240 | |
241 | - Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); |
|
241 | + Prado::trace("Page initRecursive()", 'System.Web.UI.TPage'); |
|
242 | 242 | $this->initRecursive(); |
243 | 243 | |
244 | - Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); |
|
244 | + Prado::trace("Page onInitComplete()", 'System.Web.UI.TPage'); |
|
245 | 245 | $this->onInitComplete(null); |
246 | 246 | |
247 | 247 | $this->_restPostData=new TMap; |
248 | - Prado::trace("Page loadPageState()",'System.Web.UI.TPage'); |
|
248 | + Prado::trace("Page loadPageState()", 'System.Web.UI.TPage'); |
|
249 | 249 | $this->loadPageState(); |
250 | - Prado::trace("Page processPostData()",'System.Web.UI.TPage'); |
|
251 | - $this->processPostData($this->_postData,true); |
|
252 | - Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); |
|
250 | + Prado::trace("Page processPostData()", 'System.Web.UI.TPage'); |
|
251 | + $this->processPostData($this->_postData, true); |
|
252 | + Prado::trace("Page onPreLoad()", 'System.Web.UI.TPage'); |
|
253 | 253 | $this->onPreLoad(null); |
254 | - Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); |
|
254 | + Prado::trace("Page loadRecursive()", 'System.Web.UI.TPage'); |
|
255 | 255 | $this->loadRecursive(); |
256 | - Prado::trace("Page processPostData()",'System.Web.UI.TPage'); |
|
257 | - $this->processPostData($this->_restPostData,false); |
|
258 | - Prado::trace("Page raiseChangedEvents()",'System.Web.UI.TPage'); |
|
256 | + Prado::trace("Page processPostData()", 'System.Web.UI.TPage'); |
|
257 | + $this->processPostData($this->_restPostData, false); |
|
258 | + Prado::trace("Page raiseChangedEvents()", 'System.Web.UI.TPage'); |
|
259 | 259 | $this->raiseChangedEvents(); |
260 | - Prado::trace("Page raisePostBackEvent()",'System.Web.UI.TPage'); |
|
260 | + Prado::trace("Page raisePostBackEvent()", 'System.Web.UI.TPage'); |
|
261 | 261 | $this->raisePostBackEvent(); |
262 | - Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); |
|
262 | + Prado::trace("Page onLoadComplete()", 'System.Web.UI.TPage'); |
|
263 | 263 | $this->onLoadComplete(null); |
264 | 264 | |
265 | - Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); |
|
265 | + Prado::trace("Page preRenderRecursive()", 'System.Web.UI.TPage'); |
|
266 | 266 | $this->preRenderRecursive(); |
267 | - Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); |
|
267 | + Prado::trace("Page onPreRenderComplete()", 'System.Web.UI.TPage'); |
|
268 | 268 | $this->onPreRenderComplete(null); |
269 | 269 | |
270 | - Prado::trace("Page savePageState()",'System.Web.UI.TPage'); |
|
270 | + Prado::trace("Page savePageState()", 'System.Web.UI.TPage'); |
|
271 | 271 | $this->savePageState(); |
272 | - Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); |
|
272 | + Prado::trace("Page onSaveStateComplete()", 'System.Web.UI.TPage'); |
|
273 | 273 | $this->onSaveStateComplete(null); |
274 | 274 | |
275 | - Prado::trace("Page renderControl()",'System.Web.UI.TPage'); |
|
275 | + Prado::trace("Page renderControl()", 'System.Web.UI.TPage'); |
|
276 | 276 | $this->renderControl($writer); |
277 | - Prado::trace("Page unloadRecursive()",'System.Web.UI.TPage'); |
|
277 | + Prado::trace("Page unloadRecursive()", 'System.Web.UI.TPage'); |
|
278 | 278 | $this->unloadRecursive(); |
279 | 279 | } |
280 | 280 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | $data[$k]=self::decodeUTF8($v, $enc); |
287 | 287 | return $data; |
288 | 288 | } elseif(is_string($data)) { |
289 | - return iconv('UTF-8',$enc.'//IGNORE',$data); |
|
289 | + return iconv('UTF-8', $enc.'//IGNORE', $data); |
|
290 | 290 | } else { |
291 | 291 | return $data; |
292 | 292 | } |
@@ -303,39 +303,39 @@ discard block |
||
303 | 303 | |
304 | 304 | $this->setAdapter(new TActivePageAdapter($this)); |
305 | 305 | |
306 | - $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
306 | + $callbackEventParameter=$this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER); |
|
307 | 307 | if(strlen($callbackEventParameter) > 0) |
308 | - $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter); |
|
308 | + $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string) $callbackEventParameter); |
|
309 | 309 | |
310 | 310 | // Decode Callback postData from UTF-8 to current Charset |
311 | - if (($g=$this->getApplication()->getGlobalization(false))!==null && |
|
311 | + if(($g=$this->getApplication()->getGlobalization(false))!==null && |
|
312 | 312 | strtoupper($enc=$g->getCharset())!='UTF-8') |
313 | - foreach ($this->_postData as $k=>$v) |
|
313 | + foreach($this->_postData as $k=>$v) |
|
314 | 314 | $this->_postData[$k]=self::decodeUTF8($v, $enc); |
315 | 315 | |
316 | - Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); |
|
316 | + Prado::trace("Page onPreInit()", 'System.Web.UI.TPage'); |
|
317 | 317 | $this->onPreInit(null); |
318 | 318 | |
319 | - Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); |
|
319 | + Prado::trace("Page initRecursive()", 'System.Web.UI.TPage'); |
|
320 | 320 | $this->initRecursive(); |
321 | 321 | |
322 | - Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); |
|
322 | + Prado::trace("Page onInitComplete()", 'System.Web.UI.TPage'); |
|
323 | 323 | $this->onInitComplete(null); |
324 | 324 | |
325 | 325 | $this->_restPostData=new TMap; |
326 | - Prado::trace("Page loadPageState()",'System.Web.UI.TPage'); |
|
326 | + Prado::trace("Page loadPageState()", 'System.Web.UI.TPage'); |
|
327 | 327 | $this->loadPageState(); |
328 | - Prado::trace("Page processPostData()",'System.Web.UI.TPage'); |
|
329 | - $this->processPostData($this->_postData,true); |
|
330 | - Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); |
|
328 | + Prado::trace("Page processPostData()", 'System.Web.UI.TPage'); |
|
329 | + $this->processPostData($this->_postData, true); |
|
330 | + Prado::trace("Page onPreLoad()", 'System.Web.UI.TPage'); |
|
331 | 331 | $this->onPreLoad(null); |
332 | - Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); |
|
332 | + Prado::trace("Page loadRecursive()", 'System.Web.UI.TPage'); |
|
333 | 333 | $this->loadRecursive(); |
334 | 334 | |
335 | - Prado::trace("Page processPostData()",'System.Web.UI.TPage'); |
|
336 | - $this->processPostData($this->_restPostData,false); |
|
335 | + Prado::trace("Page processPostData()", 'System.Web.UI.TPage'); |
|
336 | + $this->processPostData($this->_restPostData, false); |
|
337 | 337 | |
338 | - Prado::trace("Page raiseChangedEvents()",'System.Web.UI.TPage'); |
|
338 | + Prado::trace("Page raiseChangedEvents()", 'System.Web.UI.TPage'); |
|
339 | 339 | $this->raiseChangedEvents(); |
340 | 340 | |
341 | 341 | |
@@ -345,17 +345,17 @@ discard block |
||
345 | 345 | Prado::trace("Page raisePostBackEvent()",'System.Web.UI.TPage'); |
346 | 346 | $this->raisePostBackEvent(); |
347 | 347 | */ |
348 | - Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); |
|
348 | + Prado::trace("Page onLoadComplete()", 'System.Web.UI.TPage'); |
|
349 | 349 | $this->onLoadComplete(null); |
350 | 350 | |
351 | - Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); |
|
351 | + Prado::trace("Page preRenderRecursive()", 'System.Web.UI.TPage'); |
|
352 | 352 | $this->preRenderRecursive(); |
353 | - Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); |
|
353 | + Prado::trace("Page onPreRenderComplete()", 'System.Web.UI.TPage'); |
|
354 | 354 | $this->onPreRenderComplete(null); |
355 | 355 | |
356 | - Prado::trace("Page savePageState()",'System.Web.UI.TPage'); |
|
356 | + Prado::trace("Page savePageState()", 'System.Web.UI.TPage'); |
|
357 | 357 | $this->savePageState(); |
358 | - Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); |
|
358 | + Prado::trace("Page onSaveStateComplete()", 'System.Web.UI.TPage'); |
|
359 | 359 | $this->onSaveStateComplete(null); |
360 | 360 | |
361 | 361 | /* |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | $this->getAdapter()->renderCallbackResponse($writer); |
366 | 366 | |
367 | - Prado::trace("Page unloadRecursive()",'System.Web.UI.TPage'); |
|
367 | + Prado::trace("Page unloadRecursive()", 'System.Web.UI.TPage'); |
|
368 | 368 | $this->unloadRecursive(); |
369 | 369 | } |
370 | 370 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function getCallbackClient() |
377 | 377 | { |
378 | - if($this->getAdapter() !== null) |
|
378 | + if($this->getAdapter()!==null) |
|
379 | 379 | return $this->getAdapter()->getCallbackClientHandler(); |
380 | 380 | else |
381 | 381 | return new TCallbackClientScript(); |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | { |
458 | 458 | if(!$this->_validators) |
459 | 459 | $this->_validators=new TList; |
460 | - if(empty($validationGroup) === true) |
|
460 | + if(empty($validationGroup)===true) |
|
461 | 461 | return $this->_validators; |
462 | 462 | else |
463 | 463 | { |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | */ |
478 | 478 | public function validate($validationGroup=null) |
479 | 479 | { |
480 | - Prado::trace("Page validate()",'System.Web.UI.TPage'); |
|
480 | + Prado::trace("Page validate()", 'System.Web.UI.TPage'); |
|
481 | 481 | $this->_validated=true; |
482 | 482 | if($this->_validators && $this->_validators->getCount()) |
483 | 483 | { |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | */ |
536 | 536 | public function setTheme($value) |
537 | 537 | { |
538 | - $this->_theme=empty($value)?null:$value; |
|
538 | + $this->_theme=empty($value) ? null : $value; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | */ |
556 | 556 | public function setStyleSheetTheme($value) |
557 | 557 | { |
558 | - $this->_styleSheet=empty($value)?null:$value; |
|
558 | + $this->_styleSheet=empty($value) ? null : $value; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | /** |
@@ -586,13 +586,13 @@ discard block |
||
586 | 586 | public function getClientScript() |
587 | 587 | { |
588 | 588 | if(!$this->_clientScript) { |
589 | - $className = $classPath = $this->getService()->getClientScriptManagerClass(); |
|
589 | + $className=$classPath=$this->getService()->getClientScriptManagerClass(); |
|
590 | 590 | Prado::using($className); |
591 | - if(($pos=strrpos($className,'.'))!==false) |
|
592 | - $className=substr($className,$pos+1); |
|
591 | + if(($pos=strrpos($className, '.'))!==false) |
|
592 | + $className=substr($className, $pos + 1); |
|
593 | 593 | |
594 | - if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager'))) |
|
595 | - throw new THttpException(404,'page_csmanagerclass_invalid',$classPath); |
|
594 | + if(!class_exists($className, false) || ($className!=='TClientScriptManager' && !is_subclass_of($className, 'TClientScriptManager'))) |
|
595 | + throw new THttpException(404, 'page_csmanagerclass_invalid', $classPath); |
|
596 | 596 | |
597 | 597 | $this->_clientScript=new $className($this); |
598 | 598 | } |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | */ |
611 | 611 | public function onPreInit($param) |
612 | 612 | { |
613 | - $this->raiseEvent('OnPreInit',$this,$param); |
|
613 | + $this->raiseEvent('OnPreInit', $this, $param); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | */ |
624 | 624 | public function onInitComplete($param) |
625 | 625 | { |
626 | - $this->raiseEvent('OnInitComplete',$this,$param); |
|
626 | + $this->raiseEvent('OnInitComplete', $this, $param); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | /** |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | */ |
637 | 637 | public function onPreLoad($param) |
638 | 638 | { |
639 | - $this->raiseEvent('OnPreLoad',$this,$param); |
|
639 | + $this->raiseEvent('OnPreLoad', $this, $param); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | public function onLoadComplete($param) |
651 | 651 | { |
652 | - $this->raiseEvent('OnLoadComplete',$this,$param); |
|
652 | + $this->raiseEvent('OnLoadComplete', $this, $param); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -662,23 +662,23 @@ discard block |
||
662 | 662 | */ |
663 | 663 | public function onPreRenderComplete($param) |
664 | 664 | { |
665 | - $this->raiseEvent('OnPreRenderComplete',$this,$param); |
|
665 | + $this->raiseEvent('OnPreRenderComplete', $this, $param); |
|
666 | 666 | $cs=$this->getClientScript(); |
667 | 667 | $theme=$this->getTheme(); |
668 | 668 | if($theme instanceof ITheme) |
669 | 669 | { |
670 | 670 | foreach($theme->getStyleSheetFiles() as $url) |
671 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
671 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
672 | 672 | foreach($theme->getJavaScriptFiles() as $url) |
673 | - $cs->registerHeadScriptFile($url,$url); |
|
673 | + $cs->registerHeadScriptFile($url, $url); |
|
674 | 674 | } |
675 | 675 | $styleSheet=$this->getStyleSheetTheme(); |
676 | 676 | if($styleSheet instanceof ITheme) |
677 | 677 | { |
678 | 678 | foreach($styleSheet->getStyleSheetFiles() as $url) |
679 | - $cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url)); |
|
679 | + $cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url)); |
|
680 | 680 | foreach($styleSheet->getJavaScriptFiles() as $url) |
681 | - $cs->registerHeadScriptFile($url,$url); |
|
681 | + $cs->registerHeadScriptFile($url, $url); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | if($cs->getRequiresHead() && $this->getHead()===null) |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | */ |
696 | 696 | private function getCssMediaType($url) |
697 | 697 | { |
698 | - $segs=explode('.',basename($url)); |
|
698 | + $segs=explode('.', basename($url)); |
|
699 | 699 | if(isset($segs[2])) |
700 | - return $segs[count($segs)-2]; |
|
700 | + return $segs[count($segs) - 2]; |
|
701 | 701 | else |
702 | 702 | return ''; |
703 | 703 | } |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | */ |
712 | 712 | public function onSaveStateComplete($param) |
713 | 713 | { |
714 | - $this->raiseEvent('OnSaveStateComplete',$this,$param); |
|
714 | + $this->raiseEvent('OnSaveStateComplete', $this, $param); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /** |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | public function saveState() |
750 | 750 | { |
751 | 751 | parent::saveState(); |
752 | - $this->setViewState('ControlsRequiringPostBack',$this->_controlsRegisteredForPostData,array()); |
|
752 | + $this->setViewState('ControlsRequiringPostBack', $this->_controlsRegisteredForPostData, array()); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | public function loadState() |
761 | 761 | { |
762 | 762 | parent::loadState(); |
763 | - $this->_controlsRequiringPostData=$this->getViewState('ControlsRequiringPostBack',array()); |
|
763 | + $this->_controlsRequiringPostData=$this->getViewState('ControlsRequiringPostBack', array()); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | */ |
769 | 769 | protected function loadPageState() |
770 | 770 | { |
771 | - Prado::trace("Loading state",'System.Web.UI.TPage'); |
|
771 | + Prado::trace("Loading state", 'System.Web.UI.TPage'); |
|
772 | 772 | $state=$this->getStatePersister()->load(); |
773 | - $this->loadStateRecursive($state,$this->getEnableViewState()); |
|
773 | + $this->loadStateRecursive($state, $this->getEnableViewState()); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | /** |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | */ |
779 | 779 | protected function savePageState() |
780 | 780 | { |
781 | - Prado::trace("Saving state",'System.Web.UI.TPage'); |
|
781 | + Prado::trace("Saving state", 'System.Web.UI.TPage'); |
|
782 | 782 | $state=&$this->saveStateRecursive($this->getEnableViewState()); |
783 | 783 | $this->getStatePersister()->save($state); |
784 | 784 | } |
@@ -801,11 +801,11 @@ discard block |
||
801 | 801 | */ |
802 | 802 | public function registerRequiresPostData($control) |
803 | 803 | { |
804 | - $id=is_string($control)?$control:$control->getUniqueID(); |
|
804 | + $id=is_string($control) ? $control : $control->getUniqueID(); |
|
805 | 805 | $this->_controlsRegisteredForPostData[$id]=true; |
806 | 806 | $params=func_get_args(); |
807 | 807 | foreach($this->getCachingStack() as $item) |
808 | - $item->registerAction('Page','registerRequiresPostData',array($id)); |
|
808 | + $item->registerAction('Page', 'registerRequiresPostData', array($id)); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | * @param TMap post data to be processed |
858 | 858 | * @param boolean whether this method is invoked before {@link onLoad OnLoad}. |
859 | 859 | */ |
860 | - protected function processPostData($postData,$beforeLoad) |
|
860 | + protected function processPostData($postData, $beforeLoad) |
|
861 | 861 | { |
862 | 862 | $this->_isLoadingPostData=true; |
863 | 863 | if($beforeLoad) |
@@ -870,18 +870,18 @@ discard block |
||
870 | 870 | { |
871 | 871 | if($control instanceof IPostBackDataHandler) |
872 | 872 | { |
873 | - if($control->loadPostData($key,$postData)) |
|
873 | + if($control->loadPostData($key, $postData)) |
|
874 | 874 | $this->_controlsPostDataChanged[]=$control; |
875 | 875 | } |
876 | 876 | else if($control instanceof IPostBackEventHandler && |
877 | 877 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
878 | 878 | { |
879 | - $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); // not calling setPostBackEventTarget() because the control may be removed later |
|
879 | + $this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); // not calling setPostBackEventTarget() because the control may be removed later |
|
880 | 880 | } |
881 | 881 | unset($this->_controlsRequiringPostData[$key]); |
882 | 882 | } |
883 | 883 | else if($beforeLoad) |
884 | - $this->_restPostData->add($key,$value); |
|
884 | + $this->_restPostData->add($key, $value); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | foreach($this->_controlsRequiringPostData as $key=>$value) |
@@ -890,11 +890,11 @@ discard block |
||
890 | 890 | { |
891 | 891 | if($control instanceof IPostBackDataHandler) |
892 | 892 | { |
893 | - if($control->loadPostData($key,$this->_postData)) |
|
893 | + if($control->loadPostData($key, $this->_postData)) |
|
894 | 894 | $this->_controlsPostDataChanged[]=$control; |
895 | 895 | } |
896 | 896 | else |
897 | - throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key); |
|
897 | + throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key); |
|
898 | 898 | unset($this->_controlsRequiringPostData[$key]); |
899 | 899 | } |
900 | 900 | } |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | public function ensureRenderInForm($control) |
946 | 946 | { |
947 | 947 | if(!$this->getIsCallback() && !$this->_inFormRender) |
948 | - throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null); |
|
948 | + throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | if($this->_formRendered) |
957 | 957 | throw new TConfigurationException('page_form_duplicated'); |
958 | 958 | $this->_formRendered=true; |
959 | - $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE,$this->getClientState()); |
|
959 | + $this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState()); |
|
960 | 960 | $this->_inFormRender=true; |
961 | 961 | } |
962 | 962 | |
@@ -1186,12 +1186,12 @@ discard block |
||
1186 | 1186 | * @param string method name of the context object |
1187 | 1187 | * @param array list of parameters to be passed to the action method |
1188 | 1188 | */ |
1189 | - public function registerCachingAction($context,$funcName,$funcParams) |
|
1189 | + public function registerCachingAction($context, $funcName, $funcParams) |
|
1190 | 1190 | { |
1191 | 1191 | if($this->_cachingStack) |
1192 | 1192 | { |
1193 | 1193 | foreach($this->_cachingStack as $cache) |
1194 | - $cache->registerAction($context,$funcName,$funcParams); |
|
1194 | + $cache->registerAction($context, $funcName, $funcParams); |
|
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1210,7 +1210,7 @@ discard block |
||
1210 | 1210 | */ |
1211 | 1211 | public function flushWriter() |
1212 | 1212 | { |
1213 | - if ($this->_writer) |
|
1213 | + if($this->_writer) |
|
1214 | 1214 | $this->Response->write($this->_writer->flush()); |
1215 | 1215 | } |
1216 | 1216 | |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | * @param mixed state data |
1275 | 1275 | * @return string serialized data |
1276 | 1276 | */ |
1277 | - public static function serialize($page,$data) |
|
1277 | + public static function serialize($page, $data) |
|
1278 | 1278 | { |
1279 | 1279 | $sm=$page->getApplication()->getSecurityManager(); |
1280 | 1280 | if($page->getEnableStateValidation()) |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | * @param string serialized data |
1294 | 1294 | * @return mixed unserialized state data, null if data is corrupted |
1295 | 1295 | */ |
1296 | - public static function unserialize($page,$data) |
|
1296 | + public static function unserialize($page, $data) |
|
1297 | 1297 | { |
1298 | 1298 | $str=base64_decode($data); |
1299 | 1299 | if($str==='') |
@@ -192,8 +192,7 @@ discard block |
||
192 | 192 | $this->processCallbackRequest($writer); |
193 | 193 | else |
194 | 194 | $this->processPostBackRequest($writer); |
195 | - } |
|
196 | - else |
|
195 | + } else |
|
197 | 196 | $this->processNormalRequest($writer); |
198 | 197 | |
199 | 198 | $this->_writer = null; |
@@ -485,8 +484,7 @@ discard block |
||
485 | 484 | { |
486 | 485 | foreach($this->_validators as $validator) |
487 | 486 | $validator->validate(); |
488 | - } |
|
489 | - else |
|
487 | + } else |
|
490 | 488 | { |
491 | 489 | foreach($this->_validators as $validator) |
492 | 490 | { |
@@ -514,8 +512,7 @@ discard block |
||
514 | 512 | return false; |
515 | 513 | } |
516 | 514 | return true; |
517 | - } |
|
518 | - else |
|
515 | + } else |
|
519 | 516 | throw new TInvalidOperationException('page_isvalid_unknown'); |
520 | 517 | } |
521 | 518 | |
@@ -872,15 +869,13 @@ discard block |
||
872 | 869 | { |
873 | 870 | if($control->loadPostData($key,$postData)) |
874 | 871 | $this->_controlsPostDataChanged[]=$control; |
875 | - } |
|
876 | - else if($control instanceof IPostBackEventHandler && |
|
872 | + } else if($control instanceof IPostBackEventHandler && |
|
877 | 873 | empty($this->_postData[self::FIELD_POSTBACK_TARGET])) |
878 | 874 | { |
879 | 875 | $this->_postData->add(self::FIELD_POSTBACK_TARGET,$key); // not calling setPostBackEventTarget() because the control may be removed later |
880 | 876 | } |
881 | 877 | unset($this->_controlsRequiringPostData[$key]); |
882 | - } |
|
883 | - else if($beforeLoad) |
|
878 | + } else if($beforeLoad) |
|
884 | 879 | $this->_restPostData->add($key,$value); |
885 | 880 | } |
886 | 881 | |
@@ -892,8 +887,7 @@ discard block |
||
892 | 887 | { |
893 | 888 | if($control->loadPostData($key,$this->_postData)) |
894 | 889 | $this->_controlsPostDataChanged[]=$control; |
895 | - } |
|
896 | - else |
|
890 | + } else |
|
897 | 891 | throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key); |
898 | 892 | unset($this->_controlsRequiringPostData[$key]); |
899 | 893 | } |
@@ -972,8 +966,7 @@ discard block |
||
972 | 966 | else |
973 | 967 | $focus=$this->_focus; |
974 | 968 | $this->getClientScript()->registerFocusControl($focus); |
975 | - } |
|
976 | - else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) |
|
969 | + } else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) |
|
977 | 970 | $this->getClientScript()->registerFocusControl($lastFocus); |
978 | 971 | $this->_inFormRender=false; |
979 | 972 | } |
@@ -1309,8 +1302,7 @@ discard block |
||
1309 | 1302 | { |
1310 | 1303 | if(($str=$sm->validateData($str))!==false) |
1311 | 1304 | return unserialize($str); |
1312 | - } |
|
1313 | - else |
|
1305 | + } else |
|
1314 | 1306 | return unserialize($str); |
1315 | 1307 | } |
1316 | 1308 | return null; |
@@ -144,6 +144,7 @@ discard block |
||
144 | 144 | * Registers a content control. |
145 | 145 | * @param string ID of the content |
146 | 146 | * @param TContent |
147 | + * @param string $id |
|
147 | 148 | */ |
148 | 149 | public function registerContent($id,TContent $object) |
149 | 150 | { |
@@ -158,6 +159,7 @@ discard block |
||
158 | 159 | * This method should only be used by framework and control developers. |
159 | 160 | * @param string placeholder ID |
160 | 161 | * @param TContentPlaceHolder placeholder control |
162 | + * @param string $id |
|
161 | 163 | */ |
162 | 164 | public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
163 | 165 | { |
@@ -184,7 +186,7 @@ discard block |
||
184 | 186 | } |
185 | 187 | |
186 | 188 | /** |
187 | - * @return TTemplateControl|null master control associated with this control, null if none |
|
189 | + * @return TTemplateControl master control associated with this control, null if none |
|
188 | 190 | */ |
189 | 191 | public function getMaster() |
190 | 192 | { |
@@ -238,90 +238,90 @@ |
||
238 | 238 | parent::initRecursive($namingContainer); |
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Function to update view controls with data in a given AR object. |
|
243 | - * View controls and AR object need to have the same name in IDs and Attrs respectively. |
|
244 | - * @param TActiveRecord $arObj |
|
245 | - * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
246 | - * @author Daniel Sampedro <[email protected]> |
|
247 | - */ |
|
248 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
249 | - { |
|
250 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | - foreach (array_keys($objAttrs) as $key) |
|
252 | - { |
|
253 | - try |
|
254 | - { |
|
255 | - if ($key != "RELATIONS") |
|
256 | - { |
|
257 | - $control = $this->{$key}; |
|
258 | - if ($control instanceof TTextBox) |
|
259 | - $control->Text = $arObj->{$key}; |
|
260 | - elseif ($control instanceof TCheckBox) |
|
261 | - $control->Checked = (boolean) $arObj->{$key}; |
|
262 | - elseif ($control instanceof TDatePicker) |
|
263 | - $control->Date = $arObj->{$key}; |
|
264 | - } |
|
265 | - else |
|
266 | - { |
|
267 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | - { |
|
269 | - $relControl = $this->{$relKey}; |
|
270 | - switch ($relValues[0]) |
|
271 | - { |
|
272 | - case TActiveRecord::BELONGS_TO: |
|
273 | - case TActiveRecord::HAS_ONE: |
|
274 | - $relControl->Text = $arObj->{$relKey}; |
|
275 | - break; |
|
276 | - case TActiveRecord::HAS_MANY: |
|
277 | - if ($relControl instanceof TListControl) |
|
278 | - { |
|
279 | - $relControl->DataSource = $arObj->{$relKey}; |
|
280 | - $relControl->dataBind(); |
|
281 | - } |
|
282 | - break; |
|
283 | - } |
|
284 | - } |
|
285 | - break; |
|
286 | - } |
|
287 | - } |
|
288 | - catch (Exception $ex) |
|
289 | - { |
|
290 | - if ($throwExceptions) |
|
291 | - throw $ex; |
|
292 | - } |
|
293 | - } |
|
294 | - } |
|
241 | + /** |
|
242 | + * Function to update view controls with data in a given AR object. |
|
243 | + * View controls and AR object need to have the same name in IDs and Attrs respectively. |
|
244 | + * @param TActiveRecord $arObj |
|
245 | + * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
246 | + * @author Daniel Sampedro <[email protected]> |
|
247 | + */ |
|
248 | + public function tryToUpdateView($arObj, $throwExceptions = false) |
|
249 | + { |
|
250 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | + foreach (array_keys($objAttrs) as $key) |
|
252 | + { |
|
253 | + try |
|
254 | + { |
|
255 | + if ($key != "RELATIONS") |
|
256 | + { |
|
257 | + $control = $this->{$key}; |
|
258 | + if ($control instanceof TTextBox) |
|
259 | + $control->Text = $arObj->{$key}; |
|
260 | + elseif ($control instanceof TCheckBox) |
|
261 | + $control->Checked = (boolean) $arObj->{$key}; |
|
262 | + elseif ($control instanceof TDatePicker) |
|
263 | + $control->Date = $arObj->{$key}; |
|
264 | + } |
|
265 | + else |
|
266 | + { |
|
267 | + foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | + { |
|
269 | + $relControl = $this->{$relKey}; |
|
270 | + switch ($relValues[0]) |
|
271 | + { |
|
272 | + case TActiveRecord::BELONGS_TO: |
|
273 | + case TActiveRecord::HAS_ONE: |
|
274 | + $relControl->Text = $arObj->{$relKey}; |
|
275 | + break; |
|
276 | + case TActiveRecord::HAS_MANY: |
|
277 | + if ($relControl instanceof TListControl) |
|
278 | + { |
|
279 | + $relControl->DataSource = $arObj->{$relKey}; |
|
280 | + $relControl->dataBind(); |
|
281 | + } |
|
282 | + break; |
|
283 | + } |
|
284 | + } |
|
285 | + break; |
|
286 | + } |
|
287 | + } |
|
288 | + catch (Exception $ex) |
|
289 | + { |
|
290 | + if ($throwExceptions) |
|
291 | + throw $ex; |
|
292 | + } |
|
293 | + } |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * Function to try to update an AR object with data in view controls. |
|
298 | - * @param TActiveRecord $arObj |
|
299 | - * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
300 | - * @author Daniel Sampedro <[email protected]> |
|
301 | - */ |
|
302 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
303 | - { |
|
304 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | - foreach (array_keys($objAttrs) as $key) |
|
306 | - { |
|
307 | - try |
|
308 | - { |
|
309 | - if ($key == "RELATIONS") |
|
310 | - break; |
|
311 | - $control = $this->{$key}; |
|
312 | - if ($control instanceof TTextBox) |
|
313 | - $arObj->{$key} = $control->Text; |
|
314 | - elseif ($control instanceof TCheckBox) |
|
315 | - $arObj->{$key} = $control->Checked; |
|
316 | - elseif ($control instanceof TDatePicker) |
|
317 | - $arObj->{$key} = $control->Date; |
|
318 | - } |
|
319 | - catch (Exception $ex) |
|
320 | - { |
|
321 | - if ($throwExceptions) |
|
322 | - throw $ex; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
296 | + /** |
|
297 | + * Function to try to update an AR object with data in view controls. |
|
298 | + * @param TActiveRecord $arObj |
|
299 | + * @param Boolean $throwExceptions Wheter or not to throw exceptions |
|
300 | + * @author Daniel Sampedro <[email protected]> |
|
301 | + */ |
|
302 | + public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
303 | + { |
|
304 | + $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | + foreach (array_keys($objAttrs) as $key) |
|
306 | + { |
|
307 | + try |
|
308 | + { |
|
309 | + if ($key == "RELATIONS") |
|
310 | + break; |
|
311 | + $control = $this->{$key}; |
|
312 | + if ($control instanceof TTextBox) |
|
313 | + $arObj->{$key} = $control->Text; |
|
314 | + elseif ($control instanceof TCheckBox) |
|
315 | + $arObj->{$key} = $control->Checked; |
|
316 | + elseif ($control instanceof TDatePicker) |
|
317 | + $arObj->{$key} = $control->Date; |
|
318 | + } |
|
319 | + catch (Exception $ex) |
|
320 | + { |
|
321 | + if ($throwExceptions) |
|
322 | + throw $ex; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | 326 | } |
327 | 327 |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | protected function loadTemplate() |
117 | 117 | { |
118 | - Prado::trace("Loading template ".get_class($this),'System.Web.UI.TTemplateControl'); |
|
118 | + Prado::trace("Loading template ".get_class($this), 'System.Web.UI.TTemplateControl'); |
|
119 | 119 | $template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); |
120 | 120 | return $template; |
121 | 121 | } |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | foreach($tpl->getDirective() as $name=>$value) |
133 | 133 | { |
134 | 134 | if(is_string($value)) |
135 | - $this->setSubProperty($name,$value); |
|
135 | + $this->setSubProperty($name, $value); |
|
136 | 136 | else |
137 | - throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name); |
|
137 | + throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name); |
|
138 | 138 | } |
139 | 139 | $tpl->instantiateIn($this); |
140 | 140 | } |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | * @param string ID of the content |
146 | 146 | * @param TContent |
147 | 147 | */ |
148 | - public function registerContent($id,TContent $object) |
|
148 | + public function registerContent($id, TContent $object) |
|
149 | 149 | { |
150 | 150 | if(isset($this->_contents[$id])) |
151 | - throw new TConfigurationException('templatecontrol_contentid_duplicated',$id); |
|
151 | + throw new TConfigurationException('templatecontrol_contentid_duplicated', $id); |
|
152 | 152 | else |
153 | 153 | $this->_contents[$id]=$object; |
154 | 154 | } |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * @param string placeholder ID |
160 | 160 | * @param TContentPlaceHolder placeholder control |
161 | 161 | */ |
162 | - public function registerContentPlaceHolder($id,TContentPlaceHolder $object) |
|
162 | + public function registerContentPlaceHolder($id, TContentPlaceHolder $object) |
|
163 | 163 | { |
164 | 164 | if(isset($this->_placeholders[$id])) |
165 | - throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id); |
|
165 | + throw new TConfigurationException('templatecontrol_placeholderid_duplicated', $id); |
|
166 | 166 | else |
167 | 167 | $this->_placeholders[$id]=$object; |
168 | 168 | } |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | * @param string ID of the content control |
198 | 198 | * @param TContent the content to be injected |
199 | 199 | */ |
200 | - public function injectContent($id,$content) |
|
200 | + public function injectContent($id, $content) |
|
201 | 201 | { |
202 | 202 | if(isset($this->_placeholders[$id])) |
203 | 203 | { |
204 | 204 | $placeholder=$this->_placeholders[$id]; |
205 | 205 | $controls=$placeholder->getParent()->getControls(); |
206 | 206 | $loc=$controls->remove($placeholder); |
207 | - $controls->insertAt($loc,$content); |
|
207 | + $controls->insertAt($loc, $content); |
|
208 | 208 | } |
209 | 209 | else |
210 | - throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
|
210 | + throw new TConfigurationException('templatecontrol_placeholder_inexistent', $id); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | $this->getControls()->add($master); |
232 | 232 | $master->ensureChildControls(); |
233 | 233 | foreach($this->_contents as $id=>$content) |
234 | - $master->injectContent($id,$content); |
|
234 | + $master->injectContent($id, $content); |
|
235 | 235 | } |
236 | 236 | else if(!empty($this->_contents)) |
237 | - throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
|
237 | + throw new TConfigurationException('templatecontrol_mastercontrol_required', get_class($this)); |
|
238 | 238 | parent::initRecursive($namingContainer); |
239 | 239 | } |
240 | 240 | |
@@ -245,38 +245,38 @@ discard block |
||
245 | 245 | * @param Boolean $throwExceptions Wheter or not to throw exceptions |
246 | 246 | * @author Daniel Sampedro <[email protected]> |
247 | 247 | */ |
248 | - public function tryToUpdateView($arObj, $throwExceptions = false) |
|
248 | + public function tryToUpdateView($arObj, $throwExceptions=false) |
|
249 | 249 | { |
250 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
251 | - foreach (array_keys($objAttrs) as $key) |
|
250 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
251 | + foreach(array_keys($objAttrs) as $key) |
|
252 | 252 | { |
253 | 253 | try |
254 | 254 | { |
255 | - if ($key != "RELATIONS") |
|
255 | + if($key!="RELATIONS") |
|
256 | 256 | { |
257 | - $control = $this->{$key}; |
|
258 | - if ($control instanceof TTextBox) |
|
259 | - $control->Text = $arObj->{$key}; |
|
260 | - elseif ($control instanceof TCheckBox) |
|
261 | - $control->Checked = (boolean) $arObj->{$key}; |
|
262 | - elseif ($control instanceof TDatePicker) |
|
263 | - $control->Date = $arObj->{$key}; |
|
257 | + $control=$this->{$key}; |
|
258 | + if($control instanceof TTextBox) |
|
259 | + $control->Text=$arObj->{$key}; |
|
260 | + elseif($control instanceof TCheckBox) |
|
261 | + $control->Checked=(boolean) $arObj->{$key}; |
|
262 | + elseif($control instanceof TDatePicker) |
|
263 | + $control->Date=$arObj->{$key}; |
|
264 | 264 | } |
265 | 265 | else |
266 | 266 | { |
267 | - foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
267 | + foreach($objAttrs["RELATIONS"] as $relKey => $relValues) |
|
268 | 268 | { |
269 | - $relControl = $this->{$relKey}; |
|
270 | - switch ($relValues[0]) |
|
269 | + $relControl=$this->{$relKey}; |
|
270 | + switch($relValues[0]) |
|
271 | 271 | { |
272 | 272 | case TActiveRecord::BELONGS_TO: |
273 | 273 | case TActiveRecord::HAS_ONE: |
274 | - $relControl->Text = $arObj->{$relKey}; |
|
274 | + $relControl->Text=$arObj->{$relKey}; |
|
275 | 275 | break; |
276 | 276 | case TActiveRecord::HAS_MANY: |
277 | - if ($relControl instanceof TListControl) |
|
277 | + if($relControl instanceof TListControl) |
|
278 | 278 | { |
279 | - $relControl->DataSource = $arObj->{$relKey}; |
|
279 | + $relControl->DataSource=$arObj->{$relKey}; |
|
280 | 280 | $relControl->dataBind(); |
281 | 281 | } |
282 | 282 | break; |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | break; |
286 | 286 | } |
287 | 287 | } |
288 | - catch (Exception $ex) |
|
288 | + catch(Exception $ex) |
|
289 | 289 | { |
290 | - if ($throwExceptions) |
|
290 | + if($throwExceptions) |
|
291 | 291 | throw $ex; |
292 | 292 | } |
293 | 293 | } |
@@ -299,26 +299,26 @@ discard block |
||
299 | 299 | * @param Boolean $throwExceptions Wheter or not to throw exceptions |
300 | 300 | * @author Daniel Sampedro <[email protected]> |
301 | 301 | */ |
302 | - public function tryToUpdateAR($arObj, $throwExceptions = false) |
|
302 | + public function tryToUpdateAR($arObj, $throwExceptions=false) |
|
303 | 303 | { |
304 | - $objAttrs = get_class_vars(get_class($arObj)); |
|
305 | - foreach (array_keys($objAttrs) as $key) |
|
304 | + $objAttrs=get_class_vars(get_class($arObj)); |
|
305 | + foreach(array_keys($objAttrs) as $key) |
|
306 | 306 | { |
307 | 307 | try |
308 | 308 | { |
309 | - if ($key == "RELATIONS") |
|
309 | + if($key=="RELATIONS") |
|
310 | 310 | break; |
311 | - $control = $this->{$key}; |
|
312 | - if ($control instanceof TTextBox) |
|
313 | - $arObj->{$key} = $control->Text; |
|
314 | - elseif ($control instanceof TCheckBox) |
|
315 | - $arObj->{$key} = $control->Checked; |
|
316 | - elseif ($control instanceof TDatePicker) |
|
317 | - $arObj->{$key} = $control->Date; |
|
311 | + $control=$this->{$key}; |
|
312 | + if($control instanceof TTextBox) |
|
313 | + $arObj->{$key}=$control->Text; |
|
314 | + elseif($control instanceof TCheckBox) |
|
315 | + $arObj->{$key}=$control->Checked; |
|
316 | + elseif($control instanceof TDatePicker) |
|
317 | + $arObj->{$key}=$control->Date; |
|
318 | 318 | } |
319 | - catch (Exception $ex) |
|
319 | + catch(Exception $ex) |
|
320 | 320 | { |
321 | - if ($throwExceptions) |
|
321 | + if($throwExceptions) |
|
322 | 322 | throw $ex; |
323 | 323 | } |
324 | 324 | } |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | if(!isset(self::$_template[$class])) |
70 | 70 | self::$_template[$class]=$this->loadTemplate(); |
71 | 71 | return self::$_template[$class]; |
72 | - } |
|
73 | - else |
|
72 | + } else |
|
74 | 73 | return $this->_localTemplate; |
75 | 74 | } |
76 | 75 | |
@@ -205,8 +204,7 @@ discard block |
||
205 | 204 | $controls=$placeholder->getParent()->getControls(); |
206 | 205 | $loc=$controls->remove($placeholder); |
207 | 206 | $controls->insertAt($loc,$content); |
208 | - } |
|
209 | - else |
|
207 | + } else |
|
210 | 208 | throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id); |
211 | 209 | } |
212 | 210 | |
@@ -232,8 +230,7 @@ discard block |
||
232 | 230 | $master->ensureChildControls(); |
233 | 231 | foreach($this->_contents as $id=>$content) |
234 | 232 | $master->injectContent($id,$content); |
235 | - } |
|
236 | - else if(!empty($this->_contents)) |
|
233 | + } else if(!empty($this->_contents)) |
|
237 | 234 | throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this)); |
238 | 235 | parent::initRecursive($namingContainer); |
239 | 236 | } |
@@ -261,8 +258,7 @@ discard block |
||
261 | 258 | $control->Checked = (boolean) $arObj->{$key}; |
262 | 259 | elseif ($control instanceof TDatePicker) |
263 | 260 | $control->Date = $arObj->{$key}; |
264 | - } |
|
265 | - else |
|
261 | + } else |
|
266 | 262 | { |
267 | 263 | foreach ($objAttrs["RELATIONS"] as $relKey => $relValues) |
268 | 264 | { |
@@ -284,8 +280,7 @@ discard block |
||
284 | 280 | } |
285 | 281 | break; |
286 | 282 | } |
287 | - } |
|
288 | - catch (Exception $ex) |
|
283 | + } catch (Exception $ex) |
|
289 | 284 | { |
290 | 285 | if ($throwExceptions) |
291 | 286 | throw $ex; |
@@ -315,8 +310,7 @@ discard block |
||
315 | 310 | $arObj->{$key} = $control->Checked; |
316 | 311 | elseif ($control instanceof TDatePicker) |
317 | 312 | $arObj->{$key} = $control->Date; |
318 | - } |
|
319 | - catch (Exception $ex) |
|
313 | + } catch (Exception $ex) |
|
320 | 314 | { |
321 | 315 | if ($throwExceptions) |
322 | 316 | throw $ex; |
@@ -76,7 +76,7 @@ |
||
76 | 76 | /** |
77 | 77 | * This method creates the template object for the given class |
78 | 78 | * |
79 | - * @param string $p_class The class to create the template from |
|
79 | + * @param string $parentClass |
|
80 | 80 | * @return void |
81 | 81 | * @throws TConfigurationException if a template control directive is invalid |
82 | 82 | */ |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function createChildControls() |
45 | 45 | { |
46 | - if(null === ($_template = $this->getTemplate())) { |
|
46 | + if(null===($_template=$this->getTemplate())) { |
|
47 | 47 | return $this->doCreateChildControlsFor(get_class($this)); |
48 | 48 | } |
49 | 49 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function doCreateChildControlsFor($parentClass) |
68 | 68 | { |
69 | - if(false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) { |
|
69 | + if(false!==($_parentClass=get_parent_class($parentClass)) && 'TTemplateControl'!=$_parentClass) { |
|
70 | 70 | $this->doCreateChildControlsFor($_parentClass); |
71 | 71 | } |
72 | 72 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function doTemplateForClass($parentClass) |
84 | 84 | { |
85 | - if(null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
85 | + if(null!==($_template=$this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) { |
|
86 | 86 | foreach($_template->getDirective() as $_name => $_value) { |
87 | 87 | if(!is_string($_value)) { |
88 | 88 | throw new TConfigurationException('templatecontrol_directive_invalid', get_class(this), $_name); |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getIsSourceTemplateControl() |
107 | 107 | { |
108 | - if(null !== ($_template = $this->getTemplate())) { |
|
108 | + if(null!==($_template=$this->getTemplate())) { |
|
109 | 109 | return $_template->getIsSourceTemplate(); |
110 | 110 | } |
111 | 111 | |
112 | - return ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName(get_parent_class($this))) |
|
112 | + return ($_template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_parent_class($this))) |
|
113 | 113 | ? $_template->getIsSourceTemplate() |
114 | 114 | : false; |
115 | 115 | } |
@@ -69,6 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Loads the template from the specified file. |
72 | + * @param string $fileName |
|
72 | 73 | * @return ITemplate template parsed from the specified file, null if the file doesn't exist. |
73 | 74 | */ |
74 | 75 | public function getTemplateByFileName($fileName) |
@@ -415,6 +416,7 @@ discard block |
||
415 | 416 | * @param TControl control to be configured |
416 | 417 | * @param string property name |
417 | 418 | * @param mixed property initial value |
419 | + * @param TControl $control |
|
418 | 420 | */ |
419 | 421 | protected function configureControl($control,$name,$value) |
420 | 422 | { |
@@ -431,6 +433,7 @@ discard block |
||
431 | 433 | * @param TComponent component to be configured |
432 | 434 | * @param string property name |
433 | 435 | * @param mixed property initial value |
436 | + * @param TComponent $component |
|
434 | 437 | */ |
435 | 438 | protected function configureComponent($component,$name,$value) |
436 | 439 | { |
@@ -817,6 +820,8 @@ discard block |
||
817 | 820 | /** |
818 | 821 | * Parses the attributes of a tag from a string. |
819 | 822 | * @param string the string to be parsed. |
823 | + * @param string $str |
|
824 | + * @param string $offset |
|
820 | 825 | * @return array attribute values indexed by names. |
821 | 826 | */ |
822 | 827 | protected function parseAttributes($str,$offset) |
@@ -851,6 +856,9 @@ discard block |
||
851 | 856 | return $attributes; |
852 | 857 | } |
853 | 858 | |
859 | + /** |
|
860 | + * @param string $content |
|
861 | + */ |
|
854 | 862 | protected function parseTemplateProperty($content,$offset) |
855 | 863 | { |
856 | 864 | $line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1; |
@@ -860,6 +868,7 @@ discard block |
||
860 | 868 | /** |
861 | 869 | * Parses a single attribute. |
862 | 870 | * @param string the string to be parsed. |
871 | + * @param string $value |
|
863 | 872 | * @return array attribute initialization |
864 | 873 | */ |
865 | 874 | protected function parseAttribute($value) |
@@ -1002,6 +1011,8 @@ discard block |
||
1002 | 1011 | * @param Exception template exception |
1003 | 1012 | * @param int line number |
1004 | 1013 | * @param string template string if no source file is used |
1014 | + * @param Exception $e |
|
1015 | + * @param integer $line |
|
1005 | 1016 | */ |
1006 | 1017 | protected function handleException($e,$line,$input=null) |
1007 | 1018 | { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | /** |
169 | 169 | * '<!--.*?--!>' - template comments |
170 | - * '<!--.*?-->' - HTML comments |
|
170 | + * '<!--.*?-->' - HTML comments |
|
171 | 171 | * '<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>' - component tags |
172 | 172 | * '<\/?prop:([\w\.]+)\s*>' - property tags |
173 | 173 | * '<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>' - directives |
@@ -1080,15 +1080,15 @@ discard block |
||
1080 | 1080 | $component=new ReflectionClass('TComponent'); |
1081 | 1081 | $behaviors=$component->getStaticProperties(); |
1082 | 1082 | if(!isset($behaviors['_um'])) |
1083 | - return false; |
|
1083 | + return false; |
|
1084 | 1084 | foreach($behaviors['_um'] as $name=>$list) |
1085 | 1085 | { |
1086 | - if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
|
1087 | - foreach($list as $param) |
|
1088 | - { |
|
1089 | - if(method_exists($param->getBehavior(),$method)) |
|
1090 | - return true; |
|
1091 | - } |
|
1086 | + if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
|
1087 | + foreach($list as $param) |
|
1088 | + { |
|
1089 | + if(method_exists($param->getBehavior(),$method)) |
|
1090 | + return true; |
|
1091 | + } |
|
1092 | 1092 | } |
1093 | 1093 | return false; |
1094 | 1094 | } |
@@ -107,8 +107,7 @@ discard block |
||
107 | 107 | $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps)); |
108 | 108 | return $template; |
109 | 109 | } |
110 | - } |
|
111 | - else |
|
110 | + } else |
|
112 | 111 | return null; |
113 | 112 | } |
114 | 113 | |
@@ -357,8 +356,7 @@ discard block |
||
357 | 356 | $component->createdOnTemplate($parent); |
358 | 357 | if($component->getAllowChildControls()) |
359 | 358 | $controls[$key]=$component; |
360 | - } |
|
361 | - else if($component instanceof TComponent) |
|
359 | + } else if($component instanceof TComponent) |
|
362 | 360 | { |
363 | 361 | $controls[$key]=$component; |
364 | 362 | if(isset($properties['id'])) |
@@ -376,8 +374,7 @@ discard block |
||
376 | 374 | else |
377 | 375 | $component->createdOnTemplate($parent); |
378 | 376 | } |
379 | - } |
|
380 | - else |
|
377 | + } else |
|
381 | 378 | { |
382 | 379 | if($object[1] instanceof TCompositeLiteral) |
383 | 380 | { |
@@ -388,8 +385,7 @@ discard block |
||
388 | 385 | $directChildren[]=$o; |
389 | 386 | else |
390 | 387 | $parent->addParsedObject($o); |
391 | - } |
|
392 | - else |
|
388 | + } else |
|
393 | 389 | { |
394 | 390 | if($parent===$parentControl) |
395 | 391 | $directChildren[]=$object[1]; |
@@ -500,8 +496,7 @@ discard block |
||
500 | 496 | throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
501 | 497 | break; |
502 | 498 | } |
503 | - } |
|
504 | - else |
|
499 | + } else |
|
505 | 500 | { |
506 | 501 | if (substr($name,0,2)=='js') |
507 | 502 | if ($value and !($value instanceof TJavaScriptLiteral)) |
@@ -549,8 +544,7 @@ discard block |
||
549 | 544 | throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
550 | 545 | break; |
551 | 546 | } |
552 | - } |
|
553 | - else |
|
547 | + } else |
|
554 | 548 | $component->setSubProperty($name,$value); |
555 | 549 | } |
556 | 550 | |
@@ -611,8 +605,7 @@ discard block |
||
611 | 605 | $stack[] = $type; |
612 | 606 | $container=$c-1; |
613 | 607 | } |
614 | - } |
|
615 | - else if(strpos($str,'</com:')===0) // closing component tag |
|
608 | + } else if(strpos($str,'</com:')===0) // closing component tag |
|
616 | 609 | { |
617 | 610 | if($expectPropEnd) |
618 | 611 | continue; |
@@ -631,8 +624,7 @@ discard block |
||
631 | 624 | throw new TConfigurationException('template_closingtag_expected',$tag); |
632 | 625 | } |
633 | 626 | $container=$tpl[$container][0]; |
634 | - } |
|
635 | - else if(strpos($str,'<%@')===0) // directive |
|
627 | + } else if(strpos($str,'<%@')===0) // directive |
|
636 | 628 | { |
637 | 629 | if($expectPropEnd) |
638 | 630 | continue; |
@@ -642,8 +634,7 @@ discard block |
||
642 | 634 | if(isset($tpl[0]) || $this->_directive!==null) |
643 | 635 | throw new TConfigurationException('template_directive_nonunique'); |
644 | 636 | $this->_directive=$this->parseAttributes($match[4][0],$match[4][1]); |
645 | - } |
|
646 | - else if(strpos($str,'<%')===0) // expression |
|
637 | + } else if(strpos($str,'<%')===0) // expression |
|
647 | 638 | { |
648 | 639 | if($expectPropEnd) |
649 | 640 | continue; |
@@ -668,8 +659,7 @@ discard block |
||
668 | 659 | $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); |
669 | 660 | $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')")); |
670 | 661 | } |
671 | - } |
|
672 | - else if(strpos($str,'<prop:')===0) // opening property |
|
662 | + } else if(strpos($str,'<prop:')===0) // opening property |
|
673 | 663 | { |
674 | 664 | if(strrpos($str,'/>')===strlen($str)-2) //subproperties |
675 | 665 | { |
@@ -691,8 +681,7 @@ discard block |
||
691 | 681 | throw new TConfigurationException('template_property_duplicated',$name); |
692 | 682 | $tpl[$container][2][$name]=$value; |
693 | 683 | } |
694 | - } |
|
695 | - else // regular property |
|
684 | + } else // regular property |
|
696 | 685 | { |
697 | 686 | $prop=strtolower($match[3][0]); |
698 | 687 | $stack[] = '@'.$prop; |
@@ -704,8 +693,7 @@ discard block |
||
704 | 693 | $expectPropEnd=true; |
705 | 694 | } |
706 | 695 | } |
707 | - } |
|
708 | - else if(strpos($str,'</prop:')===0) // closing property |
|
696 | + } else if(strpos($str,'</prop:')===0) // closing property |
|
709 | 697 | { |
710 | 698 | $prop=strtolower($match[3][0]); |
711 | 699 | if(empty($stack)) |
@@ -732,23 +720,20 @@ discard block |
||
732 | 720 | if(isset($tpl[$container][2][$prop])) |
733 | 721 | throw new TConfigurationException('template_property_duplicated',$prop); |
734 | 722 | $tpl[$container][2][$prop]=$value; |
735 | - } |
|
736 | - else // a property for the template control |
|
723 | + } else // a property for the template control |
|
737 | 724 | $this->_directive[$prop]=$value; |
738 | 725 | $textStart=$matchEnd+1; |
739 | 726 | } |
740 | 727 | $expectPropEnd=false; |
741 | 728 | } |
742 | - } |
|
743 | - else if(strpos($str,'<!--')===0) // comments |
|
729 | + } else if(strpos($str,'<!--')===0) // comments |
|
744 | 730 | { |
745 | 731 | if($expectPropEnd) |
746 | 732 | throw new TConfigurationException('template_comments_forbidden'); |
747 | 733 | if($matchStart>$textStart) |
748 | 734 | $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
749 | 735 | $textStart=$matchEnd+1; |
750 | - } |
|
751 | - else |
|
736 | + } else |
|
752 | 737 | throw new TConfigurationException('template_matching_unexpected',$match); |
753 | 738 | } |
754 | 739 | if(!empty($stack)) |
@@ -759,8 +744,7 @@ discard block |
||
759 | 744 | } |
760 | 745 | if($textStart<strlen($input)) |
761 | 746 | $tpl[$c++]=array($container,substr($input,$textStart)); |
762 | - } |
|
763 | - catch(Exception $e) |
|
747 | + } catch(Exception $e) |
|
764 | 748 | { |
765 | 749 | if(($e instanceof TException) && ($e instanceof TTemplateException)) |
766 | 750 | throw $e; |
@@ -793,14 +777,12 @@ discard block |
||
793 | 777 | { |
794 | 778 | $parent=null; |
795 | 779 | $objects[$id]=$object; |
796 | - } |
|
797 | - else |
|
780 | + } else |
|
798 | 781 | { |
799 | 782 | $parent=$object[0]; |
800 | 783 | $merged=array($parent,array($object[1])); |
801 | 784 | } |
802 | - } |
|
803 | - else |
|
785 | + } else |
|
804 | 786 | $merged[1][]=$object[1]; |
805 | 787 | } |
806 | 788 | if($parent!==null) |
@@ -839,8 +821,7 @@ discard block |
||
839 | 821 | $attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1); |
840 | 822 | else |
841 | 823 | $attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]); |
842 | - } |
|
843 | - else |
|
824 | + } else |
|
844 | 825 | { |
845 | 826 | if($value[0]==='\'' || $value[0]==='"') |
846 | 827 | $attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2)); |
@@ -889,8 +870,7 @@ discard block |
||
889 | 870 | return array(self::CONFIG_DATABIND,ltrim($expr,'.')); |
890 | 871 | else |
891 | 872 | return array(self::CONFIG_EXPRESSION,ltrim($expr,'.')); |
892 | - } |
|
893 | - else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
873 | + } else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
894 | 874 | { |
895 | 875 | $value=$matches[1]; |
896 | 876 | if($value[2]==='~') |
@@ -903,8 +883,7 @@ discard block |
||
903 | 883 | $literal = trim(substr($value,3,strlen($value)-5)); |
904 | 884 | return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"); |
905 | 885 | } |
906 | - } |
|
907 | - else |
|
886 | + } else |
|
908 | 887 | return $value; |
909 | 888 | } |
910 | 889 | |
@@ -926,16 +905,14 @@ discard block |
||
926 | 905 | $subname=substr($name,0,$pos); |
927 | 906 | if(!$class->hasMethod('get'.$subname)) |
928 | 907 | throw new TConfigurationException('template_property_unknown',$type,$subname); |
929 | - } |
|
930 | - else if(strncasecmp($name,'on',2)===0) |
|
908 | + } else if(strncasecmp($name,'on',2)===0) |
|
931 | 909 | { |
932 | 910 | // an event |
933 | 911 | if(!$class->hasMethod($name)) |
934 | 912 | throw new TConfigurationException('template_event_unknown',$type,$name); |
935 | 913 | else if(!is_string($att)) |
936 | 914 | throw new TConfigurationException('template_eventhandler_invalid',$type,$name); |
937 | - } |
|
938 | - else |
|
915 | + } else |
|
939 | 916 | { |
940 | 917 | // a simple property |
941 | 918 | if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) ) |
@@ -944,8 +921,7 @@ discard block |
||
944 | 921 | throw new TConfigurationException('template_property_readonly',$type,$name); |
945 | 922 | else |
946 | 923 | throw new TConfigurationException('template_property_unknown',$type,$name); |
947 | - } |
|
948 | - else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
|
924 | + } else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
|
949 | 925 | { |
950 | 926 | if(strcasecmp($name,'id')===0) |
951 | 927 | throw new TConfigurationException('template_controlid_invalid',$type); |
@@ -954,8 +930,7 @@ discard block |
||
954 | 930 | } |
955 | 931 | } |
956 | 932 | } |
957 | - } |
|
958 | - else if(is_subclass_of($className,'TComponent') || $className==='TComponent') |
|
933 | + } else if(is_subclass_of($className,'TComponent') || $className==='TComponent') |
|
959 | 934 | { |
960 | 935 | foreach($attributes as $name=>$att) |
961 | 936 | { |
@@ -967,8 +942,7 @@ discard block |
||
967 | 942 | $subname=substr($name,0,$pos); |
968 | 943 | if(!$class->hasMethod('get'.$subname)) |
969 | 944 | throw new TConfigurationException('template_property_unknown',$type,$subname); |
970 | - } |
|
971 | - else if(strncasecmp($name,'on',2)===0) |
|
945 | + } else if(strncasecmp($name,'on',2)===0) |
|
972 | 946 | throw new TConfigurationException('template_event_forbidden',$type,$name); |
973 | 947 | else |
974 | 948 | { |
@@ -982,8 +956,7 @@ discard block |
||
982 | 956 | } |
983 | 957 | } |
984 | 958 | } |
985 | - } |
|
986 | - else |
|
959 | + } else |
|
987 | 960 | throw new TConfigurationException('template_component_required',$type); |
988 | 961 | } |
989 | 962 | |
@@ -1018,8 +991,7 @@ discard block |
||
1018 | 991 | $line=$line-$this->_includeAtLine[$i]+1; |
1019 | 992 | $srcFile=$this->_includedFiles[$i]; |
1020 | 993 | break; |
1021 | - } |
|
1022 | - else |
|
994 | + } else |
|
1023 | 995 | $line=$line-$this->_includeLines[$i]+1; |
1024 | 996 | } |
1025 | 997 | } |
@@ -75,21 +75,21 @@ discard block |
||
75 | 75 | { |
76 | 76 | if(($fileName=$this->getLocalizedTemplate($fileName))!==null) |
77 | 77 | { |
78 | - Prado::trace("Loading template $fileName",'System.Web.UI.TTemplateManager'); |
|
78 | + Prado::trace("Loading template $fileName", 'System.Web.UI.TTemplateManager'); |
|
79 | 79 | if(($cache=$this->getApplication()->getCache())===null) |
80 | - return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName); |
|
80 | + return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
81 | 81 | else |
82 | 82 | { |
83 | 83 | $array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName); |
84 | 84 | if(is_array($array)) |
85 | 85 | { |
86 | - list($template,$timestamps)=$array; |
|
86 | + list($template, $timestamps)=$array; |
|
87 | 87 | if($this->getApplication()->getMode()===TApplicationMode::Performance) |
88 | 88 | return $template; |
89 | 89 | $cacheValid=true; |
90 | 90 | foreach($timestamps as $tplFile=>$timestamp) |
91 | 91 | { |
92 | - if(!is_file($tplFile) || filemtime($tplFile)>$timestamp) |
|
92 | + if(!is_file($tplFile) || filemtime($tplFile) > $timestamp) |
|
93 | 93 | { |
94 | 94 | $cacheValid=false; |
95 | 95 | break; |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | if($cacheValid) |
99 | 99 | return $template; |
100 | 100 | } |
101 | - $template=new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName); |
|
101 | + $template=new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); |
|
102 | 102 | $includedFiles=$template->getIncludedFiles(); |
103 | 103 | $timestamps=array(); |
104 | 104 | $timestamps[$fileName]=filemtime($fileName); |
105 | 105 | foreach($includedFiles as $includedFile) |
106 | 106 | $timestamps[$includedFile]=filemtime($includedFile); |
107 | - $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps)); |
|
107 | + $cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName, array($template, $timestamps)); |
|
108 | 108 | return $template; |
109 | 109 | } |
110 | 110 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | protected function getLocalizedTemplate($filename) |
121 | 121 | { |
122 | 122 | if(($app=$this->getApplication()->getGlobalization(false))===null) |
123 | - return is_file($filename)?$filename:null; |
|
123 | + return is_file($filename) ? $filename : null; |
|
124 | 124 | foreach($app->getLocalizedResource($filename) as $file) |
125 | 125 | { |
126 | 126 | if(($file=realpath($file))!==false && is_file($file)) |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @param boolean whether this template is a source template, i.e., this template is loaded from |
235 | 235 | * some external storage rather than from within another template. |
236 | 236 | */ |
237 | - public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true) |
|
237 | + public function __construct($template, $contextPath, $tplFile=null, $startingLine=0, $sourceTemplate=true) |
|
238 | 238 | { |
239 | 239 | $this->_sourceTemplate=$sourceTemplate; |
240 | 240 | $this->_contextPath=$contextPath; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param TControl the control who owns the template |
303 | 303 | * @param TControl the control who will become the root parent of the controls on the template. If null, it uses the template control. |
304 | 304 | */ |
305 | - public function instantiateIn($tplControl,$parentControl=null) |
|
305 | + public function instantiateIn($tplControl, $parentControl=null) |
|
306 | 306 | { |
307 | 307 | $this->_tplControl=$tplControl; |
308 | 308 | if($parentControl===null) |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | { |
333 | 333 | if(is_array($properties['id'])) |
334 | 334 | $properties['id']=$component->evaluateExpression($properties['id'][1]); |
335 | - $tplControl->registerObject($properties['id'],$component); |
|
335 | + $tplControl->registerObject($properties['id'], $component); |
|
336 | 336 | } |
337 | 337 | if(isset($properties['skinid'])) |
338 | 338 | { |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | |
348 | 348 | $component->applyStyleSheetSkin($page); |
349 | 349 | foreach($properties as $name=>$value) |
350 | - $this->configureControl($component,$name,$value); |
|
350 | + $this->configureControl($component, $name, $value); |
|
351 | 351 | |
352 | 352 | $component->trackViewState(true); |
353 | 353 | |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | { |
366 | 366 | if(is_array($properties['id'])) |
367 | 367 | $properties['id']=$component->evaluateExpression($properties['id'][1]); |
368 | - $tplControl->registerObject($properties['id'],$component); |
|
368 | + $tplControl->registerObject($properties['id'], $component); |
|
369 | 369 | if(!$component->hasProperty('id')) |
370 | 370 | unset($properties['id']); |
371 | 371 | } |
372 | 372 | foreach($properties as $name=>$value) |
373 | - $this->configureComponent($component,$name,$value); |
|
373 | + $this->configureComponent($component, $name, $value); |
|
374 | 374 | if($parent===$parentControl) |
375 | 375 | $directChildren[]=$component; |
376 | 376 | else |
@@ -416,14 +416,14 @@ discard block |
||
416 | 416 | * @param string property name |
417 | 417 | * @param mixed property initial value |
418 | 418 | */ |
419 | - protected function configureControl($control,$name,$value) |
|
419 | + protected function configureControl($control, $name, $value) |
|
420 | 420 | { |
421 | - if(strncasecmp($name,'on',2)===0) // is an event |
|
422 | - $this->configureEvent($control,$name,$value,$control); |
|
423 | - else if(($pos=strrpos($name,'.'))===false) // is a simple property or custom attribute |
|
424 | - $this->configureProperty($control,$name,$value); |
|
421 | + if(strncasecmp($name, 'on', 2)===0) // is an event |
|
422 | + $this->configureEvent($control, $name, $value, $control); |
|
423 | + else if(($pos=strrpos($name, '.'))===false) // is a simple property or custom attribute |
|
424 | + $this->configureProperty($control, $name, $value); |
|
425 | 425 | else // is a subproperty |
426 | - $this->configureSubProperty($control,$name,$value); |
|
426 | + $this->configureSubProperty($control, $name, $value); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -432,12 +432,12 @@ discard block |
||
432 | 432 | * @param string property name |
433 | 433 | * @param mixed property initial value |
434 | 434 | */ |
435 | - protected function configureComponent($component,$name,$value) |
|
435 | + protected function configureComponent($component, $name, $value) |
|
436 | 436 | { |
437 | - if(strpos($name,'.')===false) // is a simple property or custom attribute |
|
438 | - $this->configureProperty($component,$name,$value); |
|
437 | + if(strpos($name, '.')===false) // is a simple property or custom attribute |
|
438 | + $this->configureProperty($component, $name, $value); |
|
439 | 439 | else // is a subproperty |
440 | - $this->configureSubProperty($component,$name,$value); |
|
440 | + $this->configureSubProperty($component, $name, $value); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | * @param string event handler |
448 | 448 | * @param TControl context control |
449 | 449 | */ |
450 | - protected function configureEvent($control,$name,$value,$contextControl) |
|
450 | + protected function configureEvent($control, $name, $value, $contextControl) |
|
451 | 451 | { |
452 | - if(strpos($value,'.')===false) |
|
453 | - $control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value)); |
|
452 | + if(strpos($value, '.')===false) |
|
453 | + $control->attachEventHandler($name, array($contextControl, 'TemplateControl.'.$value)); |
|
454 | 454 | else |
455 | - $control->attachEventHandler($name,array($contextControl,$value)); |
|
455 | + $control->attachEventHandler($name, array($contextControl, $value)); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -461,18 +461,18 @@ discard block |
||
461 | 461 | * @param string property name |
462 | 462 | * @param mixed property initial value |
463 | 463 | */ |
464 | - protected function configureProperty($component,$name,$value) |
|
464 | + protected function configureProperty($component, $name, $value) |
|
465 | 465 | { |
466 | 466 | if(is_array($value)) |
467 | 467 | { |
468 | 468 | switch($value[0]) |
469 | 469 | { |
470 | 470 | case self::CONFIG_DATABIND: |
471 | - $component->bindProperty($name,$value[1]); |
|
471 | + $component->bindProperty($name, $value[1]); |
|
472 | 472 | break; |
473 | 473 | case self::CONFIG_EXPRESSION: |
474 | 474 | if($component instanceof TControl) |
475 | - $component->autoBindProperty($name,$value[1]); |
|
475 | + $component->autoBindProperty($name, $value[1]); |
|
476 | 476 | else |
477 | 477 | { |
478 | 478 | $setter='set'.$name; |
@@ -497,15 +497,15 @@ discard block |
||
497 | 497 | $component->$setter(Prado::localize($value[1])); |
498 | 498 | break; |
499 | 499 | default: // an error if reaching here |
500 | - throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
500 | + throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
501 | 501 | break; |
502 | 502 | } |
503 | 503 | } |
504 | 504 | else |
505 | 505 | { |
506 | - if (substr($name,0,2)=='js') |
|
507 | - if ($value and !($value instanceof TJavaScriptLiteral)) |
|
508 | - $value = new TJavaScriptLiteral($value); |
|
506 | + if(substr($name, 0, 2)=='js') |
|
507 | + if($value and !($value instanceof TJavaScriptLiteral)) |
|
508 | + $value=new TJavaScriptLiteral($value); |
|
509 | 509 | $setter='set'.$name; |
510 | 510 | $component->$setter($value); |
511 | 511 | } |
@@ -517,41 +517,41 @@ discard block |
||
517 | 517 | * @param string subproperty name |
518 | 518 | * @param mixed subproperty initial value |
519 | 519 | */ |
520 | - protected function configureSubProperty($component,$name,$value) |
|
520 | + protected function configureSubProperty($component, $name, $value) |
|
521 | 521 | { |
522 | 522 | if(is_array($value)) |
523 | 523 | { |
524 | 524 | switch($value[0]) |
525 | 525 | { |
526 | 526 | case self::CONFIG_DATABIND: // databinding |
527 | - $component->bindProperty($name,$value[1]); |
|
527 | + $component->bindProperty($name, $value[1]); |
|
528 | 528 | break; |
529 | 529 | case self::CONFIG_EXPRESSION: // expression |
530 | 530 | if($component instanceof TControl) |
531 | - $component->autoBindProperty($name,$value[1]); |
|
531 | + $component->autoBindProperty($name, $value[1]); |
|
532 | 532 | else |
533 | - $component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1])); |
|
533 | + $component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1])); |
|
534 | 534 | break; |
535 | 535 | case self::CONFIG_TEMPLATE: |
536 | - $component->setSubProperty($name,$value[1]); |
|
536 | + $component->setSubProperty($name, $value[1]); |
|
537 | 537 | break; |
538 | 538 | case self::CONFIG_ASSET: // asset URL |
539 | 539 | $url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]); |
540 | - $component->setSubProperty($name,$url); |
|
540 | + $component->setSubProperty($name, $url); |
|
541 | 541 | break; |
542 | 542 | case self::CONFIG_PARAMETER: // application parameter |
543 | - $component->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1])); |
|
543 | + $component->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1])); |
|
544 | 544 | break; |
545 | 545 | case self::CONFIG_LOCALIZATION: |
546 | - $component->setSubProperty($name,Prado::localize($value[1])); |
|
546 | + $component->setSubProperty($name, Prado::localize($value[1])); |
|
547 | 547 | break; |
548 | 548 | default: // an error if reaching here |
549 | - throw new TConfigurationException('template_tag_unexpected',$name,$value[1]); |
|
549 | + throw new TConfigurationException('template_tag_unexpected', $name, $value[1]); |
|
550 | 550 | break; |
551 | 551 | } |
552 | 552 | } |
553 | 553 | else |
554 | - $component->setSubProperty($name,$value); |
|
554 | + $component->setSubProperty($name, $value); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | { |
580 | 580 | $input=$this->preprocess($input); |
581 | 581 | $tpl=&$this->_tpl; |
582 | - $n=preg_match_all(self::REGEX_RULES,$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
582 | + $n=preg_match_all(self::REGEX_RULES, $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
583 | 583 | $expectPropEnd=false; |
584 | 584 | $textStart=0; |
585 | 585 | $stack=array(); |
@@ -589,186 +589,186 @@ discard block |
||
589 | 589 | $this->_directive=null; |
590 | 590 | try |
591 | 591 | { |
592 | - for($i=0;$i<$n;++$i) |
|
592 | + for($i=0; $i < $n; ++$i) |
|
593 | 593 | { |
594 | 594 | $match=&$matches[$i]; |
595 | 595 | $str=$match[0][0]; |
596 | 596 | $matchStart=$match[0][1]; |
597 | - $matchEnd=$matchStart+strlen($str)-1; |
|
598 | - if(strpos($str,'<com:')===0) // opening component tag |
|
597 | + $matchEnd=$matchStart + strlen($str) - 1; |
|
598 | + if(strpos($str, '<com:')===0) // opening component tag |
|
599 | 599 | { |
600 | 600 | if($expectPropEnd) |
601 | 601 | continue; |
602 | - if($matchStart>$textStart) |
|
603 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
604 | - $textStart=$matchEnd+1; |
|
602 | + if($matchStart > $textStart) |
|
603 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
604 | + $textStart=$matchEnd + 1; |
|
605 | 605 | $type=$match[1][0]; |
606 | - $attributes=$this->parseAttributes($match[2][0],$match[2][1]); |
|
607 | - $this->validateAttributes($type,$attributes); |
|
608 | - $tpl[$c++]=array($container,$type,$attributes); |
|
609 | - if($str[strlen($str)-2]!=='/') // open tag |
|
606 | + $attributes=$this->parseAttributes($match[2][0], $match[2][1]); |
|
607 | + $this->validateAttributes($type, $attributes); |
|
608 | + $tpl[$c++]=array($container, $type, $attributes); |
|
609 | + if($str[strlen($str) - 2]!=='/') // open tag |
|
610 | 610 | { |
611 | - $stack[] = $type; |
|
612 | - $container=$c-1; |
|
611 | + $stack[]=$type; |
|
612 | + $container=$c - 1; |
|
613 | 613 | } |
614 | 614 | } |
615 | - else if(strpos($str,'</com:')===0) // closing component tag |
|
615 | + else if(strpos($str, '</com:')===0) // closing component tag |
|
616 | 616 | { |
617 | 617 | if($expectPropEnd) |
618 | 618 | continue; |
619 | - if($matchStart>$textStart) |
|
620 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
621 | - $textStart=$matchEnd+1; |
|
619 | + if($matchStart > $textStart) |
|
620 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
621 | + $textStart=$matchEnd + 1; |
|
622 | 622 | $type=$match[1][0]; |
623 | 623 | |
624 | 624 | if(empty($stack)) |
625 | - throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>"); |
|
625 | + throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>"); |
|
626 | 626 | |
627 | 627 | $name=array_pop($stack); |
628 | 628 | if($name!==$type) |
629 | 629 | { |
630 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
631 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
630 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
631 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
632 | 632 | } |
633 | 633 | $container=$tpl[$container][0]; |
634 | 634 | } |
635 | - else if(strpos($str,'<%@')===0) // directive |
|
635 | + else if(strpos($str, '<%@')===0) // directive |
|
636 | 636 | { |
637 | 637 | if($expectPropEnd) |
638 | 638 | continue; |
639 | - if($matchStart>$textStart) |
|
640 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
641 | - $textStart=$matchEnd+1; |
|
639 | + if($matchStart > $textStart) |
|
640 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
641 | + $textStart=$matchEnd + 1; |
|
642 | 642 | if(isset($tpl[0]) || $this->_directive!==null) |
643 | 643 | throw new TConfigurationException('template_directive_nonunique'); |
644 | - $this->_directive=$this->parseAttributes($match[4][0],$match[4][1]); |
|
644 | + $this->_directive=$this->parseAttributes($match[4][0], $match[4][1]); |
|
645 | 645 | } |
646 | - else if(strpos($str,'<%')===0) // expression |
|
646 | + else if(strpos($str, '<%')===0) // expression |
|
647 | 647 | { |
648 | 648 | if($expectPropEnd) |
649 | 649 | continue; |
650 | - if($matchStart>$textStart) |
|
651 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
652 | - $textStart=$matchEnd+1; |
|
650 | + if($matchStart > $textStart) |
|
651 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
652 | + $textStart=$matchEnd + 1; |
|
653 | 653 | $literal=trim($match[5][0]); |
654 | 654 | if($str[2]==='=') // expression |
655 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal)); |
|
655 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, $literal)); |
|
656 | 656 | else if($str[2]==='%') // statements |
657 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal)); |
|
657 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_STATEMENTS, $literal)); |
|
658 | 658 | else if($str[2]==='#') |
659 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal)); |
|
659 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_DATABINDING, $literal)); |
|
660 | 660 | else if($str[2]==='$') |
661 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
661 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')")); |
|
662 | 662 | else if($str[2]==='~') |
663 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
663 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')")); |
|
664 | 664 | else if($str[2]==='/') |
665 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); |
|
665 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'")); |
|
666 | 666 | else if($str[2]==='[') |
667 | 667 | { |
668 | - $literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\")); |
|
669 | - $tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')")); |
|
668 | + $literal=strtr(trim(substr($literal, 0, strlen($literal) - 1)), array("'"=>"\'", "\\"=>"\\\\")); |
|
669 | + $tpl[$c++]=array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')")); |
|
670 | 670 | } |
671 | 671 | } |
672 | - else if(strpos($str,'<prop:')===0) // opening property |
|
672 | + else if(strpos($str, '<prop:')===0) // opening property |
|
673 | 673 | { |
674 | - if(strrpos($str,'/>')===strlen($str)-2) //subproperties |
|
674 | + if(strrpos($str, '/>')===strlen($str) - 2) //subproperties |
|
675 | 675 | { |
676 | 676 | if($expectPropEnd) |
677 | 677 | continue; |
678 | - if($matchStart>$textStart) |
|
679 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
680 | - $textStart=$matchEnd+1; |
|
678 | + if($matchStart > $textStart) |
|
679 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
680 | + $textStart=$matchEnd + 1; |
|
681 | 681 | $prop=strtolower($match[6][0]); |
682 | - $attrs=$this->parseAttributes($match[7][0],$match[7][1]); |
|
682 | + $attrs=$this->parseAttributes($match[7][0], $match[7][1]); |
|
683 | 683 | $attributes=array(); |
684 | 684 | foreach($attrs as $name=>$value) |
685 | 685 | $attributes[$prop.'.'.$name]=$value; |
686 | 686 | $type=$tpl[$container][1]; |
687 | - $this->validateAttributes($type,$attributes); |
|
687 | + $this->validateAttributes($type, $attributes); |
|
688 | 688 | foreach($attributes as $name=>$value) |
689 | 689 | { |
690 | 690 | if(isset($tpl[$container][2][$name])) |
691 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
691 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
692 | 692 | $tpl[$container][2][$name]=$value; |
693 | 693 | } |
694 | 694 | } |
695 | 695 | else // regular property |
696 | 696 | { |
697 | 697 | $prop=strtolower($match[3][0]); |
698 | - $stack[] = '@'.$prop; |
|
698 | + $stack[]='@'.$prop; |
|
699 | 699 | if(!$expectPropEnd) |
700 | 700 | { |
701 | - if($matchStart>$textStart) |
|
702 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
703 | - $textStart=$matchEnd+1; |
|
701 | + if($matchStart > $textStart) |
|
702 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
703 | + $textStart=$matchEnd + 1; |
|
704 | 704 | $expectPropEnd=true; |
705 | 705 | } |
706 | 706 | } |
707 | 707 | } |
708 | - else if(strpos($str,'</prop:')===0) // closing property |
|
708 | + else if(strpos($str, '</prop:')===0) // closing property |
|
709 | 709 | { |
710 | 710 | $prop=strtolower($match[3][0]); |
711 | 711 | if(empty($stack)) |
712 | - throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>"); |
|
712 | + throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>"); |
|
713 | 713 | $name=array_pop($stack); |
714 | 714 | if($name!=='@'.$prop) |
715 | 715 | { |
716 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
717 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
716 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
717 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
718 | 718 | } |
719 | - if(($last=count($stack))<1 || $stack[$last-1][0]!=='@') |
|
719 | + if(($last=count($stack)) < 1 || $stack[$last - 1][0]!=='@') |
|
720 | 720 | { |
721 | - if($matchStart>$textStart) |
|
721 | + if($matchStart > $textStart) |
|
722 | 722 | { |
723 | - $value=substr($input,$textStart,$matchStart-$textStart); |
|
724 | - if(substr($prop,-8,8)==='template') |
|
725 | - $value=$this->parseTemplateProperty($value,$textStart); |
|
723 | + $value=substr($input, $textStart, $matchStart - $textStart); |
|
724 | + if(substr($prop, -8, 8)==='template') |
|
725 | + $value=$this->parseTemplateProperty($value, $textStart); |
|
726 | 726 | else |
727 | 727 | $value=$this->parseAttribute($value); |
728 | - if($container>=0) |
|
728 | + if($container >= 0) |
|
729 | 729 | { |
730 | 730 | $type=$tpl[$container][1]; |
731 | - $this->validateAttributes($type,array($prop=>$value)); |
|
731 | + $this->validateAttributes($type, array($prop=>$value)); |
|
732 | 732 | if(isset($tpl[$container][2][$prop])) |
733 | - throw new TConfigurationException('template_property_duplicated',$prop); |
|
733 | + throw new TConfigurationException('template_property_duplicated', $prop); |
|
734 | 734 | $tpl[$container][2][$prop]=$value; |
735 | 735 | } |
736 | 736 | else // a property for the template control |
737 | 737 | $this->_directive[$prop]=$value; |
738 | - $textStart=$matchEnd+1; |
|
738 | + $textStart=$matchEnd + 1; |
|
739 | 739 | } |
740 | 740 | $expectPropEnd=false; |
741 | 741 | } |
742 | 742 | } |
743 | - else if(strpos($str,'<!--')===0) // comments |
|
743 | + else if(strpos($str, '<!--')===0) // comments |
|
744 | 744 | { |
745 | 745 | if($expectPropEnd) |
746 | 746 | throw new TConfigurationException('template_comments_forbidden'); |
747 | - if($matchStart>$textStart) |
|
748 | - $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart)); |
|
749 | - $textStart=$matchEnd+1; |
|
747 | + if($matchStart > $textStart) |
|
748 | + $tpl[$c++]=array($container, substr($input, $textStart, $matchStart - $textStart)); |
|
749 | + $textStart=$matchEnd + 1; |
|
750 | 750 | } |
751 | 751 | else |
752 | - throw new TConfigurationException('template_matching_unexpected',$match); |
|
752 | + throw new TConfigurationException('template_matching_unexpected', $match); |
|
753 | 753 | } |
754 | 754 | if(!empty($stack)) |
755 | 755 | { |
756 | 756 | $name=array_pop($stack); |
757 | - $tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>"; |
|
758 | - throw new TConfigurationException('template_closingtag_expected',$tag); |
|
757 | + $tag=$name[0]==='@' ? '</prop:'.substr($name, 1).'>' : "</com:$name>"; |
|
758 | + throw new TConfigurationException('template_closingtag_expected', $tag); |
|
759 | 759 | } |
760 | - if($textStart<strlen($input)) |
|
761 | - $tpl[$c++]=array($container,substr($input,$textStart)); |
|
760 | + if($textStart < strlen($input)) |
|
761 | + $tpl[$c++]=array($container, substr($input, $textStart)); |
|
762 | 762 | } |
763 | 763 | catch(Exception $e) |
764 | 764 | { |
765 | 765 | if(($e instanceof TException) && ($e instanceof TTemplateException)) |
766 | 766 | throw $e; |
767 | 767 | if($matchEnd===0) |
768 | - $line=$this->_startingLine+1; |
|
768 | + $line=$this->_startingLine + 1; |
|
769 | 769 | else |
770 | - $line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1))); |
|
771 | - $this->handleException($e,$line,$input); |
|
770 | + $line=$this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1))); |
|
771 | + $this->handleException($e, $line, $input); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | if($this->_directive===null) |
@@ -785,9 +785,9 @@ discard block |
||
785 | 785 | if($parent!==null) |
786 | 786 | { |
787 | 787 | if(count($merged[1])===1 && is_string($merged[1][0])) |
788 | - $objects[$id-1]=array($merged[0],$merged[1][0]); |
|
788 | + $objects[$id - 1]=array($merged[0], $merged[1][0]); |
|
789 | 789 | else |
790 | - $objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
790 | + $objects[$id - 1]=array($merged[0], new TCompositeLiteral($merged[1])); |
|
791 | 791 | } |
792 | 792 | if(isset($object[2])) |
793 | 793 | { |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | else |
798 | 798 | { |
799 | 799 | $parent=$object[0]; |
800 | - $merged=array($parent,array($object[1])); |
|
800 | + $merged=array($parent, array($object[1])); |
|
801 | 801 | } |
802 | 802 | } |
803 | 803 | else |
@@ -806,9 +806,9 @@ discard block |
||
806 | 806 | if($parent!==null) |
807 | 807 | { |
808 | 808 | if(count($merged[1])===1 && is_string($merged[1][0])) |
809 | - $objects[$id]=array($merged[0],$merged[1][0]); |
|
809 | + $objects[$id]=array($merged[0], $merged[1][0]); |
|
810 | 810 | else |
811 | - $objects[$id]=array($merged[0],new TCompositeLiteral($merged[1])); |
|
811 | + $objects[$id]=array($merged[0], new TCompositeLiteral($merged[1])); |
|
812 | 812 | } |
813 | 813 | $tpl=$objects; |
814 | 814 | return $objects; |
@@ -819,31 +819,31 @@ discard block |
||
819 | 819 | * @param string the string to be parsed. |
820 | 820 | * @return array attribute values indexed by names. |
821 | 821 | */ |
822 | - protected function parseAttributes($str,$offset) |
|
822 | + protected function parseAttributes($str, $offset) |
|
823 | 823 | { |
824 | 824 | if($str==='') |
825 | 825 | return array(); |
826 | 826 | $pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS'; |
827 | 827 | $attributes=array(); |
828 | - $n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); |
|
829 | - for($i=0;$i<$n;++$i) |
|
828 | + $n=preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); |
|
829 | + for($i=0; $i < $n; ++$i) |
|
830 | 830 | { |
831 | 831 | $match=&$matches[$i]; |
832 | 832 | $name=strtolower($match[1][0]); |
833 | 833 | if(isset($attributes[$name])) |
834 | - throw new TConfigurationException('template_property_duplicated',$name); |
|
834 | + throw new TConfigurationException('template_property_duplicated', $name); |
|
835 | 835 | $value=$match[2][0]; |
836 | - if(substr($name,-8,8)==='template') |
|
836 | + if(substr($name, -8, 8)==='template') |
|
837 | 837 | { |
838 | 838 | if($value[0]==='\'' || $value[0]==='"') |
839 | - $attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1); |
|
839 | + $attributes[$name]=$this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1); |
|
840 | 840 | else |
841 | - $attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]); |
|
841 | + $attributes[$name]=$this->parseTemplateProperty($value, $match[2][1]); |
|
842 | 842 | } |
843 | 843 | else |
844 | 844 | { |
845 | 845 | if($value[0]==='\'' || $value[0]==='"') |
846 | - $attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2)); |
|
846 | + $attributes[$name]=$this->parseAttribute(substr($value, 1, strlen($value) - 2)); |
|
847 | 847 | else |
848 | 848 | $attributes[$name]=$this->parseAttribute($value); |
849 | 849 | } |
@@ -851,10 +851,10 @@ discard block |
||
851 | 851 | return $attributes; |
852 | 852 | } |
853 | 853 | |
854 | - protected function parseTemplateProperty($content,$offset) |
|
854 | + protected function parseTemplateProperty($content, $offset) |
|
855 | 855 | { |
856 | - $line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1; |
|
857 | - return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false)); |
|
856 | + $line=$this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1; |
|
857 | + return array(self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false)); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | /** |
@@ -864,12 +864,12 @@ discard block |
||
864 | 864 | */ |
865 | 865 | protected function parseAttribute($value) |
866 | 866 | { |
867 | - if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0) |
|
867 | + if(($n=preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0) |
|
868 | 868 | { |
869 | 869 | $isDataBind=false; |
870 | 870 | $textStart=0; |
871 | 871 | $expr=''; |
872 | - for($i=0;$i<$n;++$i) |
|
872 | + for($i=0; $i < $n; ++$i) |
|
873 | 873 | { |
874 | 874 | $match=$matches[0][$i]; |
875 | 875 | $token=$match[0]; |
@@ -877,114 +877,114 @@ discard block |
||
877 | 877 | $length=strlen($token); |
878 | 878 | if($token[2]==='#') |
879 | 879 | $isDataBind=true; |
880 | - if($offset>$textStart) |
|
881 | - $expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
882 | - $expr.='.('.substr($token,3,$length-5).')'; |
|
883 | - $textStart=$offset+$length; |
|
880 | + if($offset > $textStart) |
|
881 | + $expr.=".'".strtr(substr($value, $textStart, $offset - $textStart), array("'"=>"\\'", "\\"=>"\\\\"))."'"; |
|
882 | + $expr.='.('.substr($token, 3, $length - 5).')'; |
|
883 | + $textStart=$offset + $length; |
|
884 | 884 | } |
885 | 885 | $length=strlen($value); |
886 | - if($length>$textStart) |
|
887 | - $expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'"; |
|
886 | + if($length > $textStart) |
|
887 | + $expr.=".'".strtr(substr($value, $textStart, $length - $textStart), array("'"=>"\\'", "\\"=>"\\\\"))."'"; |
|
888 | 888 | if($isDataBind) |
889 | - return array(self::CONFIG_DATABIND,ltrim($expr,'.')); |
|
889 | + return array(self::CONFIG_DATABIND, ltrim($expr, '.')); |
|
890 | 890 | else |
891 | - return array(self::CONFIG_EXPRESSION,ltrim($expr,'.')); |
|
891 | + return array(self::CONFIG_EXPRESSION, ltrim($expr, '.')); |
|
892 | 892 | } |
893 | - else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value) |
|
893 | + else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0]===$value) |
|
894 | 894 | { |
895 | 895 | $value=$matches[1]; |
896 | 896 | if($value[2]==='~') |
897 | - return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5))); |
|
897 | + return array(self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5))); |
|
898 | 898 | elseif($value[2]==='[') |
899 | - return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6))); |
|
899 | + return array(self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6))); |
|
900 | 900 | elseif($value[2]==='$') |
901 | - return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5))); |
|
901 | + return array(self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5))); |
|
902 | 902 | elseif($value[2]==='/') { |
903 | - $literal = trim(substr($value,3,strlen($value)-5)); |
|
904 | - return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
|
903 | + $literal=trim(substr($value, 3, strlen($value) - 5)); |
|
904 | + return array(self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '\/').'/$literal'"); |
|
905 | 905 | } |
906 | 906 | } |
907 | 907 | else |
908 | 908 | return $value; |
909 | 909 | } |
910 | 910 | |
911 | - protected function validateAttributes($type,$attributes) |
|
911 | + protected function validateAttributes($type, $attributes) |
|
912 | 912 | { |
913 | 913 | Prado::using($type); |
914 | - if(($pos=strrpos($type,'.'))!==false) |
|
915 | - $className=substr($type,$pos+1); |
|
914 | + if(($pos=strrpos($type, '.'))!==false) |
|
915 | + $className=substr($type, $pos + 1); |
|
916 | 916 | else |
917 | 917 | $className=$type; |
918 | 918 | $class=new ReflectionClass($className); |
919 | - if(is_subclass_of($className,'TControl') || $className==='TControl') |
|
919 | + if(is_subclass_of($className, 'TControl') || $className==='TControl') |
|
920 | 920 | { |
921 | 921 | foreach($attributes as $name=>$att) |
922 | 922 | { |
923 | - if(($pos=strpos($name,'.'))!==false) |
|
923 | + if(($pos=strpos($name, '.'))!==false) |
|
924 | 924 | { |
925 | 925 | // a subproperty, so the first segment must be readable |
926 | - $subname=substr($name,0,$pos); |
|
926 | + $subname=substr($name, 0, $pos); |
|
927 | 927 | if(!$class->hasMethod('get'.$subname)) |
928 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
928 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
929 | 929 | } |
930 | - else if(strncasecmp($name,'on',2)===0) |
|
930 | + else if(strncasecmp($name, 'on', 2)===0) |
|
931 | 931 | { |
932 | 932 | // an event |
933 | 933 | if(!$class->hasMethod($name)) |
934 | - throw new TConfigurationException('template_event_unknown',$type,$name); |
|
934 | + throw new TConfigurationException('template_event_unknown', $type, $name); |
|
935 | 935 | else if(!is_string($att)) |
936 | - throw new TConfigurationException('template_eventhandler_invalid',$type,$name); |
|
936 | + throw new TConfigurationException('template_eventhandler_invalid', $type, $name); |
|
937 | 937 | } |
938 | 938 | else |
939 | 939 | { |
940 | 940 | // a simple property |
941 | - if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) ) |
|
941 | + if(!($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name))) |
|
942 | 942 | { |
943 | - if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
944 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
943 | + if($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) |
|
944 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
945 | 945 | else |
946 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
946 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
947 | 947 | } |
948 | 948 | else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION) |
949 | 949 | { |
950 | - if(strcasecmp($name,'id')===0) |
|
951 | - throw new TConfigurationException('template_controlid_invalid',$type); |
|
952 | - else if(strcasecmp($name,'skinid')===0) |
|
953 | - throw new TConfigurationException('template_controlskinid_invalid',$type); |
|
950 | + if(strcasecmp($name, 'id')===0) |
|
951 | + throw new TConfigurationException('template_controlid_invalid', $type); |
|
952 | + else if(strcasecmp($name, 'skinid')===0) |
|
953 | + throw new TConfigurationException('template_controlskinid_invalid', $type); |
|
954 | 954 | } |
955 | 955 | } |
956 | 956 | } |
957 | 957 | } |
958 | - else if(is_subclass_of($className,'TComponent') || $className==='TComponent') |
|
958 | + else if(is_subclass_of($className, 'TComponent') || $className==='TComponent') |
|
959 | 959 | { |
960 | 960 | foreach($attributes as $name=>$att) |
961 | 961 | { |
962 | 962 | if(is_array($att) && ($att[0]===self::CONFIG_DATABIND)) |
963 | - throw new TConfigurationException('template_databind_forbidden',$type,$name); |
|
964 | - if(($pos=strpos($name,'.'))!==false) |
|
963 | + throw new TConfigurationException('template_databind_forbidden', $type, $name); |
|
964 | + if(($pos=strpos($name, '.'))!==false) |
|
965 | 965 | { |
966 | 966 | // a subproperty, so the first segment must be readable |
967 | - $subname=substr($name,0,$pos); |
|
967 | + $subname=substr($name, 0, $pos); |
|
968 | 968 | if(!$class->hasMethod('get'.$subname)) |
969 | - throw new TConfigurationException('template_property_unknown',$type,$subname); |
|
969 | + throw new TConfigurationException('template_property_unknown', $type, $subname); |
|
970 | 970 | } |
971 | - else if(strncasecmp($name,'on',2)===0) |
|
972 | - throw new TConfigurationException('template_event_forbidden',$type,$name); |
|
971 | + else if(strncasecmp($name, 'on', 2)===0) |
|
972 | + throw new TConfigurationException('template_event_forbidden', $type, $name); |
|
973 | 973 | else |
974 | 974 | { |
975 | 975 | // id is still alowed for TComponent, even if id property doesn't exist |
976 | - if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name))) |
|
976 | + if(strcasecmp($name, 'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class, 'set'.$name))) |
|
977 | 977 | { |
978 | 978 | if($class->hasMethod('get'.$name)) |
979 | - throw new TConfigurationException('template_property_readonly',$type,$name); |
|
979 | + throw new TConfigurationException('template_property_readonly', $type, $name); |
|
980 | 980 | else |
981 | - throw new TConfigurationException('template_property_unknown',$type,$name); |
|
981 | + throw new TConfigurationException('template_property_unknown', $type, $name); |
|
982 | 982 | } |
983 | 983 | } |
984 | 984 | } |
985 | 985 | } |
986 | 986 | else |
987 | - throw new TConfigurationException('template_component_required',$type); |
|
987 | + throw new TConfigurationException('template_component_required', $type); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | /** |
@@ -1003,28 +1003,28 @@ discard block |
||
1003 | 1003 | * @param int line number |
1004 | 1004 | * @param string template string if no source file is used |
1005 | 1005 | */ |
1006 | - protected function handleException($e,$line,$input=null) |
|
1006 | + protected function handleException($e, $line, $input=null) |
|
1007 | 1007 | { |
1008 | 1008 | $srcFile=$this->_tplFile; |
1009 | 1009 | |
1010 | - if(($n=count($this->_includedFiles))>0) // need to adjust error row number and file name |
|
1010 | + if(($n=count($this->_includedFiles)) > 0) // need to adjust error row number and file name |
|
1011 | 1011 | { |
1012 | - for($i=$n-1;$i>=0;--$i) |
|
1012 | + for($i=$n - 1; $i >= 0; --$i) |
|
1013 | 1013 | { |
1014 | - if($this->_includeAtLine[$i]<=$line) |
|
1014 | + if($this->_includeAtLine[$i] <= $line) |
|
1015 | 1015 | { |
1016 | - if($line<$this->_includeAtLine[$i]+$this->_includeLines[$i]) |
|
1016 | + if($line < $this->_includeAtLine[$i] + $this->_includeLines[$i]) |
|
1017 | 1017 | { |
1018 | - $line=$line-$this->_includeAtLine[$i]+1; |
|
1018 | + $line=$line - $this->_includeAtLine[$i] + 1; |
|
1019 | 1019 | $srcFile=$this->_includedFiles[$i]; |
1020 | 1020 | break; |
1021 | 1021 | } |
1022 | 1022 | else |
1023 | - $line=$line-$this->_includeLines[$i]+1; |
|
1023 | + $line=$line - $this->_includeLines[$i] + 1; |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | } |
1027 | - $exception=new TTemplateException('template_format_invalid',$e->getMessage()); |
|
1027 | + $exception=new TTemplateException('template_format_invalid', $e->getMessage()); |
|
1028 | 1028 | $exception->setLineNumber($line); |
1029 | 1029 | if(!empty($srcFile)) |
1030 | 1030 | $exception->setTemplateFile($srcFile); |
@@ -1040,29 +1040,29 @@ discard block |
||
1040 | 1040 | */ |
1041 | 1041 | protected function preprocess($input) |
1042 | 1042 | { |
1043 | - if($n=preg_match_all('/<%include(.*?)%>/',$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) |
|
1043 | + if($n=preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) |
|
1044 | 1044 | { |
1045 | - for($i=0;$i<$n;++$i) |
|
1045 | + for($i=0; $i < $n; ++$i) |
|
1046 | 1046 | { |
1047 | - $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT); |
|
1047 | + $filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT); |
|
1048 | 1048 | if($filePath!==null && is_file($filePath)) |
1049 | 1049 | $this->_includedFiles[]=$filePath; |
1050 | 1050 | else |
1051 | 1051 | { |
1052 | - $errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1))); |
|
1053 | - $this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input); |
|
1052 | + $errorLine=count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1))); |
|
1053 | + $this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input); |
|
1054 | 1054 | } |
1055 | 1055 | } |
1056 | 1056 | $base=0; |
1057 | - for($i=0;$i<$n;++$i) |
|
1057 | + for($i=0; $i < $n; ++$i) |
|
1058 | 1058 | { |
1059 | 1059 | $ext=file_get_contents($this->_includedFiles[$i]); |
1060 | 1060 | $length=strlen($matches[$i][0][0]); |
1061 | - $offset=$base+$matches[$i][0][1]; |
|
1062 | - $this->_includeAtLine[$i]=count(explode("\n",substr($input,0,$offset))); |
|
1063 | - $this->_includeLines[$i]=count(explode("\n",$ext)); |
|
1064 | - $input=substr_replace($input,$ext,$offset,$length); |
|
1065 | - $base+=strlen($ext)-$length; |
|
1061 | + $offset=$base + $matches[$i][0][1]; |
|
1062 | + $this->_includeAtLine[$i]=count(explode("\n", substr($input, 0, $offset))); |
|
1063 | + $this->_includeLines[$i]=count(explode("\n", $ext)); |
|
1064 | + $input=substr_replace($input, $ext, $offset, $length); |
|
1065 | + $base+=strlen($ext) - $length; |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | * @param string $method |
1076 | 1076 | * @return boolean |
1077 | 1077 | */ |
1078 | - protected function isClassBehaviorMethod(ReflectionClass $class,$method) |
|
1078 | + protected function isClassBehaviorMethod(ReflectionClass $class, $method) |
|
1079 | 1079 | { |
1080 | 1080 | $component=new ReflectionClass('TComponent'); |
1081 | 1081 | $behaviors=$component->getStaticProperties(); |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue; |
1087 | 1087 | foreach($list as $param) |
1088 | 1088 | { |
1089 | - if(method_exists($param->getBehavior(),$method)) |
|
1089 | + if(method_exists($param->getBehavior(), $method)) |
|
1090 | 1090 | return true; |
1091 | 1091 | } |
1092 | 1092 | } |
@@ -54,6 +54,9 @@ discard block |
||
54 | 54 | return $caseSensitive?$token:strtoupper($token); |
55 | 55 | } |
56 | 56 | |
57 | +/** |
|
58 | + * @param string $hex |
|
59 | + */ |
|
57 | 60 | function hash2string($hex,$alphabet) |
58 | 61 | { |
59 | 62 | if(strlen($alphabet)<2) |
@@ -121,6 +124,11 @@ discard block |
||
121 | 124 | imagedestroy($image); |
122 | 125 | } |
123 | 126 | |
127 | +/** |
|
128 | + * @param resource $image |
|
129 | + * @param double $width |
|
130 | + * @param double $height |
|
131 | + */ |
|
124 | 132 | function addBackground($image,$width,$height,$opaque,$noisy,$hasGrid,$hasScribble,$morph) |
125 | 133 | { |
126 | 134 | $background=imagecreatetruecolor($width*2,$height*2); |
@@ -148,6 +156,9 @@ discard block |
||
148 | 156 | imagecolortransparent($image,$white); |
149 | 157 | } |
150 | 158 | |
159 | +/** |
|
160 | + * @param resource $image |
|
161 | + */ |
|
151 | 162 | function addNoise($image,$width,$height) |
152 | 163 | { |
153 | 164 | for($x=0;$x<$width;++$x) |
@@ -164,6 +175,9 @@ discard block |
||
164 | 175 | } |
165 | 176 | } |
166 | 177 | |
178 | +/** |
|
179 | + * @param resource $image |
|
180 | + */ |
|
167 | 181 | function addGrid($image,$width,$height) |
168 | 182 | { |
169 | 183 | for($i=0;$i<$width;$i+=rand(15,25)) |
@@ -182,6 +196,9 @@ discard block |
||
182 | 196 | } |
183 | 197 | } |
184 | 198 | |
199 | +/** |
|
200 | + * @param resource $image |
|
201 | + */ |
|
185 | 202 | function addScribble($image,$width,$height) |
186 | 203 | { |
187 | 204 | for($i=0;$i<8;$i++) |
@@ -199,6 +216,9 @@ discard block |
||
199 | 216 | } |
200 | 217 | } |
201 | 218 | |
219 | +/** |
|
220 | + * @param resource $image |
|
221 | + */ |
|
202 | 222 | function morphImage($image,$width,$height) |
203 | 223 | { |
204 | 224 | $tempImage=imagecreatetruecolor($width,$height); |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | $font=dirname(__FILE__).DIRECTORY_SEPARATOR.'verase.ttf'; |
101 | 101 | |
102 | 102 | if(function_exists('imagefilter')) |
103 | - imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR); |
|
103 | + imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR); |
|
104 | 104 | |
105 | 105 | $hasShadow=($theme&THEME_SHADOWED_TEXT); |
106 | - for($i=0;$i<$length;$i++) |
|
106 | + for($i=0;$i<$length;$i++) |
|
107 | 107 | { |
108 | - $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); |
|
109 | - $size=rand($fontWidth-10,$fontWidth); |
|
110 | - $angle=rand(-30,30); |
|
111 | - $x=$padding+$i*$fontWidth; |
|
112 | - $y=rand($fontHeight-15,$fontHeight-10); |
|
113 | - imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]); |
|
114 | - if($hasShadow) |
|
115 | - imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]); |
|
116 | - imagecolordeallocate($image,$color); |
|
117 | - } |
|
108 | + $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); |
|
109 | + $size=rand($fontWidth-10,$fontWidth); |
|
110 | + $angle=rand(-30,30); |
|
111 | + $x=$padding+$i*$fontWidth; |
|
112 | + $y=rand($fontHeight-15,$fontHeight-10); |
|
113 | + imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]); |
|
114 | + if($hasShadow) |
|
115 | + imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]); |
|
116 | + imagecolordeallocate($image,$color); |
|
117 | + } |
|
118 | 118 | |
119 | 119 | header('Content-Type: image/png'); |
120 | 120 | imagepng($image); |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | { |
159 | 159 | $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); |
160 | 160 | imagesetpixel($image,$x,$y,$color); |
161 | - imagecolordeallocate($image,$color); |
|
162 | - } |
|
161 | + imagecolordeallocate($image,$color); |
|
162 | + } |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | * @package System.Web.UI.WebControls.assets |
10 | 10 | */ |
11 | 11 | |
12 | -define('THEME_OPAQUE_BACKGROUND',0x0001); |
|
13 | -define('THEME_NOISY_BACKGROUND',0x0002); |
|
14 | -define('THEME_HAS_GRID',0x0004); |
|
15 | -define('THEME_HAS_SCRIBBLE',0x0008); |
|
16 | -define('THEME_MORPH_BACKGROUND',0x0010); |
|
17 | -define('THEME_SHADOWED_TEXT',0x0020); |
|
12 | +define('THEME_OPAQUE_BACKGROUND', 0x0001); |
|
13 | +define('THEME_NOISY_BACKGROUND', 0x0002); |
|
14 | +define('THEME_HAS_GRID', 0x0004); |
|
15 | +define('THEME_HAS_SCRIBBLE', 0x0008); |
|
16 | +define('THEME_MORPH_BACKGROUND', 0x0010); |
|
17 | +define('THEME_SHADOWED_TEXT', 0x0020); |
|
18 | 18 | |
19 | 19 | require_once(dirname(__FILE__).'/captcha_key.php'); |
20 | 20 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | if(isset($_GET['options'])) |
25 | 25 | { |
26 | 26 | $str=base64_decode($_GET['options']); |
27 | - if(strlen($str)>32) |
|
27 | + if(strlen($str) > 32) |
|
28 | 28 | { |
29 | - $hash=substr($str,0,32); |
|
30 | - $str=substr($str,32); |
|
29 | + $hash=substr($str, 0, 32); |
|
30 | + $str=substr($str, 32); |
|
31 | 31 | if(md5($privateKey.$str)===$hash) |
32 | 32 | { |
33 | 33 | $options=unserialize($str); |
@@ -37,83 +37,82 @@ discard block |
||
37 | 37 | $alphabet=$options['alphabet']; |
38 | 38 | $fontSize=$options['fontSize']; |
39 | 39 | $theme=$options['theme']; |
40 | - if(($randomSeed=$options['randomSeed'])>0) |
|
40 | + if(($randomSeed=$options['randomSeed']) > 0) |
|
41 | 41 | srand($randomSeed); |
42 | 42 | else |
43 | - srand((int)(microtime()*1000000)); |
|
44 | - $token=generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive); |
|
43 | + srand((int) (microtime() * 1000000)); |
|
44 | + $token=generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -displayToken($token,$fontSize,$theme); |
|
49 | +displayToken($token, $fontSize, $theme); |
|
50 | 50 | |
51 | -function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive) |
|
51 | +function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive) |
|
52 | 52 | { |
53 | - $token=substr(hash2string(md5($publicKey.$privateKey),$alphabet).hash2string(md5($privateKey.$publicKey),$alphabet),0,$tokenLength); |
|
54 | - return $caseSensitive?$token:strtoupper($token); |
|
53 | + $token=substr(hash2string(md5($publicKey.$privateKey), $alphabet).hash2string(md5($privateKey.$publicKey), $alphabet), 0, $tokenLength); |
|
54 | + return $caseSensitive ? $token : strtoupper($token); |
|
55 | 55 | } |
56 | 56 | |
57 | -function hash2string($hex,$alphabet) |
|
57 | +function hash2string($hex, $alphabet) |
|
58 | 58 | { |
59 | - if(strlen($alphabet)<2) |
|
59 | + if(strlen($alphabet) < 2) |
|
60 | 60 | $alphabet='234578adefhijmnrtABDEFGHJLMNRT'; |
61 | 61 | $hexLength=strlen($hex); |
62 | 62 | $base=strlen($alphabet); |
63 | 63 | $result=''; |
64 | - for($i=0;$i<$hexLength;$i+=6) |
|
64 | + for($i=0; $i < $hexLength; $i+=6) |
|
65 | 65 | { |
66 | - $number=hexdec(substr($hex,$i,6)); |
|
66 | + $number=hexdec(substr($hex, $i, 6)); |
|
67 | 67 | while($number) |
68 | 68 | { |
69 | - $result.=$alphabet[$number%$base]; |
|
70 | - $number=floor($number/$base); |
|
69 | + $result.=$alphabet[$number % $base]; |
|
70 | + $number=floor($number / $base); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | return $result; |
74 | 74 | } |
75 | 75 | |
76 | -function displayToken($token,$fontSize,$theme) |
|
76 | +function displayToken($token, $fontSize, $theme) |
|
77 | 77 | { |
78 | - if(($fontSize=(int)$fontSize)<22) |
|
78 | + if(($fontSize=(int) $fontSize) < 22) |
|
79 | 79 | $fontSize=22; |
80 | - if($fontSize>100) |
|
80 | + if($fontSize > 100) |
|
81 | 81 | $fontSize=100; |
82 | 82 | $length=strlen($token); |
83 | 83 | $padding=10; |
84 | 84 | $fontWidth=$fontSize; |
85 | - $fontHeight=floor($fontWidth*1.5); |
|
86 | - $width=$fontWidth*$length+$padding*2; |
|
85 | + $fontHeight=floor($fontWidth * 1.5); |
|
86 | + $width=$fontWidth * $length + $padding * 2; |
|
87 | 87 | $height=$fontHeight; |
88 | - $image=imagecreatetruecolor($width,$height); |
|
88 | + $image=imagecreatetruecolor($width, $height); |
|
89 | 89 | |
90 | - addBackground |
|
91 | - ( |
|
90 | + addBackground( |
|
92 | 91 | $image, $width, $height, |
93 | - $theme&THEME_OPAQUE_BACKGROUND, |
|
94 | - $theme&THEME_NOISY_BACKGROUND, |
|
95 | - $theme&THEME_HAS_GRID, |
|
96 | - $theme&THEME_HAS_SCRIBBLE, |
|
97 | - $theme&THEME_MORPH_BACKGROUND |
|
92 | + $theme & THEME_OPAQUE_BACKGROUND, |
|
93 | + $theme & THEME_NOISY_BACKGROUND, |
|
94 | + $theme & THEME_HAS_GRID, |
|
95 | + $theme & THEME_HAS_SCRIBBLE, |
|
96 | + $theme & THEME_MORPH_BACKGROUND |
|
98 | 97 | ); |
99 | 98 | |
100 | 99 | $font=dirname(__FILE__).DIRECTORY_SEPARATOR.'verase.ttf'; |
101 | 100 | |
102 | 101 | if(function_exists('imagefilter')) |
103 | - imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR); |
|
102 | + imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); |
|
104 | 103 | |
105 | - $hasShadow=($theme&THEME_SHADOWED_TEXT); |
|
106 | - for($i=0;$i<$length;$i++) |
|
104 | + $hasShadow=($theme & THEME_SHADOWED_TEXT); |
|
105 | + for($i=0; $i < $length; $i++) |
|
107 | 106 | { |
108 | - $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); |
|
109 | - $size=rand($fontWidth-10,$fontWidth); |
|
110 | - $angle=rand(-30,30); |
|
111 | - $x=$padding+$i*$fontWidth; |
|
112 | - $y=rand($fontHeight-15,$fontHeight-10); |
|
113 | - imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]); |
|
107 | + $color=imagecolorallocate($image, rand(150, 220), rand(150, 220), rand(150, 220)); |
|
108 | + $size=rand($fontWidth - 10, $fontWidth); |
|
109 | + $angle=rand(-30, 30); |
|
110 | + $x=$padding + $i * $fontWidth; |
|
111 | + $y=rand($fontHeight - 15, $fontHeight - 10); |
|
112 | + imagettftext($image, $size, $angle, $x, $y, $color, $font, $token[$i]); |
|
114 | 113 | if($hasShadow) |
115 | - imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]); |
|
116 | - imagecolordeallocate($image,$color); |
|
114 | + imagettftext($image, $size, $angle, $x + 2, $y + 2, $color, $font, $token[$i]); |
|
115 | + imagecolordeallocate($image, $color); |
|
117 | 116 | } |
118 | 117 | |
119 | 118 | header('Content-Type: image/png'); |
@@ -121,103 +120,103 @@ discard block |
||
121 | 120 | imagedestroy($image); |
122 | 121 | } |
123 | 122 | |
124 | -function addBackground($image,$width,$height,$opaque,$noisy,$hasGrid,$hasScribble,$morph) |
|
123 | +function addBackground($image, $width, $height, $opaque, $noisy, $hasGrid, $hasScribble, $morph) |
|
125 | 124 | { |
126 | - $background=imagecreatetruecolor($width*2,$height*2); |
|
127 | - $white=imagecolorallocate($background,255,255,255); |
|
128 | - imagefill($background,0,0,$white); |
|
125 | + $background=imagecreatetruecolor($width * 2, $height * 2); |
|
126 | + $white=imagecolorallocate($background, 255, 255, 255); |
|
127 | + imagefill($background, 0, 0, $white); |
|
129 | 128 | |
130 | 129 | if($opaque) |
131 | - imagefill($background,0,0,imagecolorallocate($background,100,100,100)); |
|
130 | + imagefill($background, 0, 0, imagecolorallocate($background, 100, 100, 100)); |
|
132 | 131 | |
133 | 132 | if($noisy) |
134 | - addNoise($background,$width*2,$height*2); |
|
133 | + addNoise($background, $width * 2, $height * 2); |
|
135 | 134 | |
136 | 135 | if($hasGrid) |
137 | - addGrid($background,$width*2,$height*2); |
|
136 | + addGrid($background, $width * 2, $height * 2); |
|
138 | 137 | |
139 | 138 | if($hasScribble) |
140 | - addScribble($background,$width*2,$height*2); |
|
139 | + addScribble($background, $width * 2, $height * 2); |
|
141 | 140 | |
142 | 141 | if($morph) |
143 | - morphImage($background,$width*2,$height*2); |
|
142 | + morphImage($background, $width * 2, $height * 2); |
|
144 | 143 | |
145 | - imagecopy($image,$background,0,0,30,30,$width,$height); |
|
144 | + imagecopy($image, $background, 0, 0, 30, 30, $width, $height); |
|
146 | 145 | |
147 | 146 | if(!$opaque) |
148 | - imagecolortransparent($image,$white); |
|
147 | + imagecolortransparent($image, $white); |
|
149 | 148 | } |
150 | 149 | |
151 | -function addNoise($image,$width,$height) |
|
150 | +function addNoise($image, $width, $height) |
|
152 | 151 | { |
153 | - for($x=0;$x<$width;++$x) |
|
152 | + for($x=0; $x < $width; ++$x) |
|
154 | 153 | { |
155 | - for($y=0;$y<$height;++$y) |
|
154 | + for($y=0; $y < $height; ++$y) |
|
156 | 155 | { |
157 | - if(rand(0,100)<25) |
|
156 | + if(rand(0, 100) < 25) |
|
158 | 157 | { |
159 | - $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); |
|
160 | - imagesetpixel($image,$x,$y,$color); |
|
161 | - imagecolordeallocate($image,$color); |
|
158 | + $color=imagecolorallocate($image, rand(150, 220), rand(150, 220), rand(150, 220)); |
|
159 | + imagesetpixel($image, $x, $y, $color); |
|
160 | + imagecolordeallocate($image, $color); |
|
162 | 161 | } |
163 | 162 | } |
164 | 163 | } |
165 | 164 | } |
166 | 165 | |
167 | -function addGrid($image,$width,$height) |
|
166 | +function addGrid($image, $width, $height) |
|
168 | 167 | { |
169 | - for($i=0;$i<$width;$i+=rand(15,25)) |
|
168 | + for($i=0; $i < $width; $i+=rand(15, 25)) |
|
170 | 169 | { |
171 | - imagesetthickness($image,rand(2,6)); |
|
172 | - $color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180)); |
|
173 | - imageline($image,$i+rand(-10,20),0,$i+rand(-10,20),$height,$color); |
|
174 | - imagecolordeallocate($image,$color); |
|
170 | + imagesetthickness($image, rand(2, 6)); |
|
171 | + $color=imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
|
172 | + imageline($image, $i + rand(-10, 20), 0, $i + rand(-10, 20), $height, $color); |
|
173 | + imagecolordeallocate($image, $color); |
|
175 | 174 | } |
176 | - for($i=0;$i<$height;$i+=rand(15,25)) |
|
175 | + for($i=0; $i < $height; $i+=rand(15, 25)) |
|
177 | 176 | { |
178 | - imagesetthickness($image,rand(2,6)); |
|
179 | - $color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180)); |
|
180 | - imageline($image,0,$i+rand(-10,20),$width,$i+rand(-10,20),$color); |
|
181 | - imagecolordeallocate($image,$color); |
|
177 | + imagesetthickness($image, rand(2, 6)); |
|
178 | + $color=imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
|
179 | + imageline($image, 0, $i + rand(-10, 20), $width, $i + rand(-10, 20), $color); |
|
180 | + imagecolordeallocate($image, $color); |
|
182 | 181 | } |
183 | 182 | } |
184 | 183 | |
185 | -function addScribble($image,$width,$height) |
|
184 | +function addScribble($image, $width, $height) |
|
186 | 185 | { |
187 | - for($i=0;$i<8;$i++) |
|
186 | + for($i=0; $i < 8; $i++) |
|
188 | 187 | { |
189 | - $color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180)); |
|
188 | + $color=imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
|
190 | 189 | $points=array(); |
191 | - for($j=1;$j<rand(5,10);$j++) |
|
190 | + for($j=1; $j < rand(5, 10); $j++) |
|
192 | 191 | { |
193 | - $points[]=rand(2*(20*($i+1)),2*(50*($i+1))); |
|
194 | - $points[]=rand(30,$height+30); |
|
192 | + $points[]=rand(2 * (20 * ($i + 1)), 2 * (50 * ($i + 1))); |
|
193 | + $points[]=rand(30, $height + 30); |
|
195 | 194 | } |
196 | - imagesetthickness($image,rand(2,6)); |
|
197 | - imagepolygon($image,$points,intval(sizeof($points)/2),$color); |
|
198 | - imagecolordeallocate($image,$color); |
|
195 | + imagesetthickness($image, rand(2, 6)); |
|
196 | + imagepolygon($image, $points, intval(sizeof($points) / 2), $color); |
|
197 | + imagecolordeallocate($image, $color); |
|
199 | 198 | } |
200 | 199 | } |
201 | 200 | |
202 | -function morphImage($image,$width,$height) |
|
201 | +function morphImage($image, $width, $height) |
|
203 | 202 | { |
204 | - $tempImage=imagecreatetruecolor($width,$height); |
|
205 | - $chunk=rand(1,5); |
|
206 | - for($x=$y=0;$x<$width;$x+=$chunk) |
|
203 | + $tempImage=imagecreatetruecolor($width, $height); |
|
204 | + $chunk=rand(1, 5); |
|
205 | + for($x=$y=0; $x < $width; $x+=$chunk) |
|
207 | 206 | { |
208 | - $chunk=rand(1,5); |
|
209 | - $y+=rand(-1,1); |
|
210 | - if($y>=$height) $y=$height-5; |
|
211 | - if($y<0) $y=5; |
|
212 | - imagecopy($tempImage,$image,$x,0,$x,$y,$chunk,$height); |
|
207 | + $chunk=rand(1, 5); |
|
208 | + $y+=rand(-1, 1); |
|
209 | + if($y >= $height) $y=$height - 5; |
|
210 | + if($y < 0) $y=5; |
|
211 | + imagecopy($tempImage, $image, $x, 0, $x, $y, $chunk, $height); |
|
213 | 212 | } |
214 | - for($x=$y=0;$y<$height;$y+=$chunk) |
|
213 | + for($x=$y=0; $y < $height; $y+=$chunk) |
|
215 | 214 | { |
216 | - $chunk=rand(1,5); |
|
217 | - $x+=rand(-1,1); |
|
218 | - if($x>=$width) $x=$width-5; |
|
219 | - if($x<0) $x=5; |
|
220 | - imagecopy($image,$tempImage,$x,$y,0,$y,$width,$chunk); |
|
215 | + $chunk=rand(1, 5); |
|
216 | + $x+=rand(-1, 1); |
|
217 | + if($x >= $width) $x=$width - 5; |
|
218 | + if($x < 0) $x=5; |
|
219 | + imagecopy($image, $tempImage, $x, $y, 0, $y, $width, $chunk); |
|
221 | 220 | } |
222 | 221 | } |
223 | 222 |
@@ -166,6 +166,7 @@ |
||
166 | 166 | * Otherwise, an exception will be raised. |
167 | 167 | * @param mixed data item |
168 | 168 | * @param mixed field name |
169 | + * @param string $field |
|
169 | 170 | * @return mixed data value at the specified field |
170 | 171 | * @throws TInvalidDataValueException if the data is invalid |
171 | 172 | */ |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function getDataKeyField() |
136 | 136 | { |
137 | - return $this->getViewState('DataKeyField',''); |
|
137 | + return $this->getViewState('DataKeyField', ''); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function setDataKeyField($value) |
144 | 144 | { |
145 | - $this->setViewState('DataKeyField',$value,''); |
|
145 | + $this->setViewState('DataKeyField', $value, ''); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function getDataKeys() |
152 | 152 | { |
153 | - if(($dataKeys=$this->getViewState('DataKeys',null))===null) |
|
153 | + if(($dataKeys=$this->getViewState('DataKeys', null))===null) |
|
154 | 154 | { |
155 | 155 | $dataKeys=new TList; |
156 | - $this->setViewState('DataKeys',$dataKeys,null); |
|
156 | + $this->setViewState('DataKeys', $dataKeys, null); |
|
157 | 157 | } |
158 | 158 | return $dataKeys; |
159 | 159 | } |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | * @return mixed data value at the specified field |
170 | 170 | * @throws TInvalidDataValueException if the data is invalid |
171 | 171 | */ |
172 | - protected function getDataFieldValue($data,$field) |
|
172 | + protected function getDataFieldValue($data, $field) |
|
173 | 173 | { |
174 | - return TDataFieldAccessor::getDataFieldValue($data,$field); |
|
174 | + return TDataFieldAccessor::getDataFieldValue($data, $field); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function onSelectedIndexChanged($param) |
184 | 184 | { |
185 | - $this->raiseEvent('OnSelectedIndexChanged',$this,$param); |
|
185 | + $this->raiseEvent('OnSelectedIndexChanged', $this, $param); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 |
@@ -182,6 +182,7 @@ discard block |
||
182 | 182 | * TBaseValidator::$_clientClass, be sure to update the corresponding |
183 | 183 | * "Javascript/validation3.js" file as well. |
184 | 184 | * @param TControl control to validate. |
185 | + * @param TControl $control |
|
185 | 186 | * @return string control type for client-side validation. |
186 | 187 | */ |
187 | 188 | private function getClientControlClass($control) |
@@ -259,7 +260,7 @@ discard block |
||
259 | 260 | /** |
260 | 261 | * Update the ControlToValidate component's css class depending |
261 | 262 | * if the ControlCssClass property is set, and whether this is valid. |
262 | - * @return boolean true if change, false otherwise. |
|
263 | + * @return boolean|null true if change, false otherwise. |
|
263 | 264 | */ |
264 | 265 | protected function updateControlCssClass() |
265 | 266 | { |
@@ -384,6 +385,7 @@ discard block |
||
384 | 385 | * The ID path is the dot-connected IDs of the controls reaching from |
385 | 386 | * the validator's naming container to the target control. |
386 | 387 | * @param string the ID path |
388 | + * @param string $value |
|
387 | 389 | */ |
388 | 390 | public function setControlToValidate($value) |
389 | 391 | { |
@@ -549,6 +551,7 @@ discard block |
||
549 | 551 | |
550 | 552 | /** |
551 | 553 | * @param string the css class that is applied to the control being validated in case the validation fails |
554 | + * @param string $value |
|
552 | 555 | */ |
553 | 556 | public function setControlCssClass($value) |
554 | 557 | { |
@@ -691,7 +694,7 @@ discard block |
||
691 | 694 | } |
692 | 695 | |
693 | 696 | /** |
694 | - * @return boolean true to observe changes. |
|
697 | + * @return boolean|string true to observe changes. |
|
695 | 698 | */ |
696 | 699 | public function getObserveChanges() |
697 | 700 | { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * them specially. |
92 | 92 | * @var array list of control class names |
93 | 93 | */ |
94 | - private static $_clientClass = array('THtmlArea', 'THtmlArea4', 'TDatePicker', 'TListBox', 'TCheckBoxList'); |
|
94 | + private static $_clientClass=array('THtmlArea', 'THtmlArea4', 'TDatePicker', 'TListBox', 'TCheckBoxList'); |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Constructor. |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | $display=$this->getDisplay(); |
137 | 137 | $visible=$this->getEnabled(true) && !$this->getIsValid(); |
138 | 138 | if($display===TValidatorDisplayStyle::None || (!$visible && $display===TValidatorDisplayStyle::Dynamic)) |
139 | - $writer->addStyleAttribute('display','none'); |
|
139 | + $writer->addStyleAttribute('display', 'none'); |
|
140 | 140 | else if(!$visible) |
141 | - $writer->addStyleAttribute('visibility','hidden'); |
|
142 | - $writer->addAttribute('id',$this->getClientID()); |
|
141 | + $writer->addStyleAttribute('visibility', 'hidden'); |
|
142 | + $writer->addAttribute('id', $this->getClientID()); |
|
143 | 143 | parent::addAttributesToRender($writer); |
144 | 144 | $this->renderClientControlScript($writer); |
145 | 145 | } |
@@ -150,29 +150,29 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function getClientScriptOptions() |
152 | 152 | { |
153 | - $control = $this->getValidationTarget(); |
|
154 | - $options['ID'] = $this->getClientID(); |
|
155 | - $options['FormID'] = $this->getPage()->getForm()->getClientID(); |
|
156 | - $options['Display'] = $this->getDisplay(); |
|
157 | - $options['ErrorMessage'] = $this->getErrorMessage(); |
|
153 | + $control=$this->getValidationTarget(); |
|
154 | + $options['ID']=$this->getClientID(); |
|
155 | + $options['FormID']=$this->getPage()->getForm()->getClientID(); |
|
156 | + $options['Display']=$this->getDisplay(); |
|
157 | + $options['ErrorMessage']=$this->getErrorMessage(); |
|
158 | 158 | if($this->getFocusOnError()) |
159 | 159 | { |
160 | - $options['FocusOnError'] = $this->getFocusOnError(); |
|
161 | - $options['FocusElementID'] = $this->getFocusElementID(); |
|
160 | + $options['FocusOnError']=$this->getFocusOnError(); |
|
161 | + $options['FocusElementID']=$this->getFocusElementID(); |
|
162 | 162 | } |
163 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
163 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
164 | 164 | if($control) |
165 | - $options['ControlToValidate'] = $control->getClientID(); |
|
166 | - $options['ControlCssClass'] = $this->getControlCssClass(); |
|
165 | + $options['ControlToValidate']=$control->getClientID(); |
|
166 | + $options['ControlCssClass']=$this->getControlCssClass(); |
|
167 | 167 | |
168 | - $options['ControlType'] = $this->getClientControlClass($control); |
|
169 | - $options['Enabled'] = $this->getEnabled(true); |
|
168 | + $options['ControlType']=$this->getClientControlClass($control); |
|
169 | + $options['Enabled']=$this->getEnabled(true); |
|
170 | 170 | |
171 | 171 | //get date format from date picker target control |
172 | 172 | if($control instanceof TDatePicker) |
173 | - $options['DateFormat'] = $control->getDateFormat(); |
|
173 | + $options['DateFormat']=$control->getDateFormat(); |
|
174 | 174 | |
175 | - $options = array_merge($options,$this->getClientSide()->getOptions()->toArray()); |
|
175 | + $options=array_merge($options, $this->getClientSide()->getOptions()->toArray()); |
|
176 | 176 | |
177 | 177 | return $options; |
178 | 178 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | public function getClientSide() |
212 | 212 | { |
213 | 213 | if($this->_clientSide===null) |
214 | - $this->_clientSide = $this->createClientSide(); |
|
214 | + $this->_clientSide=$this->createClientSide(); |
|
215 | 215 | return $this->_clientSide; |
216 | 216 | } |
217 | 217 | |
@@ -231,15 +231,15 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function renderClientControlScript($writer) |
233 | 233 | { |
234 | - $scripts = $this->getPage()->getClientScript(); |
|
235 | - if ($this->getEnableClientScript()) |
|
234 | + $scripts=$this->getPage()->getClientScript(); |
|
235 | + if($this->getEnableClientScript()) |
|
236 | 236 | $scripts->registerPradoScript('validator'); |
237 | 237 | $formID=$this->getPage()->getForm()->getClientID(); |
238 | - $scriptKey = "TBaseValidator:$formID"; |
|
238 | + $scriptKey="TBaseValidator:$formID"; |
|
239 | 239 | if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) |
240 | 240 | { |
241 | - $manager['FormID'] = $formID; |
|
242 | - $options = TJavaScript::encode($manager); |
|
241 | + $manager['FormID']=$formID; |
|
242 | + $options=TJavaScript::encode($manager); |
|
243 | 243 | $scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); |
244 | 244 | } |
245 | 245 | if($this->getEnableClientScript()) |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * Override parent implementation to update the control CSS Class before |
251 | 251 | * the validated control is rendered |
252 | 252 | */ |
253 | - public function onPreRender ($param) |
|
253 | + public function onPreRender($param) |
|
254 | 254 | { |
255 | 255 | parent::onPreRender($param); |
256 | 256 | $this->updateControlCssClass(); |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | $control=$this->getValidationTarget(); |
269 | 269 | if($control instanceof TWebControl) |
270 | 270 | { |
271 | - $class = preg_replace ('/ '.preg_quote($cssClass).'/', '',$control->getCssClass()); |
|
271 | + $class=preg_replace('/ '.preg_quote($cssClass).'/', '', $control->getCssClass()); |
|
272 | 272 | if(!$this->getIsValid()) |
273 | 273 | { |
274 | - $class .= ' '.$cssClass; |
|
274 | + $class.=' '.$cssClass; |
|
275 | 275 | $control->setCssClass($class); |
276 | - } elseif ($control->getIsValid()) |
|
276 | + } elseif($control->getIsValid()) |
|
277 | 277 | $control->setCssClass($class); |
278 | 278 | } |
279 | 279 | } |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | */ |
285 | 285 | protected function registerClientScriptValidator() |
286 | 286 | { |
287 | - $key = 'prado:'.$this->getClientID(); |
|
287 | + $key='prado:'.$this->getClientID(); |
|
288 | 288 | if(!$this->getPage()->getClientScript()->isEndScriptRegistered($key)) |
289 | 289 | { |
290 | - $options = TJavaScript::encode($this->getClientScriptOptions()); |
|
291 | - $script = 'new '.$this->getClientClassName().'('.$options.');'; |
|
290 | + $options=TJavaScript::encode($this->getClientScriptOptions()); |
|
291 | + $script='new '.$this->getClientClassName().'('.$options.');'; |
|
292 | 292 | $this->getPage()->getClientScript()->registerEndScript($key, $script); |
293 | 293 | } |
294 | 294 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function setForControl($value) |
309 | 309 | { |
310 | - throw new TNotSupportedException('basevalidator_forcontrol_unsupported',get_class($this)); |
|
310 | + throw new TNotSupportedException('basevalidator_forcontrol_unsupported', get_class($this)); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | */ |
328 | 328 | public function getDisplay() |
329 | 329 | { |
330 | - return $this->getViewState('Display',TValidatorDisplayStyle::Fixed); |
|
330 | + return $this->getViewState('Display', TValidatorDisplayStyle::Fixed); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function setDisplay($value) |
337 | 337 | { |
338 | - $this->setViewState('Display',TPropertyValue::ensureEnum($value,'TValidatorDisplayStyle'),TValidatorDisplayStyle::Fixed); |
|
338 | + $this->setViewState('Display', TPropertyValue::ensureEnum($value, 'TValidatorDisplayStyle'), TValidatorDisplayStyle::Fixed); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function getEnableClientScript() |
345 | 345 | { |
346 | - return $this->getViewState('EnableClientScript',true); |
|
346 | + return $this->getViewState('EnableClientScript', true); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public function setEnableClientScript($value) |
353 | 353 | { |
354 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
354 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | */ |
360 | 360 | public function getErrorMessage() |
361 | 361 | { |
362 | - return $this->getViewState('ErrorMessage',''); |
|
362 | + return $this->getViewState('ErrorMessage', ''); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function setErrorMessage($value) |
370 | 370 | { |
371 | - $this->setViewState('ErrorMessage',$value,''); |
|
371 | + $this->setViewState('ErrorMessage', $value, ''); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function getControlToValidate() |
378 | 378 | { |
379 | - return $this->getViewState('ControlToValidate',''); |
|
379 | + return $this->getViewState('ControlToValidate', ''); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function setControlToValidate($value) |
389 | 389 | { |
390 | - $this->setViewState('ControlToValidate',$value,''); |
|
390 | + $this->setViewState('ControlToValidate', $value, ''); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function getFocusOnError() |
397 | 397 | { |
398 | - return $this->getViewState('FocusOnError',false); |
|
398 | + return $this->getViewState('FocusOnError', false); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | */ |
404 | 404 | public function setFocusOnError($value) |
405 | 405 | { |
406 | - $this->setViewState('FocusOnError',TPropertyValue::ensureBoolean($value),false); |
|
406 | + $this->setViewState('FocusOnError', TPropertyValue::ensureBoolean($value), false); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -413,13 +413,13 @@ discard block |
||
413 | 413 | */ |
414 | 414 | public function getFocusElementID() |
415 | 415 | { |
416 | - if(($id=$this->getViewState('FocusElementID',''))==='') |
|
416 | + if(($id=$this->getViewState('FocusElementID', ''))==='') |
|
417 | 417 | { |
418 | 418 | $target=$this->getValidationTarget(); |
419 | 419 | /* Workaround: TCheckBoxList and TRadioButtonList nests the actual |
420 | 420 | * inputs inside a table; we ensure the first input gets focused |
421 | 421 | */ |
422 | - if($target instanceof TCheckBoxList && $target->getItemCount()>0) |
|
422 | + if($target instanceof TCheckBoxList && $target->getItemCount() > 0) |
|
423 | 423 | { |
424 | 424 | $id=$target->getClientID().'_c0'; |
425 | 425 | } else { |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | */ |
444 | 444 | public function getValidationGroup() |
445 | 445 | { |
446 | - return $this->getViewState('ValidationGroup',''); |
|
446 | + return $this->getViewState('ValidationGroup', ''); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | */ |
452 | 452 | public function setValidationGroup($value) |
453 | 453 | { |
454 | - $this->setViewState('ValidationGroup',$value,''); |
|
454 | + $this->setViewState('ValidationGroup', $value, ''); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null) |
482 | 482 | return $control; |
483 | 483 | else |
484 | - throw new TConfigurationException('basevalidator_controltovalidate_invalid',get_class($this)); |
|
484 | + throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this)); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | if($control instanceof IValidatable) |
496 | 496 | return $control->getValidationPropertyValue(); |
497 | 497 | else |
498 | - throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this)); |
|
498 | + throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this)); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public function getControlCssClass() |
546 | 546 | { |
547 | - return $this->getViewState('ControlCssClass',''); |
|
547 | + return $this->getViewState('ControlCssClass', ''); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | */ |
553 | 553 | public function setControlCssClass($value) |
554 | 554 | { |
555 | - $this->setViewState('ControlCssClass',$value,''); |
|
555 | + $this->setViewState('ControlCssClass', $value, ''); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | */ |
568 | 568 | public function onValidationSuccess() |
569 | 569 | { |
570 | - $this->raiseEvent('OnValidationSuccess',$this,null); |
|
570 | + $this->raiseEvent('OnValidationSuccess', $this, null); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | */ |
576 | 576 | public function onValidationError() |
577 | 577 | { |
578 | - $this->raiseEvent('OnValidationError',$this,null); |
|
578 | + $this->raiseEvent('OnValidationError', $this, null); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | */ |
587 | 587 | public function onValidate() |
588 | 588 | { |
589 | - $this->raiseEvent('OnValidate',$this,null); |
|
589 | + $this->raiseEvent('OnValidate', $this, null); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | */ |
696 | 696 | public function getObserveChanges() |
697 | 697 | { |
698 | - $changes = $this->getOption('ObserveChanges'); |
|
698 | + $changes=$this->getOption('ObserveChanges'); |
|
699 | 699 | return ($changes===null) ? true : $changes; |
700 | 700 | } |
701 | 701 | } |
@@ -518,16 +518,14 @@ |
||
518 | 518 | { |
519 | 519 | $this->setIsValid(true); |
520 | 520 | $this->onValidationSuccess(); |
521 | - } |
|
522 | - else |
|
521 | + } else |
|
523 | 522 | { |
524 | 523 | if($target) |
525 | 524 | $target->setIsValid(false); |
526 | 525 | $this->setIsValid(false); |
527 | 526 | $this->onValidationError(); |
528 | 527 | } |
529 | - } |
|
530 | - else |
|
528 | + } else |
|
531 | 529 | { |
532 | 530 | $this->evaluateIsValid(); |
533 | 531 | $this->setIsValid(true); |
@@ -216,6 +216,7 @@ discard block |
||
216 | 216 | * This method is invoked when the {@link getDisplayMode DisplayMode} is 'LinkButton' |
217 | 217 | * and end-users click on one of the buttons. |
218 | 218 | * @param TBulletedListEventParameter event parameter. |
219 | + * @param TBulletedListEventParameter $param |
|
219 | 220 | */ |
220 | 221 | public function onClick($param) |
221 | 222 | { |
@@ -425,6 +426,7 @@ discard block |
||
425 | 426 | /** |
426 | 427 | * Constructor. |
427 | 428 | * @param integer index of the item clicked |
429 | + * @param integer $index |
|
428 | 430 | */ |
429 | 431 | public function __construct($index) |
430 | 432 | { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | if($this->getCausesValidation()) |
63 | 63 | $this->getPage()->validate($this->getValidationGroup()); |
64 | - $this->onClick(new TBulletedListEventParameter((int)$param)); |
|
64 | + $this->onClick(new TBulletedListEventParameter((int) $param)); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -102,45 +102,45 @@ discard block |
||
102 | 102 | switch($this->getBulletStyle()) |
103 | 103 | { |
104 | 104 | case TBulletStyle::None: |
105 | - $writer->addStyleAttribute('list-style-type','none'); |
|
105 | + $writer->addStyleAttribute('list-style-type', 'none'); |
|
106 | 106 | $needStart=true; |
107 | 107 | break; |
108 | 108 | case TBulletStyle::Numbered: |
109 | - $writer->addStyleAttribute('list-style-type','decimal'); |
|
109 | + $writer->addStyleAttribute('list-style-type', 'decimal'); |
|
110 | 110 | $needStart=true; |
111 | 111 | break; |
112 | 112 | case TBulletStyle::LowerAlpha: |
113 | - $writer->addStyleAttribute('list-style-type','lower-alpha'); |
|
113 | + $writer->addStyleAttribute('list-style-type', 'lower-alpha'); |
|
114 | 114 | $needStart=true; |
115 | 115 | break; |
116 | 116 | case TBulletStyle::UpperAlpha: |
117 | - $writer->addStyleAttribute('list-style-type','upper-alpha'); |
|
117 | + $writer->addStyleAttribute('list-style-type', 'upper-alpha'); |
|
118 | 118 | $needStart=true; |
119 | 119 | break; |
120 | 120 | case TBulletStyle::LowerRoman: |
121 | - $writer->addStyleAttribute('list-style-type','lower-roman'); |
|
121 | + $writer->addStyleAttribute('list-style-type', 'lower-roman'); |
|
122 | 122 | $needStart=true; |
123 | 123 | break; |
124 | 124 | case TBulletStyle::UpperRoman: |
125 | - $writer->addStyleAttribute('list-style-type','upper-roman'); |
|
125 | + $writer->addStyleAttribute('list-style-type', 'upper-roman'); |
|
126 | 126 | $needStart=true; |
127 | 127 | break; |
128 | 128 | case TBulletStyle::Disc: |
129 | - $writer->addStyleAttribute('list-style-type','disc'); |
|
129 | + $writer->addStyleAttribute('list-style-type', 'disc'); |
|
130 | 130 | break; |
131 | 131 | case TBulletStyle::Circle: |
132 | - $writer->addStyleAttribute('list-style-type','circle'); |
|
132 | + $writer->addStyleAttribute('list-style-type', 'circle'); |
|
133 | 133 | break; |
134 | 134 | case TBulletStyle::Square: |
135 | - $writer->addStyleAttribute('list-style-type','square'); |
|
135 | + $writer->addStyleAttribute('list-style-type', 'square'); |
|
136 | 136 | break; |
137 | 137 | case TBulletStyle::CustomImage: |
138 | 138 | $url=$this->getBulletImageUrl(); |
139 | - $writer->addStyleAttribute('list-style-image',"url($url)"); |
|
139 | + $writer->addStyleAttribute('list-style-image', "url($url)"); |
|
140 | 140 | break; |
141 | 141 | } |
142 | 142 | if($needStart && ($start=$this->getFirstBulletNumber())!=1) |
143 | - $writer->addAttribute('start',"$start"); |
|
143 | + $writer->addAttribute('start', "$start"); |
|
144 | 144 | parent::addAttributesToRender($writer); |
145 | 145 | } |
146 | 146 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function getBulletImageUrl() |
151 | 151 | { |
152 | - return $this->getViewState('BulletImageUrl',''); |
|
152 | + return $this->getViewState('BulletImageUrl', ''); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function setBulletImageUrl($value) |
159 | 159 | { |
160 | - $this->setViewState('BulletImageUrl',$value,''); |
|
160 | + $this->setViewState('BulletImageUrl', $value, ''); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function getBulletStyle() |
167 | 167 | { |
168 | - return $this->getViewState('BulletStyle',TBulletStyle::NotSet); |
|
168 | + return $this->getViewState('BulletStyle', TBulletStyle::NotSet); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function setBulletStyle($value) |
175 | 175 | { |
176 | - $this->setViewState('BulletStyle',TPropertyValue::ensureEnum($value,'TBulletStyle'),TBulletStyle::NotSet); |
|
176 | + $this->setViewState('BulletStyle', TPropertyValue::ensureEnum($value, 'TBulletStyle'), TBulletStyle::NotSet); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function getDisplayMode() |
183 | 183 | { |
184 | - return $this->getViewState('DisplayMode',TBulletedListDisplayMode::Text); |
|
184 | + return $this->getViewState('DisplayMode', TBulletedListDisplayMode::Text); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function setDisplayMode($value) |
191 | 191 | { |
192 | - $this->setViewState('DisplayMode',TPropertyValue::ensureEnum($value,'TBulletedListDisplayMode'),TBulletedListDisplayMode::Text); |
|
192 | + $this->setViewState('DisplayMode', TPropertyValue::ensureEnum($value, 'TBulletedListDisplayMode'), TBulletedListDisplayMode::Text); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function getFirstBulletNumber() |
201 | 201 | { |
202 | - return $this->getViewState('FirstBulletNumber',1); |
|
202 | + return $this->getViewState('FirstBulletNumber', 1); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | public function setFirstBulletNumber($value) |
210 | 210 | { |
211 | - $this->setViewState('FirstBulletNumber',TPropertyValue::ensureInteger($value),1); |
|
211 | + $this->setViewState('FirstBulletNumber', TPropertyValue::ensureInteger($value), 1); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function onClick($param) |
221 | 221 | { |
222 | - $this->raiseEvent('OnClick',$this,$param); |
|
222 | + $this->raiseEvent('OnClick', $this, $param); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function getTarget() |
231 | 231 | { |
232 | - return $this->getViewState('Target',''); |
|
232 | + return $this->getViewState('Target', ''); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function setTarget($value) |
241 | 241 | { |
242 | - $this->setViewState('Target',$value,''); |
|
242 | + $this->setViewState('Target', $value, ''); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | if($item->getHasAttributes()) |
267 | 267 | $writer->addAttributes($item->getAttributes()); |
268 | 268 | $writer->renderBeginTag('li'); |
269 | - $this->renderBulletText($writer,$item,$index); |
|
269 | + $this->renderBulletText($writer, $item, $index); |
|
270 | 270 | $writer->renderEndTag(); |
271 | 271 | $writer->writeLine(); |
272 | 272 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param TListItem item to be rendered |
279 | 279 | * @param integer index of the item being rendered |
280 | 280 | */ |
281 | - protected function renderBulletText($writer,$item,$index) |
|
281 | + protected function renderBulletText($writer, $item, $index) |
|
282 | 282 | { |
283 | 283 | switch($this->getDisplayMode()) |
284 | 284 | { |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $writer->write(THttpUtility::htmlEncode($item->getText())); |
301 | 301 | else |
302 | 302 | { |
303 | - $writer->addAttribute('disabled','disabled'); |
|
303 | + $writer->addAttribute('disabled', 'disabled'); |
|
304 | 304 | $writer->renderBeginTag('span'); |
305 | 305 | $writer->write(THttpUtility::htmlEncode($item->getText())); |
306 | 306 | $writer->renderEndTag(); |
@@ -310,15 +310,15 @@ discard block |
||
310 | 310 | protected function renderHyperLinkItem($writer, $item, $index) |
311 | 311 | { |
312 | 312 | if(!$this->_isEnabled || !$item->getEnabled()) |
313 | - $writer->addAttribute('disabled','disabled'); |
|
313 | + $writer->addAttribute('disabled', 'disabled'); |
|
314 | 314 | else |
315 | 315 | { |
316 | - $writer->addAttribute('href',$item->getValue()); |
|
316 | + $writer->addAttribute('href', $item->getValue()); |
|
317 | 317 | if(($target=$this->getTarget())!=='') |
318 | - $writer->addAttribute('target',$target); |
|
318 | + $writer->addAttribute('target', $target); |
|
319 | 319 | } |
320 | 320 | if(($accesskey=$this->getAccessKey())!=='') |
321 | - $writer->addAttribute('accesskey',$accesskey); |
|
321 | + $writer->addAttribute('accesskey', $accesskey); |
|
322 | 322 | $writer->renderBeginTag('a'); |
323 | 323 | $writer->write(THttpUtility::htmlEncode($item->getText())); |
324 | 324 | $writer->renderEndTag(); |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | protected function renderLinkButtonItem($writer, $item, $index) |
328 | 328 | { |
329 | 329 | if(!$this->_isEnabled || !$item->getEnabled()) |
330 | - $writer->addAttribute('disabled','disabled'); |
|
330 | + $writer->addAttribute('disabled', 'disabled'); |
|
331 | 331 | else |
332 | 332 | { |
333 | - $this->_currentRenderItemIndex = $index; |
|
333 | + $this->_currentRenderItemIndex=$index; |
|
334 | 334 | $writer->addAttribute('id', $this->getClientID().$index); |
335 | 335 | $writer->addAttribute('href', "javascript:;//".$this->getClientID().$index); |
336 | - $cs = $this->getPage()->getClientScript(); |
|
337 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
336 | + $cs=$this->getPage()->getClientScript(); |
|
337 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
338 | 338 | } |
339 | 339 | if(($accesskey=$this->getAccessKey())!=='') |
340 | - $writer->addAttribute('accesskey',$accesskey); |
|
340 | + $writer->addAttribute('accesskey', $accesskey); |
|
341 | 341 | $writer->renderBeginTag('a'); |
342 | 342 | $writer->write(THttpUtility::htmlEncode($item->getText())); |
343 | 343 | $writer->renderEndTag(); |
@@ -348,19 +348,19 @@ discard block |
||
348 | 348 | */ |
349 | 349 | protected function getPostBackOptions() |
350 | 350 | { |
351 | - $options['ValidationGroup'] = $this->getValidationGroup(); |
|
352 | - $options['CausesValidation'] = $this->getCausesValidation(); |
|
353 | - $options['EventTarget'] = $this->getUniqueID(); |
|
354 | - $options['EventParameter'] = $this->_currentRenderItemIndex; |
|
355 | - $options['ID'] = $this->getClientID().$this->_currentRenderItemIndex; |
|
356 | - $options['StopEvent'] = true; |
|
351 | + $options['ValidationGroup']=$this->getValidationGroup(); |
|
352 | + $options['CausesValidation']=$this->getCausesValidation(); |
|
353 | + $options['EventTarget']=$this->getUniqueID(); |
|
354 | + $options['EventParameter']=$this->_currentRenderItemIndex; |
|
355 | + $options['ID']=$this->getClientID().$this->_currentRenderItemIndex; |
|
356 | + $options['StopEvent']=true; |
|
357 | 357 | return $options; |
358 | 358 | } |
359 | 359 | |
360 | 360 | protected function canCauseValidation() |
361 | 361 | { |
362 | - $group = $this->getValidationGroup(); |
|
363 | - $hasValidators = $this->getPage()->getValidators($group)->getCount()>0; |
|
362 | + $group=$this->getValidationGroup(); |
|
363 | + $hasValidators=$this->getPage()->getValidators($group)->getCount() > 0; |
|
364 | 364 | return $this->getCausesValidation() && $hasValidators; |
365 | 365 | } |
366 | 366 |