function redirect_404_list in Redirect 7.2
Same name and namespace in other branches
- 7 redirect.admin.inc \redirect_404_list()
1 string reference to 'redirect_404_list'
- redirect_menu in ./
redirect.module - Implements hook_menu().
File
- ./
redirect.admin.inc, line 761 - Administrative page callbacks for the redirect module.
Code
function redirect_404_list($form = NULL) {
$destination = drupal_get_destination();
// Get filter keys and add the filter form.
$keys = func_get_args();
// Offset the $form and $form_state parameters.
$keys = implode('/', $keys);
$build['redirect_list_404_filter_form'] = drupal_get_form('redirect_list_404_filter_form', $keys);
$header = array(
array(
'data' => t('Page'),
'field' => 'message',
),
array(
'data' => t('Count'),
'field' => 'count',
'sort' => 'desc',
),
array(
'data' => t('Last accessed'),
'field' => 'timestamp',
),
array(
'data' => t('Operations'),
),
);
// Filter on current domain with like in the queries.
global $base_url;
$count_query = db_select('watchdog', 'w');
$count_query
->addExpression('COUNT(DISTINCT(w.message))');
$count_query
->leftJoin('redirect', 'r', 'w.message = r.source');
$count_query
->condition('w.type', 'page not found');
$count_query
->condition('w.location', '%' . db_like($base_url) . '%', 'LIKE');
$count_query
->isNull('r.rid');
redirect_build_filter_query($count_query, array(
'w.message',
), $keys);
$query = db_select('watchdog', 'w')
->extend('PagerDefault')
->extend('TableSort');
$query
->fields('w', array(
'message',
'location',
));
$query
->addExpression('COUNT(wid)', 'count');
$query
->addExpression('MAX(timestamp)', 'timestamp');
$query
->leftJoin('redirect', 'r', 'w.message = r.source');
$query
->isNull('r.rid');
$query
->condition('w.type', 'page not found');
$query
->condition('w.location', '%' . db_like($base_url) . '%', 'LIKE');
$query
->groupBy('w.location');
$query
->orderByHeader($header);
$query
->limit(25);
redirect_build_filter_query($query, array(
'w.message',
), $keys);
$query
->setCountQuery($count_query);
$results = $query
->execute();
$rows = array();
foreach ($results as $result) {
$row = array();
$row['source'] = l($result->location, $result->location, array(
'query' => $destination,
));
$row['count'] = $result->count;
$row['timestamp'] = format_date($result->timestamp, 'short');
$operations = array();
if (redirect_access('create', 'redirect')) {
$operations['add'] = array(
'title' => t('Add redirect'),
'href' => 'admin/config/search/redirect/add/',
'query' => array(
'source' => $result->message,
) + $destination,
);
}
$row['operations'] = array(
'data' => array(
'#theme' => 'links',
'#links' => $operations,
'#attributes' => array(
'class' => array(
'links',
'inline',
'nowrap',
),
),
),
);
$rows[] = $row;
}
$build['redirect_404_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No 404 pages without redirects found.'),
);
$build['redirect_404_pager'] = array(
'#theme' => 'pager',
);
return $build;
}