1 block.admin.inc block_admin_list()

Page callback; Display a list of all custom blocks.

File

core/modules/block/block.admin.inc, line 10
Admin page callbacks for the Block module.

Code

function block_admin_list() {
  $custom_blocks_info = block_block_info();

  $help_text = array(
    '#theme' => 'help',
    '#markup' => t('These blocks are available to be placed in any layout in the <a href="@link">Layouts</a> page.', array('@link' => url('admin/structure/layouts'))),
  );

  $header = array(
    t('Block'),
    array('data' => t('Description'), 'class' => array('priority-low')),
    t('Operations'),
  );

  $rows = array();
  foreach ($custom_blocks_info as $delta => $block_info) {
    $block = block_custom_block_load($delta);
    $row = array();
    $row[] = theme('label_machine_name__block', array(
      'label' => $block_info['info'],
      'machine_name' => $delta,
    ));
    $row[] = filter_xss($block_info['description']);
    $links = array();
    $links['configure'] = array(
      'title' => t('Configure'),
      'href' => 'admin/structure/block/manage/' . $delta . '/configure',
    );
    $links['delete'] = array(
      'title' => t('Delete'),
      'href' => 'admin/structure/block/manage/' . $delta . '/delete',
    );
    if (module_exists('locale') && $block['default_langcode'] != LANGUAGE_NONE) {
      $links['translate'] = array(
        'title' => t('Translate'),
        'href' => 'admin/structure/block/manage/' . $delta . '/translation',
      );
    }
    if (module_exists('config') && user_access('synchronize configuration')) {
      $links['export'] = array(
        'title' => t('Export'),
        'href' => 'admin/config/development/configuration/single/export',
        'query' => array(
          'group' => 'Custom Blocks',
          'name' => 'block.custom.' . $delta,
        ),
      );
    }
    $operations = array(
      '#type' => 'operations',
      '#links' => $links,
    );
    $row[] = array('data' => $operations);

    $rows[] = $row;
  }

  $block_admin_list = array(
    '#theme' => 'table__block_admin_list',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No custom blocks have been created yet.'),
  );

  return array('help_text' => $help_text, 'block_admin_list' => $block_admin_list);
}