You are here

function fullcalendar_get_settings in FullCalendar 6.2

2 calls to fullcalendar_get_settings()
fullcalendar_handler_area_empty::render in includes/views/handlers/fullcalendar_handler_area_empty.inc
Render the area
template_preprocess_fullcalendar in theme/theme.inc
Passes options to the FullCalendar plugin as JavaScript settings.

File

./fullcalendar.module, line 138
Provides a views style plugin for FullCalendar

Code

function fullcalendar_get_settings($view) {
  global $language;
  $options = $view->style_plugin->options;
  static $fc_dom_id = 1;
  if (empty($view->dom_id)) {
    $view->dom_id = 'fc-' . $fc_dom_id++;
  }
  $dom_id = '.view-dom-id-' . $view->dom_id;
  $options['gcal'] = array();
  foreach ($view->field as $field) {
    if ($field->field == 'gcal') {
      $options['gcal'][] = $field
        ->render(array());
    }
  }
  $settings = array(
    $dom_id => array(
      'defaultView' => $options['display']['fc_view'],
      'firstDay' => $options['display']['fc_firstday'],
      'weekMode' => $options['display']['fc_weekmode'],
      'theme' => $options['modules']['fc_theme'],
      'sameWindow' => $options['modules']['fc_window'],
      'colorbox' => $options['modules']['fc_url_colorbox'],
      'colorboxClass' => $options['modules']['fc_url_colorbox_class'],
      'colorboxWidth' => $options['modules']['fc_url_colorbox_width'],
      'colorboxHeight' => $options['modules']['fc_url_colorbox_height'],
      'left' => $options['header']['fc_left'],
      'center' => $options['header']['fc_center'],
      'right' => $options['header']['fc_right'],
      'agenda' => $options['times']['fc_timeformat'],
      'clock' => $options['times']['fc_clock'],
      'monthNames' => array_values(date_month_names(TRUE)),
      'monthNamesShort' => array_values(date_month_names_abbr(TRUE)),
      'dayNames' => date_week_days(TRUE),
      'dayNamesShort' => date_week_days_abbr(TRUE),
      'allDayText' => t('All day'),
      'dayString' => t('Day'),
      'weekString' => t('Week'),
      'monthString' => t('Month'),
      'todayString' => t('Today'),
      'isRTL' => $language->direction,
      'gcal' => $options['gcal'],
    ),
  );
  if ($options['times']['fc_default_date']) {
    $settings[$dom_id]['year'] = $options['times']['fc_date']['year'];
    $settings[$dom_id]['month'] = $options['times']['fc_date']['month'];
    $settings[$dom_id]['day'] = $options['times']['fc_date']['day'];
  }
  extract($view
    ->get_exposed_input(), EXTR_SKIP);
  if (isset($year) && is_numeric($year)) {
    $settings[$dom_id]['year'] = $year;
  }
  if (isset($month) && is_numeric($month) && $month > 0 && $month <= 12) {
    $settings[$dom_id]['month'] = $month;
  }
  if (isset($day) && is_numeric($day) && $day > 0 && $day <= 31) {
    $settings[$dom_id]['day'] = $day;
  }
  if (isset($mode) && in_array($mode, array(
    'month',
    'basicWeek',
    'basicDay',
    'agendaWeek',
    'agendaDay',
  ))) {
    $settings[$dom_id]['defaultView'] = $mode;
  }
  drupal_add_js(array(
    'fullcalendar' => $settings,
  ), 'setting');
  drupal_add_js(drupal_get_path('module', 'fullcalendar') . '/js/fullcalendar.library.js', 'module');
  drupal_add_js(drupal_get_path('module', 'fullcalendar') . '/js/fullcalendar.fullcalendar.js', 'module');
  drupal_add_js(drupal_get_path('module', 'fullcalendar') . '/js/fullcalendar.views.js', 'module');
  drupal_add_js(fullcalendar_get_js_path());
  drupal_add_css(variable_get('fullcalendar_path', FULLCALENDAR_PATH) . '/fullcalendar.css');
  drupal_add_js(variable_get('fullcalendar_path', FULLCALENDAR_PATH) . '/gcal.js');
  drupal_add_css(drupal_get_path('module', 'fullcalendar') . '/css/fullcalendar.theme.css');

  // We need some jQuery UI files.
  $files = array(
    'ui.draggable',
    'ui.droppable',
    'ui.resizable',
    'effects.highlight',
  );
  jquery_ui_add($files);
}