diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2010-12-16 20:36:00 -0800 | 
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2010-12-16 20:36:00 -0800 | 
| commit | 53a2652fd6ba652b1b6604f8a4930403376a3ef5 (patch) | |
| tree | a65b388479bb887b351e33a4a62ce7431eea8b0d /modules/gallery | |
| parent | 6ac82bc6b72e94466787e291e15968f15f33089d (diff) | |
Create url::merge_querystring() which merges a query string into an
existing url.  Fixes #1537.
Diffstat (limited to 'modules/gallery')
| -rw-r--r-- | modules/gallery/helpers/MY_url.php | 14 | 
1 files changed, 14 insertions, 0 deletions
| 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"; +    } +  }  } | 
