ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e
HTMLPurifier_ConfigSchema Class Reference

Configuration definition, defines directives and their defaults. More...

+ Collaboration diagram for HTMLPurifier_ConfigSchema:

Public Member Functions

 __construct ()
 
 add ($key, $default, $type, $allow_null)
 Defines a directive for configuration. More...
 
 addValueAliases ($key, $aliases)
 Defines a directive value alias. More...
 
 addAllowedValues ($key, $allowed)
 Defines a set of allowed values for a directive. More...
 
 addAlias ($key, $new_key)
 Defines a directive alias for backwards compatibility. More...
 
 postProcess ()
 Replaces any stdClass that only has the type property with type integer. More...
 

Static Public Member Functions

static makeFromSerial ()
 Unserializes the default ConfigSchema. More...
 
static instance ($prototype=null)
 Retrieves an instance of the application-wide configuration definition. More...
 

Data Fields

 $defaults = array()
 Defaults of the directives and namespaces. More...
 
 $defaultPlist
 The default property list. More...
 
 $info = array()
 Definition of the directives. More...
 

Static Protected Attributes

static $singleton
 Application-wide singleton HTMLPurifier_ConfigSchema. More...
 

Detailed Description

Configuration definition, defines directives and their defaults.

Definition at line 6 of file ConfigSchema.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_ConfigSchema::__construct ( )

Definition at line 60 of file ConfigSchema.php.

61  {
62  $this->defaultPlist = new HTMLPurifier_PropertyList();
63  }
Generic property list implementation.
Definition: PropertyList.php:6

Member Function Documentation

◆ add()

HTMLPurifier_ConfigSchema::add (   $key,
  $default,
  $type,
  $allow_null 
)

Defines a directive for configuration.

Warning
Will fail of directive's namespace is defined.
This method's signature is slightly different from the legacy define() static method! Beware!
Parameters
string$keyName of directive
mixed$defaultDefault value of directive
string$typeAllowed type of the directive. See HTMLPurifier_VarParser::$types for allowed values
bool$allow_nullWhether or not to allow null values

Definition at line 106 of file ConfigSchema.php.

References $default, $key, $type, HTMLPurifier_VarParser\$types, and info().

107  {
108  $obj = new stdClass();
109  $obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type];
110  if ($allow_null) {
111  $obj->allow_null = true;
112  }
113  $this->info[$key] = $obj;
114  $this->defaults[$key] = $default;
115  $this->defaultPlist->set($key, $default);
116  }
$type
static $types
Lookup table of allowed types.
Definition: VarParser.php:26
$default
Definition: build.php:20
info()
Definition: info.php:2
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ addAlias()

HTMLPurifier_ConfigSchema::addAlias (   $key,
  $new_key 
)

Defines a directive alias for backwards compatibility.

Parameters
string$keyDirective that will be aliased
string$new_keyDirective that the alias will be to

Definition at line 153 of file ConfigSchema.php.

References $key, and info().

154  {
155  $obj = new stdClass;
156  $obj->key = $new_key;
157  $obj->isAlias = true;
158  $this->info[$key] = $obj;
159  }
info()
Definition: info.php:2
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ addAllowedValues()

HTMLPurifier_ConfigSchema::addAllowedValues (   $key,
  $allowed 
)

Defines a set of allowed values for a directive.

Warning
This is slightly different from the corresponding static method definition.
Parameters
string$keyName of directive
array$allowedLookup array of allowed values

Definition at line 143 of file ConfigSchema.php.

References $key, and info().

144  {
145  $this->info[$key]->allowed = $allowed;
146  }
info()
Definition: info.php:2
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ addValueAliases()

HTMLPurifier_ConfigSchema::addValueAliases (   $key,
  $aliases 
)

Defines a directive value alias.

Directive value aliases are convenient for developers because it lets them set a directive to several values and get the same result.

Parameters
string$keyName of Directive
array$aliasesHash of aliased values to the real alias

Definition at line 126 of file ConfigSchema.php.

References $key, and info().

127  {
128  if (!isset($this->info[$key]->aliases)) {
129  $this->info[$key]->aliases = array();
130  }
131  foreach ($aliases as $alias => $real) {
132  $this->info[$key]->aliases[$alias] = $real;
133  }
134  }
info()
Definition: info.php:2
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ instance()

static HTMLPurifier_ConfigSchema::instance (   $prototype = null)
static

Retrieves an instance of the application-wide configuration definition.

Parameters
HTMLPurifier_ConfigSchema$prototype
Returns
HTMLPurifier_ConfigSchema

Definition at line 85 of file ConfigSchema.php.

References $singleton, and makeFromSerial().

Referenced by HTMLPurifier_Config\createDefault(), and HTMLPurifier_Config\getAllowedDirectivesForForm().

86  {
87  if ($prototype !== null) {
89  } elseif (HTMLPurifier_ConfigSchema::$singleton === null || $prototype === true) {
91  }
93  }
static $singleton
Application-wide singleton HTMLPurifier_ConfigSchema.
static makeFromSerial()
Unserializes the default ConfigSchema.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeFromSerial()

static HTMLPurifier_ConfigSchema::makeFromSerial ( )
static

Unserializes the default ConfigSchema.

Returns
HTMLPurifier_ConfigSchema

Definition at line 69 of file ConfigSchema.php.

References $r.

Referenced by instance().

70  {
71  $contents = file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser');
72  $r = unserialize($contents);
73  if (!$r) {
74  $hash = sha1($contents);
75  trigger_error("Unserialization of configuration schema failed, sha1 of file was $hash", E_USER_ERROR);
76  }
77  return $r;
78  }
$r
Definition: example_031.php:79
+ Here is the caller graph for this function:

◆ postProcess()

HTMLPurifier_ConfigSchema::postProcess ( )

Replaces any stdClass that only has the type property with type integer.

Definition at line 164 of file ConfigSchema.php.

References $key, and info().

165  {
166  foreach ($this->info as $key => $v) {
167  if (count((array) $v) == 1) {
168  $this->info[$key] = $v->type;
169  } elseif (count((array) $v) == 2 && isset($v->allow_null)) {
170  $this->info[$key] = -$v->type;
171  }
172  }
173  }
info()
Definition: info.php:2
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

Field Documentation

◆ $defaultPlist

HTMLPurifier_ConfigSchema::$defaultPlist

The default property list.

Do not edit this property list. array

Definition at line 19 of file ConfigSchema.php.

◆ $defaults

HTMLPurifier_ConfigSchema::$defaults = array()

Defaults of the directives and namespaces.

array

Note
This shares the exact same structure as HTMLPurifier_Config::$conf

Definition at line 13 of file ConfigSchema.php.

◆ $info

HTMLPurifier_ConfigSchema::$info = array()

Definition of the directives.

The structure of this is:

array( 'Namespace' => array( 'Directive' => new stdClass(), ) )

The stdClass may have the following properties:

  • If isAlias isn't set:
    • type: Integer type of directive, see HTMLPurifier_VarParser for definitions
    • allow_null: If set, this directive allows null values
    • aliases: If set, an associative array of value aliases to real values
    • allowed: If set, a lookup array of allowed (string) values
  • If isAlias is set:
    • namespace: Namespace this directive aliases to
    • name: Directive name this directive aliases to

In certain degenerate cases, stdClass will actually be an integer. In that case, the value is equivalent to an stdClass with the type property set to the integer. If the integer is negative, type is equal to the absolute value of integer, and allow_null is true.

This class is friendly with HTMLPurifier_Config. If you need introspection about the schema, you're better of using the ConfigSchema_Interchange, which uses more memory but has much richer information. array

Definition at line 52 of file ConfigSchema.php.

◆ $singleton

HTMLPurifier_ConfigSchema::$singleton
staticprotected

Application-wide singleton HTMLPurifier_ConfigSchema.

Definition at line 58 of file ConfigSchema.php.

Referenced by instance().


The documentation for this class was generated from the following file: