You are here

function theme_calendar_systems_calendars_form in Calendar Systems 6.2

Theme callback for calendars listing form.

Parameters

$form: Admin form array.

Return value

From themed output.

File

./calendar_systems.admin.inc, line 106
Implements necessary callbacks for Calendar Systems administration forms.

Code

function theme_calendar_systems_calendars_form($form) {

  // Include damn patch helpers.
  module_load_include('patch.inc', 'calendar_systems');

  // Theme the form as a table only if the
  // required patches are already applied.
  if (_calendar_systems_patches_applied()) {
    $rows = array();

    // Set form table rows.
    foreach ($form['sitewide'] as $name => $element) {

      // Skip if it's not a fake element.
      if (!isset($element['_id']) || !is_array($element['_id'])) {
        continue;
      }

      // Loadup row.
      $rows[] = array(
        drupal_render($form['default_calendar'][$element['_id']['#value']]),
        check_plain($name),
        drupal_render($element['_config']),
      );
    }
    unset($form['sitewide']);

    // Sets form table header.
    $header = array(
      t('Default'),
      t('Calendar'),
      array(
        'colspan' => 1,
        'data' => t('Actions'),
      ),
    );
    $output = '<h3>' . t('System Default Calendar') . '</h3>';
    $output .= theme('table', $header, $rows);
    $output .= drupal_render($form);
    return $output;
  }

  // Patch is not yet applied.
  return drupal_render($form);
}