summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-12-16 20:36:00 -0800
committerBharat Mediratta <bharat@menalto.com>2010-12-16 20:36:00 -0800
commit53a2652fd6ba652b1b6604f8a4930403376a3ef5 (patch)
treea65b388479bb887b351e33a4a62ce7431eea8b0d /modules/gallery/helpers
parent6ac82bc6b72e94466787e291e15968f15f33089d (diff)
Create url::merge_querystring() which merges a query string into an
existing url. Fixes #1537.
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/MY_url.php14
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";
+ }
+ }
}