1: <?php
2:
3: 4: 5:
6: class HTMLPurifier_PropertyList
7: {
8: 9: 10:
11: protected $data = array();
12:
13: 14: 15:
16: protected $parent;
17:
18: protected $cache;
19:
20: public function __construct($parent = null) {
21: $this->parent = $parent;
22: }
23:
24: 25: 26:
27: public function get($name) {
28: if ($this->has($name)) return $this->data[$name];
29:
30: if ($this->parent) return $this->parent->get($name);
31: throw new HTMLPurifier_Exception("Key '$name' not found");
32: }
33:
34: 35: 36:
37: public function set($name, $value) {
38: $this->data[$name] = $value;
39: }
40:
41: 42: 43:
44: public function has($name) {
45: return array_key_exists($name, $this->data);
46: }
47:
48: 49: 50: 51:
52: public function reset($name = null) {
53: if ($name == null) $this->data = array();
54: else unset($this->data[$name]);
55: }
56:
57: 58: 59: 60: 61:
62: public function squash($force = false) {
63: if ($this->cache !== null && !$force) return $this->cache;
64: if ($this->parent) {
65: return $this->cache = array_merge($this->parent->squash($force), $this->data);
66: } else {
67: return $this->cache = $this->data;
68: }
69: }
70:
71: 72: 73:
74: public function getParent() {
75: return $this->parent;
76: }
77:
78: 79: 80:
81: public function setParent($plist) {
82: $this->parent = $plist;
83: }
84: }
85:
86:
87: