@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid. |
| 201 | 201 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 202 | 202 | */ |
| 203 | - public function set($id,$value,$expire=0,$dependency=null); |
|
| 203 | + public function set($id, $value, $expire = 0, $dependency = null); |
|
| 204 | 204 | /** |
| 205 | 205 | * Stores a value identified by a key into cache if the cache does not contain this key. |
| 206 | 206 | * Nothing will be done if the cache already contains the key. |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid. |
| 211 | 211 | * @return boolean true if the value is successfully stored into cache, false otherwise |
| 212 | 212 | */ |
| 213 | - public function add($id,$value,$expire=0,$dependency=null); |
|
| 213 | + public function add($id, $value, $expire = 0, $dependency = null); |
|
| 214 | 214 | /** |
| 215 | 215 | * Deletes a value with the specified key from cache |
| 216 | 216 | * @param string the key of the value to be deleted |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * Includes the PradoBase class file |
| 22 | 22 | */ |
| 23 | -require_once(dirname(__FILE__).'/PradoBase.php'); |
|
| 23 | +require_once(dirname(__FILE__) . '/PradoBase.php'); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Defines Prado class if not defined. |
| 27 | 27 | */ |
| 28 | -if(!class_exists('Prado',false)) |
|
| 28 | +if (!class_exists('Prado', false)) |
|
| 29 | 29 | { |
| 30 | 30 | /** |
| 31 | 31 | * Prado class. |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * cannot be found, if you have multiple autoloaders, Prado::autoload |
| 46 | 46 | * should be registered in the last. |
| 47 | 47 | */ |
| 48 | -spl_autoload_register(array('Prado','autoload')); |
|
| 48 | +spl_autoload_register(array('Prado', 'autoload')); |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Initializes error and exception handlers |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Includes TApplication class file |
| 57 | 57 | */ |
| 58 | -require_once(dirname(__FILE__).'/TApplication.php'); |
|
| 58 | +require_once(dirname(__FILE__) . '/TApplication.php'); |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Includes TShellApplication class file |
| 62 | 62 | */ |
| 63 | -require_once(dirname(__FILE__).'/TShellApplication.php'); |
|
| 63 | +require_once(dirname(__FILE__) . '/TShellApplication.php'); |
|
| 64 | 64 | |
@@ -52,20 +52,20 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * error template file basename |
| 54 | 54 | */ |
| 55 | - const ERROR_FILE_NAME='error'; |
|
| 55 | + const ERROR_FILE_NAME = 'error'; |
|
| 56 | 56 | /** |
| 57 | 57 | * exception template file basename |
| 58 | 58 | */ |
| 59 | - const EXCEPTION_FILE_NAME='exception'; |
|
| 59 | + const EXCEPTION_FILE_NAME = 'exception'; |
|
| 60 | 60 | /** |
| 61 | 61 | * number of lines before and after the error line to be displayed in case of an exception |
| 62 | 62 | */ |
| 63 | - const SOURCE_LINES=12; |
|
| 63 | + const SOURCE_LINES = 12; |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * @var string error template directory |
| 67 | 67 | */ |
| 68 | - private $_templatePath=null; |
|
| 68 | + private $_templatePath = null; |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Initializes the module. |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function getErrorTemplatePath() |
| 84 | 84 | { |
| 85 | - if($this->_templatePath===null) |
|
| 86 | - $this->_templatePath=Prado::getFrameworkPath().'/Exceptions/templates'; |
|
| 85 | + if ($this->_templatePath === null) |
|
| 86 | + $this->_templatePath = Prado::getFrameworkPath() . '/Exceptions/templates'; |
|
| 87 | 87 | return $this->_templatePath; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function setErrorTemplatePath($value) |
| 97 | 97 | { |
| 98 | - if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath)) |
|
| 99 | - $this->_templatePath=$templatePath; |
|
| 98 | + if (($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath)) |
|
| 99 | + $this->_templatePath = $templatePath; |
|
| 100 | 100 | else |
| 101 | - throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value); |
|
| 101 | + throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -110,30 +110,30 @@ discard block |
||
| 110 | 110 | * @param mixed sender of the event |
| 111 | 111 | * @param mixed event parameter (if the event is raised by TApplication, it refers to the exception instance) |
| 112 | 112 | */ |
| 113 | - public function handleError($sender,$param) |
|
| 113 | + public function handleError($sender, $param) |
|
| 114 | 114 | { |
| 115 | - static $handling=false; |
|
| 115 | + static $handling = false; |
|
| 116 | 116 | // We need to restore error and exception handlers, |
| 117 | 117 | // because within error and exception handlers, new errors and exceptions |
| 118 | 118 | // cannot be handled properly by PHP |
| 119 | 119 | restore_error_handler(); |
| 120 | 120 | restore_exception_handler(); |
| 121 | 121 | // ensure that we do not enter infinite loop of error handling |
| 122 | - if($handling) |
|
| 122 | + if ($handling) |
|
| 123 | 123 | $this->handleRecursiveError($param); |
| 124 | 124 | else |
| 125 | 125 | { |
| 126 | - $handling=true; |
|
| 127 | - if(($response=$this->getResponse())!==null) |
|
| 126 | + $handling = true; |
|
| 127 | + if (($response = $this->getResponse()) !== null) |
|
| 128 | 128 | $response->clear(); |
| 129 | - if(!headers_sent()) |
|
| 129 | + if (!headers_sent()) |
|
| 130 | 130 | header('Content-Type: text/html; charset=UTF-8'); |
| 131 | - if($param instanceof THttpException) |
|
| 132 | - $this->handleExternalError($param->getStatusCode(),$param); |
|
| 133 | - else if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 131 | + if ($param instanceof THttpException) |
|
| 132 | + $this->handleExternalError($param->getStatusCode(), $param); |
|
| 133 | + else if ($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 134 | 134 | $this->displayException($param); |
| 135 | 135 | else |
| 136 | - $this->handleExternalError(500,$param); |
|
| 136 | + $this->handleExternalError(500, $param); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
@@ -144,22 +144,22 @@ discard block |
||
| 144 | 144 | * @return string |
| 145 | 145 | * @since 3.1.6 |
| 146 | 146 | */ |
| 147 | - protected static function hideSecurityRelated($value, $exception=null) |
|
| 147 | + protected static function hideSecurityRelated($value, $exception = null) |
|
| 148 | 148 | { |
| 149 | 149 | $aRpl = array(); |
| 150 | - if($exception !== null && $exception instanceof Exception) |
|
| 150 | + if ($exception !== null && $exception instanceof Exception) |
|
| 151 | 151 | { |
| 152 | 152 | $aTrace = $exception->getTrace(); |
| 153 | - foreach($aTrace as $item) |
|
| 153 | + foreach ($aTrace as $item) |
|
| 154 | 154 | { |
| 155 | - if(isset($item['file'])) |
|
| 155 | + if (isset($item['file'])) |
|
| 156 | 156 | $aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR; |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | $aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}'; |
| 160 | 160 | $aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}'; |
| 161 | 161 | $aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR; |
| 162 | - if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
|
| 162 | + if (isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]); |
|
| 163 | 163 | $aRpl = array_reverse($aRpl, true); |
| 164 | 164 | |
| 165 | 165 | return str_replace(array_keys($aRpl), $aRpl, $value); |
@@ -172,36 +172,36 @@ discard block |
||
| 172 | 172 | * @param integer response status code |
| 173 | 173 | * @param Exception exception instance |
| 174 | 174 | */ |
| 175 | - protected function handleExternalError($statusCode,$exception) |
|
| 175 | + protected function handleExternalError($statusCode, $exception) |
|
| 176 | 176 | { |
| 177 | - if(!($exception instanceof THttpException)) |
|
| 177 | + if (!($exception instanceof THttpException)) |
|
| 178 | 178 | error_log($exception->__toString()); |
| 179 | 179 | |
| 180 | - $content=$this->getErrorTemplate($statusCode,$exception); |
|
| 180 | + $content = $this->getErrorTemplate($statusCode, $exception); |
|
| 181 | 181 | |
| 182 | - $serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:''; |
|
| 182 | + $serverAdmin = isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : ''; |
|
| 183 | 183 | |
| 184 | - $isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug; |
|
| 184 | + $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; |
|
| 185 | 185 | |
| 186 | 186 | $errorMessage = $exception->getMessage(); |
| 187 | - if($isDebug) |
|
| 188 | - $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
|
| 187 | + if ($isDebug) |
|
| 188 | + $version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion(); |
|
| 189 | 189 | else |
| 190 | 190 | { |
| 191 | - $version=''; |
|
| 191 | + $version = ''; |
|
| 192 | 192 | $errorMessage = self::hideSecurityRelated($errorMessage, $exception); |
| 193 | 193 | } |
| 194 | - $tokens=array( |
|
| 194 | + $tokens = array( |
|
| 195 | 195 | '%%StatusCode%%' => "$statusCode", |
| 196 | 196 | '%%ErrorMessage%%' => htmlspecialchars($errorMessage), |
| 197 | 197 | '%%ServerAdmin%%' => $serverAdmin, |
| 198 | 198 | '%%Version%%' => $version, |
| 199 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
| 199 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | 202 | $this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null); |
| 203 | 203 | |
| 204 | - echo strtr($content,$tokens); |
|
| 204 | + echo strtr($content, $tokens); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -213,16 +213,16 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | protected function handleRecursiveError($exception) |
| 215 | 215 | { |
| 216 | - if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 216 | + if ($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 217 | 217 | { |
| 218 | 218 | echo "<html><head><title>Recursive Error</title></head>\n"; |
| 219 | 219 | echo "<body><h1>Recursive Error</h1>\n"; |
| 220 | - echo "<pre>".$exception->__toString()."</pre>\n"; |
|
| 220 | + echo "<pre>" . $exception->__toString() . "</pre>\n"; |
|
| 221 | 221 | echo "</body></html>"; |
| 222 | 222 | } |
| 223 | 223 | else |
| 224 | 224 | { |
| 225 | - error_log("Error happened while processing an existing error:\n".$exception->__toString()); |
|
| 225 | + error_log("Error happened while processing an existing error:\n" . $exception->__toString()); |
|
| 226 | 226 | header('HTTP/1.0 500 Internal Error'); |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -236,55 +236,55 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function displayException($exception) |
| 238 | 238 | { |
| 239 | - if(php_sapi_name()==='cli') |
|
| 239 | + if (php_sapi_name() === 'cli') |
|
| 240 | 240 | { |
| 241 | - echo $exception->getMessage()."\n"; |
|
| 241 | + echo $exception->getMessage() . "\n"; |
|
| 242 | 242 | echo $exception->getTraceAsString(); |
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if($exception instanceof TTemplateException) |
|
| 246 | + if ($exception instanceof TTemplateException) |
|
| 247 | 247 | { |
| 248 | - $fileName=$exception->getTemplateFile(); |
|
| 249 | - $lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName); |
|
| 250 | - $source=$this->getSourceCode($lines,$exception->getLineNumber()); |
|
| 251 | - if($fileName==='') |
|
| 252 | - $fileName='---embedded template---'; |
|
| 253 | - $errorLine=$exception->getLineNumber(); |
|
| 248 | + $fileName = $exception->getTemplateFile(); |
|
| 249 | + $lines = empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName); |
|
| 250 | + $source = $this->getSourceCode($lines, $exception->getLineNumber()); |
|
| 251 | + if ($fileName === '') |
|
| 252 | + $fileName = '---embedded template---'; |
|
| 253 | + $errorLine = $exception->getLineNumber(); |
|
| 254 | 254 | } |
| 255 | 255 | else |
| 256 | 256 | { |
| 257 | - if(($trace=$this->getExactTrace($exception))!==null) |
|
| 257 | + if (($trace = $this->getExactTrace($exception)) !== null) |
|
| 258 | 258 | { |
| 259 | - $fileName=$trace['file']; |
|
| 260 | - $errorLine=$trace['line']; |
|
| 259 | + $fileName = $trace['file']; |
|
| 260 | + $errorLine = $trace['line']; |
|
| 261 | 261 | } |
| 262 | 262 | else |
| 263 | 263 | { |
| 264 | - $fileName=$exception->getFile(); |
|
| 265 | - $errorLine=$exception->getLine(); |
|
| 264 | + $fileName = $exception->getFile(); |
|
| 265 | + $errorLine = $exception->getLine(); |
|
| 266 | 266 | } |
| 267 | - $source=$this->getSourceCode(@file($fileName),$errorLine); |
|
| 267 | + $source = $this->getSourceCode(@file($fileName), $errorLine); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if($this->getApplication()->getMode()===TApplicationMode::Debug) |
|
| 271 | - $version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion(); |
|
| 270 | + if ($this->getApplication()->getMode() === TApplicationMode::Debug) |
|
| 271 | + $version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion(); |
|
| 272 | 272 | else |
| 273 | - $version=''; |
|
| 273 | + $version = ''; |
|
| 274 | 274 | |
| 275 | - $tokens=array( |
|
| 275 | + $tokens = array( |
|
| 276 | 276 | '%%ErrorType%%' => get_class($exception), |
| 277 | 277 | '%%ErrorMessage%%' => $this->addLink(htmlspecialchars($exception->getMessage())), |
| 278 | - '%%SourceFile%%' => htmlspecialchars($fileName).' ('.$errorLine.')', |
|
| 278 | + '%%SourceFile%%' => htmlspecialchars($fileName) . ' (' . $errorLine . ')', |
|
| 279 | 279 | '%%SourceCode%%' => $source, |
| 280 | 280 | '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()), |
| 281 | 281 | '%%Version%%' => $version, |
| 282 | - '%%Time%%' => @strftime('%Y-%m-%d %H:%M',time()) |
|
| 282 | + '%%Time%%' => @strftime('%Y-%m-%d %H:%M', time()) |
|
| 283 | 283 | ); |
| 284 | 284 | |
| 285 | - $content=$this->getExceptionTemplate($exception); |
|
| 285 | + $content = $this->getExceptionTemplate($exception); |
|
| 286 | 286 | |
| 287 | - echo strtr($content,$tokens); |
|
| 287 | + echo strtr($content, $tokens); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -296,11 +296,11 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | protected function getExceptionTemplate($exception) |
| 298 | 298 | { |
| 299 | - $lang=Prado::getPreferredLanguage(); |
|
| 300 | - $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'-'.$lang.'.html'; |
|
| 301 | - if(!is_file($exceptionFile)) |
|
| 302 | - $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html'; |
|
| 303 | - if(($content=@file_get_contents($exceptionFile))===false) |
|
| 299 | + $lang = Prado::getPreferredLanguage(); |
|
| 300 | + $exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '-' . $lang . '.html'; |
|
| 301 | + if (!is_file($exceptionFile)) |
|
| 302 | + $exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '.html'; |
|
| 303 | + if (($content = @file_get_contents($exceptionFile)) === false) |
|
| 304 | 304 | die("Unable to open exception template file '$exceptionFile'."); |
| 305 | 305 | return $content; |
| 306 | 306 | } |
@@ -321,84 +321,84 @@ discard block |
||
| 321 | 321 | * @param Exception the exception to be displayed |
| 322 | 322 | * @return string the template content |
| 323 | 323 | */ |
| 324 | - protected function getErrorTemplate($statusCode,$exception) |
|
| 324 | + protected function getErrorTemplate($statusCode, $exception) |
|
| 325 | 325 | { |
| 326 | - $base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME; |
|
| 327 | - $lang=Prado::getPreferredLanguage(); |
|
| 328 | - if(is_file("$base$statusCode-$lang.html")) |
|
| 329 | - $errorFile="$base$statusCode-$lang.html"; |
|
| 330 | - else if(is_file("$base$statusCode.html")) |
|
| 331 | - $errorFile="$base$statusCode.html"; |
|
| 332 | - else if(is_file("$base-$lang.html")) |
|
| 333 | - $errorFile="$base-$lang.html"; |
|
| 326 | + $base = $this->getErrorTemplatePath() . DIRECTORY_SEPARATOR . self::ERROR_FILE_NAME; |
|
| 327 | + $lang = Prado::getPreferredLanguage(); |
|
| 328 | + if (is_file("$base$statusCode-$lang.html")) |
|
| 329 | + $errorFile = "$base$statusCode-$lang.html"; |
|
| 330 | + else if (is_file("$base$statusCode.html")) |
|
| 331 | + $errorFile = "$base$statusCode.html"; |
|
| 332 | + else if (is_file("$base-$lang.html")) |
|
| 333 | + $errorFile = "$base-$lang.html"; |
|
| 334 | 334 | else |
| 335 | - $errorFile="$base.html"; |
|
| 336 | - if(($content=@file_get_contents($errorFile))===false) |
|
| 335 | + $errorFile = "$base.html"; |
|
| 336 | + if (($content = @file_get_contents($errorFile)) === false) |
|
| 337 | 337 | die("Unable to open error template file '$errorFile'."); |
| 338 | 338 | return $content; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | private function getExactTrace($exception) |
| 342 | 342 | { |
| 343 | - $trace=$exception->getTrace(); |
|
| 344 | - $result=null; |
|
| 343 | + $trace = $exception->getTrace(); |
|
| 344 | + $result = null; |
|
| 345 | 345 | // if PHP exception, we want to show the 2nd stack level context |
| 346 | 346 | // because the 1st stack level is of little use (it's in error handler) |
| 347 | - if($exception instanceof TPhpErrorException) |
|
| 347 | + if ($exception instanceof TPhpErrorException) |
|
| 348 | 348 | { |
| 349 | - if(isset($trace[0]['file'])) |
|
| 350 | - $result=$trace[0]; |
|
| 351 | - elseif(isset($trace[1])) |
|
| 352 | - $result=$trace[1]; |
|
| 349 | + if (isset($trace[0]['file'])) |
|
| 350 | + $result = $trace[0]; |
|
| 351 | + elseif (isset($trace[1])) |
|
| 352 | + $result = $trace[1]; |
|
| 353 | 353 | } |
| 354 | - else if($exception instanceof TInvalidOperationException) |
|
| 354 | + else if ($exception instanceof TInvalidOperationException) |
|
| 355 | 355 | { |
| 356 | 356 | // in case of getter or setter error, find out the exact file and row |
| 357 | - if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) |
|
| 358 | - $result=$this->getPropertyAccessTrace($trace,'__set'); |
|
| 357 | + if (($result = $this->getPropertyAccessTrace($trace, '__get')) === null) |
|
| 358 | + $result = $this->getPropertyAccessTrace($trace, '__set'); |
|
| 359 | 359 | } |
| 360 | - if($result!==null && strpos($result['file'],': eval()\'d code')!==false) |
|
| 360 | + if ($result !== null && strpos($result['file'], ': eval()\'d code') !== false) |
|
| 361 | 361 | return null; |
| 362 | 362 | |
| 363 | 363 | return $result; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - private function getPropertyAccessTrace($trace,$pattern) |
|
| 366 | + private function getPropertyAccessTrace($trace, $pattern) |
|
| 367 | 367 | { |
| 368 | - $result=null; |
|
| 369 | - foreach($trace as $t) |
|
| 368 | + $result = null; |
|
| 369 | + foreach ($trace as $t) |
|
| 370 | 370 | { |
| 371 | - if(isset($t['function']) && $t['function']===$pattern) |
|
| 372 | - $result=$t; |
|
| 371 | + if (isset($t['function']) && $t['function'] === $pattern) |
|
| 372 | + $result = $t; |
|
| 373 | 373 | else |
| 374 | 374 | break; |
| 375 | 375 | } |
| 376 | 376 | return $result; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - private function getSourceCode($lines,$errorLine) |
|
| 379 | + private function getSourceCode($lines, $errorLine) |
|
| 380 | 380 | { |
| 381 | - $beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0; |
|
| 382 | - $endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines); |
|
| 381 | + $beginLine = $errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0; |
|
| 382 | + $endLine = $errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines); |
|
| 383 | 383 | |
| 384 | - $source=''; |
|
| 385 | - for($i=$beginLine;$i<$endLine;++$i) |
|
| 384 | + $source = ''; |
|
| 385 | + for ($i = $beginLine; $i < $endLine; ++$i) |
|
| 386 | 386 | { |
| 387 | - if($i===$errorLine-1) |
|
| 387 | + if ($i === $errorLine - 1) |
|
| 388 | 388 | { |
| 389 | - $line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
| 390 | - $source.="<div class=\"error\">".$line."</div>"; |
|
| 389 | + $line = htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
| 390 | + $source .= "<div class=\"error\">" . $line . "</div>"; |
|
| 391 | 391 | } |
| 392 | 392 | else |
| 393 | - $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i]))); |
|
| 393 | + $source .= htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", ' ', $lines[$i]))); |
|
| 394 | 394 | } |
| 395 | 395 | return $source; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | private function addLink($message) |
| 399 | 399 | { |
| 400 | - $baseUrl='http://pradosoft.github.io/docs/manual/class-'; |
|
| 401 | - return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>",$message); |
|
| 400 | + $baseUrl = 'http://pradosoft.github.io/docs/manual/class-'; |
|
| 401 | + return preg_replace('/\b(T[A-Z]\w+)\b/', "<a href=\"$baseUrl\${1}\" target=\"_blank\">\${1}</a>", $message); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | class TException extends Exception |
| 34 | 34 | { |
| 35 | - private $_errorCode=''; |
|
| 36 | - static $_messageCache=array(); |
|
| 35 | + private $_errorCode = ''; |
|
| 36 | + static $_messageCache = array(); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Constructor. |
@@ -44,15 +44,15 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function __construct($errorMessage) |
| 46 | 46 | { |
| 47 | - $this->_errorCode=$errorMessage; |
|
| 48 | - $errorMessage=$this->translateErrorMessage($errorMessage); |
|
| 49 | - $args=func_get_args(); |
|
| 47 | + $this->_errorCode = $errorMessage; |
|
| 48 | + $errorMessage = $this->translateErrorMessage($errorMessage); |
|
| 49 | + $args = func_get_args(); |
|
| 50 | 50 | array_shift($args); |
| 51 | - $n=count($args); |
|
| 52 | - $tokens=array(); |
|
| 53 | - for($i=0;$i<$n;++$i) |
|
| 54 | - $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
|
| 55 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
| 51 | + $n = count($args); |
|
| 52 | + $tokens = array(); |
|
| 53 | + for ($i = 0; $i < $n; ++$i) |
|
| 54 | + $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]); |
|
| 55 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -62,17 +62,17 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | protected function translateErrorMessage($key) |
| 64 | 64 | { |
| 65 | - $msgFile=$this->getErrorMessageFile(); |
|
| 65 | + $msgFile = $this->getErrorMessageFile(); |
|
| 66 | 66 | |
| 67 | 67 | // Cache messages |
| 68 | 68 | if (!isset(self::$_messageCache[$msgFile])) |
| 69 | 69 | { |
| 70 | - if(($entries=@file($msgFile))!==false) |
|
| 70 | + if (($entries = @file($msgFile)) !== false) |
|
| 71 | 71 | { |
| 72 | - foreach($entries as $entry) |
|
| 72 | + foreach ($entries as $entry) |
|
| 73 | 73 | { |
| 74 | - @list($code,$message)=explode('=',$entry,2); |
|
| 75 | - self::$_messageCache[$msgFile][trim($code)]=trim($message); |
|
| 74 | + @list($code, $message) = explode('=', $entry, 2); |
|
| 75 | + self::$_messageCache[$msgFile][trim($code)] = trim($message); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | protected function getErrorMessageFile() |
| 86 | 86 | { |
| 87 | - $lang=Prado::getPreferredLanguage(); |
|
| 88 | - $msgFile=Prado::getFrameworkPath().'/Exceptions/messages/messages-'.$lang.'.txt'; |
|
| 89 | - if(!is_file($msgFile)) |
|
| 90 | - $msgFile=Prado::getFrameworkPath().'/Exceptions/messages/messages.txt'; |
|
| 87 | + $lang = Prado::getPreferredLanguage(); |
|
| 88 | + $msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages-' . $lang . '.txt'; |
|
| 89 | + if (!is_file($msgFile)) |
|
| 90 | + $msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages.txt'; |
|
| 91 | 91 | return $msgFile; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function setErrorCode($code) |
| 106 | 106 | { |
| 107 | - $this->_errorCode=$code; |
|
| 107 | + $this->_errorCode = $code; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function setErrorMessage($message) |
| 122 | 122 | { |
| 123 | - $this->message=$message; |
|
| 123 | + $this->message = $message; |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | class TTemplateException extends TConfigurationException |
| 216 | 216 | { |
| 217 | - private $_template=''; |
|
| 218 | - private $_lineNumber=0; |
|
| 219 | - private $_fileName=''; |
|
| 217 | + private $_template = ''; |
|
| 218 | + private $_lineNumber = 0; |
|
| 219 | + private $_fileName = ''; |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * @return string the template source code that causes the exception. This is empty if {@link getTemplateFile TemplateFile} is not empty. |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function setTemplateSource($value) |
| 233 | 233 | { |
| 234 | - $this->_template=$value; |
|
| 234 | + $this->_template = $value; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | public function setTemplateFile($value) |
| 249 | 249 | { |
| 250 | - $this->_fileName=$value; |
|
| 250 | + $this->_fileName = $value; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | public function setLineNumber($value) |
| 265 | 265 | { |
| 266 | - $this->_lineNumber=TPropertyValue::ensureInteger($value); |
|
| 266 | + $this->_lineNumber = TPropertyValue::ensureInteger($value); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | * @param string error file |
| 339 | 339 | * @param integer error line number |
| 340 | 340 | */ |
| 341 | - public function __construct($errno,$errstr,$errfile,$errline) |
|
| 341 | + public function __construct($errno, $errstr, $errfile, $errline) |
|
| 342 | 342 | { |
| 343 | - static $errorTypes=array( |
|
| 343 | + static $errorTypes = array( |
|
| 344 | 344 | E_ERROR => "Error", |
| 345 | 345 | E_WARNING => "Warning", |
| 346 | 346 | E_PARSE => "Parsing Error", |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | E_USER_NOTICE => "User Notice", |
| 355 | 355 | E_STRICT => "Runtime Notice" |
| 356 | 356 | ); |
| 357 | - $errorType=isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error'; |
|
| 357 | + $errorType = isset($errorTypes[$errno]) ? $errorTypes[$errno] : 'Unknown Error'; |
|
| 358 | 358 | parent::__construct("[$errorType] $errstr (@line $errline in file $errfile)."); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -394,19 +394,19 @@ discard block |
||
| 394 | 394 | * will be used as the error message. Any rest parameters will be used |
| 395 | 395 | * to replace placeholders ({0}, {1}, {2}, etc.) in the message. |
| 396 | 396 | */ |
| 397 | - public function __construct($statusCode,$errorMessage) |
|
| 397 | + public function __construct($statusCode, $errorMessage) |
|
| 398 | 398 | { |
| 399 | - $this->_statusCode=$statusCode; |
|
| 399 | + $this->_statusCode = $statusCode; |
|
| 400 | 400 | $this->setErrorCode($errorMessage); |
| 401 | - $errorMessage=$this->translateErrorMessage($errorMessage); |
|
| 402 | - $args=func_get_args(); |
|
| 401 | + $errorMessage = $this->translateErrorMessage($errorMessage); |
|
| 402 | + $args = func_get_args(); |
|
| 403 | 403 | array_shift($args); |
| 404 | 404 | array_shift($args); |
| 405 | - $n=count($args); |
|
| 406 | - $tokens=array(); |
|
| 407 | - for($i=0;$i<$n;++$i) |
|
| 408 | - $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]); |
|
| 409 | - parent::__construct(strtr($errorMessage,$tokens)); |
|
| 405 | + $n = count($args); |
|
| 406 | + $tokens = array(); |
|
| 407 | + for ($i = 0; $i < $n; ++$i) |
|
| 408 | + $tokens['{' . $i . '}'] = TPropertyValue::ensureString($args[$i]); |
|
| 409 | + parent::__construct(strtr($errorMessage, $tokens)); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -26,32 +26,32 @@ discard block |
||
| 26 | 26 | * @package System.Collections |
| 27 | 27 | * @since 3.0 |
| 28 | 28 | */ |
| 29 | -class TPagedDataSource extends TComponent implements IteratorAggregate,Countable |
|
| 29 | +class TPagedDataSource extends TComponent implements IteratorAggregate, Countable |
|
| 30 | 30 | { |
| 31 | 31 | /** |
| 32 | 32 | * @var mixed original data source |
| 33 | 33 | */ |
| 34 | - private $_dataSource=null; |
|
| 34 | + private $_dataSource = null; |
|
| 35 | 35 | /** |
| 36 | 36 | * @var integer number of items in each page |
| 37 | 37 | */ |
| 38 | - private $_pageSize=10; |
|
| 38 | + private $_pageSize = 10; |
|
| 39 | 39 | /** |
| 40 | 40 | * @var integer current page index |
| 41 | 41 | */ |
| 42 | - private $_currentPageIndex=0; |
|
| 42 | + private $_currentPageIndex = 0; |
|
| 43 | 43 | /** |
| 44 | 44 | * @var boolean whether to allow paging |
| 45 | 45 | */ |
| 46 | - private $_allowPaging=false; |
|
| 46 | + private $_allowPaging = false; |
|
| 47 | 47 | /** |
| 48 | 48 | * @var boolean whether to allow custom paging |
| 49 | 49 | */ |
| 50 | - private $_allowCustomPaging=false; |
|
| 50 | + private $_allowCustomPaging = false; |
|
| 51 | 51 | /** |
| 52 | 52 | * @var integer user-assigned number of items in data source |
| 53 | 53 | */ |
| 54 | - private $_virtualCount=0; |
|
| 54 | + private $_virtualCount = 0; |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @return mixed original data source. Defaults to null. |
@@ -66,16 +66,16 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function setDataSource($value) |
| 68 | 68 | { |
| 69 | - if(!($value instanceof TMap) && !($value instanceof TList)) |
|
| 69 | + if (!($value instanceof TMap) && !($value instanceof TList)) |
|
| 70 | 70 | { |
| 71 | - if(is_array($value)) |
|
| 72 | - $value=new TMap($value); |
|
| 73 | - else if($value instanceof Traversable) |
|
| 74 | - $value=new TList($value); |
|
| 75 | - else if($value!==null) |
|
| 71 | + if (is_array($value)) |
|
| 72 | + $value = new TMap($value); |
|
| 73 | + else if ($value instanceof Traversable) |
|
| 74 | + $value = new TList($value); |
|
| 75 | + else if ($value !== null) |
|
| 76 | 76 | throw new TInvalidDataTypeException('pageddatasource_datasource_invalid'); |
| 77 | 77 | } |
| 78 | - $this->_dataSource=$value; |
|
| 78 | + $this->_dataSource = $value; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function setPageSize($value) |
| 93 | 93 | { |
| 94 | - if(($value=TPropertyValue::ensureInteger($value))>0) |
|
| 95 | - $this->_pageSize=$value; |
|
| 94 | + if (($value = TPropertyValue::ensureInteger($value)) > 0) |
|
| 95 | + $this->_pageSize = $value; |
|
| 96 | 96 | else |
| 97 | 97 | throw new TInvalidDataValueException('pageddatasource_pagesize_invalid'); |
| 98 | 98 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function setCurrentPageIndex($value) |
| 112 | 112 | { |
| 113 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
| 114 | - $value=0; |
|
| 115 | - $this->_currentPageIndex=$value; |
|
| 113 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
| 114 | + $value = 0; |
|
| 115 | + $this->_currentPageIndex = $value; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function setAllowPaging($value) |
| 130 | 130 | { |
| 131 | - $this->_allowPaging=TPropertyValue::ensureBoolean($value); |
|
| 131 | + $this->_allowPaging = TPropertyValue::ensureBoolean($value); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function setAllowCustomPaging($value) |
| 146 | 146 | { |
| 147 | - $this->_allowCustomPaging=TPropertyValue::ensureBoolean($value); |
|
| 147 | + $this->_allowCustomPaging = TPropertyValue::ensureBoolean($value); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function setVirtualItemCount($value) |
| 162 | 162 | { |
| 163 | - if(($value=TPropertyValue::ensureInteger($value))>=0) |
|
| 164 | - $this->_virtualCount=$value; |
|
| 163 | + if (($value = TPropertyValue::ensureInteger($value)) >= 0) |
|
| 164 | + $this->_virtualCount = $value; |
|
| 165 | 165 | else |
| 166 | 166 | throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid'); |
| 167 | 167 | } |
@@ -171,12 +171,12 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function getCount() |
| 173 | 173 | { |
| 174 | - if($this->_dataSource===null) |
|
| 174 | + if ($this->_dataSource === null) |
|
| 175 | 175 | return 0; |
| 176 | - if(!$this->_allowPaging) |
|
| 176 | + if (!$this->_allowPaging) |
|
| 177 | 177 | return $this->getDataSourceCount(); |
| 178 | - if(!$this->_allowCustomPaging && $this->getIsLastPage()) |
|
| 179 | - return $this->getDataSourceCount()-$this->getFirstIndexInPage(); |
|
| 178 | + if (!$this->_allowCustomPaging && $this->getIsLastPage()) |
|
| 179 | + return $this->getDataSourceCount() - $this->getFirstIndexInPage(); |
|
| 180 | 180 | return $this->_pageSize; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function getPageCount() |
| 197 | 197 | { |
| 198 | - if($this->_dataSource===null) |
|
| 198 | + if ($this->_dataSource === null) |
|
| 199 | 199 | return 0; |
| 200 | - $count=$this->getDataSourceCount(); |
|
| 201 | - if(!$this->_allowPaging || $count<=0) |
|
| 200 | + $count = $this->getDataSourceCount(); |
|
| 201 | + if (!$this->_allowPaging || $count <= 0) |
|
| 202 | 202 | return 1; |
| 203 | - return (int)(($count+$this->_pageSize-1)/$this->_pageSize); |
|
| 203 | + return (int) (($count + $this->_pageSize - 1) / $this->_pageSize); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function getIsFirstPage() |
| 210 | 210 | { |
| 211 | - if($this->_allowPaging) |
|
| 212 | - return $this->_currentPageIndex===0; |
|
| 211 | + if ($this->_allowPaging) |
|
| 212 | + return $this->_currentPageIndex === 0; |
|
| 213 | 213 | else |
| 214 | 214 | return true; |
| 215 | 215 | } |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function getIsLastPage() |
| 221 | 221 | { |
| 222 | - if($this->_allowPaging) |
|
| 223 | - return $this->_currentPageIndex===$this->getPageCount()-1; |
|
| 222 | + if ($this->_allowPaging) |
|
| 223 | + return $this->_currentPageIndex === $this->getPageCount() - 1; |
|
| 224 | 224 | else |
| 225 | 225 | return true; |
| 226 | 226 | } |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function getFirstIndexInPage() |
| 233 | 233 | { |
| 234 | - if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging) |
|
| 235 | - return $this->_currentPageIndex*$this->_pageSize; |
|
| 234 | + if ($this->_dataSource !== null && $this->_allowPaging && !$this->_allowCustomPaging) |
|
| 235 | + return $this->_currentPageIndex * $this->_pageSize; |
|
| 236 | 236 | else |
| 237 | 237 | return 0; |
| 238 | 238 | } |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | public function getDataSourceCount() |
| 244 | 244 | { |
| 245 | - if($this->_dataSource===null) |
|
| 245 | + if ($this->_dataSource === null) |
|
| 246 | 246 | return 0; |
| 247 | - else if($this->_allowCustomPaging) |
|
| 247 | + else if ($this->_allowCustomPaging) |
|
| 248 | 248 | return $this->_virtualCount; |
| 249 | 249 | else |
| 250 | 250 | return $this->_dataSource->getCount(); |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | public function getIterator() |
| 257 | 257 | { |
| 258 | - if($this->_dataSource instanceof TList) |
|
| 259 | - return new TPagedListIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount()); |
|
| 260 | - else if($this->_dataSource instanceof TMap) |
|
| 261 | - return new TPagedMapIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount()); |
|
| 258 | + if ($this->_dataSource instanceof TList) |
|
| 259 | + return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount()); |
|
| 260 | + else if ($this->_dataSource instanceof TMap) |
|
| 261 | + return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount()); |
|
| 262 | 262 | else |
| 263 | 263 | return null; |
| 264 | 264 | } |
@@ -291,15 +291,15 @@ discard block |
||
| 291 | 291 | * @param integer start index |
| 292 | 292 | * @param integer number of items to be iterated through |
| 293 | 293 | */ |
| 294 | - public function __construct(TList $list,$startIndex,$count) |
|
| 294 | + public function __construct(TList $list, $startIndex, $count) |
|
| 295 | 295 | { |
| 296 | - $this->_list=$list; |
|
| 297 | - $this->_index=0; |
|
| 298 | - $this->_startIndex=$startIndex; |
|
| 299 | - if($startIndex+$count>$list->getCount()) |
|
| 300 | - $this->_count=$list->getCount()-$startIndex; |
|
| 296 | + $this->_list = $list; |
|
| 297 | + $this->_index = 0; |
|
| 298 | + $this->_startIndex = $startIndex; |
|
| 299 | + if ($startIndex + $count > $list->getCount()) |
|
| 300 | + $this->_count = $list->getCount() - $startIndex; |
|
| 301 | 301 | else |
| 302 | - $this->_count=$count; |
|
| 302 | + $this->_count = $count; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | public function rewind() |
| 310 | 310 | { |
| 311 | - $this->_index=0; |
|
| 311 | + $this->_index = 0; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | public function current() |
| 330 | 330 | { |
| 331 | - return $this->_list->itemAt($this->_startIndex+$this->_index); |
|
| 331 | + return $this->_list->itemAt($this->_startIndex + $this->_index); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | public function valid() |
| 349 | 349 | { |
| 350 | - return $this->_index<$this->_count; |
|
| 350 | + return $this->_index < $this->_count; |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
@@ -375,16 +375,16 @@ discard block |
||
| 375 | 375 | * Constructor. |
| 376 | 376 | * @param array the data to be iterated through |
| 377 | 377 | */ |
| 378 | - public function __construct(TMap $map,$startIndex,$count) |
|
| 378 | + public function __construct(TMap $map, $startIndex, $count) |
|
| 379 | 379 | { |
| 380 | - $this->_map=$map; |
|
| 381 | - $this->_index=0; |
|
| 382 | - $this->_startIndex=$startIndex; |
|
| 383 | - if($startIndex+$count>$map->getCount()) |
|
| 384 | - $this->_count=$map->getCount()-$startIndex; |
|
| 380 | + $this->_map = $map; |
|
| 381 | + $this->_index = 0; |
|
| 382 | + $this->_startIndex = $startIndex; |
|
| 383 | + if ($startIndex + $count > $map->getCount()) |
|
| 384 | + $this->_count = $map->getCount() - $startIndex; |
|
| 385 | 385 | else |
| 386 | - $this->_count=$count; |
|
| 387 | - $this->_iterator=$map->getIterator(); |
|
| 386 | + $this->_count = $count; |
|
| 387 | + $this->_iterator = $map->getIterator(); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -394,9 +394,9 @@ discard block |
||
| 394 | 394 | public function rewind() |
| 395 | 395 | { |
| 396 | 396 | $this->_iterator->rewind(); |
| 397 | - for($i=0;$i<$this->_startIndex;++$i) |
|
| 397 | + for ($i = 0; $i < $this->_startIndex; ++$i) |
|
| 398 | 398 | $this->_iterator->next(); |
| 399 | - $this->_index=0; |
|
| 399 | + $this->_index = 0; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | public function valid() |
| 438 | 438 | { |
| 439 | - return $this->_index<$this->_count; |
|
| 439 | + return $this->_index < $this->_count; |
|
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | * @package System.Collections |
| 33 | 33 | * @since 3.1 |
| 34 | 34 | */ |
| 35 | -class TQueue extends TComponent implements IteratorAggregate,Countable |
|
| 35 | +class TQueue extends TComponent implements IteratorAggregate, Countable |
|
| 36 | 36 | { |
| 37 | 37 | /** |
| 38 | 38 | * internal data storage |
| 39 | 39 | * @var array |
| 40 | 40 | */ |
| 41 | - private $_d=array(); |
|
| 41 | + private $_d = array(); |
|
| 42 | 42 | /** |
| 43 | 43 | * number of items |
| 44 | 44 | * @var integer |
| 45 | 45 | */ |
| 46 | - private $_c=0; |
|
| 46 | + private $_c = 0; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Constructor. |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * @param array|Iterator the intial data. Default is null, meaning no initialization. |
| 52 | 52 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
| 53 | 53 | */ |
| 54 | - public function __construct($data=null) |
|
| 54 | + public function __construct($data = null) |
|
| 55 | 55 | { |
| 56 | - if($data!==null) |
|
| 56 | + if ($data !== null) |
|
| 57 | 57 | $this->copyFrom($data); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function copyFrom($data) |
| 75 | 75 | { |
| 76 | - if(is_array($data) || ($data instanceof Traversable)) |
|
| 76 | + if (is_array($data) || ($data instanceof Traversable)) |
|
| 77 | 77 | { |
| 78 | 78 | $this->clear(); |
| 79 | - foreach($data as $item) |
|
| 79 | + foreach ($data as $item) |
|
| 80 | 80 | { |
| 81 | - $this->_d[]=$item; |
|
| 81 | + $this->_d[] = $item; |
|
| 82 | 82 | ++$this->_c; |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | - else if($data!==null) |
|
| 85 | + else if ($data !== null) |
|
| 86 | 86 | throw new TInvalidDataTypeException('queue_data_not_iterable'); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function clear() |
| 93 | 93 | { |
| 94 | - $this->_c=0; |
|
| 95 | - $this->_d=array(); |
|
| 94 | + $this->_c = 0; |
|
| 95 | + $this->_d = array(); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function contains($item) |
| 103 | 103 | { |
| 104 | - return array_search($item,$this->_d,true)!==false; |
|
| 104 | + return array_search($item, $this->_d, true) !== false; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function peek() |
| 114 | 114 | { |
| 115 | - if($this->_c===0) |
|
| 115 | + if ($this->_c === 0) |
|
| 116 | 116 | throw new TInvalidOperationException('queue_empty'); |
| 117 | 117 | else |
| 118 | 118 | return $this->_d[0]; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function dequeue() |
| 127 | 127 | { |
| 128 | - if($this->_c===0) |
|
| 128 | + if ($this->_c === 0) |
|
| 129 | 129 | throw new TInvalidOperationException('queue_empty'); |
| 130 | 130 | else |
| 131 | 131 | { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function getIterator() |
| 153 | 153 | { |
| 154 | - return new ArrayIterator( $this->_d ); |
|
| 154 | + return new ArrayIterator($this->_d); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function __construct(&$data) |
| 209 | 209 | { |
| 210 | - $this->_d=&$data; |
|
| 211 | - $this->_i=0; |
|
| 212 | - $this->_c=count($this->_d); |
|
| 210 | + $this->_d = &$data; |
|
| 211 | + $this->_i = 0; |
|
| 212 | + $this->_c = count($this->_d); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function rewind() |
| 220 | 220 | { |
| 221 | - $this->_i=0; |
|
| 221 | + $this->_i = 0; |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | public function valid() |
| 259 | 259 | { |
| 260 | - return $this->_i<$this->_c; |
|
| 260 | + return $this->_i < $this->_c; |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
@@ -35,23 +35,23 @@ discard block |
||
| 35 | 35 | * If -1, the item will be appended to the end. |
| 36 | 36 | * @return TListItem list item object |
| 37 | 37 | */ |
| 38 | - public function createListItem($index=-1) |
|
| 38 | + public function createListItem($index = -1) |
|
| 39 | 39 | { |
| 40 | - $item=$this->createNewListItem(); |
|
| 41 | - if($index<0) |
|
| 40 | + $item = $this->createNewListItem(); |
|
| 41 | + if ($index < 0) |
|
| 42 | 42 | $this->add($item); |
| 43 | 43 | else |
| 44 | - $this->insertAt($index,$item); |
|
| 44 | + $this->insertAt($index, $item); |
|
| 45 | 45 | return $item; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @return TListItem new item. |
| 50 | 50 | */ |
| 51 | - protected function createNewListItem($text=null) |
|
| 51 | + protected function createNewListItem($text = null) |
|
| 52 | 52 | { |
| 53 | - $item = new TListItem; |
|
| 54 | - if($text!==null) |
|
| 53 | + $item = new TListItem; |
|
| 54 | + if ($text !== null) |
|
| 55 | 55 | $item->setText($text); |
| 56 | 56 | return $item; |
| 57 | 57 | } |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | * @param TListItem the item to be inserted. |
| 64 | 64 | * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem |
| 65 | 65 | */ |
| 66 | - public function insertAt($index,$item) |
|
| 66 | + public function insertAt($index, $item) |
|
| 67 | 67 | { |
| 68 | - if(is_string($item)) |
|
| 68 | + if (is_string($item)) |
|
| 69 | 69 | $item = $this->createNewListItem($item); |
| 70 | - if(!($item instanceof TListItem)) |
|
| 71 | - throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this)); |
|
| 72 | - parent::insertAt($index,$item); |
|
| 70 | + if (!($item instanceof TListItem)) |
|
| 71 | + throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this)); |
|
| 72 | + parent::insertAt($index, $item); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | * @param boolean whether to look for disabled items also |
| 79 | 79 | * @return integer the index of the item found, -1 if not found. |
| 80 | 80 | */ |
| 81 | - public function findIndexByValue($value,$includeDisabled=true) |
|
| 81 | + public function findIndexByValue($value, $includeDisabled = true) |
|
| 82 | 82 | { |
| 83 | - $value=TPropertyValue::ensureString($value); |
|
| 84 | - $index=0; |
|
| 85 | - foreach($this as $item) |
|
| 83 | + $value = TPropertyValue::ensureString($value); |
|
| 84 | + $index = 0; |
|
| 85 | + foreach ($this as $item) |
|
| 86 | 86 | { |
| 87 | - if($item->getValue()===$value && ($includeDisabled || $item->getEnabled())) |
|
| 87 | + if ($item->getValue() === $value && ($includeDisabled || $item->getEnabled())) |
|
| 88 | 88 | return $index; |
| 89 | 89 | $index++; |
| 90 | 90 | } |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | * @param boolean whether to look for disabled items also |
| 98 | 98 | * @return integer the index of the item found, -1 if not found. |
| 99 | 99 | */ |
| 100 | - public function findIndexByText($text,$includeDisabled=true) |
|
| 100 | + public function findIndexByText($text, $includeDisabled = true) |
|
| 101 | 101 | { |
| 102 | - $text=TPropertyValue::ensureString($text); |
|
| 103 | - $index=0; |
|
| 104 | - foreach($this as $item) |
|
| 102 | + $text = TPropertyValue::ensureString($text); |
|
| 103 | + $index = 0; |
|
| 104 | + foreach ($this as $item) |
|
| 105 | 105 | { |
| 106 | - if($item->getText()===$text && ($includeDisabled || $item->getEnabled())) |
|
| 106 | + if ($item->getText() === $text && ($includeDisabled || $item->getEnabled())) |
|
| 107 | 107 | return $index; |
| 108 | 108 | $index++; |
| 109 | 109 | } |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | * @param boolean whether to look for disabled items also |
| 117 | 117 | * @return TListItem the item found, null if not found. |
| 118 | 118 | */ |
| 119 | - public function findItemByValue($value,$includeDisabled=true) |
|
| 119 | + public function findItemByValue($value, $includeDisabled = true) |
|
| 120 | 120 | { |
| 121 | - if(($index=$this->findIndexByValue($value,$includeDisabled))>=0) |
|
| 121 | + if (($index = $this->findIndexByValue($value, $includeDisabled)) >= 0) |
|
| 122 | 122 | return $this->itemAt($index); |
| 123 | 123 | else |
| 124 | 124 | return null; |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | * @param boolean whether to look for disabled items also |
| 131 | 131 | * @return TListItem the item found, null if not found. |
| 132 | 132 | */ |
| 133 | - public function findItemByText($text,$includeDisabled=true) |
|
| 133 | + public function findItemByText($text, $includeDisabled = true) |
|
| 134 | 134 | { |
| 135 | - if(($index=$this->findIndexByText($text,$includeDisabled))>=0) |
|
| 135 | + if (($index = $this->findIndexByText($text, $includeDisabled)) >= 0) |
|
| 136 | 136 | return $this->itemAt($index); |
| 137 | 137 | else |
| 138 | 138 | return null; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | public function loadState($state) |
| 147 | 147 | { |
| 148 | 148 | $this->clear(); |
| 149 | - if($state!==null) |
|
| 149 | + if ($state !== null) |
|
| 150 | 150 | $this->copyFrom($state); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -157,6 +157,6 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function saveState() |
| 159 | 159 | { |
| 160 | - return ($this->getCount()>0) ? $this->toArray() : null; |
|
| 160 | + return ($this->getCount() > 0) ? $this->toArray() : null; |
|
| 161 | 161 | } |
| 162 | 162 | } |
@@ -29,18 +29,18 @@ discard block |
||
| 29 | 29 | * @package System.Collections |
| 30 | 30 | * @since 3.0 |
| 31 | 31 | */ |
| 32 | -class TStack extends TComponent implements IteratorAggregate,Countable |
|
| 32 | +class TStack extends TComponent implements IteratorAggregate, Countable |
|
| 33 | 33 | { |
| 34 | 34 | /** |
| 35 | 35 | * internal data storage |
| 36 | 36 | * @var array |
| 37 | 37 | */ |
| 38 | - private $_d=array(); |
|
| 38 | + private $_d = array(); |
|
| 39 | 39 | /** |
| 40 | 40 | * number of items |
| 41 | 41 | * @var integer |
| 42 | 42 | */ |
| 43 | - private $_c=0; |
|
| 43 | + private $_c = 0; |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Constructor. |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | * @param array|Iterator the initial data. Default is null, meaning no initialization. |
| 49 | 49 | * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator. |
| 50 | 50 | */ |
| 51 | - public function __construct($data=null) |
|
| 51 | + public function __construct($data = null) |
|
| 52 | 52 | { |
| 53 | - if($data!==null) |
|
| 53 | + if ($data !== null) |
|
| 54 | 54 | $this->copyFrom($data); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -70,16 +70,16 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function copyFrom($data) |
| 72 | 72 | { |
| 73 | - if(is_array($data) || ($data instanceof Traversable)) |
|
| 73 | + if (is_array($data) || ($data instanceof Traversable)) |
|
| 74 | 74 | { |
| 75 | 75 | $this->clear(); |
| 76 | - foreach($data as $item) |
|
| 76 | + foreach ($data as $item) |
|
| 77 | 77 | { |
| 78 | - $this->_d[]=$item; |
|
| 78 | + $this->_d[] = $item; |
|
| 79 | 79 | ++$this->_c; |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | - else if($data!==null) |
|
| 82 | + else if ($data !== null) |
|
| 83 | 83 | throw new TInvalidDataTypeException('stack_data_not_iterable'); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function clear() |
| 90 | 90 | { |
| 91 | - $this->_c=0; |
|
| 92 | - $this->_d=array(); |
|
| 91 | + $this->_c = 0; |
|
| 92 | + $this->_d = array(); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function contains($item) |
| 100 | 100 | { |
| 101 | - return array_search($item,$this->_d,true)!==false; |
|
| 101 | + return array_search($item, $this->_d, true) !== false; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function peek() |
| 111 | 111 | { |
| 112 | - if($this->_c===0) |
|
| 112 | + if ($this->_c === 0) |
|
| 113 | 113 | throw new TInvalidOperationException('stack_empty'); |
| 114 | 114 | else |
| 115 | - return $this->_d[$this->_c-1]; |
|
| 115 | + return $this->_d[$this->_c - 1]; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function pop() |
| 124 | 124 | { |
| 125 | - if($this->_c===0) |
|
| 125 | + if ($this->_c === 0) |
|
| 126 | 126 | throw new TInvalidOperationException('stack_empty'); |
| 127 | 127 | else |
| 128 | 128 | { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function getIterator() |
| 150 | 150 | { |
| 151 | - return new ArrayIterator( $this->_d ); |
|
| 151 | + return new ArrayIterator($this->_d); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function __construct(&$data) |
| 206 | 206 | { |
| 207 | - $this->_d=&$data; |
|
| 208 | - $this->_i=0; |
|
| 209 | - $this->_c=count($this->_d); |
|
| 207 | + $this->_d = &$data; |
|
| 208 | + $this->_i = 0; |
|
| 209 | + $this->_c = count($this->_d); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function rewind() |
| 217 | 217 | { |
| 218 | - $this->_i=0; |
|
| 218 | + $this->_i = 0; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | public function valid() |
| 256 | 256 | { |
| 257 | - return $this->_i<$this->_c; |
|
| 257 | + return $this->_i < $this->_c; |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
@@ -58,28 +58,28 @@ discard block |
||
| 58 | 58 | /** |
| 59 | 59 | * @var boolean whether to allow custom paging |
| 60 | 60 | */ |
| 61 | - private $_customPaging=false; |
|
| 61 | + private $_customPaging = false; |
|
| 62 | 62 | /** |
| 63 | 63 | * @var integer number of items in each page |
| 64 | 64 | */ |
| 65 | - private $_pageSize=10; |
|
| 65 | + private $_pageSize = 10; |
|
| 66 | 66 | /** |
| 67 | 67 | * @var integer current page index |
| 68 | 68 | */ |
| 69 | - private $_currentPageIndex=-1; |
|
| 69 | + private $_currentPageIndex = -1; |
|
| 70 | 70 | /** |
| 71 | 71 | * @var integer user-assigned number of items in data source |
| 72 | 72 | */ |
| 73 | - private $_virtualCount=-1; |
|
| 73 | + private $_virtualCount = -1; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Constructor. |
| 77 | 77 | * @param array|Iterator the initial data. Default is null, meaning no initialization. |
| 78 | 78 | * @param boolean whether the list is read-only. Always true for paged list. |
| 79 | 79 | */ |
| 80 | - public function __construct($data=null,$readOnly=false) |
|
| 80 | + public function __construct($data = null, $readOnly = false) |
|
| 81 | 81 | { |
| 82 | - parent::__construct($data,true); |
|
| 82 | + parent::__construct($data, true); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function setCustomPaging($value) |
| 97 | 97 | { |
| 98 | - $this->_customPaging=TPropertyValue::ensureBoolean($value); |
|
| 98 | + $this->_customPaging = TPropertyValue::ensureBoolean($value); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function setPageSize($value) |
| 113 | 113 | { |
| 114 | - if(($value=TPropertyValue::ensureInteger($value))>0) |
|
| 115 | - $this->_pageSize=$value; |
|
| 114 | + if (($value = TPropertyValue::ensureInteger($value)) > 0) |
|
| 115 | + $this->_pageSize = $value; |
|
| 116 | 116 | else |
| 117 | 117 | throw new TInvalidDataValueException('pagedlist_pagesize_invalid'); |
| 118 | 118 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function setCurrentPageIndex($value) |
| 133 | 133 | { |
| 134 | - if($this->gotoPage($value=TPropertyValue::ensureInteger($value))===false) |
|
| 134 | + if ($this->gotoPage($value = TPropertyValue::ensureInteger($value)) === false) |
|
| 135 | 135 | throw new TInvalidDataValueException('pagedlist_currentpageindex_invalid'); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function onPageIndexChanged($param) |
| 144 | 144 | { |
| 145 | - $this->raiseEvent('OnPageIndexChanged',$this,$param); |
|
| 145 | + $this->raiseEvent('OnPageIndexChanged', $this, $param); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function onFetchData($param) |
| 156 | 156 | { |
| 157 | - $this->raiseEvent('OnFetchData',$this,$param); |
|
| 157 | + $this->raiseEvent('OnFetchData', $this, $param); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -164,21 +164,21 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public function gotoPage($pageIndex) |
| 166 | 166 | { |
| 167 | - if($pageIndex===$this->_currentPageIndex) |
|
| 167 | + if ($pageIndex === $this->_currentPageIndex) |
|
| 168 | 168 | return $pageIndex; |
| 169 | - if($this->_customPaging) |
|
| 169 | + if ($this->_customPaging) |
|
| 170 | 170 | { |
| 171 | - if($pageIndex>=0 && ($this->_virtualCount<0 || $pageIndex<$this->getPageCount())) |
|
| 171 | + if ($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount())) |
|
| 172 | 172 | { |
| 173 | - $param=new TPagedListFetchDataEventParameter($pageIndex,$this->_pageSize*$pageIndex,$this->_pageSize); |
|
| 173 | + $param = new TPagedListFetchDataEventParameter($pageIndex, $this->_pageSize * $pageIndex, $this->_pageSize); |
|
| 174 | 174 | $this->onFetchData($param); |
| 175 | - if(($data=$param->getData())!==null) |
|
| 175 | + if (($data = $param->getData()) !== null) |
|
| 176 | 176 | { |
| 177 | 177 | $this->setReadOnly(false); |
| 178 | 178 | $this->copyFrom($data); |
| 179 | 179 | $this->setReadOnly(true); |
| 180 | - $oldPage=$this->_currentPageIndex; |
|
| 181 | - $this->_currentPageIndex=$pageIndex; |
|
| 180 | + $oldPage = $this->_currentPageIndex; |
|
| 181 | + $this->_currentPageIndex = $pageIndex; |
|
| 182 | 182 | $this->onPageIndexChanged(new TPagedListPageChangedEventParameter($oldPage)); |
| 183 | 183 | return $pageIndex; |
| 184 | 184 | } |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | else |
| 192 | 192 | { |
| 193 | - if($pageIndex>=0 && $pageIndex<$this->getPageCount()) |
|
| 193 | + if ($pageIndex >= 0 && $pageIndex < $this->getPageCount()) |
|
| 194 | 194 | { |
| 195 | - $this->_currentPageIndex=$pageIndex; |
|
| 195 | + $this->_currentPageIndex = $pageIndex; |
|
| 196 | 196 | $this->onPageIndexChanged(null); |
| 197 | 197 | return $pageIndex; |
| 198 | 198 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function nextPage() |
| 209 | 209 | { |
| 210 | - return $this->gotoPage($this->_currentPageIndex+1); |
|
| 210 | + return $this->gotoPage($this->_currentPageIndex + 1); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function previousPage() |
| 218 | 218 | { |
| 219 | - return $this->gotoPage($this->_currentPageIndex-1); |
|
| 219 | + return $this->gotoPage($this->_currentPageIndex - 1); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function setVirtualCount($value) |
| 234 | 234 | { |
| 235 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
| 236 | - $value=-1; |
|
| 237 | - $this->_virtualCount=$value; |
|
| 235 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
| 236 | + $value = -1; |
|
| 237 | + $this->_virtualCount = $value; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | public function getPageCount() |
| 244 | 244 | { |
| 245 | - if($this->_customPaging) |
|
| 245 | + if ($this->_customPaging) |
|
| 246 | 246 | { |
| 247 | - if($this->_virtualCount>=0) |
|
| 248 | - return (int)(($this->_virtualCount+$this->_pageSize-1)/$this->_pageSize); |
|
| 247 | + if ($this->_virtualCount >= 0) |
|
| 248 | + return (int) (($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize); |
|
| 249 | 249 | else |
| 250 | 250 | return -1; |
| 251 | 251 | } |
| 252 | 252 | else |
| 253 | - return (int)((parent::getCount()+$this->_pageSize-1)/$this->_pageSize); |
|
| 253 | + return (int) ((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function getIsFirstPage() |
| 260 | 260 | { |
| 261 | - return $this->_currentPageIndex===0; |
|
| 261 | + return $this->_currentPageIndex === 0; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public function getIsLastPage() |
| 268 | 268 | { |
| 269 | - return $this->_currentPageIndex===$this->getPageCount()-1; |
|
| 269 | + return $this->_currentPageIndex === $this->getPageCount() - 1; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -274,12 +274,12 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | public function getCount() |
| 276 | 276 | { |
| 277 | - if($this->_customPaging) |
|
| 277 | + if ($this->_customPaging) |
|
| 278 | 278 | return parent::getCount(); |
| 279 | 279 | else |
| 280 | 280 | { |
| 281 | - if($this->_currentPageIndex===$this->getPageCount()-1) |
|
| 282 | - return parent::getCount()-$this->_pageSize*$this->_currentPageIndex; |
|
| 281 | + if ($this->_currentPageIndex === $this->getPageCount() - 1) |
|
| 282 | + return parent::getCount() - $this->_pageSize * $this->_currentPageIndex; |
|
| 283 | 283 | else |
| 284 | 284 | return $this->_pageSize; |
| 285 | 285 | } |
@@ -290,11 +290,11 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | public function getIterator() |
| 292 | 292 | { |
| 293 | - if($this->_customPaging) |
|
| 293 | + if ($this->_customPaging) |
|
| 294 | 294 | return parent::getIterator(); |
| 295 | 295 | else |
| 296 | 296 | { |
| 297 | - $data=$this->toArray(); |
|
| 297 | + $data = $this->toArray(); |
|
| 298 | 298 | return new TListIterator($data); |
| 299 | 299 | } |
| 300 | 300 | } |
@@ -308,10 +308,10 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | public function itemAt($index) |
| 310 | 310 | { |
| 311 | - if($this->_customPaging) |
|
| 311 | + if ($this->_customPaging) |
|
| 312 | 312 | return parent::itemAt($index); |
| 313 | 313 | else |
| 314 | - return parent::itemAt($this->_pageSize*$this->_currentPageIndex+$index); |
|
| 314 | + return parent::itemAt($this->_pageSize * $this->_currentPageIndex + $index); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | public function indexOf($item) |
| 322 | 322 | { |
| 323 | - $c=$this->getCount(); |
|
| 324 | - for($i=0;$i<$c;++$i) |
|
| 325 | - if($this->itemAt($i)===$item) |
|
| 323 | + $c = $this->getCount(); |
|
| 324 | + for ($i = 0; $i < $c; ++$i) |
|
| 325 | + if ($this->itemAt($i) === $item) |
|
| 326 | 326 | return $i; |
| 327 | 327 | return -1; |
| 328 | 328 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public function offsetExists($offset) |
| 337 | 337 | { |
| 338 | - return ($offset>=0 && $offset<$this->getCount()); |
|
| 338 | + return ($offset >= 0 && $offset < $this->getCount()); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -355,10 +355,10 @@ discard block |
||
| 355 | 355 | */ |
| 356 | 356 | public function toArray() |
| 357 | 357 | { |
| 358 | - $c=$this->getCount(); |
|
| 359 | - $array=array(); |
|
| 360 | - for($i=0;$i<$c;++$i) |
|
| 361 | - $array[$i]=$this->itemAt($i); |
|
| 358 | + $c = $this->getCount(); |
|
| 359 | + $array = array(); |
|
| 360 | + for ($i = 0; $i < $c; ++$i) |
|
| 361 | + $array[$i] = $this->itemAt($i); |
|
| 362 | 362 | return $array; |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | public function __construct($oldPage) |
| 385 | 385 | { |
| 386 | - $this->_oldPage=$oldPage; |
|
| 386 | + $this->_oldPage = $oldPage; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | private $_pageIndex; |
| 416 | 416 | private $_offset; |
| 417 | 417 | private $_limit; |
| 418 | - private $_data=null; |
|
| 418 | + private $_data = null; |
|
| 419 | 419 | |
| 420 | 420 | /** |
| 421 | 421 | * Constructor. |
@@ -423,11 +423,11 @@ discard block |
||
| 423 | 423 | * @param integer offset of the first item in the new page |
| 424 | 424 | * @param integer number of items in the new page desired |
| 425 | 425 | */ |
| 426 | - public function __construct($pageIndex,$offset,$limit) |
|
| 426 | + public function __construct($pageIndex, $offset, $limit) |
|
| 427 | 427 | { |
| 428 | - $this->_pageIndex=$pageIndex; |
|
| 429 | - $this->_offset=$offset; |
|
| 430 | - $this->_limit=$limit; |
|
| 428 | + $this->_pageIndex = $pageIndex; |
|
| 429 | + $this->_offset = $offset; |
|
| 430 | + $this->_limit = $limit; |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | public function setData($value) |
| 469 | 469 | { |
| 470 | - $this->_data=$value; |
|
| 470 | + $this->_data = $value; |
|
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |