ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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

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.

References ILIAS\GlobalScreen\Provider\__construct(), ilHtmlPurifierAbstractLibWrapper\_getCacheDirectory(), and ilObjAdvancedEditing\_getUsedHTMLTags().

45  {
47  $this->allowed_tags = $allowed_tags ?? ilObjAdvancedEditing::_getUsedHTMLTags('textarea');
48  $this->create_config = $create_config ?? HTMLPurifier_Config::createDefault(...);
50  }
__construct(Container $dic, ilPlugin $plugin)
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 52 of file HTMLPurifier.php.

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

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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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.

◆ $cache_directory

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

Definition at line 32 of file HTMLPurifier.php.

◆ $create_config

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

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