You are here

function block_admin_display in Drupal 5

Same name and namespace in other branches
  1. 4 modules/block.module \block_admin_display()
  2. 6 modules/block/block.admin.inc \block_admin_display()
  3. 7 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/block.module
Implementation of hook_menu().

File

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

Code

function block_admin_display($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.
  if ($theme) {
    $custom_theme = $theme;
  }
  else {
    $custom_theme = variable_get('theme_default', 'garland');
  }
  init_theme();

  // Fetch and sort blocks
  $blocks = _block_rehash();
  usort($blocks, '_block_compare');
  $throttle = module_exists('throttle');
  $block_regions = array(
    BLOCK_REGION_NONE => '<' . t('none') . '>',
  ) + system_region_list($theme_key);

  // Build form tree
  $form['#action'] = arg(3) ? url('admin/build/block/list/' . $theme_key) : url('admin/build/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' => check_plain($block['info']),
    );
    $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' => $block['status'] ? isset($block['region']) ? $block['region'] : system_default_region($theme_key) : BLOCK_REGION_NONE,
      '#options' => $block_regions,
    );
    if ($throttle) {
      $form[$i]['throttle'] = array(
        '#type' => 'checkbox',
        '#default_value' => $block['throttle'],
      );
    }
    $form[$i]['configure'] = array(
      '#value' => l(t('configure'), 'admin/build/block/configure/' . $block['module'] . '/' . $block['delta']),
    );
    if ($block['module'] == 'block') {
      $form[$i]['delete'] = array(
        '#value' => l(t('delete'), 'admin/build/block/delete/' . $block['delta']),
      );
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save blocks'),
  );
  return $form;
}