ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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...
 

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

array $allowed_tags
 
string $cache_directory
 
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
null|Closure()HTMLPurifier_Config $create_config

Definition at line 40 of file HTMLPurifier.php.

References ILIAS\MetaData\Repository\Validation\Data\__construct(), ilHtmlPurifierAbstractLibWrapper\_getCacheDirectory(), and ilObjAdvancedEditing\_getUsedHTMLTags().

44  {
46  $this->allowed_tags = $allowed_tags ?? ilObjAdvancedEditing::_getUsedHTMLTags('textarea');
47  $this->create_config = $create_config ?? HTMLPurifier_Config::createDefault(...);
49  }
__construct(VocabulariesInterface $vocabularies)
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
+ Here is the call graph for this function:

Member Function Documentation

◆ getPurifierConfigInstance()

ILIAS\LegalDocuments\HTMLPurifier::getPurifierConfigInstance ( )
protected

Definition at line 51 of file HTMLPurifier.php.

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

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

Field Documentation

◆ $allowed_tags

array ILIAS\LegalDocuments\HTMLPurifier::$allowed_tags
private

Definition at line 31 of file HTMLPurifier.php.

◆ $cache_directory

string ILIAS\LegalDocuments\HTMLPurifier::$cache_directory
private

Definition at line 32 of file HTMLPurifier.php.

◆ $create_config

Closure ILIAS\LegalDocuments\HTMLPurifier::$create_config
private

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