function feedapi_admin_overview in FeedAPI 5
Same name and namespace in other branches
- 6 feedapi.admin.inc \feedapi_admin_overview()
Provide a UI for overviewing the existing feeds
1 string reference to 'feedapi_admin_overview'
- feedapi_menu in ./
feedapi.module - Implementation of hook_menu().
File
- ./
feedapi.module, line 665 - Handle the submodules (for feed and item processing) Provide a basic management of feeds
Code
function feedapi_admin_overview() {
$header = array(
t('Title'),
t('Last refresh'),
t('New items added per update'),
t('Update rate'),
t('Number of items'),
t('Processing time'),
t('Commands'),
);
$rows = array();
$result = pager_query("SELECT nid from {feedapi} ORDER BY checked DESC", 50, 0, "SELECT count(*) FROM {feedapi}");
while ($nid = db_fetch_array($result)) {
$node = node_load($nid['nid']);
$commands = array(
l(t('Delete'), 'node/' . $node->nid . '/delete', NULL, 'destination=admin/content/feed'),
l(t('Remove items'), 'node/' . $node->nid . '/purge', NULL, 'destination=admin/content/feed'),
l(t('Refresh'), 'node/' . $node->nid . '/refresh', NULL, 'destination=admin/content/feed'),
l(t('Edit'), 'node/' . $node->nid . '/edit', NULL, 'destination=admin/content/feed'),
);
// Fetch statistics for this feed
foreach (array(
'download_num',
'new',
'process_time',
'update_times',
) as $type) {
$node->feed->statistics[$type] = _feedapi_get_stat($node->nid, $type, TRUE);
}
if (count($node->feed->statistics['download_num']) != 0 && count($node->feed->statistics['new']) != 0 && count($node->feed->statistics['process_time']) != 0) {
$update_rate = _feedapi_update_rate($node->feed->statistics['update_times']);
$rows[] = array(
l($node->title, "node/{$node->nid}"),
$node->feed->checked == 0 ? t('Never') : t('%time ago', array(
'%time' => format_interval(time() - $node->feed->checked),
)),
round(array_sum($node->feed->statistics['new']) / count($node->feed->statistics['new']), 2),
is_numeric($update_rate) ? format_interval($update_rate) : $update_rate,
round(array_sum($node->feed->statistics['download_num']) / count($node->feed->statistics['download_num']), 2),
round(array_sum($node->feed->statistics['process_time']) / count($node->feed->statistics['process_time']), 2) . ' ' . t('ms'),
theme('item_list', $commands),
);
}
else {
$rows[] = array(
l($node->title, "node/{$node->nid}"),
$node->feed->checked == 0 ? t('Never') : t('%time ago', array(
'%time' => format_interval(time() - $node->feed->checked),
)),
'',
'',
t('No enough data for statistics'),
'',
theme('item_list', $commands),
);
}
}
$output = format_plural(round(FEEDAPI_CRON_STAT_LIFETIME / (24 * 3600)), "Average over the last day.", "Averages over the last @count days.");
$output .= theme('table', $header, $rows);
$output .= theme('pager', 0, 50);
return $output;
}