You are here

function calendar_plugin_style::options_form in Calendar 7.3

Provide a form to edit options for this plugin.

Overrides views_plugin_style::options_form

File

includes/calendar_plugin_style.inc, line 50
Views style plugin for the Calendar module.

Class

calendar_plugin_style
Default style plugin to render an iCal feed.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['calendar_type'] = array(
    '#title' => t('Calendar type'),
    '#type' => 'select',
    '#description' => t('Select the calendar time period for this display.'),
    '#default_value' => $this->options['calendar_type'],
    '#options' => calendar_display_types(),
  );
  $form['mini'] = array(
    '#title' => t('Display as mini calendar'),
    '#default_value' => $this->options['mini'],
    '#type' => 'radios',
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#description' => t('Display the mini style calendar, with no item details. Suitable for a calendar displayed in a block.'),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'month',
      ),
    ),
  );
  $form['name_size'] = array(
    '#title' => t('Calendar day of week names'),
    '#default_value' => $this->options['name_size'],
    '#type' => 'radios',
    '#options' => array(
      1 => t('First letter of name'),
      2 => t('First two letters of name'),
      3 => t('Abbreviated name'),
      99 => t('Full name'),
    ),
    '#description' => t('The way day of week names should be displayed in a calendar.'),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'month',
        'week',
        'year',
      ),
    ),
  );
  $form['with_weekno'] = array(
    '#title' => t('Show week numbers'),
    '#default_value' => $this->options['with_weekno'],
    '#type' => 'radios',
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#description' => t('Whether or not to show week numbers in the left column of calendar weeks and months.'),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'month',
      ),
    ),
  );
  $form['max_items'] = array(
    '#title' => t('Maximum items'),
    '#type' => 'select',
    '#options' => array(
      0 => t('Unlimited'),
      1 => format_plural(1, '1 item', '@count items'),
      3 => format_plural(3, '1 item', '@count items'),
      5 => format_plural(5, '1 item', '@count items'),
      10 => format_plural(10, '1 item', '@count items'),
    ),
    '#default_value' => $this->options['calendar_type'] != 'day' ? $this->options['max_items'] : 0,
    '#description' => t('Maximum number of items to show in calendar cells, used to keep the calendar from expanding to a huge size when there are lots of items in one day.'),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'month',
      ),
    ),
  );
  $form['max_items_behavior'] = array(
    '#title' => t('Too many items'),
    '#type' => 'select',
    '#options' => array(
      'more' => t("Show maximum, add 'more' link"),
      'hide' => t('Hide all, add link to day'),
    ),
    '#default_value' => $this->options['calendar_type'] != 'day' ? $this->options['max_items_behavior'] : 'more',
    '#description' => t('Behavior when there are more than the above number of items in a single day. When there more items than this limit, a link to the day view will be displayed.'),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'month',
      ),
    ),
  );
  $form['groupby_times'] = array(
    '#title' => t('Time grouping'),
    '#type' => 'select',
    '#default_value' => $this->options['groupby_times'],
    '#description' => t("Group items together into time periods based on their start time."),
    '#options' => array(
      '' => t('None'),
      'hour' => t('Hour'),
      'half' => t('Half hour'),
      'custom' => t('Custom'),
    ),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'day',
        'week',
      ),
    ),
  );
  $form['groupby_times_custom'] = array(
    '#title' => t('Custom time grouping'),
    '#type' => 'textarea',
    '#default_value' => $this->options['groupby_times_custom'],
    '#description' => t("When choosing the 'custom' Time grouping option above, create custom time period groupings as a comma-separated list of 24-hour times in the format HH:MM:SS, like '00:00:00,08:00:00,18:00:00'. Be sure to start with '00:00:00'. All items after the last time will go in the final group."),
    '#dependency' => array(
      'edit-style-options-groupby-times' => array(
        'custom',
      ),
    ),
  );
  $form['theme_style'] = array(
    '#title' => t('Overlapping time style'),
    '#default_value' => $this->options['theme_style'],
    '#type' => 'select',
    '#options' => array(
      0 => t('Do not display overlapping items'),
      1 => t('Display overlapping items, with scrolling'),
      2 => t('Display overlapping items, no scrolling'),
    ),
    '#description' => t('Select whether calendar items are displayed as overlapping items. Use scrolling to shrink the window and focus on the selected items, or omit scrolling to display the whole day. This only works if hour or half hour time grouping is chosen!'),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'day',
        'week',
      ),
    ),
  );

  // Create a list of fields that are available for grouping,
  $field_options = array();
  $fields = $this->display->handler
    ->get_option('fields');
  foreach ($fields as $field_name => $field) {
    $field_options[$field_name] = $field['field'];
  }
  $form['groupby_field'] = array(
    '#title' => t('Field grouping'),
    '#type' => 'select',
    '#default_value' => $this->options['groupby_field'],
    '#description' => t("Optionally group items into columns by a field value, for instance select the content type to show items for each content type in their own column, or use a location field to organize items into columns by location. NOTE! This is incompatible with the overlapping style option."),
    '#options' => array(
      '' => '',
    ) + $field_options,
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'day',
      ),
    ),
  );
  $form['multiday_theme'] = array(
    '#title' => t('Multi-day style'),
    '#default_value' => $this->options['multiday_theme'],
    '#type' => 'select',
    '#options' => array(
      0 => t('Display multi-day item as a single column'),
      1 => t('Display multi-day item as a multiple column row'),
    ),
    '#description' => t('If selected, items which span multiple days will displayed as a multi-column row.  If not selected, items will be displayed as an individual column.'),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'month',
        'week',
      ),
    ),
  );
  $form['multiday_hidden'] = array(
    '#title' => t('Fields to hide in Multi-day rows'),
    '#default_value' => $this->options['multiday_hidden'],
    '#type' => 'checkboxes',
    '#options' => $field_options,
    '#description' => t('Choose fields to hide when displayed in multi-day rows. Usually you only want to see the title or Colorbox selector in multi-day rows and would hide all other fields.'),
    '#dependency' => array(
      'edit-style-options-calendar-type' => array(
        'month',
        'week',
        'day',
      ),
    ),
  );
}