1 views_ui.admin.inc views_ui_admin_settings_basic()

Form builder for the admin display defaults page.

File

core/modules/views_ui/views_ui.admin.inc, line 4424
Provides the Views' administrative interface.

Code

function views_ui_admin_settings_basic() {
  $form = array();
  $form['#attached']['css'] = views_ui_get_admin_css();
  $config = config('views_ui.settings');

  $options = array();
  foreach (list_themes() as $name => $theme) {
    if ($theme->status) {
      $options[$name] = $theme->info['name'];
    }
  }

  // This is not currently a fieldset but we may want it to be later, so this
  // will make it easier to change if we do.
  $form['basic'] = array();

  $form['basic']['show_master_display'] = array(
    '#type' => 'checkbox',
    '#title' => t('Always show the <em>Master</em> display'),
    '#description' => t('Show the <em>Master</em> (i.e. default) display, which is otherwise hidden.'),
    '#default_value' => $config->get('show_master_display'),
  );

  $form['basic']['display_embed'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow <em>embed</em> displays to be created via the UI'),
    '#description' => t('Enables the <em>embed</em> type of display. Embed displays can be used in code via <a href="@api_link"><code>views_embed_view()</code></a>. Embedded displays will still work even if this setting is disabled.', array('@api_link' => url('https://api.backdropcms.org/api/backdrop/core%21modules%21views%21views.module/function/views_embed_view'))),
    '#default_value' => $config->get('display_embed'),
  );

  $form['basic']['custom_theme'] = array(
    '#type' => 'select',
    '#title' => t('Custom admin theme for the Views UI'),
    '#options' => array('_default' => t('- Use default -')) + $options,
    '#default_value' => $config->get('custom_theme'),
    '#description' => t('In some cases you might want to select a different admin theme for the Views UI.')
  );

  $form['basic']['exposed_filter_any_label'] = array(
    '#type' => 'select',
    '#title' => t('Label for "Any" value on non-required single-select exposed filters'),
    '#options' => array('old_any' => '<Any>', 'new_any' => t('- Any -')),
    '#default_value' => config_get('views.settings', 'exposed_filter_any_label'),
  );

  $form['live_preview'] = array(
    '#type' => 'fieldset',
    '#title' => t('Live preview settings'),
  );

  $form['live_preview']['always_live_preview'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatically update preview on changes'),
    '#default_value' => $config->get('always_live_preview'),
  );

  $form['live_preview']['show_preview_information'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show information and statistics about the view during live preview'),
    '#default_value' => $config->get('show_preview_information'),
  );

  // Set a common variable used for #states on the following elements.
  $preview_checked = array(
    'visible' => array(
      ':input[name="show_preview_information"]' => array('checked' => TRUE),
    ),
  );

  $form['live_preview']['show_sql_query_where'] = array(
    '#type' => 'radios',
    '#title' => t('Statistics location'),
    '#options' => array(
      'above' => t('Above the preview'),
      'below' => t('Below the preview'),
    ),
    '#default_value' => $config->get('show_sql_query_where'),
    '#states' => $preview_checked,
  );

  $form['live_preview']['show_sql_query'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show the SQL query'),
    '#default_value' => $config->get('show_sql_query'),
    '#states' => $preview_checked,
  );
  $form['live_preview']['show_performance_statistics'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show performance statistics'),
    '#default_value' => $config->get('show_performance_statistics'),
    '#states' => $preview_checked,
  );

  $form['live_preview']['show_additional_queries'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show other queries run during render during live preview'),
    '#description' => t("Backdrop has the potential to run many queries while a view is being rendered. Checking this box will display every query run during view render as part of the live preview."),
    '#default_value' => config_get('views.settings', 'show_additional_queries'),
    '#states' => array(
      'visible' => array(
        ':input[name="show_preview_information"]' => array('checked' => TRUE),
      ),
    ),
  );

  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );

  return $form;
}