You are here

function views_data_export_plugin_display_export::options_form in Views data export 7.4

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. 6.2 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.

Overrides views_plugin_display_feed::options_form

File

plugins/views_data_export_plugin_display_export.inc, line 104
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(
          'ctools_dependent_process',
        ),
        '#dependency' => array(
          'radio:use_batch' => array(
            'batch',
          ),
        ),
      );
      $form['return_path'] = array(
        '#title' => t('Return path'),
        '#type' => 'textfield',
        '#description' => t('Return path after the batched operation, leave empty for default. This path will only be used if the export URL is visited directly, and not by following a link when attached to another view display.'),
        '#default_value' => $this
          ->get_option('return_path'),
        '#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',
          '#markup' => theme('views_data_export_message', array(
            '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(),
            )),
            'type' => 'warning',
          )),
          '#weight' => -10,
        );
      }
      break;
    case 'cache':

      // We're basically going to disable using cache plugins, by disabling
      // the UI.
      if (isset($form['cache']['type']['#options'])) {
        foreach ($form['cache']['type']['#options'] as $id => $v) {
          if ($id != 'none') {
            unset($form['cache']['type']['#options'][$id]);
          }
          $form['cache']['type']['#description'] = t("Views data export isn't currently compatible with caching plugins.");
        }
      }
      break;
  }
}