MDL-20278 moodle_paging_bar - no link for the current page number
This commit is contained in:
@@ -377,7 +377,6 @@
|
||||
function print_navigation_bar($totalcount,$page,$perpage,$encodedsearch,$modulelink) {
|
||||
global $OUTPUT;
|
||||
$pagingbar = moodle_paging_bar::make($totalcount, $page, $perpage, "search.php?search=$encodedsearch".$modulelink."&perpage=$perpage");
|
||||
$pagingbar->nocurr = ($perpage == 99999);
|
||||
echo $OUTPUT->paging_bar($pagingbar);
|
||||
|
||||
//display
|
||||
|
||||
@@ -2971,7 +2971,7 @@ function doc_link($path='', $text='', $iconpath='') {
|
||||
* @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 $nocurr do not display the current page as a link (dropped, link is never displayed for the current page)
|
||||
* @param bool $return whether to return an output string or echo now
|
||||
* @return bool|string depending on $result
|
||||
*/
|
||||
@@ -2980,9 +2980,12 @@ function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page
|
||||
|
||||
debugging('print_paging_bar() has been deprecated. Please change your code to use $OUTPUT->paging_bar($pagingbar).');
|
||||
|
||||
if (empty($nocurr)) {
|
||||
debugging('the feature of parameter $nocurr has been removed from the moodle_paging_bar');
|
||||
}
|
||||
|
||||
$pagingbar = moodle_paging_bar::make($totalcount, $page, $perpage, $baseurl);
|
||||
$pagingbar->pagevar = $pagevar;
|
||||
$pagingbar->nocurr = $nocurr;
|
||||
$output = $OUTPUT->paging_bar($pagingbar);
|
||||
|
||||
if ($return) {
|
||||
@@ -3724,4 +3727,4 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
|
||||
// moodle 2.0
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1660,10 +1660,6 @@ class moodle_paging_bar extends moodle_html_component {
|
||||
* @var string $pagevar This is the variable name that you use for the page number in your code (ie. 'tablepage', 'blogpage', etc)
|
||||
*/
|
||||
public $pagevar = 'page';
|
||||
/**
|
||||
* @var bool $nocurr do not display the current page as a link
|
||||
*/
|
||||
public $nocurr;
|
||||
/**
|
||||
* @var html_link $previouslink A HTML link representing the "previous" page
|
||||
*/
|
||||
@@ -1741,7 +1737,7 @@ class moodle_paging_bar extends moodle_html_component {
|
||||
while ($displaycount < $this->maxdisplay and $currpage < $lastpage) {
|
||||
$displaypage = $currpage + 1;
|
||||
|
||||
if ($this->page == $currpage && empty($this->nocurr)) {
|
||||
if ($this->page == $currpage) {
|
||||
$this->pagelinks[] = $displaypage;
|
||||
} else {
|
||||
$pagelink = new html_link();
|
||||
|
||||
@@ -1163,26 +1163,18 @@ class moodle_core_renderer_test extends UnitTestCase {
|
||||
$pagingbar->perpage = $perpage;
|
||||
$pagingbar->baseurl = $baseurl;
|
||||
$pagingbar->pagevar = $pagevar;
|
||||
$pagingbar->nocurr = true;
|
||||
|
||||
$originalbar = clone($pagingbar);
|
||||
|
||||
$html = $OUTPUT->paging_bar($pagingbar);
|
||||
|
||||
$this->assert(new ContainsTagWithAttribute('div', 'class', 'paging'), $html);
|
||||
// the 'Previous' link
|
||||
$this->assert(new ContainsTagWithAttributes('a', array('class' => 'previous', 'href' => $baseurl->out().'?mypage=0')), $html);
|
||||
// One of the links to the previous page must not have the 'previous' class
|
||||
// the numeric link to the previous page '1' (does not have the 'previous' class)
|
||||
$this->assert(new ContainsTagWithAttributes('a', array('href' => $baseurl->out().'?mypage=0'), array('class' => 'previous')), $html);
|
||||
// The link to the current page must not have the 'next' class: it's the last page
|
||||
$this->assert(new ContainsTagWithAttributes('a', array('href' => $baseurl->out().'?mypage=1'), array('class' => 'next')), $html);
|
||||
|
||||
$pagingbar = clone($originalbar); // clone the original bar before each output and set of assertions
|
||||
$pagingbar->nocurr = false;
|
||||
$html = $OUTPUT->paging_bar($pagingbar);
|
||||
$this->assert(new ContainsTagWithAttribute('div', 'class', 'paging'), $html);
|
||||
$this->assert(new ContainsTagWithAttributes('a', array('href' => $baseurl->out().'?mypage=0'), array('class' => 'previous')), $html);
|
||||
$this->assert(new ContainsTagWithAttributes('a', array('class' => 'previous', 'href' => $baseurl->out().'?mypage=0')), $html);
|
||||
$expectation = new ContainsTagWithAttributes('a', array('href' => $baseurl->out().'?mypage=1'), array('class' => 'next'));
|
||||
// no link to the current page, it's the last page
|
||||
$expectation = new ContainsTagWithAttributes('a', array('href' => $baseurl->out().'?mypage=1'), array());
|
||||
$this->assertFalse($expectation->test($html));
|
||||
|
||||
// TODO test with more different parameters
|
||||
|
||||
Reference in New Issue
Block a user