From 53a2652fd6ba652b1b6604f8a4930403376a3ef5 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 16 Dec 2010 20:36:00 -0800 Subject: Create url::merge_querystring() which merges a query string into an existing url. Fixes #1537. --- modules/gallery/helpers/MY_url.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'modules') diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index 877c5ada..d3ab1b4d 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -101,4 +101,18 @@ class url extends url_Core { static function current($qs=false, $suffix=false) { return htmlspecialchars(parent::current($qs, $suffix)); } + + /** + * Merge extra an query string onto a given url safely. + * @param string the original url + * @param array the query string data in key=value form + */ + static function merge_querystring($url, $query_params) { + $qs = implode("&", $query_params); + if (strpos($url, "?") === false) { + return $url . "?$qs"; + } else { + return $url . "&$qs"; + } + } } -- cgit v1.2.3