@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function getKey() |
| 61 | 61 | { |
| 62 | - if(empty($this->key)) |
|
| 62 | + if (empty($this->key)) |
|
| 63 | 63 | throw new TException('The Key property must be specified.'); |
| 64 | 64 | return $this->key; |
| 65 | 65 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | public function getParameter() |
| 108 | 108 | { |
| 109 | 109 | $value = $this->getValue(); |
| 110 | - if(strlen($value) > 0) |
|
| 110 | + if (strlen($value) > 0) |
|
| 111 | 111 | return $value; |
| 112 | 112 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
| 113 | 113 | $this->renderControl($htmlWriter); |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | */ |
| 80 | 80 | public function raiseCallbackEvent($param) |
| 81 | 81 | { |
| 82 | - if($this->getActiveControl()->canCauseValidation()) |
|
| 82 | + if ($this->getActiveControl()->canCauseValidation()) |
|
| 83 | 83 | $this->getPage()->validate($this->getActiveControl()->getValidationGroup()); |
| 84 | 84 | $this->onCallback($param); |
| 85 | 85 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | public function setDecayRate($value) |
| 81 | 81 | { |
| 82 | 82 | $decay = TPropertyValue::ensureFloat($value); |
| 83 | - if($decay < 0) |
|
| 83 | + if ($decay < 0) |
|
| 84 | 84 | throw new TConfigurationException('callback_decay_be_not_negative', $this->getID()); |
| 85 | 85 | $this->setViewState('Decay', $decay); |
| 86 | 86 | } |
@@ -35,9 +35,9 @@ |
||
| 35 | 35 | public function getPHPType() |
| 36 | 36 | { |
| 37 | 37 | $dbtype = strtolower($this->getDbType()); |
| 38 | - foreach(self::$types as $type => $dbtypes) |
|
| 38 | + foreach (self::$types as $type => $dbtypes) |
|
| 39 | 39 | { |
| 40 | - if(in_array($dbtype, $dbtypes)) |
|
| 40 | + if (in_array($dbtype, $dbtypes)) |
|
| 41 | 41 | return $type; |
| 42 | 42 | } |
| 43 | 43 | return 'string'; |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function setText($value) |
| 52 | 52 | { |
| 53 | - if(parent::getText() === $value) |
|
| 53 | + if (parent::getText() === $value) |
|
| 54 | 54 | return; |
| 55 | 55 | |
| 56 | 56 | parent::setText($value); |
| 57 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 57 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 58 | 58 | $this->getPage()->getCallbackClient()->update($this, $value); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function setImageUrl($value) |
| 66 | 66 | { |
| 67 | - if(parent::getImageUrl() === $value) |
|
| 67 | + if (parent::getImageUrl() === $value) |
|
| 68 | 68 | return; |
| 69 | 69 | |
| 70 | 70 | parent::setImageUrl($value); |
| 71 | - if($this->getActiveControl()->canUpdateClientSide() && $value !== '') |
|
| 71 | + if ($this->getActiveControl()->canUpdateClientSide() && $value !== '') |
|
| 72 | 72 | { |
| 73 | 73 | $textWriter = new TTextWriter; |
| 74 | 74 | $renderer = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $textWriter); |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function setNavigateUrl($value) |
| 85 | 85 | { |
| 86 | - if(parent::getNavigateUrl() === $value) |
|
| 86 | + if (parent::getNavigateUrl() === $value) |
|
| 87 | 87 | return; |
| 88 | 88 | |
| 89 | 89 | parent::setNavigateUrl($value); |
| 90 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 90 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 91 | 91 | { |
| 92 | 92 | //replace & with & and urldecode the url (setting the href using javascript is literal) |
| 93 | 93 | $url = urldecode(str_replace('&', '&', $value)); |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function setTarget($value) |
| 103 | 103 | { |
| 104 | - if(parent::getTarget() === $value) |
|
| 104 | + if (parent::getTarget() === $value) |
|
| 105 | 105 | return; |
| 106 | 106 | |
| 107 | 107 | parent::setTarget($value); |
| 108 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 108 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 109 | 109 | $this->getPage()->getCallbackClient()->setAttribute($this, 'target', $value); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function setAlternateText($value) |
| 50 | 50 | { |
| 51 | - if(parent::getAlternateText() === $value) |
|
| 51 | + if (parent::getAlternateText() === $value) |
|
| 52 | 52 | return; |
| 53 | 53 | |
| 54 | 54 | parent::setAlternateText($value); |
| 55 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 55 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 56 | 56 | $this->getPage()->getCallbackClient()->setAttribute($this, 'alt', $value); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function setImageAlign($value) |
| 67 | 67 | { |
| 68 | - if(parent::getImageAlign() === $value) |
|
| 68 | + if (parent::getImageAlign() === $value) |
|
| 69 | 69 | return; |
| 70 | 70 | |
| 71 | 71 | parent::setImageAlign($value); |
| 72 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 72 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 73 | 73 | $this->getPage()->getCallbackClient()->setAttribute($this, 'align', $value); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function setImageUrl($value) |
| 80 | 80 | { |
| 81 | - if(parent::getImageUrl() === $value) |
|
| 81 | + if (parent::getImageUrl() === $value) |
|
| 82 | 82 | return; |
| 83 | 83 | |
| 84 | 84 | parent::setImageUrl($value); |
| 85 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 85 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 86 | 86 | $this->getPage()->getCallbackClient()->setAttribute($this, 'src', $value); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function setDescriptionUrl($value) |
| 93 | 93 | { |
| 94 | - if(parent::getDescriptionUrl() === $value) |
|
| 94 | + if (parent::getDescriptionUrl() === $value) |
|
| 95 | 95 | return; |
| 96 | 96 | |
| 97 | 97 | parent::setDescriptionUrl($value); |
| 98 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 98 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 99 | 99 | $this->getPage()->getCallbackClient()->setAttribute($this, 'longdesc', $value); |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | public function getPage() |
| 50 | 50 | { |
| 51 | - return $this->_control?$this->_control->getPage():null; |
|
| 51 | + return $this->_control ? $this->_control->getPage() : null; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -28,13 +28,13 @@ |
||
| 28 | 28 | if(!defined('PRADO_DIR')) |
| 29 | 29 | define('PRADO_DIR', __DIR__); |
| 30 | 30 | /** |
| 31 | - * Defines the default permission for writable directories and files |
|
| 32 | - */ |
|
| 31 | + * Defines the default permission for writable directories and files |
|
| 32 | + */ |
|
| 33 | 33 | if(!defined('PRADO_CHMOD')) |
| 34 | 34 | define('PRADO_CHMOD', 0777); |
| 35 | 35 | /** |
| 36 | - * Defines the Composer's vendor/ path. |
|
| 37 | - */ |
|
| 36 | + * Defines the Composer's vendor/ path. |
|
| 37 | + */ |
|
| 38 | 38 | if(!defined('PRADO_VENDORDIR')) |
| 39 | 39 | { |
| 40 | 40 | $reflector = new \ReflectionClass('\Composer\Autoload\ClassLoader'); |
@@ -25,17 +25,17 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * Defines the PRADO framework installation path. |
| 27 | 27 | */ |
| 28 | -if(!defined('PRADO_DIR')) |
|
| 28 | +if (!defined('PRADO_DIR')) |
|
| 29 | 29 | define('PRADO_DIR', __DIR__); |
| 30 | 30 | /** |
| 31 | 31 | * Defines the default permission for writable directories and files |
| 32 | 32 | */ |
| 33 | -if(!defined('PRADO_CHMOD')) |
|
| 33 | +if (!defined('PRADO_CHMOD')) |
|
| 34 | 34 | define('PRADO_CHMOD', 0777); |
| 35 | 35 | /** |
| 36 | 36 | * Defines the Composer's vendor/ path. |
| 37 | 37 | */ |
| 38 | -if(!defined('PRADO_VENDORDIR')) |
|
| 38 | +if (!defined('PRADO_VENDORDIR')) |
|
| 39 | 39 | { |
| 40 | 40 | $reflector = new \ReflectionClass('\Composer\Autoload\ClassLoader'); |
| 41 | 41 | define('PRADO_VENDORDIR', dirname(dirname($reflector->getFileName()))); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public static function initAutoloader() |
| 111 | 111 | { |
| 112 | - self::$classMap = require(__DIR__ . '/classes.php'); |
|
| 112 | + self::$classMap = require(__DIR__.'/classes.php'); |
|
| 113 | 113 | |
| 114 | 114 | spl_autoload_register([get_called_class(), 'autoload']); |
| 115 | 115 | } |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | /** |
| 125 | 125 | * Sets error handler to be Prado::phpErrorHandler |
| 126 | 126 | */ |
| 127 | - set_error_handler(['\Prado\PradoBase','phpErrorHandler']); |
|
| 127 | + set_error_handler(['\Prado\PradoBase', 'phpErrorHandler']); |
|
| 128 | 128 | /** |
| 129 | 129 | * Sets shutdown function to be Prado::phpFatalErrorHandler |
| 130 | 130 | */ |
| 131 | - register_shutdown_function(['PradoBase','phpFatalErrorHandler']); |
|
| 131 | + register_shutdown_function(['PradoBase', 'phpFatalErrorHandler']); |
|
| 132 | 132 | /** |
| 133 | 133 | * Sets exception handler to be Prado::exceptionHandler |
| 134 | 134 | */ |
| 135 | - set_exception_handler(['\Prado\PradoBase','exceptionHandler']); |
|
| 135 | + set_exception_handler(['\Prado\PradoBase', 'exceptionHandler']); |
|
| 136 | 136 | /** |
| 137 | 137 | * Disable php's builtin error reporting to avoid duplicated reports |
| 138 | 138 | */ |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public static function poweredByPrado($logoType = 0) |
| 157 | 157 | { |
| 158 | - $logoName = $logoType == 1?'powered2':'powered'; |
|
| 159 | - if(self::$_application !== null) |
|
| 158 | + $logoName = $logoType == 1 ? 'powered2' : 'powered'; |
|
| 159 | + if (self::$_application !== null) |
|
| 160 | 160 | { |
| 161 | 161 | $am = self::$_application->getAssetManager(); |
| 162 | - $url = $am->publishFilePath(self::getPathOfNamespace('Prado\\' . $logoName, '.gif')); |
|
| 162 | + $url = $am->publishFilePath(self::getPathOfNamespace('Prado\\'.$logoName, '.gif')); |
|
| 163 | 163 | } |
| 164 | 164 | else |
| 165 | - $url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif'; |
|
| 166 | - return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="' . $url . '" style="border-width:0px;" alt="Powered by PRADO" /></a>'; |
|
| 165 | + $url = 'http://pradosoft.github.io/docs/'.$logoName.'.gif'; |
|
| 166 | + return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>'; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public static function phpErrorHandler($errno, $errstr, $errfile, $errline) |
| 180 | 180 | { |
| 181 | - if(error_reporting() & $errno) |
|
| 181 | + if (error_reporting() & $errno) |
|
| 182 | 182 | throw new TPhpErrorException($errno, $errstr, $errfile, $errline); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | public static function phpFatalErrorHandler() |
| 192 | 192 | { |
| 193 | 193 | $error = error_get_last(); |
| 194 | - if($error && |
|
| 194 | + if ($error && |
|
| 195 | 195 | TPhpErrorException::isFatalError($error) && |
| 196 | 196 | error_reporting() & $error['type']) |
| 197 | 197 | { |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public static function exceptionHandler($exception) |
| 212 | 212 | { |
| 213 | - if(self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null) |
|
| 213 | + if (self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null) |
|
| 214 | 214 | { |
| 215 | 215 | $errorHandler->handleError(null, $exception); |
| 216 | 216 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public static function setApplication($application) |
| 234 | 234 | { |
| 235 | - if(self::$_application !== null && !defined('PRADO_TEST_RUN')) |
|
| 235 | + if (self::$_application !== null && !defined('PRADO_TEST_RUN')) |
|
| 236 | 236 | throw new TInvalidOperationException('prado_application_singleton_required'); |
| 237 | 237 | self::$_application = $application; |
| 238 | 238 | } |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | protected static function prado3NamespaceToPhpNamespace($type) |
| 263 | 263 | { |
| 264 | - if(substr($type, 0, 6) === 'System') |
|
| 265 | - $type = 'Prado' . substr($type, 6); |
|
| 264 | + if (substr($type, 0, 6) === 'System') |
|
| 265 | + $type = 'Prado'.substr($type, 6); |
|
| 266 | 266 | |
| 267 | - if(false === strpos($type, '\\')) |
|
| 267 | + if (false === strpos($type, '\\')) |
|
| 268 | 268 | return str_replace('.', '\\', $type); |
| 269 | 269 | else |
| 270 | 270 | return $type; |
@@ -286,10 +286,10 @@ discard block |
||
| 286 | 286 | public static function createComponent($requestedType) |
| 287 | 287 | { |
| 288 | 288 | $type = static::prado3NamespaceToPhpNamespace($requestedType); |
| 289 | - if(!isset(self::$classExists[$type])) |
|
| 289 | + if (!isset(self::$classExists[$type])) |
|
| 290 | 290 | self::$classExists[$type] = class_exists($type, false); |
| 291 | 291 | |
| 292 | - if(!isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
| 292 | + if (!isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
| 293 | 293 | static::using($type); |
| 294 | 294 | self::$classExists[$type] = class_exists($type, false); |
| 295 | 295 | } |
@@ -301,13 +301,13 @@ discard block |
||
| 301 | 301 | * \Application\Common\MyDataModule) |
| 302 | 302 | * Skip this if the class is inside the Prado\* namespace, since all Prado classes are now namespaced |
| 303 | 303 | */ |
| 304 | - if(($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0) |
|
| 304 | + if (($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0) |
|
| 305 | 305 | $type = substr($type, $pos + 1); |
| 306 | 306 | |
| 307 | - if(($n = func_num_args()) > 1) |
|
| 307 | + if (($n = func_num_args()) > 1) |
|
| 308 | 308 | { |
| 309 | 309 | $args = func_get_args(); |
| 310 | - switch($n) { |
|
| 310 | + switch ($n) { |
|
| 311 | 311 | case 2: |
| 312 | 312 | return new $type($args[1]); |
| 313 | 313 | break; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | break; |
| 323 | 323 | default: |
| 324 | 324 | $s = '$args[1]'; |
| 325 | - for($i = 2;$i < $n;++$i) |
|
| 325 | + for ($i = 2; $i < $n; ++$i) |
|
| 326 | 326 | $s .= ",\$args[$i]"; |
| 327 | 327 | eval("\$component=new $type($s);"); |
| 328 | 328 | return $component; |
@@ -346,58 +346,58 @@ discard block |
||
| 346 | 346 | { |
| 347 | 347 | $namespace = static::prado3NamespaceToPhpNamespace($namespace); |
| 348 | 348 | |
| 349 | - if(isset(self::$_usings[$namespace]) || class_exists($namespace, false)) |
|
| 349 | + if (isset(self::$_usings[$namespace]) || class_exists($namespace, false)) |
|
| 350 | 350 | return; |
| 351 | 351 | |
| 352 | - if(array_key_exists($namespace, self::$classMap)) |
|
| 352 | + if (array_key_exists($namespace, self::$classMap)) |
|
| 353 | 353 | { |
| 354 | 354 | // fast autoload a Prado3 class name |
| 355 | 355 | $phpNamespace = self::$classMap[$namespace]; |
| 356 | - if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) |
|
| 356 | + if (class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) |
|
| 357 | 357 | { |
| 358 | - if(!class_exists($namespace) && !interface_exists($namespace)) |
|
| 358 | + if (!class_exists($namespace) && !interface_exists($namespace)) |
|
| 359 | 359 | class_alias($phpNamespace, $namespace); |
| 360 | 360 | return; |
| 361 | 361 | } |
| 362 | - } elseif(($pos = strrpos($namespace, '\\')) === false) { |
|
| 362 | + } elseif (($pos = strrpos($namespace, '\\')) === false) { |
|
| 363 | 363 | // trying to autoload an old class name |
| 364 | - foreach(self::$_usings as $k => $v) |
|
| 364 | + foreach (self::$_usings as $k => $v) |
|
| 365 | 365 | { |
| 366 | - $path = $v . DIRECTORY_SEPARATOR . $namespace . self::CLASS_FILE_EXT; |
|
| 367 | - if(file_exists($path)) |
|
| 366 | + $path = $v.DIRECTORY_SEPARATOR.$namespace.self::CLASS_FILE_EXT; |
|
| 367 | + if (file_exists($path)) |
|
| 368 | 368 | { |
| 369 | - $phpNamespace = '\\' . $k . '\\' . $namespace; |
|
| 370 | - if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) |
|
| 369 | + $phpNamespace = '\\'.$k.'\\'.$namespace; |
|
| 370 | + if (class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) |
|
| 371 | 371 | { |
| 372 | - if(!class_exists($namespace) && !interface_exists($namespace)) |
|
| 372 | + if (!class_exists($namespace) && !interface_exists($namespace)) |
|
| 373 | 373 | class_alias($phpNamespace, $namespace); |
| 374 | 374 | return; |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false)) |
|
| 379 | + if ($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false)) |
|
| 380 | 380 | throw new TInvalidOperationException('prado_component_unknown', $namespace, ''); |
| 381 | - } elseif(($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) { |
|
| 381 | + } elseif (($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) { |
|
| 382 | 382 | $className = substr($namespace, $pos + 1); |
| 383 | - if($className === '*') // a directory |
|
| 383 | + if ($className === '*') // a directory |
|
| 384 | 384 | { |
| 385 | 385 | self::$_usings[substr($namespace, 0, $pos)] = $path; |
| 386 | 386 | } |
| 387 | 387 | else // a file |
| 388 | 388 | { |
| 389 | 389 | //self::$_usings[$namespace]=$path; |
| 390 | - if(!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false))) |
|
| 390 | + if (!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false))) |
|
| 391 | 391 | { |
| 392 | 392 | try |
| 393 | 393 | { |
| 394 | 394 | include_once($path); |
| 395 | - if(class_exists($namespace, false) || interface_exists($namespace, false)) |
|
| 395 | + if (class_exists($namespace, false) || interface_exists($namespace, false)) |
|
| 396 | 396 | class_alias($namespace, $className); |
| 397 | 397 | } |
| 398 | - catch(\Exception $e) |
|
| 398 | + catch (\Exception $e) |
|
| 399 | 399 | { |
| 400 | - if($checkClassExistence && !class_exists($className, false)) |
|
| 400 | + if ($checkClassExistence && !class_exists($className, false)) |
|
| 401 | 401 | throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage()); |
| 402 | 402 | else |
| 403 | 403 | throw $e; |
@@ -423,20 +423,20 @@ discard block |
||
| 423 | 423 | { |
| 424 | 424 | $namespace = static::prado3NamespaceToPhpNamespace($namespace); |
| 425 | 425 | |
| 426 | - if(self::CLASS_FILE_EXT === $ext || empty($ext)) |
|
| 426 | + if (self::CLASS_FILE_EXT === $ext || empty($ext)) |
|
| 427 | 427 | { |
| 428 | - if(isset(self::$_usings[$namespace])) |
|
| 428 | + if (isset(self::$_usings[$namespace])) |
|
| 429 | 429 | return self::$_usings[$namespace]; |
| 430 | 430 | |
| 431 | - if(isset(self::$_aliases[$namespace])) |
|
| 431 | + if (isset(self::$_aliases[$namespace])) |
|
| 432 | 432 | return self::$_aliases[$namespace]; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | $segs = explode('\\', $namespace); |
| 436 | 436 | $alias = array_shift($segs); |
| 437 | 437 | |
| 438 | - if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) |
|
| 439 | - return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext); |
|
| 438 | + if (null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) |
|
| 439 | + return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $segs), '/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext); |
|
| 440 | 440 | |
| 441 | 441 | return null; |
| 442 | 442 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | */ |
| 448 | 448 | public static function getPathOfAlias($alias) |
| 449 | 449 | { |
| 450 | - return isset(self::$_aliases[$alias])?self::$_aliases[$alias]:null; |
|
| 450 | + return isset(self::$_aliases[$alias]) ?self::$_aliases[$alias] : null; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | protected static function getPathAliases() |
@@ -463,11 +463,11 @@ discard block |
||
| 463 | 463 | */ |
| 464 | 464 | public static function setPathOfAlias($alias, $path) |
| 465 | 465 | { |
| 466 | - if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) |
|
| 466 | + if (isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) |
|
| 467 | 467 | throw new TInvalidOperationException('prado_alias_redefined', $alias); |
| 468 | - elseif(($rp = realpath($path)) !== false && is_dir($rp)) |
|
| 468 | + elseif (($rp = realpath($path)) !== false && is_dir($rp)) |
|
| 469 | 469 | { |
| 470 | - if(strpos($alias, '.') === false) |
|
| 470 | + if (strpos($alias, '.') === false) |
|
| 471 | 471 | self::$_aliases[$alias] = $rp; |
| 472 | 472 | else |
| 473 | 473 | throw new TInvalidDataValueException('prado_aliasname_invalid', $alias); |
@@ -485,45 +485,45 @@ discard block |
||
| 485 | 485 | public static function fatalError($msg) |
| 486 | 486 | { |
| 487 | 487 | echo '<h1>Fatal Error</h1>'; |
| 488 | - echo '<p>' . $msg . '</p>'; |
|
| 489 | - if(!function_exists('debug_backtrace')) |
|
| 488 | + echo '<p>'.$msg.'</p>'; |
|
| 489 | + if (!function_exists('debug_backtrace')) |
|
| 490 | 490 | return; |
| 491 | 491 | echo '<h2>Debug Backtrace</h2>'; |
| 492 | 492 | echo '<pre>'; |
| 493 | 493 | $index = -1; |
| 494 | - foreach(debug_backtrace() as $t) |
|
| 494 | + foreach (debug_backtrace() as $t) |
|
| 495 | 495 | { |
| 496 | 496 | $index++; |
| 497 | - if($index == 0) // hide the backtrace of this function |
|
| 497 | + if ($index == 0) // hide the backtrace of this function |
|
| 498 | 498 | continue; |
| 499 | - echo '#' . $index . ' '; |
|
| 500 | - if(isset($t['file'])) |
|
| 501 | - echo basename($t['file']) . ':' . $t['line']; |
|
| 499 | + echo '#'.$index.' '; |
|
| 500 | + if (isset($t['file'])) |
|
| 501 | + echo basename($t['file']).':'.$t['line']; |
|
| 502 | 502 | else |
| 503 | 503 | echo '<PHP inner-code>'; |
| 504 | 504 | echo ' -- '; |
| 505 | - if(isset($t['class'])) |
|
| 506 | - echo $t['class'] . $t['type']; |
|
| 507 | - echo $t['function'] . '('; |
|
| 508 | - if(isset($t['args']) && count($t['args']) > 0) |
|
| 505 | + if (isset($t['class'])) |
|
| 506 | + echo $t['class'].$t['type']; |
|
| 507 | + echo $t['function'].'('; |
|
| 508 | + if (isset($t['args']) && count($t['args']) > 0) |
|
| 509 | 509 | { |
| 510 | 510 | $count = 0; |
| 511 | - foreach($t['args'] as $item) |
|
| 511 | + foreach ($t['args'] as $item) |
|
| 512 | 512 | { |
| 513 | - if(is_string($item)) |
|
| 513 | + if (is_string($item)) |
|
| 514 | 514 | { |
| 515 | 515 | $str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES); |
| 516 | 516 | if (strlen($item) > 70) |
| 517 | - echo "'" . substr($str, 0, 70) . "...'"; |
|
| 517 | + echo "'".substr($str, 0, 70)."...'"; |
|
| 518 | 518 | else |
| 519 | - echo "'" . $str . "'"; |
|
| 519 | + echo "'".$str."'"; |
|
| 520 | 520 | } |
| 521 | 521 | elseif (is_int($item) || is_float($item)) |
| 522 | 522 | echo $item; |
| 523 | 523 | elseif (is_object($item)) |
| 524 | 524 | echo get_class($item); |
| 525 | 525 | elseif (is_array($item)) |
| 526 | - echo 'array(' . count($item) . ')'; |
|
| 526 | + echo 'array('.count($item).')'; |
|
| 527 | 527 | elseif (is_bool($item)) |
| 528 | 528 | echo $item ? 'true' : 'false'; |
| 529 | 529 | elseif ($item === null) |
@@ -551,21 +551,21 @@ discard block |
||
| 551 | 551 | public static function getUserLanguages() |
| 552 | 552 | { |
| 553 | 553 | static $languages = null; |
| 554 | - if($languages === null) |
|
| 554 | + if ($languages === null) |
|
| 555 | 555 | { |
| 556 | - if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
| 556 | + if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
| 557 | 557 | $languages[0] = 'en'; |
| 558 | 558 | else |
| 559 | 559 | { |
| 560 | 560 | $languages = []; |
| 561 | - foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
| 561 | + foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
|
| 562 | 562 | { |
| 563 | 563 | $array = explode(';q=', trim($language)); |
| 564 | - $languages[trim($array[0])] = isset($array[1])?(float)$array[1]:1.0; |
|
| 564 | + $languages[trim($array[0])] = isset($array[1]) ? (float) $array[1] : 1.0; |
|
| 565 | 565 | } |
| 566 | 566 | arsort($languages); |
| 567 | 567 | $languages = array_keys($languages); |
| 568 | - if(empty($languages)) |
|
| 568 | + if (empty($languages)) |
|
| 569 | 569 | $languages[0] = 'en'; |
| 570 | 570 | } |
| 571 | 571 | } |
@@ -579,11 +579,11 @@ discard block |
||
| 579 | 579 | public static function getPreferredLanguage() |
| 580 | 580 | { |
| 581 | 581 | static $language = null; |
| 582 | - if($language === null) |
|
| 582 | + if ($language === null) |
|
| 583 | 583 | { |
| 584 | 584 | $langs = Prado::getUserLanguages(); |
| 585 | 585 | $lang = explode('-', $langs[0]); |
| 586 | - if(empty($lang[0]) || !ctype_alpha($lang[0])) |
|
| 586 | + if (empty($lang[0]) || !ctype_alpha($lang[0])) |
|
| 587 | 587 | $language = 'en'; |
| 588 | 588 | else |
| 589 | 589 | $language = $lang[0]; |
@@ -605,12 +605,12 @@ discard block |
||
| 605 | 605 | */ |
| 606 | 606 | public static function trace($msg, $category = 'Uncategorized', $ctl = null) |
| 607 | 607 | { |
| 608 | - if(self::$_application && self::$_application->getMode() === TApplicationMode::Performance) |
|
| 608 | + if (self::$_application && self::$_application->getMode() === TApplicationMode::Performance) |
|
| 609 | 609 | return; |
| 610 | - if(!self::$_application || self::$_application->getMode() === TApplicationMode::Debug) |
|
| 610 | + if (!self::$_application || self::$_application->getMode() === TApplicationMode::Debug) |
|
| 611 | 611 | { |
| 612 | 612 | $trace = debug_backtrace(); |
| 613 | - if(isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
| 613 | + if (isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
| 614 | 614 | $msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})"; |
| 615 | 615 | $level = TLogger::DEBUG; |
| 616 | 616 | } |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | */ |
| 634 | 634 | public static function log($msg, $level = TLogger::INFO, $category = 'Uncategorized', $ctl = null) |
| 635 | 635 | { |
| 636 | - if(self::$_logger === null) |
|
| 636 | + if (self::$_logger === null) |
|
| 637 | 637 | self::$_logger = new TLogger; |
| 638 | 638 | self::$_logger->log($msg, $level, $category, $ctl); |
| 639 | 639 | } |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | */ |
| 644 | 644 | public static function getLogger() |
| 645 | 645 | { |
| 646 | - if(self::$_logger === null) |
|
| 646 | + if (self::$_logger === null) |
|
| 647 | 647 | self::$_logger = new TLogger; |
| 648 | 648 | return self::$_logger; |
| 649 | 649 | } |
@@ -677,15 +677,15 @@ discard block |
||
| 677 | 677 | $app = Prado::getApplication()->getGlobalization(false); |
| 678 | 678 | |
| 679 | 679 | $params = []; |
| 680 | - foreach($parameters as $key => $value) |
|
| 681 | - $params['{' . $key . '}'] = $value; |
|
| 680 | + foreach ($parameters as $key => $value) |
|
| 681 | + $params['{'.$key.'}'] = $value; |
|
| 682 | 682 | |
| 683 | 683 | //no translation handler provided |
| 684 | - if($app === null || ($config = $app->getTranslationConfiguration()) === null) |
|
| 684 | + if ($app === null || ($config = $app->getTranslationConfiguration()) === null) |
|
| 685 | 685 | return strtr($text, $params); |
| 686 | 686 | |
| 687 | 687 | if ($catalogue === null) |
| 688 | - $catalogue = isset($config['catalogue'])?$config['catalogue']:'messages'; |
|
| 688 | + $catalogue = isset($config['catalogue']) ? $config['catalogue'] : 'messages'; |
|
| 689 | 689 | |
| 690 | 690 | Translation::init($catalogue); |
| 691 | 691 | |
@@ -696,8 +696,8 @@ discard block |
||
| 696 | 696 | $defaultCharset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset(); |
| 697 | 697 | |
| 698 | 698 | //fall back |
| 699 | - if(empty($charset)) $charset = $appCharset; |
|
| 700 | - if(empty($charset)) $charset = $defaultCharset; |
|
| 699 | + if (empty($charset)) $charset = $appCharset; |
|
| 700 | + if (empty($charset)) $charset = $defaultCharset; |
|
| 701 | 701 | |
| 702 | 702 | return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset); |
| 703 | 703 | } |
@@ -26,6 +26,6 @@ |
||
| 26 | 26 | { |
| 27 | 27 | public function toJavaScriptLiteral() |
| 28 | 28 | { |
| 29 | - return TJavaScript::jsonEncode((string)$this->_s, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
| 29 | + return TJavaScript::jsonEncode((string) $this->_s, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |