You are here

function date_ical_plugin_row_ical_entity::options_form in Date iCal 7.2

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

Provide a form for setting options.

Overrides views_plugin_row::options_form

File

includes/date_ical_plugin_row_ical_entity.inc, line 38
Contains the iCal row style plugin.

Class

date_ical_plugin_row_ical_entity
Plugin which creates a view on the resulting object and formats it as an iCal VEVENT.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  // Build the select dropdown for the date field that the user wants to use
  // to populate the date fields in VEVENTs.
  $data = date_views_fields($this->base_table);
  $options = array();
  foreach ($data['name'] as $item => $value) {

    // We only want to see one value for each field, skip '_value2', and other columns.
    if ($item == $value['fromto'][0]) {
      $options[$item] = $value['label'];
    }
  }
  $form['date_field'] = array(
    '#type' => 'select',
    '#title' => t('Date field'),
    '#options' => $options,
    '#default_value' => $this->options['date_field'],
    '#description' => t('Please identify the field to use as the iCal date for each item in this view.
          Add a Date Filter or a Date Argument to the view to limit results to content in a specified date range.'),
    '#required' => TRUE,
  );
  $form['instructions'] = array(
    // The surrounding <div> is necessary to ensure that the settings dialog expands to show everything.
    '#prefix' => '<div style="font-size: 90%">',
    '#suffix' => '</div>',
    '#markup' => t("Each item's Title and iCal view mode will be included as the SUMMARY and DESCRIPTION elements (respectively) in the VEVENTs output by this View.\n        <br>To change the iCal view mode, configure it on the 'Manage Display' page for each Content Type.\n        Please note that HTML will be stripped from the output (link URLs will become footnotes), to comply with iCal standards."),
  );

  // Build the select dropdown for the text/node_reference field that the user
  // wants to use to (optionally) populate the SUMMARY.
  $summary_fields = date_ical_get_summary_fields($this->base_table);
  $summary_options = array(
    'default_title' => t('- Default Title -'),
  );
  foreach ($summary_fields['name'] as $item => $value) {
    $summary_options[$item] = $value['label'];
  }
  $form['summary_field'] = array(
    '#type' => 'select',
    '#title' => t('SUMMARY field'),
    '#options' => $summary_options,
    '#default_value' => $this->options['summary_field'],
    '#description' => t('You may optionally change the SUMMARY component for each event in the iCal output.
        Choose which text, taxonomy term reference or Node Reference field you would like to be output as the SUMMARY.
        If using a Node Reference, the Title of the referenced node will be used.'),
  );

  // Build the select dropdown for the text/node_reference field that the user
  // wants to use to (optionally) populate the LOCATION.
  $location_fields = date_ical_get_location_fields($this->base_table);
  $location_options = array(
    'none' => t('- None -'),
  );
  foreach ($location_fields['name'] as $item => $value) {
    $location_options[$item] = $value['label'];
  }
  $form['location_field'] = array(
    '#type' => 'select',
    '#title' => t('LOCATION field'),
    '#options' => $location_options,
    '#default_value' => $this->options['location_field'],
    '#description' => t('You may optionally include a LOCATION component for each event in the iCal output.
        Choose which text or Node Reference field you would like to be output as the LOCATION.
        If using a Node Reference, the Title of the referenced node will be used.'),
  );
}