1.20.x system.theme.inc theme_status_report($variables)

Returns HTML for the status report.

This theme function is dependent on install.inc being loaded, because that's where the constants are defined.

Parameters

$variables: An associative array containing:

  • requirements: An array of requirements/status items. Each requirement is an associative array containing the following elements:

    • title: The name of the requirement.
    • value: (optional) The current value (version, time, level, etc).
    • description: (optional) The description of the requirement.
    • severity: (optional) The requirement's result/severity level, one of:

Related topics

File

modules/system/system.theme.inc, line 288
Theme functions for the System module.

Code

function theme_status_report($variables) {
  $requirements = $variables['requirements'];
  backdrop_sort($requirements, array('title' => SORT_STRING));

  // Separate requirements by severity.
  $errors = array();
  $warnings = array();
  $infos = array();
  $okays = array();
  foreach ($requirements as $requirement) {
    if (!isset($requirement['severity'])) {
      $requirement['severity'] = REQUIREMENT_OK;
    }
    switch ($requirement['severity']) {
      case REQUIREMENT_ERROR:
        $errors[] = $requirement;
        break;
      case REQUIREMENT_WARNING:
        $warnings[] = $requirement;
        break;
      case REQUIREMENT_INFO:
        $infos[] = $requirement;
        break;
      case REQUIREMENT_OK:
        $okays[] = $requirement;
        break;
    }
  }
  // Put them back together in the desired order.
  $requirements = array_merge($errors, $warnings, $infos, $okays);

  $severities = array(
    REQUIREMENT_INFO => array(
      'title' => t('Info'),
      'class' => array('report-info'),
    ),
    REQUIREMENT_OK => array(
      'title' => t('OK'),
      'class' => array('report-status'),
    ),
    REQUIREMENT_WARNING => array(
      'title' => t('Warning'),
      'class' => array('report-warning'),
    ),
    REQUIREMENT_ERROR => array(
      'title' => t('Error'),
      'class' => array('report-error'),
    ),
  );

  $system_status_report_table = array(
    'header' => array(),
    'rows' => array(),
    'attributes' => array('class' => 'system-status-report'),
    'caption' => '',
    'colgroups' => array(),
    'sticky' => FALSE,
    'empty' => 'No status report. Something is definitely wrong.',
  );

  $rows = array();
  foreach ($requirements as $requirement) {
    $severity = $severities[isset($requirement['severity']) ? (int) $requirement['severity'] : REQUIREMENT_OK];
    $severity['icon'] = '<div title="' . $severity['title'] . '"><span class="element-invisible">' . $severity['title'] . '</span></div>';

    // The requirement's 'value' key is optional, provide a default value.
    $requirement['value'] = isset($requirement['value']) ? $requirement['value'] : '';

    $title = $requirement['title'] . '<br/>';
    $title .= '<span class="status-summary-mobile">' . $requirement['value'] . '</span>';

    $more = ' ';
    $details = '';
    if (!empty($requirement['description'])) {
      $more .= '<a class="description-toggle" href="#">more</a>';
      $details = '<div class="status-description">' . $requirement['description'] . '</div>';
    }

    $description = '<div class="status-summary">' . $requirement['value'] . $more . '</div>' . $details;

    $row = array(
      'data' => array(
        array('data' => $severity['icon'], 'class' => 'report-icon'),
        array('data' => $title, 'class' => 'status-title'),
        array('data' => $description, 'class' => array('status-value', 'priority-low')),
      ),
      'class' => $severity['class'],
    );

    $rows[] = $row;
  }

  $system_status_report_table['rows'] = $rows;
  $path = backdrop_get_path('module', 'system');
  backdrop_add_js($path . '/js/status.js');

  return theme_table($system_status_report_table);
}