~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to lib/htmlpurifier/HTMLPurifier/IDAccumulator.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
HTMLPurifier_ConfigSchema::define(
 
4
    'Attr', 'IDBlacklist', array(), 'list',
 
5
    'Array of IDs not allowed in the document.'
 
6
);
 
7
 
 
8
/**
 
9
 * Component of HTMLPurifier_AttrContext that accumulates IDs to prevent dupes
 
10
 * @note In Slashdot-speak, dupe means duplicate.
 
11
 * @note The default constructor does not accept $config or $context objects:
 
12
 *       use must use the static build() factory method to perform initialization.
 
13
 */
 
14
class HTMLPurifier_IDAccumulator
 
15
{
 
16
    
 
17
    /**
 
18
     * Lookup table of IDs we've accumulated.
 
19
     * @public
 
20
     */
 
21
    var $ids = array();
 
22
    
 
23
    /**
 
24
     * Builds an IDAccumulator, also initializing the default blacklist
 
25
     * @param $config Instance of HTMLPurifier_Config
 
26
     * @param $context Instance of HTMLPurifier_Context
 
27
     * @return Fully initialized HTMLPurifier_IDAccumulator
 
28
     * @static
 
29
     */
 
30
    function build($config, &$context) {
 
31
        $acc = new HTMLPurifier_IDAccumulator();
 
32
        $acc->load($config->get('Attr', 'IDBlacklist'));
 
33
        return $acc;
 
34
    }
 
35
    
 
36
    /**
 
37
     * Add an ID to the lookup table.
 
38
     * @param $id ID to be added.
 
39
     * @return Bool status, true if success, false if there's a dupe
 
40
     */
 
41
    function add($id) {
 
42
        if (isset($this->ids[$id])) return false;
 
43
        return $this->ids[$id] = true;
 
44
    }
 
45
    
 
46
    /**
 
47
     * Load a list of IDs into the lookup table
 
48
     * @param $array_of_ids Array of IDs to load
 
49
     * @note This function doesn't care about duplicates
 
50
     */
 
51
    function load($array_of_ids) {
 
52
        foreach ($array_of_ids as $id) {
 
53
            $this->ids[$id] = true;
 
54
        }
 
55
    }
 
56
    
 
57
}
 
58