1 layout.entity.admin.inc layout_entity_admin_form(array $form, array &$form_state, $entity_type, $bundle_arg)

Render the settings form for listing entity layouts.

Parameters

array $form: The form array.

array $form_state: The form state.

string $entity_type: The entity type such as "node", "user", "taxonomy_term", etc.

string|stdClass $bundle_arg: The bundle as a string or object. The object may be a TaxonomyVocabulary or stdClass (in the case of a node type).

Return value

array: The built form array.

Related topics

File

core/modules/layout/layout.entity.admin.inc, line 25
Provides a user interface for managing layouts for entity bundles.

Code

function layout_entity_admin_form(array $form, array &$form_state, $entity_type, $bundle_arg) {
  form_load_include($form_state, 'inc', 'layout', 'layout.admin');
  form_load_include($form_state, 'inc', 'layout', 'layout.context.admin');
  $form['#attached']['css'][] = backdrop_get_path('module', 'layout') . '/css/layout.admin.css';

  $form['messages'] = array(
    '#theme' => 'status_messages',
    '#messages' => '',
    '#weight' => -100,
    // Prefix/suffix used to identify in AJAX requests.
    '#prefix' => '<div id="layout-messages">',
    '#suffix' => '</div>',
  );
  $bundle = field_extract_bundle($entity_type, $bundle_arg);
  $layouts = layout_get_entity_layouts($entity_type, $bundle);
  $entity_info = entity_get_info($entity_type);
  if ($entity_info['label'] == 'Node') {
    $entity_info['label'] = 'Content';
  }

  $header = array(
    array('data' => t('Layout'), 'class' => array(
      'layout-title',
    )),
    array('data' => t('Template'), 'class' => array(
      'layout-template',
      'priority-low',
    )),
    array('data' => t('Conditions'), 'class' => array(
      'layout-conditions',
      'priority-low',
    )),
    array('data' => t('Operations'), 'class' => array(
      'layout-operations',
    )),
  );

  $rows = array();
  foreach ($layouts['all'] as $layout) {
    $operations = array(
      '#type' => 'dropbutton',
      '#links' => _layout_get_operations($layout),
    );
    foreach ($operations['#links'] as $link_key => $op) {
      $operations['#links'][$link_key]['query'] = backdrop_get_destination();
    }

    // Create a link to the settings page.
    $info = layout_get_layout_template_info($layout->layout_template);
    $template = l($info['title'], 'admin/structure/layouts/manage/' . $layout->name . '/configure');

    $row = array();
    $row[] = theme('layout_info', array('layout' => $layout));
    $row[] = $template;
    $row[] = theme('layout_condition_info', array('layout' => $layout));
    $row[] = backdrop_render($operations);
    $class = array('layout-row');
    if ($layout->disabled) {
      $class[] = 'disabled';
    }

    $rows[] = array('data' => $row, 'class' => $class);
  }

  $bundle_label = _layout_entity_bundle_label($entity_type, $bundle_arg);
  $form['stand_alone_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#attributes' => array('class' => array('layout-list')),
    '#empty' => t('No layout overrides have been created for @bundle pages yet. All pages for @bundle will display using the <a href="@default_layout_href">Default layout</a>.', array(
      '@bundle' => $bundle_label,
      '@default_layout_href' => '/admin/structure/layouts/manage/default',
    )),
    '#weight' => 1,
  );

  return $form;
}