You are here

function template_preprocess_fullcalendar in FullCalendar 7.2

Same name and namespace in other branches
  1. 8 fullcalendar.theme.inc \template_preprocess_fullcalendar()
  2. 8.3 fullcalendar.theme.inc \template_preprocess_fullcalendar()
  3. 6.2 theme/theme.inc \template_preprocess_fullcalendar()

Builds the FullCalendar structure as a render array.

File

theme/theme.inc, line 11
Preprocess functions for FullCalendar.

Code

function template_preprocess_fullcalendar(&$variables) {
  $events = fullcalendar_prepare_events($variables['view'], $variables['rows'], $variables['options']['fields']);

  // If we're using ajax, we're done.
  if (!empty($variables['view']->fullcalendar_ajax)) {
    $variables['element'] = $events;
    return;
  }
  $variables['element'] = array(
    'status' => array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'fullcalendar-status',
        ),
      ),
    ),
    'fullcalendar' => array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'fullcalendar',
        ),
      ),
    ),
    'content' => array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'fullcalendar-content',
        ),
      ),
    ),
  );
  if ($events) {
    $variables['element']['content']['events'] = $events;
  }

  // Gather options from all modules.
  $settings = array();
  fullcalendar_include_api();
  $fullcalendar_options = module_invoke_all('fullcalendar_options_info');
  uasort($fullcalendar_options, 'drupal_sort_weight');
  foreach (array_intersect(array_keys($fullcalendar_options), module_implements('fullcalendar_options_process')) as $module) {
    $function = $module . '_fullcalendar_options_process';
    $function($variables, $settings);
  }

  // Add settings to Drupal.settings.
  $variables['element']['#attached']['js'][] = array(
    'type' => 'setting',
    'data' => array(
      'fullcalendar' => array(
        '.view-dom-id-' . $variables['view']->dom_id => $settings,
      ),
    ),
  );
}