theme_block_admin_display

Versions
4.7 – 5
theme_block_admin_display($form)

Theme main block administration form submission.

Note: the blocks are already sorted in the right order, grouped by status, region and weight.

Code

modules/block.module, line 288

<?php
function theme_block_admin_display($form) {
  global $theme_key;

  $throttle = module_exist('throttle');
  $block_regions = system_region_list($theme_key);

  // Highlight regions on page to provide visual reference.
  foreach ($block_regions as $key => $value) {
    drupal_set_content($key, '<div class="block-region">' . $value . '</div>');
  }

  // Build rows
  $rows = array();
  $last_region = '';
  $last_status = 1;
  foreach (element_children($form) as $i) {
    $block = &$form[$i];
    // Only take form elements that are blocks.
    if (is_array($block['info'])) {
      // Fetch values
      $region = $block['region']['#default_value'];
      $status = $block['status']['#default_value'];

      // Output region header
      if ($status && $region != $last_region) {
        $region_title = t('%region', array('%region' => drupal_ucfirst($block_regions[$region])));
        $rows[] = array(array('data' => $region_title, 'class' => 'region', 'colspan' => ($throttle ? 7 : 6)));
        $last_region = $region;
      }
      // Output disabled header
      elseif ($status != $last_status) {
        $rows[] = array(array('data' => t('Disabled'), 'class' => 'region', 'colspan' => ($throttle ? 7 : 6)));
        $last_status = $status;
      }

      // Generate block row
      $row = array(
        array('data' => form_render($block['info']), 'class' => 'block'),
        form_render($block['status']) . form_render($block['theme']),
        form_render($block['weight']),
        form_render($block['region'])
      );
      if ($throttle) {
        $row[] = form_render($block['throttle']);
      }
      $row[] = form_render($block['configure']);
      $row[] = $block['delete'] ? form_render($block['delete']) : '';
      $rows[] = $row;
    }
  }

  // Finish table
  $header = array(t('Block'), t('Enabled'), t('Weight'), t('Placement'));
  if ($throttle) {
    $header[] = t('Throttle');
  }
  $header[] = array('data' => t('Operations'), 'colspan' => 2);

  $output = theme('table', $header, $rows, array('id' => 'blocks'));
  $output .= form_render($form['submit']);
  $output .= form_render($form);
  return $output;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.