function homebox_admin_display_form in Homebox 7.3
Same name and namespace in other branches
- 6.3 homebox.admin.inc \homebox_admin_display_form()
- 6 homebox.admin.inc \homebox_admin_display_form()
- 6.2 homebox.admin.inc \homebox_admin_display_form()
- 7.2 homebox.admin.inc \homebox_admin_display_form()
Generate main blocks administration form.
1 string reference to 'homebox_admin_display_form'
- homebox_layout in ./
homebox.admin.inc - Form builder function for module settings.
File
- ./
homebox.admin.inc, line 434 - Homebox admin file, takes care admin interface for homebox
Code
function homebox_admin_display_form($form, &$form_state, $blocks, $page) {
drupal_add_css(drupal_get_path('module', 'block') . '/block.css', array(
'preprocess' => FALSE,
));
$columns = homebox_named_columns($page->settings['regions']);
$block_regions = $columns + array(
HOMEBOX_REGION_NONE => '<' . t('none') . '>',
);
// Weights range from -delta to +delta, so delta should be at least half
// of the amount of blocks present. This makes sure all blocks in the same
// region get an unique weight.
$weight_delta = round(count($blocks) / 2);
// Build form tree
$form = array(
'#tree' => TRUE,
);
// Iterate on each block
foreach ($blocks as $i => $block) {
$key = $block['module'] . '_' . $block['delta'];
// Get default region/column for block
if (isset($page->settings['blocks'][$key]['region'])) {
$column = $page->settings['blocks'][$key]['region'];
}
else {
// Skip not configured blocks to not have an excessive long list of
// blocks.
$disabled_options[$key] = $block['info'];
continue;
}
$form[$key]['module'] = array(
'#type' => 'value',
'#value' => $block['module'],
);
$form[$key]['delta'] = array(
'#type' => 'value',
'#value' => $block['delta'],
);
$form[$key]['info'] = array(
'#value' => check_plain($block['info']),
);
$form[$key]['weight'] = array(
'#type' => 'weight',
'#default_value' => $block['weight'],
'#delta' => $weight_delta,
);
$form[$key]['region'] = array(
'#type' => 'select',
'#default_value' => $column,
'#options' => $block_regions,
);
$form[$key]['title'] = array(
'#type' => 'textfield',
'#default_value' => $block['title'],
'#size' => 15,
);
$form[$key]['status'] = array(
'#type' => 'checkbox',
'#default_value' => $block['status'],
);
$form[$key]['open'] = array(
'#type' => 'checkbox',
'#default_value' => $block['open'],
);
$form[$key]['movable'] = array(
'#type' => 'checkbox',
'#default_value' => $block['movable'],
);
$form[$key]['closable'] = array(
'#type' => 'checkbox',
'#default_value' => $block['closable'],
);
$form[$key]['bid'] = array(
'#type' => 'value',
'#value' => $block['bid'],
);
}
$form['enable_block'] = array(
'#type' => 'select',
'#title' => t('Enable block'),
'#options' => array(
0 => t('- None -'),
) + $disabled_options,
);
$form['name'] = array(
'#type' => 'value',
'#value' => $page->name,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save blocks'),
);
return $form;
}