From 4f5111aa04841a766b5fd8e782050de494628e45 Mon Sep 17 00:00:00 2001 From: HungNA - Technical Manager Date: Tue, 10 Sep 2024 09:42:40 +0700 Subject: [PATCH] Update trim --- system/helpers/url_helper.php | 18 ++++++++++++------ thirdParty/MX/Controller.php | 7 ++++++- thirdParty/REST/Format.php | 15 ++++++++++++--- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index e2464ff..ae0e35a 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -704,8 +704,10 @@ function redirect($uri = '', $method = 'auto', $code = NULL) function cdn_js_url($uri = '') { $cdnJs = '//cdnjs.cloudflare.com/ajax/libs/'; - - return $cdnJs . trim($uri); + if ($uri !== null) { + $uri = trim($uri); + } + return $cdnJs . $uri; } } @@ -725,8 +727,10 @@ function cdn_js_url($uri = '') function google_fonts_url($family = '') { $fonts = '//fonts.googleapis.com/css?family='; - - return $fonts . trim($family); + if ($family !== null) { + $family = trim($family); + } + return $fonts .$family; } } @@ -746,7 +750,9 @@ function google_fonts_url($family = '') function bootstrapcdn_url($uri = '') { $cdn = '//maxcdn.bootstrapcdn.com/bootstrap/'; - - return $cdn . trim($uri); + if ($uri !== null) { + $uri = trim($uri); + } + return $cdn .$uri; } } diff --git a/thirdParty/MX/Controller.php b/thirdParty/MX/Controller.php index 3b6c021..adc5f99 100644 --- a/thirdParty/MX/Controller.php +++ b/thirdParty/MX/Controller.php @@ -46,7 +46,12 @@ class MX_Controller public function __construct() { - $class = str_replace(CI::$APP->config->item('controller_suffix'), '', get_class($this)); + if (CI::$APP->config->item('controller_suffix') !== null) { + $class = str_replace(CI::$APP->config->item('controller_suffix'), '', get_class($this)); + } else { + $class = get_class($this); + } + log_message('info', $class . " MX_Controller Initialized"); Modules::$registry[bear_str_to_lower($class)] = $this; diff --git a/thirdParty/REST/Format.php b/thirdParty/REST/Format.php index d4efb98..9cb8c89 100644 --- a/thirdParty/REST/Format.php +++ b/thirdParty/REST/Format.php @@ -476,7 +476,10 @@ protected function _from_csv($data, $delimiter = ',', $enclosure = '"') */ protected function _from_json($data) { - return json_decode(trim($data)); + if ($data !== null){ + $data = trim($data); + } + return json_decode($data); } /** @@ -486,7 +489,10 @@ protected function _from_json($data) */ protected function _from_serialize($data) { - return unserialize(trim($data)); + if ($data !== null) { + $data = trim($data); + } + return unserialize($data); } /** @@ -496,7 +502,10 @@ protected function _from_serialize($data) */ protected function _from_php($data) { - return trim($data); + if ($data !== null) { + return trim($data); + } + return $data; } }