data)) $this->reset(); } /** * Resets the report data. * * @return void */ public function reset() { $this->data = array(); $this->data['errors'] = array(); $this->data['compat'] = array(); $this->data['info'] = array(); $this->data['count'] = new stdClass(); $this->data['count']->total = 0; $this->data['count']->errors = 0; $this->data['count']->compat = 0; $this->data['count']->info = 0; } /** * Adds an error to the report. * * @param string $location The location of the error. Can be a path to a file or dir. * @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. * * @return void */ public function addError($location, $text = NULL, $line = 0) { $item = new stdClass(); $item->location = $location; $item->line = $line; $item->text = (empty($text) ? '' : JText::_($text)); $this->addItem($item, 'errors'); } /** * Adds an error to the report. * * @param string $location The location of the error. Can be a path to a file or dir. * @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. * * @return void */ public function addInfo($location, $text = NULL, $line = 0) { $item = new stdClass(); $item->location = $location; $item->line = $line; $item->text = (empty($text) ? '' : JText::_($text)); $this->addItem($item, 'info'); } /** * Adds a compatibility issue to the report. * * @param string $location The location of the issue. Can be a path to a file or dir. * @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. * * @return void */ public function addCompat($location, $text = NULL, $line = 0) { $item = new stdClass(); $item->location = $location; $item->line = $line; $item->text = empty($text) ? NULL : JText::_($text); $this->addItem($item, 'compat'); } /** * Formats the existing report data into HTML and returns it. * * @return string The HTML report data */ public function getHTML() { $html = array(); if($this->data['count']->total == 0) { // No errors or compatibility issues found $html[] = ''; $html[] = JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE'); $html[] = ''; } else { $error_count = $this->data['count']->errors; $compat_count = $this->data['count']->compat; $info_count = $this->data['count']->info; // Go through the error list if($error_count > 0) { $html[] = ''.$error_count. ' '.JText::_('COM_JEDCHECKER_ERRORS').''; $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[] = '