ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 addValueAliases ($key, $aliases)
 Defines a directive value alias.
 addAllowedValues ($key, $allowed)
 Defines a set of allowed values for a directive.
 addAlias ($key, $new_key)
 Defines a directive alias for backwards compatibility.
 postProcess ()
 Replaces any stdclass that only has the type property with type integer.

Static Public Member Functions

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

Data Fields

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

Static Protected Attributes

static $singleton
 Application-wide singleton HTMLPurifier_ConfigSchema.

Detailed Description

Configuration definition, defines directives and their defaults.

Definition at line 6 of file ConfigSchema.php.

Constructor & Destructor Documentation

HTMLPurifier_ConfigSchema::__construct ( )

Definition at line 60 of file ConfigSchema.php.

{
$this->defaultPlist = new HTMLPurifier_PropertyList();
}

Member Function Documentation

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_DirectiveDef::$type for allowed values
bool$allow_nullWhether or not to allow null values

Definition at line 106 of file ConfigSchema.php.

References HTMLPurifier_VarParser\$types.

{
$obj = new stdclass();
$obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type];
if ($allow_null) {
$obj->allow_null = true;
}
$this->info[$key] = $obj;
$this->defaults[$key] = $default;
$this->defaultPlist->set($key, $default);
}
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.

{
$obj = new stdclass;
$obj->key = $new_key;
$obj->isAlias = true;
$this->info[$key] = $obj;
}
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.

{
$this->info[$key]->allowed = $allowed;
}
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.

{
if (!isset($this->info[$key]->aliases)) {
$this->info[$key]->aliases = array();
}
foreach ($aliases as $alias => $real) {
$this->info[$key]->aliases[$alias] = $real;
}
}
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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static HTMLPurifier_ConfigSchema::makeFromSerial ( )
static

Unserializes the default ConfigSchema.

Returns
HTMLPurifier_ConfigSchema

Definition at line 69 of file ConfigSchema.php.

Referenced by instance().

{
$contents = file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser');
$r = unserialize($contents);
if (!$r) {
$hash = sha1($contents);
trigger_error("Unserialization of configuration schema failed, sha1 of file was $hash", E_USER_ERROR);
}
return $r;
}

+ Here is the caller graph for this function:

HTMLPurifier_ConfigSchema::postProcess ( )

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

Definition at line 164 of file ConfigSchema.php.

{
foreach ($this->info as $key => $v) {
if (count((array) $v) == 1) {
$this->info[$key] = $v->type;
} elseif (count((array) $v) == 2 && isset($v->allow_null)) {
$this->info[$key] = -$v->type;
}
}
}

Field Documentation

HTMLPurifier_ConfigSchema::$defaultPlist

The default property list.

Do not edit this property list. array

Definition at line 19 of file ConfigSchema.php.

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.

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.

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: