function antispam_block_view in AntiSpam 7
Implements hook_block_view().
File
- ./
antispam.module, line 1706 - Primary hook implementations for the Antispam module.
Code
function antispam_block_view($delta = '') {
$block_fields = _antispam_get_block_fields();
if ($delta >= 0 && $delta < variable_get('antispam_blocks_counter', 1)) {
$block_settings = variable_get('antispam_blocks_' . $delta, FALSE);
if (!$block_settings) {
$block_settings = array();
}
$block_args = array(
'content' => '',
'counter' => antispam_get_total_counter(ANTISPAM_COUNT_SPAM_DETECTED),
'since' => antispam_get_counting_since(),
'text' => '',
'image' => '',
// Completed below with current block settings.
'block' => array(
'delta' => $delta,
),
);
foreach ($block_fields as $field_key => $field_info) {
if (!isset($block_settings[$field_key])) {
$block_settings[$field_key] = $field_info['#default_value'];
}
$block_args['block'][$field_key] = $block_settings[$field_key];
}
$target = $block_settings['newwin'] ? ' target="_blank"' : '';
$sitename = $block_settings['sitename'] ? variable_get('site_name', 'drupal') : t('This site');
$block_args['text'] = array(
'plain' => t('@site_name is proudly protected by AntiSpam, !spams caught since @since.', array(
'@site_name' => $sitename,
'!spams' => format_plural($block_args['counter'], '1 spam', '@count spams'),
'@since' => $block_args['since'],
)),
'html' => t('@site_name is proudly protected by <a href="!antispam"@target>AntiSpam</a>, %spams caught since @since', array(
'@site_name' => $sitename,
'!antispam' => url('http://drupal.org/project/antispam'),
'@target' => $target,
'%spams' => format_plural($block_args['counter'], '1 spam', '@count spams'),
'@since' => $block_args['since'],
)),
);
$title_text = $block_args['text']['plain'];
$image_url = base_path() . drupal_get_path('module', 'antispam') . '/antispam.png';
$block_args['image'] = '<img src="' . $image_url . '" title="' . $title_text . '" alt="' . $title_text . '" />';
if ($block_settings['type'] == 'image') {
$block_args['content'] = '<a href="http://drupal.org/project/antispam" title="' . $title_text . '"' . $target . '>' . $block_args['image'] . '</a>';
}
else {
$block_args['content'] = $block_args['text']['html'];
}
$block = array();
$block['subject'] = t('AntiSpam spam counter');
$block['content'] = theme('antispam_counter_block', $block_args);
return $block;
}
}