ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilAccessibilityDocumentHtmlPurifier.php
Go to the documentation of this file.
1 <?php
2 
23 {
24  private array $allowedTags = [];
25  protected string $cacheDirectory = '';
26 
27  public function __construct(?array $allowedTags = null, ?string $cacheDirectory = null)
28  {
29  if (null === $cacheDirectory) {
31  }
32  $this->cacheDirectory = $cacheDirectory;
33 
34  if (null === $allowedTags) {
35  $allowedTags = ilObjAdvancedEditing::_getUsedHTMLTags('textarea');
36  }
37  $this->allowedTags = $allowedTags;
38 
40  $this->allowedTags = $allowedTags;
41  }
42 
44  {
45  $config = HTMLPurifier_Config::createDefault();
46  $config->set('HTML.DefinitionID', 'ilias accessibility document');
47  $config->set('HTML.DefinitionRev', 1);
48  $config->set('HTML.TargetBlank', true);
49  $config->set('Cache.SerializerPath', $this->cacheDirectory);
50  $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
51 
52  $tags = $this->allowedTags;
53  $tags = $this->makeElementListTinyMceCompliant($tags);
54 
55  $tags[] = 'b';
56  $tags[] = 'i';
57 
58  $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
59  $config->set('HTML.ForbiddenAttributes', 'div@style');
60 
61  if ($def = $config->maybeGetRawHTMLDefinition()) {
62  $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
63  }
64 
65  return $config;
66  }
67 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?array $allowedTags=null, ?string $cacheDirectory=null)
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(Container $dic, ilPlugin $plugin)
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.