Permalink
Browse files

Merge branch 'MDL-26964-moodle_url-anchor_20_STABLE' of git://github.…

…com/mudrd8mz/moodle into MOODLE_20_STABLE
  • Loading branch information...
2 parents 09c1e72 + dbe6d9f commit 4cb05cea9d506cda17660ae4a8dc48aa8acac63d @skodak skodak committed Mar 29, 2011
Showing with 19 additions and 3 deletions.
  1. +11 −2 lib/outputrenderers.php
  2. +8 −1 lib/weblib.php
@@ -1124,7 +1124,11 @@ protected function render_single_button(single_button $button) {
$output = html_writer::tag('div', $output);
// now the form itself around it
- $url = $button->url->out_omit_querystring(); // url without params
+ if ($button->method === 'get') {
+ $url = $button->url->out_omit_querystring(true); // url without params, the anchor part allowed
+ } else {
+ $url = $button->url->out_omit_querystring(); // url without params, the anchor part not allowed
+ }
if ($url === '') {
$url = '#'; // there has to be always some action
}
@@ -1210,8 +1214,13 @@ protected function render_single_select(single_select $select) {
$output = html_writer::tag('div', $output);
// now the form itself around it
+ if ($select->method === 'get') {
+ $url = $select->url->out_omit_querystring(true); // url without params, the anchor part allowed
+ } else {
+ $url = $select->url->out_omit_querystring(); // url without params, the anchor part not allowed
+ }
$formattributes = array('method' => $select->method,
- 'action' => $select->url->out_omit_querystring(),
+ 'action' => $url,
'id' => $select->formid);
$output = html_writer::tag('form', $output, $formattributes);
View
@@ -541,14 +541,21 @@ public function out($escaped = true, array $overrideparams = null) {
/**
* 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;
}

0 comments on commit 4cb05ce

Please sign in to comment.