3
HTMLPurifier_ConfigSchema::define(
4
'Attr', 'IDBlacklist', array(), 'list',
5
'Array of IDs not allowed in the document.'
9
4
* Component of HTMLPurifier_AttrContext that accumulates IDs to prevent dupes
10
5
* @note In Slashdot-speak, dupe means duplicate.
14
9
class HTMLPurifier_IDAccumulator
18
13
* Lookup table of IDs we've accumulated.
16
public $ids = array();
24
19
* Builds an IDAccumulator, also initializing the default blacklist
25
20
* @param $config Instance of HTMLPurifier_Config
26
21
* @param $context Instance of HTMLPurifier_Context
27
22
* @return Fully initialized HTMLPurifier_IDAccumulator
30
function build($config, &$context) {
31
$acc = new HTMLPurifier_IDAccumulator();
32
$acc->load($config->get('Attr', 'IDBlacklist'));
24
public static function build($config, $context) {
25
$id_accumulator = new HTMLPurifier_IDAccumulator();
26
$id_accumulator->load($config->get('Attr.IDBlacklist'));
27
return $id_accumulator;
37
31
* Add an ID to the lookup table.
38
32
* @param $id ID to be added.
39
33
* @return Bool status, true if success, false if there's a dupe
35
public function add($id) {
42
36
if (isset($this->ids[$id])) return false;
43
37
return $this->ids[$id] = true;
47
41
* Load a list of IDs into the lookup table
48
42
* @param $array_of_ids Array of IDs to load
49
43
* @note This function doesn't care about duplicates
51
function load($array_of_ids) {
45
public function load($array_of_ids) {
52
46
foreach ($array_of_ids as $id) {
53
47
$this->ids[$id] = true;