You are here

public function SiteAuditReportAbstract::toHtml in Site Audit 7

Same name and namespace in other branches
  1. 8.2 Report/Abstract.php \SiteAuditReportAbstract::toHtml()

Render response as HTML; does not include head, body, etc.

Return value

string Report as rendered HTML.

File

Report/Abstract.php, line 227
Contains \SiteAudit\Report\Abstract.

Class

SiteAuditReportAbstract
Class SiteAuditReportAbstract.

Code

public function toHtml() {
  $ret_val = '<h2 id="' . get_class($this) . '">' . $this
    ->getLabel();
  if ($this->percent != SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO) {
    $ret_val .= ' <span class="label label-' . $this
      ->getPercentCssClass() . '">' . $this->percent . '%</span>';
  }
  else {
    $ret_val .= ' <span class="label label-info">' . dt('Info') . '</span>';
  }
  $ret_val .= '</h2>';
  if ($this->percent == 100) {
    $ret_val .= '<p class="text-success">';
    $ret_val .= '<strong>' . dt('Well done!') . '</strong> ' . dt('No action required.');
    $ret_val .= '</p>';
  }
  if (drush_get_option('detail') || $this->percent != 100) {
    foreach ($this->checks as $check) {
      if (drush_get_option('detail') || $check
        ->getScore() != SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS || $this->percent == SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO) {
        $ret_val .= '<div class="panel panel-' . $check
          ->getScoreCssClass() . '">';

        // Heading.
        $ret_val .= '<div class="panel-heading"><strong>' . $check
          ->getLabel() . '</strong>';
        if (drush_get_option('detail')) {
          $ret_val .= '<small> - ' . $check
            ->getDescription() . '</small>';
        }
        $ret_val .= '</div>';

        // Result.
        $ret_val .= '<p>' . $check
          ->getResult() . '</p>';
        if ($check
          ->renderAction()) {
          $ret_val .= '<div class="well well-small">' . $check
            ->renderAction() . '</div>';
        }
        $ret_val .= '</div>';
      }
    }
  }
  $ret_val .= "\n";
  return $ret_val;
}