ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAccessibilityDocumentHtmlPurifier.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
10 private $allowedTags = [];
11
13 protected $cacheDirectory = '';
14
20 public function __construct(array $allowedTags = null, string $cacheDirectory = null)
21 {
22 if (null === $cacheDirectory) {
24 }
25 $this->cacheDirectory = $cacheDirectory;
26
27 if (null === $allowedTags) {
29 }
30 $this->allowedTags = $allowedTags;
31
33 $this->allowedTags = $allowedTags;
34 }
35
39 protected function getPurifierConfigInstance() : HTMLPurifier_Config
40 {
41 $config = HTMLPurifier_Config::createDefault();
42 $config->set('HTML.DefinitionID', 'ilias accessibility document');
43 $config->set('HTML.DefinitionRev', 1);
44 $config->set('HTML.TargetBlank', true);
45 $config->set('Cache.SerializerPath', $this->cacheDirectory);
46 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
47
48 $tags = $this->allowedTags;
49 $tags = $this->makeElementListTinyMceCompliant($tags);
50
51 $tags[] = 'b';
52 $tags[] = 'i';
53
54 $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
55 $config->set('HTML.ForbiddenAttributes', 'div@style');
56
57 if ($def = $config->maybeGetRawHTMLDefinition()) {
58 $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
59 }
60
61 return $config;
62 }
63}
An exception for terminatinating execution or to throw for unit testing.
__construct(array $allowedTags=null, string $cacheDirectory=null)
ilAccessibilityDocumentHtmlPurifier constructor.
Abstract class wrapping the HTMLPurifier instance.
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc