original_string: protected function listing_pagination(core_course_category $category, $page, $perpage, $showtotals = false,
                                            $viewmode = 'default') {
          $html = '';
          $totalcourses = $category->get_courses_count();
          $totalpages = ceil($totalcourses / $perpage);
          if ($showtotals) {
              if ($totalpages == 0) {
                  $str = get_string('nocoursesyet');
              } else if ($totalpages == 1) {
                  $str = get_string('showingacourses', 'moodle', $totalcourses);
              } else {
                  $a = new stdClass;
                  $a->start = ($page * $perpage) + 1;
                  $a->end = min((($page + 1) * $perpage), $totalcourses);
                  $a->total = $totalcourses;
                  $str = get_string('showingxofycourses', 'moodle', $a);
              }
              $html .= html_writer::div($str, 'listing-pagination-totals dimmed');
          }
  
          if ($viewmode !== 'default') {
              $baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id,
                  'view' => $viewmode));
          } else {
              $baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id));
          }
  
          $html .= $this->output->paging_bar($totalcourses, $page, $perpage, $baseurl);
          return $html;
      }
code: protected function listing_pagination(core_course_category $category, $page, $perpage, $showtotals = false,
                                            $viewmode = 'default') {
          $html = '';
          $totalcourses = $category->get_courses_count();
          $totalpages = ceil($totalcourses / $perpage);
          if ($showtotals) {
              if ($totalpages == 0) {
                  $str = get_string('nocoursesyet');
              } else if ($totalpages == 1) {
                  $str = get_string('showingacourses', 'moodle', $totalcourses);
              } else {
                  $a = new stdClass;
                  $a->start = ($page * $perpage) + 1;
                  $a->end = min((($page + 1) * $perpage), $totalcourses);
                  $a->total = $totalcourses;
                  $str = get_string('showingxofycourses', 'moodle', $a);
              }
              $html .= html_writer::div($str, 'listing-pagination-totals dimmed');
          }
  
          if ($viewmode !== 'default') {
              $baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id,
                  'view' => $viewmode));
          } else {
              $baseurl = new moodle_url('/course/management.php', array('categoryid' => $category->id));
          }
  
          $html .= $this->output->paging_bar($totalcourses, $page, $perpage, $baseurl);
          return $html;
      }
code_tokens: protected function listing_pagination ( core_course_category $ category , $ page , $ perpage , $ showtotals = false , $ viewmode = 'default' ) { $ html = '' ; $ totalcourses = $ category -> get_courses_count ( ) ; $ totalpages = ceil ( $ totalcourses / $ perpage ) ; if ( $ showtotals ) { if ( $ totalpages == 0 ) { $ str = get_string ( 'nocoursesyet' ) ; } else if ( $ totalpages == 1 ) { $ str = get_string ( 'showingacourses' , 'moodle' , $ totalcourses ) ; } else { $ a = new stdClass ; $ a -> start = ( $ page * $ perpage ) + 1 ; $ a -> end = min ( ( ( $ page + 1 ) * $ perpage ) , $ totalcourses ) ; $ a -> total = $ totalcourses ; $ str = get_string ( 'showingxofycourses' , 'moodle' , $ a ) ; } $ html .= html_writer :: div ( $ str , 'listing-pagination-totals dimmed' ) ; } if ( $ viewmode !== 'default' ) { $ baseurl = new moodle_url ( '/course/management.php' , array ( 'categoryid' => $ category -> id , 'view' => $ viewmode ) ) ; } else { $ baseurl = new moodle_url ( '/course/management.php' , array ( 'categoryid' => $ category -> id ) ) ; } $ html .= $ this -> output -> paging_bar ( $ totalcourses , $ page , $ perpage , $ baseurl ) ; return $ html ; }
docstring: Renders pagination for a course listing.
  
  @param core_course_category $category The category to produce pagination for.
  @param int $page The current page.
  @param int $perpage The number of courses to display per page.
  @param bool $showtotals Set to true to show the total number of courses and what is being displayed.
  @param string|null $viewmode The view mode the page is in, one out of 'default', 'combined', 'courses' or 'categories'.
  @return string
docstring_tokens: Renders pagination for a course listing .