function print_table($data) { $table = new html_table(); $table->head = array(get_string('lastcrawledtime', 'local_linkchecker_robot'), get_string('linktext', 'local_linkchecker_robot'), get_string('idattr', 'local_linkchecker_robot'), get_string('response', 'local_linkchecker_robot'), get_string('size', 'local_linkchecker_robot'), get_string('url', 'local_linkchecker_robot'), get_string('mimetype', 'local_linkchecker_robot')); $table->data = array(); foreach ($data as $row) { $text = trim($row->title); if (!$text || $text == "") { $text = get_string('unknown', 'local_linkchecker_robot'); } $code = local_linkchecker_robot_http_code($row); $size = $row->filesize * 1; $data = array(userdate($row->lastcrawled, '%h %e, %H:%M:%S'), $row->text, str_replace(' #', '<br>#', $row->idattr), $code, display_size($size), local_linkchecker_robot_link($row->target, $text, $row->redirect), $row->mimetype); $table->data[] = $data; } echo html_writer::table($table); }
$opts = array($bigfilesize * 1000000); $data = $DB->get_records_sql("SELECT concat(b.id, '-', a.id, '-', l.id) id,\n b.url target,\n b.filesize,\n b.lastcrawled,\n b.mimetype,\n l.text,\n a.title,\n a.url,\n a.redirect,\n a.courseid,\n c.shortname\n {$sql}\n ORDER BY b.filesize DESC,\n l.text,\n a.id", $opts, $start, $perpage); $count = $DB->get_field_sql("SELECT count(*) AS count" . $sql, $opts); $mdlw = strlen($CFG->wwwroot); $table = new html_table(); $table->head = array(get_string('lastcrawledtime', 'local_linkchecker_robot'), get_string('size', 'local_linkchecker_robot'), get_string('slowurl', 'local_linkchecker_robot'), get_string('mimetype', 'local_linkchecker_robot'), get_string('frompage', 'local_linkchecker_robot')); if (!$courseid) { array_push($table->head, get_string('course', 'local_linkchecker_robot')); } $table->data = array(); foreach ($data as $row) { $size = $row->filesize * 1; $text = trim($row->text); if (!$text || $text == "") { $text = get_string('missing', 'local_linkchecker_robot'); } $data = array(userdate($row->lastcrawled, '%h %e, %H:%M:%S'), display_size($size), local_linkchecker_robot_link($row->target, $text, $row->redirect), $row->mimetype, local_linkchecker_robot_link($row->url, $row->title, $row->redirect)); if (!$courseid) { array_push($data, html_writer::link('/course/view.php?id=' . $row->courseid, $row->shortname)); } $table->data[] = $data; } } } } } echo $OUTPUT->heading(get_string('numberurlsfound', 'local_linkchecker_robot', array('reports_number' => $count, 'repoprt_type' => $report))); echo get_string($report . '_header', 'local_linkchecker_robot'); echo html_writer::table($table); echo $OUTPUT->paging_bar($count, $page, $perpage, $baseurl); echo $OUTPUT->footer();