ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
HTMLPurifier_DoctypeRegistry Class Reference
+ Collaboration diagram for HTMLPurifier_DoctypeRegistry:

Public Member Functions

 register ( $doctype, $xml=true, $modules=array(), $tidy_modules=array(), $aliases=array(), $dtd_public=null, $dtd_system=null)
 Registers a doctype to the registry. More...
 
 get ($doctype)
 Retrieves reference to a doctype of a certain name. More...
 
 make ($config)
 Creates a doctype based on a configuration object, will perform initialization on the doctype. More...
 
 getDoctypeFromConfig ($config)
 Retrieves the doctype from the configuration object. More...
 

Protected Attributes

 $doctypes
 Hash of doctype names to doctype objects. More...
 
 $aliases
 Lookup table of aliases to real doctype names. More...
 

Detailed Description

Definition at line 3 of file DoctypeRegistry.php.

Member Function Documentation

◆ get()

HTMLPurifier_DoctypeRegistry::get (   $doctype)

Retrieves reference to a doctype of a certain name.

Note
This function resolves aliases
When possible, use the more fully-featured make()
Parameters
string$doctypeName of doctype
Returns
HTMLPurifier_Doctype Editable doctype object

Definition at line 83 of file DoctypeRegistry.php.

84  {
85  if (isset($this->aliases[$doctype])) {
86  $doctype = $this->aliases[$doctype];
87  }
88  if (!isset($this->doctypes[$doctype])) {
89  trigger_error('Doctype ' . htmlspecialchars($doctype) . ' does not exist', E_USER_ERROR);
90  $anon = new HTMLPurifier_Doctype($doctype);
91  return $anon;
92  }
93  return $this->doctypes[$doctype];
94  }
Represents a document type, contains information on which modules need to be loaded.
Definition: Doctype.php:9

◆ getDoctypeFromConfig()

HTMLPurifier_DoctypeRegistry::getDoctypeFromConfig (   $config)

Retrieves the doctype from the configuration object.

Parameters
HTMLPurifier_Config$config
Returns
string

Definition at line 116 of file DoctypeRegistry.php.

References $config.

Referenced by make().

117  {
118  // recommended test
119  $doctype = $config->get('HTML.Doctype');
120  if (!empty($doctype)) {
121  return $doctype;
122  }
123  $doctype = $config->get('HTML.CustomDoctype');
124  if (!empty($doctype)) {
125  return $doctype;
126  }
127  // backwards-compatibility
128  if ($config->get('HTML.XHTML')) {
129  $doctype = 'XHTML 1.0';
130  } else {
131  $doctype = 'HTML 4.01';
132  }
133  if ($config->get('HTML.Strict')) {
134  $doctype .= ' Strict';
135  } else {
136  $doctype .= ' Transitional';
137  }
138  return $doctype;
139  }
+ Here is the caller graph for this function:

◆ make()

HTMLPurifier_DoctypeRegistry::make (   $config)

Creates a doctype based on a configuration object, will perform initialization on the doctype.

Note
Use this function to get a copy of doctype that config can hold on to (this is necessary in order to tell Generator whether or not the current document is XML based or not).
Parameters
HTMLPurifier_Config$config
Returns
HTMLPurifier_Doctype

Definition at line 106 of file DoctypeRegistry.php.

References $config, and getDoctypeFromConfig().

107  {
108  return clone $this->get($this->getDoctypeFromConfig($config));
109  }
getDoctypeFromConfig($config)
Retrieves the doctype from the configuration object.
+ Here is the call graph for this function:

◆ register()

HTMLPurifier_DoctypeRegistry::register (   $doctype,
  $xml = true,
  $modules = array(),
  $tidy_modules = array(),
  $aliases = array(),
  $dtd_public = null,
  $dtd_system = null 
)

Registers a doctype to the registry.

Note
Accepts a fully-formed doctype object, or the parameters for constructing a doctype object
Parameters
string$doctypeName of doctype or literal doctype object
bool$xml
array$modulesModules doctype will load
array$tidy_modulesModules doctype will load for certain modes
array$aliasesAlias names for doctype
string$dtd_public
string$dtd_system
Returns
HTMLPurifier_Doctype Editable registered doctype

Definition at line 31 of file DoctypeRegistry.php.

References $aliases, and array.

39  {
40  if (!is_array($modules)) {
41  $modules = array($modules);
42  }
43  if (!is_array($tidy_modules)) {
44  $tidy_modules = array($tidy_modules);
45  }
46  if (!is_array($aliases)) {
48  }
49  if (!is_object($doctype)) {
50  $doctype = new HTMLPurifier_Doctype(
51  $doctype,
52  $xml,
53  $modules,
54  $tidy_modules,
55  $aliases,
56  $dtd_public,
57  $dtd_system
58  );
59  }
60  $this->doctypes[$doctype->name] = $doctype;
61  $name = $doctype->name;
62  // hookup aliases
63  foreach ($doctype->aliases as $alias) {
64  if (isset($this->doctypes[$alias])) {
65  continue;
66  }
67  $this->aliases[$alias] = $name;
68  }
69  // remove old aliases
70  if (isset($this->aliases[$name])) {
71  unset($this->aliases[$name]);
72  }
73  return $doctype;
74  }
Represents a document type, contains information on which modules need to be loaded.
Definition: Doctype.php:9
Create styles array
The data for the language used.
$aliases
Lookup table of aliases to real doctype names.

Field Documentation

◆ $aliases

HTMLPurifier_DoctypeRegistry::$aliases
protected

Lookup table of aliases to real doctype names.

array

Definition at line 16 of file DoctypeRegistry.php.

Referenced by register().

◆ $doctypes

HTMLPurifier_DoctypeRegistry::$doctypes
protected

Hash of doctype names to doctype objects.

array

Definition at line 10 of file DoctypeRegistry.php.


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