1 views_ui.admin.inc views_ui_render_display_top($view, $display_id)

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

File

core/modules/views_ui/views_ui.admin.inc, line 1249
Admin page callbacks for the Views UI module.

Code

function views_ui_render_display_top($view, $display_id) {
  $element['#theme_wrappers'] = array('views_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',
    '#links' => array(
      'edit-details' => array(
        'title' => t('Change view name/description'),
        'href' => "admin/structure/views/nojs/config-details/$view->name",
        'attributes' => array('class' => array('views-ajax-link')),
      ),
      'analyze' => array(
        'title' => t('analyze view'),
        'href' => "admin/structure/views/nojs/analyze/$view->name/$display_id",
        'attributes' => array('class' => array('views-ajax-link')),
      ),
      'clone' => array(
        'title' => t('clone view'),
        'href' => "admin/structure/views/view/$view->name/clone",
      ),
      'export' => array(), // Placeholder for export
      'reorder' => array(
        'title' => t('reorder displays'),
        'href' => "admin/structure/views/nojs/reorder-displays/$view->name/$display_id",
        'attributes' => array('class' => array('views-ajax-link')),
      ),
    ),
  );

  if (module_exists('config') && user_access('synchronize configuration')) {
    $element['extra_actions']['#links']['export'] = array(
      'title' => t('export view'),
      'href' => 'admin/config/development/configuration/single/export',
      'query' => array(
        'group' => 'Views',
        'name' => 'views.view.' . $view->name,
      ),
    );
  }
  else {
    unset($element['extra_actions']['#links']['export']);
  }

  // Let other modules add additional links here.
  backdrop_alter('views_ui_display_top_links', $element['extra_actions']['#links'], $view, $display_id);

  if (isset($view->storage) && $view->storage != VIEWS_STORAGE_DEFAULT) {
    if ($view->type == t('Overridden')) {
      $element['extra_actions']['#links']['revert'] = array(
        'title' => t('revert view'),
        'href' => "admin/structure/views/view/$view->name/revert",
        'query' => array('destination' => "admin/structure/views/view/$view->name"),
      );
    }
    else {
      $element['extra_actions']['#links']['delete'] = array(
        'title' => t('delete view'),
        'href' => "admin/structure/views/view/$view->name/delete",
      );
    }
  }

  // Determine the displays available for configuring.
  if ($tabs = views_ui_edit_page_display_tabs($view, $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($view->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('views_ui_edit_form_submit_add_display', 'views_ui_edit_form_submit_delay_destination'),
      '#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;
}