@@ -249,8 +249,7 @@ |
||
| 249 | 249 | ini_set('display_errors', 0); |
| 250 | 250 | if (version_compare(PHP_VERSION, '5.3', '>=')) { |
| 251 | 251 | error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); |
| 252 | - } |
|
| 253 | - else { |
|
| 252 | + } else { |
|
| 254 | 253 | error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); |
| 255 | 254 | } |
| 256 | 255 | break; |
@@ -69,14 +69,14 @@ |
||
| 69 | 69 | * @param string $item the cookie item name to be cleared |
| 70 | 70 | * @return boolean true if the item exists and is deleted successfully otherwise will return false. |
| 71 | 71 | */ |
| 72 | - public static function delete($item){ |
|
| 72 | + public static function delete($item) { |
|
| 73 | 73 | $logger = self::getLogger(); |
| 74 | - if(array_key_exists($item, $_COOKIE)){ |
|
| 75 | - $logger->info('Delete cookie item ['.$item.']'); |
|
| 74 | + if (array_key_exists($item, $_COOKIE)) { |
|
| 75 | + $logger->info('Delete cookie item [' . $item . ']'); |
|
| 76 | 76 | unset($_COOKIE[$item]); |
| 77 | 77 | return true; |
| 78 | - } else{ |
|
| 79 | - $logger->warning('Cookie item ['.$item.'] to be deleted does not exists'); |
|
| 78 | + } else { |
|
| 79 | + $logger->warning('Cookie item [' . $item . '] to be deleted does not exists'); |
|
| 80 | 80 | return false; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | $this->_forceFail = false; |
| 246 | 246 | |
| 247 | 247 | foreach ($this->getData() as $inputName => $inputVal) { |
| 248 | - if(is_array($this->data[$inputName])){ |
|
| 248 | + if (is_array($this->data[$inputName])) { |
|
| 249 | 249 | $this->data[$inputName] = array_map('trim', $this->data[$inputName]); |
| 250 | - } else{ |
|
| 250 | + } else { |
|
| 251 | 251 | $this->data[$inputName] = trim($this->data[$inputName]); |
| 252 | 252 | } |
| 253 | 253 | |
@@ -607,12 +607,12 @@ discard block |
||
| 607 | 607 | */ |
| 608 | 608 | protected function _validateRequired($inputName, $ruleName, array $ruleArgs) { |
| 609 | 609 | $inputVal = $this->post($inputName); |
| 610 | - if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) { |
|
| 610 | + if (array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) { |
|
| 611 | 611 | $callbackReturn = $this->_runEmptyCallback($ruleArgs[1]); |
| 612 | 612 | if ($inputVal == '' && $callbackReturn == true) { |
| 613 | 613 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 614 | 614 | } |
| 615 | - } else if($inputVal == '') { |
|
| 615 | + } else if ($inputVal == '') { |
|
| 616 | 616 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 617 | 617 | } |
| 618 | 618 | } |
@@ -48,16 +48,14 @@ discard block |
||
| 48 | 48 | require_once CONFIG_PATH . 'config_pagination.php'; |
| 49 | 49 | if (empty($config) || !is_array($config)) { |
| 50 | 50 | show_error('No configuration found in ' . CONFIG_PATH . 'config_pagination.php'); |
| 51 | - } |
|
| 52 | - else { |
|
| 51 | + } else { |
|
| 53 | 52 | $config = array_merge($config, $overwriteConfig); |
| 54 | 53 | $this->config = $config; |
| 55 | 54 | //put it gobally |
| 56 | 55 | Config::setAll($config); |
| 57 | 56 | unset($config); |
| 58 | 57 | } |
| 59 | - } |
|
| 60 | - else { |
|
| 58 | + } else { |
|
| 61 | 59 | show_error('Unable to find the pagination configuration file'); |
| 62 | 60 | } |
| 63 | 61 | } |
@@ -177,11 +175,9 @@ discard block |
||
| 177 | 175 | $navbar = null; |
| 178 | 176 | if ($currentPageNumber == 1) { |
| 179 | 177 | $navbar .= $this->buildPaginationLinkForFirstPage($begin, $end, $currentPageNumber); |
| 180 | - } |
|
| 181 | - else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage) { |
|
| 178 | + } else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage) { |
|
| 182 | 179 | $navbar .= $this->buildPaginationLinkForMiddlePage($begin, $end, $currentPageNumber); |
| 183 | - } |
|
| 184 | - else if ($currentPageNumber == $numberOfPage) { |
|
| 180 | + } else if ($currentPageNumber == $numberOfPage) { |
|
| 185 | 181 | $navbar .= $this->buildPaginationLinkForLastPage($begin, $end, $currentPageNumber); |
| 186 | 182 | } |
| 187 | 183 | $navbar = $this->config['pagination_open'] . $navbar . $this->config['pagination_close']; |
@@ -55,14 +55,14 @@ |
||
| 55 | 55 | * @return string|void if $stream is true send PDF document to browser for download, else return the generated PDF |
| 56 | 56 | * content like to join in Email attachment of for other purpose use. |
| 57 | 57 | */ |
| 58 | - public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait'){ |
|
| 59 | - $this->logger->info('Generating of PDF document: filename [' .$filename. '], stream [' .($stream ? 'TRUE':'FALSE'). '], paper [' .$paper. '], orientation [' .$orientation. ']'); |
|
| 58 | + public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait') { |
|
| 59 | + $this->logger->info('Generating of PDF document: filename [' . $filename . '], stream [' . ($stream ? 'TRUE' : 'FALSE') . '], paper [' . $paper . '], orientation [' . $orientation . ']'); |
|
| 60 | 60 | $this->dompdf->load_html($html); |
| 61 | 61 | $this->dompdf->set_paper($paper, $orientation); |
| 62 | 62 | $this->dompdf->render(); |
| 63 | - if($stream){ |
|
| 63 | + if ($stream) { |
|
| 64 | 64 | $this->dompdf->stream($filename); |
| 65 | - } else{ |
|
| 65 | + } else { |
|
| 66 | 66 | return $this->dompdf->output(); |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -142,9 +142,9 @@ |
||
| 142 | 142 | public function setTos(array $emails) |
| 143 | 143 | { |
| 144 | 144 | foreach ($emails as $name => $email) { |
| 145 | - if(is_numeric($name)){ |
|
| 145 | + if (is_numeric($name)) { |
|
| 146 | 146 | $this->setTo($email); |
| 147 | - } else{ |
|
| 147 | + } else { |
|
| 148 | 148 | $this->setTo($email, $name); |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -222,16 +222,14 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | if (isset($http_status[$code])) { |
| 224 | 224 | $text = $http_status[$code]; |
| 225 | - } |
|
| 226 | - else { |
|
| 225 | + } else { |
|
| 227 | 226 | show_error('No HTTP status text found for your code please check it.'); |
| 228 | 227 | } |
| 229 | 228 | } |
| 230 | 229 | |
| 231 | 230 | if (strpos(php_sapi_name(), 'cgi') === 0) { |
| 232 | 231 | header('Status: ' . $code . ' ' . $text, TRUE); |
| 233 | - } |
|
| 234 | - else { |
|
| 232 | + } else { |
|
| 235 | 233 | $proto = 'HTTP/1.1'; |
| 236 | 234 | if (isset($_SERVER['SERVER_PROTOCOL'])) { |
| 237 | 235 | $proto = $_SERVER['SERVER_PROTOCOL']; |
@@ -323,8 +321,7 @@ discard block |
||
| 323 | 321 | function php_exception_handler($ex) { |
| 324 | 322 | if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) { |
| 325 | 323 | show_error('An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
| 326 | - } |
|
| 327 | - else { |
|
| 324 | + } else { |
|
| 328 | 325 | save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception'); |
| 329 | 326 | } |
| 330 | 327 | return true; |
@@ -440,15 +437,13 @@ discard block |
||
| 440 | 437 | function clean_input($str) { |
| 441 | 438 | if (is_array($str)) { |
| 442 | 439 | $str = array_map('clean_input', $str); |
| 443 | - } |
|
| 444 | - else if (is_object($str)) { |
|
| 440 | + } else if (is_object($str)) { |
|
| 445 | 441 | $obj = $str; |
| 446 | 442 | foreach ($str as $var => $value) { |
| 447 | 443 | $obj->$var = clean_input($value); |
| 448 | 444 | } |
| 449 | 445 | $str = $obj; |
| 450 | - } |
|
| 451 | - else { |
|
| 446 | + } else { |
|
| 452 | 447 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
| 453 | 448 | } |
| 454 | 449 | return $str; |
@@ -521,8 +516,7 @@ discard block |
||
| 521 | 516 | session_save_path($sessionSavePath); |
| 522 | 517 | $logger->info('Session save path: ' . $sessionSavePath); |
| 523 | 518 | } |
| 524 | - } |
|
| 525 | - else if ($sessionHandler == 'database') { |
|
| 519 | + } else if ($sessionHandler == 'database') { |
|
| 526 | 520 | //load database session handle library |
| 527 | 521 | //Database Session handler Model |
| 528 | 522 | require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php'; |
@@ -530,8 +524,7 @@ discard block |
||
| 530 | 524 | $DBS = & class_loader('DBSessionHandler', 'classes'); |
| 531 | 525 | session_set_save_handler($DBS, true); |
| 532 | 526 | $logger->info('session save path: ' . get_config('session_save_path')); |
| 533 | - } |
|
| 534 | - else { |
|
| 527 | + } else { |
|
| 535 | 528 | show_error('Invalid session handler configuration'); |
| 536 | 529 | } |
| 537 | 530 | $lifetime = get_config('session_cookie_lifetime', 0); |
@@ -15,9 +15,9 @@ |
||
| 15 | 15 | $lang['fv_not_equal_string'] = 'Field %1 must not contain the value %2.'; |
| 16 | 16 | $lang['fv_depends'] = 'Field %1 depends on field %2 which is not valid.'; |
| 17 | 17 | $lang['fv_is_unique'] = 'The value of field %1 already exists.'; |
| 18 | - $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
|
| 18 | + $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
|
| 19 | 19 | $lang['fv_exists'] = 'The value of the field %1 does not exist.'; |
| 20 | - $lang['fv_regex'] = 'The value of the field %1 does not use the correct format.'; |
|
| 20 | + $lang['fv_regex'] = 'The value of the field %1 does not use the correct format.'; |
|
| 21 | 21 | $lang['fv_in_list'] = 'The value of field %1 must be one of the list (%2).'; |
| 22 | 22 | $lang['fv_numeric'] = 'The value of field %1 must be a number.'; |
| 23 | 23 | $lang['fv_callback'] = 'The value of field %1 is not valid.'; |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | * @param string $eventName the name of the event to register for |
| 48 | 48 | * @param callable $listener the function or class method to receive the event information after dispatch |
| 49 | 49 | */ |
| 50 | - public function addListener($eventName, callable $listener){ |
|
| 51 | - $this->logger->debug('Adding new event listener for the event name [' .$eventName. '], listener [' .stringfy_vars($listener). ']'); |
|
| 52 | - if(! isset($this->listeners[$eventName])){ |
|
| 50 | + public function addListener($eventName, callable $listener) { |
|
| 51 | + $this->logger->debug('Adding new event listener for the event name [' . $eventName . '], listener [' . stringfy_vars($listener) . ']'); |
|
| 52 | + if (!isset($this->listeners[$eventName])) { |
|
| 53 | 53 | $this->logger->info('This event does not have the registered event listener before, adding new one'); |
| 54 | 54 | $this->listeners[$eventName] = array(); |
| 55 | - } else{ |
|
| 55 | + } else { |
|
| 56 | 56 | $this->logger->info('This event already have the registered listener, add this listener to the list'); |
| 57 | 57 | } |
| 58 | 58 | $this->listeners[$eventName][] = $listener; |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | * @param string $eventName the event name |
| 64 | 64 | * @param callable $listener the listener callback |
| 65 | 65 | */ |
| 66 | - public function removeListener($eventName, callable $listener){ |
|
| 67 | - $this->logger->debug('Removing of the event listener, the event name [' .$eventName. '], listener [' .stringfy_vars($listener). ']'); |
|
| 68 | - if(isset($this->listeners[$eventName])){ |
|
| 66 | + public function removeListener($eventName, callable $listener) { |
|
| 67 | + $this->logger->debug('Removing of the event listener, the event name [' . $eventName . '], listener [' . stringfy_vars($listener) . ']'); |
|
| 68 | + if (isset($this->listeners[$eventName])) { |
|
| 69 | 69 | $this->logger->info('This event have the listeners, check if this listener exists'); |
| 70 | - if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){ |
|
| 71 | - $this->logger->info('Found the listener at index [' .$index. '] remove it'); |
|
| 70 | + if (false !== $index = array_search($listener, $this->listeners[$eventName], true)) { |
|
| 71 | + $this->logger->info('Found the listener at index [' . $index . '] remove it'); |
|
| 72 | 72 | unset($this->listeners[$eventName][$index]); |
| 73 | - } else{ |
|
| 73 | + } else { |
|
| 74 | 74 | $this->logger->info('Cannot found this listener in the event listener list'); |
| 75 | 75 | } |
| 76 | - } else{ |
|
| 76 | + } else { |
|
| 77 | 77 | $this->logger->info('This event does not have this listener ignore remove'); |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -83,12 +83,12 @@ discard block |
||
| 83 | 83 | * remove all listeners for this event |
| 84 | 84 | * @param string $eventName the event name |
| 85 | 85 | */ |
| 86 | - public function removeAllListener($eventName = null){ |
|
| 87 | - $this->logger->debug('Removing of all event listener, the event name [' .$eventName. ']'); |
|
| 88 | - if($eventName !== null && isset($this->listeners[$eventName])){ |
|
| 86 | + public function removeAllListener($eventName = null) { |
|
| 87 | + $this->logger->debug('Removing of all event listener, the event name [' . $eventName . ']'); |
|
| 88 | + if ($eventName !== null && isset($this->listeners[$eventName])) { |
|
| 89 | 89 | $this->logger->info('The event name is set of exist in the listener just remove all event listener for this event'); |
| 90 | 90 | unset($this->listeners[$eventName]); |
| 91 | - } else{ |
|
| 91 | + } else { |
|
| 92 | 92 | $this->logger->info('The event name is not set or does not exist in the listener, so remove all event listener'); |
| 93 | 93 | $this->listeners = array(); |
| 94 | 94 | } |
@@ -108,20 +108,20 @@ discard block |
||
| 108 | 108 | * @param mixed|object $event the event information |
| 109 | 109 | * @return void|object if event need return, will return the final EventInfo object. |
| 110 | 110 | */ |
| 111 | - public function dispatch($event){ |
|
| 112 | - if(! $event || !$event instanceof EventInfo){ |
|
| 111 | + public function dispatch($event) { |
|
| 112 | + if (!$event || !$event instanceof EventInfo) { |
|
| 113 | 113 | $this->logger->info('The event is not set or is not an instance of "EventInfo" create the default "EventInfo" object to use instead of.'); |
| 114 | 114 | $event = new EventInfo((string) $event); |
| 115 | 115 | } |
| 116 | - $this->logger->debug('Dispatch to the event listener, the event [' .stringfy_vars($event). ']'); |
|
| 117 | - if(isset($event->stop) && $event->stop){ |
|
| 116 | + $this->logger->debug('Dispatch to the event listener, the event [' . stringfy_vars($event) . ']'); |
|
| 117 | + if (isset($event->stop) && $event->stop) { |
|
| 118 | 118 | $this->logger->info('This event need stopped, no need call any listener'); |
| 119 | 119 | return; |
| 120 | 120 | } |
| 121 | - if($event->returnBack){ |
|
| 121 | + if ($event->returnBack) { |
|
| 122 | 122 | $this->logger->info('This event need return back, return the result for future use'); |
| 123 | 123 | return $this->dispatchToListerners($event); |
| 124 | - } else{ |
|
| 124 | + } else { |
|
| 125 | 125 | $this->logger->info('This event no need return back the result, just dispatch it'); |
| 126 | 126 | $this->dispatchToListerners($event); |
| 127 | 127 | } |
@@ -132,35 +132,35 @@ discard block |
||
| 132 | 132 | * @param object EventInfo $event the event information |
| 133 | 133 | * @return void|object if event need return, will return the final EventInfo instance. |
| 134 | 134 | */ |
| 135 | - private function dispatchToListerners(EventInfo $event){ |
|
| 135 | + private function dispatchToListerners(EventInfo $event) { |
|
| 136 | 136 | $eBackup = $event; |
| 137 | 137 | $list = $this->getListeners($event->name); |
| 138 | - if(empty($list)){ |
|
| 139 | - $this->logger->info('No event listener is registered for the event [' .$event->name. '] skipping.'); |
|
| 140 | - if($event->returnBack){ |
|
| 138 | + if (empty($list)) { |
|
| 139 | + $this->logger->info('No event listener is registered for the event [' . $event->name . '] skipping.'); |
|
| 140 | + if ($event->returnBack) { |
|
| 141 | 141 | return $event; |
| 142 | 142 | } |
| 143 | 143 | return; |
| 144 | - } else{ |
|
| 145 | - $this->logger->info('Found the registered event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list)); |
|
| 144 | + } else { |
|
| 145 | + $this->logger->info('Found the registered event listener for the event [' . $event->name . '] the list are: ' . stringfy_vars($list)); |
|
| 146 | 146 | } |
| 147 | - foreach($list as $listener){ |
|
| 148 | - if($eBackup->returnBack){ |
|
| 147 | + foreach ($list as $listener) { |
|
| 148 | + if ($eBackup->returnBack) { |
|
| 149 | 149 | $returnedEvent = call_user_func_array($listener, array($event)); |
| 150 | - if($returnedEvent instanceof EventInfo){ |
|
| 150 | + if ($returnedEvent instanceof EventInfo) { |
|
| 151 | 151 | $event = $returnedEvent; |
| 152 | - } else{ |
|
| 153 | - show_error('This event [' .$event->name. '] need you return the event object after processing'); |
|
| 152 | + } else { |
|
| 153 | + show_error('This event [' . $event->name . '] need you return the event object after processing'); |
|
| 154 | 154 | } |
| 155 | - } else{ |
|
| 155 | + } else { |
|
| 156 | 156 | call_user_func_array($listener, array($event)); |
| 157 | 157 | } |
| 158 | - if($event->stop){ |
|
| 158 | + if ($event->stop) { |
|
| 159 | 159 | break; |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | //only test for original event may be during the flow some listeners change this parameter |
| 163 | - if($eBackup->returnBack){ |
|
| 163 | + if ($eBackup->returnBack) { |
|
| 164 | 164 | return $event; |
| 165 | 165 | } |
| 166 | 166 | } |