You are here

function views_data_export_plugin_display_export::options_form in Views data export 6.2

Same name and namespace in other branches
  1. 6.3 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::options_form()
  2. 6 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::options_form()
  3. 7.4 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::options_form()
  4. 7 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::options_form()
  5. 7.3 plugins/views_data_export_plugin_display_export.inc \views_data_export_plugin_display_export::options_form()

Provide the default form for setting options.

File

plugins/views_data_export_plugin_display_export.inc, line 99
Contains the bulk export display plugin.

Class

views_data_export_plugin_display_export
The plugin that batches its rendering.

Code

function options_form(&$form, &$form_state) {

  // It is very important to call the parent function here:
  parent::options_form($form, $form_state);
  switch ($form_state['section']) {
    case 'use_batch':
      $form['#title'] .= t('Batched export');
      $form['use_batch'] = array(
        '#type' => 'radios',
        '#description' => t(''),
        '#default_value' => $this
          ->get_option('use_batch'),
        '#options' => array(
          'no_batch' => t('Export data all in one segment. Possible time and memory limit issues.'),
          'batch' => t('Export data in small segments to build a complete export. Recommended for large exports sets (1000+ rows)'),
        ),
      );

      // Allow the administrator to configure the number of items exported per batch.
      $form['segment_size'] = array(
        '#type' => 'select',
        '#title' => t('Segment size'),
        '#description' => t('If each row of your export consumes a lot of memory to render, then reduce this value. Higher values will generally mean that the export completes in less time but will have a higher peak memory usage.'),
        '#options' => drupal_map_assoc(range(1, 500)),
        '#default_value' => $this
          ->get_option('segment_size'),
        '#process' => array(
          'views_process_dependency',
        ),
        '#dependency' => array(
          'radio:use_batch' => array(
            'batch',
          ),
        ),
      );
      if (!$this
        ->is_compatible()) {
        $form['use_batch']['#disabled'] = TRUE;
        $form['use_batch']['#default_value'] = 'no_batch';
        $form['use_batch']['message'] = array(
          '#type' => 'markup',
          '#value' => theme('views_data_export_message', t('The underlying database (!db_driver) is incompatible with the batched export option and it has been disabled.', array(
            '!db_driver' => $this
              ->_get_database_driver(),
          ))),
          '#weight' => -10,
        );
      }
      break;
  }
}