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:
Diffstat (limited to 'libs/Zend/Uri/Http.php')
-rw-r--r--libs/Zend/Uri/Http.php89
1 files changed, 66 insertions, 23 deletions
diff --git a/libs/Zend/Uri/Http.php b/libs/Zend/Uri/Http.php
index c8ef6ac360..48911dad64 100644
--- a/libs/Zend/Uri/Http.php
+++ b/libs/Zend/Uri/Http.php
@@ -14,20 +14,20 @@
*
* @category Zend
* @package Zend_Uri
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id: Http.php 16208 2009-06-21 19:19:26Z thomas $
+ * @version $Id: Http.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Uri
*/
-require_once 'Zend/Uri.php';
+// require_once 'Zend/Uri.php';
/**
* @see Zend_Validate_Hostname
*/
-require_once 'Zend/Validate/Hostname.php';
+// require_once 'Zend/Validate/Hostname.php';
/**
* HTTP(S) URI handler
@@ -35,7 +35,7 @@ require_once 'Zend/Validate/Hostname.php';
* @category Zend
* @package Zend_Uri
* @uses Zend_Uri
- * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Uri_Http extends Zend_Uri
@@ -152,7 +152,7 @@ class Zend_Uri_Http extends Zend_Uri
// Validate the URI
if ($this->valid() === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Invalid URI supplied');
}
}
@@ -170,7 +170,7 @@ class Zend_Uri_Http extends Zend_Uri
public static function fromString($uri)
{
if (is_string($uri) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('$uri is not a string');
}
@@ -179,7 +179,7 @@ class Zend_Uri_Http extends Zend_Uri
$schemeSpecific = isset($uri[1]) === true ? $uri[1] : '';
if (in_array($scheme, array('http', 'https')) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception("Invalid scheme: '$scheme'");
}
@@ -201,7 +201,7 @@ class Zend_Uri_Http extends Zend_Uri
$pattern = '~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~';
$status = @preg_match($pattern, $schemeSpecific, $matches);
if ($status === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: scheme-specific decomposition failed');
}
@@ -220,7 +220,7 @@ class Zend_Uri_Http extends Zend_Uri
$pattern = '~^(([^:@]*)(:([^@]*))?@)?([^:]+)(:(.*))?$~';
$status = @preg_match($pattern, $combo, $matches);
if ($status === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: authority decomposition failed');
}
@@ -247,7 +247,7 @@ class Zend_Uri_Http extends Zend_Uri
public function getUri()
{
if ($this->valid() === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('One or more parts of the URI are invalid');
}
@@ -320,7 +320,7 @@ class Zend_Uri_Http extends Zend_Uri
self::CHAR_ALNUM . self::CHAR_MARK . ';:&=+$,' . '])+$/', $username);
if ($status === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: username validation failed');
}
@@ -337,7 +337,7 @@ class Zend_Uri_Http extends Zend_Uri
public function setUsername($username)
{
if ($this->validateUsername($username) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception("Username \"$username\" is not a valid HTTP username");
}
@@ -387,7 +387,7 @@ class Zend_Uri_Http extends Zend_Uri
self::CHAR_ALNUM . self::CHAR_MARK . ';:&=+$,' . '])+$/', $password);
if ($status === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: password validation failed.');
}
@@ -404,7 +404,7 @@ class Zend_Uri_Http extends Zend_Uri
public function setPassword($password)
{
if ($this->validatePassword($password) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception("Password \"$password\" is not a valid HTTP password.");
}
@@ -459,7 +459,7 @@ class Zend_Uri_Http extends Zend_Uri
public function setHost($host)
{
if ($this->validateHost($host) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception("Host \"$host\" is not a valid HTTP host");
}
@@ -511,7 +511,7 @@ class Zend_Uri_Http extends Zend_Uri
public function setPort($port)
{
if ($this->validatePort($port) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception("Port \"$port\" is not a valid HTTP port.");
}
@@ -554,7 +554,7 @@ class Zend_Uri_Http extends Zend_Uri
$pattern = '/^' . $this->_regex['path'] . '$/';
$status = @preg_match($pattern, $path);
if ($status === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: path validation failed');
}
@@ -571,7 +571,7 @@ class Zend_Uri_Http extends Zend_Uri
public function setPath($path)
{
if ($this->validatePath($path) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception("Path \"$path\" is not a valid HTTP path");
}
@@ -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.
*
@@ -615,7 +632,7 @@ class Zend_Uri_Http extends Zend_Uri
$pattern = '/^' . $this->_regex['uric'] . '*$/';
$status = @preg_match($pattern, $query);
if ($status === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: query validation failed');
}
@@ -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.
*
@@ -654,7 +697,7 @@ class Zend_Uri_Http extends Zend_Uri
// Make sure the query is valid, and set it
if ($this->validateQuery($query) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception("'$query' is not a valid query string");
}
@@ -697,7 +740,7 @@ class Zend_Uri_Http extends Zend_Uri
$pattern = '/^' . $this->_regex['uric'] . '*$/';
$status = @preg_match($pattern, $fragment);
if ($status === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: fragment validation failed');
}
@@ -714,7 +757,7 @@ class Zend_Uri_Http extends Zend_Uri
public function setFragment($fragment)
{
if ($this->validateFragment($fragment) === false) {
- require_once 'Zend/Uri/Exception.php';
+ // require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception("Fragment \"$fragment\" is not a valid HTTP fragment");
}