class SiteAuditCheckStatusSystem in Site Audit 8.2
Same name and namespace in other branches
- 7 Check/Status/System.php \SiteAuditCheckStatusSystem
Class SiteAuditCheckStatusSystem.
Hierarchy
- class \SiteAuditCheckAbstract
- class \SiteAuditCheckStatusSystem
Expanded class hierarchy of SiteAuditCheckStatusSystem
File
- Check/
Status/ System.php, line 10 - Contains \SiteAudit\Check\Status\System.
View source
class SiteAuditCheckStatusSystem extends SiteAuditCheckAbstract {
/**
* Implements \SiteAudit\Check\Abstract\getLabel().
*/
public function getLabel() {
return dt('System Status');
}
/**
* Implements \SiteAudit\Check\Abstract\getDescription().
*/
public function getDescription() {
return dt("Drupal's status report.");
}
/**
* Implements \SiteAudit\Check\Abstract\getResultFail().
*/
public function getResultFail() {
return $this
->getResultPass();
}
/**
* Implements \SiteAudit\Check\Abstract\getResultInfo().
*/
public function getResultInfo() {
}
/**
* Implements \SiteAudit\Check\Abstract\getResultPass().
*/
public function getResultPass() {
$items = array();
foreach ($this->registry['requirements'] as $requirement) {
// Default to REQUIREMENT_INFO if no severity is set.
if (!isset($requirement['severity'])) {
$requirement['severity'] = REQUIREMENT_INFO;
}
// Reduce verbosity.
if (!drush_get_option('detail') && $requirement['severity'] < REQUIREMENT_WARNING) {
continue;
}
// Title: severity - value.
if ($requirement['severity'] == REQUIREMENT_INFO) {
$class = 'info';
$severity = 'Info';
}
elseif ($requirement['severity'] == REQUIREMENT_OK) {
$severity = 'Ok';
$class = 'success';
}
elseif ($requirement['severity'] == REQUIREMENT_WARNING) {
$severity = 'Warning';
$class = 'warning';
}
elseif ($requirement['severity'] == REQUIREMENT_ERROR) {
$severity = 'Error';
$class = 'error';
}
if (drush_get_option('html')) {
$value = isset($requirement['value']) && $requirement['value'] ? $requirement['value'] : ' ';
$uri = drush_get_context('DRUSH_URI');
// Unknown URI - strip all links, but leave formatting.
if ($uri == 'http://default') {
$value = strip_tags($value, '<em><i><b><strong><span>');
}
else {
$value = preg_replace("#(<\\s*a\\s+[^>]*href\\s*=\\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#", '$1' . $uri . '$2$3', $value);
}
$item = array(
'title' => $requirement['title'],
'severity' => $severity,
'value' => $value,
'class' => $class,
);
}
else {
$item = strip_tags($requirement['title']) . ': ' . $severity;
if (isset($requirement['value']) && $requirement['value']) {
$item .= ' - ' . dt('@value', array(
'@value' => strip_tags($requirement['value']),
));
}
}
$items[] = $item;
}
if (drush_get_option('html')) {
$ret_val = '<table class="table table-condensed">';
$ret_val .= '<thead><tr><th>' . dt('Title') . '</th><th>' . dt('Severity') . '</th><th>' . dt('Value') . '</th></thead>';
$ret_val .= '<tbody>';
foreach ($items as $item) {
$ret_val .= '<tr class="' . $item['class'] . '">';
$ret_val .= '<td>' . $item['title'] . '</td>';
$ret_val .= '<td>' . $item['severity'] . '</td>';
$ret_val .= '<td>' . $item['value'] . '</td>';
$ret_val .= '</tr>';
}
$ret_val .= '</tbody>';
$ret_val .= '</table>';
}
else {
$separator = PHP_EOL;
if (!drush_get_option('json')) {
$separator .= str_repeat(' ', 4);
}
$ret_val = implode($separator, $items);
}
return $ret_val;
}
/**
* Implements \SiteAudit\Check\Abstract\getResultWarn().
*/
public function getResultWarn() {
return $this
->getResultPass();
}
/**
* Implements \SiteAudit\Check\Abstract\getAction().
*/
public function getAction() {
}
/**
* Implements \SiteAudit\Check\Abstract\calculateScore().
*/
public function calculateScore() {
// See system/system.admin.inc function system_status().
// Load .install files.
include_once DRUPAL_ROOT . '/core/includes/install.inc';
drupal_load_updates();
// Check run-time requirements and status information.
$this->registry['requirements'] = \Drupal::moduleHandler()
->invokeAll('requirements', array(
'runtime',
));
usort($this->registry['requirements'], function ($a, $b) {
if (!isset($a['weight'])) {
if (!isset($b['weight'])) {
return strcmp($a['title'], $b['title']);
}
return -$b['weight'];
}
return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
});
$this->percentOverride = 0;
$requirements_with_severity = array();
foreach ($this->registry['requirements'] as $key => $value) {
if (isset($value['severity'])) {
$requirements_with_severity[$key] = $value;
}
}
$score_each = 100 / count($requirements_with_severity);
$worst_severity = REQUIREMENT_INFO;
foreach ($this->registry['requirements'] as $requirement) {
if (isset($requirement['severity'])) {
if ($requirement['severity'] > $worst_severity) {
$worst_severity = $requirement['severity'];
}
if ($requirement['severity'] == REQUIREMENT_WARNING) {
$this->percentOverride += $score_each / 2;
}
elseif ($requirement['severity'] != REQUIREMENT_ERROR) {
$this->percentOverride += $score_each;
}
}
}
$this->percentOverride = round($this->percentOverride);
if ($this->percentOverride > 80) {
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
}
elseif ($this->percentOverride > 60) {
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
}
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SiteAuditCheckAbstract:: |
protected | property | Indicate that no other checks should be run after this check. | |
SiteAuditCheckAbstract:: |
private static | property | Use for checking whether custom code paths have been validated. | |
SiteAuditCheckAbstract:: |
protected | property | User has opted out of this check in configuration. | |
SiteAuditCheckAbstract:: |
protected | property | If set, will override the Report's percentage. | |
SiteAuditCheckAbstract:: |
protected | property | Use for passing data between checks within a report. | |
SiteAuditCheckAbstract:: |
protected | property | Quantifiable number associated with result on a scale of 0 to 2. | |
SiteAuditCheckAbstract:: |
constant | |||
SiteAuditCheckAbstract:: |
constant | |||
SiteAuditCheckAbstract:: |
constant | |||
SiteAuditCheckAbstract:: |
constant | |||
SiteAuditCheckAbstract:: |
public | function | Returns an array containing custom code paths or AUDIT_CHECK_SCORE_INFO. | |
SiteAuditCheckAbstract:: |
public | function | Returns the path of the executable. | |
SiteAuditCheckAbstract:: |
public | function | Returns the values of the valid options for a command. | |
SiteAuditCheckAbstract:: |
public | function | Get the report percent override, if any. | |
SiteAuditCheckAbstract:: |
public | function | Get the check registry. | |
SiteAuditCheckAbstract:: |
public | function | Gives path relative to DRUPAL_ROOT of the path is inside Drupal. | |
SiteAuditCheckAbstract:: |
public | function | Determine the result message based on the score. | |
SiteAuditCheckAbstract:: |
public | function | Get a quantifiable number representing a check result; lazy initialization. | |
SiteAuditCheckAbstract:: |
public | function | Get the CSS class associated with a score. | |
SiteAuditCheckAbstract:: |
public | function | Get the Drush message level associated with a score. | |
SiteAuditCheckAbstract:: |
public | function | Get a human readable label for a score. | |
SiteAuditCheckAbstract:: |
public | function | Logs error if unable to parse XML output. | |
SiteAuditCheckAbstract:: |
public | function | Display action items for a user to perform. | |
SiteAuditCheckAbstract:: |
public | function | Determine whether the check failed so badly that the report must stop. | |
SiteAuditCheckAbstract:: |
public | function | Constructor. | |
SiteAuditCheckStatusSystem:: |
public | function |
Implements \SiteAudit\Check\Abstract\calculateScore(). Overrides SiteAuditCheckAbstract:: |
|
SiteAuditCheckStatusSystem:: |
public | function |
Implements \SiteAudit\Check\Abstract\getAction(). Overrides SiteAuditCheckAbstract:: |
|
SiteAuditCheckStatusSystem:: |
public | function |
Implements \SiteAudit\Check\Abstract\getDescription(). Overrides SiteAuditCheckAbstract:: |
|
SiteAuditCheckStatusSystem:: |
public | function |
Implements \SiteAudit\Check\Abstract\getLabel(). Overrides SiteAuditCheckAbstract:: |
|
SiteAuditCheckStatusSystem:: |
public | function |
Implements \SiteAudit\Check\Abstract\getResultFail(). Overrides SiteAuditCheckAbstract:: |
|
SiteAuditCheckStatusSystem:: |
public | function |
Implements \SiteAudit\Check\Abstract\getResultInfo(). Overrides SiteAuditCheckAbstract:: |
|
SiteAuditCheckStatusSystem:: |
public | function |
Implements \SiteAudit\Check\Abstract\getResultPass(). Overrides SiteAuditCheckAbstract:: |
|
SiteAuditCheckStatusSystem:: |
public | function |
Implements \SiteAudit\Check\Abstract\getResultWarn(). Overrides SiteAuditCheckAbstract:: |