From: jamiesensei Date: Mon, 28 May 2007 14:25:40 +0000 (+0000) Subject: added another parameter to moodle_url out, out_action and get_query_string so that... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=099f7fb6ca591e05a1f5d038698a13b9a6998be4;p=moodle.git added another parameter to moodle_url out, out_action and get_query_string so that developer can output url with query string joined by '&' and not '&'. & breaks redirect on IE. --- diff --git a/lib/listlib.php b/lib/listlib.php index 75c266d2bd..87ec53b95a 100644 --- a/lib/listlib.php +++ b/lib/listlib.php @@ -275,7 +275,7 @@ class moodle_list{ $html .= " $currentpage \n"; } else { - $html .= "pageurl->out(false, array($this->pageparamname => $currentpage))."\">"; + $html .= "pageurl->out('', false, array($this->pageparamname => $currentpage))."\">"; $html .= " $currentpage \n"; } } @@ -429,7 +429,7 @@ class moodle_list{ return false; } - redirect($this->pageurl->out()); + redirect($this->pageurl->out('&')); } } @@ -541,26 +541,26 @@ class list_item{ } else { $action = $strmoveleft; } - $icons['left'] = $this->image_icon($action, $this->parentlist->pageurl->out_action(array('left'=>$this->id)), 'left'); + $icons['left'] = $this->image_icon($action, $this->parentlist->pageurl->out_action('', array('left'=>$this->id)), 'left'); } else { $icons['left'] = $this->image_spacer(); } if (!$first) { - $icons['up'] = $this->image_icon($strmoveup, $this->parentlist->pageurl->out_action(array('moveup'=>$this->id)), 'up'); + $icons['up'] = $this->image_icon($strmoveup, $this->parentlist->pageurl->out_action('', array('moveup'=>$this->id)), 'up'); } else { $icons['up'] = $this->image_spacer(); } if (!$last) { - $icons['down'] = $this->image_icon($strmovedown, $this->parentlist->pageurl->out_action(array('movedown'=>$this->id)), 'down'); + $icons['down'] = $this->image_icon($strmovedown, $this->parentlist->pageurl->out_action('', array('movedown'=>$this->id)), 'down'); } else { $icons['down'] = $this->image_spacer(); } if (!empty($lastitem)) { $makechildof = get_string('makechildof', 'question', $lastitem->name); - $icons['right'] = $this->image_icon($makechildof, $this->parentlist->pageurl->out_action(array('right'=>$this->id)), 'right'); + $icons['right'] = $this->image_icon($makechildof, $this->parentlist->pageurl->out_action('', array('right'=>$this->id)), 'right'); } else { $icons['right'] = $this->image_spacer(); } diff --git a/lib/weblib.php b/lib/weblib.php index 6993c8eef9..ad5d1c3f18 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -368,13 +368,16 @@ class moodle_url { } - function get_query_string($overrideparams = array()){ + function get_query_string($seperator='', $overrideparams = array()){ $arr = array(); + if ($seperator==''){ + $seperator = '&'; + } $params = $overrideparams + $this->params; foreach ($params as $key => $val){ $arr[] = urlencode($key)."=".urlencode($val); } - return implode($arr, "&"); + return implode($arr, $seperator); } /** * Outputs params as hidden form elements. @@ -401,14 +404,14 @@ class moodle_url { * @param array $overrideparams params to add to the output url, these override existing ones with the same name. * @return string url */ - function out($noquerystring = false, $overrideparams = array()) { + function out($seperator='', $noquerystring = false, $overrideparams = array()) { $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 (!$noquerystring){ - $uri .= (count($this->params)||count($overrideparams)) ? '?'.$this->get_query_string($overrideparams) : ''; + $uri .= (count($this->params)||count($overrideparams)) ? '?'.$this->get_query_string($seperator, $overrideparams) : ''; } $uri .= $this->fragment ? '#'.$this->fragment : ''; return $uri; @@ -419,9 +422,9 @@ class moodle_url { * @param boolean $noquerystring whether to output page params as a query string in the url. * @return string url */ - function out_action($overrideparams = array()) { + function out_action($seperator='', $overrideparams = array()) { $overrideparams = array('sesskey'=> sesskey()) + $overrideparams; - return $this->out(false, $overrideparams); + return $this->out($seperator, false, $overrideparams); } } @@ -5602,7 +5605,7 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page if (!is_a($baseurl, 'moodle_url')){ $output .= ' ('. get_string('previous') .') '; } else { - $output .= ' ('. get_string('previous') .') '; + $output .= ' ('. get_string('previous') .') '; } } $lastpage = ceil($totalcount / $perpage); @@ -5611,7 +5614,7 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page if (!is_a($baseurl, 'moodle_url')){ $output .= ' 1 ...'; } else { - $output .= ' 1 ...'; + $output .= ' 1 ...'; } } else { $startpage = 0; @@ -5626,7 +5629,7 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page if (!is_a($baseurl, 'moodle_url')){ $output .= '  '. $displaypage .''; } else { - $output .= '  '. $displaypage .''; + $output .= '  '. $displaypage .''; } } @@ -5638,7 +5641,7 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page if (!is_a($baseurl, 'moodle_url')){ $output .= ' ...'. $lastpage .' '; } else { - $output .= ' ...'. $lastpage .' '; + $output .= ' ...'. $lastpage .' '; } } $pagenum = $page + 1; @@ -5646,7 +5649,7 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page if (!is_a($baseurl, 'moodle_url')){ $output .= '  ('. get_string('next') .')'; } else { - $output .= '  ('. get_string('next') .')'; + $output .= '  ('. get_string('next') .')'; } } $output .= '';