ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilHtmlPurifierAbstractLibWrapper.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'libs/composer/vendor/autoload.php';
5require_once 'Services/Html/interfaces/interface.ilHtmlPurifierInterface.php';
6
16{
17
26 protected $oPurifier = null;
27
34 public function __construct()
35 {
36 $this->setPurifier(
38 );
39 }
40
50 final public function purify($a_html, $a_config = null)
51 {
52 return $this->oPurifier->purify($a_html, $a_config);
53 }
54
64 final public function purifyArray(array $a_array_of_html, $a_config = null)
65 {
66 return $this->oPurifier->purifyArray($a_array_of_html, $a_config);
67 }
68
77 abstract protected function getPurifierConfigInstance();
78
89 {
90 $this->oPurifier = $oPurifier;
91 return $this;
92 }
93
102 protected function getPurifier()
103 {
104 return $this->oPurifier;
105 }
106
117 final public static function _getCacheDirectory()
118 {
119 if (!file_exists(ilUtil::getDataDir() . '/HTMLPurifier') ||
120 !is_dir(ilUtil::getDataDir() . '/HTMLPurifier')) {
121 ilUtil::makeDirParents(ilUtil::getDataDir() . '/HTMLPurifier');
122 }
123
124 return ilUtil::getDataDir() . '/HTMLPurifier';
125 }
126
136 final protected function removeUnsupportedElements($a_array)
137 {
138 $supportedElements = array();
139
140 $notSupportedTags = array(
141 'rp',
142 'rt',
143 'rb',
144 'rtc',
145 'rbc',
146 'ruby',
147 'u',
148 'strike',
149 'param',
150 'object'
151 );
152
153 foreach ($a_array as $element) {
154 if (!in_array($element, $notSupportedTags)) {
155 $supportedElements[] = $element;
156 }
157 }
158
159 return $supportedElements;
160 }
161
162 protected function makeElementListTinyMceCompliant($elements)
163 {
164 // Bugfix #5945: Necessary because TinyMCE does not use the "u"
165 // html element but <span style="text-decoration: underline">E</span>
166
167 if (in_array('u', $elements) && !in_array('span', $elements)) {
168 $elements[] = 'span';
169 }
170
171 return $elements;
172 }
173}
HTMLPurifier($html, $config=null)
Purify HTML.
An exception for terminatinating execution or to throw for unit testing.
Facade that coordinates HTML Purifier's subsystems in order to purify HTML.
Abstract class wrapping the HTMLPurifier instance.
removeUnsupportedElements($a_array)
Removes all unsupported elements.
purifyArray(array $a_array_of_html, $a_config=null)
Filters an array of HTML snippets/documents to be XSS-free and standards-compliant.
setPurifier(HTMLPurifier $oPurifier)
Set the purifier by subclass.
getPurifierConfigInstance()
Has to be implemented by subclasses to build the HTMLPurifier_Config instance with object specific co...
purify($a_html, $a_config=null)
Filters an HTML snippet/document to be XSS-free and standards-compliant.
static _getCacheDirectory()
Get the directory for HTMLPurifier cache files.
static getDataDir()
get data directory (outside webspace)
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Interface for html sanitizing functionality.