@@ -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 | /** |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | */ |
| 70 | 70 | public function current() |
| 71 | 71 | { |
| 72 | - return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null; |
|
| 72 | + return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -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 |
@@ -41,6 +41,6 @@ |
||
| 41 | 41 | public function insertAt($index, $item) |
| 42 | 42 | { |
| 43 | 43 | if(!is_string($item)) // string is possible if property tag is used. we simply ignore it in this case |
| 44 | - parent::insertAt($index, $item); // this will generate an exception in parent implementation |
|
| 44 | + parent::insertAt($index, $item); // this will generate an exception in parent implementation |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -86,12 +86,12 @@ |
||
| 86 | 86 | else |
| 87 | 87 | { |
| 88 | 88 | $this->getPage()->getAdapter()->registerControlToRender($this, $writer); |
| 89 | - if ($this->getHasControls()) |
|
| 89 | + if($this->getHasControls()) |
|
| 90 | 90 | { |
| 91 | 91 | // If we update a TActivePanel on callback, |
| 92 | 92 | // We shouldn't update all childs, because the whole content will be replaced by |
| 93 | 93 | // the parent |
| 94 | - foreach ($this->findControlsByType('Prado\Web\UI\ActiveControls\IActiveControl', false) as $control) |
|
| 94 | + foreach($this->findControlsByType('Prado\Web\UI\ActiveControls\IActiveControl', false) as $control) |
|
| 95 | 95 | { |
| 96 | 96 | $control->getActiveControl()->setEnableUpdate(false); |
| 97 | 97 | } |
@@ -607,15 +607,15 @@ |
||
| 607 | 607 | public function _hash($data, $controlType) |
| 608 | 608 | { |
| 609 | 609 | switch ($controlType) { |
| 610 | - case 'md5': |
|
| 611 | - return md5($data); |
|
| 612 | - case 'crc32': |
|
| 613 | - return sprintf('% 32d', crc32($data)); |
|
| 614 | - case 'strlen': |
|
| 615 | - return sprintf('% 32d', strlen($data)); |
|
| 616 | - default: |
|
| 617 | - $this->raiseError('Unknown controlType ! ' . |
|
| 618 | - '(available values are only \'md5\', \'crc32\', \'strlen\')', -5); |
|
| 610 | + case 'md5': |
|
| 611 | + return md5($data); |
|
| 612 | + case 'crc32': |
|
| 613 | + return sprintf('% 32d', crc32($data)); |
|
| 614 | + case 'strlen': |
|
| 615 | + return sprintf('% 32d', strlen($data)); |
|
| 616 | + default: |
|
| 617 | + $this->raiseError('Unknown controlType ! ' . |
|
| 618 | + '(available values are only \'md5\', \'crc32\', \'strlen\')', -5); |
|
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public function __construct($options = [null]) |
| 235 | 235 | { |
| 236 | - $availableOptions = [ 'automaticSerialization', |
|
| 236 | + $availableOptions = ['automaticSerialization', |
|
| 237 | 237 | 'fileNameProtection', |
| 238 | 238 | 'memoryCaching', |
| 239 | 239 | 'onlyMemoryCaching', |
@@ -269,35 +269,35 @@ discard block |
||
| 269 | 269 | $this->_id = $id; |
| 270 | 270 | $this->_group = $group; |
| 271 | 271 | $data = false; |
| 272 | - if ($this->_caching) { |
|
| 272 | + if($this->_caching) { |
|
| 273 | 273 | $this->_setFileName($id, $group); |
| 274 | - if ($this->_memoryCaching) { |
|
| 275 | - if (isset($this->_memoryCachingArray[$this->_file])) { |
|
| 276 | - if ($this->_automaticSerialization) { |
|
| 274 | + if($this->_memoryCaching) { |
|
| 275 | + if(isset($this->_memoryCachingArray[$this->_file])) { |
|
| 276 | + if($this->_automaticSerialization) { |
|
| 277 | 277 | return unserialize( |
| 278 | 278 | $this->_memoryCachingArray[$this->_file]); |
| 279 | 279 | } else { |
| 280 | 280 | return $this->_memoryCachingArray[$this->_file]; |
| 281 | 281 | } |
| 282 | 282 | } else { |
| 283 | - if ($this->_onlyMemoryCaching) { |
|
| 283 | + if($this->_onlyMemoryCaching) { |
|
| 284 | 284 | return false; |
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | - if ($doNotTestCacheValidity) { |
|
| 289 | - if (file_exists($this->_file)) { |
|
| 288 | + if($doNotTestCacheValidity) { |
|
| 289 | + if(file_exists($this->_file)) { |
|
| 290 | 290 | $data = $this->_read(); |
| 291 | 291 | } |
| 292 | 292 | } else { |
| 293 | - if (@filemtime($this->_file) > $this->_refreshTime) { |
|
| 293 | + if(@filemtime($this->_file) > $this->_refreshTime) { |
|
| 294 | 294 | $data = $this->_read(); |
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | - if (($data) and ($this->_memoryCaching)) { |
|
| 297 | + if(($data) and ($this->_memoryCaching)) { |
|
| 298 | 298 | $this->_memoryCacheAdd($this->_file, $data); |
| 299 | 299 | } |
| 300 | - if ($this->_automaticSerialization && is_string($data)) { |
|
| 300 | + if($this->_automaticSerialization && is_string($data)) { |
|
| 301 | 301 | $data = unserialize($data); |
| 302 | 302 | } |
| 303 | 303 | return $data; |
@@ -317,21 +317,21 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | public function save($data, $id = null, $group = 'default') |
| 319 | 319 | { |
| 320 | - if ($this->_caching) { |
|
| 321 | - if ($this->_automaticSerialization) { |
|
| 320 | + if($this->_caching) { |
|
| 321 | + if($this->_automaticSerialization) { |
|
| 322 | 322 | $data = serialize($data); |
| 323 | 323 | } |
| 324 | - if (isset($id)) { |
|
| 324 | + if(isset($id)) { |
|
| 325 | 325 | $this->_setFileName($id, $group); |
| 326 | 326 | } |
| 327 | - if ($this->_memoryCaching) { |
|
| 327 | + if($this->_memoryCaching) { |
|
| 328 | 328 | $this->_memoryCacheAdd($this->_file, $data); |
| 329 | - if ($this->_onlyMemoryCaching) { |
|
| 329 | + if($this->_onlyMemoryCaching) { |
|
| 330 | 330 | return true; |
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | - if ($this->_writeControl) { |
|
| 334 | - if (!$this->_writeAndControl($data)) { |
|
| 333 | + if($this->_writeControl) { |
|
| 334 | + if(!$this->_writeAndControl($data)) { |
|
| 335 | 335 | @touch($this->_file, time() - 2 * abs($this->_lifeTime)); |
| 336 | 336 | return false; |
| 337 | 337 | } else { |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | public function remove($id, $group = 'default') |
| 356 | 356 | { |
| 357 | 357 | $this->_setFileName($id, $group); |
| 358 | - if (!@unlink($this->_file)) { |
|
| 358 | + if(!@unlink($this->_file)) { |
|
| 359 | 359 | $this->raiseError('TCache_Lite : Unable to remove cache !', -3); |
| 360 | 360 | return false; |
| 361 | 361 | } |
@@ -374,33 +374,33 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | public function clean($group = false) |
| 376 | 376 | { |
| 377 | - if ($this->_fileNameProtection) { |
|
| 377 | + if($this->_fileNameProtection) { |
|
| 378 | 378 | $motif = ($group) ? 'cache_' . md5($group) . '_' : 'cache_'; |
| 379 | 379 | } else { |
| 380 | 380 | $motif = ($group) ? 'cache_' . $group . '_' : 'cache_'; |
| 381 | 381 | } |
| 382 | - if ($this->_memoryCaching) { |
|
| 383 | - while (list($key, $value) = each($this->_memoryCaching)) { |
|
| 384 | - if (strpos($key, $motif, 0)) { |
|
| 382 | + if($this->_memoryCaching) { |
|
| 383 | + while(list($key, $value) = each($this->_memoryCaching)) { |
|
| 384 | + if(strpos($key, $motif, 0)) { |
|
| 385 | 385 | unset($this->_memoryCaching[$key]); |
| 386 | 386 | $this->_memoryCachingCounter = |
| 387 | 387 | $this->_memoryCachingCounter - 1; |
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | - if ($this->_onlyMemoryCaching) { |
|
| 390 | + if($this->_onlyMemoryCaching) { |
|
| 391 | 391 | return true; |
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | - if (!($dh = opendir($this->_cacheDir))) { |
|
| 394 | + if(!($dh = opendir($this->_cacheDir))) { |
|
| 395 | 395 | $this->raiseError('TCache_Lite : Unable to open cache directory !'); |
| 396 | 396 | return false; |
| 397 | 397 | } |
| 398 | - while ($file = readdir($dh)) { |
|
| 399 | - if (($file != '.') && ($file != '..')) { |
|
| 398 | + while($file = readdir($dh)) { |
|
| 399 | + if(($file != '.') && ($file != '..')) { |
|
| 400 | 400 | $file = $this->_cacheDir . $file; |
| 401 | - if (is_file($file)) { |
|
| 402 | - if (strpos($file, $motif, 0)) { |
|
| 403 | - if (!@unlink($file)) { |
|
| 401 | + if(is_file($file)) { |
|
| 402 | + if(strpos($file, $motif, 0)) { |
|
| 403 | + if(!@unlink($file)) { |
|
| 404 | 404 | $this->raiseError('Cache_Lite : Unable to remove cache !', -3); |
| 405 | 405 | return false; |
| 406 | 406 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | public function saveMemoryCachingState($id, $group = 'default') |
| 431 | 431 | { |
| 432 | - if ($this->_caching) { |
|
| 432 | + if($this->_caching) { |
|
| 433 | 433 | $array = [ |
| 434 | 434 | 'counter' => $this->_memoryCachingCounter, |
| 435 | 435 | 'array' => $this->_memoryCachingState |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | public function getMemoryCachingState($id, $group = 'default', |
| 447 | 447 | $doNotTestCacheValidity = false) |
| 448 | 448 | { |
| 449 | - if ($this->_caching) { |
|
| 450 | - if ($data = $this->get($id, $group, $doNotTestCacheValidity)) |
|
| 449 | + if($this->_caching) { |
|
| 450 | + if($data = $this->get($id, $group, $doNotTestCacheValidity)) |
|
| 451 | 451 | { |
| 452 | 452 | $array = unserialize($data); |
| 453 | 453 | $this->_memoryCachingCounter = $array['counter']; |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | public function _memoryCacheAdd($id, $data) |
| 493 | 493 | { |
| 494 | 494 | $this->_memoryCachingArray[$this->_file] = $data; |
| 495 | - if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { |
|
| 495 | + if($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { |
|
| 496 | 496 | list($key, $value) = each($this->_memoryCachingArray); |
| 497 | 497 | unset($this->_memoryCachingArray[$key]); |
| 498 | 498 | } else { |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | */ |
| 510 | 510 | public function _setFileName($id, $group) |
| 511 | 511 | { |
| 512 | - if ($this->_fileNameProtection) { |
|
| 512 | + if($this->_fileNameProtection) { |
|
| 513 | 513 | $this->_file = ($this->_cacheDir . 'cache_' . md5($group) . '_' |
| 514 | 514 | . md5($id)); |
| 515 | 515 | } else { |
@@ -531,21 +531,21 @@ discard block |
||
| 531 | 531 | public function _read() |
| 532 | 532 | { |
| 533 | 533 | $fp = @fopen($this->_file, "rb"); |
| 534 | - if ($this->_fileLocking) @flock($fp, LOCK_SH); |
|
| 535 | - if ($fp) { |
|
| 534 | + if($this->_fileLocking) @flock($fp, LOCK_SH); |
|
| 535 | + if($fp) { |
|
| 536 | 536 | // because the filesize can be cached by PHP itself... |
| 537 | 537 | clearstatcache(); |
| 538 | 538 | $length = @filesize($this->_file); |
| 539 | - if ($this->_readControl) { |
|
| 539 | + if($this->_readControl) { |
|
| 540 | 540 | $hashControl = @fread($fp, 32); |
| 541 | 541 | $length = $length - 32; |
| 542 | 542 | } |
| 543 | 543 | $data = @fread($fp, $length); |
| 544 | - if ($this->_fileLocking) @flock($fp, LOCK_UN); |
|
| 544 | + if($this->_fileLocking) @flock($fp, LOCK_UN); |
|
| 545 | 545 | @fclose($fp); |
| 546 | - if ($this->_readControl) { |
|
| 546 | + if($this->_readControl) { |
|
| 547 | 547 | $hashData = $this->_hash($data, $this->_readControlType); |
| 548 | - if ($hashData != $hashControl) { |
|
| 548 | + if($hashData != $hashControl) { |
|
| 549 | 549 | @touch($this->_file, time() - 2 * abs($this->_lifeTime)); |
| 550 | 550 | return false; |
| 551 | 551 | } |
@@ -566,14 +566,14 @@ discard block |
||
| 566 | 566 | public function _write($data) |
| 567 | 567 | { |
| 568 | 568 | $fp = @fopen($this->_file, "wb"); |
| 569 | - if ($fp) { |
|
| 570 | - if ($this->_fileLocking) @flock($fp, LOCK_EX); |
|
| 571 | - if ($this->_readControl) { |
|
| 569 | + if($fp) { |
|
| 570 | + if($this->_fileLocking) @flock($fp, LOCK_EX); |
|
| 571 | + if($this->_readControl) { |
|
| 572 | 572 | @fwrite($fp, $this->_hash($data, $this->_readControlType), 32); |
| 573 | 573 | } |
| 574 | 574 | $len = strlen($data); |
| 575 | 575 | @fwrite($fp, $data, $len); |
| 576 | - if ($this->_fileLocking) @flock($fp, LOCK_UN); |
|
| 576 | + if($this->_fileLocking) @flock($fp, LOCK_UN); |
|
| 577 | 577 | @fclose($fp); |
| 578 | 578 | return true; |
| 579 | 579 | } |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | */ |
| 607 | 607 | public function _hash($data, $controlType) |
| 608 | 608 | { |
| 609 | - switch ($controlType) { |
|
| 609 | + switch($controlType) { |
|
| 610 | 610 | case 'md5': |
| 611 | 611 | return md5($data); |
| 612 | 612 | case 'crc32': |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function __destruct() |
| 115 | 115 | { |
| 116 | - if ($this->_cache instanceof \Redis) |
|
| 116 | + if($this->_cache instanceof \Redis) |
|
| 117 | 117 | $this->_cache->close(); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function init($config) |
| 128 | 128 | { |
| 129 | - if (!extension_loaded('redis') || !class_exists('\Redis', false)) |
|
| 129 | + if(!extension_loaded('redis') || !class_exists('\Redis', false)) |
|
| 130 | 130 | throw new TConfigurationException('rediscache_extension_required'); |
| 131 | 131 | $this->_cache = new \Redis(); |
| 132 | - if ($this->_socket !== null) |
|
| 132 | + if($this->_socket !== null) |
|
| 133 | 133 | $this->_cache->connect($this->_socket); |
| 134 | 134 | else |
| 135 | 135 | $this->_cache->connect($this->_host, $this->_port); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function setHost($value) |
| 159 | 159 | { |
| 160 | - if ($this->_initialized) |
|
| 160 | + if($this->_initialized) |
|
| 161 | 161 | throw new TInvalidOperationException('rediscache_host_unchangeable'); |
| 162 | 162 | else |
| 163 | 163 | $this->_host = $value; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function setPort($value) |
| 179 | 179 | { |
| 180 | - if ($this->_initialized) |
|
| 180 | + if($this->_initialized) |
|
| 181 | 181 | throw new TInvalidOperationException('rediscache_port_unchangeable'); |
| 182 | 182 | else |
| 183 | 183 | $this->_port = TPropertyValue::ensureInteger($value); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function setIndex($value) |
| 219 | 219 | { |
| 220 | - if ($this->_initialized) |
|
| 220 | + if($this->_initialized) |
|
| 221 | 221 | throw new TInvalidOperationException('rediscache_index_unchangeable'); |
| 222 | 222 | else |
| 223 | 223 | $this->_index = TPropertyValue::ensureInteger($value); |
@@ -56,8 +56,8 @@ |
||
| 56 | 56 | if(!function_exists('xcache_isset')) |
| 57 | 57 | throw new TConfigurationException('xcache_extension_required'); |
| 58 | 58 | |
| 59 | - $enabled = (int)ini_get('xcache.cacher') !== 0; |
|
| 60 | - $var_size = (int)ini_get('xcache.var_size'); |
|
| 59 | + $enabled = (int) ini_get('xcache.cacher') !== 0; |
|
| 60 | + $var_size = (int) ini_get('xcache.var_size'); |
|
| 61 | 61 | |
| 62 | 62 | if(!($enabled && $var_size > 0)) |
| 63 | 63 | throw new TConfigurationException('xcache_extension_not_enabled'); |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | E_USER_NOTICE => "User Notice", |
| 47 | 47 | E_STRICT => "Runtime Notice" |
| 48 | 48 | ]; |
| 49 | - $errorType = isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error'; |
|
| 49 | + $errorType = isset($errorTypes[$errno]) ? $errorTypes[$errno] : 'Unknown Error'; |
|
| 50 | 50 | parent::__construct("[$errorType] $errstr (@line $errline in file $errfile)."); |
| 51 | 51 | } |
| 52 | 52 | |