diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-05 03:20:27 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-05 03:20:27 +0000 |
commit | 2cd3ef9e9b25a9166b6c816d622f593a41256898 (patch) | |
tree | e1b9b947662080d6953513f6714e8a6abfd186f0 /engine/lib/elgglib.php | |
parent | e53bf6cc34137cee9bec69cbe5c35c3851567fe9 (diff) | |
download | elgg-2cd3ef9e9b25a9166b6c816d622f593a41256898.tar.gz elgg-2cd3ef9e9b25a9166b6c816d622f593a41256898.tar.bz2 |
Fixes #1481: Applie Mike's patch and created function elgg_http_add_url_query_elements() to handle what the pagination view was trying to do.
git-svn-id: http://code.elgg.org/elgg/trunk@3903 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r-- | engine/lib/elgglib.php | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 357141baa..76f8430b7 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2576,12 +2576,12 @@ function elgg_validate_action_url($link) { * @return string */ function elgg_http_remove_url_query_element($url, $element) { - $url = parse_url($url); + $url_array = parse_url($url); - if (isset($url['query'])) { - parse_str($url['query'], $query); + if (isset($url_array['query'])) { + parse_str($url_array['query'], $query); } else { - // nothing to remove. + // nothing to remove. Return original URL. return $url; } @@ -2589,13 +2589,39 @@ function elgg_http_remove_url_query_element($url, $element) { unset($query[$element]); } - $url['query'] = http_build_query($query); - $string = elgg_http_build_url($url); + $url_array['query'] = http_build_query($query); + $string = elgg_http_build_url($url_array); return $string; } /** + * Adds get params to $url + * + * @param str $url + * @param array $elements k/v pairs. + * @return str + */ +function elgg_http_add_url_query_elements($url, array $elements) { + $url_array = parse_url($url); + + if (isset($url_array['query'])) { + parse_str($url_array['query'], $query); + } else { + $query = array(); + } + + foreach ($elements as $k => $v) { + $query[$k] = $v; + } + + $url_array['query'] = http_build_query($query); + $string = elgg_http_build_url($url_array); + + return $string; +} + +/** * Returns the PHP INI setting in bytes * * @param str $setting |