1 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.
@since 1.26.2 support for the "phase" variable added.
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:
- REQUIREMENT_INFO: Status information.
- REQUIREMENT_OK: The requirement is satisfied.
- REQUIREMENT_WARNING: The requirement failed with a warning.
- REQUIREMENT_ERROR: The requirement failed with an error.
- phase: The current phase. Possible values are one of:
- install: When called from install.php.
- update: When called from update.php.
- runtime: Showing the normal status report page, or no phase specified.
Related topics
File
- core/
modules/ system/ system.theme.inc, line 309 - Theme functions for the System module.
Code
function theme_status_report($variables) {
$requirements = $variables['requirements'];
$phase = isset($variables['phase']) ? $variables['phase'] : 'runtime';
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' => array('system-status-report', 'phase-' . $phase)),
'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>';
}
// For the "Requirements problem" page of the installer, place the label and
// the description of each check/row in a single table cell.
if ($phase == 'install') {
$description = '<div class="status-summary status-value">' . $requirement['value'] . $more . '</div>' . $details;
$data = array(
array('data' => $severity['icon'], 'class' => 'report-icon'),
array('data' => $title . $description, 'class' => 'status-title'),
);
}
// For the site status report page, place the label and the description of
// each check in separate table cells in the same row.
else {
$description = '<div class="status-summary">' . $requirement['value'] . $more . '</div>' . $details;
$data = array(
array('data' => $severity['icon'], 'class' => 'report-icon'),
array('data' => $title, 'class' => 'status-title'),
array('data' => $description, 'class' => array('status-value', 'priority-low')),
);
}
$row = array(
'data' => $data,
'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);
}