1 views_plugin_display.inc views_plugin_display::options_summary(&$categories, &$options)

Provide the default summary for options in the views UI.

This output is returned as an array.

File

core/modules/views/plugins/views_plugin_display.inc, line 1092
Contains the base display plugin.

Class

views_plugin_display
The default display plugin handler. Display plugins handle options and basic mechanisms for different output methods.

Code

function options_summary(&$categories, &$options) {
  $categories = array(
    'title' => array(
      'title' => t('Title'),
      'column' => 'first',
    ),
    'format' => array(
      'title' => t('Format'),
      'column' => 'first',
    ),
    'fields' => array(
      'title' => t('Fields'),
      'column' => 'first',
    ),
    'filters' => array(
      'title' => t('Filters'),
      'column' => 'first',
    ),
    'access' => array(
      'title' => t('Access'),
      'column' => 'second',
      'build' => array(
        '#weight' => -5,
      ),
    ),
    'pager' => array(
      'title' => t('Pager'),
      'column' => 'second',
    ),
    'exposed' => array(
      'title' => t('Exposed form'),
      'column' => 'third',
      'build' => array(
        '#weight' => 1,
      ),
    ),
    'other' => array(
      'title' => t('Other'),
      'column' => 'third',
      'build' => array(
        '#weight' => 2,
      ),
    ),
  );

  if ($this->display->id != 'default') {
    $options['display_id'] = array(
      'category' => 'other',
      'title' => t('Machine Name'),
      'value' => !empty($this->display->new_id) ? check_plain($this->display->new_id) : check_plain($this->display->id),
      'desc' => t('Change the machine name of this display.'),
    );
  }

  $display_comment = check_plain(views_ui_truncate($this->get_option('display_comment'), 80));
  $options['display_comment'] = array(
    'category' => 'other',
    'title' => t('Comment'),
    'value' => !empty($display_comment) ? $display_comment : t('No comment'),
    'desc' => t('Comment or document this display.'),
  );

  $title = strip_tags($this->get_option('title'));
  if (!$title) {
    $title = t('None');
  }

  $options['title'] = array(
    'category' => 'title',
    'title' => t('Title'),
    'value' => $title,
    'desc' => t('Change the title that this display will use.'),
  );

  $style_plugin = views_fetch_plugin_data('style', $this->get_option('style_plugin'));
  $style_plugin_instance = $this->get_plugin('style');
  $style_summary = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->summary_title();
  $style_title = empty($style_plugin['title']) ? t('Missing style plugin') : $style_plugin_instance->plugin_title();

  $style = '';

  $options['style_plugin'] = array(
    'category' => 'format',
    'title' => t('Format'),
    'value' => $style_title,
    'setting' => $style_summary,
    'desc' => t('Change the way content is formatted.'),
  );

  // This adds a 'Settings' link to the style_options setting if the style has options.
  if (!empty($style_plugin['uses options'])) {
    $options['style_plugin']['links']['style_options'] = t('Change settings for this format');
  }

  if (!empty($style_plugin['uses row plugin'])) {
    $row_plugin = views_fetch_plugin_data('row', $this->get_option('row_plugin'));
    $row_plugin_instance = $this->get_plugin('row');
    $row_summary = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->summary_title();
    $row_title = empty($row_plugin['title']) ? t('Missing style plugin') : $row_plugin_instance->plugin_title();

    $options['row_plugin'] = array(
      'category' => 'format',
      'title' => t('Show'),
      'value' => $row_title,
      'setting' => $row_summary,
      'desc' => t('Change the way each row in the view is styled.'),
    );
    // This adds a 'Settings' link to the row_options setting if the row style has options.
    if (!empty($row_plugin['uses options'])) {
      $options['row_plugin']['links']['row_options'] = t('Change settings for this style');
    }
  }
  if (!empty($this->definition['use ajax'])) {
    $options['use_ajax'] = array(
      'category' => 'other',
      'title' => t('Use AJAX'),
      'value' => $this->get_option('use_ajax') ? t('Yes') : t('No'),
      'desc' => t('Change whether or not this display will use AJAX.'),
    );
  }
  if (!empty($this->definition['accept attachments'])) {
    $options['hide_attachment_summary'] = array(
      'category' => 'other',
      'title' => t('Hide attachments in summary'),
      'value' => $this->get_option('hide_attachment_summary') ? t('Yes') : t('No'),
      'desc' => t('Change whether or not to display attachments when displaying a contextual filter summary.'),
    );
  }
  if (!isset($this->definition['contextual links locations']) || !empty($this->definition['contextual links locations'])) {
    $options['hide_admin_links'] = array(
      'category' => 'other',
      'title' => t('Hide contextual links'),
      'value' => $this->get_option('hide_admin_links') ? t('Yes') : t('No'),
      'desc' => t('Change whether or not to display contextual links for this view.'),
    );
  }

  $pager_plugin = $this->get_plugin('pager');
  if (!$pager_plugin) {
    // default to the no pager plugin.
    $pager_plugin = views_get_plugin('pager', 'none');
  }

  $pager_str = $pager_plugin->summary_title();

  $options['pager'] = array(
    'category' => 'pager',
    'title' => t('Use pager'),
    'value' => $pager_plugin->plugin_title(),
    'setting' => $pager_str,
    'desc' => t("Change this display's pager setting."),
  );

  // If pagers aren't allowed, change the text of the item:
  if (empty($this->definition['use pager'])) {
    $options['pager']['title'] = t('Items to display');
  }

  if (!empty($pager_plugin->definition['uses options'])) {
    $options['pager']['links']['pager_options'] = t('Change settings for this pager type.');
  }

  if (!empty($this->definition['use more'])) {
    $options['use_more'] = array(
      'category' => 'pager',
      'title' => t('More link'),
      'value' => $this->get_option('use_more') ? t('Yes') : t('No'),
      'desc' => t('Specify whether this display will provide a "more" link.'),
    );
  }

  $this->view->init_query();
  if ($this->view->query->get_aggregation_info()) {
    $options['group_by'] = array(
      'category' => 'other',
      'title' => t('Use aggregation'),
      'value' => $this->get_option('group_by') ? t('Yes') : t('No'),
      'desc' => t('Allow grouping and aggregation (calculation) of fields.'),
    );
  }

  $options['query'] = array(
    'category' => 'other',
    'title' => t('Query settings'),
    'value' => t('Settings'),
    'desc' => t('Allow to set some advanced settings for the query plugin'),
  );

  $languages = array(
    '***CURRENT_LANGUAGE***' => t("Current user's language"),
    '***DEFAULT_LANGUAGE***' => t("Default site language"),
    LANGUAGE_NONE => t('Language neutral'),
  );
  if (module_exists('locale')) {
    $languages = array_merge($languages, views_language_list());
  }
  $options['field_language'] = array(
    'category' => 'other',
    'title' => t('Field Language'),
    'value' => $languages[$this->get_option('field_language')],
    'desc' => t('All fields which support translations will be displayed in the selected language.'),
  );

  $access_plugin = $this->get_plugin('access');
  if (!$access_plugin) {
    // default to the no access control plugin.
    $access_plugin = views_get_plugin('access', 'none');
  }

  $access_str = $access_plugin->summary_title();

  $options['access'] = array(
    'category' => 'access',
    'title' => t('Access'),
    'value' => $access_plugin->plugin_title(),
    'setting' => $access_str,
    'desc' => t('Specify access control type for this display.'),
  );

  if (!empty($access_plugin->definition['uses options'])) {
    $options['access']['links']['access_options'] = t('Change settings for this access type.');
  }

  $cache_plugin = $this->get_plugin('cache');
  if (!$cache_plugin) {
    // default to the no cache control plugin.
    $cache_plugin = views_get_plugin('cache', 'none');
  }

  $cache_str = $cache_plugin->summary_title();

  $options['cache'] = array(
    'category' => 'other',
    'title' => t('Caching'),
    'value' => $cache_plugin->plugin_title(),
    'setting' => $cache_str,
    'desc' => t('Specify caching type for this display.'),
  );

  if (!empty($cache_plugin->definition['uses options'])) {
    $options['cache']['links']['cache_options'] = t('Change settings for this caching type.');
  }

  if (!empty($access_plugin->definition['uses options'])) {
    $options['access']['links']['access_options'] = t('Change settings for this access type.');
  }

  if ($this->uses_link_display()) {
    $display_id = $this->get_link_display();
    $link_display = empty($this->view->display[$display_id]) ? t('None') : check_plain($this->view->display[$display_id]->display_title);
    $link_display = $this->get_option('link_display') == 'custom_url' ? t('Custom URL') : $link_display;
    $options['link_display'] = array(
      'category' => 'other',
      'title' => t('Link display'),
      'value' => $link_display,
      'desc' => t('Specify which display or custom url this display will link to.'),
    );
  }

  if ($this->uses_exposed_form_in_block()) {
    $options['exposed_block'] = array(
      'category' => 'exposed',
      'title' => t('Create exposed form block'),
      'value' => $this->get_option('exposed_block') ? t('Yes') : t('No'),
      'desc' => t('Allow the exposed form to appear in a block instead of the view.'),
    );
  }

  $exposed_form_plugin = $this->get_plugin('exposed_form');
  if (!$exposed_form_plugin) {
    // default to the no cache control plugin.
    $exposed_form_plugin = views_get_plugin('exposed_form', 'basic');
  }

  $exposed_form_str = $exposed_form_plugin->summary_title();

  $options['exposed_form'] = array(
    'category' => 'exposed',
    'title' => t('Exposed form style'),
    'value' => $exposed_form_plugin->plugin_title(),
    'setting' => $exposed_form_str,
    'desc' => t('Select the kind of exposed filter to use.'),
  );

  if (!empty($exposed_form_plugin->definition['uses options'])) {
    $options['exposed_form']['links']['exposed_form_options'] = t('Exposed form settings for this exposed form style.');
  }

  $css_class = check_plain(trim($this->get_option('css_class')));
  if (!$css_class) {
    $css_class = t('None');
  }

  $options['css_class'] = array(
    'category' => 'other',
    'title' => t('CSS class'),
    'value' => $css_class,
    'desc' => t('Change the CSS class name(s) that will be added to this display.'),
  );

  $options['analyze-theme'] = array(
    'category' => 'other',
    'title' => t('Theme'),
    'value' => t('Information'),
    'desc' => t('Get information on how to theme this display'),
  );

  foreach ($this->extender as $extender) {
    $extender->options_summary($categories, $options);
  }
}