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
* @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
*/
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) {
// moodle 2.0
return '';
-}
\ No newline at end of file
+}
* @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
*/
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();
$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