Release 2.0.1, merged in 1181 to HEAD.
[htmlpurifier.git] / library / HTMLPurifier / IDAccumulator.php
blob525c9aa0800fc31be92d9b72d4d39eb1a41aaed0
1 <?php
3 /**
4 * Component of HTMLPurifier_AttrContext that accumulates IDs to prevent dupes
5 * @note In Slashdot-speak, dupe means duplicate.
6 * @note This class does not accept $config or $context, thus, it is the
7 * burden of the callee to register the appropriate errors or
8 * configuration.
9 */
10 class HTMLPurifier_IDAccumulator
13 /**
14 * Lookup table of IDs we've accumulated.
15 * @public
17 var $ids = array();
19 /**
20 * Add an ID to the lookup table.
21 * @param $id ID to be added.
22 * @return Bool status, true if success, false if there's a dupe
24 function add($id) {
25 if (isset($this->ids[$id])) return false;
26 return $this->ids[$id] = true;
29 /**
30 * Load a list of IDs into the lookup table
31 * @param $array_of_ids Array of IDs to load
32 * @note This function doesn't care about duplicates
34 function load($array_of_ids) {
35 foreach ($array_of_ids as $id) {
36 $this->ids[$id] = true;