You are here

public function SiteAuditCheckStatusSystem::getResultPass in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Check/Status/System.php \SiteAuditCheckStatusSystem::getResultPass()

Implements \SiteAudit\Check\Abstract\getResultPass().

Overrides SiteAuditCheckAbstract::getResultPass

2 calls to SiteAuditCheckStatusSystem::getResultPass()
SiteAuditCheckStatusSystem::getResultFail in Check/Status/System.php
Implements \SiteAudit\Check\Abstract\getResultFail().
SiteAuditCheckStatusSystem::getResultWarn in Check/Status/System.php
Implements \SiteAudit\Check\Abstract\getResultWarn().

File

Check/Status/System.php, line 41
Contains \SiteAudit\Check\Status\System.

Class

SiteAuditCheckStatusSystem
Class SiteAuditCheckStatusSystem.

Code

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'] : '&nbsp;';
      $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;
}