errors[] = array($msg, $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) {
$generator = new HTMLPurifier_Generator();
$context = new HTMLPurifier_Context();
$generator->generateFromTokens(array(), $config, $context); // initialize
$ret = array();
$errors = $this->errors;
// sort error array by line
if ($config->get('Core', 'MaintainLineNumbers')) {
$lines = array();
foreach ($errors as $error) $lines[] = $error[1]->line;
array_multisort($lines, SORT_ASC, $errors);
}
foreach ($errors as $error) {
$string = $generator->escape($error[0]); // message
if (!empty($error[1]->line)) {
$string .= ' at line ' . $error[1]->line;
}
$string .= ' (';
foreach ($error[2] as $token) {
if ($token !== true) {
$string .= $generator->escape($generator->generateFromToken($token));
} else {
$string .= '' . $generator->escape($generator->generateFromToken($error[1])) . '';
}
}
$string .= '
)';
$ret[] = $string;
}
return $ret;
}
}
?>