Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2014-02-18 04:30:41 +0400
committermattab <matthieu.aubry@gmail.com>2014-02-18 04:30:41 +0400
commit58449a825aaddf2f9bd223cdb89fd6c74775440f (patch)
tree52fcb4935bbcfef21ffcd73f96f66ddc804a7f39 /core/UrlHelper.php
parent06946af25eb5785e85a01e4c3117b2bb718497b8 (diff)
Finishing clearing the console command to allow piwik domain
Diffstat (limited to 'core/UrlHelper.php')
-rw-r--r--core/UrlHelper.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/core/UrlHelper.php b/core/UrlHelper.php
index dbdb04dfd2..2ce26ba165 100644
--- a/core/UrlHelper.php
+++ b/core/UrlHelper.php
@@ -456,4 +456,41 @@ class UrlHelper
'keywords' => $key,
);
}
+
+ /**
+ * Returns the query part from any valid url and adds additional parameters to the query part if needed.
+ *
+ * @param string $url Any url eg `"http://example.com/piwik/?foo=bar"`
+ * @param array $additionalParamsToAdd If not empty the given parameters will be added to the query.
+ *
+ * @return string eg. `"foo=bar&foo2=bar2"`
+ * @api
+ */
+ public static function getQueryFromUrl($url, array $additionalParamsToAdd = array())
+ {
+ $url = @parse_url($url);
+ $query = '';
+
+ if (!empty($url['query'])) {
+ $query .= $url['query'];
+ }
+
+ if (!empty($additionalParamsToAdd)) {
+ if (!empty($query)) {
+ $query .= '&';
+ }
+
+ $query .= Url::getQueryStringFromParameters($additionalParamsToAdd);
+ }
+
+ return $query;
+ }
+
+ public static function getHostFromUrl($url)
+ {
+ if (!UrlHelper::isLookLikeUrl($url)) {
+ $url = "http://" . $url;
+ }
+ return parse_url($url, PHP_URL_HOST);
+ }
}