block_admin_display
- Versions
- 4.6 – 4.7
block_admin_display()- 5 – 7
block_admin_display($theme = NULL)
Prepare the main block administration form.
Code
modules/block.module, line 183
<?php
function block_admin_display() {
$blocks = _block_rehash();
$header = array(t('Block'), t('Enabled'), t('Weight'), t('Sidebar'));
if (module_exist('throttle')) {
$header[] = t('Throttle');
}
$header[] = array('data' => t('Operations'), 'colspan' => 2);
$left = array();
$right = array();
$disabled = array();
foreach ($blocks as $block) {
if ($block['module'] == 'block') {
$delete = l(t('delete'), 'admin/block/delete/'. $block['delta']);
}
else {
$delete = '';
}
$row = array(array('data' => $block['info'], 'class' => 'block'),
form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']),
form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']),
form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'],
array(t('left'), t('right'))));
if (module_exist('throttle')) {
$row[] = form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle']);
}
$row[] = l(t('configure'), 'admin/block/configure/'. $block['module'] .'/'. $block['delta']);
$row[] = $delete;
if ($block['status']) {
if ($block['region'] == 0) {
$left[] = $row;
}
if ($block['region'] == 1) {
$right[] = $row;
}
}
else if ($block['region'] <= 1) {
$disabled[] = $row;
}
}
$rows = array();
if (count($left)) {
$rows[] = array(array('data' => t('Left sidebar'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
$rows = array_merge($rows, $left);
}
if (count($right)) {
$rows[] = array(array('data' => t('Right sidebar'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
$rows = array_merge($rows, $right);
}
if (count($disabled)) {
$rows[] = array(array('data' => t('Disabled'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
$rows = array_merge($rows, $disabled);
}
$output = theme('table', $header, $rows, array('id' => 'blocks'));
$output .= form_submit(t('Save blocks'));
return form($output, 'post', url('admin/block'));
}
?>Login or register to post comments 