00001 <?php
00002
00010 class HTMLPurifier_Context
00011 {
00012
00016 private $_storage = array();
00017
00023 public function register($name, &$ref) {
00024 if (isset($this->_storage[$name])) {
00025 trigger_error("Name $name produces collision, cannot re-register",
00026 E_USER_ERROR);
00027 return;
00028 }
00029 $this->_storage[$name] =& $ref;
00030 }
00031
00037 public function &get($name, $ignore_error = false) {
00038 if (!isset($this->_storage[$name])) {
00039 if (!$ignore_error) {
00040 trigger_error("Attempted to retrieve non-existent variable $name",
00041 E_USER_ERROR);
00042 }
00043 $var = null;
00044 return $var;
00045 }
00046 return $this->_storage[$name];
00047 }
00048
00053 public function destroy($name) {
00054 if (!isset($this->_storage[$name])) {
00055 trigger_error("Attempted to destroy non-existent variable $name",
00056 E_USER_ERROR);
00057 return;
00058 }
00059 unset($this->_storage[$name]);
00060 }
00061
00066 public function exists($name) {
00067 return isset($this->_storage[$name]);
00068 }
00069
00074 public function loadArray($context_array) {
00075 foreach ($context_array as $key => $discard) {
00076 $this->register($key, $context_array[$key]);
00077 }
00078 }
00079
00080 }
00081