You are here

function calendar_systems_profile_overview in Calendar Systems 7.3

Same name and namespace in other branches
  1. 8 calendar_systems.admin.inc \calendar_systems_profile_overview()
  2. 6.3 calendar_systems.admin.inc \calendar_systems_profile_overview()
  3. 6 calendar_systems.admin.inc \calendar_systems_profile_overview()
  4. 7 calendar_systems.admin.inc \calendar_systems_profile_overview()
  5. 7.2 calendar_systems.admin.inc \calendar_systems_profile_overview()

Form callback for calendar systems profiles.

1 string reference to 'calendar_systems_profile_overview'
calendar_systems_menu in ./calendar_systems.module
Implements hook_menu().

File

./calendar_systems.admin.inc, line 13
Contains Calendar Systems administration form callbacks.

Code

function calendar_systems_profile_overview($form, &$form_state) {
  $form = array();
  if (_calendar_systems_patch_applied() !== TRUE) {
    drupal_set_message(t('There is a problem with calendar systems installation, please visit <a href="!readme-link">site status page</a> for more information.', array(
      '!readme-link' => url('admin/reports/status'),
    )), 'warning', FALSE);
  }

  // build the overview form array.
  $form['formats'] = array();
  $form['formats']['#tree'] = TRUE;

  // Set initials.
  $options = array();
  $profiles = _calendar_systems_profiles();
  $languages = _calendar_systems_langauges();
  $calendar_systems = _calendar_systems_plugins();

  // Build available calendar systems array:
  foreach ($calendar_systems as $id => $calendar_system) {
    $options[$id] = $calendar_system['title'];
  }

  // Table rows:
  foreach ($languages as $id => $language) {

    // Language:
    $form['formats'][$id]['name'] = array(
      '#type' => 'markup',
      '#markup' => check_plain($language['name']),
    );

    // Calendar systems:
    $form['formats'][$id]['editor'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#id' => "edit-editor-{$id}",
      '#default_value' => isset($profiles[$id]) ? $profiles[$id]->calendar_system : '',
      '#disabled' => isset($profiles[$id]) ? (bool) $profiles[$id]->calendar_system : FALSE,
    );

    // Operation links:
    if (isset($profiles[$id]) && !empty($profiles[$id]->calendar_system)) {
      $form['formats'][$id]['remove'] = array(
        '#type' => 'markup',
        '#markup' => l(t('Remove'), "admin/config/regional/calendar-systems/profile/{$id}/delete"),
      );
    }
  }

  // Append submit button:
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );

  // Render:
  return $form;
}