You are here

public function ViewUI::renderDisplayTop in Views (for Drupal 7) 8.3

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

2 calls to ViewUI::renderDisplayTop()
ViewUI::buildEditForm in views_ui/lib/Drupal/views_ui/ViewUI.php
Form builder callback for editing a View.
ViewUI::rebuildCurrentTab in views_ui/lib/Drupal/views_ui/ViewUI.php
Regenerate the current tab for AJAX updates.

File

views_ui/lib/Drupal/views_ui/ViewUI.php, line 384
Definition of Drupal\views_ui\ViewUI.

Class

ViewUI
Stores UI related temporary settings.

Namespace

Drupal\views_ui

Code

public function renderDisplayTop($display_id) {
  $element['#theme_wrappers'] = array(
    '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/{$this->storage->name}",
        'attributes' => array(
          'class' => array(
            'views-ajax-link',
          ),
        ),
      ),
      'analyze' => array(
        'title' => t('analyze view'),
        'href' => "admin/structure/views/nojs/analyze/{$this->storage->name}/{$display_id}",
        'attributes' => array(
          'class' => array(
            'views-ajax-link',
          ),
        ),
      ),
      'clone' => array(
        'title' => t('clone view'),
        'href' => "admin/structure/views/view/{$this->storage->name}/clone",
      ),
      'reorder' => array(
        'title' => t('reorder displays'),
        'href' => "admin/structure/views/nojs/reorder-displays/{$this->storage->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'], $this, $display_id);
  if (isset($this->type) && $this->type != t('Default')) {
    if ($this->type == t('Overridden')) {
      $element['extra_actions']['#links']['revert'] = array(
        'title' => t('revert view'),
        'href' => "admin/structure/views/view/{$this->storage->name}/revert",
        'query' => array(
          'destination' => "admin/structure/views/view/{$this->storage->name}",
        ),
      );
    }
    else {
      $element['extra_actions']['#links']['delete'] = array(
        'title' => t('delete view'),
        'href' => "admin/structure/views/view/{$this->storage->name}/delete",
      );
    }
  }

  // Determine the displays available for editing.
  if ($tabs = $this
    ->getDisplayTabs($display_id)) {
    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(
    $this->storage->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;
}