function mostpopular_form_block_admin_configure_alter in Drupal Most Popular 7
Implements form_FORM_ID_alter().
Adds extra properties to the block configuration form.
_state
Parameters
array $form:
File
- ./
mostpopular.blocks.inc, line 255 - Provides an admin GUI for configuring most popular blocks.
Code
function mostpopular_form_block_admin_configure_alter(&$form, &$form_state) {
if ($form['module']['#value'] == 'mostpopular') {
$delta = $form['delta']['#value'];
$block = mostpopular_blocks($delta);
if ($block) {
$form_state['mostpopular_block'] = $block;
// Assign weights to each of the existing components
$form['title']['#weight'] = 0;
$form['regions']['#weight'] = 10;
$form['visibility_title']['#weight'] = 30;
$form['visibility']['#weight'] = 31;
$form['actions']['#weight'] = 40;
$form['mostpopular'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => t('Most Popular settings'),
'#weight' => 20,
'data' => array(
'#tree' => TRUE,
'#weight' => 10,
'show_count' => array(
'#type' => 'checkbox',
'#title' => t('Show item counts'),
'#description' => t('Should the number of times each item appears be displayed in the Most Popular block?'),
'#default_value' => isset($block->data['show_count']) ? $block->data['show_count'] : FALSE,
),
),
);
if (empty($block->remote_bid)) {
$form['mostpopular']['count'] = array(
'#type' => 'textfield',
'#title' => t('Max Results'),
'#description' => t('The number of results to display in this block'),
'#default_value' => $block->count,
'#size' => 3,
'#required' => TRUE,
'#element_validate' => array(
'mostpopular_blocks_validate_count',
),
'#weight' => 1,
);
}
else {
$block->data += array(
'remote_database' => 'default',
);
global $databases;
$options = array();
foreach ($databases as $db => $data) {
$options[$db] = $db;
}
$form['mostpopular']['data']['remote_database'] = array(
'#type' => 'radios',
'#title' => t('Database'),
'#description' => t('Choose a database that will be used to lookup the most popular records.'),
'#options' => $options,
'#required' => TRUE,
'#default_value' => check_plain($block->data['remote_database']),
);
$form['mostpopular']['remote_bid'] = array(
'#type' => 'textfield',
'#title' => t('Remote Block ID'),
'#description' => t('The ID of the block in the Remote database. That block\'s services, intervals and cached items will be displayed on this site.'),
'#required' => TRUE,
'#size' => 5,
'#default_value' => check_plain($block->remote_bid),
'#weight' => 11,
);
}
}
}
}