From 6dbc83f7825a72cf9aa8575e6b6d5b4e8c3ecfa6 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 23 Feb 2021 22:33:32 +0300 Subject: [PATCH] extract common code to formatItems method --- .../com_jedchecker/models/report.php | 137 ++++++------------ 1 file changed, 43 insertions(+), 94 deletions(-) diff --git a/administrator/components/com_jedchecker/models/report.php b/administrator/components/com_jedchecker/models/report.php index 6d0dae2..f040375 100644 --- a/administrator/components/com_jedchecker/models/report.php +++ b/administrator/components/com_jedchecker/models/report.php @@ -188,28 +188,7 @@ class JEDcheckerReport extends JObject $html[] = '
' . $error_count . ' ' . JText::_('COM_JEDCHECKER_ERRORS') . ' - Click to View Details
'; $html[] = '
'; } @@ -223,30 +202,7 @@ class JEDcheckerReport extends JObject $html[] = '
' . $compat_count . ' ' . JText::_('COM_JEDCHECKER_COMPAT_ISSUES') . ' - Click to View Details
'; $html[] = '
'; } @@ -260,30 +216,7 @@ class JEDcheckerReport extends JObject $html[] = '
' . $info_count . ' ' . JText::_('COM_JEDCHECKER_INFO') . ' - Click to View Details
'; $html[] = '
'; } @@ -296,30 +229,7 @@ class JEDcheckerReport extends JObject $html[] = '
' . $warning_count . ' ' . JText::_('COM_JEDCHECKER_WARNING') . ' - Click to View Details
'; $html[] = '
'; } @@ -356,4 +266,43 @@ class JEDcheckerReport extends JObject $this->data['count']->total++; $this->data['count']->$type++; } + + /** + * Converts an item to the string representation + * + * @param array $items List or reports + * + * @return string + */ + protected function formatItems($items) + { + $html = array(); + + foreach ($items as $i => $item) + { + $num = $i + 1; + + // Add count number + $html[] = '
  • #' . str_pad($num, 3, '0', STR_PAD_LEFT) . ' '; + $html[] = $item->location; + + // Add line information if given + if ($item->line > 0) + { + $html[] = ' ' . JText::_('COM_JEDCHECKER_IN_LINE') . ': ' . $item->line . ''; + } + + $html[] = '
    '; + + // Add text if given + if (!empty($item->text)) + { + $html[] = '' . $item->text . ''; + } + + $html[] = '
  • '; + } + + return implode('', $html); + } }