You are here

function _calendar_setup_form in Calendar 5.2

Same name and namespace in other branches
  1. 5 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.
1 string reference to '_calendar_setup_form'
calendar_menu in ./calendar.module
Implementation of hook_menu().

File

./calendar_admin.inc, line 322
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) {
  $view = views_get_view($view_name);
  $form = array();
  $time = mktime(1, 15, 0, 1, 1, date('Y', 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['markup'] = array(
    '#type' => 'markup',
    '#value' => _calendar_settings_header($view),
  );
  $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.'),
  );
  $form['calendar_day_header'] = array(
    '#title' => t('Mini day name size'),
    '#default_value' => variable_get('calendar_day_header_' . $view->name, 1),
    '#type' => 'select',
    '#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 mini calendar.'),
  );
  $form['calendar_full_day_header'] = array(
    '#title' => t('Full day name size'),
    '#default_value' => variable_get('calendar_full_day_header_' . $view->name, 3),
    '#type' => 'select',
    '#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 full size calendar.'),
  );
  $form['calendar_weekno'] = array(
    '#title' => t('Show week numbers'),
    '#type' => 'select',
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#default_value' => variable_get('calendar_weekno_' . $view->name, 1),
    '#description' => t('Whether or not to display a clickable week number link on the left side of each calendar week.'),
  );
  $form['calendar_popup'] = array(
    '#title' => t('Popup date selector'),
    '#type' => 'select',
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#default_value' => variable_get('calendar_popup_' . $view->name, module_exists('date_popup')),
    '#description' => t('Whether or not to display a popup date selector to change the calendar period. (Only works when the Date Popup module is enabled.)'),
  );
  $form['calendar_limit'] = array(
    '#title' => t('Maximum items'),
    '#type' => 'select',
    '#options' => array(
      0 => t('Unlimited'),
      3 => t('3 items'),
      5 => t('5 items'),
      10 => t('10 items'),
    ),
    '#default_value' => variable_get('calendar_limit_' . $view->name, 5),
    '#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. '),
  );
  $form['calendar_limit_behavior'] = array(
    '#title' => t('Too many items'),
    '#type' => $calendar_type != 'day' ? 'select' : 'hidden',
    '#options' => array(
      'more' => t("Show maximum, add 'more' link"),
      'hide' => t('Hide all, add link to day'),
    ),
    '#default_value' => variable_get('calendar_limit_behavior_' . $view->name, '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.'),
  );
  $form['calendar_truncate_length'] = array(
    '#title' => t('Truncate length'),
    '#type' => 'textfield',
    '#default_value' => variable_get('calendar_truncate_length_' . $view->name, ''),
    '#description' => t("Truncate size for titles in month and week view so things fit better into the calendar cell. For instance, change the title from 'Very Very Very Long Name' to something like 'Very Very...'."),
    '#maxlength' => 4,
    '#size' => 4,
  );
  $display_options = array(
    'calendar' => t('Calendar'),
    'table' => t('Table'),
    'teasers' => t('Teasers'),
    'nodes' => t('Full Nodes'),
    'list' => t('List'),
    '' => t('None'),
  );
  $display_format = variable_get('calendar_display_format_' . $view->name, array(
    'year' => 'calendar',
    'month' => 'calendar',
    'week' => 'calendar',
    'day' => 'calendar',
    'block' => 'calendar',
  ));
  $form['display'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display options'),
    '#description' => t('Choose the way the calendar entries should be displayed. Selecting \'None\' will hide links to that option.'),
  );
  $form['display']['year'] = array(
    '#title' => t('Year display'),
    '#default_value' => $display_format['year'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['display']['month'] = array(
    '#title' => t('Month display'),
    '#default_value' => $display_format['month'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['display']['week'] = array(
    '#title' => t('Week display'),
    '#default_value' => $display_format['week'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['display']['day'] = array(
    '#title' => t('Day display'),
    '#default_value' => $display_format['day'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['display']['block'] = array(
    '#title' => t('Block display'),
    '#default_value' => $display_format['block'],
    '#type' => 'select',
    '#options' => $display_options,
  );
  $form['calendar_year_range'] = array(
    '#title' => t('Date year range'),
    '#type' => 'textfield',
    '#default_value' => variable_get('calendar_year_range_' . $view->name, '-3:+3'),
    '#description' => t("Set the allowable minimum and maximum year range for this view, either a -X:+X offset from the current year, like '-3:+3' or an absolute minimum and maximum year, like '2005:2010'.  When the argument is set to a date outside the range, the page will be returned as 'Page not found (404)'."),
  );
  $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;
}