You are here

function theme_update_advanced_settings in Update Status Advanced Settings 6

Same name and namespace in other branches
  1. 7 update_advanced.settings.inc \theme_update_advanced_settings()

Theme function for the update status settings tab.

Formats the table of per-project settings, and renders the rest of the form elements into their proper places for maximum clarity.

File

./update_advanced.settings.inc, line 77
Code only required on the settings tab of the update status page.

Code

function theme_update_advanced_settings($form) {
  $output = '';
  $output .= drupal_render($form['update_notify_emails']);
  $output .= drupal_render($form['update_check_frequency']);
  $output .= drupal_render($form['update_notification_threshold']);
  $output .= drupal_render($form['update_advanced_check_disabled']);
  $header = array(
    array(
      'data' => t('Project'),
      'class' => 'update-advanced-project',
    ),
    array(
      'data' => t('Warn if out of date'),
      'class' => 'update-advanced-status',
    ),
    array(
      'data' => t('Notes'),
      'class' => 'update-advanced-notes',
    ),
  );
  $data = $form['data']['#value'];
  $available = $form['available']['#value'];
  $rows = array();
  foreach ($data as $key => $project) {
    if (isset($available[$key])) {
      $row = array();
      $row[] = array(
        'class' => 'update-project',
        'data' => check_plain($available[$key]['title']),
      );
      $row[] = array(
        'class' => 'update-status',
        'data' => drupal_render($form['update_advanced_project_settings'][$key]['check']),
      );
      $row[] = array(
        'class' => 'update-notes',
        'data' => drupal_render($form['update_advanced_project_settings'][$key]['notes']),
      );
      if (!isset($rows[$project['project_type']])) {
        $rows[$project['project_type']] = array();
      }
      $row_key = drupal_strtolower($available[$key]['title']);
      $rows[$project['project_type']][$row_key] = $row;
    }
  }
  $split_rows = array();
  $project_types = array(
    'core' => t('Drupal core'),
    'module' => t('Modules'),
    'theme' => t('Themes'),
    'disabled-module' => t('Disabled modules'),
    'disabled-theme' => t('Disabled themes'),
  );
  foreach ($project_types as $type_name => $type_label) {
    if (!empty($rows[$type_name])) {
      $split_rows[] = array(
        'class' => 'update-advanced-settings-label',
        'data' => array(
          array(
            'class' => 'update-advanced-settings-label',
            'data' => $type_label,
            'colspan' => 3,
          ),
        ),
      );
      ksort($rows[$type_name]);
      $split_rows = array_merge($split_rows, $rows[$type_name]);
    }
  }
  $output .= theme('table', $header, $split_rows, array(
    'class' => 'update-advanced-settings',
  ));
  $output .= '<div class="form-item"><div class="description">' . "\n";
  $output .= drupal_render($form['update_advanced_project_settings_help']);
  $output .= "</div></div>\n";
  $output .= drupal_render($form['buttons']);
  $output .= drupal_render($form);
  return $output;
}