You are here

function fullcalendar_fullcalendar_options_form in FullCalendar 7.2

Implements hook_fullcalendar_options_form().

File

includes/fullcalendar.fullcalendar.inc, line 160
Provides default FullCalendar configuration options.

Code

function fullcalendar_fullcalendar_options_form(&$form, &$form_state, &$view) {
  $form['#pre_render'][] = 'views_ui_pre_render_add_fieldset_markup';
  $form['display'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display settings'),
    '#collapsible' => TRUE,
  );
  $form['header'] = array(
    '#type' => 'fieldset',
    '#title' => t('Header settings'),
    '#description' => l(t('More info'), 'http://arshaw.com/fullcalendar/docs/display/header', array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['times'] = array(
    '#type' => 'fieldset',
    '#title' => t('Time/date settings'),
    '#description' => l(t('More info'), 'http://arshaw.com/fullcalendar/docs/utilities/formatDate', array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['style'] = array(
    '#type' => 'fieldset',
    '#title' => t('Style settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['defaultView'] = array(
    '#type' => 'select',
    '#title' => t('Initial display'),
    '#options' => array(
      'month' => 'Month',
      'agendaWeek' => 'Week (Agenda)',
      'basicWeek' => 'Week (Basic)',
      'agendaDay' => 'Day (Agenda)',
      'basicDay' => 'Day (Basic)',
    ),
    '#description' => l(t('More info'), 'http://arshaw.com/fullcalendar/docs/views/Available_Views', array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )),
    '#default_value' => $view->options['defaultView'],
    '#prefix' => '<div class="views-left-30">',
    '#suffix' => '</div>',
    '#fieldset' => 'display',
  );
  $form['firstDay'] = array(
    '#type' => 'select',
    '#title' => t('Week starts on'),
    '#options' => date_week_days(TRUE),
    '#default_value' => $view->options['firstDay'],
    '#prefix' => '<div class="views-left-30">',
    '#suffix' => '</div>',
    '#fieldset' => 'display',
  );
  $form['weekMode'] = array(
    '#type' => 'select',
    '#title' => t('Week mode'),
    '#options' => array(
      'fixed' => 'Fixed',
      'liquid' => 'Liquid',
      'variable' => 'Variable',
    ),
    '#default_value' => $view->options['weekMode'],
    '#description' => l(t('More info'), 'http://arshaw.com/fullcalendar/docs/display/weekMode', array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )),
    '#prefix' => '<div class="views-left-30">',
    '#suffix' => '</div>',
    '#fieldset' => 'display',
  );
  $form['left'] = array(
    '#type' => 'textfield',
    '#title' => t('Left'),
    '#default_value' => $view->options['left'],
    '#prefix' => '<div class="views-left-30">',
    '#suffix' => '</div>',
    '#size' => '30',
    '#fieldset' => 'header',
  );
  $form['center'] = array(
    '#type' => 'textfield',
    '#title' => t('Center'),
    '#default_value' => $view->options['center'],
    '#prefix' => '<div class="views-left-30">',
    '#suffix' => '</div>',
    '#size' => '30',
    '#fieldset' => 'header',
  );
  $form['right'] = array(
    '#type' => 'textfield',
    '#title' => t('Right'),
    '#default_value' => $view->options['right'],
    '#prefix' => '<div class="views-left-30">',
    '#suffix' => '</div>',
    '#size' => '30',
    '#fieldset' => 'header',
  );
  $form['times']['default_date'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use a custom initial date'),
    '#description' => t('If unchecked, the calendar will load the current date.'),
    '#default_value' => $view->options['times']['default_date'],
    '#data_type' => 'bool',
    '#fieldset' => 'times',
  );
  $form['times']['date'] = array(
    '#type' => 'date',
    '#title' => t('Custom initial date'),
    '#title_display' => 'invisible',
    '#default_value' => $view->options['times']['date'],
    '#dependency' => array(
      'edit-style-options-times-default-date' => array(
        1,
      ),
    ),
    '#fieldset' => 'times',
  );
  $form['timeformat'] = array(
    '#type' => 'textfield',
    '#title' => t('Time format'),
    '#default_value' => $view->options['timeformat'],
    '#size' => '30',
    '#fieldset' => 'times',
    '#dependency' => array(
      'edit-style-options-advanced' => array(
        0,
      ),
    ),
  );
  $form['advanced'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable advanced time and date format settings'),
    '#default_value' => $view->options['advanced'],
    '#data_type' => 'bool',
    '#fieldset' => 'times',
  );
  $form['axisFormat'] = array(
    '#type' => 'textfield',
    '#title' => t('Axis format'),
    '#description' => l(t('More info'), 'http://arshaw.com/fullcalendar/docs/agenda/axisFormat', array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )),
    '#default_value' => $view->options['axisFormat'],
    '#size' => '30',
    '#fieldset' => 'times',
    '#dependency' => array(
      'edit-style-options-advanced' => array(
        1,
      ),
    ),
  );

  // Add the nine time/date formats.
  foreach (array(
    'time',
    'title',
    'column',
  ) as $type) {
    foreach (array(
      'Month',
      'Week',
      'Day',
    ) as $range) {
      $key = $type . 'format' . $range;
      $form[$key] = array(
        '#type' => 'textfield',
        '#title' => t($range),
        '#default_value' => $view->options[$key],
        '#prefix' => '<div class="views-left-30">',
        '#suffix' => '</div>',
        '#size' => '30',
        '#fieldset' => $type,
      );
    }
  }
  $form['time'] = array(
    '#type' => 'fieldset',
    '#title' => t('Time format'),
    '#description' => l(t('More info'), 'http://arshaw.com/fullcalendar/docs/text/timeFormat', array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#fieldset' => 'times',
    '#dependency' => array(
      'edit-style-options-advanced' => array(
        1,
      ),
    ),
  );
  $form['title'] = array(
    '#type' => 'fieldset',
    '#title' => t('Title format'),
    '#description' => l(t('More info'), 'http://arshaw.com/fullcalendar/docs/text/titleFormat', array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#fieldset' => 'times',
    '#dependency' => array(
      'edit-style-options-advanced' => array(
        1,
      ),
    ),
  );
  $form['column'] = array(
    '#type' => 'fieldset',
    '#title' => t('Column format'),
    '#description' => l(t('More info'), 'http://arshaw.com/fullcalendar/docs/text/columnFormat', array(
      'attributes' => array(
        'target' => '_blank',
      ),
    )),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#fieldset' => 'times',
    '#dependency' => array(
      'edit-style-options-advanced' => array(
        1,
      ),
    ),
  );
  $form['theme'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use jQuery UI Theme'),
    '#default_value' => $view->options['theme'],
    '#data_type' => 'bool',
    '#fieldset' => 'style',
  );
  $form['sameWindow'] = array(
    '#type' => 'checkbox',
    '#title' => t('Open events in same window'),
    '#default_value' => $view->options['sameWindow'],
    '#data_type' => 'bool',
    '#fieldset' => 'style',
  );
  $form['contentHeight'] = array(
    '#type' => 'textfield',
    '#title' => t('Calendar height'),
    '#size' => 4,
    '#default_value' => $view->options['contentHeight'],
    '#field_suffix' => 'px',
    '#data_type' => 'int',
    '#fieldset' => 'style',
  );
  if (module_implements('fullcalendar_droppable')) {
    $form['droppable'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow external events to be added via drag and drop'),
      '#default_value' => $view->options['droppable'],
      '#data_type' => 'bool',
      '#fieldset' => 'style',
    );
  }
  $form['editable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Prevent editing events via drag-and-drop'),
    '#default_value' => $view->options['editable'],
    '#data_type' => 'bool',
    '#fieldset' => 'style',
    '#description' => t('Modules can set custom access rules, but this will override those.'),
  );

  // Get the regular fields.
  $field_options = $view->display->handler
    ->get_field_labels();

  // Get the date fields.
  $date_fields = $view
    ->fullcalendar_parse_fields();
  $form['fields'] = array(
    '#type' => 'fieldset',
    '#title' => t('Customize fields'),
    '#description' => t('Add fields to the view in order to customize fields below.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['fields']['title'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use a custom title'),
    '#default_value' => $view->options['fields']['title'],
    '#data_type' => 'bool',
    '#fieldset' => 'fields',
  );
  $form['fields']['title_field'] = array(
    '#type' => 'select',
    '#title' => t('Title field'),
    '#options' => $field_options,
    '#default_value' => $view->options['fields']['title_field'],
    '#description' => t('Choose the field with the custom title.'),
    '#process' => array(
      'form_process_select',
    ),
    '#dependency' => array(
      'edit-style-options-fields-title' => array(
        1,
      ),
    ),
    '#fieldset' => 'fields',
  );
  $form['fields']['url'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use a custom redirect URL'),
    '#default_value' => $view->options['fields']['url'],
    '#data_type' => 'bool',
    '#fieldset' => 'fields',
  );
  $form['fields']['url_field'] = array(
    '#type' => 'select',
    '#title' => t('URL field'),
    '#options' => $field_options,
    '#default_value' => $view->options['fields']['url_field'],
    '#description' => t('Choose the field with the custom link.'),
    '#process' => array(
      'form_process_select',
    ),
    '#dependency' => array(
      'edit-style-options-fields-url' => array(
        1,
      ),
    ),
    '#fieldset' => 'fields',
  );
  $form['fields']['date'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use a custom date field'),
    '#default_value' => $view->options['fields']['date'],
    '#data_type' => 'bool',
    '#fieldset' => 'fields',
  );
  $form['fields']['date_field'] = array(
    '#type' => 'select',
    '#title' => t('Date fields'),
    '#options' => $date_fields,
    '#default_value' => $view->options['fields']['date_field'],
    '#description' => t('Select one or more date fields.'),
    '#multiple' => TRUE,
    '#size' => count($date_fields),
    '#process' => array(
      'form_process_select',
    ),
    '#dependency' => array(
      'edit-style-options-fields-date' => array(
        1,
      ),
    ),
    '#fieldset' => 'fields',
  );

  // Disable form elements when not needed.
  if (empty($field_options)) {
    $form['fields']['#description'] = t('All the options are hidden, you need to add fields first.');
    $form['fields']['title']['#type'] = 'hidden';
    $form['fields']['url']['#type'] = 'hidden';
    $form['fields']['date']['#type'] = 'hidden';
    $form['fields']['title_field']['#disabled'] = TRUE;
    $form['fields']['url_field']['#disabled'] = TRUE;
    $form['fields']['date_field']['#disabled'] = TRUE;
  }
  elseif (empty($date_fields)) {
    $form['fields']['date']['#type'] = 'hidden';
    $form['fields']['date_field']['#disabled'] = TRUE;
  }
}