You are here

function layout_admin_region_delete in Layout 7

Page callback for region deletion.

File

./layout.admin.regions.inc, line 143
Responsive layout builder tool administration interface for regions.

Code

function layout_admin_region_delete($region) {

  // Set nice page title.
  drupal_set_title(t('Delete region @region', array(
    '@region' => $region->admin_title,
  )));

  // Check if the region is used in any of our responsive layouts.
  $layouts = layout_get_layouts_using_region($region->name);
  if (count($layouts)) {

    // If any layouts use this region, inform the user.
    $layout_list = array();
    foreach ($layouts as $name => $title) {
      $layout_list[] = l($title, 'admin/structure/panels/layouts/list/' . $name . '/edit');
    }
    drupal_set_message(t('<p>The region %region cannot be deleted because it is in use in the following layouts:</p>!layouts<p>To enable deletion of the region, either remove it from the layouts where it appears or delete them.</p>', array(
      '%region' => $region->admin_title,
      '!layouts' => theme('item_list', array(
        'items' => $layout_list,
      )),
    )), 'warning');
    return '';
  }
  else {
    return drupal_get_form('layout_admin_region_delete_form', $region);
  }
}