~ubuntu-branches/ubuntu/natty/moodle/natty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Tomasz Muras
  • Date: 2010-10-30 12:19:28 UTC
  • mfrom: (1.1.12 upstream) (3.1.10 squeeze)
  • Revision ID: james.westby@ubuntu.com-20101030121928-qzobi6mctpnk4dif
Tags: 1.9.9.dfsg2-2
* Added Romanian translation
* Updated Japanese translation (closes: #596820)
* Backporting security fixes from Moodle 1.9.10 (closes: #601384)
   - Updated embedded CAS to 1.1.3
   - Added patch for MDL-24523:
     clean_text() not filtering text in markdown format
   - Added patch for MDL-24810 and upgraded customized HTML Purifier to 4.2.0 
   - Added patch for MDL-24258:
     students can delete their forum posts later than $CFG->maxeditingtime 
     under certain conditions
   - Added patch for MDL-23377:
     Can't delete quiz attempts in course without enrolled students

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
 
3
 
HTMLPurifier_ConfigSchema::define(
4
 
    'Attr', 'IDBlacklist', array(), 'list',
5
 
    'Array of IDs not allowed in the document.'
6
 
);
7
 
 
8
3
/**
9
4
 * Component of HTMLPurifier_AttrContext that accumulates IDs to prevent dupes
10
5
 * @note In Slashdot-speak, dupe means duplicate.
13
8
 */
14
9
class HTMLPurifier_IDAccumulator
15
10
{
16
 
    
 
11
 
17
12
    /**
18
13
     * Lookup table of IDs we've accumulated.
19
14
     * @public
20
15
     */
21
 
    var $ids = array();
22
 
    
 
16
    public $ids = array();
 
17
 
23
18
    /**
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
28
 
     * @static
29
23
     */
30
 
    function build($config, &$context) {
31
 
        $acc = new HTMLPurifier_IDAccumulator();
32
 
        $acc->load($config->get('Attr', 'IDBlacklist'));
33
 
        return $acc;
 
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;
34
28
    }
35
 
    
 
29
 
36
30
    /**
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
40
34
     */
41
 
    function add($id) {
 
35
    public function add($id) {
42
36
        if (isset($this->ids[$id])) return false;
43
37
        return $this->ids[$id] = true;
44
38
    }
45
 
    
 
39
 
46
40
    /**
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
50
44
     */
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;
54
48
        }
55
49
    }
56
 
    
 
50
 
57
51
}
58
52
 
 
53
// vim: et sw=4 sts=4