@@ -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,12 +48,14 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function setAlternateText($value) |
| 50 | 50 | { |
| 51 | - if(parent::getAlternateText() === $value) |
|
| 52 | - return; |
|
| 51 | + if(parent::getAlternateText() === $value) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 53 | 54 | |
| 54 | 55 | parent::setAlternateText($value); |
| 55 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 56 | - $this->getPage()->getCallbackClient()->setAttribute($this, 'alt', $value); |
|
| 56 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 57 | + $this->getPage()->getCallbackClient()->setAttribute($this, 'alt', $value); |
|
| 58 | + } |
|
| 57 | 59 | } |
| 58 | 60 | |
| 59 | 61 | /** |
@@ -65,12 +67,14 @@ discard block |
||
| 65 | 67 | */ |
| 66 | 68 | public function setImageAlign($value) |
| 67 | 69 | { |
| 68 | - if(parent::getImageAlign() === $value) |
|
| 69 | - return; |
|
| 70 | + if(parent::getImageAlign() === $value) { |
|
| 71 | + return; |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | parent::setImageAlign($value); |
| 72 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 73 | - $this->getPage()->getCallbackClient()->setAttribute($this, 'align', $value); |
|
| 75 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 76 | + $this->getPage()->getCallbackClient()->setAttribute($this, 'align', $value); |
|
| 77 | + } |
|
| 74 | 78 | } |
| 75 | 79 | |
| 76 | 80 | /** |
@@ -78,12 +82,14 @@ discard block |
||
| 78 | 82 | */ |
| 79 | 83 | public function setImageUrl($value) |
| 80 | 84 | { |
| 81 | - if(parent::getImageUrl() === $value) |
|
| 82 | - return; |
|
| 85 | + if(parent::getImageUrl() === $value) { |
|
| 86 | + return; |
|
| 87 | + } |
|
| 83 | 88 | |
| 84 | 89 | parent::setImageUrl($value); |
| 85 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 86 | - $this->getPage()->getCallbackClient()->setAttribute($this, 'src', $value); |
|
| 90 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 91 | + $this->getPage()->getCallbackClient()->setAttribute($this, 'src', $value); |
|
| 92 | + } |
|
| 87 | 93 | } |
| 88 | 94 | |
| 89 | 95 | /** |
@@ -91,12 +97,14 @@ discard block |
||
| 91 | 97 | */ |
| 92 | 98 | public function setDescriptionUrl($value) |
| 93 | 99 | { |
| 94 | - if(parent::getDescriptionUrl() === $value) |
|
| 95 | - return; |
|
| 100 | + if(parent::getDescriptionUrl() === $value) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 96 | 103 | |
| 97 | 104 | parent::setDescriptionUrl($value); |
| 98 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 99 | - $this->getPage()->getCallbackClient()->setAttribute($this, 'longdesc', $value); |
|
| 105 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 106 | + $this->getPage()->getCallbackClient()->setAttribute($this, 'longdesc', $value); |
|
| 107 | + } |
|
| 100 | 108 | } |
| 101 | 109 | } |
| 102 | 110 | |
@@ -145,8 +145,9 @@ |
||
| 145 | 145 | */ |
| 146 | 146 | public function setErrorMessage($value) |
| 147 | 147 | { |
| 148 | - if(parent::getErrorMessage() === $value) |
|
| 149 | - return; |
|
| 148 | + if(parent::getErrorMessage() === $value) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 150 | 151 | |
| 151 | 152 | |
| 152 | 153 | parent::setErrorMessage($value); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // it could have been changed by the clientside validation. |
| 115 | 115 | |
| 116 | 116 | parent::setIsValid($value); |
| 117 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 117 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 118 | 118 | { |
| 119 | 119 | $client = $this->getPage()->getCallbackClient(); |
| 120 | 120 | $func = 'Prado.Validation.updateActiveCustomValidator'; |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function setErrorMessage($value) |
| 153 | 153 | { |
| 154 | - if(parent::getErrorMessage() === $value) |
|
| 154 | + if (parent::getErrorMessage() === $value) |
|
| 155 | 155 | return; |
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | parent::setErrorMessage($value); |
| 159 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 159 | + if ($this->getActiveControl()->canUpdateClientSide()) |
|
| 160 | 160 | { |
| 161 | 161 | $client = $this->getPage()->getCallbackClient(); |
| 162 | 162 | $func = 'Prado.Validation.setErrorMessage'; |
@@ -44,11 +44,13 @@ |
||
| 44 | 44 | public function setInterval($value) |
| 45 | 45 | { |
| 46 | 46 | $interval = TPropertyValue::ensureFloat($value); |
| 47 | - if($interval <= 0) |
|
| 48 | - throw new TConfigurationException('callback_interval_be_positive', $this->getID()); |
|
| 47 | + if($interval <= 0) { |
|
| 48 | + throw new TConfigurationException('callback_interval_be_positive', $this->getID()); |
|
| 49 | + } |
|
| 49 | 50 | |
| 50 | - if($this->getInterval() === $value) |
|
| 51 | - return; |
|
| 51 | + if($this->getInterval() === $value) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | $this->setViewState('Interval', $interval, 1); |
| 54 | 56 | if ($this->getActiveControl()->canUpdateClientSide()){ |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | public function setInterval($value) |
| 50 | 50 | { |
| 51 | 51 | $interval = TPropertyValue::ensureFloat($value); |
| 52 | - if($interval <= 0) |
|
| 52 | + if ($interval <= 0) |
|
| 53 | 53 | throw new TConfigurationException('callback_interval_be_positive', $this->getID()); |
| 54 | 54 | |
| 55 | - if($this->getInterval() === $value) |
|
| 55 | + if ($this->getInterval() === $value) |
|
| 56 | 56 | return; |
| 57 | 57 | |
| 58 | 58 | $this->setViewState('Interval', $interval, 1); |
| 59 | - if ($this->getActiveControl()->canUpdateClientSide()){ |
|
| 59 | + if ($this->getActiveControl()->canUpdateClientSide()) { |
|
| 60 | 60 | $client = $this->getPage()->getCallbackClient(); |
| 61 | 61 | $client->callClientFunction('Prado.WebUI.TTimeTriggeredCallback.setTimerInterval', [$this, $interval]); |
| 62 | 62 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | parent::render($writer); |
| 118 | 118 | $this->getActiveControl()->registerCallbackClientScript( |
| 119 | 119 | $this->getClientClassName(), $this->getTriggerOptions()); |
| 120 | - if($this->getStartTimerOnLoad()){ |
|
| 120 | + if ($this->getStartTimerOnLoad()) { |
|
| 121 | 121 | $id = $this->getClientID(); |
| 122 | 122 | $code = "Prado.WebUI.TTimeTriggeredCallback.start('{$id}');"; |
| 123 | 123 | $cs = $this->getPage()->getClientScript(); |
@@ -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 | /** |
@@ -72,16 +72,13 @@ |
||
| 72 | 72 | try |
| 73 | 73 | { |
| 74 | 74 | return xmlrpc_server_call_method($this->_xmlrpcServer, $requestPayload, null); |
| 75 | - } |
|
| 76 | - catch(TRpcException $e) |
|
| 75 | + } catch(TRpcException $e) |
|
| 77 | 76 | { |
| 78 | 77 | return $this->createErrorResponse($e); |
| 79 | - } |
|
| 80 | - catch(THttpException $e) |
|
| 78 | + } catch(THttpException $e) |
|
| 81 | 79 | { |
| 82 | 80 | throw $e; |
| 83 | - } |
|
| 84 | - catch(\Exception $e) |
|
| 81 | + } catch(\Exception $e) |
|
| 85 | 82 | { |
| 86 | 83 | return $this->createErrorResponse(new TRpcException('An internal error occured')); |
| 87 | 84 | } |
@@ -74,15 +74,15 @@ |
||
| 74 | 74 | { |
| 75 | 75 | return xmlrpc_server_call_method($this->_xmlrpcServer, $requestPayload, null); |
| 76 | 76 | } |
| 77 | - catch(TRpcException $e) |
|
| 77 | + catch (TRpcException $e) |
|
| 78 | 78 | { |
| 79 | 79 | return $this->createErrorResponse($e); |
| 80 | 80 | } |
| 81 | - catch(THttpException $e) |
|
| 81 | + catch (THttpException $e) |
|
| 82 | 82 | { |
| 83 | 83 | throw $e; |
| 84 | 84 | } |
| 85 | - catch(\Exception $e) |
|
| 85 | + catch (\Exception $e) |
|
| 86 | 86 | { |
| 87 | 87 | return $this->createErrorResponse(new TRpcException('An internal error occured')); |
| 88 | 88 | } |
@@ -69,8 +69,7 @@ |
||
| 69 | 69 | try |
| 70 | 70 | { |
| 71 | 71 | return $this->handler->callMethod($this->getPayload()); |
| 72 | - } |
|
| 73 | - catch(TRpcException $e) |
|
| 72 | + } catch(TRpcException $e) |
|
| 74 | 73 | { |
| 75 | 74 | return $this->handler->createErrorResponse($e); |
| 76 | 75 | } |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | { |
| 71 | 71 | return $this->handler->callMethod($this->getPayload()); |
| 72 | 72 | } |
| 73 | - catch(TRpcException $e) |
|
| 73 | + catch (TRpcException $e) |
|
| 74 | 74 | { |
| 75 | 75 | return $this->handler->createErrorResponse($e); |
| 76 | 76 | } |
@@ -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 | } |
@@ -25,13 +25,15 @@ 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 | 32 | * Defines the default permission for writable directories and files |
| 32 | 33 | */ |
| 33 | -if(!defined('PRADO_CHMOD')) |
|
| 34 | +if(!defined('PRADO_CHMOD')) { |
|
| 34 | 35 | define('PRADO_CHMOD', 0777); |
| 36 | +} |
|
| 35 | 37 | /** |
| 36 | 38 | * Defines the Composer's vendor/ path. |
| 37 | 39 | */ |
@@ -160,9 +162,9 @@ discard block |
||
| 160 | 162 | { |
| 161 | 163 | $am = self::$_application->getAssetManager(); |
| 162 | 164 | $url = $am->publishFilePath(self::getPathOfNamespace('Prado\\' . $logoName, '.gif')); |
| 165 | + } else { |
|
| 166 | + $url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif'; |
|
| 163 | 167 | } |
| 164 | - else |
|
| 165 | - $url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif'; |
|
| 166 | 168 | 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 | 169 | } |
| 168 | 170 | |
@@ -178,8 +180,9 @@ discard block |
||
| 178 | 180 | */ |
| 179 | 181 | public static function phpErrorHandler($errno, $errstr, $errfile, $errline) |
| 180 | 182 | { |
| 181 | - if(error_reporting() & $errno) |
|
| 182 | - throw new TPhpErrorException($errno, $errstr, $errfile, $errline); |
|
| 183 | + if(error_reporting() & $errno) { |
|
| 184 | + throw new TPhpErrorException($errno, $errstr, $errfile, $errline); |
|
| 185 | + } |
|
| 183 | 186 | } |
| 184 | 187 | |
| 185 | 188 | /** |
@@ -213,8 +216,7 @@ discard block |
||
| 213 | 216 | if(self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null) |
| 214 | 217 | { |
| 215 | 218 | $errorHandler->handleError(null, $exception); |
| 216 | - } |
|
| 217 | - else |
|
| 219 | + } else |
|
| 218 | 220 | { |
| 219 | 221 | echo $exception; |
| 220 | 222 | } |
@@ -232,8 +234,9 @@ discard block |
||
| 232 | 234 | */ |
| 233 | 235 | public static function setApplication($application) |
| 234 | 236 | { |
| 235 | - if(self::$_application !== null && !defined('PRADO_TEST_RUN')) |
|
| 236 | - throw new TInvalidOperationException('prado_application_singleton_required'); |
|
| 237 | + if(self::$_application !== null && !defined('PRADO_TEST_RUN')) { |
|
| 238 | + throw new TInvalidOperationException('prado_application_singleton_required'); |
|
| 239 | + } |
|
| 237 | 240 | self::$_application = $application; |
| 238 | 241 | } |
| 239 | 242 | |
@@ -261,13 +264,15 @@ discard block |
||
| 261 | 264 | |
| 262 | 265 | protected static function prado3NamespaceToPhpNamespace($type) |
| 263 | 266 | { |
| 264 | - if(substr($type, 0, 6) === 'System') |
|
| 265 | - $type = 'Prado' . substr($type, 6); |
|
| 267 | + if(substr($type, 0, 6) === 'System') { |
|
| 268 | + $type = 'Prado' . substr($type, 6); |
|
| 269 | + } |
|
| 266 | 270 | |
| 267 | - if(false === strpos($type, '\\')) |
|
| 268 | - return str_replace('.', '\\', $type); |
|
| 269 | - else |
|
| 270 | - return $type; |
|
| 271 | + if(false === strpos($type, '\\')) { |
|
| 272 | + return str_replace('.', '\\', $type); |
|
| 273 | + } else { |
|
| 274 | + return $type; |
|
| 275 | + } |
|
| 271 | 276 | } |
| 272 | 277 | |
| 273 | 278 | /** |
@@ -286,8 +291,9 @@ discard block |
||
| 286 | 291 | public static function createComponent($requestedType) |
| 287 | 292 | { |
| 288 | 293 | $type = static::prado3NamespaceToPhpNamespace($requestedType); |
| 289 | - if(!isset(self::$classExists[$type])) |
|
| 290 | - self::$classExists[$type] = class_exists($type, false); |
|
| 294 | + if(!isset(self::$classExists[$type])) { |
|
| 295 | + self::$classExists[$type] = class_exists($type, false); |
|
| 296 | + } |
|
| 291 | 297 | |
| 292 | 298 | if(!isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
| 293 | 299 | static::using($type); |
@@ -301,8 +307,9 @@ discard block |
||
| 301 | 307 | * \Application\Common\MyDataModule) |
| 302 | 308 | * Skip this if the class is inside the Prado\* namespace, since all Prado classes are now namespaced |
| 303 | 309 | */ |
| 304 | - if(($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0) |
|
| 305 | - $type = substr($type, $pos + 1); |
|
| 310 | + if(($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0) { |
|
| 311 | + $type = substr($type, $pos + 1); |
|
| 312 | + } |
|
| 306 | 313 | |
| 307 | 314 | if(($n = func_num_args()) > 1) |
| 308 | 315 | { |
@@ -322,15 +329,16 @@ discard block |
||
| 322 | 329 | break; |
| 323 | 330 | default: |
| 324 | 331 | $s = '$args[1]'; |
| 325 | - for($i = 2;$i < $n;++$i) |
|
| 326 | - $s .= ",\$args[$i]"; |
|
| 332 | + for($i = 2;$i < $n;++$i) { |
|
| 333 | + $s .= ",\$args[$i]"; |
|
| 334 | + } |
|
| 327 | 335 | eval("\$component=new $type($s);"); |
| 328 | 336 | return $component; |
| 329 | 337 | break; |
| 330 | 338 | } |
| 339 | + } else { |
|
| 340 | + return new $type; |
|
| 331 | 341 | } |
| 332 | - else |
|
| 333 | - return new $type; |
|
| 334 | 342 | } |
| 335 | 343 | |
| 336 | 344 | /** |
@@ -346,8 +354,9 @@ discard block |
||
| 346 | 354 | { |
| 347 | 355 | $namespace = static::prado3NamespaceToPhpNamespace($namespace); |
| 348 | 356 | |
| 349 | - if(isset(self::$_usings[$namespace]) || class_exists($namespace, false)) |
|
| 350 | - return; |
|
| 357 | + if(isset(self::$_usings[$namespace]) || class_exists($namespace, false)) { |
|
| 358 | + return; |
|
| 359 | + } |
|
| 351 | 360 | |
| 352 | 361 | if(array_key_exists($namespace, self::$classMap)) |
| 353 | 362 | { |
@@ -355,8 +364,9 @@ discard block |
||
| 355 | 364 | $phpNamespace = self::$classMap[$namespace]; |
| 356 | 365 | if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) |
| 357 | 366 | { |
| 358 | - if(!class_exists($namespace) && !interface_exists($namespace)) |
|
| 359 | - class_alias($phpNamespace, $namespace); |
|
| 367 | + if(!class_exists($namespace) && !interface_exists($namespace)) { |
|
| 368 | + class_alias($phpNamespace, $namespace); |
|
| 369 | + } |
|
| 360 | 370 | return; |
| 361 | 371 | } |
| 362 | 372 | } elseif(($pos = strrpos($namespace, '\\')) === false) { |
@@ -369,22 +379,25 @@ discard block |
||
| 369 | 379 | $phpNamespace = '\\' . $k . '\\' . $namespace; |
| 370 | 380 | if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) |
| 371 | 381 | { |
| 372 | - if(!class_exists($namespace) && !interface_exists($namespace)) |
|
| 373 | - class_alias($phpNamespace, $namespace); |
|
| 382 | + if(!class_exists($namespace) && !interface_exists($namespace)) { |
|
| 383 | + class_alias($phpNamespace, $namespace); |
|
| 384 | + } |
|
| 374 | 385 | return; |
| 375 | 386 | } |
| 376 | 387 | } |
| 377 | 388 | } |
| 378 | 389 | |
| 379 | - if($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false)) |
|
| 380 | - throw new TInvalidOperationException('prado_component_unknown', $namespace, ''); |
|
| 390 | + if($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false)) { |
|
| 391 | + throw new TInvalidOperationException('prado_component_unknown', $namespace, ''); |
|
| 392 | + } |
|
| 381 | 393 | } elseif(($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) { |
| 382 | 394 | $className = substr($namespace, $pos + 1); |
| 383 | - if($className === '*') // a directory |
|
| 395 | + if($className === '*') { |
|
| 396 | + // a directory |
|
| 384 | 397 | { |
| 385 | 398 | self::$_usings[substr($namespace, 0, $pos)] = $path; |
| 386 | 399 | } |
| 387 | - else // a file |
|
| 400 | + } else // a file |
|
| 388 | 401 | { |
| 389 | 402 | //self::$_usings[$namespace]=$path; |
| 390 | 403 | if(!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false))) |
@@ -392,15 +405,16 @@ discard block |
||
| 392 | 405 | try |
| 393 | 406 | { |
| 394 | 407 | include_once($path); |
| 395 | - if(class_exists($namespace, false) || interface_exists($namespace, false)) |
|
| 396 | - class_alias($namespace, $className); |
|
| 397 | - } |
|
| 398 | - catch(\Exception $e) |
|
| 408 | + if(class_exists($namespace, false) || interface_exists($namespace, false)) { |
|
| 409 | + class_alias($namespace, $className); |
|
| 410 | + } |
|
| 411 | + } catch(\Exception $e) |
|
| 399 | 412 | { |
| 400 | - if($checkClassExistence && !class_exists($className, false)) |
|
| 401 | - throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage()); |
|
| 402 | - else |
|
| 403 | - throw $e; |
|
| 413 | + if($checkClassExistence && !class_exists($className, false)) { |
|
| 414 | + throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage()); |
|
| 415 | + } else { |
|
| 416 | + throw $e; |
|
| 417 | + } |
|
| 404 | 418 | } |
| 405 | 419 | } |
| 406 | 420 | } |
@@ -425,18 +439,21 @@ discard block |
||
| 425 | 439 | |
| 426 | 440 | if(self::CLASS_FILE_EXT === $ext || empty($ext)) |
| 427 | 441 | { |
| 428 | - if(isset(self::$_usings[$namespace])) |
|
| 429 | - return self::$_usings[$namespace]; |
|
| 442 | + if(isset(self::$_usings[$namespace])) { |
|
| 443 | + return self::$_usings[$namespace]; |
|
| 444 | + } |
|
| 430 | 445 | |
| 431 | - if(isset(self::$_aliases[$namespace])) |
|
| 432 | - return self::$_aliases[$namespace]; |
|
| 446 | + if(isset(self::$_aliases[$namespace])) { |
|
| 447 | + return self::$_aliases[$namespace]; |
|
| 448 | + } |
|
| 433 | 449 | } |
| 434 | 450 | |
| 435 | 451 | $segs = explode('\\', $namespace); |
| 436 | 452 | $alias = array_shift($segs); |
| 437 | 453 | |
| 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); |
|
| 454 | + if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) { |
|
| 455 | + return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext); |
|
| 456 | + } |
|
| 440 | 457 | |
| 441 | 458 | return null; |
| 442 | 459 | } |
@@ -463,17 +480,18 @@ discard block |
||
| 463 | 480 | */ |
| 464 | 481 | public static function setPathOfAlias($alias, $path) |
| 465 | 482 | { |
| 466 | - if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) |
|
| 467 | - throw new TInvalidOperationException('prado_alias_redefined', $alias); |
|
| 468 | - elseif(($rp = realpath($path)) !== false && is_dir($rp)) |
|
| 483 | + if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) { |
|
| 484 | + throw new TInvalidOperationException('prado_alias_redefined', $alias); |
|
| 485 | + } elseif(($rp = realpath($path)) !== false && is_dir($rp)) |
|
| 469 | 486 | { |
| 470 | - if(strpos($alias, '.') === false) |
|
| 471 | - self::$_aliases[$alias] = $rp; |
|
| 472 | - else |
|
| 473 | - throw new TInvalidDataValueException('prado_aliasname_invalid', $alias); |
|
| 487 | + if(strpos($alias, '.') === false) { |
|
| 488 | + self::$_aliases[$alias] = $rp; |
|
| 489 | + } else { |
|
| 490 | + throw new TInvalidDataValueException('prado_aliasname_invalid', $alias); |
|
| 491 | + } |
|
| 492 | + } else { |
|
| 493 | + throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path); |
|
| 474 | 494 | } |
| 475 | - else |
|
| 476 | - throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path); |
|
| 477 | 495 | } |
| 478 | 496 | |
| 479 | 497 | /** |
@@ -486,24 +504,29 @@ discard block |
||
| 486 | 504 | { |
| 487 | 505 | echo '<h1>Fatal Error</h1>'; |
| 488 | 506 | echo '<p>' . $msg . '</p>'; |
| 489 | - if(!function_exists('debug_backtrace')) |
|
| 490 | - return; |
|
| 507 | + if(!function_exists('debug_backtrace')) { |
|
| 508 | + return; |
|
| 509 | + } |
|
| 491 | 510 | echo '<h2>Debug Backtrace</h2>'; |
| 492 | 511 | echo '<pre>'; |
| 493 | 512 | $index = -1; |
| 494 | 513 | foreach(debug_backtrace() as $t) |
| 495 | 514 | { |
| 496 | 515 | $index++; |
| 497 | - if($index == 0) // hide the backtrace of this function |
|
| 516 | + if($index == 0) { |
|
| 517 | + // hide the backtrace of this function |
|
| 498 | 518 | continue; |
| 519 | + } |
|
| 499 | 520 | echo '#' . $index . ' '; |
| 500 | - if(isset($t['file'])) |
|
| 501 | - echo basename($t['file']) . ':' . $t['line']; |
|
| 502 | - else |
|
| 503 | - echo '<PHP inner-code>'; |
|
| 521 | + if(isset($t['file'])) { |
|
| 522 | + echo basename($t['file']) . ':' . $t['line']; |
|
| 523 | + } else { |
|
| 524 | + echo '<PHP inner-code>'; |
|
| 525 | + } |
|
| 504 | 526 | echo ' -- '; |
| 505 | - if(isset($t['class'])) |
|
| 506 | - echo $t['class'] . $t['type']; |
|
| 527 | + if(isset($t['class'])) { |
|
| 528 | + echo $t['class'] . $t['type']; |
|
| 529 | + } |
|
| 507 | 530 | echo $t['function'] . '('; |
| 508 | 531 | if(isset($t['args']) && count($t['args']) > 0) |
| 509 | 532 | { |
@@ -513,26 +536,28 @@ discard block |
||
| 513 | 536 | if(is_string($item)) |
| 514 | 537 | { |
| 515 | 538 | $str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES); |
| 516 | - if (strlen($item) > 70) |
|
| 517 | - echo "'" . substr($str, 0, 70) . "...'"; |
|
| 518 | - else |
|
| 519 | - echo "'" . $str . "'"; |
|
| 539 | + if (strlen($item) > 70) { |
|
| 540 | + echo "'" . substr($str, 0, 70) . "...'"; |
|
| 541 | + } else { |
|
| 542 | + echo "'" . $str . "'"; |
|
| 543 | + } |
|
| 544 | + } elseif (is_int($item) || is_float($item)) { |
|
| 545 | + echo $item; |
|
| 546 | + } elseif (is_object($item)) { |
|
| 547 | + echo get_class($item); |
|
| 548 | + } elseif (is_array($item)) { |
|
| 549 | + echo 'array(' . count($item) . ')'; |
|
| 550 | + } elseif (is_bool($item)) { |
|
| 551 | + echo $item ? 'true' : 'false'; |
|
| 552 | + } elseif ($item === null) { |
|
| 553 | + echo 'NULL'; |
|
| 554 | + } elseif (is_resource($item)) { |
|
| 555 | + echo get_resource_type($item); |
|
| 520 | 556 | } |
| 521 | - elseif (is_int($item) || is_float($item)) |
|
| 522 | - echo $item; |
|
| 523 | - elseif (is_object($item)) |
|
| 524 | - echo get_class($item); |
|
| 525 | - elseif (is_array($item)) |
|
| 526 | - echo 'array(' . count($item) . ')'; |
|
| 527 | - elseif (is_bool($item)) |
|
| 528 | - echo $item ? 'true' : 'false'; |
|
| 529 | - elseif ($item === null) |
|
| 530 | - echo 'NULL'; |
|
| 531 | - elseif (is_resource($item)) |
|
| 532 | - echo get_resource_type($item); |
|
| 533 | 557 | $count++; |
| 534 | - if (count($t['args']) > $count) |
|
| 535 | - echo ', '; |
|
| 558 | + if (count($t['args']) > $count) { |
|
| 559 | + echo ', '; |
|
| 560 | + } |
|
| 536 | 561 | } |
| 537 | 562 | } |
| 538 | 563 | echo ")\n"; |
@@ -553,9 +578,9 @@ discard block |
||
| 553 | 578 | static $languages = null; |
| 554 | 579 | if($languages === null) |
| 555 | 580 | { |
| 556 | - if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
| 557 | - $languages[0] = 'en'; |
|
| 558 | - else |
|
| 581 | + if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 582 | + $languages[0] = 'en'; |
|
| 583 | + } else |
|
| 559 | 584 | { |
| 560 | 585 | $languages = []; |
| 561 | 586 | foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) |
@@ -565,8 +590,9 @@ discard block |
||
| 565 | 590 | } |
| 566 | 591 | arsort($languages); |
| 567 | 592 | $languages = array_keys($languages); |
| 568 | - if(empty($languages)) |
|
| 569 | - $languages[0] = 'en'; |
|
| 593 | + if(empty($languages)) { |
|
| 594 | + $languages[0] = 'en'; |
|
| 595 | + } |
|
| 570 | 596 | } |
| 571 | 597 | } |
| 572 | 598 | return $languages; |
@@ -583,10 +609,11 @@ discard block |
||
| 583 | 609 | { |
| 584 | 610 | $langs = Prado::getUserLanguages(); |
| 585 | 611 | $lang = explode('-', $langs[0]); |
| 586 | - if(empty($lang[0]) || !ctype_alpha($lang[0])) |
|
| 587 | - $language = 'en'; |
|
| 588 | - else |
|
| 589 | - $language = $lang[0]; |
|
| 612 | + if(empty($lang[0]) || !ctype_alpha($lang[0])) { |
|
| 613 | + $language = 'en'; |
|
| 614 | + } else { |
|
| 615 | + $language = $lang[0]; |
|
| 616 | + } |
|
| 590 | 617 | } |
| 591 | 618 | return $language; |
| 592 | 619 | } |
@@ -605,17 +632,19 @@ discard block |
||
| 605 | 632 | */ |
| 606 | 633 | public static function trace($msg, $category = 'Uncategorized', $ctl = null) |
| 607 | 634 | { |
| 608 | - if(self::$_application && self::$_application->getMode() === TApplicationMode::Performance) |
|
| 609 | - return; |
|
| 635 | + if(self::$_application && self::$_application->getMode() === TApplicationMode::Performance) { |
|
| 636 | + return; |
|
| 637 | + } |
|
| 610 | 638 | if(!self::$_application || self::$_application->getMode() === TApplicationMode::Debug) |
| 611 | 639 | { |
| 612 | 640 | $trace = debug_backtrace(); |
| 613 | - if(isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
| 614 | - $msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})"; |
|
| 641 | + if(isset($trace[0]['file']) && isset($trace[0]['line'])) { |
|
| 642 | + $msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})"; |
|
| 643 | + } |
|
| 615 | 644 | $level = TLogger::DEBUG; |
| 645 | + } else { |
|
| 646 | + $level = TLogger::INFO; |
|
| 616 | 647 | } |
| 617 | - else |
|
| 618 | - $level = TLogger::INFO; |
|
| 619 | 648 | self::log($msg, $level, $category, $ctl); |
| 620 | 649 | } |
| 621 | 650 | |
@@ -633,8 +662,9 @@ discard block |
||
| 633 | 662 | */ |
| 634 | 663 | public static function log($msg, $level = TLogger::INFO, $category = 'Uncategorized', $ctl = null) |
| 635 | 664 | { |
| 636 | - if(self::$_logger === null) |
|
| 637 | - self::$_logger = new TLogger; |
|
| 665 | + if(self::$_logger === null) { |
|
| 666 | + self::$_logger = new TLogger; |
|
| 667 | + } |
|
| 638 | 668 | self::$_logger->log($msg, $level, $category, $ctl); |
| 639 | 669 | } |
| 640 | 670 | |
@@ -643,8 +673,9 @@ discard block |
||
| 643 | 673 | */ |
| 644 | 674 | public static function getLogger() |
| 645 | 675 | { |
| 646 | - if(self::$_logger === null) |
|
| 647 | - self::$_logger = new TLogger; |
|
| 676 | + if(self::$_logger === null) { |
|
| 677 | + self::$_logger = new TLogger; |
|
| 678 | + } |
|
| 648 | 679 | return self::$_logger; |
| 649 | 680 | } |
| 650 | 681 | |
@@ -677,15 +708,18 @@ discard block |
||
| 677 | 708 | $app = Prado::getApplication()->getGlobalization(false); |
| 678 | 709 | |
| 679 | 710 | $params = []; |
| 680 | - foreach($parameters as $key => $value) |
|
| 681 | - $params['{' . $key . '}'] = $value; |
|
| 711 | + foreach($parameters as $key => $value) { |
|
| 712 | + $params['{' . $key . '}'] = $value; |
|
| 713 | + } |
|
| 682 | 714 | |
| 683 | 715 | //no translation handler provided |
| 684 | - if($app === null || ($config = $app->getTranslationConfiguration()) === null) |
|
| 685 | - return strtr($text, $params); |
|
| 716 | + if($app === null || ($config = $app->getTranslationConfiguration()) === null) { |
|
| 717 | + return strtr($text, $params); |
|
| 718 | + } |
|
| 686 | 719 | |
| 687 | - if ($catalogue === null) |
|
| 688 | - $catalogue = isset($config['catalogue'])?$config['catalogue']:'messages'; |
|
| 720 | + if ($catalogue === null) { |
|
| 721 | + $catalogue = isset($config['catalogue'])?$config['catalogue']:'messages'; |
|
| 722 | + } |
|
| 689 | 723 | |
| 690 | 724 | Translation::init($catalogue); |
| 691 | 725 | |
@@ -696,8 +730,12 @@ discard block |
||
| 696 | 730 | $defaultCharset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset(); |
| 697 | 731 | |
| 698 | 732 | //fall back |
| 699 | - if(empty($charset)) $charset = $appCharset; |
|
| 700 | - if(empty($charset)) $charset = $defaultCharset; |
|
| 733 | + if(empty($charset)) { |
|
| 734 | + $charset = $appCharset; |
|
| 735 | + } |
|
| 736 | + if(empty($charset)) { |
|
| 737 | + $charset = $defaultCharset; |
|
| 738 | + } |
|
| 701 | 739 | |
| 702 | 740 | return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset); |
| 703 | 741 | } |
@@ -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 |
@@ -60,8 +60,7 @@ |
||
| 60 | 60 | $content = $response->createHtmlWriter(); |
| 61 | 61 | $content->getWriter()->setBoundary(TActivePageAdapter::CALLBACK_ERROR_HEADER); |
| 62 | 62 | $content->write($trace); |
| 63 | - } |
|
| 64 | - else |
|
| 63 | + } else |
|
| 65 | 64 | { |
| 66 | 65 | error_log("Error happened while processing an existing error:\n" . $exception->__toString()); |
| 67 | 66 | header('HTTP/1.0 500 Internal Server Error', true, 500); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | protected function displayException($exception) |
| 42 | 42 | { |
| 43 | - if($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 43 | + if ($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 44 | 44 | { |
| 45 | 45 | $response = $this->getApplication()->getResponse(); |
| 46 | 46 | $trace = $this->getExceptionStackTrace($exception); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | else |
| 65 | 65 | { |
| 66 | - error_log("Error happened while processing an existing error:\n" . $exception->__toString()); |
|
| 66 | + error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
|
| 67 | 67 | header('HTTP/1.0 500 Internal Server Error', true, 500); |
| 68 | 68 | } |
| 69 | 69 | $this->getApplication()->getResponse()->flush(); |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | $data['file'] = $exception->getFile(); |
| 80 | 80 | $data['line'] = $exception->getLine(); |
| 81 | 81 | $data['trace'] = $exception->getTrace(); |
| 82 | - if($exception instanceof TPhpErrorException) |
|
| 82 | + if ($exception instanceof TPhpErrorException) |
|
| 83 | 83 | { |
| 84 | 84 | // if PHP exception, we want to show the 2nd stack level context |
| 85 | 85 | // because the 1st stack level is of little use (it's in error handler) |
| 86 | - if(isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
| 86 | + if (isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line'])) |
|
| 87 | 87 | { |
| 88 | 88 | $data['file'] = $trace[0]['file']; |
| 89 | 89 | $data['line'] = $trace[0]['line']; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | $data['type'] = get_class($exception); |
| 93 | 93 | $data['message'] = $exception->getMessage(); |
| 94 | - $data['version'] = $_SERVER['SERVER_SOFTWARE'] . ' ' . Prado::getVersion(); |
|
| 94 | + $data['version'] = $_SERVER['SERVER_SOFTWARE'].' '.Prado::getVersion(); |
|
| 95 | 95 | $data['time'] = @strftime('%Y-%m-%d %H:%M', time()); |
| 96 | 96 | return $data; |
| 97 | 97 | } |