4 * Registry object that contains information about the current context.
6 class HTMLPurifier_Context
10 * Private array that stores the references.
13 var $_storage = array();
16 * Registers a variable into the context.
17 * @param $name String name
18 * @param $ref Variable to be registered
20 function register($name, &$ref) {
21 if (isset($this->_storage
[$name])) {
22 trigger_error('Name collision, cannot re-register',
26 $this->_storage
[$name] =& $ref;
30 * Retrieves a variable reference from the context.
31 * @param $name String name
33 function &get($name) {
34 if (!isset($this->_storage
[$name])) {
35 trigger_error('Attempted to retrieve non-existent variable',
37 $var = null; // so we can return by reference
40 return $this->_storage
[$name];
44 * Destorys a variable in the context.
45 * @param $name String name
47 function destroy($name) {
48 if (!isset($this->_storage
[$name])) {
49 trigger_error('Attempted to destroy non-existent variable',
53 unset($this->_storage
[$name]);
57 * Checks whether or not the variable exists.
58 * @param $name String name
60 function exists($name) {
61 return isset($this->_storage
[$name]);
65 * Loads a series of variables from an associative array
66 * @param $context_array Assoc array of variables to load
68 function loadArray(&$context_array) {
69 foreach ($context_array as $key => $discard) {
70 $this->register($key, $context_array[$key]);