3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * This file contains backup and restore output renderers
22 * @copyright 2010 Sam Hemelryk
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 * The primary renderer for the backup.
29 * Can be retrieved with the following code:
31 * $renderer = $PAGE->get_renderer('core','backup');
34 * @copyright 2010 Sam Hemelryk
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 class core_backup_renderer extends plugin_renderer_base {
39 * Renderers a progress bar for the backup or restore given the items that
41 * @param array $items An array of items
44 public function progress_bar(array $items) {
45 foreach ($items as &$item) {
46 $text = $item['text'];
48 if (array_key_exists('link', $item)) {
49 $link = $item['link'];
51 $item = html_writer::link($link, $text, $item);
53 $item = html_writer::tag('span', $text, $item);
56 return html_writer::tag('div', join(get_separator(), $items), array('class'=>'backup_progress clearfix'));
59 * Prints a dependency notification
60 * @param string $message
63 public function dependency_notification($message) {
64 return html_writer::tag('div', $message, array('class'=>'notification dependencies_enforced'));
68 * Displays the details of a backup file
70 * @param stdClass $details
71 * @param moodle_url $nextstageurl
74 public function backup_details($details, $nextstageurl) {
75 $yestick = $this->output->pix_icon('i/tick_green_big', get_string('yes'));
76 $notick = $this->output->pix_icon('i/cross_red_big', get_string('no'));
78 $html = html_writer::start_tag('div', array('class'=>'backup-restore'));
80 $html .= html_writer::start_tag('div', array('class'=>'backup-section'));
81 $html .= $this->output->heading(get_string('backupdetails', 'backup'), 2, array('class'=>'header'));
82 $html .= $this->backup_detail_pair(get_string('backuptype', 'backup'), get_string('backuptype'.$details->type, 'backup'));
83 $html .= $this->backup_detail_pair(get_string('backupformat', 'backup'), get_string('backupformat'.$details->format, 'backup'));
84 $html .= $this->backup_detail_pair(get_string('backupmode', 'backup'), get_string('backupmode'.$details->mode, 'backup'));
85 $html .= $this->backup_detail_pair(get_string('backupdate', 'backup'), userdate($details->backup_date));
86 $html .= $this->backup_detail_pair(get_string('moodleversion', 'backup'),
87 html_writer::tag('span', $details->moodle_release, array('class'=>'moodle_release')).
88 html_writer::tag('span', '['.$details->moodle_version.']', array('class'=>'moodle_version sub-detail')));
89 $html .= $this->backup_detail_pair(get_string('backupversion', 'backup'),
90 html_writer::tag('span', $details->backup_release, array('class'=>'moodle_release')).
91 html_writer::tag('span', '['.$details->backup_version.']', array('class'=>'moodle_version sub-detail')));
92 $html .= $this->backup_detail_pair(get_string('originalwwwroot', 'backup'),
93 html_writer::tag('span', $details->original_wwwroot, array('class'=>'originalwwwroot')).
94 html_writer::tag('span', '['.$details->original_site_identifier_hash.']', array('class'=>'sitehash sub-detail')));
95 $html .= html_writer::end_tag('div');
97 $html .= html_writer::start_tag('div', array('class'=>'backup-section settings-section'));
98 $html .= $this->output->heading(get_string('backupsettings', 'backup'), 2, array('class'=>'header'));
99 foreach ($details->root_settings as $label=>$value) {
100 if ($label == 'filename') continue;
101 $html .= $this->backup_detail_pair(get_string('rootsetting'.str_replace('_','',$label), 'backup'), $value?$yestick:$notick);
103 $html .= html_writer::end_tag('div');
105 if ($details->type === 'course') {
106 $html .= html_writer::start_tag('div', array('class'=>'backup-section'));
107 $html .= $this->output->heading(get_string('backupcoursedetails', 'backup'), 2, array('class'=>'header'));
108 $html .= $this->backup_detail_pair(get_string('coursetitle', 'backup'), $details->course->title);
109 $html .= $this->backup_detail_pair(get_string('courseid', 'backup'), $details->course->courseid);
111 $html .= html_writer::start_tag('div', array('class'=>'backup-sub-section'));
112 $html .= $this->output->heading(get_string('backupcoursesections', 'backup'), 3, array('class'=>'subheader'));
113 foreach ($details->sections as $key=>$section) {
114 $included = $key.'_included';
115 $userinfo = $key.'_userinfo';
116 if ($section->settings[$included] && $section->settings[$userinfo]) {
117 $value = get_string('sectionincanduser','backup');
118 } else if ($section->settings[$included]) {
119 $value = get_string('sectioninc','backup');
123 $html .= $this->backup_detail_pair(get_string('backupcoursesection', 'backup', $section->title), $value);
125 foreach ($details->activities as $activitykey=>$activity) {
126 if ($activity->sectionid != $section->sectionid) {
130 $table = new html_table();
131 $table->head = array('Module', 'Title', 'Userinfo');
132 $table->colclasses = array('modulename', 'moduletitle', 'userinfoincluded');
133 $table->align = array('left','left', 'center');
134 $table->attributes = array('class'=>'activitytable generaltable');
135 $table->data = array();
137 $name = get_string('pluginname', $activity->modulename);
138 $icon = new pix_icon('icon', $name, $activity->modulename);
139 $table->data[] = array(
140 $this->output->render($icon).' '.$name,
142 ($activity->settings[$activitykey.'_userinfo'])?$yestick:$notick,
145 if (!empty($table)) {
146 $html .= $this->backup_detail_pair(get_string('sectionactivities','backup'), html_writer::table($table));
150 $html .= html_writer::end_tag('div');
151 $html .= html_writer::end_tag('div');
154 $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post');
155 $html .= html_writer::end_tag('div');
161 * Displays the general information about a backup file with non-standard format
163 * @param moodle_url $nextstageurl URL to send user to
164 * @param array $details basic info about the file (format, type)
165 * @return string HTML code to display
167 public function backup_details_nonstandard($nextstageurl, array $details) {
169 $html = html_writer::start_tag('div', array('class' => 'backup-restore nonstandardformat'));
170 $html .= html_writer::start_tag('div', array('class' => 'backup-section'));
171 $html .= $this->output->heading(get_string('backupdetails', 'backup'), 2, 'header');
172 $html .= $this->output->box(get_string('backupdetailsnonstandardinfo', 'backup'), 'noticebox');
173 $html .= $this->backup_detail_pair(
174 get_string('backupformat', 'backup'),
175 get_string('backupformat'.$details['format'], 'backup'));
176 $html .= $this->backup_detail_pair(
177 get_string('backuptype', 'backup'),
178 get_string('backuptype'.$details['type'], 'backup'));
179 $html .= html_writer::end_tag('div');
180 $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post');
181 $html .= html_writer::end_tag('div');
187 * Displays the general information about a backup file with unknown format
189 * @param moodle_url $nextstageurl URL to send user to
190 * @return string HTML code to display
192 public function backup_details_unknown(moodle_url $nextstageurl) {
194 $html = html_writer::start_tag('div', array('class' => 'unknownformat'));
195 $html .= $this->output->heading(get_string('errorinvalidformat', 'backup'), 2, 'notifyproblem');
196 $html .= html_writer::tag('div', get_string('errorinvalidformatinfo', 'backup'), array('class' => 'notifyproblem'));
197 $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post');
198 $html .= html_writer::end_tag('div');
204 * Displays a course selector for restore
206 * @param moodle_url $nextstageurl
207 * @param bool $wholecourse true if we are restoring whole course (as with backup::TYPE_1COURSE), false otherwise
208 * @param restore_category_search $categories
209 * @param restore_course_search $courses
210 * @param int $currentcourse
213 public function course_selector(moodle_url $nextstageurl, $wholecourse = true, restore_category_search $categories = null, restore_course_search $courses=null, $currentcourse = null) {
215 require_once($CFG->dirroot.'/course/lib.php');
217 $nextstageurl->param('sesskey', sesskey());
219 $form = html_writer::start_tag('form', array('method'=>'post', 'action'=>$nextstageurl->out_omit_querystring()));
220 foreach ($nextstageurl->params() as $key=>$value) {
221 $form .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>$key, 'value'=>$value));
224 $hasrestoreoption = false;
226 $html = html_writer::start_tag('div', array('class'=>'backup-course-selector backup-restore'));
227 if ($wholecourse && !empty($categories) && ($categories->get_count() > 0 || $categories->get_search())) {
229 $hasrestoreoption = true;
231 $html .= html_writer::start_tag('div', array('class'=>'bcs-new-course backup-section'));
232 $html .= $this->output->heading(get_string('restoretonewcourse', 'backup'), 2, array('class'=>'header'));
233 $html .= $this->backup_detail_input(get_string('restoretonewcourse', 'backup'), 'radio', 'target', backup::TARGET_NEW_COURSE, array('checked'=>'checked'));
234 $html .= $this->backup_detail_pair(get_string('selectacategory', 'backup'), $this->render($categories));
235 $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'))));
236 $html .= html_writer::end_tag('div');
237 $html .= html_writer::end_tag('form');
240 if ($wholecourse && !empty($currentcourse)) {
242 $hasrestoreoption = true;
244 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'targetid', 'value'=>$currentcourse));
245 $html .= html_writer::start_tag('div', array('class'=>'bcs-current-course backup-section'));
246 $html .= $this->output->heading(get_string('restoretocurrentcourse', 'backup'), 2, array('class'=>'header'));
247 $html .= $this->backup_detail_input(get_string('restoretocurrentcourseadding', 'backup'), 'radio', 'target', backup::TARGET_CURRENT_ADDING, array('checked'=>'checked'));
248 $html .= $this->backup_detail_input(get_string('restoretocurrentcoursedeleting', 'backup'), 'radio', 'target', backup::TARGET_CURRENT_DELETING);
249 $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'))));
250 $html .= html_writer::end_tag('div');
251 $html .= html_writer::end_tag('form');
254 if (!empty($courses) && ($courses->get_count() > 0 || $courses->get_search())) {
256 $hasrestoreoption = true;
258 $html .= html_writer::start_tag('div', array('class'=>'bcs-existing-course backup-section'));
259 $html .= $this->output->heading(get_string('restoretoexistingcourse', 'backup'), 2, array('class'=>'header'));
261 $html .= $this->backup_detail_input(get_string('restoretoexistingcourseadding', 'backup'), 'radio', 'target', backup::TARGET_EXISTING_ADDING, array('checked'=>'checked'));
262 $html .= $this->backup_detail_input(get_string('restoretoexistingcoursedeleting', 'backup'), 'radio', 'target', backup::TARGET_EXISTING_DELETING);
263 $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
265 // We only allow restore adding to existing for now. Enforce it here.
266 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'target', 'value'=>backup::TARGET_EXISTING_ADDING));
267 $courses->invalidate_results(); // Clean list of courses
268 $courses->set_include_currentcourse(); // Show current course in the list
269 $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
271 $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'))));
272 $html .= html_writer::end_tag('div');
273 $html .= html_writer::end_tag('form');
276 if (!$hasrestoreoption) {
277 echo $this->output->notification(get_string('norestoreoptions','backup'));
280 $html .= html_writer::end_tag('div');
285 * Displays the import course selector
287 * @param moodle_url $nextstageurl
288 * @param import_course_search $courses
291 public function import_course_selector(moodle_url $nextstageurl, import_course_search $courses=null) {
292 $html = html_writer::start_tag('div', array('class'=>'import-course-selector backup-restore'));
293 $html .= html_writer::start_tag('form', array('method'=>'post', 'action'=>$nextstageurl->out_omit_querystring()));
294 foreach ($nextstageurl->params() as $key=>$value) {
295 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>$key, 'value'=>$value));
297 // We only allow import adding for now. Enforce it here.
298 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'target', 'value'=>backup::TARGET_CURRENT_ADDING));
299 $html .= html_writer::start_tag('div', array('class'=>'ics-existing-course backup-section'));
300 $html .= $this->output->heading(get_string('importdatafrom'), 2, array('class'=>'header'));
301 $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
302 $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'))));
303 $html .= html_writer::end_tag('div');
304 $html .= html_writer::end_tag('form');
305 $html .= html_writer::end_tag('div');
310 * Creates a detailed pairing (key + value)
312 * @staticvar int $count
313 * @param string $label
314 * @param string $value
317 protected function backup_detail_pair($label, $value) {
320 $html = html_writer::start_tag('div', array('class'=>'detail-pair'));
321 $html .= html_writer::tag('label', $label, array('class'=>'detail-pair-label', 'for'=>'detail-pair-value-'.$count));
322 $html .= html_writer::tag('div', $value, array('class'=>'detail-pair-value', 'name'=>'detail-pair-value-'.$count));
323 $html .= html_writer::end_tag('div');
328 * Created a detailed pairing with an input
330 * @param string $label
331 * @param string $type
332 * @param string $name
333 * @param string $value
334 * @param array $attributes
335 * @param string|null $description
338 protected function backup_detail_input($label, $type, $name, $value, array $attributes=array(), $description=null) {
339 if (!empty ($description)) {
340 $description = html_writer::tag('span', $description, array('class'=>'description'));
344 return $this->backup_detail_pair($label, html_writer::empty_tag('input', $attributes+array('name'=>$name, 'type'=>$type, 'value'=>$value)).$description);
348 * Creates a detailed pairing with a select
350 * @param string $label
351 * @param string $name
352 * @param array $options
353 * @param string $selected
354 * @param bool $nothing
355 * @param array $attributes
356 * @param string|null $description
359 protected function backup_detail_select($label, $name, $options, $selected='', $nothing=false, array $attributes=array(), $description=null) {
360 if (!empty ($description)) {
361 $description = html_writer::tag('span', $description, array('class'=>'description'));
365 return $this->backup_detail_pair($label, html_writer::select($options, $name, $selected, false, $attributes).$description);
369 * Displays precheck notices
371 * @param array $results
374 public function precheck_notices($results) {
375 $output = html_writer::start_tag('div', array('class'=>'restore-precheck-notices'));
376 if (array_key_exists('errors', $results)) {
377 foreach ($results['errors'] as $error) {
378 $output .= $this->output->notification($error);
381 if (array_key_exists('warnings', $results)) {
382 foreach ($results['warnings'] as $warning) {
383 $output .= $this->output->notification($warning, 'notifywarning notifyproblem');
386 return $output.html_writer::end_tag('div');
390 * Displays substage buttons
392 * @param bool $haserrors
395 public function substage_buttons($haserrors) {
396 $output = html_writer::start_tag('div', array('continuebutton'));
398 $output .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue')));
400 $output .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'cancel', 'value'=>get_string('cancel')));
401 $output .= html_writer::end_tag('div');
406 * Displays a role mapping interface
408 * @param array $rolemappings
409 * @param array $roles
412 public function role_mappings($rolemappings, $roles) {
413 $roles[0] = get_string('none');
414 $output = html_writer::start_tag('div', array('class'=>'restore-rolemappings'));
415 $output .= $this->output->heading(get_string('restorerolemappings', 'backup'), 2);
416 foreach ($rolemappings as $id=>$mapping) {
417 $label = $mapping->name;
418 $name = 'mapping'.$id;
419 $selected = $mapping->targetroleid;
420 $output .= $this->backup_detail_select($label, $name, $roles, $mapping->targetroleid, false, array(), $mapping->description);
422 $output .= html_writer::end_tag('div');
427 * Displays a continue button
429 * @param string|moodle_url $url
430 * @param string $method
433 public function continue_button($url, $method='post') {
434 if (!($url instanceof moodle_url)) {
435 $url = new moodle_url($url);
437 if ($method != 'post') {
440 $url->param('sesskey', sesskey());
441 $button = new single_button($url, get_string('continue'), $method);
442 $button->class = 'continuebutton';
443 return $this->render($button);
446 * Print a backup files tree
447 * @param array $options
450 public function backup_files_viewer(array $options = null) {
451 $files = new backup_files_viewer($options);
452 return $this->render($files);
456 * Displays a backup files viewer
458 * @global stdClass $USER
459 * @param backup_files_viewer $tree
462 public function render_backup_files_viewer(backup_files_viewer $viewer) {
464 $files = $viewer->files;
466 $table = new html_table();
467 $table->attributes['class'] = 'backup-files-table generaltable';
468 $table->head = array(get_string('filename', 'backup'), get_string('time'), get_string('size'), get_string('download'), get_string('restore'));
469 $table->width = '100%';
470 $table->data = array();
472 foreach ($files as $file) {
473 if ($file->is_directory()) {
476 $fileurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename(), true);
478 $params['action'] = 'choosebackupfile';
479 $params['filename'] = $file->get_filename();
480 $params['filepath'] = $file->get_filepath();
481 $params['component'] = $file->get_component();
482 $params['filearea'] = $file->get_filearea();
483 $params['filecontextid'] = $file->get_contextid();
484 $params['contextid'] = $viewer->currentcontext->id;
485 $params['itemid'] = $file->get_itemid();
486 $restoreurl = new moodle_url('/backup/restorefile.php', $params);
487 $table->data[] = array(
488 $file->get_filename(),
489 userdate($file->get_timemodified()),
490 display_size($file->get_filesize()),
491 html_writer::link($fileurl, get_string('download')),
492 html_writer::link($restoreurl, get_string('restore')),
496 $html = html_writer::table($table);
497 $html .= $this->output->single_button(new moodle_url('/backup/backupfilesedit.php', array('currentcontext'=>$viewer->currentcontext->id, 'contextid'=>$viewer->filecontext->id, 'filearea'=>$viewer->filearea, 'component'=>$viewer->component, 'returnurl'=>$this->page->url->out())), get_string('managefiles', 'backup'), 'post');
503 * Renders a restore course search object
505 * @param restore_course_search $component
508 public function render_restore_course_search(restore_course_search $component) {
509 $url = $component->get_url();
511 $output = html_writer::start_tag('div', array('class' => 'restore-course-search'));
512 $output .= html_writer::start_tag('div', array('class' => 'rcs-results'));
514 $table = new html_table();
515 $table->head = array('', get_string('shortnamecourse'), get_string('fullnamecourse'));
516 $table->data = array();
517 if ($component->get_count() !== 0) {
518 foreach ($component->get_results() as $course) {
519 $row = new html_table_row();
520 $row->attributes['class'] = 'rcs-course';
521 if (!$course->visible) {
522 $row->attributes['class'] .= ' dimmed';
525 html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$course->id)),
526 format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
529 $table->data[] = $row;
531 if ($component->has_more_results()) {
532 $cell = new html_table_cell(get_string('moreresults', 'backup'));
534 $cell->attributes['class'] = 'notifyproblem';
535 $row = new html_table_row(array($cell));
536 $row->attributes['class'] = 'rcs-course';
537 $table->data[] = $row;
540 $cell = new html_table_cell(get_string('nomatchingcourses', 'backup'));
542 $cell->attributes['class'] = 'notifyproblem';
543 $row = new html_table_row(array($cell));
544 $row->attributes['class'] = 'rcs-course';
545 $table->data[] = $row;
547 $output .= html_writer::table($table);
548 $output .= html_writer::end_tag('div');
550 $output .= html_writer::start_tag('div', array('class'=>'rcs-search'));
551 $output .= html_writer::empty_tag('input', array('type'=>'text', 'name'=>restore_course_search::$VAR_SEARCH, 'value'=>$component->get_search()));
552 $output .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'searchcourses', 'value'=>get_string('search')));
553 $output .= html_writer::end_tag('div');
555 $output .= html_writer::end_tag('div');
560 * Renders an import course search object
562 * @param import_course_search $component
565 public function render_import_course_search(import_course_search $component) {
566 $url = $component->get_url();
568 $output = html_writer::start_tag('div', array('class' => 'import-course-search'));
569 if ($component->get_count() === 0) {
570 $output .= $this->output->notification(get_string('nomatchingcourses', 'backup'));
571 $output .= html_writer::end_tag('div');
575 $output .= html_writer::tag('div', get_string('totalcoursesearchresults', 'backup', $component->get_count()), array('class'=>'ics-totalresults'));
577 $output .= html_writer::start_tag('div', array('class' => 'ics-results'));
579 $table = new html_table();
580 $table->head = array('', get_string('shortnamecourse'), get_string('fullnamecourse'));
581 $table->data = array();
582 foreach ($component->get_results() as $course) {
583 $row = new html_table_row();
584 $row->attributes['class'] = 'ics-course';
585 if (!$course->visible) {
586 $row->attributes['class'] .= ' dimmed';
589 html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'importid', 'value'=>$course->id)),
590 format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))),
593 $table->data[] = $row;
595 $output .= html_writer::table($table);
596 $output .= html_writer::end_tag('div');
598 $output .= html_writer::start_tag('div', array('class'=>'ics-search'));
599 $output .= html_writer::empty_tag('input', array('type'=>'text', 'name'=>restore_course_search::$VAR_SEARCH, 'value'=>$component->get_search()));
600 $output .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'searchcourses', 'value'=>get_string('search')));
601 $output .= html_writer::end_tag('div');
603 $output .= html_writer::end_tag('div');
608 * Renders a restore category search object
610 * @param restore_category_search $component
613 public function render_restore_category_search(restore_category_search $component) {
614 $url = $component->get_url();
616 $output = html_writer::start_tag('div', array('class' => 'restore-course-search'));
617 $output .= html_writer::start_tag('div', array('class' => 'rcs-results'));
619 $table = new html_table();
620 $table->head = array('', get_string('name'), get_string('description'));
621 $table->data = array();
623 if ($component->get_count() !== 0) {
624 foreach ($component->get_results() as $category) {
625 $row = new html_table_row();
626 $row->attributes['class'] = 'rcs-course';
627 if (!$category->visible) {
628 $row->attributes['class'] .= ' dimmed';
631 html_writer::empty_tag('input', array('type'=>'radio', 'name'=>'targetid', 'value'=>$category->id)),
632 format_string($category->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $category->id))),
633 format_text($category->description, $category->descriptionformat, array('overflowdiv'=>true))
635 $table->data[] = $row;
637 if ($component->has_more_results()) {
638 $cell = new html_table_cell(get_string('moreresults', 'backup'));
639 $cell->attributes['class'] = 'notifyproblem';
641 $row = new html_table_row(array($cell));
642 $row->attributes['class'] = 'rcs-course';
643 $table->data[] = $row;
646 $cell = new html_table_cell(get_string('nomatchingcourses', 'backup'));
648 $cell->attributes['class'] = 'notifyproblem';
649 $row = new html_table_row(array($cell));
650 $row->attributes['class'] = 'rcs-course';
651 $table->data[] = $row;
653 $output .= html_writer::table($table);
654 $output .= html_writer::end_tag('div');
656 $output .= html_writer::start_tag('div', array('class'=>'rcs-search'));
657 $output .= html_writer::empty_tag('input', array('type'=>'text', 'name'=>restore_category_search::$VAR_SEARCH, 'value'=>$component->get_search()));
658 $output .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'searchcourses', 'value'=>get_string('search')));
659 $output .= html_writer::end_tag('div');
661 $output .= html_writer::end_tag('div');
667 * Data structure representing backup files viewer
669 * @copyright 2010 Dongsheng Cai
670 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
673 class backup_files_viewer implements renderable {
678 public $currentcontext;
681 * Constructor of backup_files_viewer class
682 * @param array $options
684 public function __construct(array $options = null) {
686 $fs = get_file_storage();
687 $this->currentcontext = $options['currentcontext'];
688 $this->filecontext = $options['filecontext'];
689 $this->component = $options['component'];
690 $this->filearea = $options['filearea'];
691 $files = $fs->get_area_files($this->filecontext->id, $this->component, $this->filearea, false, 'timecreated');
692 $this->files = array_reverse($files);