public function render_import_course_search(import_course_search $component)
 {
     $output = '';
     if ($component->get_count() === 0) {
         $output .= bootstrap::alert_error(get_string('nomatchingcourses', 'backup'));
         $output .= html_writer::empty_tag('input', array('type' => 'text', 'name' => restore_course_search::$VAR_SEARCH, 'value' => $component->get_search()));
         $output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'searchcourses', 'value' => get_string('search')));
         return $output;
     }
     $output .= html_writer::tag('div', get_string('totalcoursesearchresults', 'backup', $component->get_count()), array('class' => 'ics-totalresults'));
     $table = new html_table();
     $table->attributes['class'] = 'table table-striped table-hover';
     $table->head = array('', get_string('shortnamecourse'), get_string('fullnamecourse'));
     $table->data = array();
     foreach ($component->get_results() as $course) {
         $row = new html_table_row();
         $row->attributes['class'] = 'ics-course';
         if (!$course->visible) {
             $row->attributes['class'] .= ' muted';
         }
         $row->cells = array(html_writer::empty_tag('input', array('type' => 'radio', 'name' => 'importid', 'value' => $course->id)), format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))), format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))));
         $table->data[] = $row;
     }
     $output .= html_writer::table($table);
     $output .= html_writer::empty_tag('input', array('type' => 'text', 'name' => restore_course_search::$VAR_SEARCH, 'value' => $component->get_search()));
     $output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'searchcourses', 'value' => get_string('search')));
     $output .= html_writer::end_tag('div');
     return $output;
 }
 public function notification($message, $classes = 'notifyproblem')
 {
     $message = clean_text($message);
     if ($classes == 'notifyproblem') {
         return bootstrap::alert_error($message);
     }
     if ($classes == 'notifysuccess') {
         return bootstrap::alert_success($message);
     }
     if ($classes == 'notifymessage') {
         return bootstrap::alert_info($message);
     }
     if ($classes == 'notifymessage') {
         return bootstrap::alert_default($message);
     }
     if ($classes == 'redirectmessage') {
         return bootstrap::alert_block_info($message);
     }
     return bootstrap::alert_default($message);
 }
 public function environment_check_table($result, $environment_results)
 {
     global $CFG;
     $servertable = new html_table();
     $servertable->head = array(get_string('name'), get_string('info'), get_string('report'), get_string('status'));
     $servertable->attributes['class'] = 'table table-striped table-hover';
     $serverdata = array('success' => array(), 'warning' => array(), 'important' => array());
     $othertable = new html_table();
     $othertable->head = array(get_string('info'), get_string('report'), get_string('status'));
     $othertable->attributes['class'] = 'table table-striped table-hover';
     $otherdata = array('success' => array(), 'warning' => array(), 'important' => array());
     // Iterate over each environment_result
     $continue = true;
     foreach ($environment_results as $environment_result) {
         $errorline = false;
         $warningline = false;
         $stringtouse = '';
         if ($continue) {
             $type = $environment_result->getPart();
             $info = $environment_result->getInfo();
             $status = $environment_result->getStatus();
             $error_code = $environment_result->getErrorCode();
             // Process Report field
             $rec = new stdClass();
             // Something has gone wrong at parsing time
             if ($error_code) {
                 $stringtouse = 'environmentxmlerror';
                 $rec->error_code = $error_code;
                 $status = get_string('error');
                 $errorline = true;
                 $continue = false;
             }
             if ($continue) {
                 if ($rec->needed = $environment_result->getNeededVersion()) {
                     // We are comparing versions
                     $rec->current = $environment_result->getCurrentVersion();
                     if ($environment_result->getLevel() == 'required') {
                         $stringtouse = 'environmentrequireversion';
                     } else {
                         $stringtouse = 'environmentrecommendversion';
                     }
                 } else {
                     if ($environment_result->getPart() == 'custom_check') {
                         // We are checking installed & enabled things
                         if ($environment_result->getLevel() == 'required') {
                             $stringtouse = 'environmentrequirecustomcheck';
                         } else {
                             $stringtouse = 'environmentrecommendcustomcheck';
                         }
                     } else {
                         if ($environment_result->getPart() == 'php_setting') {
                             if ($status) {
                                 $stringtouse = 'environmentsettingok';
                             } else {
                                 if ($environment_result->getLevel() == 'required') {
                                     $stringtouse = 'environmentmustfixsetting';
                                 } else {
                                     $stringtouse = 'environmentshouldfixsetting';
                                 }
                             }
                         } else {
                             if ($environment_result->getLevel() == 'required') {
                                 $stringtouse = 'environmentrequireinstall';
                             } else {
                                 $stringtouse = 'environmentrecommendinstall';
                             }
                         }
                     }
                 }
                 // Calculate the status value
                 if ($environment_result->getBypassStr() != '') {
                     //Handle bypassed result (warning)
                     $status = get_string('bypassed');
                     $warningline = true;
                 } else {
                     if ($environment_result->getRestrictStr() != '') {
                         //Handle restricted result (error)
                         $status = get_string('restricted');
                         $errorline = true;
                     } else {
                         if ($status) {
                             //Handle ok result (ok)
                             $status = get_string('ok');
                         } else {
                             if ($environment_result->getLevel() == 'optional') {
                                 //Handle check result (warning)
                                 $status = get_string('check');
                                 $warningline = true;
                             } else {
                                 //Handle error result (error)
                                 $status = get_string('check');
                                 $errorline = true;
                             }
                         }
                     }
                 }
             }
             // Build the text
             $linkparts = array();
             $linkparts[] = 'admin/environment';
             $linkparts[] = $type;
             if (!empty($info)) {
                 $linkparts[] = $info;
             }
             if (empty($CFG->docroot)) {
                 $report = get_string($stringtouse, 'admin', $rec);
             } else {
                 $report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));
             }
             // Format error or warning line
             if ($errorline || $warningline) {
                 $messagetype = $errorline ? 'important' : 'warning';
             } else {
                 $messagetype = 'success';
             }
             $status = label::make($messagetype, $status);
             // Here we'll store all the feedback found
             $feedbacktext = '';
             // Append the feedback if there is some
             $feedbacktext .= $environment_result->strToReport($environment_result->getFeedbackStr(), 'alert alert-' . $messagetype);
             //Append the bypass if there is some
             $feedbacktext .= $environment_result->strToReport($environment_result->getBypassStr(), 'alert');
             //Append the restrict if there is some
             $feedbacktext .= $environment_result->strToReport($environment_result->getRestrictStr(), 'alert alert-important');
             $report .= $feedbacktext;
             // Add the row to the table
             if ($environment_result->getPart() == 'custom_check') {
                 $otherdata[$messagetype][] = array($info, $report, $status);
             } else {
                 $serverdata[$messagetype][] = array($type, $info, $report, $status);
             }
         }
     }
     $servertable->data = array_merge($serverdata['important'], $serverdata['warning'], $serverdata['success']);
     $othertable->data = array_merge($otherdata['important'], $otherdata['warning'], $otherdata['success']);
     $output = $this->heading(get_string('serverchecks', 'admin'));
     $output .= html_writer::table($servertable);
     if (count($othertable->data)) {
         $output .= $this->heading(get_string('customcheck', 'admin'));
         $output .= html_writer::table($othertable);
     }
     // Finally, if any error has happened, print the summary box.
     if (!$result) {
         $output .= bootstrap::alert_error(get_string('environmenterrortodo', 'admin'));
     }
     return $output;
 }