MDL-20204 converted paging_bar to new coding style + fixed regressions from recent...
authorPetr Skoda <skodak@moodle.org>
Wed, 17 Feb 2010 16:59:41 +0000 (16:59 +0000)
committerPetr Skoda <skodak@moodle.org>
Wed, 17 Feb 2010 16:59:41 +0000 (16:59 +0000)
28 files changed:
admin/mnet/access_control.php
admin/report/configlog/index.php
admin/user.php
blog/locallib.php
comment/lib.php
course/category.php
course/lib.php
course/search.php
grade/report/grader/index.php
grade/report/grader/quickedit_item.php
lib/commentlib.php
lib/deprecatedlib.php
lib/outputcomponents.php
lib/outputrenderers.php
lib/simpletest/testoutputlib.php
lib/tablelib.php
mod/data/view.php
mod/forum/lib.php
mod/forum/search.php
mod/forum/user.php
mod/workshop/allocation/manual/lib.php
mod/workshop/view.php
question/editlib.php
repository/filepicker.php
tag/index.php
tag/locallib.php
user/index.php
user/portfoliologs.php

index c963d65..3680365 100644 (file)
@@ -187,8 +187,7 @@ if (!empty($table)) {
     echo $OUTPUT->table($table);
     echo '<p>&nbsp;</p>';
     $baseurl = new moodle_url('/admin/mnet/access_control.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
-    $pagingbar = moodle_paging_bar::make($aclcount, $page, $perpage, $baseurl);
-    echo $OUTPUT->paging_bar($pagingbar);
+    echo $OUTPUT->paging_bar($aclcount, $page, $perpage, $baseurl);
 }
 
 
index 2d2f9ad..adf4874 100644 (file)
@@ -53,7 +53,7 @@ foreach ($columns as $column=>$strcolumn) {
 }
 
 $baseurl = new moodle_url('index.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
-echo $OUTPUT->paging_bar(moodle_paging_bar::make($changescount, $page, $perpage, $baseurl));
+echo $OUTPUT->paging_bar($changescount, $page, $perpage, $baseurl);
 
 $override = new object();
 $override->firstname = 'firstname';
index ad8a4ab..b72ae4c 100644 (file)
     $strall = get_string('all');
 
     $baseurl = new moodle_url('user.php', array('sort' => $sort, 'dir' => $dir, 'perpage' => $perpage));
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($usercount, $page, $perpage, $baseurl));
+    echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl);
 
     flush();
 
     }
     if (!empty($table)) {
         echo $OUTPUT->table($table);
-        echo $OUTPUT->paging_bar(moodle_paging_bar::make($usercount, $page, $perpage, $baseurl));
+        echo $OUTPUT->paging_bar($usercount, $page, $perpage, $baseurl);
         if (has_capability('moodle/user:create', $sitecontext)) {
             echo $OUTPUT->heading('<a href="'.$securewwwroot.'/user/editadvanced.php?id=-1">'.get_string('addnewuser').'</a>');
         }
index ec30c87..0150d9d 100644 (file)
@@ -804,11 +804,11 @@ class blog_listing {
         }
 
         $entries = $this->get_entries($start, $limit);
-        $pagingbar = moodle_paging_bar::make($totalentries, $page, $limit, $this->get_baseurl());
+        $pagingbar = new paging_bar($totalentries, $page, $limit, $this->get_baseurl());
         $pagingbar->pagevar = 'blogpage';
         $blogheaders = blog_get_headers();
 
-        echo $OUTPUT->paging_bar($pagingbar);
+        echo $OUTPUT->render($pagingbar);
 
         /* TODO RSS link
         if ($CFG->enablerssfeeds) {
@@ -854,7 +854,7 @@ class blog_listing {
                 $count++;
             }
 
-            echo $OUTPUT->paging_bar($pagingbar);
+            echo $OUTPUT->render($pagingbar);
 
             if (!$count) {
                 print '<br /><div style="text-align:center">'. get_string('noentriesyet', 'blog') .'</div><br />';
index 996b1e5..85e7160 100644 (file)
@@ -102,7 +102,7 @@ class comment_manager {
             $table->data[] = array($checkbox, $c->username, $c->content, $action);
         }
         echo $OUTPUT->table($table);
-        echo $OUTPUT->paging_bar(moodle_paging_bar::make($count, $page, $this->perpage, $CFG->wwwroot.'/comment/index.php'));
+        echo $OUTPUT->paging_bar($count, $page, $this->perpage, $CFG->wwwroot.'/comment/index.php');
     }
 
     /**
index 0eb31ff..ce57022 100644 (file)
         echo $OUTPUT->box_end();
 
     } else {
-        echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "category.php?id=$category->id&perpage=$perpage"));
+        echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "/mod/course/category.php?id=$category->id&perpage=$perpage");
 
         $strcourses = get_string('courses');
         $strselect = get_string('select');
index e88af86..07a98cf 100644 (file)
@@ -343,7 +343,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
     print_string("displayingrecords", "", $totalcount);
     echo "</div>\n";
 
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "$url&perpage=$perpage"));
+    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
 
     $table = new html_table();
     $table->classes = array('logtable','generalbox','boxaligncenter');
@@ -420,7 +420,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
     }
 
     echo $OUTPUT->table($table);
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "$url&perpage=$perpage"));
+    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
 }
 
 
@@ -457,7 +457,7 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
     print_string("displayingrecords", "", $totalcount);
     echo "</div>\n";
 
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "$url&perpage=$perpage"));
+    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
 
     echo "<table class=\"logtable\" cellpadding=\"3\" cellspacing=\"0\">\n";
     echo "<tr>";
@@ -524,7 +524,7 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
     }
     echo "</table>\n";
 
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, "$url&perpage=$perpage"));
+    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
 }
 
 
index e64f806..453d3bb 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");
-        echo $OUTPUT->paging_bar($pagingbar);
+        echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "search.php?search=$encodedsearch".$modulelink."&perpage=$perpage");
 
         //display
         if ($perpage != 99999 && $totalcount > $perpage) {
index 336afde..1a3e8ce 100644 (file)
@@ -155,7 +155,7 @@ foreach($warnings as $warning) {
 $studentsperpage = $report->get_pref('studentsperpage');
 // Don't use paging if studentsperpage is empty or 0 at course AND site levels
 if (!empty($studentsperpage)) {
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($numusers, $report->page, $studentsperpage, $report->pbarurl));
+    echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
 }
 
 $reporthtml = $report->get_grade_table();
@@ -176,6 +176,6 @@ if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback')
 
 // prints paging bar at bottom for large pages
 if (!empty($studentsperpage) && $studentsperpage >= 20) {
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($numusers, $report->page, $studentsperpage, $report->pbarurl));
+    echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
 }
 echo $OUTPUT->footer();
index cb8aecb..7a9ce65 100644 (file)
@@ -97,7 +97,7 @@ foreach($warnings as $warning) {
 $studentsperpage = $report->get_pref('studentsperpage');
 // Don't use paging if studentsperpage is empty or 0 at course AND site levels
 if (!empty($studentsperpage)) {
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($numusers, $report->page, $studentsperpage, $report->pbarurl));
+    echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
 }
 
 /// TODO Print links to previous - next grade items in this course
@@ -110,7 +110,7 @@ echo '</div></form>';
 
 // prints paging bar at bottom for large pages
 if (!empty($studentsperpage) && $studentsperpage >= 20) {
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($numusers, $report->page, $studentsperpage, $report->pbarurl));
+    echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
 }
 
 echo $OUTPUT->footer();
index 1ea79aa..4c921aa 100644 (file)
@@ -414,7 +414,7 @@ EOD;
         }
         if (!empty(self::$nonjs)) {
             // used in non-js interface
-            return $OUTPUT->paging_bar(moodle_paging_bar::make($count, $page, $CFG->commentsperpage, $this->link));
+            return $OUTPUT->paging_bar($count, $page, $CFG->commentsperpage, $this->link);
         } else {
             // return ajax paging bar
             $str = '';
index 5722feb..8bdacea 100644 (file)
@@ -2971,15 +2971,15 @@ function doc_link($path='', $text='', $iconpath='ignored') {
 function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page',$nocurr=false, $return=false) {
     global $OUTPUT;
 
-    debugging('print_paging_bar() has been deprecated. Please change your code to use $OUTPUT->paging_bar($pagingbar).');
+    debugging('print_paging_bar() has been deprecated. Please change your code to use $OUTPUT->render($pagingbar).');
 
     if (empty($nocurr)) {
-        debugging('the feature of parameter $nocurr has been removed from the moodle_paging_bar');
+        debugging('the feature of parameter $nocurr has been removed from the paging_bar');
     }
 
-    $pagingbar = moodle_paging_bar::make($totalcount, $page, $perpage, $baseurl);
+    $pagingbar = new paging_bar($totalcount, $page, $perpage, $baseurl);
     $pagingbar->pagevar = $pagevar;
-    $output = $OUTPUT->paging_bar($pagingbar);
+    $output = $OUTPUT->render($pagingbar);
 
     if ($return) {
         return $output;
index ddb5372..c388f80 100644 (file)
@@ -1714,7 +1714,7 @@ class html_span extends html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class moodle_paging_bar extends html_component {
+class paging_bar implements renderable {
     /**
      * @var int $maxdisplay The maximum number of pagelinks to display
      */
@@ -1726,7 +1726,7 @@ class moodle_paging_bar extends html_component {
     /**
      * @var int $page The page you are currently viewing
      */
-    public $page = 0;
+    public $page;
     /**
      * @var int $perpage The number of entries that should be shown per page
      */
@@ -1739,7 +1739,7 @@ class moodle_paging_bar extends 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';
+    public $pagevar;
     /**
      * @var string $previouslink A HTML link representing the "previous" page
      */
@@ -1761,32 +1761,46 @@ class moodle_paging_bar extends html_component {
      */
     public $pagelinks = array();
 
+    /**
+     * Constructor paging_bar with only the required params.
+     *
+     * @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|moodle_url $baseurl url of the current page, the $pagevar parameter is added
+     * @param string $pagevar name of page parameter that holds the page number
+     */
+    public function __construct($totalcount, $page, $perpage, $baseurl, $pagevar = 'page') {
+        $this->totalcount = $totalcount;
+        $this->page       = $page;
+        $this->perpage    = $perpage;
+        $this->baseurl    = $baseurl;
+        $this->pagevar    = $pagevar;
+    }
+
     /**
      * @see lib/html_component#prepare()
      * @return void
      */
     public function prepare(renderer_base $output, moodle_page $page, $target) {
         if (!isset($this->totalcount) || is_null($this->totalcount)) {
-            throw new coding_exception('moodle_paging_bar requires a totalcount value.');
+            throw new coding_exception('paging_bar requires a totalcount value.');
         }
         if (!isset($this->page) || is_null($this->page)) {
-            throw new coding_exception('moodle_paging_bar requires a page value.');
+            throw new coding_exception('paging_bar requires a page value.');
         }
         if (empty($this->perpage)) {
-            throw new coding_exception('moodle_paging_bar requires a perpage value.');
+            throw new coding_exception('paging_bar requires a perpage value.');
         }
         if (empty($this->baseurl)) {
-            throw new coding_exception('moodle_paging_bar requires a baseurl value.');
-        }
-        if (!($this->baseurl instanceof moodle_url)) {
-            $this->baseurl = new moodle_url($this->baseurl);
+            throw new coding_exception('paging_bar requires a baseurl value.');
         }
 
         if ($this->totalcount > $this->perpage) {
             $pagenum = $this->page - 1;
 
             if ($this->page > 0) {
-                $this->previouslink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar=>$pagenum)), array('class'=>'previous'), get_string('previous'));
+                $this->previouslink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar=>$pagenum)), get_string('previous'), array('class'=>'previous'));
             }
 
             if ($this->perpage > 0) {
@@ -1798,7 +1812,7 @@ class moodle_paging_bar extends html_component {
             if ($this->page > 15) {
                 $startpage = $this->page - 10;
 
-                $this->firstlink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar=>0)), array('class'=>'first'), '1');
+                $this->firstlink = html_writer::link(new moodle_url($this->baseurl, array($this->pagevar=>0)), '1', array('class'=>'first'));
             } else {
                 $startpage = 0;
             }
@@ -1832,24 +1846,6 @@ class moodle_paging_bar extends html_component {
             }
         }
     }
-
-    /**
-     * Shortcut for initialising a moodle_paging_bar with only the required params.
-     *
-     * @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 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.
-     */
-    public static function make($totalcount, $page, $perpage, $baseurl) {
-        $pagingbar = new moodle_paging_bar();
-        $pagingbar->totalcount = $totalcount;
-        $pagingbar->page = $page;
-        $pagingbar->perpage = $perpage;
-        $pagingbar->baseurl = $baseurl;
-        return $pagingbar;
-    }
 }
 
 
index 77bbef0..558f9b4 100644 (file)
@@ -1743,10 +1743,24 @@ class core_renderer extends renderer_base {
     /**
      * Prints a single paging bar to provide access to other pages  (usually in a search)
      *
-     * @param string|moodle_url $link The url the button goes to.
+     * @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|moodle_url $baseurl url of the current page, the $pagevar parameter is added
+     * @param string $pagevar name of page parameter that holds the page number
      * @return string the HTML to output.
      */
-    public function paging_bar($pagingbar) {
+    public function paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar = 'page') {
+        $pb = new paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar);
+        return $this->render($pb);
+    }
+
+    /**
+     * Internal implementation of paging bar rendering.
+     * @param paging_bar $pagingbar
+     * @return string
+     */
+    protected function render_paging_bar(paging_bar $pagingbar) {
         $output = '';
         $pagingbar = clone($pagingbar);
         $pagingbar->prepare($this, $this->page, $this->target);
index a4c8b37..e1efcd5 100644 (file)
@@ -567,38 +567,6 @@ class core_renderer_test extends UnitTestCase {
         $this->assertEqual('', $html);
     }
 
-    public function test_paging_bar() {
-        global $CFG;
-
-        $totalcount = 5;
-        $perpage = 4;
-        $page = 1;
-        $baseurl = new moodle_url('/index.php');
-        $pagevar = 'mypage';
-
-        $pagingbar = new moodle_paging_bar();
-        $pagingbar->totalcount = $totalcount;
-        $pagingbar->page = $page;
-        $pagingbar->perpage = $perpage;
-        $pagingbar->baseurl = $baseurl;
-        $pagingbar->pagevar = $pagevar;
-
-        $originalbar = clone($pagingbar);
-
-        $html = $this->renderer->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);
-        // 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);
-        // 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
-    }
-
     public function test_html_list() {
         $htmllist = new html_list();
         $data = array('item1', 'item2', array('item1-1', 'item1-2'));
index d467d52..adea9df 100644 (file)
@@ -1003,9 +1003,9 @@ class flexible_table {
                 echo $this->download_buttons();
             }
             if($this->use_pages) {
-                $pagingbar = moodle_paging_bar::make($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl);
+                $pagingbar = new paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl);
                 $pagingbar->pagevar = $this->request[TABLE_VAR_PAGE];
-                echo $OUTPUT->paging_bar($pagingbar);
+                echo $OUTPUT->render($pagingbar);
             }
         }
     }
@@ -1140,9 +1140,9 @@ class flexible_table {
 
         // Paging bar
         if($this->use_pages) {
-            $pagingbar = moodle_paging_bar::make($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl);
+            $pagingbar = new paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl);
             $pagingbar->pagevar = $this->request[TABLE_VAR_PAGE];
-            echo $OUTPUT->paging_bar($pagingbar);
+            echo $OUTPUT->render($pagingbar);
         }
 
         if(in_array(TABLE_P_TOP, $this->showdownloadbuttonsat)) {
index 5805615..e16935f 100755 (executable)
                 if (!empty($search)) {
                     $baseurl .= 'filter=1&amp;';
                 }
-                echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl));
+                echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
 
                 if (empty($data->singletemplate)){
                     echo $OUTPUT->notification(get_string('nosingletemplate','data'));
 
                 data_print_template('singletemplate', $records, $data, $search, $page);
 
-                echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl));
+                echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
 
             } else {                                  // List template
                 $baseurl = 'view.php?d='.$data->id.'&amp;';
                 //pass variable to allow determining whether or not we are paging through results.
                 $baseurl .= 'paging='.$paging.'&amp;';
 
-                echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl));
+                echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
 
                 if (empty($data->listtemplate)){
                     echo $OUTPUT->notification(get_string('nolisttemplate','data'));
                 data_print_template('listtemplate', $records, $data, $search, $page);
                 echo $data->listtemplatefooter;
 
-                echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl));
+                echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
             }
 
         }
index 6fa7efe..10d2145 100644 (file)
@@ -5592,7 +5592,7 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=-1, $di
         $numdiscussions = forum_get_discussions_count($cm);
 
         ///Show the paging bar
-        echo $OUTPUT->paging_bar(moodle_paging_bar::make($numdiscussions, $page, $perpage, "view.php?f=$forum->id"));
+        echo $OUTPUT->paging_bar($numdiscussions, $page, $perpage, "view.php?f=$forum->id");
         if ($numdiscussions > 1000) {
             // saves some memory on sites with very large forums
             $replies = forum_count_discussion_replies($forum->id, $sort, $maxdiscussions, $page, $perpage);
@@ -5732,7 +5732,7 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=-1, $di
     }
 
     if ($page != -1) { ///Show the paging bar
-        echo $OUTPUT->paging_bar(moodle_paging_bar::make($numdiscussions, $page, $perpage, "view.php?f=$forum->id"));
+        echo $OUTPUT->paging_bar($numdiscussions, $page, $perpage, "view.php?f=$forum->id");
     }
 }
 
index 7d4871e..6e1e8e6 100644 (file)
@@ -179,7 +179,7 @@ echo '</div>';
 echo $OUTPUT->heading("$strsearchresults: $totalcount");
 
 $url = new moodle_url('search.php', array('search' => urlencode($search), 'id' => $course->id, 'perpage' => $perpage));
-echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, $url));
+echo $OUTPUT->paging_bar($totalcount, $page, $perpage, $url);
 
 //added to implement highlighting of search terms found only in HTML markup
 //fiedorow - 9/2/2005
@@ -255,7 +255,7 @@ foreach ($posts as $post) {
             $fulllink, $strippedsearch, -99, false);
 }
 
-echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, $url));
+echo $OUTPUT->paging_bar($totalcount, $page, $perpage, $url);
 
 echo $OUTPUT->footer();
 
index c37e397..a6b1d08 100644 (file)
@@ -131,7 +131,7 @@ if ($posts = forum_search_posts($searchterms, $searchcourse, $page*$perpage, $pe
             $totalcount, $extrasql)) {
 
     $baseurl = new moodle_url('user.php', array('id' => $user->id, 'course' => $course->id, 'mode' => $mode, 'perpage' => $perpage));
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, $baseurl));
+    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, $baseurl);
 
     $discussions = array();
     $forums      = array();
@@ -198,7 +198,7 @@ if ($posts = forum_search_posts($searchterms, $searchcourse, $page*$perpage, $pe
         echo "<br />";
     }
 
-    echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $perpage, $baseurl));
+    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, $baseurl);
 } else {
     if ($mode == 'posts') {
         echo $OUTPUT->heading(get_string('noposts', 'forum'));
index 936faac..97bacb6 100644 (file)
@@ -308,14 +308,9 @@ class workshop_manual_allocator implements workshop_allocator {
         $data->selfassessment   = $this->workshop->useselfassessment;
 
         // prepare paging bar
-        $pagingbar              = new moodle_paging_bar();
-        $pagingbar->totalcount  = $numofparticipants;
-        $pagingbar->page        = $page;
-        $pagingbar->perpage     = $perpage;
-        $pagingbar->baseurl     = $PAGE->url;
-        $pagingbar->pagevar     = $pagingvar;
-
-        $pagingbarout = $OUTPUT->paging_bar($pagingbar);
+        $pagingbar              = new paging_bar($numofparticipants, $page, $perpage, $PAGE->url, $pagingvar);
+
+        $pagingbarout = $OUTPUT->render($pagingbar);
 
         // we have all data, let us pass it to the renderers and return the output
         $wsoutput = $PAGE->get_renderer('mod_workshop');
index 3cfb99b..7397d59 100644 (file)
@@ -185,12 +185,7 @@ case workshop::PHASE_ASSESSMENT:
             $showreviewernames  = has_capability('mod/workshop:viewreviewernames', $workshop->context);
 
             // prepare paging bar
-            $pagingbar              = new moodle_paging_bar();
-            $pagingbar->totalcount  = $data->totalcount;
-            $pagingbar->page        = $page;
-            $pagingbar->perpage     = $perpage;
-            $pagingbar->baseurl     = $PAGE->url;
-            $pagingbar->pagevar     = 'page';
+            $pagingbar              = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page');
 
             // grading report display options
             $reportopts                         = new stdclass();
@@ -201,9 +196,9 @@ case workshop::PHASE_ASSESSMENT:
             $reportopts->showsubmissiongrade    = false;
             $reportopts->showgradinggrade       = false;
 
-            echo $OUTPUT->paging_bar($pagingbar);
+            echo $OUTPUT->render($pagingbar);
             echo $wsoutput->grading_report($data, $reportopts);
-            echo $OUTPUT->paging_bar($pagingbar);
+            echo $OUTPUT->render($pagingbar);
         }
     }
     if (trim(strip_tags($workshop->instructreviewers))) {
@@ -272,12 +267,7 @@ case workshop::PHASE_EVALUATION:
             }
 
             // prepare paging bar
-            $pagingbar              = new moodle_paging_bar();
-            $pagingbar->totalcount  = $data->totalcount;
-            $pagingbar->page        = $page;
-            $pagingbar->perpage     = $perpage;
-            $pagingbar->baseurl     = $PAGE->url;
-            $pagingbar->pagevar     = 'page';
+            $pagingbar              = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page');
 
             // grading report display options
             $reportopts                         = new stdclass();
@@ -288,9 +278,9 @@ case workshop::PHASE_EVALUATION:
             $reportopts->showsubmissiongrade    = true;
             $reportopts->showgradinggrade       = true;
 
-            echo $OUTPUT->paging_bar($pagingbar);
+            echo $OUTPUT->render($pagingbar);
             echo $wsoutput->grading_report($data, $reportopts);
-            echo $OUTPUT->paging_bar($pagingbar);
+            echo $OUTPUT->render($pagingbar);
         }
     }
     break;
index f4c86b2..0d509a1 100644 (file)
@@ -1266,9 +1266,9 @@ class question_bank_view {
         echo '<div class="categorypagingbarcontainer">';
         $pageing_url = new moodle_url('edit.php');
         $r = $pageing_url->params($pageurl->params());
-        $pagingbar = moodle_paging_bar::make($totalnumber, $page, $perpage, $pageing_url);
+        $pagingbar = new paging_bar($totalnumber, $page, $perpage, $pageing_url);
         $pagingbar->pagevar = 'qpage';
-        echo $OUTPUT->paging_bar($pagingbar);
+        echo $OUTPUT->render($pagingbar);
         echo '</div>';
 
         echo '<form method="post" action="edit.php">';
@@ -1287,7 +1287,7 @@ class question_bank_view {
         echo "</div>\n";
 
         echo '<div class="categorypagingbarcontainer pagingbottom">';
-        echo $OUTPUT->paging_bar($pagingbar);
+        echo $OUTPUT->render($pagingbar);
         if ($totalnumber > DEFAULT_QUESTIONS_PER_PAGE) {
             if ($perpage == DEFAULT_QUESTIONS_PER_PAGE) {
                 $url = new moodle_url('edit.php', ($pageurl->params()+array('qperpage'=>1000)));
index d6777d2..c29b663 100755 (executable)
@@ -126,14 +126,9 @@ case 'search':
         $search_result['repo_id'] = $repo_id;
 
         // TODO: need a better solution
-        $pagingbar = new moodle_paging_bar();
-        $pagingbar->totalcount = $search_result['total'];
-        $pagingbar->page = $search_result['page'] - 1;
-        $pagingbar->perpage = $search_result['perpage'];
-        $pagingbar->baseurl = clone($url);
-        $pagingbar->baseurl->params(array('search_paging' => 1, 'action' => 'search', 'repo_id' => $repo_id));
-        $pagingbar->pagevar = 'p';
-        echo $OUTPUT->paging_bar($pagingbar);
+        $purl = new moodle_ulr($url, array('search_paging' => 1, 'action' => 'search', 'repo_id' => $repo_id));
+        $pagingbar = new paging_bar($search_result['total'], $search_result['page'] - 1, $search_result['perpage'], $purl, 'p');
+        echo $OUTPUT->render($pagingbar);
 
         echo '<table>';
         foreach ($search_result['list'] as $item) {
@@ -193,7 +188,7 @@ case 'sign':
             if (!empty($list['page'])) {
                 // TODO: need a better solution
                 $pagingurl = new moodle_url("$CFG->httpswwwroot/repository/filepicker.php?action=list&itemid=$itemid&ctx_id=$contextid&repo_id=$repo_id");
-                echo $OUTPUT->paging_bar(moodle_paging_bar::make($list['total'], $list['page'] - 1, $list['perpage'], $pagingurl));
+                echo $OUTPUT->paging_bar($list['total'], $list['page'] - 1, $list['perpage'], $pagingurl);
             }
             echo '<table>';
             foreach ($list['list'] as $item) {
index b126ed4..763a516 100644 (file)
@@ -145,9 +145,9 @@ if ($usercount > 0) {
     echo $OUTPUT->heading($heading, 3);
 
     $baseurl = new moodle_url('/tag/index.php', array('id' => $tag->id));
-    $pagingbar = moodle_paging_bar::make($usercount, $userpage, $perpage, $baseurl);
+    $pagingbar = new paging_bar($usercount, $userpage, $perpage, $baseurl);
     $pagingbar->pagevar = 'userpage';
-    echo $OUTPUT->paging_bar($pagingbar);
+    echo $OUTPUT->render($pagingbar);
     tag_print_tagged_users_table($tag, $userpage * $perpage, $perpage);
     echo $OUTPUT->box_end();
 }
index 58e5e0d..380b611 100644 (file)
@@ -266,7 +266,7 @@ function tag_print_search_results($query,  $page, $perpage, $return=false) {
         $output .= '</ul>';
         $output .= '<div>&nbsp;</div>'; // <-- small layout hack in order to look good in Firefox
 
-        $output .= $OUTPUT->paging_bar(moodle_paging_bar::make($count, $page, $perpage, $baseurl));
+        $output .= $OUTPUT->paging_bar($count, $page, $perpage, $baseurl);
     }
     else { //no results were found!!
         $output .= $OUTPUT->heading(get_string('noresultsfor', 'tag', htmlspecialchars($query)), 3, 'main');
index 8e67034..6ad9378 100644 (file)
                 }
                 echo '</div>';
 
-                $pagingbar = moodle_paging_bar::make($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl);
+                $pagingbar = new paging_bar($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl);
                 $pagingbar->pagevar = 'spage';
-                echo $OUTPUT->paging_bar($pagingbar);
+                echo $OUTPUT->new($pagingbar);
             }
 
             if ($matchcount > 0) {
index 5f82036..3c3017e 100644 (file)
@@ -137,10 +137,10 @@ if ($logcount > 0) {
         );
     }
     echo $OUTPUT->heading(get_string('logsummary', 'portfolio'));
-    $pagingbar = moodle_paging_bar::make($logcount, $page, $perpage, $CFG->wwwroot . '/user/portfoliologs.php?');
-    echo $OUTPUT->paging_bar($pagingbar);
+    $pagingbar = new paging_bar($logcount, $page, $perpage, $CFG->wwwroot . '/user/portfoliologs.php?');
+    echo $OUTPUT->render($pagingbar);
     echo $OUTPUT->table($table);
-    echo $OUTPUT->paging_bar($pagingbar);
+    echo $OUTPUT->render($pagingbar);
     $somethingprinted = true;
 }
 if (!$somethingprinted) {