]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20278 moodle_paging_bar - no link for the current page number
authormudrd8mz <mudrd8mz>
Mon, 14 Sep 2009 07:26:54 +0000 (07:26 +0000)
committermudrd8mz <mudrd8mz>
Mon, 14 Sep 2009 07:26:54 +0000 (07:26 +0000)
course/search.php
lib/deprecatedlib.php
lib/outputcomponents.php
lib/simpletest/testoutputlib.php

index e161eecebeb73d846f8c0a62a85330b4788333d6..738f1119dcf0250db4c50bcfa06bfb5be2c3d7d5 100644 (file)
     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
index 32b8f67f1369bf317da87de8dda2acfdbd39b7e6..cd44793efc3409c2c4cc3f8eb365de6e57e2e5eb 100644 (file)
@@ -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
+}
index 4cd7d01fabde9bbeb548cf53fcb2dd505c669119..ecab1a2746bc6fdaf230b261c98ef61478e7d469 100644 (file)
@@ -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();
index bfd05a8ced2aa516619f72b5ba8f295c7178c85b..dd0ae0feec826e0e591bb9c1f0d4294291f62047 100644 (file)
@@ -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