ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\HTMLPurifier Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\HTMLPurifier:
+ Collaboration diagram for ILIAS\LegalDocuments\HTMLPurifier:

Public Member Functions

 __construct (?array $allowed_tags=null, ?string $cache_directory=null, ?Closure $create_config=null)
 
- Public Member Functions inherited from ilHtmlPurifierAbstractLibWrapper
 __construct ()
 ilHtmlPurifierAbstractLibWrapper constructor. More...
 
 purify (string $html)
 Filters an HTML snippet/document to be XSS-free and standards-compliant. More...
 
 purifyArray (array $htmlCollection)
 Filters an array of HTML snippets/documents to be XSS-free and standards-compliant. More...
 
 purify (string $html)
 Filters an HTML snippet/document to be XSS-free and standards-compliant. More...
 
 purifyArray (array $htmlCollection)
 Filters an array of HTML snippets/documents to be XSS-free and standards-compliant. More...
 

Protected Member Functions

 getPurifierConfigInstance ()
 
- Protected Member Functions inherited from ilHtmlPurifierAbstractLibWrapper
 getPurifierConfigInstance ()
 
 setPurifier (HTMLPurifier $purifier)
 
 getPurifier ()
 
 removeUnsupportedElements (array $elements)
 Removes all unsupported elements. More...
 
 makeElementListTinyMceCompliant (array $elements)
 

Private Attributes

readonly array $allowed_tags
 
readonly string $cache_directory
 
readonly Closure $create_config
 

Additional Inherited Members

- Static Public Member Functions inherited from ilHtmlPurifierAbstractLibWrapper
static _getCacheDirectory ()
 
- Protected Attributes inherited from ilHtmlPurifierAbstractLibWrapper
HTMLPurifier $purifier
 

Detailed Description

Definition at line 28 of file HTMLPurifier.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\HTMLPurifier::__construct ( ?array  $allowed_tags = null,
?string  $cache_directory = null,
?Closure  $create_config = null 
)
Parameters
list<string>$allowed_tags
null|Closure()HTMLPurifier_Config $create_config

Definition at line 41 of file HTMLPurifier.php.

45 {
47 $this->allowed_tags = $allowed_tags ?? ilRTESettings::_getUsedHTMLTags('textarea');
48 $this->create_config = $create_config ?? HTMLPurifier_Config::createDefault(...);
50 }
static _getUsedHTMLTags(string $module='')
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\LegalDocuments\HTMLPurifier\$allowed_tags, ILIAS\LegalDocuments\HTMLPurifier\$cache_directory, ILIAS\LegalDocuments\HTMLPurifier\$create_config, ILIAS\GlobalScreen\Provider\__construct(), ilHtmlPurifierAbstractLibWrapper\_getCacheDirectory(), and ilRTESettings\_getUsedHTMLTags().

+ Here is the call graph for this function:

Member Function Documentation

◆ getPurifierConfigInstance()

ILIAS\LegalDocuments\HTMLPurifier::getPurifierConfigInstance ( )
protected

Reimplemented from ilHtmlPurifierAbstractLibWrapper.

Definition at line 52 of file HTMLPurifier.php.

52 : HTMLPurifier_Config
53 {
54 $config = ($this->create_config)();
55 $config->set('HTML.DefinitionID', 'ilias termsofservice document');
56 $config->set('HTML.DefinitionRev', 1);
57 $config->set('HTML.TargetBlank', true);
58 $config->set('Cache.SerializerPath', $this->cache_directory);
59 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
60
61 $tags = $this->makeElementListTinyMceCompliant($this->allowed_tags);
62
63 $tags[] = 'b';
64 $tags[] = 'i';
65
66 $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
67 $config->set('HTML.ForbiddenAttributes', 'div@style');
68
69 if (($def = $config->maybeGetRawHTMLDefinition()) !== null) {
70 $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
71 }
72
73 return $config;
74 }
removeUnsupportedElements(array $elements)
Removes all unsupported elements.

References ILIAS\LegalDocuments\HTMLPurifier\$create_config, ilHtmlPurifierAbstractLibWrapper\makeElementListTinyMceCompliant(), and ilHtmlPurifierAbstractLibWrapper\removeUnsupportedElements().

+ Here is the call graph for this function:

Field Documentation

◆ $allowed_tags

readonly array ILIAS\LegalDocuments\HTMLPurifier::$allowed_tags
private

Definition at line 31 of file HTMLPurifier.php.

Referenced by ILIAS\LegalDocuments\HTMLPurifier\__construct().

◆ $cache_directory

readonly string ILIAS\LegalDocuments\HTMLPurifier::$cache_directory
private

Definition at line 32 of file HTMLPurifier.php.

Referenced by ILIAS\LegalDocuments\HTMLPurifier\__construct().

◆ $create_config

readonly Closure ILIAS\LegalDocuments\HTMLPurifier::$create_config
private

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