function archive_block in Archive 5
Same name and namespace in other branches
- 6 archive.module \archive_block()
Implementation of hook_block().
File
- ./
archive.module, line 441
Code
function archive_block($op = 'list', $delta = 0, $edit = array()) {
if ($op == 'list') {
$blocks = array(
array(
'info' => t('Archive calendar'),
),
array(
'info' => t('Archive months'),
),
);
return $blocks;
}
else {
if ($op == 'view') {
switch ($delta) {
case 0:
drupal_add_css(drupal_get_path('module', 'archive') . '/archive.css');
$block = array(
'subject' => t('Archives'),
'content' => theme('archive_block_calendar', time()),
);
break;
case 1:
$block = array(
'subject' => t('Archives'),
'content' => theme('archive_month_list', archive_month_list()),
);
break;
}
return $block;
}
else {
if ($op == 'configure') {
if ($delta == 1) {
$form['archive_block_months'] = array(
'#type' => 'select',
'#title' => t('Maximum number of months to display'),
'#default_value' => variable_get('archive_block_months', 6),
'#options' => array(
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
8 => 8,
9 => 9,
10 => 10,
),
);
return $form;
}
}
else {
if ($op == 'save') {
if ($delta == 1) {
variable_set('archive_block_months', $edit['archive_block_months']);
}
}
}
}
}
}