You are here

public function date_ical_plugin_row_ical_fields::options_form in Date iCal 7.3

Same name and namespace in other branches
  1. 7.2 includes/date_ical_plugin_row_ical_fields.inc \date_ical_plugin_row_ical_fields::options_form()

Build the form for setting the row plugin's options.

Overrides views_plugin_row::options_form

File

includes/date_ical_plugin_row_ical_fields.inc, line 30
Defines the iCal Fields row style plugin, which lets users map view fields to the components of the VEVENTs in the iCal feed.

Class

date_ical_plugin_row_ical_fields
A Views plugin which builds an iCal VEVENT from a views row with Fields.

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $all_field_labels = $this->display->handler
    ->get_field_labels();
  $date_field_labels = $this
    ->get_date_field_candidates($all_field_labels);
  $date_field_label_options = array_merge(array(
    'first_available' => t('First populated Date field'),
  ), $date_field_labels);
  $text_field_label_options = array_merge(array(
    '' => t('- None -'),
  ), $all_field_labels);
  $form['instructions'] = array(
    // The surrounding <div> ensures that the settings dialog expands.
    '#prefix' => '<div style="font-size: 90%">',
    '#suffix' => '</div>',
    '#markup' => t("Once you've finished setting up the fields for this View, you may want to return to this dialog to set the Date field."),
  );
  $form['date_field'] = array(
    '#type' => 'select',
    '#title' => t('Date field'),
    '#description' => t('The views field to use as the start (and possibly end) time for each event (DTSTART/DTEND).
        If you retain the default ("First populated Date field"), Date iCal will use the first non-empty Date field in the row.'),
    '#options' => $date_field_label_options,
    '#default_value' => $this->options['date_field'],
    '#required' => TRUE,
  );
  $form['title_field'] = array(
    '#type' => 'select',
    '#title' => t('Title field'),
    '#description' => t('The views field to use as the title for each event (SUMMARY).'),
    '#options' => $text_field_label_options,
    '#default_value' => $this->options['title_field'],
    '#required' => FALSE,
  );
  $form['description_field'] = array(
    '#type' => 'select',
    '#title' => t('Description field'),
    '#description' => t("The views field to use as the body text for each event (DESCRIPTION).<br>\n          If you wish to include more than one entity field in the event body, you may want to use the 'Content: Rendered Node' views field,\n          and set it to the 'iCal' view mode. Then configure the iCal view mode on your event nodes to include the text you want."),
    '#options' => $text_field_label_options,
    '#default_value' => $this->options['description_field'],
    '#required' => FALSE,
  );
  $form['location_field'] = array(
    '#type' => 'select',
    '#title' => t('Location field'),
    '#description' => t('(optional) The views field to use as the location for each event (LOCATION).'),
    '#options' => $text_field_label_options,
    '#default_value' => $this->options['location_field'],
    '#required' => FALSE,
  );
  $form['categories_field'] = array(
    '#type' => 'select',
    '#title' => t('Categories field'),
    '#description' => t('(optional) The views field to use as the categories for each event (CATEGORIES).'),
    '#options' => $text_field_label_options,
    '#default_value' => $this->options['categories_field'],
    '#required' => FALSE,
  );
  $form['additional_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Additional settings'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['additional_settings']['skip_blank_dates'] = array(
    '#type' => 'checkbox',
    '#title' => t('Skip blank dates'),
    '#description' => t('Normally, if a view result has a blank date field, the feed will display an error,
        because it is impossible to create an iCal event with no date. This option makes Views silently skip those results, instead.'),
    '#default_value' => $this->options['additional_settings']['skip_blank_dates'],
  );
}