~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
/**
4
 
 * This is in almost every respect equivalent to an array except
5
 
 * that it keeps track of which keys were accessed.
6
 
 *
7
 
 * @warning For the sake of backwards compatibility with early versions
8
 
 *     of PHP 5, you must not use the $hash[$key] syntax; if you do
9
 
 *     our version of offsetGet is never called.
10
 
 */
11
 
class HTMLPurifier_StringHash extends ArrayObject
12
 
{
13
 
    protected $accessed = array();
14
 
 
15
 
    /**
16
 
     * Retrieves a value, and logs the access.
17
 
     */
18
 
    public function offsetGet($index) {
19
 
        $this->accessed[$index] = true;
20
 
        return parent::offsetGet($index);
21
 
    }
22
 
 
23
 
    /**
24
 
     * Returns a lookup array of all array indexes that have been accessed.
25
 
     * @return Array in form array($index => true).
26
 
     */
27
 
    public function getAccessed() {
28
 
        return $this->accessed;
29
 
    }
30
 
 
31
 
    /**
32
 
     * Resets the access array.
33
 
     */
34
 
    public function resetAccessed() {
35
 
        $this->accessed = array();
36
 
    }
37
 
}
38
 
 
39
 
// vim: et sw=4 sts=4
 
1
<?php
 
2
 
 
3
/**
 
4
 * This is in almost every respect equivalent to an array except
 
5
 * that it keeps track of which keys were accessed.
 
6
 *
 
7
 * @warning For the sake of backwards compatibility with early versions
 
8
 *     of PHP 5, you must not use the $hash[$key] syntax; if you do
 
9
 *     our version of offsetGet is never called.
 
10
 */
 
11
class HTMLPurifier_StringHash extends ArrayObject
 
12
{
 
13
    /**
 
14
     * @type array
 
15
     */
 
16
    protected $accessed = array();
 
17
 
 
18
    /**
 
19
     * Retrieves a value, and logs the access.
 
20
     * @param mixed $index
 
21
     * @return mixed
 
22
     */
 
23
    public function offsetGet($index)
 
24
    {
 
25
        $this->accessed[$index] = true;
 
26
        return parent::offsetGet($index);
 
27
    }
 
28
 
 
29
    /**
 
30
     * Returns a lookup array of all array indexes that have been accessed.
 
31
     * @return array in form array($index => true).
 
32
     */
 
33
    public function getAccessed()
 
34
    {
 
35
        return $this->accessed;
 
36
    }
 
37
 
 
38
    /**
 
39
     * Resets the access array.
 
40
     */
 
41
    public function resetAccessed()
 
42
    {
 
43
        $this->accessed = array();
 
44
    }
 
45
}
 
46
 
 
47
// vim: et sw=4 sts=4