82 'CommonAttributes',
'Text',
'Hypertext',
'List',
83 'Presentation',
'Edit',
'Bdo',
'Tables',
'Image',
86 'Scripting',
'Object',
'Forms',
90 $transitional =
array(
'Legacy',
'Target',
'Iframe');
91 $xml =
array(
'XMLCommonAttributes');
92 $non_xml =
array(
'NonXMLCommonAttributes');
95 $this->doctypes->register(
96 'HTML 4.01 Transitional',
98 array_merge($common, $transitional, $non_xml),
99 array(
'Tidy_Transitional',
'Tidy_Proprietary'),
101 '-//W3C//DTD HTML 4.01 Transitional//EN',
102 'http://www.w3.org/TR/html4/loose.dtd' 105 $this->doctypes->register(
108 array_merge($common, $non_xml),
109 array(
'Tidy_Strict',
'Tidy_Proprietary',
'Tidy_Name'),
111 '-//W3C//DTD HTML 4.01//EN',
112 'http://www.w3.org/TR/html4/strict.dtd' 115 $this->doctypes->register(
116 'XHTML 1.0 Transitional',
118 array_merge($common, $transitional, $xml, $non_xml),
119 array(
'Tidy_Transitional',
'Tidy_XHTML',
'Tidy_Proprietary',
'Tidy_Name'),
121 '-//W3C//DTD XHTML 1.0 Transitional//EN',
122 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd' 125 $this->doctypes->register(
128 array_merge($common, $xml, $non_xml),
129 array(
'Tidy_Strict',
'Tidy_XHTML',
'Tidy_Strict',
'Tidy_Proprietary',
'Tidy_Name'),
131 '-//W3C//DTD XHTML 1.0 Strict//EN',
132 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd' 135 $this->doctypes->register(
140 array_merge($common, $xml,
array(
'Ruby',
'Iframe')),
141 array(
'Tidy_Strict',
'Tidy_XHTML',
'Tidy_Proprietary',
'Tidy_Strict',
'Tidy_Name'),
143 '-//W3C//DTD XHTML 1.1//EN',
144 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd' 172 if (is_string($module)) {
174 $original_module = $module;
176 foreach ($this->prefixes as $prefix) {
177 $module = $prefix . $original_module;
178 if (class_exists($module)) {
184 $module = $original_module;
185 if (!class_exists($module)) {
187 $original_module .
' module does not exist',
193 $module =
new $module();
195 if (empty($module->name)) {
196 trigger_error(
'Module instance of ' . get_class($module) .
' must have name');
199 if (!$overload && isset($this->registeredModules[$module->name])) {
200 trigger_error(
'Overloading ' . $module->name .
' without explicit overload parameter', E_USER_WARNING);
202 $this->registeredModules[$module->name] = $module;
212 if (is_object($module)) {
213 $module = $module->name;
215 $this->userModules[] = $module;
224 $this->prefixes[] = $prefix;
234 $this->trusted =
$config->get(
'HTML.Trusted');
237 $this->doctype = $this->doctypes->make(
$config);
241 $lookup =
$config->get(
'HTML.AllowedModules');
242 $special_cases =
$config->get(
'HTML.CoreModules');
244 if (is_array($lookup)) {
246 if (isset($special_cases[$m])) {
249 if (!isset($lookup[$m])) {
256 if (
$config->get(
'HTML.Proprietary')) {
259 if (
$config->get(
'HTML.SafeObject')) {
262 if (
$config->get(
'HTML.SafeEmbed')) {
268 if (
$config->get(
'HTML.Nofollow')) {
271 if (
$config->get(
'HTML.TargetBlank')) {
276 if (
$config->get(
'HTML.TargetNoreferrer')) {
285 $this->modules[$module]->setup(
$config);
288 foreach ($this->doctype->tidyModules as $module) {
290 $this->modules[$module]->setup(
$config);
294 foreach ($this->modules as $module) {
296 foreach ($module->info_injector as $injector) {
297 if (!is_object($injector)) {
298 $class =
"HTMLPurifier_Injector_$injector";
299 $injector =
new $class;
301 $n[$injector->name] = $injector;
303 $module->info_injector =
$n;
307 foreach ($this->modules as $module) {
308 foreach ($module->info as $name => $def) {
309 if (!isset($this->elementLookup[$name])) {
310 $this->elementLookup[$name] =
array();
312 $this->elementLookup[$name][] = $module->name;
337 if (!isset($this->registeredModules[$module]) || is_object($module)) {
340 $this->modules[$module] = $this->registeredModules[$module];
350 foreach ($this->modules as $module) {
351 if (!$this->trusted && !$module->safe) {
354 foreach ($module->info as $name => $v) {
355 if (isset($elements[$name])) {
364 foreach ($elements as
$n => $v) {
366 unset($elements[
$n]);
386 if (!isset($this->elementLookup[$name])) {
398 foreach ($this->elementLookup[$name] as $module_name) {
399 $module = $this->modules[$module_name];
410 $new_def = clone $module->info[$name];
412 if (!$def && $new_def->standalone) {
417 $def->mergeIn($new_def);
433 $this->attrCollections->performInclusions($def->attr);
434 $this->attrCollections->expandIdentifiers($def->attr, $this->attrTypes);
437 if (is_string($def->content_model) &&
438 strpos($def->content_model,
'Inline') !==
false) {
439 if ($name !=
'del' && $name !=
'ins') {
441 $def->descendants_are_inline =
true;
445 $this->contentSets->generateChildDef($def, $module);
455 foreach ($def->attr as $attr_name => $attr_def) {
456 if ($attr_def->required) {
457 $def->required_attr[] = $attr_name;
$attrCollections
HTMLPurifier_AttrCollections
$contentSets
HTMLPurifier_ContentSets
$trusted
If set to true, unsafe elements and attributes will be allowed.
$doctypes
HTMLPurifier_DoctypeRegistry
processModule($module)
Takes a module and adds it to the active module collection, registering it if necessary.
$registeredModules
Array of recognized HTMLPurifier_HTMLModule instances, indexed by module's class name.
registerModule($module, $overload=false)
Registers a module to the recognized module list, useful for overloading pre-existing modules...
setup($config)
Performs processing on modules, after being called you may use getElement() and getElements() ...
getElements()
Retrieves merged element definitions.
getElement($name, $trusted=null)
Retrieves a single merged element definition.
$modules
Active instances of modules for the specified doctype are indexed, by name, in this array...
addPrefix($prefix)
Adds a class prefix that registerModule() will use to resolve a string name to a concrete class...
Create styles array
The data for the language used.
addModule($module)
Adds a module to the current doctype by first registering it, and then tacking it on to the active do...
$userModules
List of extra modules that were added by the user using addModule().
$elementLookup
Associative array of element name to list of modules that have definitions for the element; this arra...
Defines common attribute collections that modules reference.
Provides lookup array of attribute types to HTMLPurifier_AttrDef objects.
$attrTypes
HTMLPurifier_AttrTypes
$doctype
Instance of current doctype.
$prefixes
List of prefixes we should use for registering small names.