Merge branch 'MDL-35603_23' of git://github.com/rlorenzo/moodle into MOODLE_23_STABLE
This commit is contained in:
@@ -521,6 +521,15 @@ class core_backup_renderer extends plugin_renderer_base {
|
||||
$url = $component->get_url();
|
||||
|
||||
$output = html_writer::start_tag('div', array('class' => 'restore-course-search'));
|
||||
|
||||
$count_str = '';
|
||||
if ($component->has_more_results()) {
|
||||
$count_str = get_string('morecoursesearchresults', 'backup', $component->get_count());
|
||||
} else {
|
||||
$count_str = get_string('totalcoursesearchresults', 'backup', $component->get_count());
|
||||
}
|
||||
|
||||
$output .= html_writer::tag('div', $count_str, array('class'=>'rcs-totalresults'));
|
||||
$output .= html_writer::start_tag('div', array('class' => 'rcs-results'));
|
||||
|
||||
$table = new html_table();
|
||||
@@ -590,8 +599,14 @@ class core_backup_renderer extends plugin_renderer_base {
|
||||
return $output;
|
||||
}
|
||||
|
||||
$output .= html_writer::tag('div', get_string('totalcoursesearchresults', 'backup', $component->get_count()), array('class'=>'ics-totalresults'));
|
||||
$count_str = '';
|
||||
if ($component->has_more_results()) {
|
||||
$count_str = get_string('morecoursesearchresults', 'backup', $component->get_count());
|
||||
} else {
|
||||
$count_str = get_string('totalcoursesearchresults', 'backup', $component->get_count());
|
||||
}
|
||||
|
||||
$output .= html_writer::tag('div', $count_str, array('class'=>'ics-totalresults'));
|
||||
$output .= html_writer::start_tag('div', array('class' => 'ics-results'));
|
||||
|
||||
$table = new html_table();
|
||||
@@ -610,6 +625,14 @@ class core_backup_renderer extends plugin_renderer_base {
|
||||
);
|
||||
$table->data[] = $row;
|
||||
}
|
||||
if ($component->has_more_results()) {
|
||||
$cell = new html_table_cell(get_string('moreresults', 'backup'));
|
||||
$cell->colspan = 3;
|
||||
$cell->attributes['class'] = 'notifyproblem';
|
||||
$row = new html_table_row(array($cell));
|
||||
$row->attributes['class'] = 'rcs-course';
|
||||
$table->data[] = $row;
|
||||
}
|
||||
$output .= html_writer::table($table);
|
||||
$output .= html_writer::end_tag('div');
|
||||
|
||||
|
||||
@@ -65,6 +65,11 @@ abstract class restore_search_base implements renderable {
|
||||
* @var array
|
||||
*/
|
||||
private $requiredcapabilities = array();
|
||||
/**
|
||||
* Indicates if we have more than maxresults found.
|
||||
* @var boolean
|
||||
*/
|
||||
private $has_more_results = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -177,7 +182,7 @@ abstract class restore_search_base implements renderable {
|
||||
foreach ($this->requiredcapabilities as $cap) {
|
||||
$requiredcaps[] = $cap['capability'];
|
||||
}
|
||||
// Iterate while we have records and haven't reached MAXRESULTS
|
||||
// Iterate while we have records and haven't reached $this->maxresults.
|
||||
while ($totalcourses > $offs and $this->totalcount < self::$MAXRESULTS) {
|
||||
$resultset = $DB->get_records_sql($sql, $params, $offs, $blocksz);
|
||||
foreach ($resultset as $result) {
|
||||
@@ -188,11 +193,14 @@ abstract class restore_search_base implements renderable {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$this->results[$result->id] = $result;
|
||||
$this->totalcount++;
|
||||
if ($this->totalcount >= self::$MAXRESULTS) {
|
||||
// Check if we are over the limit.
|
||||
if ($this->totalcount+1 > self::$MAXRESULTS) {
|
||||
$this->has_more_results = true;
|
||||
break;
|
||||
}
|
||||
// If not, then continue.
|
||||
$this->totalcount++;
|
||||
$this->results[$result->id] = $result;
|
||||
}
|
||||
$offs += $blocksz;
|
||||
}
|
||||
@@ -201,7 +209,10 @@ abstract class restore_search_base implements renderable {
|
||||
}
|
||||
|
||||
final public function has_more_results() {
|
||||
return $this->get_count() >= self::$MAXRESULTS;
|
||||
if ($this->results === null) {
|
||||
$this->search();
|
||||
}
|
||||
return $this->has_more_results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -240,3 +240,4 @@ $string['setting_keep_roles_and_enrolments'] = 'Keep current roles and enrolment
|
||||
$string['setting_keep_groups_and_groupings'] = 'Keep current groups and groupings';
|
||||
$string['totalcategorysearchresults'] = 'Total categories: {$a}';
|
||||
$string['totalcoursesearchresults'] = 'Total courses: {$a}';
|
||||
$string['morecoursesearchresults'] = 'More than {$a} courses found, showing first {$a} results';
|
||||
|
||||
Reference in New Issue
Block a user