00001 <?php
00002
00006 class HTMLPurifier_URISchemeRegistry
00007 {
00008
00016 public static function instance($prototype = null) {
00017 static $instance = null;
00018 if ($prototype !== null) {
00019 $instance = $prototype;
00020 } elseif ($instance === null || $prototype == true) {
00021 $instance = new HTMLPurifier_URISchemeRegistry();
00022 }
00023 return $instance;
00024 }
00025
00029 protected $schemes = array();
00030
00037 public function getScheme($scheme, $config, $context) {
00038 if (!$config) $config = HTMLPurifier_Config::createDefault();
00039 $null = null;
00040
00041
00042 $allowed_schemes = $config->get('URI', 'AllowedSchemes');
00043 if (!$config->get('URI', 'OverrideAllowedSchemes') &&
00044 !isset($allowed_schemes[$scheme])
00045 ) {
00046 return $null;
00047 }
00048
00049 if (isset($this->schemes[$scheme])) return $this->schemes[$scheme];
00050 if (!isset($allowed_schemes[$scheme])) return $null;
00051
00052 $class = 'HTMLPurifier_URIScheme_' . $scheme;
00053 if (!class_exists($class)) return $null;
00054 $this->schemes[$scheme] = new $class();
00055 return $this->schemes[$scheme];
00056 }
00057
00063 public function register($scheme, $scheme_obj) {
00064 $this->schemes[$scheme] = $scheme_obj;
00065 }
00066
00067 }
00068
00069