From f43cdceb752b37d7111873c56d4ed26fd14ed58d Mon Sep 17 00:00:00 2001 From: mudrd8mz Date: Mon, 14 Sep 2009 07:26:54 +0000 Subject: [PATCH] MDL-20278 moodle_paging_bar - no link for the current page number --- course/search.php | 1 - lib/deprecatedlib.php | 9 ++++++--- lib/outputcomponents.php | 6 +----- lib/simpletest/testoutputlib.php | 16 ++++------------ 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/course/search.php b/course/search.php index e161eecebe..738f1119dc 100644 --- a/course/search.php +++ b/course/search.php @@ -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 diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 32b8f67f13..cd44793efc 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -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 ''; -} \ No newline at end of file +} diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 4cd7d01fab..ecab1a2746 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -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(); diff --git a/lib/simpletest/testoutputlib.php b/lib/simpletest/testoutputlib.php index bfd05a8ced..dd0ae0feec 100644 --- a/lib/simpletest/testoutputlib.php +++ b/lib/simpletest/testoutputlib.php @@ -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 -- 2.39.5