public function ViewEditFormController::getDisplayDetails

Helper function to get the display details section of the edit UI.

Parameters

$display:

Return value

array A renderable page build array.

1 call to ViewEditFormController::getDisplayDetails()
ViewEditFormController::getDisplayTab in drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php
Returns a renderable array representing the edit page for one display.

File

drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php, line 343
Contains Drupal\views_ui\ViewEditFormController.

Class

ViewEditFormController
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function getDisplayDetails($view, $display) {
  $display_title = $this
    ->getDisplayLabel($view, $display['id'], FALSE);
  $build = array(
    '#theme_wrappers' => array(
      'container',
    ),
    '#attributes' => array(
      'id' => 'edit-display-settings-details',
    ),
  );
  $is_display_deleted = !empty($display['deleted']);

  // The master display cannot be cloned.
  $is_default = $display['id'] == 'default';

  // @todo: Figure out why getOption doesn't work here.
  $is_enabled = $view
    ->get('executable')->displayHandlers[$display['id']]
    ->isEnabled();
  if ($display['id'] != 'default') {
    $build['top']['#theme_wrappers'] = array(
      'container',
    );
    $build['top']['#attributes']['id'] = 'edit-display-settings-top';
    $build['top']['#attributes']['class'] = array(
      'views-ui-display-tab-actions',
      'views-ui-display-tab-bucket',
      'clearfix',
    );

    // The Delete, Duplicate and Undo Delete buttons.
    $build['top']['actions'] = array(
      '#theme_wrappers' => array(
        'dropbutton_wrapper',
      ),
    );

    // Because some of the 'links' are actually submit buttons, we have to
    // manually wrap each item in <li> and the whole list in <ul>.
    $build['top']['actions']['prefix']['#markup'] = '<ul class="dropbutton">';
    if (!$is_display_deleted) {
      if (!$is_enabled) {
        $build['top']['actions']['enable'] = array(
          '#type' => 'submit',
          '#value' => t('enable @display_title', array(
            '@display_title' => $display_title,
          )),
          '#limit_validation_errors' => array(),
          '#submit' => array(
            array(
              $this,
              'submitDisplayEnable',
            ),
            array(
              $this,
              'submitDelayDestination',
            ),
          ),
          '#prefix' => '<li class="enable">',
          "#suffix" => '</li>',
        );
      }
      elseif ($view
        ->get('executable')->displayHandlers[$display['id']]
        ->hasPath()) {
        $path = $view
          ->get('executable')->displayHandlers[$display['id']]
          ->getPath();
        if (strpos($path, '%') === FALSE) {
          $build['top']['actions']['path'] = array(
            '#type' => 'link',
            '#title' => t('view @display', array(
              '@display' => $display['display_title'],
            )),
            '#options' => array(
              'alt' => array(
                t("Go to the real page for this display"),
              ),
            ),
            '#href' => $path,
            '#prefix' => '<li class="view">',
            "#suffix" => '</li>',
          );
        }
      }
      if (!$is_default) {
        $build['top']['actions']['duplicate'] = array(
          '#type' => 'submit',
          '#value' => t('clone @display_title', array(
            '@display_title' => $display_title,
          )),
          '#limit_validation_errors' => array(),
          '#submit' => array(
            array(
              $this,
              'submitDisplayDuplicate',
            ),
            array(
              $this,
              'submitDelayDestination',
            ),
          ),
          '#prefix' => '<li class="duplicate">',
          "#suffix" => '</li>',
        );
      }

      // Always allow a display to be deleted.
      $build['top']['actions']['delete'] = array(
        '#type' => 'submit',
        '#value' => t('delete @display_title', array(
          '@display_title' => $display_title,
        )),
        '#limit_validation_errors' => array(),
        '#submit' => array(
          array(
            $this,
            'submitDisplayDelete',
          ),
          array(
            $this,
            'submitDelayDestination',
          ),
        ),
        '#prefix' => '<li class="delete">',
        "#suffix" => '</li>',
      );
      if ($is_enabled) {
        $build['top']['actions']['disable'] = array(
          '#type' => 'submit',
          '#value' => t('disable @display_title', array(
            '@display_title' => $display_title,
          )),
          '#limit_validation_errors' => array(),
          '#submit' => array(
            array(
              $this,
              'submitDisplayDisable',
            ),
            array(
              $this,
              'submitDelayDestination',
            ),
          ),
          '#prefix' => '<li class="disable">',
          "#suffix" => '</li>',
        );
      }
    }
    else {
      $build['top']['actions']['undo_delete'] = array(
        '#type' => 'submit',
        '#value' => t('undo delete of @display_title', array(
          '@display_title' => $display_title,
        )),
        '#limit_validation_errors' => array(),
        '#submit' => array(
          array(
            $this,
            'submitDisplayUndoDelete',
          ),
          array(
            $this,
            'submitDelayDestination',
          ),
        ),
        '#prefix' => '<li class="undo-delete">',
        "#suffix" => '</li>',
      );
    }
    $build['top']['actions']['suffix']['#markup'] = '</ul>';

    // The area above the three columns.
    $build['top']['display_title'] = array(
      '#theme' => 'views_ui_display_tab_setting',
      '#description' => t('Display name'),
      '#link' => $view
        ->get('executable')->displayHandlers[$display['id']]
        ->optionLink(check_plain($display_title), 'display_title'),
    );
  }
  $build['columns'] = array();
  $build['columns']['#theme_wrappers'] = array(
    'container',
  );
  $build['columns']['#attributes'] = array(
    'id' => 'edit-display-settings-main',
    'class' => array(
      'clearfix',
      'views-display-columns',
    ),
  );
  $build['columns']['first']['#theme_wrappers'] = array(
    'container',
  );
  $build['columns']['first']['#attributes'] = array(
    'class' => array(
      'views-display-column',
      'first',
    ),
  );
  $build['columns']['second']['#theme_wrappers'] = array(
    'container',
  );
  $build['columns']['second']['#attributes'] = array(
    'class' => array(
      'views-display-column',
      'second',
    ),
  );
  $build['columns']['second']['settings'] = array();
  $build['columns']['second']['header'] = array();
  $build['columns']['second']['footer'] = array();
  $build['columns']['second']['pager'] = array();

  // The third column buckets are wrapped in details.
  $build['columns']['third'] = array(
    '#type' => 'details',
    '#title' => t('Advanced'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#theme_wrappers' => array(
      'details',
      'container',
    ),
    '#attributes' => array(
      'class' => array(
        'views-display-column',
        'third',
      ),
    ),
  );

  // Collapse the details by default.
  if (config('views.settings')
    ->get('ui.show.advanced_column')) {
    $build['columns']['third']['#collapsed'] = FALSE;
  }

  // Each option (e.g. title, access, display as grid/table/list) fits into one
  // of several "buckets," or boxes (Format, Fields, Sort, and so on).
  $buckets = array();

  // Fetch options from the display plugin, with a list of buckets they go into.
  $options = array();
  $view
    ->get('executable')->displayHandlers[$display['id']]
    ->optionsSummary($buckets, $options);

  // Place each option into its bucket.
  foreach ($options as $id => $option) {

    // Each option self-identifies as belonging in a particular bucket.
    $buckets[$option['category']]['build'][$id] = $this
      ->buildOptionForm($view, $id, $option, $display);
  }

  // Place each bucket into the proper column.
  foreach ($buckets as $id => $bucket) {

    // Let buckets identify themselves as belonging in a column.
    if (isset($bucket['column']) && isset($build['columns'][$bucket['column']])) {
      $column = $bucket['column'];
    }
    else {
      $column = 'third';
    }
    if (isset($bucket['build']) && is_array($bucket['build'])) {
      $build['columns'][$column][$id] = $bucket['build'];
      $build['columns'][$column][$id]['#theme_wrappers'][] = 'views_ui_display_tab_bucket';
      $build['columns'][$column][$id]['#title'] = !empty($bucket['title']) ? $bucket['title'] : '';
      $build['columns'][$column][$id]['#name'] = !empty($bucket['title']) ? $bucket['title'] : $id;
    }
  }
  $build['columns']['first']['fields'] = $this
    ->getFormBucket($view, 'field', $display);
  $build['columns']['first']['filters'] = $this
    ->getFormBucket($view, 'filter', $display);
  $build['columns']['first']['sorts'] = $this
    ->getFormBucket($view, 'sort', $display);
  $build['columns']['second']['header'] = $this
    ->getFormBucket($view, 'header', $display);
  $build['columns']['second']['footer'] = $this
    ->getFormBucket($view, 'footer', $display);
  $build['columns']['third']['arguments'] = $this
    ->getFormBucket($view, 'argument', $display);
  $build['columns']['third']['relationships'] = $this
    ->getFormBucket($view, 'relationship', $display);
  $build['columns']['third']['empty'] = $this
    ->getFormBucket($view, 'empty', $display);
  return $build;
}