ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilHtmlPurifierAbstractLibWrapper Class Reference

Abstract class wrapping the HTMLPurifier instance. More...

+ Inheritance diagram for ilHtmlPurifierAbstractLibWrapper:
+ Collaboration diagram for ilHtmlPurifierAbstractLibWrapper:

Public Member Functions

 __construct ()
 Constructor. More...
 
 purify ($a_html, $a_config=null)
 Filters an HTML snippet/document to be XSS-free and standards-compliant. More...
 
 purifyArray (array $a_array_of_html, $a_config=null)
 Filters an array of HTML snippets/documents to be XSS-free and standards-compliant. More...
 
- Public Member Functions inherited from ilHtmlPurifierInterface
 purify ($a_html)
 Filters an HTML snippet/document to be XSS-free and standards-compliant. More...
 
 purifyArray (array $a_array_of_html)
 Filters an array of HTML snippets/documents to be XSS-free and standards-compliant. More...
 

Static Public Member Functions

static _getCacheDirectory ()
 Get the directory for HTMLPurifier cache files. More...
 

Protected Member Functions

 getPurifierConfigInstance ()
 Has to be implemented by subclasses to build the HTMLPurifier_Config instance with object specific configurations. More...
 
 setPurifier (HTMLPurifier $oPurifier)
 Set the purifier by subclass. More...
 
 getPurifier ()
 Get the purifier. More...
 
 removeUnsupportedElements ($a_array)
 Removes all unsupported elements. More...
 
 makeElementListTinyMceCompliant ($elements)
 

Protected Attributes

 $oPurifier = null
 

Detailed Description

Abstract class wrapping the HTMLPurifier instance.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$ @abstract

Definition at line 15 of file class.ilHtmlPurifierAbstractLibWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

ilHtmlPurifierAbstractLibWrapper::__construct ( )

Constructor.

@access public

Reimplemented in ilHtmlForumPostPurifier.

Definition at line 34 of file class.ilHtmlPurifierAbstractLibWrapper.php.

35 {
36 $this->setPurifier(
38 );
39 }
HTMLPurifier($html, $config=null)
Purify HTML.
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...

References getPurifierConfigInstance(), HTMLPurifier(), and setPurifier().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getCacheDirectory()

static ilHtmlPurifierAbstractLibWrapper::_getCacheDirectory ( )
staticfinal

Get the directory for HTMLPurifier cache files.

Returns
string Cache directory for HTMLPurifier @access public @final @statc

Definition at line 117 of file class.ilHtmlPurifierAbstractLibWrapper.php.

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 }
static getDataDir()
get data directory (outside webspace)
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\getDataDir(), and ilUtil\makeDirParents().

Referenced by ilAssHtmlPurifier\getPurifierConfigInstance(), and ilHtmlForumPostPurifier\getPurifierConfigInstance().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPurifier()

ilHtmlPurifierAbstractLibWrapper::getPurifier ( )
protected

Get the purifier.

Returns
HTMLPurifier instance of HTMLPurifier @access protected

Definition at line 102 of file class.ilHtmlPurifierAbstractLibWrapper.php.

References $oPurifier.

◆ getPurifierConfigInstance()

ilHtmlPurifierAbstractLibWrapper::getPurifierConfigInstance ( )
abstractprotected

Has to be implemented by subclasses to build the HTMLPurifier_Config instance with object specific configurations.

@abstract @access protected

Reimplemented in ilAssHtmlPurifier, and ilHtmlForumPostPurifier.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ makeElementListTinyMceCompliant()

ilHtmlPurifierAbstractLibWrapper::makeElementListTinyMceCompliant (   $elements)
protected

Definition at line 162 of file class.ilHtmlPurifierAbstractLibWrapper.php.

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 }

Referenced by ilAssHtmlPurifier\getAllowedElements(), and ilHtmlForumPostPurifier\getPurifierConfigInstance().

+ Here is the caller graph for this function:

◆ purify()

ilHtmlPurifierAbstractLibWrapper::purify (   $a_html,
  $a_config = null 
)
final

Filters an HTML snippet/document to be XSS-free and standards-compliant.

@access public

Parameters
string$a_htmlHTML snippet/document
Returns
string purified html @final

Definition at line 50 of file class.ilHtmlPurifierAbstractLibWrapper.php.

51 {
52 return $this->oPurifier->purify($a_html, $a_config);
53 }

◆ purifyArray()

ilHtmlPurifierAbstractLibWrapper::purifyArray ( array  $a_array_of_html,
  $a_config = null 
)
final

Filters an array of HTML snippets/documents to be XSS-free and standards-compliant.

@access public

Parameters
array$a_array_of_htmlHTML snippet/document
Returns
array Array of HTML snippets/documents @final

Definition at line 64 of file class.ilHtmlPurifierAbstractLibWrapper.php.

65 {
66 return $this->oPurifier->purifyArray($a_array_of_html, $a_config);
67 }

◆ removeUnsupportedElements()

ilHtmlPurifierAbstractLibWrapper::removeUnsupportedElements (   $a_array)
finalprotected

Removes all unsupported elements.

Parameters
Array$a_arrayarray of all elements
Returns
Array array of supported elements @access protected @final

Definition at line 136 of file class.ilHtmlPurifierAbstractLibWrapper.php.

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 }

Referenced by ilAssHtmlPurifier\getAllowedElements(), and ilHtmlForumPostPurifier\getPurifierConfigInstance().

+ Here is the caller graph for this function:

◆ setPurifier()

ilHtmlPurifierAbstractLibWrapper::setPurifier ( HTMLPurifier  $oPurifier)
protected

Set the purifier by subclass.

Parameters
HTMLPurifier$oPurifierInstance of HTMLPurifier
Returns
ilHtmlPurifier This reference @access protected

Definition at line 88 of file class.ilHtmlPurifierAbstractLibWrapper.php.

89 {
90 $this->oPurifier = $oPurifier;
91 return $this;
92 }

References $oPurifier.

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $oPurifier

ilHtmlPurifierAbstractLibWrapper::$oPurifier = null
protected

Definition at line 26 of file class.ilHtmlPurifierAbstractLibWrapper.php.

Referenced by getPurifier(), and setPurifier().


The documentation for this class was generated from the following file: