function linkchecker_admin_report in Link checker 5.2
Menu callback for reporting.
1 string reference to 'linkchecker_admin_report'
- linkchecker_menu in ./
linkchecker.module - Implementation of hook_menu().
File
- ./
linkchecker.module, line 419 - This module periodically check links in given node types, blocks, cck fields, etc.
Code
function linkchecker_admin_report() {
$header = array(
array(
'data' => t('URL'),
'field' => 'url',
'sort' => 'desc',
),
array(
'data' => t('Response'),
'field' => 'code',
'sort' => 'desc',
),
array(
'data' => t('Error'),
'field' => 'error',
),
array(
'data' => t('Operations'),
),
);
$ignore_response_codes = preg_split('/(\\r\\n?|\\n)/', variable_get('linkchecker_ignore_response_codes', "200\n302\n304\n401\n403"));
$placeholders = implode(',', array_fill(0, count($ignore_response_codes), '%d'));
$links_report_sql = "SELECT ll.*\n FROM {linkchecker_links} ll\n INNER JOIN (\n SELECT lid FROM (\n SELECT DISTINCT lid FROM {linkchecker_boxes}\n UNION\n SELECT DISTINCT lid FROM {linkchecker_comments}\n UNION\n SELECT DISTINCT lid FROM {linkchecker_nodes}\n ) q1\n ) q2 ON q2.lid = ll.lid\n WHERE ll.last_checked <> %d AND ll.status = %d AND ll.code NOT IN (" . $placeholders . ")";
$result = pager_query($links_report_sql . tablesort_sql($header), 50, 0, NULL, array_merge(array(
0,
1,
), $ignore_response_codes));
$rows = array();
while ($link = db_fetch_object($result)) {
$links = array();
// Show links to link settings.
if (user_access('edit link settings')) {
$links[] = l(t('Edit link settings'), 'linkchecker/' . $link->lid . '/edit', array(), 'destination=admin/logs/linkchecker');
}
// Show link to nodes having this broken link.
$nodes = db_query('SELECT nid FROM {linkchecker_nodes} WHERE lid = %d', $link->lid);
while ($node = db_fetch_object($nodes)) {
$links[] = l(t('Edit node @node', array(
'@node' => $node->nid,
)), 'node/' . $node->nid . '/edit', array(), 'destination=admin/logs/linkchecker');
}
// Show link to comments having this broken link.
$comments = db_query('SELECT cid FROM {linkchecker_comments} WHERE lid = %d', $link->lid);
while ($comment = db_fetch_object($comments)) {
$links[] = l(t('Edit comment @comment', array(
'@comment' => $comment->cid,
)), 'comment/edit/' . $comment->cid, array(), 'destination=admin/logs/linkchecker');
}
// Show link to blocks having this broken link.
$boxes = db_query('SELECT bid FROM {linkchecker_boxes} WHERE lid = %d', $link->lid);
while ($box = db_fetch_object($boxes)) {
$links[] = l(t('Edit block @block', array(
'@block' => $box->bid,
)), 'admin/build/block/configure/block/' . $box->bid, array(), 'destination=admin/logs/linkchecker');
}
// Create table data for output.
$rows[] = array(
l(_filter_url_trim($link->url, 40), $link->url),
$link->code,
check_plain($link->error),
theme('item_list', $links),
);
}
if (empty($rows)) {
$rows[] = array(
array(
'data' => t('No broken links have been found.'),
'colspan' => count($header),
),
);
}
$output = theme('table', $header, $rows);
$output .= theme('pager', NULL, 3000, 0);
return $output;
}