Warning, file /webapps/ocs-webserver/library/HTMLPurifier/IDAccumulator.php was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 <?php
0002 
0003 /**
0004  * Component of HTMLPurifier_AttrContext that accumulates IDs to prevent dupes
0005  * @note In Slashdot-speak, dupe means duplicate.
0006  * @note The default constructor does not accept $config or $context objects:
0007  *       use must use the static build() factory method to perform initialization.
0008  */
0009 class HTMLPurifier_IDAccumulator
0010 {
0011 
0012     /**
0013      * Lookup table of IDs we've accumulated.
0014      * @public
0015      */
0016     public $ids = array();
0017 
0018     /**
0019      * Builds an IDAccumulator, also initializing the default blacklist
0020      * @param HTMLPurifier_Config $config Instance of HTMLPurifier_Config
0021      * @param HTMLPurifier_Context $context Instance of HTMLPurifier_Context
0022      * @return HTMLPurifier_IDAccumulator Fully initialized HTMLPurifier_IDAccumulator
0023      */
0024     public static function build($config, $context)
0025     {
0026         $id_accumulator = new HTMLPurifier_IDAccumulator();
0027         $id_accumulator->load($config->get('Attr.IDBlacklist'));
0028         return $id_accumulator;
0029     }
0030 
0031     /**
0032      * Add an ID to the lookup table.
0033      * @param string $id ID to be added.
0034      * @return bool status, true if success, false if there's a dupe
0035      */
0036     public function add($id)
0037     {
0038         if (isset($this->ids[$id])) {
0039             return false;
0040         }
0041         return $this->ids[$id] = true;
0042     }
0043 
0044     /**
0045      * Load a list of IDs into the lookup table
0046      * @param $array_of_ids Array of IDs to load
0047      * @note This function doesn't care about duplicates
0048      */
0049     public function load($array_of_ids)
0050     {
0051         foreach ($array_of_ids as $id) {
0052             $this->ids[$id] = true;
0053         }
0054     }
0055 }
0056 
0057 // vim: et sw=4 sts=4