ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTermsOfServiceDocumentHtmlPurifier.php
Go to the documentation of this file.
1<?php
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
33 parent::__construct();
34 $this->allowedTags = $allowedTags;
35 }
36
40 protected function getPurifierConfigInstance()
41 {
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
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.
static createDefault()
Convenience constructor that creates a default configuration object.
Definition: Config.php:154
Abstract class wrapping the HTMLPurifier instance.
removeUnsupportedElements($a_array)
Removes all unsupported elements.
static _getCacheDirectory()
Get the directory for HTMLPurifier cache files.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
__construct(array $allowedTags=null, string $cacheDirectory=null)
ilTermsOfServiceDocumentHtmlPurifier constructor.
getPurifierConfigInstance()
Has to be implemented by subclasses to build the HTMLPurifier_Config instance with object specific co...
$tags
Definition: croninfo.php:19
$def
Definition: croninfo.php:21
$config
Definition: bootstrap.php:15