ILIAS  release_8 Revision v8.24
class.ilTermsOfServiceDocumentHtmlPurifier.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
28 private array $allowedTags;
29 protected string $cacheDirectory;
30
36 public function __construct(array $allowedTags = null, string $cacheDirectory = null)
37 {
38 if (null === $cacheDirectory) {
40 }
41 $this->cacheDirectory = $cacheDirectory;
42
43 if (null === $allowedTags) {
45 }
46 $this->allowedTags = $allowedTags;
47
49 $this->allowedTags = $allowedTags;
50 }
51
52 protected function getPurifierConfigInstance(): HTMLPurifier_Config
53 {
54 $config = HTMLPurifier_Config::createDefault();
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->cacheDirectory);
59 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
60
61 $tags = $this->allowedTags;
62 $tags = $this->makeElementListTinyMceCompliant($tags);
63
64 $tags[] = 'b';
65 $tags[] = 'i';
66
67 $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
68 $config->set('HTML.ForbiddenAttributes', 'div@style');
69
70 if ($def = $config->maybeGetRawHTMLDefinition()) {
71 $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
72 }
73
74 return $config;
75 }
76}
Abstract class wrapping the HTMLPurifier instance.
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
__construct(array $allowedTags=null, string $cacheDirectory=null)
ilTermsOfServiceDocumentHtmlPurifier constructor.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc