block_admin_display
Definition
block_admin_display()
modules/block.module, line 201
Description
Generate main block administration form.
Code
<?php
function block_admin_display() {
global $theme_key, $custom_theme;
// If non-default theme configuration has been selected, set the custom theme.
if (arg(3)) {
$custom_theme = arg(3);
}
else {
$custom_theme = variable_get('theme_default', 'bluemarine');
}
init_theme();
// Fetch and sort blocks
$blocks = _block_rehash();
usort($blocks, '_block_compare');
$throttle = module_exist('throttle');
$block_regions = system_region_list($theme_key);
// Build form tree
$form['#action'] = arg(3) ? url('admin/block/list/' . $theme_key) : url('admin/block');
$form['#tree'] = TRUE;
foreach ($blocks as $i => $block) {
$form[$i]['module'] = array('#type' => 'value', '#value' => $block['module']);
$form[$i]['delta'] = array('#type' => 'value', '#value' => $block['delta']);
$form[$i]['info'] = array('#value' => $block['info']);
$form[$i]['status'] = array('#type' => 'checkbox', '#default_value' => $block['status']);
$form[$i]['theme'] = array('#type' => 'hidden', '#value' => $theme_key);
$form[$i]['weight'] = array('#type' => 'weight', '#default_value' => $block['weight']);
$form[$i]['region'] = array('#type' => 'select',
'#default_value' => isset($block['region']) ? $block['region'] : system_default_region($theme_key),
'#options' => $block_regions,
);
if ($throttle) {
$form[$i]['throttle'] = array('#type' => 'checkbox', '#default_value' => $block['throttle']);
}
$form[$i]['configure'] = array('#value' => l(t('configure'), 'admin/block/configure/'. $block['module'] .'/'. $block['delta']));
if ($block['module'] == 'block') {
$form[$i]['delete'] = array('#value' => l(t('delete'), 'admin/block/delete/'. $block['delta']));
}
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save blocks'));
return drupal_get_form('block_admin_display', $form);
}
?> 