public function ViewEditFormController::renderDisplayTop

Render the top of the display so it can be updated during ajax operations.

2 calls to ViewEditFormController::renderDisplayTop()
ViewEditFormController::form in drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php
Overrides Drupal\Core\Entity\EntityFormController::form().
ViewEditFormController::rebuildCurrentTab in drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php
Regenerate the current tab for AJAX updates.

File

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

Class

ViewEditFormController
Form controller for the Views edit form.

Namespace

Drupal\views_ui

Code

public function renderDisplayTop(ViewUI $view) {
  $display_id = $view->displayID;
  $element['#theme_wrappers'][] = 'views_ui_container';
  $element['#attributes']['class'] = array(
    'views-display-top',
    'clearfix',
  );
  $element['#attributes']['id'] = array(
    'views-display-top',
  );

  // Extra actions for the display
  $element['extra_actions'] = array(
    '#type' => 'dropbutton',
    '#attributes' => array(
      'id' => 'views-display-extra-actions',
    ),
    '#links' => array(
      'edit-details' => array(
        'title' => t('edit view name/description'),
        'href' => "admin/structure/views/nojs/edit-details/{$view->get('name')}",
        'attributes' => array(
          'class' => array(
            'views-ajax-link',
          ),
        ),
      ),
      'analyze' => array(
        'title' => t('analyze view'),
        'href' => "admin/structure/views/nojs/analyze/{$view->get('name')}/{$display_id}",
        'attributes' => array(
          'class' => array(
            'views-ajax-link',
          ),
        ),
      ),
      'clone' => array(
        'title' => t('clone view'),
        'href' => "admin/structure/views/view/{$view->get('name')}/clone",
      ),
      'reorder' => array(
        'title' => t('reorder displays'),
        'href' => "admin/structure/views/nojs/reorder-displays/{$view->get('name')}/{$display_id}",
        'attributes' => array(
          'class' => array(
            'views-ajax-link',
          ),
        ),
      ),
    ),
  );

  // Let other modules add additional links here.
  drupal_alter('views_ui_display_top_links', $element['extra_actions']['#links'], $view, $display_id);
  if (isset($view->type) && $view->type != t('Default')) {
    if ($view->type == t('Overridden')) {
      $element['extra_actions']['#links']['revert'] = array(
        'title' => t('revert view'),
        'href' => "admin/structure/views/view/{$view->get('name')}/revert",
        'query' => array(
          'destination' => "admin/structure/views/view/{$view->get('name')}",
        ),
      );
    }
    else {
      $element['extra_actions']['#links']['delete'] = array(
        'title' => t('delete view'),
        'href' => "admin/structure/views/view/{$view->get('name')}/delete",
      );
    }
  }

  // Determine the displays available for editing.
  if ($tabs = $this
    ->getDisplayTabs($view)) {
    if ($display_id) {
      $tabs[$display_id]['#active'] = TRUE;
    }
    $tabs['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2><ul id = "views-display-menu-tabs" class="tabs secondary">';
    $tabs['#suffix'] = '</ul>';
    $element['tabs'] = $tabs;
  }

  // Buttons for adding a new display.
  foreach (views_fetch_plugin_names('display', NULL, array(
    $view
      ->get('base_table'),
  )) as $type => $label) {
    $element['add_display'][$type] = array(
      '#type' => 'submit',
      '#value' => t('Add !display', array(
        '!display' => $label,
      )),
      '#limit_validation_errors' => array(),
      '#submit' => array(
        array(
          $this,
          'submitDisplayAdd',
        ),
        array(
          $this,
          'submitDelayDestination',
        ),
      ),
      '#attributes' => array(
        'class' => array(
          'add-display',
        ),
      ),
      // Allow JavaScript to remove the 'Add ' prefix from the button label when
      // placing the button in a "Add" dropdown menu.
      '#process' => array_merge(array(
        'views_ui_form_button_was_clicked',
      ), element_info_property('submit', '#process', array())),
      '#values' => array(
        t('Add !display', array(
          '!display' => $label,
        )),
        $label,
      ),
    );
  }
  return $element;
}