You are here

function views_plugin_style_atom_fields::options_form in Views Atom 7

Same name and namespace in other branches
  1. 6 views/views_plugin_style_atom_fields.inc \views_plugin_style_atom_fields::options_form()

Provide a form for setting options.

Overrides views_plugin_style::options_form

File

./views_plugin_style_atom_fields.inc, line 50
Style plugin for a standard Atom feed.

Class

views_plugin_style_atom_fields
@file Style plugin for a standard Atom feed.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $options = parent::option_definition();
  $handlers = $this->display->handler
    ->get_handlers('field');
  if (empty($handlers)) {
    $form['error_markup'] = array(
      '#value' => t('You need at least one field before you can configure your field settings'),
      '#prefix' => '<div class="error form-item description">',
      '#suffix' => '</div>',
    );
  }
  else {
    $form['entry_type'] = array(
      '#type' => 'select',
      '#title' => t('Entry type'),
      '#options' => drupal_map_assoc(array(
        'text',
        'html',
        'xhtml',
        'xml',
      )),
      '#default_value' => $this->options['entry_type'],
      '#description' => t('Select the media type of the content of each entry. If XML, enter the mimetype to use below.'),
    );
    $form['entry_type_custom'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom entry type'),
      '#desctiption' => t('Enter the mimetype of the content of this feed.  It must be a valid XML mimetype.'),
      '#default_value' => $this->options['entry_type_custom'],
    );

    // Feed Description
    $form['description'] = array(
      '#type' => 'fieldset',
      '#title' => t('Feed Description'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['description']['feed_description'] = array(
      '#type' => 'textarea',
      '#default_value' => $this->options['description']['feed_description'],
      '#description' => t('Description for this feed.  If left blank, the default site mission will be used.'),
    );

    // Field Chooser
    $field_names = array(
      '' => '--',
    );
    foreach ($handlers as $field => $handler) {
      if ($label = $handler
        ->label()) {
        $field_names[$field] = $label;
      }
      else {
        $field_names[$field] = $handler
          ->ui_name();
      }
    }
    $field_options = $this
      ->atom_mapping_fields();
    $form['fields'] = array(
      '#type' => 'fieldset',
      '#title' => t('Field usage'),
      '#description' => t('Atom needs certain elements have values. Specify which fields should be used to populate each field. Note that all fields will still be available to the content of the record.'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    foreach ($field_options as $k => $v) {
      $form['fields'][$k] = array(
        '#type' => 'select',
        '#title' => $v['label'],
        '#options' => $field_names,
        '#default_value' => $this->options['fields'][$k],
      );
    }

    // Feed Description
    $form['guid'] = array(
      '#type' => 'fieldset',
      '#title' => t('GUID settings'),
      '#description' => t('Controls how the GUID is created.'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    if (module_exists('feeds')) {
      $form['guid']['use_existing_from_feed'] = array(
        '#title' => t('Use existing GUID when available'),
        '#type' => 'checkbox',
        '#default_value' => !empty($this->options['guid']['use_existing_from_feed']),
        '#description' => t('If the node was imported into the site from another feed, use the original GUID.'),
      );
    }
    $form['guid']['#access'] = count(element_children($form['guid'])) ? TRUE : FALSE;
  }
}