function event_block in Event 5
Same name and namespace in other branches
- 5.2 event.module \event_block()
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
File
- ./
event.module, line 1764
Code
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.');
return $blocks;
break;
case 'view':
if (user_access('access content')) {
switch ($delta) {
case 0:
drupal_add_js(drupal_get_path('module', 'event') . '/eventblock.js');
drupal_add_js('misc/progress.js');
$time = _event_user_date();
if (arg(0) == 'event' && is_numeric(arg(1))) {
// follow event calendar
$year = arg(1) ? arg(1) : gmdate('Y', $time);
$month = arg(2) ? arg(2) : gmdate('m', $time);
$day = arg(3) ? arg(3) : gmdate('d', $time);
$stamp = gmmktime(0, 0, 0, $month, $day, $year);
}
else {
$stamp = _event_user_date();
}
$block['subject'] = t('Events');
$block['content'] = event_calendar_month('block', $stamp);
return $block;
case 1:
$block['subject'] = t('Upcoming events');
$block['content'] = event_block_upcoming(variable_get('event_upcoming_limit', '6'));
return $block;
}
}
if (event_is_enabled($node->type)) {
$length = strlen(ical_export(_event_node_ical($node), $node->title));
return array(
array(
'key' => 'enclosure',
'attributes' => array(
'url' => url('node/' . $node->nid . '/ical', NULL, NULL, TRUE),
'length' => $length,
'type' => 'text/calendar',
),
),
);
}
break;
}
}