}
/**
+ * Returns a clone of this object. Useful for chaining.
+ *
+ * @return Horde_Url A clone of this object.
+ */
+ public function copy()
+ {
+ $url = clone $this;
+ return $url;
+ }
+
+ /**
* Adds one or more query parameters.
*
* @param mixed $parameters Either the name value or an array of
}
/**
- * Identical to add(), except the return value is a cloned object.
- *
- * @param mixed $parameters Either the name value or an array of
- * name/value pairs.
- * @param string $value If specified, the value part ($parameters is
- * then assumed to just be the parameter name).
- *
- * @return Horde_Url Cloned object, to allow chaining.
- */
- public function cAdd($parameters, $value = null)
- {
- $url = clone $this;
- return $url->add($parameters, $value);
- }
-
- /**
* Removes one ore more parameters.
*
* @param mixed $remove Either a single parameter to remove or an array
}
/**
- * Identical to remove(), except the return value is a cloned object.
- *
- * @param mixed $remove Either a single parameter to remove or an array
- * of parameters to remove.
- *
- * @return Horde_Url Cloned object, to allow chaining.
- */
- public function cRemove($parameters)
- {
- $url = clone $this;
- return $url->remove($parameters);
- }
-
- /**
* Sets the $raw value. This call can be chained.
*
* @param boolean $raw Whether to output the URL in the raw URL format or
}
if ($url instanceof Horde_Url) {
- return $url->cAdd($parameter, $value)->setRaw(!$encode);
+ $url = $url->copy()->add($parameter, $value);
+ if (is_null($url->raw)) {
+ $url->setRaw(!$encode);
+ }
+ return $url;
}
- $horde_url = new Horde_Url($url, !$encode);
- return $horde_url->add($parameter, $value);
+ $url = new Horde_Url($url);
+ if (is_null($url->raw) && count($url->parameters)) {
+ $url->setRaw(!$encode);
+ }
+ return $url->add($parameter, $value);
}
/**
static public function removeParameter($url, $remove)
{
if ($url instanceof Horde_Url) {
- return $url->cRemove($remove);
+ return $url->copy()->remove($remove);
}
$horde_url = new Horde_Url($url);