Skip to content

Commit

Permalink
Merge pull request #23 from nguyenanhung/develop
Browse files Browse the repository at this point in the history
Add some helper in url_helper
  • Loading branch information
nguyenanhung authored Apr 17, 2023
2 parents d00c097 + d9f1986 commit 56ec69b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ Hiện tại việc sử dụng nanoid đang là xu hướng so với uuid truy
- [x] Helper Function: `cdn_url` - Hàm customize dành riêng cho framework CodeIgniter
- [x] Helper Function: `images_url` - Hàm customize dành riêng cho framework CodeIgniter
- [x] Helper Function: `audio_url` - Hàm customize dành riêng cho framework CodeIgniter
- [x] Helper Function: `append_params_into_url` - Append parameters to URL
- [x] Helper Function: `append_query_string_to_current_url` - Get current URL including query string - Hàm customize dành riêng cho framework CodeIgniter

### UUID Helper

Expand Down
1 change: 0 additions & 1 deletion helpers/chart_render.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function bear_framework_default_get_data_chart($item_list, $valueGet, $total)
return (new \nguyenanhung\CodeIgniter\BasicHelper\ChartRender())->get_data_chart($item_list, $valueGet, $total);
}
}

if (!function_exists('bear_framework_default_get_data_chart_report')) {
function bear_framework_default_get_data_chart_report($item_list, $valueGet)
{
Expand Down
2 changes: 1 addition & 1 deletion helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ function __get_error_trace__($e)
{
return "Error Trace: " . $e->getTraceAsString();
}
}
}
56 changes: 56 additions & 0 deletions helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,59 @@ function audio_url($input = '')
return $audio_url;
}
}
if (!function_exists('append_params_into_url')) {
/**
* Function Append parameters to URL
*
* @param $url
* @param $params
*
* @return string
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 17/04/2023 29:59
*/
function append_params_into_url($url, $params)
{
$urlParts = parse_url($url);
if (isset($urlParts['query'])) {
$queryParams = [];
parse_str($urlParts['query'], $queryParams);
$queryParams = array_merge($queryParams, $params);
$urlParts['query'] = http_build_query($queryParams);
} else {
$urlParts['query'] = http_build_query($params);
}

$newUrl = $urlParts['scheme'] . '://' . $urlParts['host'] . $urlParts['path'] . '?' . $urlParts['query'];

if (isset($urlParts['port'])) {
$newUrl = $urlParts['scheme'] . '://' . $urlParts['host'] . ':' . $urlParts['port'] . $urlParts['path'] . '?' . $urlParts['query'];
}

return $newUrl;
}
}
if (!function_exists('append_query_string_to_current_url')) {
/**
* Function Get current URL including query string
*
* @return string
* @author : 713uk13m <[email protected]>
* @copyright: 713uk13m <[email protected]>
* @time : 17/04/2023 31:27
*/
function append_query_string_to_current_url()
{
if (function_exists('current_url')) {
$url = current_url();
if (!empty($_SERVER['QUERY_STRING'])) {
$url .= '?' . $_SERVER['QUERY_STRING'];
}

return $url;
}

return '';
}
}
4 changes: 2 additions & 2 deletions src/BaseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
*/
class BaseHelper
{
const VERSION = '1.3.7';
const LAST_MODIFIED = '2023-03-29';
const VERSION = '1.3.8';
const LAST_MODIFIED = '2023-04-17';
const PROJECT_NAME = 'CodeIgniter - Basic Helper';
const AUTHOR_NAME = 'Hung Nguyen';
const AUTHOR_FULL_NAME = 'Hung Nguyen';
Expand Down

0 comments on commit 56ec69b

Please sign in to comment.