You are here

function _calendar_setup_form in Calendar 5

Same name and namespace in other branches
  1. 5.2 calendar_admin.inc \_calendar_setup_form()

Setup Calendar parameters.

1 call to _calendar_setup_form()
calendar_setup_form in ./calendar.module
Setup Calendar parameters in the Setup Tab.

File

./calendar_admin.inc, line 219
This file contains administrative functions used only when setting up the calendar and views_hooks() that are called infrequently and cached. No need to parse all this code the rest of the time.

Code

function _calendar_setup_form($view_name) {
  calendar_load_date_api();
  $view = views_load_view($view_name);
  $form = array();
  $time = mktime(1, 15, 0, 1, 1, date('Y', date_time()));
  $time_options = array(
    'G:i' => date('G:i', $time),
    'g:ia' => date('g:ia', $time),
    'g:iA' => date('g:iA', $time),
    'g:i a' => date('g:i a', $time),
    'g:i A' => date('g:i A', $time),
    'H:i' => date('H:i', $time),
    'h:ia' => date('h:ia', $time),
    'h:iA' => date('h:iA', $time),
    'h:i a' => date('h:i a', $time),
    'h:i A' => date('h:i A', $time),
  );
  $form['calendar_time_format'] = array(
    '#title' => t('Time format'),
    '#default_value' => variable_get('calendar_time_format_' . $view->name, 'H:i'),
    '#type' => 'select',
    '#options' => $time_options,
    '#description' => t('The format to use for the time-only date display.'),
  );
  $display_options = array(
    'calendar' => t('Calendar'),
    'table' => t('Table'),
    'teasers' => t('Teasers'),
    'nodes' => t('Full Nodes'),
    'list' => t('List'),
  );
  $display_format = variable_get('calendar_display_format_' . $view->name, array(
    'year' => 'calendar',
    'month' => 'calendar',
    'week' => 'calendar',
    'day' => 'calendar',
    'block' => 'calendar',
  ));
  $form['year'] = array(
    '#title' => t('Year display'),
    '#default_value' => $display_format['year'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['month'] = array(
    '#title' => t('Month display'),
    '#default_value' => $display_format['month'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['week'] = array(
    '#title' => t('Week display'),
    '#default_value' => $display_format['week'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['day'] = array(
    '#title' => t('Day display'),
    '#default_value' => $display_format['day'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['block'] = array(
    '#title' => t('Block display'),
    '#default_value' => $display_format['block'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['calendar_empty_arg'] = array(
    '#title' => t('Wildcard argument'),
    '#type' => 'textfield',
    '#default_value' => variable_get('calendar_empty_arg', 'all'),
    '#description' => t('A character or short text string to use for empty calendar arguments. For instance, \'all\' would create the url 2007/12/all to show all days in December of 2007. Note that non-ASCII characters will not display correctly in urls.'),
  );
  $form['view_name'] = array(
    '#type' => 'hidden',
    '#value' => $view->name,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}