public function search_listing(array $courses, $totalcourses, core_course_list_element $course = null, $page = 0, $perpage = 20,
            $search = '') {
        $page = max($page, 0);
        $perpage = max($perpage, 2);
        $totalpages = ceil($totalcourses / $perpage);
        if ($page > $totalpages - 1) {
            $page = $totalpages - 1;
        }
        $courseid = isset($course) ? $course->id : null;
        $first = true;
        $last = false;
        $i = $page * $perpage;

        $html  = html_writer::start_div('course-listing w-100', array(
                'data-category' => 'search',
                'data-page' => $page,
                'data-totalpages' => $totalpages,
                'data-totalcourses' => $totalcourses
        ));
        $html .= html_writer::tag('h3', get_string('courses'));
        $html .= $this->search_pagination($totalcourses, $page, $perpage);
        $html .= html_writer::start_tag('ul', array('class' => 'ml'));
        foreach ($courses as $listitem) {
            $i++;
            if ($i == $totalcourses) {
                $last = true;
            }
            $html .= $this->search_listitem($listitem, $courseid, $first, $last);
            $first = false;
        }
        $html .= html_writer::end_tag('ul');
        $html .= $this->search_pagination($totalcourses, $page, $perpage, true, $search);
        $html .= $this->course_search_bulk_actions();
        $html .= html_writer::end_div();
        return $html;
    }
public function search_listing(array $courses, $totalcourses, core_course_list_element $course = null, $page = 0, $perpage = 20,
            $search = '') {
        $page = max($page, 0);
        $perpage = max($perpage, 2);
        $totalpages = ceil($totalcourses / $perpage);
        if ($page > $totalpages - 1) {
            $page = $totalpages - 1;
        }
        $courseid = isset($course) ? $course->id : null;
        $first = true;
        $last = false;
        $i = $page * $perpage;

        $html  = html_writer::start_div('course-listing w-100', array(
                'data-category' => 'search',
                'data-page' => $page,
                'data-totalpages' => $totalpages,
                'data-totalcourses' => $totalcourses
        ));
        $html .= html_writer::tag('h3', get_string('courses'));
        $html .= $this->search_pagination($totalcourses, $page, $perpage);
        $html .= html_writer::start_tag('ul', array('class' => 'ml'));
        foreach ($courses as $listitem) {
            $i++;
            if ($i == $totalcourses) {
                $last = true;
            }
            $html .= $this->search_listitem($listitem, $courseid, $first, $last);
            $first = false;
        }
        $html .= html_writer::end_tag('ul');
        $html .= $this->search_pagination($totalcourses, $page, $perpage, true, $search);
        $html .= $this->course_search_bulk_actions();
        $html .= html_writer::end_div();
        return $html;
    }
public function search_listing ( array $ courses , $ totalcourses , core_course_list_element $ course = null , $ page = 0 , $ perpage = 20 , $ search = '' ) { $ page = max ( $ page , 0 ) ; $ perpage = max ( $ perpage , 2 ) ; $ totalpages = ceil ( $ totalcourses / $ perpage ) ; if ( $ page > $ totalpages - 1 ) { $ page = $ totalpages - 1 ; } $ courseid = isset ( $ course ) ? $ course -> id : null ; $ first = true ; $ last = false ; $ i = $ page * $ perpage ; $ html = html_writer :: start_div ( 'course-listing w-100' , array ( 'data-category' => 'search' , 'data-page' => $ page , 'data-totalpages' => $ totalpages , 'data-totalcourses' => $ totalcourses ) ) ; $ html .= html_writer :: tag ( 'h3' , get_string ( 'courses' ) ) ; $ html .= $ this -> search_pagination ( $ totalcourses , $ page , $ perpage ) ; $ html .= html_writer :: start_tag ( 'ul' , array ( 'class' => 'ml' ) ) ; foreach ( $ courses as $ listitem ) { $ i ++ ; if ( $ i == $ totalcourses ) { $ last = true ; } $ html .= $ this -> search_listitem ( $ listitem , $ courseid , $ first , $ last ) ; $ first = false ; } $ html .= html_writer :: end_tag ( 'ul' ) ; $ html .= $ this -> search_pagination ( $ totalcourses , $ page , $ perpage , true , $ search ) ; $ html .= $ this -> course_search_bulk_actions ( ) ; $ html .= html_writer :: end_div ( ) ; return $ html ; }
Displays a search result listing.

@param array $courses The courses to display.
@param int $totalcourses The total number of courses to display.
@param core_course_list_element $course The currently selected course if there is one.
@param int $page The current page, starting at 0.
@param int $perpage The number of courses to display per page.
@param string $search The string we are searching for.
@return string
Displays a search result listing .