@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | if(! isset($this->listeners[$eventName])){ |
| 60 | 60 | $this->logger->info('This event does not have the registered event listener before, adding new one'); |
| 61 | 61 | $this->listeners[$eventName] = array(); |
| 62 | - } |
|
| 63 | - else{ |
|
| 62 | + } else{ |
|
| 64 | 63 | $this->logger->info('This event already have the registered listener, add this listener to the list'); |
| 65 | 64 | } |
| 66 | 65 | $this->listeners[$eventName][] = $listener; |
@@ -78,12 +77,10 @@ discard block |
||
| 78 | 77 | if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){ |
| 79 | 78 | $this->logger->info('Found the listener at index [' .$index. '] remove it'); |
| 80 | 79 | unset($this->listeners[$eventName][$index]); |
| 81 | - } |
|
| 82 | - else{ |
|
| 80 | + } else{ |
|
| 83 | 81 | $this->logger->info('Cannot found this listener in the event listener list'); |
| 84 | 82 | } |
| 85 | - } |
|
| 86 | - else{ |
|
| 83 | + } else{ |
|
| 87 | 84 | $this->logger->info('This event does not have this listener ignore remove'); |
| 88 | 85 | } |
| 89 | 86 | } |
@@ -98,8 +95,7 @@ discard block |
||
| 98 | 95 | if($eventName !== null && isset($this->listeners[$eventName])){ |
| 99 | 96 | $this->logger->info('The event name is set of exist in the listener just remove all event listener for this event'); |
| 100 | 97 | unset($this->listeners[$eventName]); |
| 101 | - } |
|
| 102 | - else{ |
|
| 98 | + } else{ |
|
| 103 | 99 | $this->logger->info('The event name is not set or does not exist in the listener, so remove all event listener'); |
| 104 | 100 | $this->listeners = array(); |
| 105 | 101 | } |
@@ -132,8 +128,7 @@ discard block |
||
| 132 | 128 | if($event->returnBack){ |
| 133 | 129 | $this->logger->info('This event need return back, return the result for future use'); |
| 134 | 130 | return $this->dispatchToListerners($event); |
| 135 | - } |
|
| 136 | - else{ |
|
| 131 | + } else{ |
|
| 137 | 132 | $this->logger->info('This event no need return back the result, just dispatch it'); |
| 138 | 133 | $this->dispatchToListerners($event); |
| 139 | 134 | } |
@@ -153,8 +148,7 @@ discard block |
||
| 153 | 148 | return $event; |
| 154 | 149 | } |
| 155 | 150 | return; |
| 156 | - } |
|
| 157 | - else{ |
|
| 151 | + } else{ |
|
| 158 | 152 | $this->logger->info('Found the registered event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list)); |
| 159 | 153 | } |
| 160 | 154 | foreach($list as $listener){ |
@@ -162,12 +156,10 @@ discard block |
||
| 162 | 156 | $returnedEvent = call_user_func_array($listener, array($event)); |
| 163 | 157 | if($returnedEvent instanceof EventInfo){ |
| 164 | 158 | $event = $returnedEvent; |
| 165 | - } |
|
| 166 | - else{ |
|
| 159 | + } else{ |
|
| 167 | 160 | show_error('This event [' .$event->name. '] need you return the event object after processing'); |
| 168 | 161 | } |
| 169 | - } |
|
| 170 | - else{ |
|
| 162 | + } else{ |
|
| 171 | 163 | call_user_func_array($listener, array($event)); |
| 172 | 164 | } |
| 173 | 165 | if($event->stop){ |
@@ -115,8 +115,7 @@ |
||
| 115 | 115 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 116 | 116 | if($logger !== null){ |
| 117 | 117 | $this->logger = $logger; |
| 118 | - } |
|
| 119 | - else{ |
|
| 118 | + } else{ |
|
| 120 | 119 | $this->logger =& class_loader('Log', 'classes'); |
| 121 | 120 | $this->logger->setLogger('MainController'); |
| 122 | 121 | } |
@@ -477,8 +477,7 @@ discard block |
||
| 477 | 477 | if (mkdir($destination_directory, 0775, true)) { |
| 478 | 478 | $this->destination_directory = $destination_directory; |
| 479 | 479 | chdir($destination_directory); |
| 480 | - } |
|
| 481 | - else{ |
|
| 480 | + } else{ |
|
| 482 | 481 | $this->logger->warning('Can not create the upload directory [' .$destination_directory. ']'); |
| 483 | 482 | } |
| 484 | 483 | } |
@@ -630,8 +629,7 @@ discard block |
||
| 630 | 629 | // set original filename if not have a new name |
| 631 | 630 | if (empty($this->filename)) { |
| 632 | 631 | $this->filename = $this->file_array[$this->input]['name']; |
| 633 | - } |
|
| 634 | - else{ |
|
| 632 | + } else{ |
|
| 635 | 633 | // Replace %s for extension in filename |
| 636 | 634 | // Before: /[\w\d]*(.[\d\w]+)$/i |
| 637 | 635 | // After: /^[\s[:alnum:]\-\_\.]*\.([\d\w]+)$/iu |
@@ -225,8 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | if (empty($this->join)){ |
| 227 | 227 | $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 228 | - } |
|
| 229 | - else{ |
|
| 228 | + } else{ |
|
| 230 | 229 | $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on; |
| 231 | 230 | } |
| 232 | 231 | return $this; |
@@ -334,8 +333,7 @@ discard block |
||
| 334 | 333 | $whereStr = ''; |
| 335 | 334 | if (is_array($where)){ |
| 336 | 335 | $whereStr = $this->getWhereStrIfIsArray($where, $type, $andOr, $escape); |
| 337 | - } |
|
| 338 | - else{ |
|
| 336 | + } else{ |
|
| 339 | 337 | if (is_array($op)){ |
| 340 | 338 | $whereStr = $this->getWhereStrIfOperatorIsArray($where, $op, $type, $escape); |
| 341 | 339 | } else { |
@@ -585,8 +583,7 @@ discard block |
||
| 585 | 583 | } |
| 586 | 584 | if (! is_null($limitEnd)){ |
| 587 | 585 | $this->limit = $limit . ', ' . $limitEnd; |
| 588 | - } |
|
| 589 | - else{ |
|
| 586 | + } else{ |
|
| 590 | 587 | $this->limit = $limit; |
| 591 | 588 | } |
| 592 | 589 | return $this; |
@@ -601,8 +598,7 @@ discard block |
||
| 601 | 598 | public function orderBy($orderBy, $orderDir = ' ASC'){ |
| 602 | 599 | if (stristr($orderBy, ' ') || $orderBy == 'rand()'){ |
| 603 | 600 | $this->orderBy = empty($this->orderBy) ? $orderBy : $this->orderBy . ', ' . $orderBy; |
| 604 | - } |
|
| 605 | - else{ |
|
| 601 | + } else{ |
|
| 606 | 602 | $this->orderBy = empty($this->orderBy) |
| 607 | 603 | ? ($orderBy . ' ' . strtoupper($orderDir)) |
| 608 | 604 | : $this->orderBy . ', ' . $orderBy . ' ' . strtoupper($orderDir); |
@@ -618,8 +614,7 @@ discard block |
||
| 618 | 614 | public function groupBy($field){ |
| 619 | 615 | if (is_array($field)){ |
| 620 | 616 | $this->groupBy = implode(', ', $field); |
| 621 | - } |
|
| 622 | - else{ |
|
| 617 | + } else{ |
|
| 623 | 618 | $this->groupBy = $field; |
| 624 | 619 | } |
| 625 | 620 | return $this; |
@@ -636,14 +631,12 @@ discard block |
||
| 636 | 631 | public function having($field, $op = null, $val = null, $escape = true){ |
| 637 | 632 | if (is_array($op)){ |
| 638 | 633 | $this->having = $this->getHavingStrIfOperatorIsArray($field, $op, $escape); |
| 639 | - } |
|
| 640 | - else if (! in_array($op, $this->operatorList)){ |
|
| 634 | + } else if (! in_array($op, $this->operatorList)){ |
|
| 641 | 635 | if (is_null($op)){ |
| 642 | 636 | $op = ''; |
| 643 | 637 | } |
| 644 | 638 | $this->having = $field . ' > ' . ($this->escape($op, $escape)); |
| 645 | - } |
|
| 646 | - else{ |
|
| 639 | + } else{ |
|
| 647 | 640 | if (is_null($val)){ |
| 648 | 641 | $val = ''; |
| 649 | 642 | } |
@@ -149,8 +149,7 @@ discard block |
||
| 149 | 149 | $isSqlSELECTQuery = stristr($this->query, 'SELECT') !== false; |
| 150 | 150 | if($isSqlSELECTQuery){ |
| 151 | 151 | $this->setResultForSelect(); |
| 152 | - } |
|
| 153 | - else{ |
|
| 152 | + } else{ |
|
| 154 | 153 | $this->setResultForNonSelect(); |
| 155 | 154 | } |
| 156 | 155 | return $this->queryResult; |
@@ -172,15 +171,13 @@ discard block |
||
| 172 | 171 | } |
| 173 | 172 | if ($this->returnAsList){ |
| 174 | 173 | $result = $this->pdoStatment->fetchAll($fetchMode); |
| 175 | - } |
|
| 176 | - else{ |
|
| 174 | + } else{ |
|
| 177 | 175 | $result = $this->pdoStatment->fetch($fetchMode); |
| 178 | 176 | } |
| 179 | 177 | //Sqlite and pgsql always return 0 when using rowCount() |
| 180 | 178 | if (in_array($this->driver, array('sqlite', 'pgsql'))){ |
| 181 | 179 | $numRows = count($result); |
| 182 | - } |
|
| 183 | - else{ |
|
| 180 | + } else{ |
|
| 184 | 181 | $numRows = $this->pdoStatment->rowCount(); |
| 185 | 182 | } |
| 186 | 183 | if(! is_object($this->queryResult)){ |
@@ -201,8 +198,7 @@ discard block |
||
| 201 | 198 | if (in_array($this->driver, array('sqlite', 'pgsql'))){ |
| 202 | 199 | $result = true; //to test the result for the query like UPDATE, INSERT, DELETE |
| 203 | 200 | $numRows = 1; //TODO use the correct method to get the exact affected row |
| 204 | - } |
|
| 205 | - else{ |
|
| 201 | + } else{ |
|
| 206 | 202 | //to test the result for the query like UPDATE, INSERT, DELETE |
| 207 | 203 | $result = $this->pdoStatment->rowCount() >= 0; |
| 208 | 204 | $numRows = $this->pdoStatment->rowCount(); |
@@ -380,8 +376,7 @@ discard block |
||
| 380 | 376 | protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){ |
| 381 | 377 | if ($logger !== null){ |
| 382 | 378 | $this->logger = $logger; |
| 383 | - } |
|
| 384 | - else{ |
|
| 379 | + } else{ |
|
| 385 | 380 | $this->logger =& class_loader('Log', 'classes'); |
| 386 | 381 | $this->logger->setLogger('Library::DatabaseQueryRunner'); |
| 387 | 382 | } |
@@ -62,8 +62,7 @@ |
||
| 62 | 62 | $query[0] = rtrim($query[0], '/'); |
| 63 | 63 | $query[0] .= $suffix; |
| 64 | 64 | $path = implode('?', $query); |
| 65 | - } |
|
| 66 | - else{ |
|
| 65 | + } else{ |
|
| 67 | 66 | $path .= $suffix; |
| 68 | 67 | } |
| 69 | 68 | } |
@@ -128,8 +128,7 @@ discard block |
||
| 128 | 128 | $logger->info('Delete config item ['.$item.']'); |
| 129 | 129 | unset(self::$config[$item]); |
| 130 | 130 | return true; |
| 131 | - } |
|
| 132 | - else{ |
|
| 131 | + } else{ |
|
| 133 | 132 | $logger->warning('Config item ['.$item.'] to be deleted does not exists'); |
| 134 | 133 | return false; |
| 135 | 134 | } |
@@ -179,8 +178,7 @@ discard block |
||
| 179 | 178 | 0, |
| 180 | 179 | strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])) |
| 181 | 180 | ); |
| 182 | - } |
|
| 183 | - else{ |
|
| 181 | + } else{ |
|
| 184 | 182 | $logger->warning('Can not determine the application base URL automatically, use http://localhost as default'); |
| 185 | 183 | $baseUrl = 'http://localhost/'; |
| 186 | 184 | } |
@@ -234,8 +234,7 @@ discard block |
||
| 234 | 234 | //first check for CSRF |
| 235 | 235 | if (get_config('csrf_enable', false) && ! Security::validateCSRF()){ |
| 236 | 236 | show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.'); |
| 237 | - } |
|
| 238 | - else{ |
|
| 237 | + } else{ |
|
| 239 | 238 | $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it'); |
| 240 | 239 | } |
| 241 | 240 | } |
@@ -255,8 +254,7 @@ discard block |
||
| 255 | 254 | foreach ($this->getData() as $inputName => $inputVal) { |
| 256 | 255 | if(is_array($this->data[$inputName])){ |
| 257 | 256 | $this->data[$inputName] = array_map('trim', $this->data[$inputName]); |
| 258 | - } |
|
| 259 | - else{ |
|
| 257 | + } else{ |
|
| 260 | 258 | $this->data[$inputName] = trim($this->data[$inputName]); |
| 261 | 259 | } |
| 262 | 260 | |
@@ -624,8 +622,7 @@ discard block |
||
| 624 | 622 | if ($inputVal == '' && $callbackReturn == true) { |
| 625 | 623 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 626 | 624 | } |
| 627 | - } |
|
| 628 | - else if($inputVal == '') { |
|
| 625 | + } else if($inputVal == '') { |
|
| 629 | 626 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 630 | 627 | } |
| 631 | 628 | } |
@@ -684,8 +681,7 @@ discard block |
||
| 684 | 681 | $this->_setError($inputName, $ruleName . ',post:key', array($this->_getLabel($inputName), $this->_getLabel(str_replace('post:', '', $doNotEqual)))); |
| 685 | 682 | continue; |
| 686 | 683 | } |
| 687 | - } |
|
| 688 | - else{ |
|
| 684 | + } else{ |
|
| 689 | 685 | if ($inputVal == $doNotEqual) { |
| 690 | 686 | $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual)); |
| 691 | 687 | continue; |
@@ -48,8 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | if(is_object($logger)){ |
| 50 | 50 | $this->logger = $logger; |
| 51 | - } |
|
| 52 | - else{ |
|
| 51 | + } else{ |
|
| 53 | 52 | $this->logger =& class_loader('Log', 'classes'); |
| 54 | 53 | $this->logger->setLogger('Library::FileCache'); |
| 55 | 54 | } |
@@ -95,8 +94,7 @@ discard block |
||
| 95 | 94 | // Unlinking when the file was expired |
| 96 | 95 | unlink($filePath); |
| 97 | 96 | return false; |
| 98 | - } |
|
| 99 | - else{ |
|
| 97 | + } else{ |
|
| 100 | 98 | $this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']'); |
| 101 | 99 | return $data['data']; |
| 102 | 100 | } |
@@ -133,8 +131,7 @@ discard block |
||
| 133 | 131 | $this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false'); |
| 134 | 132 | fclose($handle); |
| 135 | 133 | return false; |
| 136 | - } |
|
| 137 | - else{ |
|
| 134 | + } else{ |
|
| 138 | 135 | $this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']'); |
| 139 | 136 | fclose($handle); |
| 140 | 137 | chmod($filePath, 0640); |
@@ -156,8 +153,7 @@ discard block |
||
| 156 | 153 | if(! file_exists($filePath)){ |
| 157 | 154 | $this->logger->info('This cache file does not exists skipping'); |
| 158 | 155 | return false; |
| 159 | - } |
|
| 160 | - else{ |
|
| 156 | + } else{ |
|
| 161 | 157 | $this->logger->info('Found cache file [' .$filePath. '] remove it'); |
| 162 | 158 | unlink($filePath); |
| 163 | 159 | return true; |
@@ -210,8 +206,7 @@ discard block |
||
| 210 | 206 | $list = glob(CACHE_PATH . '*.cache'); |
| 211 | 207 | if(! $list){ |
| 212 | 208 | $this->logger->info('No cache files were found skipping'); |
| 213 | - } |
|
| 214 | - else{ |
|
| 209 | + } else{ |
|
| 215 | 210 | $this->logger->info('Found [' . count($list) . '] cache files to remove if expired'); |
| 216 | 211 | foreach ($list as $file) { |
| 217 | 212 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -219,12 +214,10 @@ discard block |
||
| 219 | 214 | $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data); |
| 220 | 215 | if(! $data){ |
| 221 | 216 | $this->logger->warning('Can not unserialize the cache data for file [' . $file . ']'); |
| 222 | - } |
|
| 223 | - else if(time() > $data['expire']){ |
|
| 217 | + } else if(time() > $data['expire']){ |
|
| 224 | 218 | $this->logger->info('The cache data for file [' . $file . '] already expired remove it'); |
| 225 | 219 | unlink($file); |
| 226 | - } |
|
| 227 | - else{ |
|
| 220 | + } else{ |
|
| 228 | 221 | $this->logger->info('The cache data for file [' . $file . '] not yet expired skip it'); |
| 229 | 222 | } |
| 230 | 223 | } |
@@ -239,8 +232,7 @@ discard block |
||
| 239 | 232 | $list = glob(CACHE_PATH . '*.cache'); |
| 240 | 233 | if(! $list){ |
| 241 | 234 | $this->logger->info('No cache files were found skipping'); |
| 242 | - } |
|
| 243 | - else{ |
|
| 235 | + } else{ |
|
| 244 | 236 | $this->logger->info('Found [' . count($list) . '] cache files to remove'); |
| 245 | 237 | foreach ($list as $file) { |
| 246 | 238 | $this->logger->debug('Processing the cache file [' . $file . ']'); |
@@ -267,8 +259,7 @@ discard block |
||
| 267 | 259 | |
| 268 | 260 | $this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE'); |
| 269 | 261 | $this->compressCacheData = false; |
| 270 | - } |
|
| 271 | - else{ |
|
| 262 | + } else{ |
|
| 272 | 263 | $this->compressCacheData = $status; |
| 273 | 264 | } |
| 274 | 265 | return $this; |