event_block
- Versions
- 5 – 6
event_block($op = 'list', $delta = 0)
Provides the blocks that this module is capable of displaying.
Parameters
$op the operation that is being requested. This defaults to 'list', which indicates that the method should return which blocks are available.
$delta the specific block to display. This is actually the offset into an array.
Return value
one of two possibilities. The first is an array of available blocks. The other is an array containing a block.
Related topics
Code
contrib/event/event.module, line 1952
<?php
function event_block($op = 'list', $delta = 0) {
switch ($op) {
case 'list' :
$blocks[0]['info'] = t('Calendar to browse events.');
$blocks[1]['info'] = t('List of upcoming events.');
$types = event_get_types('all') + event_get_types('solo');
foreach ($types as $type) {
$blocks["event-upcoming-$type"]['info'] = t('List of upcoming events for node type @name.', array('@name' => $type));
}
return $blocks;
break;
case 'view' :
if (user_access('access content')) {
event_include_files();
$type = '';
if (strpos($delta, 'event-upcoming-') === 0) {
$type = substr($delta, 15);
}
switch ($delta) {
case '0':
drupal_add_js(drupal_get_path('module', 'event') .'/eventblock.js');
drupal_add_js('misc/progress.js');
$date = _event_user_date();
if (arg(0) == 'event' && is_numeric(arg(1))) {
// follow event calendar
$date['year'] = (arg(1) ? arg(1) : $time['year']);
$date['month'] = (arg(2) ? arg(2) : $time['month']);
$date['day'] = (arg(3) ? arg(3) : $time['day']);
}
$block['subject'] = t('Events');
$block['content'] = event_calendar_month('block', $date);
return $block;
case '1':
$block['subject'] = t('Upcoming events');
$result = event_block_upcoming(variable_get('event_upcoming_limit', '6'));
$block['content'] = $result['content'];
return $block;
case 'event-upcoming-'. $type:
$result = event_block_upcoming(variable_get('event_upcoming_limit', '6'), array($type));
$block['subject'] = format_plural($result['count'], 'Upcoming @name', 'Upcoming @count @names', array('@name' => $type));
$block['content'] = $result['content'];
return $block;
}
}
break;
}
}
?>


