@@ -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) |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * directory containing Prado javascript files |
| 27 | 27 | */ |
| 28 | - const SCRIPT_PATH='Web/Javascripts/source'; |
|
| 28 | + const SCRIPT_PATH = 'Web/Javascripts/source'; |
|
| 29 | 29 | /** |
| 30 | 30 | * file containing javascript packages and their cross dependencies |
| 31 | 31 | */ |
| 32 | - const PACKAGES_FILE='Web/Javascripts/packages.php'; |
|
| 32 | + const PACKAGES_FILE = 'Web/Javascripts/packages.php'; |
|
| 33 | 33 | /** |
| 34 | 34 | * @var TPage page who owns this manager |
| 35 | 35 | */ |
@@ -37,39 +37,39 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @var array registered hidden fields, indexed by hidden field names |
| 39 | 39 | */ |
| 40 | - private $_hiddenFields=array(); |
|
| 40 | + private $_hiddenFields = array(); |
|
| 41 | 41 | /** |
| 42 | 42 | * @var array javascript blocks to be rendered at the beginning of the form |
| 43 | 43 | */ |
| 44 | - private $_beginScripts=array(); |
|
| 44 | + private $_beginScripts = array(); |
|
| 45 | 45 | /** |
| 46 | 46 | * @var array javascript blocks to be rendered at the end of the form |
| 47 | 47 | */ |
| 48 | - private $_endScripts=array(); |
|
| 48 | + private $_endScripts = array(); |
|
| 49 | 49 | /** |
| 50 | 50 | * @var array javascript files to be rendered in the form |
| 51 | 51 | */ |
| 52 | - private $_scriptFiles=array(); |
|
| 52 | + private $_scriptFiles = array(); |
|
| 53 | 53 | /** |
| 54 | 54 | * @var array javascript files to be rendered in page head section |
| 55 | 55 | */ |
| 56 | - private $_headScriptFiles=array(); |
|
| 56 | + private $_headScriptFiles = array(); |
|
| 57 | 57 | /** |
| 58 | 58 | * @var array javascript blocks to be rendered in page head section |
| 59 | 59 | */ |
| 60 | - private $_headScripts=array(); |
|
| 60 | + private $_headScripts = array(); |
|
| 61 | 61 | /** |
| 62 | 62 | * @var array CSS files |
| 63 | 63 | */ |
| 64 | - private $_styleSheetFiles=array(); |
|
| 64 | + private $_styleSheetFiles = array(); |
|
| 65 | 65 | /** |
| 66 | 66 | * @var array CSS declarations |
| 67 | 67 | */ |
| 68 | - private $_styleSheets=array(); |
|
| 68 | + private $_styleSheets = array(); |
|
| 69 | 69 | /** |
| 70 | 70 | * @var array registered PRADO script libraries |
| 71 | 71 | */ |
| 72 | - private $_registeredPradoScripts=array(); |
|
| 72 | + private $_registeredPradoScripts = array(); |
|
| 73 | 73 | /** |
| 74 | 74 | * Client-side javascript library dependencies, loads from PACKAGES_FILE; |
| 75 | 75 | * @var array |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | private $_renderedHiddenFields; |
| 85 | 85 | |
| 86 | - private $_renderedScriptFiles=array(); |
|
| 86 | + private $_renderedScriptFiles = array(); |
|
| 87 | 87 | |
| 88 | 88 | private $_expandedPradoScripts; |
| 89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function __construct(TPage $owner) |
| 95 | 95 | { |
| 96 | - $this->_page=$owner; |
|
| 96 | + $this->_page = $owner; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | public function registerPradoScript($name) |
| 125 | 125 | { |
| 126 | 126 | $this->registerPradoScriptInternal($name); |
| 127 | - $params=func_get_args(); |
|
| 128 | - $this->_page->registerCachingAction('Page.ClientScript','registerPradoScript',$params); |
|
| 127 | + $params = func_get_args(); |
|
| 128 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPradoScript', $params); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -134,27 +134,27 @@ discard block |
||
| 134 | 134 | protected function registerPradoScriptInternal($name) |
| 135 | 135 | { |
| 136 | 136 | // $this->checkIfNotInRender(); |
| 137 | - if(!isset($this->_registeredPradoScripts[$name])) |
|
| 137 | + if (!isset($this->_registeredPradoScripts[$name])) |
|
| 138 | 138 | { |
| 139 | - if(self::$_pradoScripts === null) |
|
| 139 | + if (self::$_pradoScripts === null) |
|
| 140 | 140 | { |
| 141 | - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; |
|
| 142 | - list($packages,$deps)= include($packageFile); |
|
| 141 | + $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::PACKAGES_FILE; |
|
| 142 | + list($packages, $deps) = include($packageFile); |
|
| 143 | 143 | self::$_pradoScripts = $deps; |
| 144 | 144 | self::$_pradoPackages = $packages; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | if (isset(self::$_pradoScripts[$name])) |
| 148 | - $this->_registeredPradoScripts[$name]=true; |
|
| 148 | + $this->_registeredPradoScripts[$name] = true; |
|
| 149 | 149 | else |
| 150 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
| 150 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); |
|
| 151 | 151 | |
| 152 | - if(($packages=array_keys($this->_registeredPradoScripts))!==array()) |
|
| 152 | + if (($packages = array_keys($this->_registeredPradoScripts)) !== array()) |
|
| 153 | 153 | { |
| 154 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
| 155 | - list($path,$baseUrl)=$this->getPackagePathUrl($base); |
|
| 156 | - $packagesUrl=array(); |
|
| 157 | - $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; |
|
| 154 | + $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH; |
|
| 155 | + list($path, $baseUrl) = $this->getPackagePathUrl($base); |
|
| 156 | + $packagesUrl = array(); |
|
| 157 | + $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
|
| 158 | 158 | foreach ($packages as $p) |
| 159 | 159 | { |
| 160 | 160 | foreach (self::$_pradoScripts[$p] as $dep) |
@@ -163,29 +163,29 @@ discard block |
||
| 163 | 163 | if (!isset($this->_expandedPradoScripts[$script])) |
| 164 | 164 | { |
| 165 | 165 | $this->_expandedPradoScripts[$script] = true; |
| 166 | - if($isDebug) |
|
| 166 | + if ($isDebug) |
|
| 167 | 167 | { |
| 168 | - if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
|
| 169 | - $packagesUrl[]=$url; |
|
| 168 | + if (!in_array($url = $baseUrl . '/' . $script, $packagesUrl)) |
|
| 169 | + $packagesUrl[] = $url; |
|
| 170 | 170 | } else { |
| 171 | - if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl)) |
|
| 171 | + if (!in_array($url = $baseUrl . '/min/' . $script, $packagesUrl)) |
|
| 172 | 172 | { |
| 173 | - if(!is_file($filePath=$path.'/min/'.$script)) |
|
| 173 | + if (!is_file($filePath = $path . '/min/' . $script)) |
|
| 174 | 174 | { |
| 175 | - $dirPath=dirname($filePath); |
|
| 176 | - if(!is_dir($dirPath)) |
|
| 175 | + $dirPath = dirname($filePath); |
|
| 176 | + if (!is_dir($dirPath)) |
|
| 177 | 177 | mkdir($dirPath, PRADO_CHMOD, true); |
| 178 | - file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$script))); |
|
| 178 | + file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base . '/' . $script))); |
|
| 179 | 179 | chmod($filePath, PRADO_CHMOD); |
| 180 | 180 | } |
| 181 | - $packagesUrl[]=$url; |
|
| 181 | + $packagesUrl[] = $url; |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | - foreach($packagesUrl as $url) |
|
| 188 | - $this->registerScriptFile($url,$url); |
|
| 187 | + foreach ($packagesUrl as $url) |
|
| 188 | + $this->registerScriptFile($url, $url); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function getPradoScriptAssetUrl() |
| 197 | 197 | { |
| 198 | - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; |
|
| 198 | + $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH; |
|
| 199 | 199 | $assets = Prado::getApplication()->getAssetManager(); |
| 200 | 200 | return $assets->getPublishedUrl($base); |
| 201 | 201 | } |
@@ -220,16 +220,16 @@ discard block |
||
| 220 | 220 | protected function getPackagePathUrl($base) |
| 221 | 221 | { |
| 222 | 222 | $assets = Prado::getApplication()->getAssetManager(); |
| 223 | - if(strpos($base, $assets->getBaseUrl())===false) |
|
| 223 | + if (strpos($base, $assets->getBaseUrl()) === false) |
|
| 224 | 224 | { |
| 225 | - if(($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
| 225 | + if (($dir = Prado::getPathOfNameSpace($base)) !== null) { |
|
| 226 | 226 | $base = $dir; |
| 227 | 227 | } |
| 228 | 228 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
| 229 | 229 | } |
| 230 | 230 | else |
| 231 | 231 | { |
| 232 | - return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
|
| 232 | + return array($assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param array additional callback options |
| 240 | 240 | * @return string javascript statement that creates a new callback request. |
| 241 | 241 | */ |
| 242 | - public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null) |
|
| 242 | + public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options = null) |
|
| 243 | 243 | { |
| 244 | 244 | $options = !is_array($options) ? array() : $options; |
| 245 | 245 | $class = new ReflectionClass($callbackHandler); |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function registerCallbackControl($class, $options) |
| 260 | 260 | { |
| 261 | - $optionString=TJavaScript::encode($options); |
|
| 262 | - $code="new {$class}({$optionString});"; |
|
| 263 | - $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
|
| 261 | + $optionString = TJavaScript::encode($options); |
|
| 262 | + $code = "new {$class}({$optionString});"; |
|
| 263 | + $this->_endScripts[sprintf('%08X', crc32($code))] = $code; |
|
| 264 | 264 | $this->registerPradoScriptInternal('ajax'); |
| 265 | 265 | |
| 266 | - $params=func_get_args(); |
|
| 267 | - $this->_page->registerCachingAction('Page.ClientScript','registerCallbackControl',$params); |
|
| 266 | + $params = func_get_args(); |
|
| 267 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerCallbackControl', $params); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -273,21 +273,21 @@ discard block |
||
| 273 | 273 | * @param string javascript class responsible for the control being registered for postback |
| 274 | 274 | * @param array postback options |
| 275 | 275 | */ |
| 276 | - public function registerPostBackControl($class,$options) |
|
| 276 | + public function registerPostBackControl($class, $options) |
|
| 277 | 277 | { |
| 278 | - if($class === null) { |
|
| 278 | + if ($class === null) { |
|
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | - if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
|
| 282 | - $options['FormID']=$form->getClientID(); |
|
| 283 | - $optionString=TJavaScript::encode($options); |
|
| 284 | - $code="new {$class}({$optionString});"; |
|
| 281 | + if (!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null) |
|
| 282 | + $options['FormID'] = $form->getClientID(); |
|
| 283 | + $optionString = TJavaScript::encode($options); |
|
| 284 | + $code = "new {$class}({$optionString});"; |
|
| 285 | 285 | |
| 286 | - $this->_endScripts[sprintf('%08X', crc32($code))]=$code; |
|
| 286 | + $this->_endScripts[sprintf('%08X', crc32($code))] = $code; |
|
| 287 | 287 | $this->registerPradoScriptInternal('prado'); |
| 288 | 288 | |
| 289 | - $params=func_get_args(); |
|
| 290 | - $this->_page->registerCachingAction('Page.ClientScript','registerPostBackControl',$params); |
|
| 289 | + $params = func_get_args(); |
|
| 290 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerPostBackControl', $params); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -298,23 +298,23 @@ discard block |
||
| 298 | 298 | */ |
| 299 | 299 | public function registerDefaultButton($panel, $button) |
| 300 | 300 | { |
| 301 | - $panelID=is_string($panel)?$panel:$panel->getUniqueID(); |
|
| 301 | + $panelID = is_string($panel) ? $panel : $panel->getUniqueID(); |
|
| 302 | 302 | |
| 303 | - if(is_string($button)) |
|
| 304 | - $buttonID=$button; |
|
| 303 | + if (is_string($button)) |
|
| 304 | + $buttonID = $button; |
|
| 305 | 305 | else |
| 306 | 306 | { |
| 307 | 307 | $button->setIsDefaultButton(true); |
| 308 | - $buttonID=$button->getUniqueID(); |
|
| 308 | + $buttonID = $button->getUniqueID(); |
|
| 309 | 309 | } |
| 310 | 310 | $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); |
| 311 | 311 | $code = "new Prado.WebUI.DefaultButton($options);"; |
| 312 | 312 | |
| 313 | - $this->_endScripts['prado:'.$panelID]=$code; |
|
| 313 | + $this->_endScripts['prado:' . $panelID] = $code; |
|
| 314 | 314 | $this->registerPradoScriptInternal('prado'); |
| 315 | 315 | |
| 316 | - $params=array($panelID,$buttonID); |
|
| 317 | - $this->_page->registerCachingAction('Page.ClientScript','registerDefaultButton',$params); |
|
| 316 | + $params = array($panelID, $buttonID); |
|
| 317 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -339,12 +339,12 @@ discard block |
||
| 339 | 339 | public function registerFocusControl($target) |
| 340 | 340 | { |
| 341 | 341 | $this->registerPradoScriptInternal('jquery'); |
| 342 | - if($target instanceof TControl) |
|
| 343 | - $target=$target->getClientID(); |
|
| 344 | - $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
|
| 342 | + if ($target instanceof TControl) |
|
| 343 | + $target = $target->getClientID(); |
|
| 344 | + $this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();'; |
|
| 345 | 345 | |
| 346 | - $params=func_get_args(); |
|
| 347 | - $this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params); |
|
| 346 | + $params = func_get_args(); |
|
| 347 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -369,15 +369,15 @@ discard block |
||
| 369 | 369 | * @param string URL to the CSS file |
| 370 | 370 | * @param string media type of the CSS (such as 'print', 'screen', etc.). Defaults to empty, meaning the CSS applies to all media types. |
| 371 | 371 | */ |
| 372 | - public function registerStyleSheetFile($key,$url,$media='') |
|
| 372 | + public function registerStyleSheetFile($key, $url, $media = '') |
|
| 373 | 373 | { |
| 374 | - if($media==='') |
|
| 375 | - $this->_styleSheetFiles[$key]=$url; |
|
| 374 | + if ($media === '') |
|
| 375 | + $this->_styleSheetFiles[$key] = $url; |
|
| 376 | 376 | else |
| 377 | - $this->_styleSheetFiles[$key]=array($url,$media); |
|
| 377 | + $this->_styleSheetFiles[$key] = array($url, $media); |
|
| 378 | 378 | |
| 379 | - $params=func_get_args(); |
|
| 380 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); |
|
| 379 | + $params = func_get_args(); |
|
| 380 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -385,12 +385,12 @@ discard block |
||
| 385 | 385 | * @param string a unique key identifying the CSS block |
| 386 | 386 | * @param string CSS block |
| 387 | 387 | */ |
| 388 | - public function registerStyleSheet($key,$css,$media='') |
|
| 388 | + public function registerStyleSheet($key, $css, $media = '') |
|
| 389 | 389 | { |
| 390 | - $this->_styleSheets[$key]=$css; |
|
| 390 | + $this->_styleSheets[$key] = $css; |
|
| 391 | 391 | |
| 392 | - $params=func_get_args(); |
|
| 393 | - $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheet',$params); |
|
| 392 | + $params = func_get_args(); |
|
| 393 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheet', $params); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | /** |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | $this->_styleSheetFiles) |
| 406 | 406 | ); |
| 407 | 407 | |
| 408 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
| 409 | - if (substr($url,strlen($url)-4)=='.css') |
|
| 408 | + foreach (Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
| 409 | + if (substr($url, strlen($url) - 4) == '.css') |
|
| 410 | 410 | $stylesheets[] = $url; |
| 411 | 411 | |
| 412 | 412 | $stylesheets = array_unique($stylesheets); |
@@ -428,13 +428,13 @@ discard block |
||
| 428 | 428 | * @param string a unique key identifying the file |
| 429 | 429 | * @param string URL to the javascript file |
| 430 | 430 | */ |
| 431 | - public function registerHeadScriptFile($key,$url) |
|
| 431 | + public function registerHeadScriptFile($key, $url) |
|
| 432 | 432 | { |
| 433 | 433 | $this->checkIfNotInRender(); |
| 434 | - $this->_headScriptFiles[$key]=$url; |
|
| 434 | + $this->_headScriptFiles[$key] = $url; |
|
| 435 | 435 | |
| 436 | - $params=func_get_args(); |
|
| 437 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScriptFile',$params); |
|
| 436 | + $params = func_get_args(); |
|
| 437 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScriptFile', $params); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | /** |
@@ -442,13 +442,13 @@ discard block |
||
| 442 | 442 | * @param string a unique key identifying the script block |
| 443 | 443 | * @param string javascript block |
| 444 | 444 | */ |
| 445 | - public function registerHeadScript($key,$script) |
|
| 445 | + public function registerHeadScript($key, $script) |
|
| 446 | 446 | { |
| 447 | 447 | $this->checkIfNotInRender(); |
| 448 | - $this->_headScripts[$key]=$script; |
|
| 448 | + $this->_headScripts[$key] = $script; |
|
| 449 | 449 | |
| 450 | - $params=func_get_args(); |
|
| 451 | - $this->_page->registerCachingAction('Page.ClientScript','registerHeadScript',$params); |
|
| 450 | + $params = func_get_args(); |
|
| 451 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScript', $params); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | public function registerScriptFile($key, $url) |
| 460 | 460 | { |
| 461 | - $this->_scriptFiles[$key]=$url; |
|
| 461 | + $this->_scriptFiles[$key] = $url; |
|
| 462 | 462 | |
| 463 | - $params=func_get_args(); |
|
| 464 | - $this->_page->registerCachingAction('Page.ClientScript','registerScriptFile',$params); |
|
| 463 | + $params = func_get_args(); |
|
| 464 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerScriptFile', $params); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | /** |
@@ -469,13 +469,13 @@ discard block |
||
| 469 | 469 | * @param string a unique key identifying the script block |
| 470 | 470 | * @param string javascript block |
| 471 | 471 | */ |
| 472 | - public function registerBeginScript($key,$script) |
|
| 472 | + public function registerBeginScript($key, $script) |
|
| 473 | 473 | { |
| 474 | 474 | $this->checkIfNotInRender(); |
| 475 | - $this->_beginScripts[$key]=$script; |
|
| 475 | + $this->_beginScripts[$key] = $script; |
|
| 476 | 476 | |
| 477 | - $params=func_get_args(); |
|
| 478 | - $this->_page->registerCachingAction('Page.ClientScript','registerBeginScript',$params); |
|
| 477 | + $params = func_get_args(); |
|
| 478 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerBeginScript', $params); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -483,12 +483,12 @@ discard block |
||
| 483 | 483 | * @param string a unique key identifying the script block |
| 484 | 484 | * @param string javascript block |
| 485 | 485 | */ |
| 486 | - public function registerEndScript($key,$script) |
|
| 486 | + public function registerEndScript($key, $script) |
|
| 487 | 487 | { |
| 488 | - $this->_endScripts[$key]=$script; |
|
| 488 | + $this->_endScripts[$key] = $script; |
|
| 489 | 489 | |
| 490 | - $params=func_get_args(); |
|
| 491 | - $this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params); |
|
| 490 | + $params = func_get_args(); |
|
| 491 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerEndScript', $params); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -497,12 +497,12 @@ discard block |
||
| 497 | 497 | * @param string|array hidden field value, if the value is an array, every element |
| 498 | 498 | * in the array will be rendered as a hidden field value. |
| 499 | 499 | */ |
| 500 | - public function registerHiddenField($name,$value) |
|
| 500 | + public function registerHiddenField($name, $value) |
|
| 501 | 501 | { |
| 502 | - $this->_hiddenFields[$name]=$value; |
|
| 502 | + $this->_hiddenFields[$name] = $value; |
|
| 503 | 503 | |
| 504 | - $params=func_get_args(); |
|
| 505 | - $this->_page->registerCachingAction('Page.ClientScript','registerHiddenField',$params); |
|
| 504 | + $params = func_get_args(); |
|
| 505 | + $this->_page->registerCachingAction('Page.ClientScript', 'registerHiddenField', $params); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -598,13 +598,13 @@ discard block |
||
| 598 | 598 | */ |
| 599 | 599 | public function renderStyleSheetFiles($writer) |
| 600 | 600 | { |
| 601 | - $str=''; |
|
| 602 | - foreach($this->_styleSheetFiles as $url) |
|
| 601 | + $str = ''; |
|
| 602 | + foreach ($this->_styleSheetFiles as $url) |
|
| 603 | 603 | { |
| 604 | - if(is_array($url)) |
|
| 605 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
| 604 | + if (is_array($url)) |
|
| 605 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n"; |
|
| 606 | 606 | else |
| 607 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
| 607 | + $str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n"; |
|
| 608 | 608 | } |
| 609 | 609 | $writer->write($str); |
| 610 | 610 | } |
@@ -614,8 +614,8 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | public function renderStyleSheets($writer) |
| 616 | 616 | { |
| 617 | - if(count($this->_styleSheets)) |
|
| 618 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
| 617 | + if (count($this->_styleSheets)) |
|
| 618 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n"); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | public function renderHeadScriptFiles($writer) |
| 625 | 625 | { |
| 626 | - $this->renderScriptFiles($writer,$this->_headScriptFiles); |
|
| 626 | + $this->renderScriptFiles($writer, $this->_headScriptFiles); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | /** |
@@ -647,13 +647,13 @@ discard block |
||
| 647 | 647 | public function markScriptFileAsRendered($url) |
| 648 | 648 | { |
| 649 | 649 | $this->_renderedScriptFiles[$url] = $url; |
| 650 | - $params=func_get_args(); |
|
| 651 | - $this->_page->registerCachingAction('Page.ClientScript','markScriptFileAsRendered',$params); |
|
| 650 | + $params = func_get_args(); |
|
| 651 | + $this->_page->registerCachingAction('Page.ClientScript', 'markScriptFileAsRendered', $params); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | protected function renderScriptFiles($writer, Array $scripts) |
| 655 | 655 | { |
| 656 | - foreach($scripts as $script) |
|
| 656 | + foreach ($scripts as $script) |
|
| 657 | 657 | { |
| 658 | 658 | $writer->write(TJavaScript::renderScriptFile($script)); |
| 659 | 659 | $this->markScriptFileAsRendered($script); |
@@ -670,10 +670,10 @@ discard block |
||
| 670 | 670 | */ |
| 671 | 671 | public function renderAllPendingScriptFiles($writer) |
| 672 | 672 | { |
| 673 | - if(!empty($this->_scriptFiles)) |
|
| 673 | + if (!empty($this->_scriptFiles)) |
|
| 674 | 674 | { |
| 675 | - $addedScripts = array_diff($this->_scriptFiles,$this->getRenderedScriptFiles()); |
|
| 676 | - $this->renderScriptFiles($writer,$addedScripts); |
|
| 675 | + $addedScripts = array_diff($this->_scriptFiles, $this->getRenderedScriptFiles()); |
|
| 676 | + $this->renderScriptFiles($writer, $addedScripts); |
|
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | |
@@ -711,12 +711,12 @@ discard block |
||
| 711 | 711 | |
| 712 | 712 | public function renderHiddenFieldsBegin($writer) |
| 713 | 713 | { |
| 714 | - $this->renderHiddenFieldsInt($writer,true); |
|
| 714 | + $this->renderHiddenFieldsInt($writer, true); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | public function renderHiddenFieldsEnd($writer) |
| 718 | 718 | { |
| 719 | - $this->renderHiddenFieldsInt($writer,false); |
|
| 719 | + $this->renderHiddenFieldsInt($writer, false); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -724,9 +724,9 @@ discard block |
||
| 724 | 724 | * @param THtmlWriter writer for the rendering purpose |
| 725 | 725 | * @param TControl the control forcing the flush (used only in error messages) |
| 726 | 726 | */ |
| 727 | - public function flushScriptFiles($writer, $control=null) |
|
| 727 | + public function flushScriptFiles($writer, $control = null) |
|
| 728 | 728 | { |
| 729 | - if(!$this->_page->getIsCallback()) |
|
| 729 | + if (!$this->_page->getIsCallback()) |
|
| 730 | 730 | { |
| 731 | 731 | $this->_page->ensureRenderInForm($control); |
| 732 | 732 | $this->renderAllPendingScriptFiles($writer); |
@@ -739,24 +739,24 @@ discard block |
||
| 739 | 739 | protected function renderHiddenFieldsInt($writer, $initial) |
| 740 | 740 | { |
| 741 | 741 | if ($initial) $this->_renderedHiddenFields = array(); |
| 742 | - $str=''; |
|
| 743 | - foreach($this->_hiddenFields as $name=>$value) |
|
| 742 | + $str = ''; |
|
| 743 | + foreach ($this->_hiddenFields as $name=>$value) |
|
| 744 | 744 | { |
| 745 | - if (in_array($name,$this->_renderedHiddenFields)) continue; |
|
| 746 | - $id=strtr($name,':','_'); |
|
| 747 | - if(is_array($value)) |
|
| 745 | + if (in_array($name, $this->_renderedHiddenFields)) continue; |
|
| 746 | + $id = strtr($name, ':', '_'); |
|
| 747 | + if (is_array($value)) |
|
| 748 | 748 | { |
| 749 | - foreach($value as $v) |
|
| 750 | - $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 749 | + foreach ($value as $v) |
|
| 750 | + $str .= '<input type="hidden" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
| 751 | 751 | } |
| 752 | 752 | else |
| 753 | 753 | { |
| 754 | - $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 754 | + $str .= '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n"; |
|
| 755 | 755 | } |
| 756 | 756 | $this->_renderedHiddenFields[] = $name; |
| 757 | 757 | } |
| 758 | - if($str!=='') |
|
| 759 | - $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
| 758 | + if ($str !== '') |
|
| 759 | + $writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n"); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | public function getHiddenFields() |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | */ |
| 803 | 803 | protected function setFunction($name, $code) |
| 804 | 804 | { |
| 805 | - if(!TJavaScript::isJsLiteral($code)) |
|
| 805 | + if (!TJavaScript::isJsLiteral($code)) |
|
| 806 | 806 | $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
| 807 | 807 | $this->setOption($name, $code); |
| 808 | 808 | } |
@@ -144,10 +144,11 @@ discard block |
||
| 144 | 144 | self::$_pradoPackages = $packages; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if (isset(self::$_pradoScripts[$name])) |
|
| 148 | - $this->_registeredPradoScripts[$name]=true; |
|
| 149 | - else |
|
| 150 | - throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
| 147 | + if (isset(self::$_pradoScripts[$name])) { |
|
| 148 | + $this->_registeredPradoScripts[$name]=true; |
|
| 149 | + } else { |
|
| 150 | + throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name); |
|
| 151 | + } |
|
| 151 | 152 | |
| 152 | 153 | if(($packages=array_keys($this->_registeredPradoScripts))!==array()) |
| 153 | 154 | { |
@@ -159,22 +160,25 @@ discard block |
||
| 159 | 160 | { |
| 160 | 161 | foreach (self::$_pradoScripts[$p] as $dep) |
| 161 | 162 | { |
| 162 | - foreach (self::$_pradoPackages[$dep] as $script) |
|
| 163 | - if (!isset($this->_expandedPradoScripts[$script])) |
|
| 163 | + foreach (self::$_pradoPackages[$dep] as $script) { |
|
| 164 | + if (!isset($this->_expandedPradoScripts[$script])) |
|
| 164 | 165 | { |
| 165 | 166 | $this->_expandedPradoScripts[$script] = true; |
| 167 | + } |
|
| 166 | 168 | if($isDebug) |
| 167 | 169 | { |
| 168 | - if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) |
|
| 169 | - $packagesUrl[]=$url; |
|
| 170 | + if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) { |
|
| 171 | + $packagesUrl[]=$url; |
|
| 172 | + } |
|
| 170 | 173 | } else { |
| 171 | 174 | if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl)) |
| 172 | 175 | { |
| 173 | 176 | if(!is_file($filePath=$path.'/min/'.$script)) |
| 174 | 177 | { |
| 175 | 178 | $dirPath=dirname($filePath); |
| 176 | - if(!is_dir($dirPath)) |
|
| 177 | - mkdir($dirPath, PRADO_CHMOD, true); |
|
| 179 | + if(!is_dir($dirPath)) { |
|
| 180 | + mkdir($dirPath, PRADO_CHMOD, true); |
|
| 181 | + } |
|
| 178 | 182 | file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$script))); |
| 179 | 183 | chmod($filePath, PRADO_CHMOD); |
| 180 | 184 | } |
@@ -184,8 +188,9 @@ discard block |
||
| 184 | 188 | } |
| 185 | 189 | } |
| 186 | 190 | } |
| 187 | - foreach($packagesUrl as $url) |
|
| 188 | - $this->registerScriptFile($url,$url); |
|
| 191 | + foreach($packagesUrl as $url) { |
|
| 192 | + $this->registerScriptFile($url,$url); |
|
| 193 | + } |
|
| 189 | 194 | } |
| 190 | 195 | } |
| 191 | 196 | } |
@@ -226,8 +231,7 @@ discard block |
||
| 226 | 231 | $base = $dir; |
| 227 | 232 | } |
| 228 | 233 | return array($assets->getPublishedPath($base), $assets->publishFilePath($base)); |
| 229 | - } |
|
| 230 | - else |
|
| 234 | + } else |
|
| 231 | 235 | { |
| 232 | 236 | return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base); |
| 233 | 237 | } |
@@ -278,8 +282,9 @@ discard block |
||
| 278 | 282 | if($class === null) { |
| 279 | 283 | return; |
| 280 | 284 | } |
| 281 | - if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) |
|
| 282 | - $options['FormID']=$form->getClientID(); |
|
| 285 | + if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) { |
|
| 286 | + $options['FormID']=$form->getClientID(); |
|
| 287 | + } |
|
| 283 | 288 | $optionString=TJavaScript::encode($options); |
| 284 | 289 | $code="new {$class}({$optionString});"; |
| 285 | 290 | |
@@ -300,9 +305,9 @@ discard block |
||
| 300 | 305 | { |
| 301 | 306 | $panelID=is_string($panel)?$panel:$panel->getUniqueID(); |
| 302 | 307 | |
| 303 | - if(is_string($button)) |
|
| 304 | - $buttonID=$button; |
|
| 305 | - else |
|
| 308 | + if(is_string($button)) { |
|
| 309 | + $buttonID=$button; |
|
| 310 | + } else |
|
| 306 | 311 | { |
| 307 | 312 | $button->setIsDefaultButton(true); |
| 308 | 313 | $buttonID=$button->getUniqueID(); |
@@ -339,8 +344,9 @@ discard block |
||
| 339 | 344 | public function registerFocusControl($target) |
| 340 | 345 | { |
| 341 | 346 | $this->registerPradoScriptInternal('jquery'); |
| 342 | - if($target instanceof TControl) |
|
| 343 | - $target=$target->getClientID(); |
|
| 347 | + if($target instanceof TControl) { |
|
| 348 | + $target=$target->getClientID(); |
|
| 349 | + } |
|
| 344 | 350 | $this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();'; |
| 345 | 351 | |
| 346 | 352 | $params=func_get_args(); |
@@ -371,10 +377,11 @@ discard block |
||
| 371 | 377 | */ |
| 372 | 378 | public function registerStyleSheetFile($key,$url,$media='') |
| 373 | 379 | { |
| 374 | - if($media==='') |
|
| 375 | - $this->_styleSheetFiles[$key]=$url; |
|
| 376 | - else |
|
| 377 | - $this->_styleSheetFiles[$key]=array($url,$media); |
|
| 380 | + if($media==='') { |
|
| 381 | + $this->_styleSheetFiles[$key]=$url; |
|
| 382 | + } else { |
|
| 383 | + $this->_styleSheetFiles[$key]=array($url,$media); |
|
| 384 | + } |
|
| 378 | 385 | |
| 379 | 386 | $params=func_get_args(); |
| 380 | 387 | $this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params); |
@@ -405,9 +412,10 @@ discard block |
||
| 405 | 412 | $this->_styleSheetFiles) |
| 406 | 413 | ); |
| 407 | 414 | |
| 408 | - foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) |
|
| 409 | - if (substr($url,strlen($url)-4)=='.css') |
|
| 415 | + foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) { |
|
| 416 | + if (substr($url,strlen($url)-4)=='.css') |
|
| 410 | 417 | $stylesheets[] = $url; |
| 418 | + } |
|
| 411 | 419 | |
| 412 | 420 | $stylesheets = array_unique($stylesheets); |
| 413 | 421 | |
@@ -601,10 +609,11 @@ discard block |
||
| 601 | 609 | $str=''; |
| 602 | 610 | foreach($this->_styleSheetFiles as $url) |
| 603 | 611 | { |
| 604 | - if(is_array($url)) |
|
| 605 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
| 606 | - else |
|
| 607 | - $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
| 612 | + if(is_array($url)) { |
|
| 613 | + $str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n"; |
|
| 614 | + } else { |
|
| 615 | + $str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n"; |
|
| 616 | + } |
|
| 608 | 617 | } |
| 609 | 618 | $writer->write($str); |
| 610 | 619 | } |
@@ -614,8 +623,9 @@ discard block |
||
| 614 | 623 | */ |
| 615 | 624 | public function renderStyleSheets($writer) |
| 616 | 625 | { |
| 617 | - if(count($this->_styleSheets)) |
|
| 618 | - $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
| 626 | + if(count($this->_styleSheets)) { |
|
| 627 | + $writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n"); |
|
| 628 | + } |
|
| 619 | 629 | } |
| 620 | 630 | |
| 621 | 631 | /** |
@@ -738,25 +748,30 @@ discard block |
||
| 738 | 748 | */ |
| 739 | 749 | protected function renderHiddenFieldsInt($writer, $initial) |
| 740 | 750 | { |
| 741 | - if ($initial) $this->_renderedHiddenFields = array(); |
|
| 751 | + if ($initial) { |
|
| 752 | + $this->_renderedHiddenFields = array(); |
|
| 753 | + } |
|
| 742 | 754 | $str=''; |
| 743 | 755 | foreach($this->_hiddenFields as $name=>$value) |
| 744 | 756 | { |
| 745 | - if (in_array($name,$this->_renderedHiddenFields)) continue; |
|
| 757 | + if (in_array($name,$this->_renderedHiddenFields)) { |
|
| 758 | + continue; |
|
| 759 | + } |
|
| 746 | 760 | $id=strtr($name,':','_'); |
| 747 | 761 | if(is_array($value)) |
| 748 | 762 | { |
| 749 | - foreach($value as $v) |
|
| 750 | - $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 751 | - } |
|
| 752 | - else |
|
| 763 | + foreach($value as $v) { |
|
| 764 | + $str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
|
| 765 | + } |
|
| 766 | + } else |
|
| 753 | 767 | { |
| 754 | 768 | $str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n"; |
| 755 | 769 | } |
| 756 | 770 | $this->_renderedHiddenFields[] = $name; |
| 757 | 771 | } |
| 758 | - if($str!=='') |
|
| 759 | - $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
| 772 | + if($str!=='') { |
|
| 773 | + $writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n"); |
|
| 774 | + } |
|
| 760 | 775 | } |
| 761 | 776 | |
| 762 | 777 | public function getHiddenFields() |
@@ -769,8 +784,9 @@ discard block |
||
| 769 | 784 | */ |
| 770 | 785 | protected function checkIfNotInRender() |
| 771 | 786 | { |
| 772 | - if ($form = $this->_page->InFormRender) |
|
| 773 | - throw new Exception('Operation invalid when page is already rendering'); |
|
| 787 | + if ($form = $this->_page->InFormRender) { |
|
| 788 | + throw new Exception('Operation invalid when page is already rendering'); |
|
| 789 | + } |
|
| 774 | 790 | } |
| 775 | 791 | } |
| 776 | 792 | |
@@ -802,8 +818,9 @@ discard block |
||
| 802 | 818 | */ |
| 803 | 819 | protected function setFunction($name, $code) |
| 804 | 820 | { |
| 805 | - if(!TJavaScript::isJsLiteral($code)) |
|
| 806 | - $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
| 821 | + if(!TJavaScript::isJsLiteral($code)) { |
|
| 822 | + $code = TJavaScript::quoteJsLiteral($this->ensureFunction($code)); |
|
| 823 | + } |
|
| 807 | 824 | $this->setOption($name, $code); |
| 808 | 825 | } |
| 809 | 826 | |
@@ -812,10 +829,11 @@ discard block |
||
| 812 | 829 | */ |
| 813 | 830 | protected function getOption($name) |
| 814 | 831 | { |
| 815 | - if ($this->_options) |
|
| 816 | - return $this->_options->itemAt($name); |
|
| 817 | - else |
|
| 818 | - return null; |
|
| 832 | + if ($this->_options) { |
|
| 833 | + return $this->_options->itemAt($name); |
|
| 834 | + } else { |
|
| 835 | + return null; |
|
| 836 | + } |
|
| 819 | 837 | } |
| 820 | 838 | |
| 821 | 839 | /** |
@@ -832,8 +850,9 @@ discard block |
||
| 832 | 850 | */ |
| 833 | 851 | public function getOptions() |
| 834 | 852 | { |
| 835 | - if (!$this->_options) |
|
| 836 | - $this->_options = Prado::createComponent('System.Collections.TMap'); |
|
| 853 | + if (!$this->_options) { |
|
| 854 | + $this->_options = Prado::createComponent('System.Collections.TMap'); |
|
| 855 | + } |
|
| 837 | 856 | return $this->_options; |
| 838 | 857 | } |
| 839 | 858 | |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | Prado::using('System.Data.ActiveRecord.TActiveRecord'); |
| 3 | -require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); |
|
| 4 | -require_once(dirname(__FILE__).'/records/DepSections.php'); |
|
| 3 | +require_once(dirname(__FILE__) . '/records/DepartmentRecord.php'); |
|
| 4 | +require_once(dirname(__FILE__) . '/records/DepSections.php'); |
|
| 5 | 5 | |
| 6 | 6 | class ActiveRecordDynamicCallTestCase extends UnitTestCase |
| 7 | 7 | { |
| 8 | 8 | function setup() |
| 9 | 9 | { |
| 10 | - $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); |
|
| 10 | + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test', 'test'); |
|
| 11 | 11 | TActiveRecordManager::getInstance()->setDbConnection($conn); |
| 12 | 12 | } |
| 13 | 13 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | function test_dynamic_multiple_field_call() |
| 29 | 29 | { |
| 30 | 30 | $finder = DepartmentRecord::finder(); |
| 31 | - $rs = $finder->findByNameAndActive('Marketing',true); |
|
| 31 | + $rs = $finder->findByNameAndActive('Marketing', true); |
|
| 32 | 32 | $this->assertNotNull($rs); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $rs = $finder->findByNameAndActive('Marketing'); |
| 41 | 41 | $this->fail(); |
| 42 | 42 | } |
| 43 | - catch(TDbException $e) |
|
| 43 | + catch (TDbException $e) |
|
| 44 | 44 | { |
| 45 | 45 | $this->pass(); |
| 46 | 46 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | function test_dynamic_call_extras_parameters_ok() |
| 50 | 50 | { |
| 51 | 51 | $finder = DepartmentRecord::finder(); |
| 52 | - $rs = $finder->findByNameAndActive('Marketing',true,true); |
|
| 52 | + $rs = $finder->findByNameAndActive('Marketing', true, true); |
|
| 53 | 53 | $this->assertNotNull($rs); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -114,8 +114,7 @@ |
||
| 114 | 114 | { |
| 115 | 115 | $this->projectDao->addUserToProject($project->ID, 'asd'); |
| 116 | 116 | $this->fail(); |
| 117 | - } |
|
| 118 | - catch(TDbException $e) |
|
| 117 | + } catch(TDbException $e) |
|
| 119 | 118 | { |
| 120 | 119 | $this->pass(); |
| 121 | 120 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | Prado::using('System.Data.ActiveRecord.TActiveRecord'); |
| 3 | -require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); |
|
| 4 | -require_once(dirname(__FILE__).'/records/UserRecord.php'); |
|
| 3 | +require_once(dirname(__FILE__) . '/records/DepartmentRecord.php'); |
|
| 4 | +require_once(dirname(__FILE__) . '/records/UserRecord.php'); |
|
| 5 | 5 | |
| 6 | 6 | class UserRecord2 extends UserRecord |
| 7 | 7 | { |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | public $category; |
| 14 | 14 | public $item; |
| 15 | 15 | |
| 16 | - const TABLE='items'; |
|
| 16 | + const TABLE = 'items'; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | class FindBySqlTestCase extends UnitTestCase |
| 20 | 20 | { |
| 21 | 21 | function setup() |
| 22 | 22 | { |
| 23 | - $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); |
|
| 23 | + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test', 'test'); |
|
| 24 | 24 | TActiveRecordManager::getInstance()->setDbConnection($conn); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | $list = array(); |
| 11 | 11 | $count = 0; |
| 12 | 12 | $token = strtolower($token); |
| 13 | - foreach($info->getCountries() as $country) |
|
| 13 | + foreach ($info->getCountries() as $country) |
|
| 14 | 14 | { |
| 15 | - if(strpos(strtolower($country), $token) === 0) |
|
| 15 | + if (strpos(strtolower($country), $token) === 0) |
|
| 16 | 16 | { |
| 17 | 17 | $list[] = $country; |
| 18 | 18 | $count++; |
| 19 | - if($count > 10) break; |
|
| 19 | + if ($count > 10) break; |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | return $list; |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
| 36 | - public function validForm ($sender, $param) |
|
| 36 | + public function validForm($sender, $param) |
|
| 37 | 37 | { |
| 38 | - $this->Result->Text = "TextBox Content : ".$this->textbox->getText()." -- Autocomplete Content :".$this->autocomplete->getText(); |
|
| 38 | + $this->Result->Text = "TextBox Content : " . $this->textbox->getText() . " -- Autocomplete Content :" . $this->autocomplete->getText(); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -29,7 +29,9 @@ |
||
| 29 | 29 | { |
| 30 | 30 | $list[] = $country; |
| 31 | 31 | $count++; |
| 32 | - if($count > 10) break; |
|
| 32 | + if($count > 10) { |
|
| 33 | + break; |
|
| 34 | + } |
|
| 33 | 35 | } |
| 34 | 36 | } |
| 35 | 37 | return $list; |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | { |
| 7 | 7 | $values = $sender->getSelectedValues(); |
| 8 | 8 | var_dump($values); |
| 9 | - $this->label1->setText("Selection: ".implode(', ', $values)); |
|
| 9 | + $this->label1->setText("Selection: " . implode(', ', $values)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | function select_index_4() |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | { |
| 10 | 10 | $sender->setDataSource($this->matchCountries($param->Token)); |
| 11 | 11 | $sender->dataBind(); |
| 12 | - $this->label1->Text = "suggestion for ".$param->Token; |
|
| 12 | + $this->label1->Text = "suggestion for " . $param->Token; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function callback_requested($sender, $param) |
| 16 | 16 | { |
| 17 | - $this->label1->Text = "Label 1: ".$sender->Text; |
|
| 17 | + $this->label1->Text = "Label 1: " . $sender->Text; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | protected function matchCountries($token) |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | $list = array(); |
| 24 | 24 | $count = 0; |
| 25 | 25 | $token = strtolower($token); |
| 26 | - foreach($info->getCountries() as $country) |
|
| 26 | + foreach ($info->getCountries() as $country) |
|
| 27 | 27 | { |
| 28 | - if(strpos(strtolower($country), $token) === 0) |
|
| 28 | + if (strpos(strtolower($country), $token) === 0) |
|
| 29 | 29 | { |
| 30 | 30 | $list[] = $country; |
| 31 | 31 | $count++; |
| 32 | - if($count > 10) break; |
|
| 32 | + if ($count > 10) break; |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | return $list; |
@@ -29,7 +29,9 @@ |
||
| 29 | 29 | { |
| 30 | 30 | $list[] = $country; |
| 31 | 31 | $count++; |
| 32 | - if($count > 10) break; |
|
| 32 | + if($count > 10) { |
|
| 33 | + break; |
|
| 34 | + } |
|
| 33 | 35 | } |
| 34 | 36 | } |
| 35 | 37 | return $list; |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Sample4 extends Sample2 |
| 6 | 6 | { |
| 7 | - protected function sortData($data,$key) |
|
| 7 | + protected function sortData($data, $key) |
|
| 8 | 8 | { |
| 9 | 9 | usort($data, function($a, $b) use ($key) { |
| 10 | 10 | if ($a[$key] == $b[$key]) { |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | return $data; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function sortDataGrid($sender,$param) |
|
| 19 | + public function sortDataGrid($sender, $param) |
|
| 20 | 20 | { |
| 21 | - $this->DataGrid->DataSource=$this->sortData($this->Data,$param->SortExpression); |
|
| 21 | + $this->DataGrid->DataSource = $this->sortData($this->Data, $param->SortExpression); |
|
| 22 | 22 | $this->DataGrid->dataBind(); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Sample4 extends Sample2 |
| 6 | 6 | { |
| 7 | - protected function sortData($data,$key) |
|
| 7 | + protected function sortData($data, $key) |
|
| 8 | 8 | { |
| 9 | 9 | usort($data, function($a, $b) use ($key) { |
| 10 | 10 | if ($a[$key] == $b[$key]) { |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | return $data; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function sortDataGrid($sender,$param) |
|
| 19 | + public function sortDataGrid($sender, $param) |
|
| 20 | 20 | { |
| 21 | - $this->DataGrid->DataSource=$this->sortData($this->Data,$param->SortExpression); |
|
| 21 | + $this->DataGrid->DataSource = $this->sortData($this->Data, $param->SortExpression); |
|
| 22 | 22 | $this->DataGrid->dataBind(); |
| 23 | 23 | } |
| 24 | 24 | } |