From 5c6ee6ec362e31822b52fecfcaa98d0be84d318f Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Thu, 24 Mar 2011 13:30:46 +0100 Subject: [PATCH] MDL-26964 URL returned by moodle_url::out_omit_querystring() may contain the anchor part --- lib/weblib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/weblib.php b/lib/weblib.php index 6141c1124d7..cb65a20d9de 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -541,14 +541,21 @@ class moodle_url { /** * Returns url without parameters, everything before '?'. + * + * @param bool $includeanchor if {@link self::anchor} is defined, should it be returned? * @return string */ - public function out_omit_querystring() { + public function out_omit_querystring($includeanchor = false) { + $uri = $this->scheme ? $this->scheme.':'.((strtolower($this->scheme) == 'mailto') ? '':'//'): ''; $uri .= $this->user ? $this->user.($this->pass? ':'.$this->pass:'').'@':''; $uri .= $this->host ? $this->host : ''; $uri .= $this->port ? ':'.$this->port : ''; $uri .= $this->path ? $this->path : ''; + if ($includeanchor and !is_null($this->anchor)) { + $uri .= '#' . $this->anchor; + } + return $uri; }