function homebox_admin_display_form in Homebox 6
Same name and namespace in other branches
- 6.3 homebox.admin.inc \homebox_admin_display_form()
- 6.2 homebox.admin.inc \homebox_admin_display_form()
- 7.3 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 259 - Home box admin file, takes care admin interface for homebox
Code
function homebox_admin_display_form(&$form_state, $blocks, $pid, $theme = NULL) {
global $theme_key, $custom_theme;
// Add CSS
drupal_add_css(drupal_get_path('module', 'block') . '/block.css', 'module', 'all', FALSE);
// If non-default theme configuration has been selected, set the custom theme.
$custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
$columns = homebox_named_columns($pid);
$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'];
$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,
);
// Get default region/column for block
$column = db_result(db_query("SELECT region FROM {homebox_default} WHERE bid = %d AND pid = %d", $block['bid'], $pid));
// If not set assign to <none>
$column = $column != 0 ? $column : HOMEBOX_REGION_NONE;
$form[$key]['region'] = array(
'#type' => 'select',
'#default_value' => $column,
'#options' => $block_regions,
);
$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]['bid'] = array(
'#type' => 'hidden',
'#value' => $block['bid'],
);
}
$form['pid'] = array(
'#type' => 'hidden',
'#value' => $pid,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save blocks'),
);
return $form;
}