ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilHtmlForumPostPurifier.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected function getPurifierConfigInstance(): HTMLPurifier_Config
28 {
29 $config = HTMLPurifier_Config::createDefault();
30 $config->set('HTML.DefinitionID', 'ilias forum post');
31 $config->set('HTML.DefinitionRev', 2);
32 $config->set('Cache.SerializerPath', ilHtmlPurifierAbstractLibWrapper::_getCacheDirectory());
33 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
34
35 $tags = ilRTESettings::_getUsedHTMLTags('frm_post');
36 $tags = $this->makeElementListTinyMceCompliant($tags);
37 $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
38 $config->set('HTML.ForbiddenAttributes', 'div@style');
39
40 if (($def = $config->maybeGetRawHTMLDefinition()) !== null) {
41 $def->addAttribute('img', 'data-id', 'Number');
42 $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
43 }
44
45 return $config;
46 }
47}
Concrete class for sanitizing html of forum posts.
Abstract class wrapping the HTMLPurifier instance.
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
static _getUsedHTMLTags(string $module='')