friendica/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorStruct.php

75 lines
1.8 KiB
PHP
Raw Normal View History

2010-09-09 05:14:17 +02:00
<?php
/**
* Records errors for particular segments of an HTML document such as tokens,
* attributes or CSS properties. They can contain error structs (which apply
* to components of what they represent), but their main purpose is to hold
* errors applying to whatever struct is being used.
*/
class HTMLPurifier_ErrorStruct
{
/**
* Possible values for $children first-key. Note that top-level structures
* are automatically token-level.
*/
const TOKEN = 0;
const ATTR = 1;
const CSSPROP = 2;
/**
* Type of this struct.
2016-02-09 11:06:17 +01:00
* @type string
2010-09-09 05:14:17 +02:00
*/
public $type;
/**
* Value of the struct we are recording errors for. There are various
* values for this:
* - TOKEN: Instance of HTMLPurifier_Token
* - ATTR: array('attr-name', 'value')
* - CSSPROP: array('prop-name', 'value')
2016-02-09 11:06:17 +01:00
* @type mixed
2010-09-09 05:14:17 +02:00
*/
public $value;
/**
* Errors registered for this structure.
2016-02-09 11:06:17 +01:00
* @type array
2010-09-09 05:14:17 +02:00
*/
public $errors = array();
/**
* Child ErrorStructs that are from this structure. For example, a TOKEN
* ErrorStruct would contain ATTR ErrorStructs. This is a multi-dimensional
* array in structure: [TYPE]['identifier']
2016-02-09 11:06:17 +01:00
* @type array
2010-09-09 05:14:17 +02:00
*/
public $children = array();
2016-02-09 11:06:17 +01:00
/**
* @param string $type
* @param string $id
* @return mixed
*/
public function getChild($type, $id)
{
2010-09-09 05:14:17 +02:00
if (!isset($this->children[$type][$id])) {
$this->children[$type][$id] = new HTMLPurifier_ErrorStruct();
$this->children[$type][$id]->type = $type;
}
return $this->children[$type][$id];
}
2016-02-09 11:06:17 +01:00
/**
* @param int $severity
* @param string $message
*/
public function addError($severity, $message)
{
2010-09-09 05:14:17 +02:00
$this->errors[] = array($severity, $message);
}
}
// vim: et sw=4 sts=4