You are here

function views_data_export_plugin_style_export::options_form in Views data export 7.4

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

Options form mini callback.

Parameters

$form: Form array to add additional fields to.

$form_state: State of the form.

Return value

None.

Overrides views_plugin_style::options_form

File

plugins/views_data_export_plugin_style_export.inc, line 60
Plugin include file for export style plugin.

Class

views_data_export_plugin_style_export
Generalized style plugin for export plugins.

Code

function options_form(&$form, &$form_state) {
  $form['attach_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Attach text'),
    '#default_value' => $this->options['attach_text'],
    '#description' => t('This text is used in building the feed link. By default it is the "alt" text for the feed image.'),
  );
  $form['provide_file'] = array(
    '#type' => 'checkbox',
    '#title' => t('Provide as file'),
    '#default_value' => $this->options['provide_file'],
    '#description' => t('By deselecting this, the xml file will be provided as a feed instead of a file for download.'),
  );
  $form['filename'] = array(
    '#type' => 'textfield',
    '#title' => t('Filename'),
    '#default_value' => $this->options['filename'],
    '#description' => t('The filename that will be suggested to the browser for downloading purposes. You may include replacement patterns from the list below.'),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'edit-style-options-provide-file' => array(
        TRUE,
      ),
    ),
  );

  // General token replacement.
  $output = t('<p>The following substitution patterns are available for this display. Use the pattern shown on the left to display the value indicated on the right.</p>');
  $items = array(
    '%view == ' . t('View name'),
    '%display == ' . t('Display name'),
  );
  $output .= theme('item_list', array(
    'items' => $items,
  ));

  // Get a list of the available arguments for token replacement.
  $options = array();
  $options = $this->options;
  $count = 0;

  // This lets us prepare the key as we want it printed.
  foreach ($this->view->display_handler
    ->get_handlers('argument') as $arg => $handler) {
    $options[t('Arguments')]['%' . ++$count . '-title'] = t('@argument title', array(
      '@argument' => $handler
        ->ui_name(),
    ));
    $options[t('Arguments')]['%' . $count . '-value'] = t('@argument value', array(
      '@argument' => $handler
        ->ui_name(),
    ));
  }

  // Append the list with exposed filters stuff.
  $options[t('Exposed filters')]['%exposed'] = t('effective exposed filters, like <em>filter1_foo-filter2_bar</em>');

  // ...and datestamp.
  $time = REQUEST_TIME;
  $parts = array(
    'full' => 'Y-m-d\\TH-i-s',
    'yy' => 'y',
    'yyyy' => 'Y',
    'mm' => 'm',
    'mmm' => 'M',
    'dd' => 'd',
    'ddd' => 'D',
    'hh' => 'H',
    'ii' => 'i',
    'ss' => 's',
  );
  foreach ($parts as $part => $format) {
    $options[t('Timestamp')]['%timestamp-' . $part] = format_date($time, 'custom', $format);
  }

  // We have some options, so make a list.
  if (!empty($options)) {
    foreach (array_keys($options) as $type) {
      if (!empty($options[$type])) {
        $items = array();
        foreach ($options[$type] as $key => $value) {
          $items[] = $key . ' == ' . $value;
        }
        $output .= theme('item_list', array(
          'items' => $items,
          'title' => $type,
        ));
      }
    }
  }
  $form['help'] = array(
    '#type' => 'fieldset',
    '#title' => t('Replacement patterns'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#value' => $output,
    '#dependency' => array(
      'edit-style-options-provide-file' => array(
        1,
      ),
    ),
  );
  $form['parent_sort'] = array(
    '#type' => 'checkbox',
    '#title' => t('Parent sort'),
    '#default_value' => $this->options['parent_sort'],
    '#description' => t('Try to apply any additional sorting from the attached display like table sorting to the exported feed.'),
  );

  // If the exporter needs settings, it will implement the interface.
  if (in_array('ViewsDataExportExporterUserConfigurationInterface', class_implements($this
    ->get_exporter()))) {

    // Group the exporter settings in a fieldset.
    $form_exporter_settings = array(
      '#type' => 'fieldset',
      '#title' => t('Exporter settings'),
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
      '#tree' => TRUE,
    );

    // Get the form options from the exporter.
    $this
      ->get_exporter()
      ->options_form($form_exporter_settings, $form_state, $this->display->handler
      ->get_field_labels());
  }
  $form['exporter_options'] = $form_exporter_settings;
}