mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-12-28 12:30:44 +00:00
Merge PR #96 with develop
This commit is contained in:
commit
c25c94b384
@ -84,15 +84,17 @@ class JEDcheckerReport extends JObject
|
||||
* @param string $text - An optional description of the error.
|
||||
* @param integer $line - If $location is a file, you may specify the line where the
|
||||
* error occurred.
|
||||
* @param string $code - Code at that location (to be displayed below the description)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addError($location, $text = null, $line = 0)
|
||||
public function addError($location, $text = null, $line = 0, $code = null)
|
||||
{
|
||||
$item = new stdClass;
|
||||
$item->location = $location;
|
||||
$item->line = $line;
|
||||
$item->text = $text;
|
||||
$item->code = $code;
|
||||
|
||||
$this->addItem($item, 'errors');
|
||||
}
|
||||
@ -104,15 +106,17 @@ class JEDcheckerReport extends JObject
|
||||
* @param string $text - An optional description of the error.
|
||||
* @param integer $line - If $location is a file, you may specify the line where the
|
||||
* error occurred.
|
||||
* @param string $code - Code at that location (to be displayed below the description)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addInfo($location, $text = null, $line = 0)
|
||||
public function addInfo($location, $text = null, $line = 0, $code = null)
|
||||
{
|
||||
$item = new stdClass;
|
||||
$item->location = $location;
|
||||
$item->line = $line;
|
||||
$item->text = $text;
|
||||
$item->code = $code;
|
||||
|
||||
$this->addItem($item, 'info');
|
||||
}
|
||||
@ -124,15 +128,17 @@ class JEDcheckerReport extends JObject
|
||||
* @param string $text - An optional description of the issue
|
||||
* @param integer $line - If $location is a file, you may specify the line where the
|
||||
* issue occurred.
|
||||
* @param string $code - Code at that location (to be displayed below the description)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addCompat($location, $text = null, $line = 0)
|
||||
public function addCompat($location, $text = null, $line = 0, $code = null)
|
||||
{
|
||||
$item = new stdClass;
|
||||
$item->location = $location;
|
||||
$item->line = $line;
|
||||
$item->text = $text;
|
||||
$item->code = $code;
|
||||
|
||||
$this->addItem($item, 'compat');
|
||||
}
|
||||
@ -144,15 +150,17 @@ class JEDcheckerReport extends JObject
|
||||
* @param string $text - An optional description of the issue
|
||||
* @param integer $line - If $location is a file, you may specify the line where the
|
||||
* issue occurred.
|
||||
* @param string $code - Code at that location (to be displayed below the description)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addWarning($location, $text = null, $line = 0)
|
||||
public function addWarning($location, $text = null, $line = 0, $code = null)
|
||||
{
|
||||
$item = new stdClass;
|
||||
$item->location = $location;
|
||||
$item->line = $line;
|
||||
$item->text = $text;
|
||||
$item->code = $code;
|
||||
|
||||
$this->addItem($item, 'warning');
|
||||
}
|
||||
@ -188,28 +196,7 @@ class JEDcheckerReport extends JObject
|
||||
$html[] = '<div class="alert alert-danger" data-toggle="collapse" data-target="#' . $collapseID . '"><strong>' . $error_count . ' ' . JText::_('COM_JEDCHECKER_ERRORS') . '</strong> - ' . JText::_('COM_JEDCHECKER_CLICK_TO_VIEW_DETAILS') . '</div>';
|
||||
$html[] = '<div id="' . $collapseID . '" class="collapse"><ul class="alert alert-danger">';
|
||||
|
||||
foreach ($this->data['errors'] AS $i => $item)
|
||||
{
|
||||
$num = $i + 1;
|
||||
|
||||
// Add the error count number
|
||||
$html[] = '<li><strong>#' . str_pad($num, 3, '0', STR_PAD_LEFT) . ':</strong> ';
|
||||
$html[] = $item->location;
|
||||
|
||||
// Add line information if given
|
||||
if ($item->line > 0)
|
||||
{
|
||||
$html[] = ' ' . JText::_('COM_JEDCHECKER_IN_LINE') . ': <strong>' . $item->line . '</strong>';
|
||||
}
|
||||
|
||||
// Add text if given
|
||||
if (!empty($item->text))
|
||||
{
|
||||
$html[] = '<br /><small>' . $item->text . '</small>';
|
||||
}
|
||||
|
||||
$html[] = '</li>';
|
||||
}
|
||||
$html[] = $this->formatItems($this->data['errors']);
|
||||
|
||||
$html[] = '</ul></div>';
|
||||
}
|
||||
@ -223,30 +210,7 @@ class JEDcheckerReport extends JObject
|
||||
$html[] = '<div class="alert alert-warning" data-toggle="collapse" data-target="#' . $collapseID . '"><strong>' . $compat_count . ' ' . JText::_('COM_JEDCHECKER_COMPAT_ISSUES') . '</strong> - ' . JText::_('COM_JEDCHECKER_CLICK_TO_VIEW_DETAILS') . '</div>';
|
||||
$html[] = '<div id="' . $collapseID . '" class="collapse"><ul class="alert alert-warning">';
|
||||
|
||||
foreach ($this->data['compat'] AS $i => $item)
|
||||
{
|
||||
$num = $i + 1;
|
||||
|
||||
// Add the error count number
|
||||
$html[] = '<li><strong>#' . str_pad($num, 3, '0', STR_PAD_LEFT) . '</strong> ';
|
||||
$html[] = $item->location;
|
||||
|
||||
// Add line information if given
|
||||
if ($item->line > 0)
|
||||
{
|
||||
$html[] = ' ' . JText::_('COM_JEDCHECKER_IN_LINE') . ': <strong>' . $item->line . '</strong>';
|
||||
}
|
||||
|
||||
$html[] = '<br />';
|
||||
|
||||
// Add text if given
|
||||
if (!empty($item->text))
|
||||
{
|
||||
$html[] = '<small>' . $item->text . '</small>';
|
||||
}
|
||||
|
||||
$html[] = '</li>';
|
||||
}
|
||||
$html[] = $this->formatItems($this->data['compat']);
|
||||
|
||||
$html[] = '</ul></div>';
|
||||
}
|
||||
@ -260,30 +224,7 @@ class JEDcheckerReport extends JObject
|
||||
$html[] = '<div class="alert alert-info" data-toggle="collapse" data-target="#' . $collapseID . '"><strong>' . $info_count . ' ' . JText::_('COM_JEDCHECKER_INFO') . '</strong> - ' . JText::_('COM_JEDCHECKER_CLICK_TO_VIEW_DETAILS') . '</div>';
|
||||
$html[] = '<div id="' . $collapseID . '" class="collapse"><ul class="alert alert-info">';
|
||||
|
||||
foreach ($this->data['info'] AS $i => $item)
|
||||
{
|
||||
$num = $i + 1;
|
||||
|
||||
// Add the error count number
|
||||
$html[] = '<li><strong>#' . str_pad($num, 3, '0', STR_PAD_LEFT) . '</strong> ';
|
||||
$html[] = $item->location;
|
||||
|
||||
// Add line information if given
|
||||
if ($item->line > 0)
|
||||
{
|
||||
$html[] = ' ' . JText::_('COM_JEDCHECKER_IN_LINE') . ': <strong>' . $item->line . '</strong>';
|
||||
}
|
||||
|
||||
$html[] = '<br />';
|
||||
|
||||
// Add text if given
|
||||
if (!empty($item->text))
|
||||
{
|
||||
$html[] = '<small>' . $item->text . '</small>';
|
||||
}
|
||||
|
||||
$html[] = '</li>';
|
||||
}
|
||||
$html[] = $this->formatItems($this->data['info']);
|
||||
|
||||
$html[] = '</ul></div>';
|
||||
}
|
||||
@ -296,30 +237,7 @@ class JEDcheckerReport extends JObject
|
||||
$html[] = '<div class="alert alert-warning" data-toggle="collapse" data-target="#' . $collapseID . '"><strong>' . $warning_count . ' ' . JText::_('COM_JEDCHECKER_WARNING') . '</strong> - ' . JText::_('COM_JEDCHECKER_CLICK_TO_VIEW_DETAILS') . '</div>';
|
||||
$html[] = '<div id="' . $collapseID . '" class="collapse"><ul class="alert alert-warning">';
|
||||
|
||||
foreach ($this->data['warning'] AS $i => $item)
|
||||
{
|
||||
$num = $i + 1;
|
||||
|
||||
// Add the warning count number
|
||||
$html[] = '<li><strong>#' . str_pad($num, 3, '0', STR_PAD_LEFT) . '</strong> ';
|
||||
$html[] = $item->location;
|
||||
|
||||
// Add line information if given
|
||||
if ($item->line > 0)
|
||||
{
|
||||
$html[] = ' ' . JText::_('COM_JEDCHECKER_IN_LINE') . ': <strong>' . $item->line . '</strong>';
|
||||
}
|
||||
|
||||
$html[] = '<br />';
|
||||
|
||||
// Add text if given
|
||||
if (!empty($item->text))
|
||||
{
|
||||
$html[] = '<small>' . $item->text . '</small>';
|
||||
}
|
||||
|
||||
$html[] = '</li>';
|
||||
}
|
||||
$html[] = $this->formatItems($this->data['warning']);
|
||||
|
||||
$html[] = '</ul></div>';
|
||||
}
|
||||
@ -356,4 +274,51 @@ 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[] = '<li><strong>#' . str_pad($num, 3, '0', STR_PAD_LEFT) . '</strong> ';
|
||||
$html[] = $item->location;
|
||||
|
||||
// Add line information if given
|
||||
if ($item->line > 0)
|
||||
{
|
||||
$html[] = ' ' . JText::_('COM_JEDCHECKER_IN_LINE') . ': <strong>' . $item->line . '</strong>';
|
||||
}
|
||||
|
||||
$html[] = '<br />';
|
||||
|
||||
// Add text if given
|
||||
if (!empty($item->text))
|
||||
{
|
||||
$html[] = '<small>' . $item->text;
|
||||
|
||||
// Add code if given
|
||||
if (!empty($item->code))
|
||||
{
|
||||
$html[] = '<pre>' . htmlspecialchars(rtrim($item->code)) . '</pre>';
|
||||
}
|
||||
|
||||
$html[] = '</small>';
|
||||
}
|
||||
|
||||
$html[] = '</li>';
|
||||
}
|
||||
|
||||
return implode('', $html);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user