errors[] = array($msg, $severity, $token, $context_tokens);
}
/**
* Retrieves raw error data for custom formatter to use
* @param List of arrays in format of array(Error message text,
* token that caused error, tokens surrounding token)
*/
function getRaw() {
return $this->errors;
}
/**
* Default HTML formatting implementation for error messages
* @param $config Configuration array, vital for HTML output nature
*/
function getHTMLFormatted($config, &$context) {
$generator = new HTMLPurifier_Generator();
$generator->generateFromTokens(array(), $config, $context); // initialize
$ret = array();
$errors = $this->errors;
$locale = $context->get('Locale');
// sort error array by line
if ($config->get('Core', 'MaintainLineNumbers')) {
$lines = array();
foreach ($errors as $error) $lines[] = $error[2]->line;
array_multisort($lines, SORT_ASC, $errors);
}
foreach ($errors as $error) {
list($msg, $severity, $token, $context_tokens) = $error;
$string = '';
$string .= $locale->getErrorName($severity) . ': ';
$string .= $generator->escape($msg);
if (!empty($token->line)) {
$string .= ' at line ' . $token->line;
}
$string .= ' (';
foreach ($context_tokens as $context_token) {
if ($context_token !== true) {
$string .= $generator->escape($generator->generateFromToken($context_token));
} else {
$string .= '' . $generator->escape($generator->generateFromToken($token)) . '';
}
}
$string .= '
)';
$ret[] = $string;
}
return $ret;
}
}
?>