You are here

function availability_calendar_admin_settings in Availability Calendars 7.4

Same name and namespace in other branches
  1. 7.5 availability_calendar.admin.inc \availability_calendar_admin_settings()
  2. 7.3 availability_calendar.admin.inc \availability_calendar_admin_settings()

Defines form callback for the admin/config/availability-calendar/settings page.

Parameters

array $form: The form.

Return value

array The form.

1 string reference to 'availability_calendar_admin_settings'
availability_calendar_menu in ./availability_calendar.module
Implements hook_menu(). @link http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...

File

./availability_calendar.admin.inc, line 21

Code

function availability_calendar_admin_settings($form) {
  drupal_add_css(drupal_get_path('module', 'availability_calendar') . '/availability_calendar.admin.css');
  $form['#validate'][] = 'availability_calendar_admin_settings_validate';
  $form['#submit'][] = 'availability_calendar_admin_settings_submit';

  // Information about date formatting (including links).
  $form['date_formatting'] = array(
    '#type' => 'item',
    '#title' => t('Date formats'),
    '#description' => t('<p class="no-space">Availability calendar defines 3 date types:</p>
<ul>
<li>@datetype1: Used to display dates to users. This is on the booking formlet.</li>
<li>@datetype2: Used in places where users can input dates. This is in the Views exposed filter when searching on availability.</li>
<li>@datetype3: Used as caption above a month when the calendar is being displayed.</li>
  </ul>
<p>You can change the formats of these date types at !link1. If you want different date formats per language, you can localize the date types at !link2. Note that you should only use date parts, no time parts.</p>', array(
      '@datetype1' => t('Availability Calendar date display'),
      '@datetype2' => t('Availability Calendar date entry'),
      '@datetype3' => t('Availability Calendar month caption'),
      '!link1' => l(t('Date and time'), 'admin/config/regional/date-time'),
      '!link2' => l(t('Date and time') . ' - ' . t('Localize'), 'admin/config/regional/date-time/locale'),
    )),
  );

  // Add states.
  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('States'),
    '#description' => t('<p>You can modify the availability states here.</p>
      <ul>
        <li>The label is what visitors will see in the legend and what editors will see when editing the calendar.</li>
        <li>The class should be unique and will be used for the css.</li>
        <li>The "Treat as available" checkbox defines whether this state should be treated as available in searches for availability.</li>
        <li>The weight defines the order in the legend.</li>
        <li>Make a label empty to remove the row.</li>
        <li>If there are no more empty lines to add new states, save the form and you will be able to add another state.</li>
        <li>If you change or define new classes, visit the styling page to define its colors.</li>
      </ul>
    '),
  );

  // Create a draggable table
  $header = array(
    t('Id'),
    t('Label'),
    t('CSS Class'),
    t('Treat as available?'),
    t('Weight'),
  );
  $form['states'] = array(
    '#type' => 'markup',
    '#tree' => TRUE,
    '#theme' => 'table',
    '#pre_render' => array(
      'availability_calendar_admin_settings_pre_render',
    ),
    '#header' => $header,
    '#attributes' => array(
      'id' => 'state-list',
    ),
  );
  $i = 0;
  foreach (availability_calendar_get_states() as $state) {
    $form['states'][$i++] = availability_calendar_admin_settings_add_state($state);
  }

  // Show a minimum of 6 available states with at least one empty state.
  do {
    $form['states'][$i++] = availability_calendar_admin_settings_add_state(array(
      'sid' => 0,
      'label' => '',
      'css_class' => '',
      'is_available' => 0,
      'weight' => 0,
    ));
  } while ($i < 6);
  drupal_add_tabledrag('state-list', 'order', 'sibling', 'state-weight');
  return system_settings_form($form);
}