cvs: pear /Net_URL2 URL2.php

From: Date: Wed, 04 Jul 2007 14:53:29 +0000
Subject: cvs: pear /Net_URL2 URL2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-47853@lists.php.net to get a copy of this message
davidc Wed Jul 4 14:53:29 2007 UTC Modified files: /pear/Net_URL2 URL2.php Log: - Diff from Brett Bieber - CS Cleanage - New method called removeQueryStringArray - Method renaming http://cvs.php.net/viewvc.cgi/pear/Net_URL2/URL2.php?r1=1.6&r2=1.7&diff_format=u Index: pear/Net_URL2/URL2.php diff -u pear/Net_URL2/URL2.php:1.6 pear/Net_URL2/URL2.php:1.7 --- pear/Net_URL2/URL2.php:1.6 Tue Jul 3 21:31:57 2007 +++ pear/Net_URL2/URL2.php Wed Jul 4 14:53:29 2007 @@ -32,10 +32,15 @@ // | Author: Richard Heyes <richard at php net> | // +-----------------------------------------------------------------------+ // -// $Id: URL2.php,v 1.6 2007/07/03 21:31:57 davidc Exp $ +// $Id: URL2.php,v 1.7 2007/07/04 14:53:29 davidc Exp $ // // Net_URL2 Class (PHP5 Only) +/** + * Net_URL Class definition. This class handles the manipulation of URLs. + * + * @package Net_URL + */ class Net_URL2 { /** @@ -168,34 +173,34 @@ foreach ($urlinfo as $key => $value) { switch ($key) { - case 'scheme': - $this->protocol = $value; - $this->port = $this->getStandardPort($value); - break; - - case 'user': - case 'pass': - case 'host': - case 'port': - $this->$key = $value; - break; - - case 'path': - if ($value{0} == '/') { - $this->path = $value; - } else { - $path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path); - $this->path = sprintf('%s/%s', $path, $value); - } - break; - - case 'query': - $this->querystring = $this->_parseRawQueryString($value); - break; - - case 'fragment': - $this->setAnchor($value); - break; + case 'scheme': + $this->protocol = $value; + $this->port = $this->getStandardPort($value); + break; + + case 'user': + case 'pass': + case 'host': + case 'port': + $this->$key = $value; + break; + + case 'path': + if ($value{0} == '/') { + $this->path = $value; + } else { + $path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path); + $this->path = sprintf('%s/%s', $path, $value); + } + break; + + case 'query': + $this->querystring = $this->_parseRawQueryString($value); + break; + + case 'fragment': + $this->setAnchor($value); + break; } } } @@ -258,7 +263,7 @@ * 'pear' => 'fun' * ); * - * $netUrlObject->addQueryStringArray($queryArray, false); + * $netUrlObject->addQueryStringArray($queryStrings, false); * </code> * * @param Array $queryArray The assoc array of keys and values to set in the query @@ -267,7 +272,7 @@ */ public function addQueryStringArray(Array $queryArray, $preEncodedValue = false) { - foreach ($query as $name => $value) { + foreach ($queryArray as $name => $value) { $this->addQueryString($name, $value, $preEncodedValue); } } @@ -290,6 +295,27 @@ } /** + * Removes multiple querystring items + * + * <code> + * $queryStrings = array( + * 'name', + * 'pear' + * ); + * + * $netUrlObject->removeQueryStringArray($queryStrings); + * </code> + * + * @param array $queryArray Array of names to remove + */ + public function removeQueryStringArray(Array $queryArray) + { + foreach ($queryArray as $name) { + $this->removeQueryString($name); + } + } + + /** * Sets the querystring to literally what you supply * * @param string $querystring The querystring data. Should be of the format foo=bar&x=y etc @@ -413,15 +439,15 @@ public static function getStandardPort($scheme) { switch (strtolower($scheme)) { - case 'http': return 80; - case 'https': return 443; - case 'ftp': return 21; - case 'imap': return 143; - case 'imaps': return 993; - case 'pop3': return 110; - case 'pop3s': return 995; - default: return null; - } + case 'http': return 80; + case 'https': return 443; + case 'ftp': return 21; + case 'imap': return 143; + case 'imaps': return 993; + case 'pop3': return 110; + case 'pop3s': return 995; + default: return null; + } } /**

« previous php.pear.cvs (#47853) next »