Source for file ErrorCollector.php
Documentation is available at ErrorCollector.php
* Error collection class that enables HTML Purifier to report HTML
* problems back to the user
$this->locale =
& $context->get('Locale');
$this->generator =
& $context->get('Generator');
* Sends an error message to the collector for later use
* @param $line Integer line number, or HTMLPurifier_Token that caused error
* @param $severity int Error severity, PHP error style (don't use E_USER_)
* @param $msg string Error message text
public function send($severity, $msg) {
$token =
$this->context->get('CurrentToken', true);
$line =
$token ?
$token->line :
$this->context->get('CurrentLine', true);
$attr =
$this->context->get('CurrentAttr', true);
// perform special substitutions, also add custom parameters
$args['CurrentToken'] =
$token;
$subst['$CurrentAttr.Name'] =
$attr;
if (isset
($token->attr[$attr])) $subst['$CurrentAttr.Value'] =
$token->attr[$attr];
$msg =
$this->locale->getMessage($msg);
$msg =
$this->locale->formatMessage($msg, $args);
if (!empty($subst)) $msg =
strtr($msg, $subst);
$this->errors[] =
array($line, $severity, $msg);
* 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)
* Default HTML formatting implementation for error messages
* @param $config Configuration array, vital for HTML output nature
// sort error array by line
// line numbers are enabled if they aren't explicitly disabled
if ($config->get('Core', 'MaintainLineNumbers') !==
false) {
$original_order =
array();
foreach ($errors as $i =>
$error) {
$has_line[] = (int) (bool)
$error[0];
array_multisort($has_line, SORT_DESC, $lines, SORT_ASC, $original_order, SORT_ASC, $errors);
foreach ($errors as $error) {
list
($line, $severity, $msg) =
$error;
$string .=
'<strong>' .
$this->locale->getErrorName($severity) .
'</strong>: ';
// have javascript link generation that causes
// textarea to skip to the specified line
$string .=
$this->locale->formatMessage(
'ErrorCollector: At line', array('line' =>
$line));
return '<p>' .
$this->locale->getMessage('ErrorCollector: No errors') .
'</p>';
return '<ul><li>' .
implode('</li><li>', $ret) .
'</li></ul>';
Documentation generated on Thu, 19 Jun 2008 18:49:10 -0400 by phpDocumentor 1.4.2