@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function __construct() |
| 88 | 88 | { |
| 89 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 89 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 90 | 90 | $this->logger->setLogger('Library::Email'); |
| 91 | 91 | $this->reset(); |
| 92 | 92 | } |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | public function setTos(array $emails) |
| 149 | 149 | { |
| 150 | 150 | foreach ($emails as $name => $email) { |
| 151 | - if(is_numeric($name)){ |
|
| 151 | + if (is_numeric($name)) { |
|
| 152 | 152 | $this->setTo($email); |
| 153 | 153 | } |
| 154 | - else{ |
|
| 154 | + else { |
|
| 155 | 155 | $this->setTo($email, $name); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public function addAttachment($path, $filename = null, $data = null) |
| 283 | 283 | { |
| 284 | - if(! file_exists($path)){ |
|
| 285 | - show_error('The file [' .$path. '] does not exists.'); |
|
| 284 | + if (!file_exists($path)) { |
|
| 285 | + show_error('The file [' . $path . '] does not exists.'); |
|
| 286 | 286 | } |
| 287 | 287 | $filename = empty($filename) ? basename($path) : $filename; |
| 288 | 288 | $filename = $this->encodeUtf8($this->filterOther((string) $filename)); |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function getAttachmentData($path) |
| 306 | 306 | { |
| 307 | - if(! file_exists($path)){ |
|
| 308 | - show_error('The file [' .$path. '] does not exists.'); |
|
| 307 | + if (!file_exists($path)) { |
|
| 308 | + show_error('The file [' . $path . '] does not exists.'); |
|
| 309 | 309 | } |
| 310 | 310 | $filesize = filesize($path); |
| 311 | 311 | $handle = fopen($path, "r"); |
| 312 | 312 | $attachment = null; |
| 313 | - if(is_resource($handle)){ |
|
| 313 | + if (is_resource($handle)) { |
|
| 314 | 314 | $attachment = fread($handle, $filesize); |
| 315 | 315 | fclose($handle); |
| 316 | 316 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @package FileUpload |
| 38 | 38 | * @version 1.5 |
| 39 | 39 | */ |
| 40 | - class Upload{ |
|
| 40 | + class Upload { |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Version |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @version 1.0 |
| 70 | 70 | * @var array |
| 71 | 71 | */ |
| 72 | - private $file_array = array(); |
|
| 72 | + private $file_array = array(); |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * If the file you are trying to upload already exists it will |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @version 1.0 |
| 120 | 120 | * @var float |
| 121 | 121 | */ |
| 122 | - private $max_file_size= 0.0; |
|
| 122 | + private $max_file_size = 0.0; |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * List of allowed mime types |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | * @return object |
| 218 | 218 | * @method object __construct |
| 219 | 219 | */ |
| 220 | - public function __construct(){ |
|
| 221 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 220 | + public function __construct() { |
|
| 221 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 222 | 222 | $this->logger->setLogger('Library::Upload'); |
| 223 | 223 | |
| 224 | 224 | Loader::lang('file_upload'); |
| 225 | - $obj =& get_instance(); |
|
| 225 | + $obj = & get_instance(); |
|
| 226 | 226 | |
| 227 | 227 | $this->error_messages = array( |
| 228 | 228 | 'upload_err_ini_size' => $obj->lang->get('fu_upload_err_ini_size'), |
@@ -239,15 +239,15 @@ discard block |
||
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | 241 | $this->file = array( |
| 242 | - 'status' => false, // True: success upload |
|
| 243 | - 'mime' => '', // Empty string |
|
| 244 | - 'filename' => '', // Empty string |
|
| 245 | - 'original' => '', // Empty string |
|
| 246 | - 'size' => 0, // 0 Bytes |
|
| 247 | - 'sizeFormated' => '0B', // 0 Bytes |
|
| 248 | - 'destination' => './', // Default: ./ |
|
| 249 | - 'allowed_mime_types' => array(), // Allowed mime types |
|
| 250 | - 'error' => null, // File error |
|
| 242 | + 'status' => false, // True: success upload |
|
| 243 | + 'mime' => '', // Empty string |
|
| 244 | + 'filename' => '', // Empty string |
|
| 245 | + 'original' => '', // Empty string |
|
| 246 | + 'size' => 0, // 0 Bytes |
|
| 247 | + 'sizeFormated' => '0B', // 0 Bytes |
|
| 248 | + 'destination' => './', // Default: ./ |
|
| 249 | + 'allowed_mime_types' => array(), // Allowed mime types |
|
| 250 | + 'error' => null, // File error |
|
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | 253 | // Change dir to current dir |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | } elseif (isset($HTTP_POST_FILES) && is_array($HTTP_POST_FILES)) { |
| 260 | 260 | $this->file_array = $HTTP_POST_FILES; |
| 261 | 261 | } |
| 262 | - $this->logger->info('The upload file information are : ' .stringfy_vars($this->file_array)); |
|
| 262 | + $this->logger->info('The upload file information are : ' . stringfy_vars($this->file_array)); |
|
| 263 | 263 | } |
| 264 | 264 | /** |
| 265 | 265 | * Set input. |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | public function setInput($input) |
| 277 | 277 | { |
| 278 | - if (!empty($input) && (is_string($input) || is_numeric($input) )) { |
|
| 278 | + if (!empty($input) && (is_string($input) || is_numeric($input))) { |
|
| 279 | 279 | $this->input = $input; |
| 280 | 280 | } |
| 281 | 281 | return $this; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | public function setAutoFilename() |
| 313 | 313 | { |
| 314 | - $this->filename = sha1(mt_rand(1, 9999).uniqid()); |
|
| 314 | + $this->filename = sha1(mt_rand(1, 9999) . uniqid()); |
|
| 315 | 315 | $this->filename .= time(); |
| 316 | 316 | return $this; |
| 317 | 317 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | $php_size = $this->sizeInBytes((int) ini_get('upload_max_filesize')); |
| 333 | 333 | // Calculate difference |
| 334 | 334 | if ($php_size < $file_size) { |
| 335 | - $this->logger->warning('The upload max file size you set [' .$file_size. '] is greather than the PHP configuration for upload max file size [' .$php_size. ']'); |
|
| 335 | + $this->logger->warning('The upload max file size you set [' . $file_size . '] is greather than the PHP configuration for upload max file size [' . $php_size . ']'); |
|
| 336 | 336 | } |
| 337 | 337 | $this->max_file_size = $file_size; |
| 338 | 338 | } |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | public function setAllowedMimeTypes(array $mimes) |
| 351 | 351 | { |
| 352 | 352 | if (count($mimes) > 0) { |
| 353 | - array_map(array($this , 'setAllowMimeType'), $mimes); |
|
| 353 | + array_map(array($this, 'setAllowMimeType'), $mimes); |
|
| 354 | 354 | } |
| 355 | 355 | return $this; |
| 356 | 356 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | { |
| 416 | 416 | if (!empty($name) && is_string($name)) { |
| 417 | 417 | if (array_key_exists($name, $this->mime_helping)) { |
| 418 | - return $this->setAllowedMimeTypes($this->mime_helping[ $name ]); |
|
| 418 | + return $this->setAllowedMimeTypes($this->mime_helping[$name]); |
|
| 419 | 419 | } |
| 420 | 420 | } |
| 421 | 421 | return $this; |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | public function setUploadFunction($function) |
| 436 | 436 | { |
| 437 | - if (!empty($function) && (is_array($function) || is_string($function) )) { |
|
| 438 | - if (is_callable( $function)) { |
|
| 437 | + if (!empty($function) && (is_array($function) || is_string($function))) { |
|
| 438 | + if (is_callable($function)) { |
|
| 439 | 439 | $this->upload_function = $function; |
| 440 | 440 | } |
| 441 | 441 | } |
@@ -488,8 +488,8 @@ discard block |
||
| 488 | 488 | chdir($destination_directory); |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | - else{ |
|
| 492 | - $this->logger->warning('Can not create the upload directory [' .$destination_directory. ']'); |
|
| 491 | + else { |
|
| 492 | + $this->logger->warning('Can not create the upload directory [' . $destination_directory . ']'); |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | public function isFilename($filename) |
| 540 | 540 | { |
| 541 | 541 | $filename = basename($filename); |
| 542 | - return (!empty($filename) && (is_string( $filename) || is_numeric($filename))); |
|
| 542 | + return (!empty($filename) && (is_string($filename) || is_numeric($filename))); |
|
| 543 | 543 | } |
| 544 | 544 | /** |
| 545 | 545 | * Validate mime type with allowed mime types, |
@@ -581,11 +581,11 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | public function isDirpath($path) |
| 583 | 583 | { |
| 584 | - if (!empty( $path) && (is_string( $path) || is_numeric($path) )) { |
|
| 584 | + if (!empty($path) && (is_string($path) || is_numeric($path))) { |
|
| 585 | 585 | if (DIRECTORY_SEPARATOR == '/') { |
| 586 | - return (preg_match( '/^[^*?"<>|:]*$/' , $path) == 1 ); |
|
| 586 | + return (preg_match('/^[^*?"<>|:]*$/', $path) == 1); |
|
| 587 | 587 | } else { |
| 588 | - return (preg_match( "/^[^*?\"<>|:]*$/" , substr($path,2) ) == 1); |
|
| 588 | + return (preg_match("/^[^*?\"<>|:]*$/", substr($path, 2)) == 1); |
|
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | return false; |
@@ -613,10 +613,10 @@ discard block |
||
| 613 | 613 | */ |
| 614 | 614 | public function getInfo() |
| 615 | 615 | { |
| 616 | - return (object)$this->file; |
|
| 616 | + return (object) $this->file; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - public function isUploaded(){ |
|
| 619 | + public function isUploaded() { |
|
| 620 | 620 | return isset($this->file_array[$this->input]) |
| 621 | 621 | && |
| 622 | 622 | is_uploaded_file($this->file_array[$this->input]['tmp_name']); |
@@ -629,9 +629,9 @@ discard block |
||
| 629 | 629 | * @return boolean |
| 630 | 630 | * @method boolean save |
| 631 | 631 | */ |
| 632 | - public function save(){ |
|
| 632 | + public function save() { |
|
| 633 | 633 | //check if file upload is allowed in the configuration |
| 634 | - if(! ini_get('file_uploads')){ |
|
| 634 | + if (!ini_get('file_uploads')) { |
|
| 635 | 635 | $this->setError($this->error_messages['file_uploads']); |
| 636 | 636 | return false; |
| 637 | 637 | } |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | if (empty($this->filename)) { |
| 642 | 642 | $this->filename = $this->file_array[$this->input]['name']; |
| 643 | 643 | } |
| 644 | - else{ |
|
| 644 | + else { |
|
| 645 | 645 | // Replace %s for extension in filename |
| 646 | 646 | // Before: /[\w\d]*(.[\d\w]+)$/i |
| 647 | 647 | // After: /^[\s[:alnum:]\-\_\.]*\.([\d\w]+)$/iu |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | '$1', |
| 653 | 653 | $this->file_array[$this->input]['name'] |
| 654 | 654 | ); |
| 655 | - $this->filename = $this->filename.'.'.$extension; |
|
| 655 | + $this->filename = $this->filename . '.' . $extension; |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | // set file info |
@@ -665,10 +665,10 @@ discard block |
||
| 665 | 665 | $this->file['filename'] = $this->filename; |
| 666 | 666 | $this->file['error'] = $this->file_array[$this->input]['error']; |
| 667 | 667 | |
| 668 | - $this->logger->info('The upload file information to process is : ' .stringfy_vars($this->file)); |
|
| 668 | + $this->logger->info('The upload file information to process is : ' . stringfy_vars($this->file)); |
|
| 669 | 669 | |
| 670 | 670 | //check for php upload error |
| 671 | - if(is_numeric($this->file['error']) && $this->file['error'] > 0){ |
|
| 671 | + if (is_numeric($this->file['error']) && $this->file['error'] > 0) { |
|
| 672 | 672 | $this->setError($this->getPhpUploadErrorMessageByCode($this->file['error'])); |
| 673 | 673 | return false; |
| 674 | 674 | } |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | // Execute input callback |
| 700 | - if (!empty( $this->callbacks['input'])) { |
|
| 701 | - call_user_func($this->callbacks['input'], (object)$this->file); |
|
| 700 | + if (!empty($this->callbacks['input'])) { |
|
| 701 | + call_user_func($this->callbacks['input'], (object) $this->file); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | |
@@ -710,8 +710,8 @@ discard block |
||
| 710 | 710 | ); |
| 711 | 711 | |
| 712 | 712 | // Execute output callback |
| 713 | - if (!empty( $this->callbacks['output'])) { |
|
| 714 | - call_user_func($this->callbacks['output'], (object)$this->file); |
|
| 713 | + if (!empty($this->callbacks['output'])) { |
|
| 714 | + call_user_func($this->callbacks['output'], (object) $this->file); |
|
| 715 | 715 | } |
| 716 | 716 | return $this->file['status']; |
| 717 | 717 | } |
@@ -730,10 +730,10 @@ discard block |
||
| 730 | 730 | */ |
| 731 | 731 | public function sizeFormat($size, $precision = 2) |
| 732 | 732 | { |
| 733 | - if($size > 0){ |
|
| 733 | + if ($size > 0) { |
|
| 734 | 734 | $base = log($size) / log(1024); |
| 735 | 735 | $suffixes = array('B', 'K', 'M', 'G', 'T'); |
| 736 | - return round(pow(1024, $base - floor($base)), $precision) . ( isset($suffixes[floor($base)]) ? $suffixes[floor($base)] : ''); |
|
| 736 | + return round(pow(1024, $base - floor($base)), $precision) . (isset($suffixes[floor($base)]) ? $suffixes[floor($base)] : ''); |
|
| 737 | 737 | } |
| 738 | 738 | return null; |
| 739 | 739 | } |
@@ -757,14 +757,14 @@ discard block |
||
| 757 | 757 | if (array_key_exists('unit', $matches)) { |
| 758 | 758 | $unit = strtoupper($matches['unit']); |
| 759 | 759 | } |
| 760 | - return (floatval($matches['size']) * pow(1024, $units[$unit]) ) ; |
|
| 760 | + return (floatval($matches['size']) * pow(1024, $units[$unit])); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | /** |
| 764 | 764 | * Get the upload error message |
| 765 | 765 | * @return string |
| 766 | 766 | */ |
| 767 | - public function getError(){ |
|
| 767 | + public function getError() { |
|
| 768 | 768 | return $this->error; |
| 769 | 769 | } |
| 770 | 770 | |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | * Set the upload error message |
| 773 | 773 | * @param string $message the upload error message to set |
| 774 | 774 | */ |
| 775 | - public function setError($message){ |
|
| 775 | + public function setError($message) { |
|
| 776 | 776 | $this->logger->info('The upload got error : ' . $message); |
| 777 | 777 | $this->error = $message; |
| 778 | 778 | } |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | * @param int $code the error code |
| 783 | 783 | * @return string the error message |
| 784 | 784 | */ |
| 785 | - private function getPhpUploadErrorMessageByCode($code){ |
|
| 785 | + private function getPhpUploadErrorMessageByCode($code) { |
|
| 786 | 786 | $codeMessageMaps = array( |
| 787 | 787 | 1 => $this->error_messages['upload_err_ini_size'], |
| 788 | 788 | 2 => $this->error_messages['upload_err_form_size'], |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | //put the first letter of class to upper case |
| 54 | 54 | $class = ucfirst($class); |
| 55 | 55 | static $classes = array(); |
| 56 | - if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){ |
|
| 56 | + if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log') { |
|
| 57 | 57 | return $classes[$class]; |
| 58 | 58 | } |
| 59 | 59 | $found = false; |
| 60 | 60 | foreach (array(ROOT_PATH, CORE_PATH) as $path) { |
| 61 | 61 | $file = $path . $dir . '/' . $class . '.php'; |
| 62 | - if(file_exists($file)){ |
|
| 63 | - if(class_exists($class, false) === false){ |
|
| 62 | + if (file_exists($file)) { |
|
| 63 | + if (class_exists($class, false) === false) { |
|
| 64 | 64 | require_once $file; |
| 65 | 65 | } |
| 66 | 66 | //already found |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | break; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - if(! $found){ |
|
| 71 | + if (!$found) { |
|
| 72 | 72 | //can't use show_error() at this time because some dependencies not yet loaded |
| 73 | 73 | set_http_status_header(503); |
| 74 | 74 | echo 'Cannot find the class [' . $class . ']'; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | /* |
| 79 | 79 | TODO use the best method to get the Log instance |
| 80 | 80 | */ |
| 81 | - if($class == 'Log'){ |
|
| 81 | + if ($class == 'Log') { |
|
| 82 | 82 | //can't use the instruction like "return new Log()" |
| 83 | 83 | //because we need return the reference instance of the loaded class. |
| 84 | 84 | $log = new Log(); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | function & class_loaded($class = null){ |
| 104 | 104 | static $list = array(); |
| 105 | - if($class !== null){ |
|
| 105 | + if ($class !== null) { |
|
| 106 | 106 | $list[strtolower($class)] = $class; |
| 107 | 107 | } |
| 108 | 108 | return $list; |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | function & load_configurations(array $overwrite_values = array()){ |
| 119 | 119 | static $config; |
| 120 | - if(empty($config)){ |
|
| 120 | + if (empty($config)) { |
|
| 121 | 121 | $file = CONFIG_PATH . 'config.php'; |
| 122 | 122 | $found = false; |
| 123 | - if(file_exists($file)){ |
|
| 123 | + if (file_exists($file)) { |
|
| 124 | 124 | require_once $file; |
| 125 | 125 | $found = true; |
| 126 | 126 | } |
| 127 | - if(! $found){ |
|
| 127 | + if (!$found) { |
|
| 128 | 128 | set_http_status_header(503); |
| 129 | 129 | echo 'Unable to find the configuration file [' . $file . ']'; |
| 130 | 130 | die(); |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @return mixed the config value |
| 146 | 146 | */ |
| 147 | - function get_config($key, $default = null){ |
|
| 147 | + function get_config($key, $default = null) { |
|
| 148 | 148 | static $cfg; |
| 149 | - if(empty($cfg)){ |
|
| 149 | + if (empty($cfg)) { |
|
| 150 | 150 | $cfg[0] = & load_configurations(); |
| 151 | 151 | } |
| 152 | 152 | return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default; |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | * |
| 161 | 161 | * @codeCoverageIgnore |
| 162 | 162 | */ |
| 163 | - function save_to_log($level, $message, $logger = null){ |
|
| 164 | - $log =& class_loader('Log', 'classes'); |
|
| 165 | - if($logger){ |
|
| 163 | + function save_to_log($level, $message, $logger = null) { |
|
| 164 | + $log = & class_loader('Log', 'classes'); |
|
| 165 | + if ($logger) { |
|
| 166 | 166 | $log->setLogger($logger); |
| 167 | 167 | } |
| 168 | 168 | $log->writeLog($message, $level); |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @codeCoverageIgnore |
| 177 | 177 | */ |
| 178 | - function set_http_status_header($code = 200, $text = null){ |
|
| 179 | - if(!is_numeric($code) || $code < 0 ){ |
|
| 178 | + function set_http_status_header($code = 200, $text = null) { |
|
| 179 | + if (!is_numeric($code) || $code < 0) { |
|
| 180 | 180 | show_error('HTTP status code must be an integer'); |
| 181 | 181 | } |
| 182 | - if(empty($text)){ |
|
| 182 | + if (empty($text)) { |
|
| 183 | 183 | $code = abs($code); |
| 184 | 184 | $http_status = array( |
| 185 | 185 | 100 => 'Continue', |
@@ -228,18 +228,18 @@ discard block |
||
| 228 | 228 | 504 => 'Gateway Timeout', |
| 229 | 229 | 505 => 'HTTP Version Not Supported', |
| 230 | 230 | ); |
| 231 | - if(isset($http_status[$code])){ |
|
| 231 | + if (isset($http_status[$code])) { |
|
| 232 | 232 | $text = $http_status[$code]; |
| 233 | 233 | } |
| 234 | - else{ |
|
| 234 | + else { |
|
| 235 | 235 | show_error('No HTTP status text found for your code please check it.'); |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - if(strpos(php_sapi_name(), 'cgi') === 0){ |
|
| 239 | + if (strpos(php_sapi_name(), 'cgi') === 0) { |
|
| 240 | 240 | header('Status: ' . $code . ' ' . $text, TRUE); |
| 241 | 241 | } |
| 242 | - else{ |
|
| 242 | + else { |
|
| 243 | 243 | $proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; |
| 244 | 244 | header($proto . ' ' . $code . ' ' . $text, TRUE, $code); |
| 245 | 245 | } |
@@ -254,13 +254,13 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @codeCoverageIgnore |
| 256 | 256 | */ |
| 257 | - function show_error($msg, $title = 'error', $logging = true){ |
|
| 257 | + function show_error($msg, $title = 'error', $logging = true) { |
|
| 258 | 258 | $title = strtoupper($title); |
| 259 | 259 | $data = array(); |
| 260 | 260 | $data['error'] = $msg; |
| 261 | 261 | $data['title'] = $title; |
| 262 | - if($logging){ |
|
| 263 | - save_to_log('error', '['.$title.'] '.strip_tags($msg), 'GLOBAL::ERROR'); |
|
| 262 | + if ($logging) { |
|
| 263 | + save_to_log('error', '[' . $title . '] ' . strip_tags($msg), 'GLOBAL::ERROR'); |
|
| 264 | 264 | } |
| 265 | 265 | $response = & class_loader('Response', 'classes'); |
| 266 | 266 | $response->sendError($data); |
@@ -274,18 +274,18 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @return boolean true if the web server uses the https protocol, false if not. |
| 276 | 276 | */ |
| 277 | - function is_https(){ |
|
| 277 | + function is_https() { |
|
| 278 | 278 | /* |
| 279 | 279 | * some servers pass the "HTTPS" parameter in the server variable, |
| 280 | 280 | * if is the case, check if the value is "on", "true", "1". |
| 281 | 281 | */ |
| 282 | - if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){ |
|
| 282 | + if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { |
|
| 283 | 283 | return true; |
| 284 | 284 | } |
| 285 | - else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ |
|
| 285 | + else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 286 | 286 | return true; |
| 287 | 287 | } |
| 288 | - else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){ |
|
| 288 | + else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { |
|
| 289 | 289 | return true; |
| 290 | 290 | } |
| 291 | 291 | return false; |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * |
| 301 | 301 | * @return boolean true if is a valid URL address or false. |
| 302 | 302 | */ |
| 303 | - function is_url($url){ |
|
| 303 | + function is_url($url) { |
|
| 304 | 304 | return preg_match('/^(http|https|ftp):\/\/(.*)/', $url) == 1; |
| 305 | 305 | } |
| 306 | 306 | |
@@ -310,8 +310,8 @@ discard block |
||
| 310 | 310 | * @param string $controllerClass the controller class name to be loaded |
| 311 | 311 | * @codeCoverageIgnore |
| 312 | 312 | */ |
| 313 | - function autoload_controller($controllerClass){ |
|
| 314 | - if(file_exists($path = APPS_CONTROLLER_PATH . $controllerClass . '.php')){ |
|
| 313 | + function autoload_controller($controllerClass) { |
|
| 314 | + if (file_exists($path = APPS_CONTROLLER_PATH . $controllerClass . '.php')) { |
|
| 315 | 315 | require_once $path; |
| 316 | 316 | } |
| 317 | 317 | } |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @return boolean |
| 327 | 327 | */ |
| 328 | - function php_exception_handler($ex){ |
|
| 329 | - if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){ |
|
| 330 | - show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
|
| 328 | + function php_exception_handler($ex) { |
|
| 329 | + if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) { |
|
| 330 | + show_error('An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode()); |
|
| 331 | 331 | } |
| 332 | - else{ |
|
| 332 | + else { |
|
| 333 | 333 | save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception'); |
| 334 | 334 | } |
| 335 | 335 | return true; |
@@ -347,16 +347,16 @@ discard block |
||
| 347 | 347 | * |
| 348 | 348 | * @return boolean |
| 349 | 349 | */ |
| 350 | - function php_error_handler($errno , $errstr, $errfile , $errline, array $errcontext = array()){ |
|
| 350 | + function php_error_handler($errno, $errstr, $errfile, $errline, array $errcontext = array()) { |
|
| 351 | 351 | $isError = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $errno) === $errno); |
| 352 | - if($isError){ |
|
| 352 | + if ($isError) { |
|
| 353 | 353 | set_http_status_header(500); |
| 354 | 354 | } |
| 355 | - if (! (error_reporting() & $errno)) { |
|
| 355 | + if (!(error_reporting() & $errno)) { |
|
| 356 | 356 | save_to_log('error', 'An error is occurred in the file ' . $errfile . ' at line ' . $errline . ' raison : ' . $errstr, 'PHP ERROR'); |
| 357 | 357 | return; |
| 358 | 358 | } |
| 359 | - if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){ |
|
| 359 | + if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) { |
|
| 360 | 360 | $errorType = 'error'; |
| 361 | 361 | switch ($errno) { |
| 362 | 362 | case E_USER_ERROR: |
@@ -372,9 +372,9 @@ discard block |
||
| 372 | 372 | $errorType = 'error'; |
| 373 | 373 | break; |
| 374 | 374 | } |
| 375 | - show_error('An error is occurred in the file <b>' . $errfile . '</b> at line <b>' . $errline .'</b> raison : ' . $errstr, 'PHP ' . $errorType); |
|
| 375 | + show_error('An error is occurred in the file <b>' . $errfile . '</b> at line <b>' . $errline . '</b> raison : ' . $errstr, 'PHP ' . $errorType); |
|
| 376 | 376 | } |
| 377 | - if ($isError){ |
|
| 377 | + if ($isError) { |
|
| 378 | 378 | die(); |
| 379 | 379 | } |
| 380 | 380 | return true; |
@@ -384,10 +384,10 @@ discard block |
||
| 384 | 384 | * This function is used to run in shutdown situation of the script |
| 385 | 385 | * @codeCoverageIgnore |
| 386 | 386 | */ |
| 387 | - function php_shudown_handler(){ |
|
| 387 | + function php_shudown_handler() { |
|
| 388 | 388 | $lastError = error_get_last(); |
| 389 | 389 | if (isset($lastError) && |
| 390 | - ($lastError['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))){ |
|
| 390 | + ($lastError['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))) { |
|
| 391 | 391 | php_error_handler($lastError['type'], $lastError['message'], $lastError['file'], $lastError['line']); |
| 392 | 392 | } |
| 393 | 393 | } |
@@ -405,11 +405,11 @@ discard block |
||
| 405 | 405 | * |
| 406 | 406 | * @return string string of the HTML attribute. |
| 407 | 407 | */ |
| 408 | - function attributes_to_string(array $attributes){ |
|
| 408 | + function attributes_to_string(array $attributes) { |
|
| 409 | 409 | $str = ' '; |
| 410 | 410 | //we check that the array passed as an argument is not empty. |
| 411 | - if(! empty($attributes)){ |
|
| 412 | - foreach($attributes as $key => $value){ |
|
| 411 | + if (!empty($attributes)) { |
|
| 412 | + foreach ($attributes as $key => $value) { |
|
| 413 | 413 | $key = trim(htmlspecialchars($key)); |
| 414 | 414 | $value = trim(htmlspecialchars($value)); |
| 415 | 415 | /* |
@@ -419,10 +419,10 @@ discard block |
||
| 419 | 419 | * $attr = array('placeholder' => 'I am a "puple"') |
| 420 | 420 | * $str = attributes_to_string($attr); => placeholder = "I am a \"puple\"" |
| 421 | 421 | */ |
| 422 | - if($value && strpos('"', $value) !== false){ |
|
| 422 | + if ($value && strpos('"', $value) !== false) { |
|
| 423 | 423 | $value = addslashes($value); |
| 424 | 424 | } |
| 425 | - $str .= $key.' = "'.$value.'" '; |
|
| 425 | + $str .= $key . ' = "' . $value . '" '; |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | //remove the space after using rtrim() |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * |
| 439 | 439 | * @return string the stringfy value |
| 440 | 440 | */ |
| 441 | - function stringfy_vars($var){ |
|
| 441 | + function stringfy_vars($var) { |
|
| 442 | 442 | return print_r($var, true); |
| 443 | 443 | } |
| 444 | 444 | |
@@ -449,18 +449,18 @@ discard block |
||
| 449 | 449 | * |
| 450 | 450 | * @return mixed the sanitize value |
| 451 | 451 | */ |
| 452 | - function clean_input($str){ |
|
| 453 | - if(is_array($str)){ |
|
| 452 | + function clean_input($str) { |
|
| 453 | + if (is_array($str)) { |
|
| 454 | 454 | $str = array_map('clean_input', $str); |
| 455 | 455 | } |
| 456 | - else if(is_object($str)){ |
|
| 456 | + else if (is_object($str)) { |
|
| 457 | 457 | $obj = $str; |
| 458 | 458 | foreach ($str as $var => $value) { |
| 459 | 459 | $obj->$var = clean_input($value); |
| 460 | 460 | } |
| 461 | 461 | $str = $obj; |
| 462 | 462 | } |
| 463 | - else{ |
|
| 463 | + else { |
|
| 464 | 464 | $str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8'); |
| 465 | 465 | } |
| 466 | 466 | return $str; |
@@ -478,11 +478,11 @@ discard block |
||
| 478 | 478 | * |
| 479 | 479 | * @return string the string with the hidden part. |
| 480 | 480 | */ |
| 481 | - function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){ |
|
| 481 | + function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') { |
|
| 482 | 482 | //get the string length |
| 483 | 483 | $len = strlen($str); |
| 484 | 484 | //if str is empty |
| 485 | - if($len <= 0){ |
|
| 485 | + if ($len <= 0) { |
|
| 486 | 486 | return str_repeat($hiddenChar, 6); |
| 487 | 487 | } |
| 488 | 488 | //if the length is less than startCount and endCount |
@@ -490,14 +490,14 @@ discard block |
||
| 490 | 490 | //or startCount is negative or endCount is negative |
| 491 | 491 | //return the full string hidden |
| 492 | 492 | |
| 493 | - if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){ |
|
| 493 | + if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) { |
|
| 494 | 494 | return str_repeat($hiddenChar, $len); |
| 495 | 495 | } |
| 496 | 496 | //the start non hidden string |
| 497 | 497 | $startNonHiddenStr = substr($str, 0, $startCount); |
| 498 | 498 | //the end non hidden string |
| 499 | 499 | $endNonHiddenStr = null; |
| 500 | - if($endCount > 0){ |
|
| 500 | + if ($endCount > 0) { |
|
| 501 | 501 | $endNonHiddenStr = substr($str, - $endCount); |
| 502 | 502 | } |
| 503 | 503 | //the hidden string |
@@ -510,31 +510,31 @@ discard block |
||
| 510 | 510 | * This function is used to set the initial session config regarding the configuration |
| 511 | 511 | * @codeCoverageIgnore |
| 512 | 512 | */ |
| 513 | - function set_session_config(){ |
|
| 513 | + function set_session_config() { |
|
| 514 | 514 | //$_SESSION is not available on cli mode |
| 515 | - if(! IS_CLI){ |
|
| 516 | - $logger =& class_loader('Log', 'classes'); |
|
| 515 | + if (!IS_CLI) { |
|
| 516 | + $logger = & class_loader('Log', 'classes'); |
|
| 517 | 517 | $logger->setLogger('PHPSession'); |
| 518 | 518 | //set session params |
| 519 | 519 | $sessionHandler = get_config('session_handler', 'files'); //the default is to store in the files |
| 520 | 520 | $sessionName = get_config('session_name'); |
| 521 | - if($sessionName){ |
|
| 521 | + if ($sessionName) { |
|
| 522 | 522 | session_name($sessionName); |
| 523 | 523 | } |
| 524 | 524 | $logger->info('Session handler: ' . $sessionHandler); |
| 525 | 525 | $logger->info('Session name: ' . $sessionName); |
| 526 | 526 | |
| 527 | - if($sessionHandler == 'files'){ |
|
| 527 | + if ($sessionHandler == 'files') { |
|
| 528 | 528 | $sessionSavePath = get_config('session_save_path'); |
| 529 | - if($sessionSavePath){ |
|
| 530 | - if(! is_dir($sessionSavePath)){ |
|
| 529 | + if ($sessionSavePath) { |
|
| 530 | + if (!is_dir($sessionSavePath)) { |
|
| 531 | 531 | mkdir($sessionSavePath, 1773); |
| 532 | 532 | } |
| 533 | 533 | session_save_path($sessionSavePath); |
| 534 | 534 | $logger->info('Session save path: ' . $sessionSavePath); |
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | - else if($sessionHandler == 'database'){ |
|
| 537 | + else if ($sessionHandler == 'database') { |
|
| 538 | 538 | //load database session handle library |
| 539 | 539 | //Model |
| 540 | 540 | require_once CORE_CLASSES_MODEL_PATH . 'Model.php'; |
@@ -542,11 +542,11 @@ discard block |
||
| 542 | 542 | //Database Session handler Model |
| 543 | 543 | require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php'; |
| 544 | 544 | |
| 545 | - $DBS =& class_loader('DBSessionHandler', 'classes'); |
|
| 545 | + $DBS = & class_loader('DBSessionHandler', 'classes'); |
|
| 546 | 546 | session_set_save_handler($DBS, true); |
| 547 | 547 | $logger->info('session save path: ' . get_config('session_save_path')); |
| 548 | 548 | } |
| 549 | - else{ |
|
| 549 | + else { |
|
| 550 | 550 | show_error('Invalid session handler configuration'); |
| 551 | 551 | } |
| 552 | 552 | $lifetime = get_config('session_cookie_lifetime', 0); |
@@ -569,9 +569,9 @@ discard block |
||
| 569 | 569 | $logger->info('Session lifetime: ' . $lifetime); |
| 570 | 570 | $logger->info('Session cookie path: ' . $path); |
| 571 | 571 | $logger->info('Session domain: ' . $domain); |
| 572 | - $logger->info('Session is secure: ' . ($secure ? 'TRUE':'FALSE')); |
|
| 572 | + $logger->info('Session is secure: ' . ($secure ? 'TRUE' : 'FALSE')); |
|
| 573 | 573 | |
| 574 | - if((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()){ |
|
| 574 | + if ((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()) { |
|
| 575 | 575 | $logger->info('Session not yet start, start it now'); |
| 576 | 576 | session_start(); |
| 577 | 577 | } |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * check if the interface "SessionHandlerInterface" exists (normally in PHP 5.4 this already exists) |
| 29 | 29 | */ |
| 30 | - if( !interface_exists('SessionHandlerInterface')){ |
|
| 30 | + if (!interface_exists('SessionHandlerInterface')) { |
|
| 31 | 31 | show_error('"SessionHandlerInterface" interface does not exists or is disabled can not use it to handler database session.'); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - class DBSessionHandler implements SessionHandlerInterface{ |
|
| 34 | + class DBSessionHandler implements SessionHandlerInterface { |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * The encryption method to use to encrypt session data in database |
@@ -81,25 +81,25 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | protected $loader = null; |
| 83 | 83 | |
| 84 | - public function __construct(DBSessionHandlerModel $modelInstance = null, Log $logger = null, Loader $loader = null){ |
|
| 84 | + public function __construct(DBSessionHandlerModel $modelInstance = null, Log $logger = null, Loader $loader = null) { |
|
| 85 | 85 | /** |
| 86 | 86 | * instance of the Log class |
| 87 | 87 | */ |
| 88 | - if(is_object($logger)){ |
|
| 88 | + if (is_object($logger)) { |
|
| 89 | 89 | $this->setLogger($logger); |
| 90 | 90 | } |
| 91 | - else{ |
|
| 92 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 91 | + else { |
|
| 92 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 93 | 93 | $this->logger->setLogger('Library::DBSessionHandler'); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if(is_object($loader)){ |
|
| 96 | + if (is_object($loader)) { |
|
| 97 | 97 | $this->setLoader($loader); |
| 98 | 98 | } |
| 99 | 99 | $this->OBJ = & get_instance(); |
| 100 | 100 | |
| 101 | 101 | |
| 102 | - if(is_object($modelInstance)){ |
|
| 102 | + if (is_object($modelInstance)) { |
|
| 103 | 103 | $this->setModelInstance($modelInstance); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * Set the session secret used to encrypt the data in database |
| 109 | 109 | * @param string $secret the base64 string secret |
| 110 | 110 | */ |
| 111 | - public function setSessionSecret($secret){ |
|
| 111 | + public function setSessionSecret($secret) { |
|
| 112 | 112 | $this->sessionSecret = $secret; |
| 113 | 113 | return $this; |
| 114 | 114 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * Return the session secret |
| 118 | 118 | * @return string |
| 119 | 119 | */ |
| 120 | - public function getSessionSecret(){ |
|
| 120 | + public function getSessionSecret() { |
|
| 121 | 121 | return $this->sessionSecret; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * Set the initializer vector for openssl |
| 127 | 127 | * @param string $key the session secret used |
| 128 | 128 | */ |
| 129 | - public function setInitializerVector($key){ |
|
| 129 | + public function setInitializerVector($key) { |
|
| 130 | 130 | $iv_length = openssl_cipher_iv_length(self::DB_SESSION_HASH_METHOD); |
| 131 | 131 | $key = base64_decode($key); |
| 132 | 132 | $this->iv = substr(hash('sha256', $key), 0, $iv_length); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * Return the initializer vector |
| 138 | 138 | * @return string |
| 139 | 139 | */ |
| 140 | - public function getInitializerVector(){ |
|
| 140 | + public function getInitializerVector() { |
|
| 141 | 141 | return $this->iv; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -147,17 +147,17 @@ discard block |
||
| 147 | 147 | * @param string $sessionName the session name |
| 148 | 148 | * @return boolean |
| 149 | 149 | */ |
| 150 | - public function open($savePath, $sessionName){ |
|
| 150 | + public function open($savePath, $sessionName) { |
|
| 151 | 151 | $this->logger->debug('Opening database session handler for [' . $sessionName . ']'); |
| 152 | 152 | //try to check if session secret is set before |
| 153 | 153 | $secret = $this->getSessionSecret(); |
| 154 | - if(empty($secret)){ |
|
| 154 | + if (empty($secret)) { |
|
| 155 | 155 | $secret = get_config('session_secret', false); |
| 156 | 156 | $this->setSessionSecret($secret); |
| 157 | 157 | } |
| 158 | 158 | $this->logger->info('Session secret: ' . $secret); |
| 159 | 159 | |
| 160 | - if(! $this->getModelInstance()){ |
|
| 160 | + if (!$this->getModelInstance()) { |
|
| 161 | 161 | $this->setModelInstanceFromConfig(); |
| 162 | 162 | } |
| 163 | 163 | $this->setInitializerVector($secret); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | //set session tables columns |
| 166 | 166 | $this->sessionTableColumns = $this->getModelInstance()->getSessionTableColumns(); |
| 167 | 167 | |
| 168 | - if(empty($this->sessionTableColumns)){ |
|
| 168 | + if (empty($this->sessionTableColumns)) { |
|
| 169 | 169 | show_error('The session handler is "database" but the table columns not set'); |
| 170 | 170 | } |
| 171 | 171 | $this->logger->info('Database session, the model columns are listed below: ' . stringfy_vars($this->sessionTableColumns)); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * Close the session |
| 182 | 182 | * @return boolean |
| 183 | 183 | */ |
| 184 | - public function close(){ |
|
| 184 | + public function close() { |
|
| 185 | 185 | $this->logger->debug('Closing database session handler'); |
| 186 | 186 | return true; |
| 187 | 187 | } |
@@ -191,28 +191,28 @@ discard block |
||
| 191 | 191 | * @param string $sid the session id to use |
| 192 | 192 | * @return string the session data in serialiaze format |
| 193 | 193 | */ |
| 194 | - public function read($sid){ |
|
| 194 | + public function read($sid) { |
|
| 195 | 195 | $this->logger->debug('Reading database session data for SID: ' . $sid); |
| 196 | 196 | $instance = $this->getModelInstance(); |
| 197 | 197 | $columns = $this->sessionTableColumns; |
| 198 | - if($this->getLoader()){ |
|
| 198 | + if ($this->getLoader()) { |
|
| 199 | 199 | $this->getLoader()->functions('user_agent'); |
| 200 | 200 | $this->getLoader()->library('Browser'); |
| 201 | 201 | } |
| 202 | - else{ |
|
| 202 | + else { |
|
| 203 | 203 | Loader::functions('user_agent'); |
| 204 | 204 | Loader::library('Browser'); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | $ip = get_ip(); |
| 208 | 208 | $host = @gethostbyaddr($ip) or null; |
| 209 | - $browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion(); |
|
| 209 | + $browser = $this->OBJ->browser->getPlatform() . ', ' . $this->OBJ->browser->getBrowser() . ' ' . $this->OBJ->browser->getVersion(); |
|
| 210 | 210 | |
| 211 | 211 | $data = $instance->get_by(array($columns['sid'] => $sid, $columns['shost'] => $host, $columns['sbrowser'] => $browser)); |
| 212 | - if($data && isset($data->{$columns['sdata']})){ |
|
| 212 | + if ($data && isset($data->{$columns['sdata']})) { |
|
| 213 | 213 | //checking inactivity |
| 214 | 214 | $timeInactivity = time() - get_config('session_inactivity_time', 100); |
| 215 | - if($data->{$columns['stime']} < $timeInactivity){ |
|
| 215 | + if ($data->{$columns['stime']} < $timeInactivity) { |
|
| 216 | 216 | $this->logger->info('Database session data for SID: ' . $sid . ' already expired, destroy it'); |
| 217 | 217 | $this->destroy($sid); |
| 218 | 218 | return null; |
@@ -229,16 +229,16 @@ discard block |
||
| 229 | 229 | * @param mixed $data the session data to save in serialize format |
| 230 | 230 | * @return boolean |
| 231 | 231 | */ |
| 232 | - public function write($sid, $data){ |
|
| 232 | + public function write($sid, $data) { |
|
| 233 | 233 | $this->logger->debug('Saving database session data for SID: ' . $sid . ', data: ' . stringfy_vars($data)); |
| 234 | 234 | $instance = $this->getModelInstance(); |
| 235 | 235 | $columns = $this->sessionTableColumns; |
| 236 | 236 | |
| 237 | - if($this->getLoader()){ |
|
| 237 | + if ($this->getLoader()) { |
|
| 238 | 238 | $this->getLoader()->functions('user_agent'); |
| 239 | 239 | $this->getLoader()->library('Browser'); |
| 240 | 240 | } |
| 241 | - else{ |
|
| 241 | + else { |
|
| 242 | 242 | Loader::functions('user_agent'); |
| 243 | 243 | Loader::library('Browser'); |
| 244 | 244 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $ip = get_ip(); |
| 247 | 247 | $keyValue = $instance->getKeyValue(); |
| 248 | 248 | $host = @gethostbyaddr($ip) or null; |
| 249 | - $browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion(); |
|
| 249 | + $browser = $this->OBJ->browser->getPlatform() . ', ' . $this->OBJ->browser->getBrowser() . ' ' . $this->OBJ->browser->getVersion(); |
|
| 250 | 250 | $data = $this->encode($data); |
| 251 | 251 | $params = array( |
| 252 | 252 | $columns['sid'] => $sid, |
@@ -259,13 +259,13 @@ discard block |
||
| 259 | 259 | ); |
| 260 | 260 | $this->logger->info('Database session data to save are listed below :' . stringfy_vars($params)); |
| 261 | 261 | $exists = $instance->get($sid); |
| 262 | - if($exists){ |
|
| 262 | + if ($exists) { |
|
| 263 | 263 | $this->logger->info('Session data for SID: ' . $sid . ' already exists, just update it'); |
| 264 | 264 | //update |
| 265 | 265 | unset($params[$columns['sid']]); |
| 266 | 266 | $instance->update($sid, $params); |
| 267 | 267 | } |
| 268 | - else{ |
|
| 268 | + else { |
|
| 269 | 269 | $this->logger->info('Session data for SID: ' . $sid . ' not yet exists, insert it now'); |
| 270 | 270 | $instance->insert($params); |
| 271 | 271 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @param string $sid the session id value |
| 279 | 279 | * @return boolean |
| 280 | 280 | */ |
| 281 | - public function destroy($sid){ |
|
| 281 | + public function destroy($sid) { |
|
| 282 | 282 | $this->logger->debug('Destroy of session data for SID: ' . $sid); |
| 283 | 283 | $instance = $this->modelInstanceName; |
| 284 | 284 | $instance->delete($sid); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param integer $maxLifetime the max lifetime |
| 291 | 291 | * @return boolean |
| 292 | 292 | */ |
| 293 | - public function gc($maxLifetime){ |
|
| 293 | + public function gc($maxLifetime) { |
|
| 294 | 294 | $instance = $this->modelInstanceName; |
| 295 | 295 | $time = time() - $maxLifetime; |
| 296 | 296 | $this->logger->debug('Garbage collector of expired session. maxLifetime [' . $maxLifetime . '] sec, expired time [' . $time . ']'); |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | * @param mixed $data the session data to encode |
| 304 | 304 | * @return mixed the encoded session data |
| 305 | 305 | */ |
| 306 | - public function encode($data){ |
|
| 306 | + public function encode($data) { |
|
| 307 | 307 | $key = base64_decode($this->sessionSecret); |
| 308 | - $dataEncrypted = openssl_encrypt($data , self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector()); |
|
| 308 | + $dataEncrypted = openssl_encrypt($data, self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector()); |
|
| 309 | 309 | $output = base64_encode($dataEncrypted); |
| 310 | 310 | return $output; |
| 311 | 311 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @param mixed $data the data to decode |
| 317 | 317 | * @return mixed the decoded data |
| 318 | 318 | */ |
| 319 | - public function decode($data){ |
|
| 319 | + public function decode($data) { |
|
| 320 | 320 | $key = base64_decode($this->sessionSecret); |
| 321 | 321 | $data = base64_decode($data); |
| 322 | 322 | $data = openssl_decrypt($data, self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector()); |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * Return the loader instance |
| 329 | 329 | * @return object Loader the loader instance |
| 330 | 330 | */ |
| 331 | - public function getLoader(){ |
|
| 331 | + public function getLoader() { |
|
| 332 | 332 | return $this->loader; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * set the loader instance for future use |
| 337 | 337 | * @param object Loader $loader the loader object |
| 338 | 338 | */ |
| 339 | - public function setLoader($loader){ |
|
| 339 | + public function setLoader($loader) { |
|
| 340 | 340 | $this->loader = $loader; |
| 341 | 341 | return $this; |
| 342 | 342 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * Return the model instance |
| 346 | 346 | * @return object DBSessionHandlerModel the model instance |
| 347 | 347 | */ |
| 348 | - public function getModelInstance(){ |
|
| 348 | + public function getModelInstance() { |
|
| 349 | 349 | return $this->modelInstanceName; |
| 350 | 350 | } |
| 351 | 351 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * set the model instance for future use |
| 354 | 354 | * @param DBSessionHandlerModel $modelInstance the model object |
| 355 | 355 | */ |
| 356 | - public function setModelInstance(DBSessionHandlerModel $modelInstance){ |
|
| 356 | + public function setModelInstance(DBSessionHandlerModel $modelInstance) { |
|
| 357 | 357 | $this->modelInstanceName = $modelInstance; |
| 358 | 358 | return $this; |
| 359 | 359 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * Return the Log instance |
| 363 | 363 | * @return Log |
| 364 | 364 | */ |
| 365 | - public function getLogger(){ |
|
| 365 | + public function getLogger() { |
|
| 366 | 366 | return $this->logger; |
| 367 | 367 | } |
| 368 | 368 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | * Set the log instance |
| 371 | 371 | * @param Log $logger the log object |
| 372 | 372 | */ |
| 373 | - public function setLogger(Log $logger){ |
|
| 373 | + public function setLogger(Log $logger) { |
|
| 374 | 374 | $this->logger = $logger; |
| 375 | 375 | return $this; |
| 376 | 376 | } |
@@ -378,18 +378,18 @@ discard block |
||
| 378 | 378 | /** |
| 379 | 379 | * Set the model instance using the configuration for session |
| 380 | 380 | */ |
| 381 | - private function setModelInstanceFromConfig(){ |
|
| 381 | + private function setModelInstanceFromConfig() { |
|
| 382 | 382 | $modelName = get_config('session_save_path'); |
| 383 | 383 | $this->logger->info('The database session model: ' . $modelName); |
| 384 | - if($this->getLoader()){ |
|
| 384 | + if ($this->getLoader()) { |
|
| 385 | 385 | $this->getLoader()->model($modelName, 'dbsessionhandlerinstance'); |
| 386 | 386 | } |
| 387 | 387 | //@codeCoverageIgnoreStart |
| 388 | - else{ |
|
| 388 | + else { |
|
| 389 | 389 | Loader::model($modelName, 'dbsessionhandlerinstance'); |
| 390 | 390 | } |
| 391 | - if(isset($this->OBJ->dbsessionhandlerinstance) && ! $this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel){ |
|
| 392 | - show_error('To use database session handler, your class model "'.get_class($this->OBJ->dbsessionhandlerinstance).'" need extends "DBSessionHandlerModel"'); |
|
| 391 | + if (isset($this->OBJ->dbsessionhandlerinstance) && !$this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel) { |
|
| 392 | + show_error('To use database session handler, your class model "' . get_class($this->OBJ->dbsessionhandlerinstance) . '" need extends "DBSessionHandlerModel"'); |
|
| 393 | 393 | } |
| 394 | 394 | //@codeCoverageIgnoreEnd |
| 395 | 395 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @copyright Copyright (c) 2012, Jamie Rumbelow <http://jamierumbelow.net> |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | - class Model{ |
|
| 36 | + class Model { |
|
| 37 | 37 | |
| 38 | 38 | /* -------------------------------------------------------------- |
| 39 | 39 | * VARIABLES |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | * Initialise the model, tie into the CodeIgniter superobject and |
| 141 | 141 | * try our best to guess the table name. |
| 142 | 142 | */ |
| 143 | - public function __construct(Database $db = null){ |
|
| 144 | - if(is_object($db)){ |
|
| 143 | + public function __construct(Database $db = null) { |
|
| 144 | + if (is_object($db)) { |
|
| 145 | 145 | $this->setDatabaseInstance($db); |
| 146 | 146 | } |
| 147 | - else{ |
|
| 147 | + else { |
|
| 148 | 148 | $obj = & get_instance(); |
| 149 | - if(isset($obj->database) && is_object($obj->database)){ |
|
| 149 | + if (isset($obj->database) && is_object($obj->database)) { |
|
| 150 | 150 | /** |
| 151 | 151 | * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
| 152 | 152 | * to prevent duplication |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 184 | 184 | { |
| 185 | - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
| 185 | + $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $this->_set_where($where); |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | $this->trigger('before_get'); |
| 225 | 225 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 226 | 226 | { |
| 227 | - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
| 227 | + $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
|
| 228 | 228 | } |
| 229 | - $type = $this->_temporary_return_type == 'array' ? 'array':false; |
|
| 229 | + $type = $this->_temporary_return_type == 'array' ? 'array' : false; |
|
| 230 | 230 | $result = $this->_database->from($this->_table)->getAll($type); |
| 231 | 231 | $this->_temporary_return_type = $this->return_type; |
| 232 | 232 | |
@@ -332,13 +332,13 @@ discard block |
||
| 332 | 332 | { |
| 333 | 333 | $args = func_get_args(); |
| 334 | 334 | $data = array(); |
| 335 | - if(count($args) == 2){ |
|
| 336 | - if(is_array($args[1])){ |
|
| 335 | + if (count($args) == 2) { |
|
| 336 | + if (is_array($args[1])) { |
|
| 337 | 337 | $data = array_pop($args); |
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | - else if(count($args) == 3){ |
|
| 341 | - if(is_array($args[2])){ |
|
| 340 | + else if (count($args) == 3) { |
|
| 341 | + if (is_array($args[2])) { |
|
| 342 | 342 | $data = array_pop($args); |
| 343 | 343 | } |
| 344 | 344 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $this->_database->where($this->primary_key, $id); |
| 377 | 377 | if ($this->soft_delete) |
| 378 | 378 | { |
| 379 | - $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
| 379 | + $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE)); |
|
| 380 | 380 | } |
| 381 | 381 | else |
| 382 | 382 | { |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | $this->_set_where($where); |
| 398 | 398 | if ($this->soft_delete) |
| 399 | 399 | { |
| 400 | - $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
| 400 | + $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE)); |
|
| 401 | 401 | } |
| 402 | 402 | else |
| 403 | 403 | { |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $this->_database->in($this->primary_key, $primary_values); |
| 417 | 417 | if ($this->soft_delete) |
| 418 | 418 | { |
| 419 | - $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
| 419 | + $result = $this->_database->from($this->_table)->update(array($this->soft_delete_key => TRUE)); |
|
| 420 | 420 | } |
| 421 | 421 | else |
| 422 | 422 | { |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | if (is_string($value)) |
| 463 | 463 | { |
| 464 | 464 | $relationship = $value; |
| 465 | - $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
|
| 465 | + $options = array('primary_key' => $value . '_id', 'model' => $value . '_model'); |
|
| 466 | 466 | } |
| 467 | 467 | else |
| 468 | 468 | { |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | |
| 473 | 473 | if (in_array($relationship, $this->_with)) |
| 474 | 474 | { |
| 475 | - if(is_object($this->loaderInstance)){ |
|
| 475 | + if (is_object($this->loaderInstance)) { |
|
| 476 | 476 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 477 | 477 | } |
| 478 | - else{ |
|
| 478 | + else { |
|
| 479 | 479 | Loader::model($options['model'], $relationship . '_model'); |
| 480 | 480 | } |
| 481 | 481 | if (is_object($row)) |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | if (is_string($value)) |
| 495 | 495 | { |
| 496 | 496 | $relationship = $value; |
| 497 | - $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
|
| 497 | + $options = array('primary_key' => $this->_table . '_id', 'model' => $value . '_model'); |
|
| 498 | 498 | } |
| 499 | 499 | else |
| 500 | 500 | { |
@@ -504,10 +504,10 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | if (in_array($relationship, $this->_with)) |
| 506 | 506 | { |
| 507 | - if(is_object($this->loaderInstance)){ |
|
| 507 | + if (is_object($this->loaderInstance)) { |
|
| 508 | 508 | $this->loaderInstance->model($options['model'], $relationship . '_model'); |
| 509 | 509 | } |
| 510 | - else{ |
|
| 510 | + else { |
|
| 511 | 511 | Loader::model($options['model'], $relationship . '_model'); |
| 512 | 512 | } |
| 513 | 513 | if (is_object($row)) |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | public function dropdown() |
| 534 | 534 | { |
| 535 | 535 | $args = func_get_args(); |
| 536 | - if(count($args) == 2) |
|
| 536 | + if (count($args) == 2) |
|
| 537 | 537 | { |
| 538 | 538 | list($key, $value) = $args; |
| 539 | 539 | } |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | $key = $this->primary_key; |
| 543 | 543 | $value = $args[0]; |
| 544 | 544 | } |
| 545 | - $this->trigger('before_dropdown', array( $key, $value )); |
|
| 545 | + $this->trigger('before_dropdown', array($key, $value)); |
|
| 546 | 546 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 547 | 547 | { |
| 548 | 548 | $this->_database->where($this->soft_delete_key, FALSE); |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | { |
| 567 | 567 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 568 | 568 | { |
| 569 | - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
| 569 | + $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
|
| 570 | 570 | } |
| 571 | 571 | $where = func_get_args(); |
| 572 | 572 | $this->_set_where($where); |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | { |
| 582 | 582 | if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
| 583 | 583 | { |
| 584 | - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
| 584 | + $this->_database->where($this->soft_delete_key, (bool) $this->_temporary_only_deleted); |
|
| 585 | 585 | } |
| 586 | 586 | $this->_database->from($this->_table)->getAll(); |
| 587 | 587 | return $this->_database->numRows(); |
@@ -590,8 +590,8 @@ discard block |
||
| 590 | 590 | /** |
| 591 | 591 | * Enabled cache temporary |
| 592 | 592 | */ |
| 593 | - public function cached($ttl = 0){ |
|
| 594 | - if($ttl > 0){ |
|
| 593 | + public function cached($ttl = 0) { |
|
| 594 | + if ($ttl > 0) { |
|
| 595 | 595 | $this->_database = $this->_database->cached($ttl); |
| 596 | 596 | } |
| 597 | 597 | return $this; |
@@ -745,13 +745,13 @@ discard block |
||
| 745 | 745 | { |
| 746 | 746 | if (is_object($row)) |
| 747 | 747 | { |
| 748 | - if(isset($row->$attr)){ |
|
| 748 | + if (isset($row->$attr)) { |
|
| 749 | 749 | unset($row->$attr); |
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | else |
| 753 | 753 | { |
| 754 | - if(isset($row[$attr])){ |
|
| 754 | + if (isset($row[$attr])) { |
|
| 755 | 755 | unset($row[$attr]); |
| 756 | 756 | } |
| 757 | 757 | } |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | * Return the database instance |
| 764 | 764 | * @return Database the database instance |
| 765 | 765 | */ |
| 766 | - public function getDatabaseInstance(){ |
|
| 766 | + public function getDatabaseInstance() { |
|
| 767 | 767 | return $this->_database; |
| 768 | 768 | } |
| 769 | 769 | |
@@ -771,9 +771,9 @@ discard block |
||
| 771 | 771 | * set the Database instance for future use |
| 772 | 772 | * @param Database $db the database object |
| 773 | 773 | */ |
| 774 | - public function setDatabaseInstance($db){ |
|
| 774 | + public function setDatabaseInstance($db) { |
|
| 775 | 775 | $this->_database = $db; |
| 776 | - if($this->dbCacheTime > 0){ |
|
| 776 | + if ($this->dbCacheTime > 0) { |
|
| 777 | 777 | $this->_database->setCache($this->dbCacheTime); |
| 778 | 778 | } |
| 779 | 779 | return $this; |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | * Return the loader instance |
| 784 | 784 | * @return Loader the loader instance |
| 785 | 785 | */ |
| 786 | - public function getLoader(){ |
|
| 786 | + public function getLoader() { |
|
| 787 | 787 | return $this->loaderInstance; |
| 788 | 788 | } |
| 789 | 789 | |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | * set the loader instance for future use |
| 792 | 792 | * @param Loader $loader the loader object |
| 793 | 793 | */ |
| 794 | - public function setLoader($loader){ |
|
| 794 | + public function setLoader($loader) { |
|
| 795 | 795 | $this->loaderInstance = $loader; |
| 796 | 796 | return $this; |
| 797 | 797 | } |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | * Return the FormValidation instance |
| 801 | 801 | * @return FormValidation the form validation instance |
| 802 | 802 | */ |
| 803 | - public function getFormValidation(){ |
|
| 803 | + public function getFormValidation() { |
|
| 804 | 804 | return $this->formValidationInstance; |
| 805 | 805 | } |
| 806 | 806 | |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | * set the form validation instance for future use |
| 809 | 809 | * @param FormValidation $fv the form validation object |
| 810 | 810 | */ |
| 811 | - public function setFormValidation($fv){ |
|
| 811 | + public function setFormValidation($fv) { |
|
| 812 | 812 | $this->formValidationInstance = $fv; |
| 813 | 813 | return $this; |
| 814 | 814 | } |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | */ |
| 823 | 823 | public function order_by($criteria, $order = 'ASC') |
| 824 | 824 | { |
| 825 | - if ( is_array($criteria) ) |
|
| 825 | + if (is_array($criteria)) |
|
| 826 | 826 | { |
| 827 | 827 | foreach ($criteria as $key => $value) |
| 828 | 828 | { |
@@ -878,17 +878,17 @@ discard block |
||
| 878 | 878 | */ |
| 879 | 879 | protected function validate(array $data) |
| 880 | 880 | { |
| 881 | - if($this->skip_validation) |
|
| 881 | + if ($this->skip_validation) |
|
| 882 | 882 | { |
| 883 | 883 | return $data; |
| 884 | 884 | } |
| 885 | - if(!empty($this->validate)) |
|
| 885 | + if (!empty($this->validate)) |
|
| 886 | 886 | { |
| 887 | 887 | $fv = null; |
| 888 | - if(is_object($this->formValidationInstance)){ |
|
| 888 | + if (is_object($this->formValidationInstance)) { |
|
| 889 | 889 | $fv = $this->formValidationInstance; |
| 890 | 890 | } |
| 891 | - else{ |
|
| 891 | + else { |
|
| 892 | 892 | Loader::library('FormValidation'); |
| 893 | 893 | $fv = $this->formvalidation; |
| 894 | 894 | $this->setFormValidation($fv); |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | { |
| 944 | 944 | $this->_database->where($params[0]); |
| 945 | 945 | } |
| 946 | - else if(count($params) == 2) |
|
| 946 | + else if (count($params) == 2) |
|
| 947 | 947 | { |
| 948 | 948 | if (is_array($params[1])) |
| 949 | 949 | { |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | $this->_database->where($params[0], $params[1]); |
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | - else if(count($params) == 3) |
|
| 957 | + else if (count($params) == 3) |
|
| 958 | 958 | { |
| 959 | 959 | $this->_database->where($params[0], $params[1], $params[2]); |
| 960 | 960 | } |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | /** |
| 975 | 975 | Shortcut to controller |
| 976 | 976 | */ |
| 977 | - public function __get($key){ |
|
| 977 | + public function __get($key) { |
|
| 978 | 978 | return get_instance()->{$key}; |
| 979 | 979 | } |
| 980 | 980 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * along with this program; if not, write to the Free Software |
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | 25 | */ |
| 26 | - class Loader{ |
|
| 26 | + class Loader { |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * List of loaded resources |
@@ -38,77 +38,77 @@ discard block |
||
| 38 | 38 | private static $logger; |
| 39 | 39 | |
| 40 | 40 | |
| 41 | - public function __construct(){ |
|
| 41 | + public function __construct() { |
|
| 42 | 42 | //add the resources already loaded during application bootstrap |
| 43 | 43 | //in the list to prevent duplicate or loading the resources again. |
| 44 | 44 | static::$loaded = class_loaded(); |
| 45 | 45 | |
| 46 | 46 | $autoloads = array(); |
| 47 | 47 | //loading of the resources in autoload.php configuration file |
| 48 | - if(file_exists(CONFIG_PATH . 'autoload.php')){ |
|
| 48 | + if (file_exists(CONFIG_PATH . 'autoload.php')) { |
|
| 49 | 49 | require_once CONFIG_PATH . 'autoload.php'; |
| 50 | - if(! empty($autoload) && is_array($autoload)){ |
|
| 50 | + if (!empty($autoload) && is_array($autoload)) { |
|
| 51 | 51 | $autoloads = $autoload; |
| 52 | 52 | unset($autoload); |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | //loading autoload configuration for modules |
| 56 | 56 | $modulesAutoloads = Module::getModulesAutoloadConfig(); |
| 57 | - if(! empty($modulesAutoloads) && is_array($modulesAutoloads)){ |
|
| 57 | + if (!empty($modulesAutoloads) && is_array($modulesAutoloads)) { |
|
| 58 | 58 | //libraries autoload |
| 59 | - if(! empty($modulesAutoloads['libraries']) && is_array($modulesAutoloads['libraries'])){ |
|
| 59 | + if (!empty($modulesAutoloads['libraries']) && is_array($modulesAutoloads['libraries'])) { |
|
| 60 | 60 | $autoloads['libraries'] = array_merge($autoloads['libraries'], $modulesAutoloads['libraries']); |
| 61 | 61 | } |
| 62 | 62 | //config autoload |
| 63 | - if(! empty($modulesAutoloads['config']) && is_array($modulesAutoloads['config'])){ |
|
| 63 | + if (!empty($modulesAutoloads['config']) && is_array($modulesAutoloads['config'])) { |
|
| 64 | 64 | $autoloads['config'] = array_merge($autoloads['config'], $modulesAutoloads['config']); |
| 65 | 65 | } |
| 66 | 66 | //models autoload |
| 67 | - if(! empty($modulesAutoloads['models']) && is_array($modulesAutoloads['models'])){ |
|
| 67 | + if (!empty($modulesAutoloads['models']) && is_array($modulesAutoloads['models'])) { |
|
| 68 | 68 | $autoloads['models'] = array_merge($autoloads['models'], $modulesAutoloads['models']); |
| 69 | 69 | } |
| 70 | 70 | //functions autoload |
| 71 | - if(! empty($modulesAutoloads['functions']) && is_array($modulesAutoloads['functions'])){ |
|
| 71 | + if (!empty($modulesAutoloads['functions']) && is_array($modulesAutoloads['functions'])) { |
|
| 72 | 72 | $autoloads['functions'] = array_merge($autoloads['functions'], $modulesAutoloads['functions']); |
| 73 | 73 | } |
| 74 | 74 | //languages autoload |
| 75 | - if(! empty($modulesAutoloads['languages']) && is_array($modulesAutoloads['languages'])){ |
|
| 75 | + if (!empty($modulesAutoloads['languages']) && is_array($modulesAutoloads['languages'])) { |
|
| 76 | 76 | $autoloads['languages'] = array_merge($autoloads['languages'], $modulesAutoloads['languages']); |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | //config autoload |
| 81 | - if(! empty($autoloads['config']) && is_array($autoloads['config'])){ |
|
| 82 | - foreach($autoloads['config'] as $c){ |
|
| 81 | + if (!empty($autoloads['config']) && is_array($autoloads['config'])) { |
|
| 82 | + foreach ($autoloads['config'] as $c) { |
|
| 83 | 83 | $this->config($c); |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | //languages autoload |
| 88 | - if(! empty($autoloads['languages']) && is_array($autoloads['languages'])){ |
|
| 89 | - foreach($autoloads['languages'] as $language){ |
|
| 88 | + if (!empty($autoloads['languages']) && is_array($autoloads['languages'])) { |
|
| 89 | + foreach ($autoloads['languages'] as $language) { |
|
| 90 | 90 | $this->lang($language); |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | //libraries autoload |
| 95 | - if(! empty($autoloads['libraries']) && is_array($autoloads['libraries'])){ |
|
| 96 | - foreach($autoloads['libraries'] as $library){ |
|
| 95 | + if (!empty($autoloads['libraries']) && is_array($autoloads['libraries'])) { |
|
| 96 | + foreach ($autoloads['libraries'] as $library) { |
|
| 97 | 97 | $this->library($library); |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | //models autoload |
| 102 | - if(! empty($autoloads['models']) && is_array($autoloads['models'])){ |
|
| 102 | + if (!empty($autoloads['models']) && is_array($autoloads['models'])) { |
|
| 103 | 103 | require_once CORE_CLASSES_MODEL_PATH . 'Model.php'; |
| 104 | - foreach($autoloads['models'] as $model){ |
|
| 104 | + foreach ($autoloads['models'] as $model) { |
|
| 105 | 105 | $this->model($model); |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | //functions autoload |
| 110 | - if(! empty($autoloads['functions']) && is_array($autoloads['functions'])){ |
|
| 111 | - foreach($autoloads['functions'] as $function){ |
|
| 110 | + if (!empty($autoloads['functions']) && is_array($autoloads['functions'])) { |
|
| 111 | + foreach ($autoloads['functions'] as $function) { |
|
| 112 | 112 | $this->functions($function); |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | * Get the logger singleton instance |
| 120 | 120 | * @return Log the logger instance |
| 121 | 121 | */ |
| 122 | - private static function getLogger(){ |
|
| 123 | - if(self::$logger == null){ |
|
| 124 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 122 | + private static function getLogger() { |
|
| 123 | + if (self::$logger == null) { |
|
| 124 | + self::$logger[0] = & class_loader('Log', 'classes'); |
|
| 125 | 125 | self::$logger[0]->setLogger('Library::Loader'); |
| 126 | 126 | } |
| 127 | 127 | return self::$logger[0]; |
@@ -135,25 +135,25 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | - public static function model($class, $instance = null){ |
|
| 138 | + public static function model($class, $instance = null) { |
|
| 139 | 139 | $logger = static::getLogger(); |
| 140 | 140 | $class = str_ireplace('.php', '', $class); |
| 141 | 141 | $class = trim($class, '/\\'); |
| 142 | - $file = ucfirst($class).'.php'; |
|
| 142 | + $file = ucfirst($class) . '.php'; |
|
| 143 | 143 | $logger->debug('Loading model [' . $class . '] ...'); |
| 144 | - if(! $instance){ |
|
| 144 | + if (!$instance) { |
|
| 145 | 145 | //for module |
| 146 | - if(strpos($class, '/') !== false){ |
|
| 146 | + if (strpos($class, '/') !== false) { |
|
| 147 | 147 | $path = explode('/', $class); |
| 148 | - if(isset($path[1])){ |
|
| 148 | + if (isset($path[1])) { |
|
| 149 | 149 | $instance = strtolower($path[1]); |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | - else{ |
|
| 152 | + else { |
|
| 153 | 153 | $instance = strtolower($class); |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | - if(isset(static::$loaded[$instance])){ |
|
| 156 | + if (isset(static::$loaded[$instance])) { |
|
| 157 | 157 | $logger->info('Model [' . $class . '] already loaded no need to load it again, cost in performance'); |
| 158 | 158 | return; |
| 159 | 159 | } |
@@ -163,43 +163,43 @@ discard block |
||
| 163 | 163 | $searchModuleName = null; |
| 164 | 164 | $obj = & get_instance(); |
| 165 | 165 | //check if the request class contains module name |
| 166 | - if(strpos($class, '/') !== false){ |
|
| 166 | + if (strpos($class, '/') !== false) { |
|
| 167 | 167 | $path = explode('/', $class); |
| 168 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 168 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 169 | 169 | $searchModuleName = $path[0]; |
| 170 | 170 | $class = ucfirst($path[1]); |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | - else{ |
|
| 173 | + else { |
|
| 174 | 174 | $class = ucfirst($class); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 177 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 178 | 178 | $searchModuleName = $obj->moduleName; |
| 179 | 179 | } |
| 180 | 180 | $moduleModelFilePath = Module::findModelFullPath($class, $searchModuleName); |
| 181 | - if($moduleModelFilePath){ |
|
| 182 | - $logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it'); |
|
| 181 | + if ($moduleModelFilePath) { |
|
| 182 | + $logger->info('Found model [' . $class . '] from module [' . $searchModuleName . '], the file path is [' . $moduleModelFilePath . '] we will used it'); |
|
| 183 | 183 | $classFilePath = $moduleModelFilePath; |
| 184 | 184 | } |
| 185 | - else{ |
|
| 185 | + else { |
|
| 186 | 186 | $logger->info('Cannot find model [' . $class . '] from modules using the default location'); |
| 187 | 187 | } |
| 188 | 188 | $logger->info('The model file path to be loaded is [' . $classFilePath . ']'); |
| 189 | - if(file_exists($classFilePath)){ |
|
| 189 | + if (file_exists($classFilePath)) { |
|
| 190 | 190 | require_once $classFilePath; |
| 191 | - if(class_exists($class)){ |
|
| 191 | + if (class_exists($class)) { |
|
| 192 | 192 | $c = new $class(); |
| 193 | 193 | $obj = & get_instance(); |
| 194 | 194 | $obj->{$instance} = $c; |
| 195 | 195 | static::$loaded[$instance] = $class; |
| 196 | 196 | $logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.'); |
| 197 | 197 | } |
| 198 | - else{ |
|
| 199 | - show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']'); |
|
| 198 | + else { |
|
| 199 | + show_error('The file ' . $classFilePath . ' exists but does not contain the class [' . $class . ']'); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | - else{ |
|
| 202 | + else { |
|
| 203 | 203 | show_error('Unable to find the model [' . $class . ']'); |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -214,31 +214,31 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @return void |
| 216 | 216 | */ |
| 217 | - public static function library($class, $instance = null, array $params = array()){ |
|
| 217 | + public static function library($class, $instance = null, array $params = array()) { |
|
| 218 | 218 | $logger = static::getLogger(); |
| 219 | 219 | $class = str_ireplace('.php', '', $class); |
| 220 | 220 | $class = trim($class, '/\\'); |
| 221 | - $file = ucfirst($class) .'.php'; |
|
| 221 | + $file = ucfirst($class) . '.php'; |
|
| 222 | 222 | $logger->debug('Loading library [' . $class . '] ...'); |
| 223 | - if(! $instance){ |
|
| 223 | + if (!$instance) { |
|
| 224 | 224 | //for module |
| 225 | - if(strpos($class, '/') !== false){ |
|
| 225 | + if (strpos($class, '/') !== false) { |
|
| 226 | 226 | $path = explode('/', $class); |
| 227 | - if(isset($path[1])){ |
|
| 227 | + if (isset($path[1])) { |
|
| 228 | 228 | $instance = strtolower($path[1]); |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | - else{ |
|
| 231 | + else { |
|
| 232 | 232 | $instance = strtolower($class); |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | - if(isset(static::$loaded[$instance])){ |
|
| 235 | + if (isset(static::$loaded[$instance])) { |
|
| 236 | 236 | $logger->info('Library [' . $class . '] already loaded no need to load it again, cost in performance'); |
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | $obj = & get_instance(); |
| 240 | 240 | //TODO for Database library |
| 241 | - if(strtolower($class) == 'database'){ |
|
| 241 | + if (strtolower($class) == 'database') { |
|
| 242 | 242 | $logger->info('This is the Database library ...'); |
| 243 | 243 | $dbInstance = & class_loader('Database', 'classes', $params); |
| 244 | 244 | $obj->{$instance} = $dbInstance; |
@@ -248,44 +248,44 @@ discard block |
||
| 248 | 248 | } |
| 249 | 249 | $libraryFilePath = null; |
| 250 | 250 | $logger->debug('Check if this is a system library ...'); |
| 251 | - if(file_exists(CORE_LIBRARY_PATH . $file)){ |
|
| 251 | + if (file_exists(CORE_LIBRARY_PATH . $file)) { |
|
| 252 | 252 | $libraryFilePath = CORE_LIBRARY_PATH . $file; |
| 253 | 253 | $class = ucfirst($class); |
| 254 | 254 | $logger->info('This library is a system library'); |
| 255 | 255 | } |
| 256 | - else{ |
|
| 256 | + else { |
|
| 257 | 257 | $logger->info('This library is not a system library'); |
| 258 | 258 | //first check if this library is in the module |
| 259 | 259 | $logger->debug('Checking library [' . $class . '] from module list ...'); |
| 260 | 260 | $searchModuleName = null; |
| 261 | 261 | //check if the request class contains module name |
| 262 | - if(strpos($class, '/') !== false){ |
|
| 262 | + if (strpos($class, '/') !== false) { |
|
| 263 | 263 | $path = explode('/', $class); |
| 264 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 264 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 265 | 265 | $searchModuleName = $path[0]; |
| 266 | 266 | $class = ucfirst($path[1]); |
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | - else{ |
|
| 269 | + else { |
|
| 270 | 270 | $class = ucfirst($class); |
| 271 | 271 | } |
| 272 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 272 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 273 | 273 | $searchModuleName = $obj->moduleName; |
| 274 | 274 | } |
| 275 | 275 | $moduleLibraryPath = Module::findLibraryFullPath($class, $searchModuleName); |
| 276 | - if($moduleLibraryPath){ |
|
| 277 | - $logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it'); |
|
| 276 | + if ($moduleLibraryPath) { |
|
| 277 | + $logger->info('Found library [' . $class . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLibraryPath . '] we will used it'); |
|
| 278 | 278 | $libraryFilePath = $moduleLibraryPath; |
| 279 | 279 | } |
| 280 | - else{ |
|
| 280 | + else { |
|
| 281 | 281 | $logger->info('Cannot find library [' . $class . '] from modules using the default location'); |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | - if(! $libraryFilePath){ |
|
| 284 | + if (!$libraryFilePath) { |
|
| 285 | 285 | $searchDir = array(LIBRARY_PATH); |
| 286 | - foreach($searchDir as $dir){ |
|
| 286 | + foreach ($searchDir as $dir) { |
|
| 287 | 287 | $filePath = $dir . $file; |
| 288 | - if(file_exists($filePath)){ |
|
| 288 | + if (file_exists($filePath)) { |
|
| 289 | 289 | $libraryFilePath = $filePath; |
| 290 | 290 | //is already found not to continue |
| 291 | 291 | break; |
@@ -293,20 +293,20 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | $logger->info('The library file path to be loaded is [' . $libraryFilePath . ']'); |
| 296 | - if($libraryFilePath){ |
|
| 296 | + if ($libraryFilePath) { |
|
| 297 | 297 | require_once $libraryFilePath; |
| 298 | - if(class_exists($class)){ |
|
| 298 | + if (class_exists($class)) { |
|
| 299 | 299 | $c = $params ? new $class($params) : new $class(); |
| 300 | 300 | $obj = & get_instance(); |
| 301 | 301 | $obj->{$instance} = $c; |
| 302 | 302 | static::$loaded[$instance] = $class; |
| 303 | 303 | $logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.'); |
| 304 | 304 | } |
| 305 | - else{ |
|
| 306 | - show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class); |
|
| 305 | + else { |
|
| 306 | + show_error('The file ' . $libraryFilePath . ' exists but does not contain the class ' . $class); |
|
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | - else{ |
|
| 309 | + else { |
|
| 310 | 310 | show_error('Unable to find library class [' . $class . ']'); |
| 311 | 311 | } |
| 312 | 312 | } |
@@ -318,14 +318,14 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @return void |
| 320 | 320 | */ |
| 321 | - public static function functions($function){ |
|
| 321 | + public static function functions($function) { |
|
| 322 | 322 | $logger = static::getLogger(); |
| 323 | 323 | $function = str_ireplace('.php', '', $function); |
| 324 | 324 | $function = trim($function, '/\\'); |
| 325 | 325 | $function = str_ireplace('function_', '', $function); |
| 326 | - $file = 'function_'.$function.'.php'; |
|
| 326 | + $file = 'function_' . $function . '.php'; |
|
| 327 | 327 | $logger->debug('Loading helper [' . $function . '] ...'); |
| 328 | - if(isset(static::$loaded['function_' . $function])){ |
|
| 328 | + if (isset(static::$loaded['function_' . $function])) { |
|
| 329 | 329 | $logger->info('Helper [' . $function . '] already loaded no need to load it again, cost in performance'); |
| 330 | 330 | return; |
| 331 | 331 | } |
@@ -335,30 +335,30 @@ discard block |
||
| 335 | 335 | $searchModuleName = null; |
| 336 | 336 | $obj = & get_instance(); |
| 337 | 337 | //check if the request class contains module name |
| 338 | - if(strpos($function, '/') !== false){ |
|
| 338 | + if (strpos($function, '/') !== false) { |
|
| 339 | 339 | $path = explode('/', $function); |
| 340 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 340 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 341 | 341 | $searchModuleName = $path[0]; |
| 342 | 342 | $function = 'function_' . $path[1] . '.php'; |
| 343 | - $file = $path[0] . DS . 'function_'.$function.'.php'; |
|
| 343 | + $file = $path[0] . DS . 'function_' . $function . '.php'; |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 346 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 347 | 347 | $searchModuleName = $obj->moduleName; |
| 348 | 348 | } |
| 349 | 349 | $moduleFunctionPath = Module::findFunctionFullPath($function, $searchModuleName); |
| 350 | - if($moduleFunctionPath){ |
|
| 351 | - $logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it'); |
|
| 350 | + if ($moduleFunctionPath) { |
|
| 351 | + $logger->info('Found helper [' . $function . '] from module [' . $searchModuleName . '], the file path is [' . $moduleFunctionPath . '] we will used it'); |
|
| 352 | 352 | $functionFilePath = $moduleFunctionPath; |
| 353 | 353 | } |
| 354 | - else{ |
|
| 354 | + else { |
|
| 355 | 355 | $logger->info('Cannot find helper [' . $function . '] from modules using the default location'); |
| 356 | 356 | } |
| 357 | - if(! $functionFilePath){ |
|
| 357 | + if (!$functionFilePath) { |
|
| 358 | 358 | $searchDir = array(FUNCTIONS_PATH, CORE_FUNCTIONS_PATH); |
| 359 | - foreach($searchDir as $dir){ |
|
| 359 | + foreach ($searchDir as $dir) { |
|
| 360 | 360 | $filePath = $dir . $file; |
| 361 | - if(file_exists($filePath)){ |
|
| 361 | + if (file_exists($filePath)) { |
|
| 362 | 362 | $functionFilePath = $filePath; |
| 363 | 363 | //is already found not to continue |
| 364 | 364 | break; |
@@ -366,12 +366,12 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | $logger->info('The helper file path to be loaded is [' . $functionFilePath . ']'); |
| 369 | - if($functionFilePath){ |
|
| 369 | + if ($functionFilePath) { |
|
| 370 | 370 | require_once $functionFilePath; |
| 371 | 371 | static::$loaded['function_' . $function] = $functionFilePath; |
| 372 | 372 | $logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.'); |
| 373 | 373 | } |
| 374 | - else{ |
|
| 374 | + else { |
|
| 375 | 375 | show_error('Unable to find helper file [' . $file . ']'); |
| 376 | 376 | } |
| 377 | 377 | } |
@@ -383,14 +383,14 @@ discard block |
||
| 383 | 383 | * |
| 384 | 384 | * @return void |
| 385 | 385 | */ |
| 386 | - public static function config($filename){ |
|
| 386 | + public static function config($filename) { |
|
| 387 | 387 | $logger = static::getLogger(); |
| 388 | 388 | $filename = str_ireplace('.php', '', $filename); |
| 389 | 389 | $filename = trim($filename, '/\\'); |
| 390 | 390 | $filename = str_ireplace('config_', '', $filename); |
| 391 | - $file = 'config_'.$filename.'.php'; |
|
| 391 | + $file = 'config_' . $filename . '.php'; |
|
| 392 | 392 | $logger->debug('Loading configuration [' . $filename . '] ...'); |
| 393 | - if(isset(static::$loaded['config_' . $filename])){ |
|
| 393 | + if (isset(static::$loaded['config_' . $filename])) { |
|
| 394 | 394 | $logger->info('Configuration [' . $file . '] already loaded no need to load it again, cost in performance'); |
| 395 | 395 | return; |
| 396 | 396 | } |
@@ -400,33 +400,33 @@ discard block |
||
| 400 | 400 | $searchModuleName = null; |
| 401 | 401 | $obj = & get_instance(); |
| 402 | 402 | //check if the request class contains module name |
| 403 | - if(strpos($filename, '/') !== false){ |
|
| 403 | + if (strpos($filename, '/') !== false) { |
|
| 404 | 404 | $path = explode('/', $filename); |
| 405 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 405 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 406 | 406 | $searchModuleName = $path[0]; |
| 407 | 407 | $filename = $path[1] . '.php'; |
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 410 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 411 | 411 | $searchModuleName = $obj->moduleName; |
| 412 | 412 | } |
| 413 | 413 | $moduleConfigPath = Module::findConfigFullPath($filename, $searchModuleName); |
| 414 | - if($moduleConfigPath){ |
|
| 415 | - $logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it'); |
|
| 414 | + if ($moduleConfigPath) { |
|
| 415 | + $logger->info('Found config [' . $filename . '] from module [' . $searchModuleName . '], the file path is [' . $moduleConfigPath . '] we will used it'); |
|
| 416 | 416 | $configFilePath = $moduleConfigPath; |
| 417 | 417 | } |
| 418 | - else{ |
|
| 418 | + else { |
|
| 419 | 419 | $logger->info('Cannot find config [' . $filename . '] from modules using the default location'); |
| 420 | 420 | } |
| 421 | 421 | $logger->info('The config file path to be loaded is [' . $configFilePath . ']'); |
| 422 | - if(file_exists($configFilePath)){ |
|
| 422 | + if (file_exists($configFilePath)) { |
|
| 423 | 423 | require_once $configFilePath; |
| 424 | - if(! empty($config) && is_array($config)){ |
|
| 424 | + if (!empty($config) && is_array($config)) { |
|
| 425 | 425 | Config::setAll($config); |
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | - else{ |
|
| 429 | - show_error('Unable to find config file ['. $configFilePath . ']'); |
|
| 428 | + else { |
|
| 429 | + show_error('Unable to find config file [' . $configFilePath . ']'); |
|
| 430 | 430 | } |
| 431 | 431 | static::$loaded['config_' . $filename] = $configFilePath; |
| 432 | 432 | $logger->info('Configuration [' . $configFilePath . '] loaded successfully.'); |
@@ -442,14 +442,14 @@ discard block |
||
| 442 | 442 | * |
| 443 | 443 | * @return void |
| 444 | 444 | */ |
| 445 | - public static function lang($language){ |
|
| 445 | + public static function lang($language) { |
|
| 446 | 446 | $logger = static::getLogger(); |
| 447 | 447 | $language = str_ireplace('.php', '', $language); |
| 448 | 448 | $language = trim($language, '/\\'); |
| 449 | 449 | $language = str_ireplace('lang_', '', $language); |
| 450 | - $file = 'lang_'.$language.'.php'; |
|
| 450 | + $file = 'lang_' . $language . '.php'; |
|
| 451 | 451 | $logger->debug('Loading language [' . $language . '] ...'); |
| 452 | - if(isset(static::$loaded['lang_' . $language])){ |
|
| 452 | + if (isset(static::$loaded['lang_' . $language])) { |
|
| 453 | 453 | $logger->info('Language [' . $language . '] already loaded no need to load it again, cost in performance'); |
| 454 | 454 | return; |
| 455 | 455 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | $cfgKey = get_config('language_cookie_name'); |
| 460 | 460 | $objCookie = & class_loader('Cookie'); |
| 461 | 461 | $cookieLang = $objCookie->get($cfgKey); |
| 462 | - if($cookieLang){ |
|
| 462 | + if ($cookieLang) { |
|
| 463 | 463 | $appLang = $cookieLang; |
| 464 | 464 | } |
| 465 | 465 | $languageFilePath = null; |
@@ -468,30 +468,30 @@ discard block |
||
| 468 | 468 | $searchModuleName = null; |
| 469 | 469 | $obj = & get_instance(); |
| 470 | 470 | //check if the request class contains module name |
| 471 | - if(strpos($language, '/') !== false){ |
|
| 471 | + if (strpos($language, '/') !== false) { |
|
| 472 | 472 | $path = explode('/', $language); |
| 473 | - if(isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
| 473 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
| 474 | 474 | $searchModuleName = $path[0]; |
| 475 | 475 | $language = 'lang_' . $path[1] . '.php'; |
| 476 | - $file = $path[0] . DS .$language; |
|
| 476 | + $file = $path[0] . DS . $language; |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | - if(! $searchModuleName && !empty($obj->moduleName)){ |
|
| 479 | + if (!$searchModuleName && !empty($obj->moduleName)) { |
|
| 480 | 480 | $searchModuleName = $obj->moduleName; |
| 481 | 481 | } |
| 482 | 482 | $moduleLanguagePath = Module::findLanguageFullPath($language, $searchModuleName, $appLang); |
| 483 | - if($moduleLanguagePath){ |
|
| 484 | - $logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it'); |
|
| 483 | + if ($moduleLanguagePath) { |
|
| 484 | + $logger->info('Found language [' . $language . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLanguagePath . '] we will used it'); |
|
| 485 | 485 | $languageFilePath = $moduleLanguagePath; |
| 486 | 486 | } |
| 487 | - else{ |
|
| 487 | + else { |
|
| 488 | 488 | $logger->info('Cannot find language [' . $language . '] from modules using the default location'); |
| 489 | 489 | } |
| 490 | - if(! $languageFilePath){ |
|
| 490 | + if (!$languageFilePath) { |
|
| 491 | 491 | $searchDir = array(APP_LANG_PATH, CORE_LANG_PATH); |
| 492 | - foreach($searchDir as $dir){ |
|
| 492 | + foreach ($searchDir as $dir) { |
|
| 493 | 493 | $filePath = $dir . $appLang . DS . $file; |
| 494 | - if(file_exists($filePath)){ |
|
| 494 | + if (file_exists($filePath)) { |
|
| 495 | 495 | $languageFilePath = $filePath; |
| 496 | 496 | //is already found not to continue |
| 497 | 497 | break; |
@@ -499,12 +499,12 @@ discard block |
||
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | $logger->info('The language file path to be loaded is [' . $languageFilePath . ']'); |
| 502 | - if($languageFilePath){ |
|
| 502 | + if ($languageFilePath) { |
|
| 503 | 503 | require_once $languageFilePath; |
| 504 | - if(! empty($lang) && is_array($lang)){ |
|
| 505 | - $logger->info('Language file [' .$languageFilePath. '] contains the valid languages keys add them to language list'); |
|
| 504 | + if (!empty($lang) && is_array($lang)) { |
|
| 505 | + $logger->info('Language file [' . $languageFilePath . '] contains the valid languages keys add them to language list'); |
|
| 506 | 506 | //Note: may be here the class 'Lang' not yet loaded |
| 507 | - $langObj =& class_loader('Lang', 'classes'); |
|
| 507 | + $langObj = & class_loader('Lang', 'classes'); |
|
| 508 | 508 | $langObj->addLangMessages($lang); |
| 509 | 509 | //free the memory |
| 510 | 510 | unset($lang); |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | static::$loaded['lang_' . $language] = $languageFilePath; |
| 513 | 513 | $logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.'); |
| 514 | 514 | } |
| 515 | - else{ |
|
| 515 | + else { |
|
| 516 | 516 | show_error('Unable to find language file [' . $file . ']'); |
| 517 | 517 | } |
| 518 | 518 | } |
@@ -92,36 +92,36 @@ discard block |
||
| 92 | 92 | /** |
| 93 | 93 | * Construct the new Router instance |
| 94 | 94 | */ |
| 95 | - public function __construct(){ |
|
| 96 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 95 | + public function __construct() { |
|
| 96 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 97 | 97 | $this->logger->setLogger('Library::Router'); |
| 98 | 98 | $routesPath = CONFIG_PATH . 'routes.php'; |
| 99 | 99 | $this->logger->debug('Loading of routes configuration file --> ' . $routesPath . ' ...'); |
| 100 | - if(file_exists($routesPath)){ |
|
| 101 | - $this->logger->info('Found routes configuration file --> ' . $routesPath. ' now load it'); |
|
| 100 | + if (file_exists($routesPath)) { |
|
| 101 | + $this->logger->info('Found routes configuration file --> ' . $routesPath . ' now load it'); |
|
| 102 | 102 | require_once $routesPath; |
| 103 | - if(! empty($route) && is_array($route)){ |
|
| 103 | + if (!empty($route) && is_array($route)) { |
|
| 104 | 104 | $this->routes = $route; |
| 105 | 105 | unset($route); |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | - else{ |
|
| 108 | + else { |
|
| 109 | 109 | show_error('Unable to find the routes configuration file [' . $routesPath . ']'); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | //loading routes for module |
| 113 | 113 | $this->logger->debug('Loading of modules routes ... '); |
| 114 | 114 | $modulesRoutes = Module::getModulesRoutes(); |
| 115 | - if($modulesRoutes && is_array($modulesRoutes)){ |
|
| 115 | + if ($modulesRoutes && is_array($modulesRoutes)) { |
|
| 116 | 116 | $this->routes = array_merge($this->routes, $modulesRoutes); |
| 117 | 117 | $this->logger->info('Routes for all modules loaded successfully'); |
| 118 | 118 | } |
| 119 | - else{ |
|
| 119 | + else { |
|
| 120 | 120 | $this->logger->info('No routes found for all modules skipping.'); |
| 121 | 121 | } |
| 122 | 122 | $this->logger->info('The routes configuration are listed below: ' . stringfy_vars($this->routes)); |
| 123 | 123 | |
| 124 | - foreach($this->routes as $pattern => $callback){ |
|
| 124 | + foreach ($this->routes as $pattern => $callback) { |
|
| 125 | 125 | $this->add($pattern, $callback); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; |
| 130 | 130 | $this->logger->debug('Check if URL suffix is enabled in the configuration'); |
| 131 | 131 | //remove url suffix from the request URI |
| 132 | - if($suffix = get_config('url_suffix')){ |
|
| 133 | - $this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']' ); |
|
| 132 | + if ($suffix = get_config('url_suffix')) { |
|
| 133 | + $this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']'); |
|
| 134 | 134 | $uri = str_ireplace($suffix, '', $uri); |
| 135 | 135 | } |
| 136 | - else{ |
|
| 136 | + else { |
|
| 137 | 137 | $this->logger->info('URL suffix is not enabled in the configuration'); |
| 138 | 138 | } |
| 139 | - if(strpos($uri, '?') !== false){ |
|
| 139 | + if (strpos($uri, '?') !== false) { |
|
| 140 | 140 | $uri = substr($uri, 0, strpos($uri, '?')); |
| 141 | 141 | } |
| 142 | 142 | $uri = trim($uri, $this->uriTrim); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function add($uri, $callback) { |
| 153 | 153 | $uri = trim($uri, $this->uriTrim); |
| 154 | - if(in_array($uri, $this->pattern)){ |
|
| 154 | + if (in_array($uri, $this->pattern)) { |
|
| 155 | 155 | $this->logger->warning('The route [' . $uri . '] already added, may be adding again can have route conflict'); |
| 156 | 156 | } |
| 157 | 157 | $this->pattern[] = $uri; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * Get the module name |
| 163 | 163 | * @return string |
| 164 | 164 | */ |
| 165 | - public function getModule(){ |
|
| 165 | + public function getModule() { |
|
| 166 | 166 | return $this->module; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * Get the controller name |
| 171 | 171 | * @return string |
| 172 | 172 | */ |
| 173 | - public function getController(){ |
|
| 173 | + public function getController() { |
|
| 174 | 174 | return $this->controller; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * Get the controller file path |
| 179 | 179 | * @return string |
| 180 | 180 | */ |
| 181 | - public function getControllerPath(){ |
|
| 181 | + public function getControllerPath() { |
|
| 182 | 182 | return $this->controllerPath; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * Get the controller method |
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | - public function getMethod(){ |
|
| 189 | + public function getMethod() { |
|
| 190 | 190 | return $this->method; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * Get the request arguments |
| 195 | 195 | * @return array |
| 196 | 196 | */ |
| 197 | - public function getArgs(){ |
|
| 197 | + public function getArgs() { |
|
| 198 | 198 | return $this->args; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * Get the URL segments array |
| 203 | 203 | * @return array |
| 204 | 204 | */ |
| 205 | - public function getSegments(){ |
|
| 205 | + public function getSegments() { |
|
| 206 | 206 | return $this->segments; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -211,27 +211,27 @@ discard block |
||
| 211 | 211 | * otherwise send 404 error. |
| 212 | 212 | */ |
| 213 | 213 | public function run() { |
| 214 | - $benchmark =& class_loader('Benchmark'); |
|
| 214 | + $benchmark = & class_loader('Benchmark'); |
|
| 215 | 215 | $benchmark->mark('ROUTING_PROCESS_START'); |
| 216 | 216 | $this->logger->debug('Routing process start ...'); |
| 217 | 217 | $segment = $this->segments; |
| 218 | 218 | $baseUrl = get_config('base_url'); |
| 219 | 219 | //check if the app is not in DOCUMENT_ROOT |
| 220 | - if(isset($segment[0]) && stripos($baseUrl, $segment[0]) != false){ |
|
| 220 | + if (isset($segment[0]) && stripos($baseUrl, $segment[0]) != false) { |
|
| 221 | 221 | array_shift($segment); |
| 222 | 222 | $this->segments = $segment; |
| 223 | 223 | } |
| 224 | 224 | $this->logger->debug('Check if the request URI contains the front controller'); |
| 225 | - if(isset($segment[0]) && $segment[0] == SELF){ |
|
| 225 | + if (isset($segment[0]) && $segment[0] == SELF) { |
|
| 226 | 226 | $this->logger->info('The request URI contains the front controller'); |
| 227 | 227 | array_shift($segment); |
| 228 | 228 | $this->segments = $segment; |
| 229 | 229 | } |
| 230 | - else{ |
|
| 230 | + else { |
|
| 231 | 231 | $this->logger->info('The request URI does not contain the front controller'); |
| 232 | 232 | } |
| 233 | 233 | $uri = implode('/', $segment); |
| 234 | - $this->logger->info('The final Request URI is [' . $uri . ']' ); |
|
| 234 | + $this->logger->info('The final Request URI is [' . $uri . ']'); |
|
| 235 | 235 | //generic routes |
| 236 | 236 | $pattern = array(':num', ':alpha', ':alnum', ':any'); |
| 237 | 237 | $replace = array('[0-9]+', '[a-zA-Z]+', '[a-zA-Z0-9]+', '.*'); |
@@ -245,20 +245,20 @@ discard block |
||
| 245 | 245 | array_shift($args); |
| 246 | 246 | //check if this contains an module |
| 247 | 247 | $moduleControllerMethod = explode('#', $this->callback[$index]); |
| 248 | - if(is_array($moduleControllerMethod) && count($moduleControllerMethod) >= 2){ |
|
| 249 | - $this->logger->info('The current request use the module [' .$moduleControllerMethod[0]. ']'); |
|
| 248 | + if (is_array($moduleControllerMethod) && count($moduleControllerMethod) >= 2) { |
|
| 249 | + $this->logger->info('The current request use the module [' . $moduleControllerMethod[0] . ']'); |
|
| 250 | 250 | $this->module = $moduleControllerMethod[0]; |
| 251 | 251 | $moduleControllerMethod = explode('@', $moduleControllerMethod[1]); |
| 252 | 252 | } |
| 253 | - else{ |
|
| 253 | + else { |
|
| 254 | 254 | $this->logger->info('The current request does not use the module'); |
| 255 | 255 | $moduleControllerMethod = explode('@', $this->callback[$index]); |
| 256 | 256 | } |
| 257 | - if(is_array($moduleControllerMethod)){ |
|
| 258 | - if(isset($moduleControllerMethod[0])){ |
|
| 257 | + if (is_array($moduleControllerMethod)) { |
|
| 258 | + if (isset($moduleControllerMethod[0])) { |
|
| 259 | 259 | $this->controller = $moduleControllerMethod[0]; |
| 260 | 260 | } |
| 261 | - if(isset($moduleControllerMethod[1])){ |
|
| 261 | + if (isset($moduleControllerMethod[1])) { |
|
| 262 | 262 | $this->method = $moduleControllerMethod[1]; |
| 263 | 263 | } |
| 264 | 264 | $this->args = $args; |
@@ -268,73 +268,73 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | //first if the controller is not set and the module is set use the module name as the controller |
| 271 | - if(! $this->getController() && $this->getModule()){ |
|
| 271 | + if (!$this->getController() && $this->getModule()) { |
|
| 272 | 272 | $this->logger->info('After loop in predefined routes configuration, the module name is set but the controller is not set, so we will use module as the controller'); |
| 273 | 273 | $this->controller = $this->getModule(); |
| 274 | 274 | } |
| 275 | 275 | //if can not determine the module/controller/method via the defined routes configuration we will use |
| 276 | 276 | //the URL like http://domain.com/module/controller/method/arg1/arg2 |
| 277 | - if(! $this->getController()){ |
|
| 277 | + if (!$this->getController()) { |
|
| 278 | 278 | $this->logger->info('Cannot determine the routing information using the predefined routes configuration, will use the request URI parameters'); |
| 279 | 279 | $nbSegment = count($segment); |
| 280 | 280 | //if segment is null so means no need to perform |
| 281 | - if($nbSegment > 0){ |
|
| 281 | + if ($nbSegment > 0) { |
|
| 282 | 282 | //get the module list |
| 283 | 283 | $modules = Module::getModuleList(); |
| 284 | 284 | //first check if no module |
| 285 | - if(! $modules){ |
|
| 285 | + if (!$modules) { |
|
| 286 | 286 | $this->logger->info('No module was loaded will skip the module checking'); |
| 287 | 287 | //the application don't use module |
| 288 | 288 | //controller |
| 289 | - if(isset($segment[0])){ |
|
| 289 | + if (isset($segment[0])) { |
|
| 290 | 290 | $this->controller = $segment[0]; |
| 291 | 291 | array_shift($segment); |
| 292 | 292 | } |
| 293 | 293 | //method |
| 294 | - if(isset($segment[0])){ |
|
| 294 | + if (isset($segment[0])) { |
|
| 295 | 295 | $this->method = $segment[0]; |
| 296 | 296 | array_shift($segment); |
| 297 | 297 | } |
| 298 | 298 | //args |
| 299 | 299 | $this->args = $segment; |
| 300 | 300 | } |
| 301 | - else{ |
|
| 301 | + else { |
|
| 302 | 302 | $this->logger->info('The application contains a loaded module will check if the current request is found in the module list'); |
| 303 | - if(in_array($segment[0], $modules)){ |
|
| 303 | + if (in_array($segment[0], $modules)) { |
|
| 304 | 304 | $this->logger->info('Found, the current request use the module [' . $segment[0] . ']'); |
| 305 | 305 | $this->module = $segment[0]; |
| 306 | 306 | array_shift($segment); |
| 307 | 307 | //check if the second arg is the controller from module |
| 308 | - if(isset($segment[0])){ |
|
| 308 | + if (isset($segment[0])) { |
|
| 309 | 309 | $this->controller = $segment[0]; |
| 310 | 310 | //check if the request use the same module name and controller |
| 311 | 311 | $path = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule()); |
| 312 | - if(! $path){ |
|
| 312 | + if (!$path) { |
|
| 313 | 313 | $this->logger->info('The controller [' . $this->getController() . '] not found in the module, may be will use the module [' . $this->getModule() . '] as controller'); |
| 314 | 314 | $this->controller = $this->getModule(); |
| 315 | 315 | } |
| 316 | - else{ |
|
| 316 | + else { |
|
| 317 | 317 | $this->controllerPath = $path; |
| 318 | 318 | array_shift($segment); |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | //check for method |
| 322 | - if(isset($segment[0])){ |
|
| 322 | + if (isset($segment[0])) { |
|
| 323 | 323 | $this->method = $segment[0]; |
| 324 | 324 | array_shift($segment); |
| 325 | 325 | } |
| 326 | 326 | //the remaining is for args |
| 327 | 327 | $this->args = $segment; |
| 328 | 328 | } |
| 329 | - else{ |
|
| 329 | + else { |
|
| 330 | 330 | $this->logger->info('The current request information is not found in the module list'); |
| 331 | 331 | //controller |
| 332 | - if(isset($segment[0])){ |
|
| 332 | + if (isset($segment[0])) { |
|
| 333 | 333 | $this->controller = $segment[0]; |
| 334 | 334 | array_shift($segment); |
| 335 | 335 | } |
| 336 | 336 | //method |
| 337 | - if(isset($segment[0])){ |
|
| 337 | + if (isset($segment[0])) { |
|
| 338 | 338 | $this->method = $segment[0]; |
| 339 | 339 | array_shift($segment); |
| 340 | 340 | } |
@@ -344,18 +344,18 @@ discard block |
||
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | - if(! $this->getController() && $this->getModule()){ |
|
| 347 | + if (!$this->getController() && $this->getModule()) { |
|
| 348 | 348 | $this->logger->info('After using the request URI the module name is set but the controller is not set so we will use module as the controller'); |
| 349 | 349 | $this->controller = $this->getModule(); |
| 350 | 350 | } |
| 351 | 351 | //did we set the controller, so set the controller path |
| 352 | - if($this->getController() && ! $this->getControllerPath()){ |
|
| 352 | + if ($this->getController() && !$this->getControllerPath()) { |
|
| 353 | 353 | $this->logger->debug('Setting the file path for the controller [' . $this->getController() . ']'); |
| 354 | 354 | //if it is the module controller |
| 355 | - if($this->getModule()){ |
|
| 355 | + if ($this->getModule()) { |
|
| 356 | 356 | $this->controllerPath = Module::findControllerFullPath(ucfirst($this->getController()), $this->getModule()); |
| 357 | 357 | } |
| 358 | - else{ |
|
| 358 | + else { |
|
| 359 | 359 | $this->controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->getController()) . '.php'; |
| 360 | 360 | } |
| 361 | 361 | } |
@@ -365,20 +365,20 @@ discard block |
||
| 365 | 365 | $this->logger->debug('Loading controller [' . $controller . '], the file path is [' . $classFilePath . ']...'); |
| 366 | 366 | $benchmark->mark('ROUTING_PROCESS_END'); |
| 367 | 367 | $e404 = false; |
| 368 | - if(file_exists($classFilePath)){ |
|
| 368 | + if (file_exists($classFilePath)) { |
|
| 369 | 369 | require_once $classFilePath; |
| 370 | - if(! class_exists($controller, false)){ |
|
| 370 | + if (!class_exists($controller, false)) { |
|
| 371 | 371 | $e404 = true; |
| 372 | - $this->logger->info('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']'); |
|
| 372 | + $this->logger->info('The controller file [' . $classFilePath . '] exists but does not contain the class [' . $controller . ']'); |
|
| 373 | 373 | } |
| 374 | - else{ |
|
| 374 | + else { |
|
| 375 | 375 | $controllerInstance = new $controller(); |
| 376 | 376 | $controllerMethod = $this->getMethod(); |
| 377 | - if(! method_exists($controllerInstance, $controllerMethod)){ |
|
| 377 | + if (!method_exists($controllerInstance, $controllerMethod)) { |
|
| 378 | 378 | $e404 = true; |
| 379 | 379 | $this->logger->info('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']'); |
| 380 | 380 | } |
| 381 | - else{ |
|
| 381 | + else { |
|
| 382 | 382 | $this->logger->info('Routing data is set correctly now GO!'); |
| 383 | 383 | call_user_func_array(array($controllerInstance, $controllerMethod), $this->getArgs()); |
| 384 | 384 | $obj = & get_instance(); |
@@ -388,12 +388,12 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | - else{ |
|
| 391 | + else { |
|
| 392 | 392 | $this->logger->info('The controller file path [' . $classFilePath . '] does not exist'); |
| 393 | 393 | $e404 = true; |
| 394 | 394 | } |
| 395 | - if($e404){ |
|
| 396 | - $response =& class_loader('Response', 'classes'); |
|
| 395 | + if ($e404) { |
|
| 396 | + $response = & class_loader('Response', 'classes'); |
|
| 397 | 397 | $response->send404(); |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | - class Log{ |
|
| 27 | + class Log { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The defined constante for Log level |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * Create new Log instance |
| 54 | 54 | */ |
| 55 | - public function __construct(){ |
|
| 55 | + public function __construct() { |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Set the logger to identify each message in the log |
| 60 | 60 | * @param string $logger the logger name |
| 61 | 61 | */ |
| 62 | - public function setLogger($logger){ |
|
| 62 | + public function setLogger($logger) { |
|
| 63 | 63 | $this->logger = $logger; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @see Log::writeLog for more detail |
| 69 | 69 | * @param string $message the log message to save |
| 70 | 70 | */ |
| 71 | - public function fatal($message){ |
|
| 71 | + public function fatal($message) { |
|
| 72 | 72 | $this->writeLog($message, self::FATAL); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @see Log::writeLog for more detail |
| 78 | 78 | * @param string $message the log message to save |
| 79 | 79 | */ |
| 80 | - public function error($message){ |
|
| 80 | + public function error($message) { |
|
| 81 | 81 | $this->writeLog($message, self::ERROR); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @see Log::writeLog for more detail |
| 87 | 87 | * @param string $message the log message to save |
| 88 | 88 | */ |
| 89 | - public function warning($message){ |
|
| 89 | + public function warning($message) { |
|
| 90 | 90 | $this->writeLog($message, self::WARNING); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @see Log::writeLog for more detail |
| 96 | 96 | * @param string $message the log message to save |
| 97 | 97 | */ |
| 98 | - public function info($message){ |
|
| 98 | + public function info($message) { |
|
| 99 | 99 | $this->writeLog($message, self::INFO); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @see Log::writeLog for more detail |
| 105 | 105 | * @param string $message the log message to save |
| 106 | 106 | */ |
| 107 | - public function debug($message){ |
|
| 107 | + public function debug($message) { |
|
| 108 | 108 | $this->writeLog($message, self::DEBUG); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -115,59 +115,59 @@ discard block |
||
| 115 | 115 | * @param integer|string $level the log level in integer or string format, if is string will convert into integer |
| 116 | 116 | * to allow check the log level threshold. |
| 117 | 117 | */ |
| 118 | - public function writeLog($message, $level = self::INFO){ |
|
| 118 | + public function writeLog($message, $level = self::INFO) { |
|
| 119 | 119 | $configLogLevel = get_config('log_level'); |
| 120 | - if(! $configLogLevel){ |
|
| 120 | + if (!$configLogLevel) { |
|
| 121 | 121 | //so means no need log just stop here |
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | //check config log level |
| 125 | - if(! self::isValidConfigLevel($configLogLevel)){ |
|
| 125 | + if (!self::isValidConfigLevel($configLogLevel)) { |
|
| 126 | 126 | //NOTE: here need put the show_error() "logging" to false to prevent loop |
| 127 | 127 | show_error('Invalid config log level [' . $configLogLevel . '], the value must be one of the following: ' . implode(', ', array_map('strtoupper', self::$validConfigLevel)), $title = 'Log Config Error', $logging = false); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | //check if config log_logger_name is set |
| 131 | - if($this->logger){ |
|
| 131 | + if ($this->logger) { |
|
| 132 | 132 | $configLoggerName = get_config('log_logger_name', ''); |
| 133 | - if($configLoggerName){ |
|
| 134 | - if (is_array($configLoggerName)){ |
|
| 133 | + if ($configLoggerName) { |
|
| 134 | + if (is_array($configLoggerName)) { |
|
| 135 | 135 | //for best comparaison put all string to lowercase |
| 136 | 136 | $configLoggerName = array_map('strtolower', $configLoggerName); |
| 137 | - if(! in_array(strtolower($this->logger), $configLoggerName)){ |
|
| 137 | + if (!in_array(strtolower($this->logger), $configLoggerName)) { |
|
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | - else if(strtolower($this->logger) !== strtolower($configLoggerName)){ |
|
| 141 | + else if (strtolower($this->logger) !== strtolower($configLoggerName)) { |
|
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | //if $level is not an integer |
| 148 | - if(! is_numeric($level)){ |
|
| 148 | + if (!is_numeric($level)) { |
|
| 149 | 149 | $level = self::getLevelValue($level); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | //check if can logging regarding the log level config |
| 153 | 153 | $configLevel = self::getLevelValue($configLogLevel); |
| 154 | - if($configLevel > $level){ |
|
| 154 | + if ($configLevel > $level) { |
|
| 155 | 155 | //can't log |
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $logSavePath = get_config('log_save_path'); |
| 160 | - if(! $logSavePath){ |
|
| 160 | + if (!$logSavePath) { |
|
| 161 | 161 | $logSavePath = LOGS_PATH; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if(! is_dir($logSavePath) || !is_writable($logSavePath)){ |
|
| 164 | + if (!is_dir($logSavePath) || !is_writable($logSavePath)) { |
|
| 165 | 165 | //NOTE: here need put the show_error() "logging" to false to prevent loop |
| 166 | 166 | show_error('Error : the log dir does not exists or is not writable', $title = 'Log directory error', $logging = false); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $path = $logSavePath . 'logs-' . date('Y-m-d') . '.log'; |
| 170 | - if(! file_exists($path)){ |
|
| 170 | + if (!file_exists($path)) { |
|
| 171 | 171 | touch($path); |
| 172 | 172 | } |
| 173 | 173 | //may be at this time helper user_agent not yet included |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $str = $logDate . ' [' . str_pad($levelName, 7 /*warning len*/) . '] ' . ' [' . str_pad($ip, 15) . '] ' . $this->logger . ' : ' . $message . ' ' . '[' . $fileInfo['file'] . '::' . $fileInfo['line'] . ']' . "\n"; |
| 191 | 191 | $fp = fopen($path, 'a+'); |
| 192 | - if(is_resource($fp)){ |
|
| 192 | + if (is_resource($fp)) { |
|
| 193 | 193 | flock($fp, LOCK_EX); // exclusive lock, will get released when the file is closed |
| 194 | 194 | fwrite($fp, $str); |
| 195 | 195 | fclose($fp); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @return boolean true if the given log level is valid, false if not |
| 205 | 205 | */ |
| 206 | - private static function isValidConfigLevel($level){ |
|
| 206 | + private static function isValidConfigLevel($level) { |
|
| 207 | 207 | $level = strtolower($level); |
| 208 | 208 | return in_array($level, self::$validConfigLevel); |
| 209 | 209 | } |
@@ -213,27 +213,27 @@ discard block |
||
| 213 | 213 | * @param string $level the log level in string format |
| 214 | 214 | * @return int the log level in integer format using the predefinied constants |
| 215 | 215 | */ |
| 216 | - private static function getLevelValue($level){ |
|
| 216 | + private static function getLevelValue($level) { |
|
| 217 | 217 | $level = strtolower($level); |
| 218 | 218 | $value = self::NONE; |
| 219 | 219 | |
| 220 | 220 | //the default value is NONE, so means no need test for NONE |
| 221 | - if($level == 'fatal'){ |
|
| 221 | + if ($level == 'fatal') { |
|
| 222 | 222 | $value = self::FATAL; |
| 223 | 223 | } |
| 224 | - else if($level == 'error'){ |
|
| 224 | + else if ($level == 'error') { |
|
| 225 | 225 | $value = self::ERROR; |
| 226 | 226 | } |
| 227 | - else if($level == 'warning' || $level == 'warn'){ |
|
| 227 | + else if ($level == 'warning' || $level == 'warn') { |
|
| 228 | 228 | $value = self::WARNING; |
| 229 | 229 | } |
| 230 | - else if($level == 'info'){ |
|
| 230 | + else if ($level == 'info') { |
|
| 231 | 231 | $value = self::INFO; |
| 232 | 232 | } |
| 233 | - else if($level == 'debug'){ |
|
| 233 | + else if ($level == 'debug') { |
|
| 234 | 234 | $value = self::DEBUG; |
| 235 | 235 | } |
| 236 | - else if($level == 'all'){ |
|
| 236 | + else if ($level == 'all') { |
|
| 237 | 237 | $value = self::ALL; |
| 238 | 238 | } |
| 239 | 239 | return $value; |
@@ -244,23 +244,23 @@ discard block |
||
| 244 | 244 | * @param integer $level the log level in integer format |
| 245 | 245 | * @return string the log level in string format |
| 246 | 246 | */ |
| 247 | - private static function getLevelName($level){ |
|
| 247 | + private static function getLevelName($level) { |
|
| 248 | 248 | $value = ''; |
| 249 | 249 | |
| 250 | 250 | //the default value is NONE, so means no need test for NONE |
| 251 | - if($level == self::FATAL){ |
|
| 251 | + if ($level == self::FATAL) { |
|
| 252 | 252 | $value = 'FATAL'; |
| 253 | 253 | } |
| 254 | - else if($level == self::ERROR){ |
|
| 254 | + else if ($level == self::ERROR) { |
|
| 255 | 255 | $value = 'ERROR'; |
| 256 | 256 | } |
| 257 | - else if($level == self::WARNING){ |
|
| 257 | + else if ($level == self::WARNING) { |
|
| 258 | 258 | $value = 'WARNING'; |
| 259 | 259 | } |
| 260 | - else if($level == self::INFO){ |
|
| 260 | + else if ($level == self::INFO) { |
|
| 261 | 261 | $value = 'INFO'; |
| 262 | 262 | } |
| 263 | - else if($level == self::DEBUG){ |
|
| 263 | + else if ($level == self::DEBUG) { |
|
| 264 | 264 | $value = 'DEBUG'; |
| 265 | 265 | } |
| 266 | 266 | //no need for ALL |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * For application languages management |
| 29 | 29 | */ |
| 30 | - class Lang{ |
|
| 30 | + class Lang { |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * The supported available language for this application. |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * Construct new Lang instance |
| 69 | 69 | */ |
| 70 | - public function __construct(){ |
|
| 71 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 70 | + public function __construct() { |
|
| 71 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 72 | 72 | $this->logger->setLogger('Library::Lang'); |
| 73 | 73 | |
| 74 | 74 | $this->default = get_config('default_language', 'en'); |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | //add the supported languages ('key', 'display name') |
| 78 | 78 | $languages = get_config('languages', null); |
| 79 | - if(! empty($languages)){ |
|
| 80 | - foreach($languages as $key => $displayName){ |
|
| 79 | + if (!empty($languages)) { |
|
| 80 | + foreach ($languages as $key => $displayName) { |
|
| 81 | 81 | $this->addLang($key, $displayName); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | //if the language exists in cookie use it |
| 87 | 87 | $cfgKey = get_config('language_cookie_name'); |
| 88 | - $this->logger->debug('Getting current language from cookie [' .$cfgKey. ']'); |
|
| 88 | + $this->logger->debug('Getting current language from cookie [' . $cfgKey . ']'); |
|
| 89 | 89 | $objCookie = & class_loader('Cookie'); |
| 90 | 90 | $cookieLang = $objCookie->get($cfgKey); |
| 91 | - if($cookieLang && $this->isValid($cookieLang)){ |
|
| 91 | + if ($cookieLang && $this->isValid($cookieLang)) { |
|
| 92 | 92 | $this->current = $cookieLang; |
| 93 | - $this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']'); |
|
| 93 | + $this->logger->info('Language from cookie [' . $cfgKey . '] is valid so we will set the language using the cookie value [' . $cookieLang . ']'); |
|
| 94 | 94 | } |
| 95 | - else{ |
|
| 96 | - $this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']'); |
|
| 95 | + else { |
|
| 96 | + $this->logger->info('Language from cookie [' . $cfgKey . '] is not set, use the default value [' . $this->getDefault() . ']'); |
|
| 97 | 97 | $this->current = $this->getDefault(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return array the language message list |
| 105 | 105 | */ |
| 106 | - public function getAll(){ |
|
| 106 | + public function getAll() { |
|
| 107 | 107 | return $this->languages; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param string $key the language key to identify |
| 114 | 114 | * @param string $value the language message value |
| 115 | 115 | */ |
| 116 | - public function set($key, $value){ |
|
| 116 | + public function set($key, $value) { |
|
| 117 | 117 | $this->languages[$key] = $value; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return string the language message value |
| 127 | 127 | */ |
| 128 | - public function get($key, $default = 'LANGUAGE_ERROR'){ |
|
| 129 | - if(isset($this->languages[$key])){ |
|
| 128 | + public function get($key, $default = 'LANGUAGE_ERROR') { |
|
| 129 | + if (isset($this->languages[$key])) { |
|
| 130 | 130 | return $this->languages[$key]; |
| 131 | 131 | } |
| 132 | - $this->logger->warning('Language key [' .$key. '] does not exist use the default value [' .$default. ']'); |
|
| 132 | + $this->logger->warning('Language key [' . $key . '] does not exist use the default value [' . $default . ']'); |
|
| 133 | 133 | return $default; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @return boolean true if the language directory exists, false or not |
| 142 | 142 | */ |
| 143 | - public function isValid($language){ |
|
| 143 | + public function isValid($language) { |
|
| 144 | 144 | $searchDir = array(CORE_LANG_PATH, APP_LANG_PATH); |
| 145 | - foreach($searchDir as $dir){ |
|
| 146 | - if(file_exists($dir . $language) && is_dir($dir . $language)){ |
|
| 145 | + foreach ($searchDir as $dir) { |
|
| 146 | + if (file_exists($dir . $language) && is_dir($dir . $language)) { |
|
| 147 | 147 | return true; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return string the default language |
| 157 | 157 | */ |
| 158 | - public function getDefault(){ |
|
| 158 | + public function getDefault() { |
|
| 159 | 159 | return $this->default; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @return string the current language |
| 166 | 166 | */ |
| 167 | - public function getCurrent(){ |
|
| 167 | + public function getCurrent() { |
|
| 168 | 168 | return $this->current; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | * @param string $name the short language name like "en", "fr". |
| 175 | 175 | * @param string $description the human readable description of this language |
| 176 | 176 | */ |
| 177 | - public function addLang($name, $description){ |
|
| 178 | - if(isset($this->availables[$name])){ |
|
| 177 | + public function addLang($name, $description) { |
|
| 178 | + if (isset($this->availables[$name])) { |
|
| 179 | 179 | return; //already added cost in performance |
| 180 | 180 | } |
| 181 | - if($this->isValid($name)){ |
|
| 181 | + if ($this->isValid($name)) { |
|
| 182 | 182 | $this->availables[$name] = $description; |
| 183 | 183 | } |
| 184 | - else{ |
|
| 184 | + else { |
|
| 185 | 185 | show_error('The language [' . $name . '] is not valid or does not exists.'); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return array the list of the application language |
| 193 | 193 | */ |
| 194 | - public function getSupported(){ |
|
| 194 | + public function getSupported() { |
|
| 195 | 195 | return $this->availables; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @param array $langs the languages array of the messages to be added |
| 202 | 202 | */ |
| 203 | - public function addLangMessages(array $langs){ |
|
| 203 | + public function addLangMessages(array $langs) { |
|
| 204 | 204 | foreach ($langs as $key => $value) { |
| 205 | 205 | $this->set($key, $value); |
| 206 | 206 | } |