}
/**
* 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;
}
* @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
$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;
}
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>';
}