From: Jan Schneider Date: Tue, 8 Dec 2009 00:40:56 +0000 (+0100) Subject: Add explicit toString() method that accepts a $raw parameter to override, but X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=536d790bfe82153b9075661a2e53d45b21bd8b8b;p=horde.git Add explicit toString() method that accepts a $raw parameter to override, but not overwrite the local $raw property. Michael, can we remove setRaw() with this new feature? --- diff --git a/framework/Url/lib/Horde/Url.php b/framework/Url/lib/Horde/Url.php index be1fabe7c..7b3e3b01e 100644 --- a/framework/Url/lib/Horde/Url.php +++ b/framework/Url/lib/Horde/Url.php @@ -186,7 +186,8 @@ class Horde_Url /** * Sets the $raw value. This call can be chained. * - * @param boolean The value to set for $raw. + * @param boolean $raw Whether to output the URL in the raw URL format or + * HTML-encoded. * * @return Horde_Url This object, to allow chaining. */ @@ -199,9 +200,12 @@ class Horde_Url /** * Creates the full URL string. * + * @param boolean $raw Whether to output the URL in the raw URL format or + * HTML-encoded. + * * @return string The string representation of this object. */ - public function __toString() + public function toString($raw = false) { $url_params = array(); foreach ($this->parameters as $parameter => $value) { @@ -223,13 +227,23 @@ class Horde_Url $url .= '/' . $this->pathInfo; } if (count($url_params)) { - $url .= '?' . implode($this->raw ? '&' : '&', $url_params); + $url .= '?' . implode($raw ? '&' : '&', $url_params); } return $url; } /** + * Creates the full URL string. + * + * @return string The string representation of this object. + */ + public function __toString() + { + return $this->toString($this->raw); + } + + /** * Generates a HTML link tag out of this URL. * * @param array $attributes A hash with any additional attributes to be