Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / Context.php
blobce6fe51e05a83887fa302d9e9adf10e23d0f6eb9
1 <?php
3 /**
4 * Registry object that contains information about the current context.
5 */
6 class HTMLPurifier_Context
9 /**
10 * Private array that stores the references.
11 * @private
13 var $_storage = array();
15 /**
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',
23 E_USER_ERROR);
24 return;
26 $this->_storage[$name] =& $ref;
29 /**
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',
36 E_USER_ERROR);
37 $var = null; // so we can return by reference
38 return $var;
40 return $this->_storage[$name];
43 /**
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',
50 E_USER_ERROR);
51 return;
53 unset($this->_storage[$name]);
56 /**
57 * Checks whether or not the variable exists.
58 * @param $name String name
60 function exists($name) {
61 return isset($this->_storage[$name]);
64 /**
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]);