original_string: public static function search_courses($search, $blocklist, $modulelist, $page = 0, $perpage = null) {
          global $CFG;
  
          if ($perpage === null) {
              $perpage = $CFG->coursesperpage;
          }
  
          $searchcriteria = array();
          if (!empty($search)) {
              $searchcriteria = array('search' => $search);
          } else if (!empty($blocklist)) {
              $searchcriteria = array('blocklist' => $blocklist);
          } else if (!empty($modulelist)) {
              $searchcriteria = array('modulelist' => $modulelist);
          }
  
          $topcat = \core_course_category::top();
          $courses = $topcat->search_courses($searchcriteria, array(
              'recursive' => true,
              'offset' => $page * $perpage,
              'limit' => $perpage,
              'sort' => array('fullname' => 1)
          ));
          $totalcount = $topcat->search_courses_count($searchcriteria, array('recursive' => true));
  
          return array($courses, \count($courses), $totalcount);
      }
code: public static function search_courses($search, $blocklist, $modulelist, $page = 0, $perpage = null) {
          global $CFG;
  
          if ($perpage === null) {
              $perpage = $CFG->coursesperpage;
          }
  
          $searchcriteria = array();
          if (!empty($search)) {
              $searchcriteria = array('search' => $search);
          } else if (!empty($blocklist)) {
              $searchcriteria = array('blocklist' => $blocklist);
          } else if (!empty($modulelist)) {
              $searchcriteria = array('modulelist' => $modulelist);
          }
  
          $topcat = \core_course_category::top();
          $courses = $topcat->search_courses($searchcriteria, array(
              'recursive' => true,
              'offset' => $page * $perpage,
              'limit' => $perpage,
              'sort' => array('fullname' => 1)
          ));
          $totalcount = $topcat->search_courses_count($searchcriteria, array('recursive' => true));
  
          return array($courses, \count($courses), $totalcount);
      }
code_tokens: public static function search_courses ( $ search , $ blocklist , $ modulelist , $ page = 0 , $ perpage = null ) { global $ CFG ; if ( $ perpage === null ) { $ perpage = $ CFG -> coursesperpage ; } $ searchcriteria = array ( ) ; if ( ! empty ( $ search ) ) { $ searchcriteria = array ( 'search' => $ search ) ; } else if ( ! empty ( $ blocklist ) ) { $ searchcriteria = array ( 'blocklist' => $ blocklist ) ; } else if ( ! empty ( $ modulelist ) ) { $ searchcriteria = array ( 'modulelist' => $ modulelist ) ; } $ topcat = \ core_course_category :: top ( ) ; $ courses = $ topcat -> search_courses ( $ searchcriteria , array ( 'recursive' => true , 'offset' => $ page * $ perpage , 'limit' => $ perpage , 'sort' => array ( 'fullname' => 1 ) ) ) ; $ totalcount = $ topcat -> search_courses_count ( $ searchcriteria , array ( 'recursive' => true ) ) ; return array ( $ courses , \ count ( $ courses ) , $ totalcount ) ; }
docstring: Search for courses with matching params.
  
  Please note that only one of search, blocklist, or modulelist can be specified at a time.
  Specifying more than one will result in only the first being used.
  
  @param string $search Words to search for. We search fullname, shortname, idnumber and summary.
  @param int $blocklist The ID of a block, courses will only be returned if they use this block.
  @param string $modulelist The name of a module (relates to database table name). Only courses containing this module
  will be returned.
  @param int $page The page number to display, starting at 0.
  @param int $perpage The number of courses to display per page.
  @return array
docstring_tokens: Search for courses with matching params .