94         $parent = $parent ? $parent : $definition->defaultPlist;
 
   96         $this->def = $definition; 
 
  117             $ret = 
new HTMLPurifier_Config($schema);
 
  148     public function get($key, $a = null) {
 
  150             $this->
triggerError(
"Using deprecated API: use \$config->get('$key.$a') instead", E_USER_WARNING);
 
  154         if (!isset($this->def->info[$key])) {
 
  156             $this->
triggerError(
'Cannot retrieve value of undefined directive ' . htmlspecialchars($key),
 
  160         if (isset($this->def->info[$key]->isAlias)) {
 
  161             $d = $this->def->info[$key];
 
  162             $this->
triggerError(
'Cannot get value from aliased directive, use real name ' . 
$d->key,
 
  167             list($ns) = explode(
'.', $key);
 
  168             if ($ns !== $this->lock) {
 
  169                 $this->
triggerError(
'Cannot get value of namespace ' . $ns . 
' when lock for ' . $this->lock . 
' is active, this probably indicates a Definition setup method is accessing directives that are not within its namespace', E_USER_ERROR);
 
  173         return $this->plist->get($key);
 
  184             $this->
triggerError(
'Cannot retrieve undefined namespace ' . htmlspecialchars($namespace),
 
  200             $batch = $this->
getBatch($namespace);
 
  201             unset($batch[
'DefinitionRev']);
 
  212         if (empty($this->serial)) {
 
  225         foreach ($this->plist->squash() as $name => $value) {
 
  226             list($ns, $key) = explode(
'.', $name, 2);
 
  227             $ret[$ns][$key] = $value;
 
  237     public function set($key, $value, $a = null) {
 
  238         if (strpos($key, 
'.') === 
false) {
 
  242             $key = 
"$key.$directive";
 
  243             $this->
triggerError(
"Using deprecated API: use \$config->set('$key', ...) instead", E_USER_NOTICE);
 
  247         if ($this->
isFinalized(
'Cannot set directive after finalization')) 
return;
 
  248         if (!isset($this->def->info[$key])) {
 
  249             $this->
triggerError(
'Cannot set undefined directive ' . htmlspecialchars($key) . 
' to value',
 
  253         $def = $this->def->info[$key];
 
  255         if (isset(
$def->isAlias)) {
 
  256             if ($this->aliasMode) {
 
  257                 $this->
triggerError(
'Double-aliases not allowed, please fix '.
 
  258                     'ConfigSchema bug with' . $key, E_USER_ERROR);
 
  261             $this->aliasMode = 
true;
 
  262             $this->
set(
$def->key, $value);
 
  263             $this->aliasMode = 
false;
 
  264             $this->
triggerError(
"$key is an alias, preferred directive name is {$def->key}", E_USER_NOTICE);
 
  276             $allow_null = isset(
$def->allow_null);
 
  280             $value = $this->parser->parse($value, $type, $allow_null);
 
  285         if (is_string($value) && is_object(
$def)) {
 
  287             if (isset(
$def->aliases[$value])) {
 
  288                 $value = 
$def->aliases[$value];
 
  291             if (isset(
$def->allowed) && !isset(
$def->allowed[$value])) {
 
  292                 $this->
triggerError(
'Value not supported, valid values are: ' .
 
  297         $this->plist->set($key, $value);
 
  314         foreach ($lookup as $name => $b) $list[] = $name;
 
  315         return implode(
', ', $list);
 
  377         if ($optimized && !$raw) {
 
  385         $cache = $factory->create($type, $this);
 
  391             if (!empty($this->definitions[$type])) {
 
  392                 $def = $this->definitions[$type];
 
  398                     if (
$def->optimized) $cache->add(
$def, $this);
 
  403             $def = $cache->get($this);
 
  406                 $this->definitions[$type] = 
$def;
 
  416             $cache->add(
$def, $this);
 
  425                 if (is_null($this->
get($type . 
'.DefinitionID'))) {
 
  430             if (!empty($this->definitions[$type])) {
 
  431                 $def = $this->definitions[$type];
 
  432                 if (
$def->setup && !$optimized) {
 
  433                     $extra = $this->chatty ? 
" (try moving this code block earlier in your initialization)" : 
"";
 
  434                     throw new HTMLPurifier_Exception(
"Cannot retrieve raw definition after it has already been setup" . $extra);
 
  436                 if (
$def->optimized === null) {
 
  437                     $extra = $this->chatty ? 
" (try flushing your cache)" : 
"";
 
  440                 if (
$def->optimized !== $optimized) {
 
  441                     $msg = $optimized ? 
"optimized" : 
"unoptimized";
 
  442                     $extra = $this->chatty ? 
" (this backtrace is for the first inconsistent call, which was for a $msg raw definition)" : 
"";
 
  443                     throw new HTMLPurifier_Exception(
"Inconsistent use of optimized and unoptimized raw definition retrievals" . $extra);
 
  464                 $def = $cache->get($this);
 
  468                     $this->definitions[$type] = 
$def;
 
  474                 if (!is_null($this->
get($type . 
'.DefinitionID'))) {
 
  476                         $this->
triggerError(
"Due to a documentation error in previous version of HTML Purifier, your definitions are not being cached.  If this is OK, you can remove the %$type.DefinitionRev and %$type.DefinitionID declaration.  Otherwise, modify your code to use maybeGetRawDefinition, and test if the returned value is null before making any edits (if it is null, that means that a cached version is available, and no raw operations are necessary).  See <a href='http://htmlpurifier.org/docs/enduser-customize.html#optimized'>Customize</a> for more details", E_USER_WARNING);
 
  478                         $this->
triggerError(
"Useless DefinitionID declaration", E_USER_WARNING);
 
  484             $def->optimized = $optimized;
 
  492         if ($type == 
'HTML') {
 
  494         } elseif ($type == 
'CSS') {
 
  496         } elseif ($type == 
'URI') {
 
  501         $this->definitions[$type] = 
$def;
 
  527         if ($this->
isFinalized(
'Cannot load directives after finalization')) 
return;
 
  528         foreach ($config_array as $key => $value) {
 
  529             $key = str_replace(
'_', 
'.', $key);
 
  530             if (strpos($key, 
'.') !== 
false) {
 
  531                 $this->
set($key, $value);
 
  534                 $namespace_values = $value;
 
  535                 foreach ($namespace_values as $directive => $value) {
 
  536                     $this->
set(
$namespace .
'.'. $directive, $value);
 
  552         if ($allowed !== 
true) {
 
  553              if (is_string($allowed)) $allowed = array($allowed);
 
  554              $allowed_ns = array();
 
  555              $allowed_directives = array();
 
  556              $blacklisted_directives = array();
 
  557              foreach ($allowed as $ns_or_directive) {
 
  558                  if (strpos($ns_or_directive, 
'.') !== 
false) {
 
  560                      if ($ns_or_directive[0] == 
'-') {
 
  561                          $blacklisted_directives[substr($ns_or_directive, 1)] = 
true;
 
  563                          $allowed_directives[$ns_or_directive] = 
true;
 
  567                      $allowed_ns[$ns_or_directive] = 
true;
 
  572         foreach ($schema->info as $key => 
$def) {
 
  573             list($ns, $directive) = explode(
'.', $key, 2);
 
  574             if ($allowed !== 
true) {
 
  575                 if (isset($blacklisted_directives[
"$ns.$directive"])) 
continue;
 
  576                 if (!isset($allowed_directives[
"$ns.$directive"]) && !isset($allowed_ns[$ns])) 
continue;
 
  578             if (isset(
$def->isAlias)) 
continue;
 
  579             if ($directive == 
'DefinitionID' || $directive == 
'DefinitionRev') 
continue;
 
  580             $ret[] = array($ns, $directive);
 
  594     public static function loadArrayFromForm($array, $index = 
false, $allowed = 
true, $mq_fix = 
true, $schema = null) {
 
  613     public static function prepareArrayFromForm($array, $index = 
false, $allowed = 
true, $mq_fix = 
true, $schema = null) {
 
  614         if ($index !== 
false) $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
 
  615         $mq = $mq_fix && function_exists(
'get_magic_quotes_gpc') && get_magic_quotes_gpc();
 
  619         foreach ($allowed as $key) {
 
  620             list($ns, $directive) = $key;
 
  621             $skey = 
"$ns.$directive";
 
  622             if (!empty($array[
"Null_$skey"])) {
 
  623                 $ret[$ns][$directive] = null;
 
  626             if (!isset($array[$skey])) 
continue;
 
  627             $value = $mq ? stripslashes($array[$skey]) : $array[$skey];
 
  628             $ret[$ns][$directive] = $value;
 
  638         if ($this->
isFinalized(
'Cannot load directives after finalization')) 
return;
 
  639         $array = parse_ini_file(
$filename, 
true);
 
  648         if ($this->finalized && $error) {
 
  662             $this->plist->squash(
true);
 
  670         $this->finalized = 
true;
 
  671         unset($this->parser);
 
  682             $trace = debug_backtrace();
 
  684             for ($i = 0, $c = count($trace); $i < $c - 1; $i++) {
 
  685                 if ($trace[$i + 1][
'class'] === 
'HTMLPurifier_Config') {
 
  689                 $extra = 
" invoked on line {$frame['line']} in file {$frame['file']}";
 
  693         trigger_error($msg . $extra, $no);