function block_refresh_form_alter in Block Refresh 5
Same name and namespace in other branches
- 8 block_refresh.module \block_refresh_form_alter()
- 7.2 block_refresh.module \block_refresh_form_alter()
Add a 'Block Refresh' settings fieldset to the block admin form
File
- ./
block_refresh.module, line 10
Code
function block_refresh_form_alter($form_id, &$form) {
if ($form_id == 'block_admin_configure') {
$settings = variable_get('block_refresh_settings', array());
$form['#submit']['block_refresh_submit'] = array();
$form['block_refresh'] = array(
'#type' => 'fieldset',
'#title' => t('Block refresh settings'),
'#collapsible' => true,
'#weight' => -5,
);
$form['block_refresh']['block_refresh_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Enable block autorefresh'),
'#description' => t('If checked, then the content of this block may be autorefreshed automatically on a timer.'),
'#default_value' => isset($settings['block-' . $form['module']['#value'] . '-' . $form['delta']['#value']]['enabled']) ? $settings['block-' . $form['module']['#value'] . '-' . $form['delta']['#value']]['enabled'] : variable_get('block_refresh_autorefresh_default_enable', BLOCK_REFRESH_AUTOREFRESH_DEFAULT_ENABLE),
);
$form['block_refresh']['block_refresh_manual'] = array(
'#type' => 'checkbox',
'#title' => t('Enable block manual refresh'),
'#description' => t('If checked, then the content of this block may be refreshed manually by the user, by clicking on a provided (themeable) button in the block\'s subject header.'),
'#default_value' => isset($settings['block-' . $form['module']['#value'] . '-' . $form['delta']['#value']]['manual']) ? $settings['block-' . $form['module']['#value'] . '-' . $form['delta']['#value']]['manual'] : variable_get('block_refresh_manual_refresh_default_enable', BLOCK_REFRESH_AUTOREFRESH_DEFAULT_MANUAL),
);
$form['block_refresh']['block_refresh_group'] = array(
'#type' => 'checkbox',
'#title' => t('Group with other refreshing blocks'),
'#description' => t('If checked, then this block will be refreshed with other blocks. If also set to autorefresh, then the timer setting will be ignored, instead using the global setting of @seconds.', array(
'@seconds' => format_plural(variable_get('block_refresh_group_auto_timer', BLOCK_REFRESH_AUTOREFRESH_DEFAULT_TIMER), '1 second', '@count seconds'),
)),
'#default_value' => isset($settings['block-' . $form['module']['#value'] . '-' . $form['delta']['#value']]['group']) ? $settings['block-' . $form['module']['#value'] . '-' . $form['delta']['#value']]['group'] : variable_get('block_refresh_group_auto', TRUE),
);
$form['block_refresh']['block_refresh_timer'] = array(
'#type' => 'textfield',
'#title' => t('Block refresh timer'),
'#description' => t('Assuming that Blox Autorefresh is enabled, then the content of this block will refresh itself periodically, every number of seconds equal to this setting. If this block is grouped to refresh with other blocks, then this setting will be ignored, instaed using the global setting of @seconds.', array(
'@seconds' => format_plural(variable_get('block_refresh_group_auto_timer', BLOCK_REFRESH_AUTOREFRESH_DEFAULT_TIMER), '1 second', '@count seconds'),
)),
'#default_value' => $settings['block-' . $form['module']['#value'] . '-' . $form['delta']['#value']]['timer'] ? $settings['block-' . $form['module']['#value'] . '-' . $form['delta']['#value']]['timer'] : variable_get('block_refresh_autorefresh_default_timer', BLOCK_REFRESH_AUTOREFRESH_DEFAULT_TIMER),
);
}
}