mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
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
This commit is contained in:
parent
5501446df5
commit
fcdb06c470
@ -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<input type=\"hidden\" name=\"$key\" value=\"$val\" />\n";
|
||||
if (FALSE === array_search($key, $exclude)) {
|
||||
$str.= "$tabindent<input type=\"hidden\" name=\"$key\" value=\"$val\" />\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 .= ' (<a href="'. $baseurl . $pagevar .'='. $pagenum .'">'. get_string('previous') .'</a>) ';
|
||||
if (!is_a($baseurl, 'moodle_url')){
|
||||
$output .= ' (<a href="'. $baseurl . $pagevar .'='. $pagenum .'">'. get_string('previous') .'</a>) ';
|
||||
} else {
|
||||
$output .= ' (<a href="'. $baseurl->out(false, array($pagevar => $pagenum)).'">'. get_string('previous') .'</a>) ';
|
||||
}
|
||||
}
|
||||
$lastpage = ceil($totalcount / $perpage);
|
||||
if ($page > 15) {
|
||||
$startpage = $page - 10;
|
||||
$output .= ' <a href="'. $baseurl . $pagevar .'=0">1</a> ...';
|
||||
if (!is_a($baseurl, 'moodle_url')){
|
||||
$output .= ' <a href="'. $baseurl . $pagevar .'=0">1</a> ...';
|
||||
} else {
|
||||
$output .= ' <a href="'. $baseurl->out(false, array($pagevar => 0)).'">1</a> ...';
|
||||
}
|
||||
} 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 .= ' <a href="'. $baseurl . $pagevar .'='. $currpage .'">'. $displaypage .'</a>';
|
||||
if (!is_a($baseurl, 'moodle_url')){
|
||||
$output .= ' <a href="'. $baseurl . $pagevar .'='. $currpage .'">'. $displaypage .'</a>';
|
||||
} else {
|
||||
$output .= ' <a href="'. $baseurl->out(false, array($pagevar => $currpage)).'">'. $displaypage .'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
$displaycount++;
|
||||
$currpage++;
|
||||
}
|
||||
if ($currpage < $lastpage) {
|
||||
$lastpageactual = $lastpage - 1;
|
||||
$output .= ' ...<a href="'. $baseurl . $pagevar .'='. $lastpageactual .'">'. $lastpage .'</a> ';
|
||||
if (!is_a($baseurl, 'moodle_url')){
|
||||
$output .= ' ...<a href="'. $baseurl . $pagevar .'='. $lastpageactual .'">'. $lastpage .'</a> ';
|
||||
} else {
|
||||
$output .= ' ...<a href="'. $baseurl->out(false, array($pagevar => $lastpageactual)).'">'. $lastpage .'</a> ';
|
||||
}
|
||||
}
|
||||
$pagenum = $page + 1;
|
||||
if ($pagenum != $displaypage) {
|
||||
$output .= ' (<a href="'. $baseurl . $pagevar .'='. $pagenum .'">'. get_string('next') .'</a>)';
|
||||
if (!is_a($baseurl, 'moodle_url')){
|
||||
$output .= ' (<a href="'. $baseurl . $pagevar .'='. $pagenum .'">'. get_string('next') .'</a>)';
|
||||
} else {
|
||||
$output .= ' (<a href="'. $baseurl->out(false, array($pagevar => $pagenum)) .'">'. get_string('next') .'</a>)';
|
||||
}
|
||||
}
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user