Skip to content

Commit

Permalink
Create url::merge_querystring() which merges a query string into an
Browse files Browse the repository at this point in the history
existing url.  Fixes #1537.
  • Loading branch information
bharat committed Dec 17, 2010
1 parent 6ac82bc commit 53a2652
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/gallery/helpers/MY_url.php
Expand Up @@ -101,4 +101,18 @@ static function merge(array $arguments) {
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";
}
}
}

0 comments on commit 53a2652

Please sign in to comment.