| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: |
|
| 10: | class HTMLPurifier_Context
|
| 11: | {
|
| 12: |
|
| 13: | |
| 14: | |
| 15: | |
| 16: |
|
| 17: | private $_storage = array();
|
| 18: |
|
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: |
|
| 24: | public function register($name, &$ref)
|
| 25: | {
|
| 26: | if (array_key_exists($name, $this->_storage)) {
|
| 27: | trigger_error(
|
| 28: | "Name $name produces collision, cannot re-register",
|
| 29: | E_USER_ERROR
|
| 30: | );
|
| 31: | return;
|
| 32: | }
|
| 33: | $this->_storage[$name] =& $ref;
|
| 34: | }
|
| 35: |
|
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: |
|
| 42: | public function &get($name, $ignore_error = false)
|
| 43: | {
|
| 44: | if (!array_key_exists($name, $this->_storage)) {
|
| 45: | if (!$ignore_error) {
|
| 46: | trigger_error(
|
| 47: | "Attempted to retrieve non-existent variable $name",
|
| 48: | E_USER_ERROR
|
| 49: | );
|
| 50: | }
|
| 51: | $var = null;
|
| 52: | return $var;
|
| 53: | }
|
| 54: | return $this->_storage[$name];
|
| 55: | }
|
| 56: |
|
| 57: | |
| 58: | |
| 59: | |
| 60: |
|
| 61: | public function destroy($name)
|
| 62: | {
|
| 63: | if (!array_key_exists($name, $this->_storage)) {
|
| 64: | trigger_error(
|
| 65: | "Attempted to destroy non-existent variable $name",
|
| 66: | E_USER_ERROR
|
| 67: | );
|
| 68: | return;
|
| 69: | }
|
| 70: | unset($this->_storage[$name]);
|
| 71: | }
|
| 72: |
|
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: |
|
| 78: | public function exists($name)
|
| 79: | {
|
| 80: | return array_key_exists($name, $this->_storage);
|
| 81: | }
|
| 82: |
|
| 83: | |
| 84: | |
| 85: | |
| 86: |
|
| 87: | public function loadArray($context_array)
|
| 88: | {
|
| 89: | foreach ($context_array as $key => $discard) {
|
| 90: | $this->register($key, $context_array[$key]);
|
| 91: | }
|
| 92: | }
|
| 93: | }
|
| 94: |
|
| 95: |
|
| 96: | |