ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTermsOfServiceDocumentHtmlPurifier.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
11 private $allowedTags = [];
12
14 protected $cacheDirectory = '';
15
21 public function __construct(array $allowedTags = null, string $cacheDirectory = null)
22 {
23 if (null === $cacheDirectory) {
25 }
26 $this->cacheDirectory = $cacheDirectory;
27
28 if (null === $allowedTags) {
30 }
31 $this->allowedTags = $allowedTags;
32
34 $this->allowedTags = $allowedTags;
35 }
36
40 protected function getPurifierConfigInstance() : HTMLPurifier_Config
41 {
42 $config = HTMLPurifier_Config::createDefault();
43 $config->set('HTML.DefinitionID', 'ilias termsofservice document');
44 $config->set('HTML.DefinitionRev', 1);
45 $config->set('HTML.TargetBlank', true);
46 $config->set('Cache.SerializerPath', $this->cacheDirectory);
47 $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
48
49 $tags = $this->allowedTags;
50 $tags = $this->makeElementListTinyMceCompliant($tags);
51
52 $tags[] = 'b';
53 $tags[] = 'i';
54
55 $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
56 $config->set('HTML.ForbiddenAttributes', 'div@style');
57
58 if ($def = $config->maybeGetRawHTMLDefinition()) {
59 $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
60 }
61
62 return $config;
63 }
64}
An exception for terminatinating execution or to throw for unit testing.
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.
__construct(array $allowedTags=null, string $cacheDirectory=null)
ilTermsOfServiceDocumentHtmlPurifier constructor.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc