diff --git a/security_review.site_audit.inc b/security_review.site_audit.inc
index 0846b39..b8c6ec2 100644
--- a/security_review.site_audit.inc
+++ b/security_review.site_audit.inc
@@ -30,24 +30,7 @@ abstract class SecurityReviewSiteAuditCheckAbstract extends SiteAuditCheckAbstra
if (isset($this->registry[$this->module][$this->check]['value'])) {
if (is_array($this->registry[$this->module][$this->check]['value'])) {
$values = $this->registry[$this->module][$this->check]['value'];
- if (drush_get_option('html')) {
- $ret_val .= '
';
- foreach ($values as $value) {
- $ret_val .= '- ' . $value . '
';
- }
- $ret_val .= '
';
- }
- else {
- foreach ($values as $value) {
- if (!drush_get_option('json')) {
- $ret_val .= PHP_EOL . str_repeat(' ', 6);
- }
- $ret_val .= '- ' . $value;
- }
- if (!drush_get_option('json')) {
- $ret_val .= str_repeat(' ', 6);
- }
- }
+ $ret_val .= $this->generateUL($values, drush_get_option('html'));
}
elseif ($this->registry[$this->module][$this->check]['value']) {
$ret_val .= ' Additional: "' . $this->registry[$this->module][$this->check]['value'] . '"';
@@ -57,6 +40,31 @@ abstract class SecurityReviewSiteAuditCheckAbstract extends SiteAuditCheckAbstra
}
/**
+ * Given a nested array, generate a unordered list, or text-only equivalent.
+ *
+ * @param $array
+ * @param bool $html
+ * @param int $indentation
+ * @return string
+ */
+ private function generateUL($array, $html = TRUE, $indentation = 6) {
+ $result = $html ? '' : '';
+ foreach ($array as $key => $value) {
+ $result .= $html ? '- ' : str_repeat(' ', $indentation);
+ $result .= $key . ': ';
+ if (is_array($value)) {
+ $result .= $this->generateUL($value, $html, $indentation + 6);
+ }
+ else {
+ $result .= $html ? $value : str_repeat(' ', $indentation) . $value;
+ }
+ $result .= $html ? '
' : PHP_EOL;
+ }
+ $result .= $html ? '
' : '';
+ return $result;
+ }
+
+ /**
* Implements \SiteAudit\Check\Abstract\getResultInfo().
*/
public function getResultInfo() {}