Same name and namespace in other branches
  1. 4.6.x modules/block.module \block_admin_display()
  2. 5.x modules/block/block.module \block_admin_display()
  3. 6.x modules/block/block.admin.inc \block_admin_display()
  4. 7.x modules/block/block.admin.inc \block_admin_display()

Generate main block administration form.

1 string reference to 'block_admin_display'
block_menu in modules/block.module
Implementation of hook_menu().

File

modules/block.module, line 201
Controls the boxes that are displayed around the main content.

Code

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);
}