Implements hook_block_view().
function statistics_block_view($delta = '') {
if (user_access('access content')) {
$content = array();
$config = config('statistics.settings');
$daytop = $config
->get('block.popular.top_day_limit');
if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
$content['top_day'] = $node_title_list;
$content['top_day']['#suffix'] = '<br />';
}
$alltimetop = $config
->get('block.popular.top_all_limit');
if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
$content['top_all'] = $node_title_list;
$content['top_all']['#suffix'] = '<br />';
}
$lasttop = $config
->get('block.popular.top_recent_limit');
if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
$content['top_last'] = $node_title_list;
$content['top_last']['#suffix'] = '<br />';
}
if (count($content)) {
$block['content'] = $content;
$block['subject'] = t('Popular content');
return $block;
}
}
}