|
|
@@ -592,6 +592,23 @@ class Zend_Uri_Http extends Zend_Uri
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Returns the query portion of the URL (after ?) as a
|
|
|
+ * key-value-array. If the query is empty an empty array
|
|
|
+ * is returned
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getQueryAsArray()
|
|
|
+ {
|
|
|
+ $query = $this->getQuery();
|
|
|
+ $querryArray = array();
|
|
|
+ if ($query !== false) {
|
|
|
+ parse_str($query, $querryArray);
|
|
|
+ }
|
|
|
+ return $querryArray;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Returns true if and only if the query string passes validation. If no query is passed,
|
|
|
* then the query string contained in the instance variable is used.
|
|
|
*
|
|
|
@@ -623,6 +640,32 @@ class Zend_Uri_Http extends Zend_Uri
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Add or replace params in the query string for the current URI, and
|
|
|
+ * return the old query.
|
|
|
+ *
|
|
|
+ * @param array $queryParams
|
|
|
+ * @return string Old query string
|
|
|
+ */
|
|
|
+ public function addReplaceQueryParameters(array $queryParams)
|
|
|
+ {
|
|
|
+ $queryParams = array_merge($this->getQueryAsArray(), $queryParams);
|
|
|
+ return $this->setQuery($queryParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Remove params in the query string for the current URI, and
|
|
|
+ * return the old query.
|
|
|
+ *
|
|
|
+ * @param array $queryParamKeys
|
|
|
+ * @return string Old query string
|
|
|
+ */
|
|
|
+ public function removeQueryParameters(array $queryParamKeys)
|
|
|
+ {
|
|
|
+ $queryParams = array_diff_key($this->getQueryAsArray(), array_fill_keys($queryParamKeys, 0));
|
|
|
+ return $this->setQuery($queryParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Set the query string for the current URI, and return the old query
|
|
|
* string This method accepts both strings and arrays.
|
|
|
*
|