You are here

public function date_ical_plugin_row_ical_entity::options_form in Date iCal 7.3

Same name and namespace in other branches
  1. 7.2 includes/date_ical_plugin_row_ical_entity.inc \date_ical_plugin_row_ical_entity::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_entity.inc, line 43
Contains the iCal row style plugin.

Class

date_ical_plugin_row_ical_entity
A Views plugin which builds an iCal VEVENT from a single node.

Code

public 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 properties 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, so we need to
    // 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> ensures that the settings dialog expands.
    '#prefix' => '<div style="font-size: 90%">',
    '#suffix' => '</div>',
    '#markup' => t("Each item's Title will be the SUMMARY and the rendered iCal view mode will be the DESCRIPTION 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 all HTML will be stripped from the output, 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.'),
  );
}