ILIAS  release_4-4 Revision
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
$doctypeName of doctype
Returns
Editable doctype object

Definition at line 56 of file DoctypeRegistry.php.

56  {
57  if (isset($this->aliases[$doctype])) $doctype = $this->aliases[$doctype];
58  if (!isset($this->doctypes[$doctype])) {
59  trigger_error('Doctype ' . htmlspecialchars($doctype) . ' does not exist', E_USER_ERROR);
60  $anon = new HTMLPurifier_Doctype($doctype);
61  return $anon;
62  }
63  return $this->doctypes[$doctype];
64  }
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.

Definition at line 81 of file DoctypeRegistry.php.

Referenced by make().

81  {
82  // recommended test
83  $doctype = $config->get('HTML.Doctype');
84  if (!empty($doctype)) return $doctype;
85  $doctype = $config->get('HTML.CustomDoctype');
86  if (!empty($doctype)) return $doctype;
87  // backwards-compatibility
88  if ($config->get('HTML.XHTML')) {
89  $doctype = 'XHTML 1.0';
90  } else {
91  $doctype = 'HTML 4.01';
92  }
93  if ($config->get('HTML.Strict')) {
94  $doctype .= ' Strict';
95  } else {
96  $doctype .= ' Transitional';
97  }
98  return $doctype;
99  }
+ 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).

Definition at line 74 of file DoctypeRegistry.php.

References getDoctypeFromConfig().

74  {
75  return clone $this->get($this->getDoctypeFromConfig($config));
76  }
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
$doctypeName of doctype or literal doctype object
$modulesModules doctype will load
$modules_for_modesModules doctype will load for certain modes
$aliasesAlias names for doctype
Returns
Editable registered doctype

Definition at line 26 of file DoctypeRegistry.php.

References $aliases.

28  {
29  if (!is_array($modules)) $modules = array($modules);
30  if (!is_array($tidy_modules)) $tidy_modules = array($tidy_modules);
31  if (!is_array($aliases)) $aliases = array($aliases);
32  if (!is_object($doctype)) {
33  $doctype = new HTMLPurifier_Doctype(
34  $doctype, $xml, $modules, $tidy_modules, $aliases, $dtd_public, $dtd_system
35  );
36  }
37  $this->doctypes[$doctype->name] = $doctype;
38  $name = $doctype->name;
39  // hookup aliases
40  foreach ($doctype->aliases as $alias) {
41  if (isset($this->doctypes[$alias])) continue;
42  $this->aliases[$alias] = $name;
43  }
44  // remove old aliases
45  if (isset($this->aliases[$name])) unset($this->aliases[$name]);
46  return $doctype;
47  }
Represents a document type, contains information on which modules need to be loaded.
Definition: Doctype.php:9
$aliases
Lookup table of aliases to real doctype names.

Field Documentation

◆ $aliases

HTMLPurifier_DoctypeRegistry::$aliases
protected

Lookup table of aliases to real doctype names.

Definition at line 14 of file DoctypeRegistry.php.

Referenced by register().

◆ $doctypes

HTMLPurifier_DoctypeRegistry::$doctypes
protected

Hash of doctype names to doctype objects.

Definition at line 9 of file DoctypeRegistry.php.


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