From fcdb06c470a2b7023b0db1b46244d631e783be6c Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Thu, 3 May 2007 10:03:59 +0000 Subject: [PATCH] change to print_paging_bar function to optionally support the use of a moodle_url object as a parameter instead of a string. small changes to moodle_url class --- lib/weblib.php | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index f135d062e0a..4e6d3c69858 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -372,14 +372,17 @@ class moodle_url { } /** * Outputs params as hidden form elements. - * + * + * @param * @return string html for form elements. */ - function hidden_params_out($indent = 0){ + function hidden_params_out($exclude = array(), $indent = 0){ $tabindent = str_repeat("\t", $indent); $str = ''; foreach ($this->params as $key => $val){ - $str.= "$tabindent\n"; + if (FALSE === array_search($key, $exclude)) { + $str.= "$tabindent\n"; + } } return $str; } @@ -5462,8 +5465,8 @@ function obfuscate_mailto($email, $label='', $dimmed=false) { * @param int $totalcount Thetotal number of entries available to be paged through * @param int $page The page you are currently viewing * @param int $perpage The number of entries that should be shown per page - * @param string $baseurl The url which will be used to create page numbered links. Each page will consist of the base url appended by the page -var an equal sign, then the page number. + * @param mixed $baseurl If this is a string then it is the url which will be appended with $pagevar, an equals sign and the page number. + * If this is a moodle_url object then the pagevar param will be replaced by the page no, for each page. * @param string $pagevar This is the variable name that you use for the page number in your code (ie. 'tablepage', 'blogpage', etc) * @param bool $nocurr do not display the current page as a link * @param bool $return whether to return an output string or echo now @@ -5478,12 +5481,20 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page $output .= get_string('page') .':'; if ($page > 0) { $pagenum = $page - 1; - $output .= ' ('. get_string('previous') .') '; + if (!is_a($baseurl, 'moodle_url')){ + $output .= ' ('. get_string('previous') .') '; + } else { + $output .= ' ('. get_string('previous') .') '; + } } $lastpage = ceil($totalcount / $perpage); if ($page > 15) { $startpage = $page - 10; - $output .= ' 1 ...'; + if (!is_a($baseurl, 'moodle_url')){ + $output .= ' 1 ...'; + } else { + $output .= ' 1 ...'; + } } else { $startpage = 0; } @@ -5494,18 +5505,31 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page if ($page == $currpage && empty($nocurr)) { $output .= '  '. $displaypage; } else { - $output .= '  '. $displaypage .''; + if (!is_a($baseurl, 'moodle_url')){ + $output .= '  '. $displaypage .''; + } else { + $output .= '  '. $displaypage .''; + } + } $displaycount++; $currpage++; } if ($currpage < $lastpage) { $lastpageactual = $lastpage - 1; - $output .= ' ...'. $lastpage .' '; + if (!is_a($baseurl, 'moodle_url')){ + $output .= ' ...'. $lastpage .' '; + } else { + $output .= ' ...'. $lastpage .' '; + } } $pagenum = $page + 1; if ($pagenum != $displaypage) { - $output .= '  ('. get_string('next') .')'; + if (!is_a($baseurl, 'moodle_url')){ + $output .= '  ('. get_string('next') .')'; + } else { + $output .= '  ('. get_string('next') .')'; + } } $output .= ''; }