ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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$

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

Constructor & Destructor Documentation

◆ __construct()

ilHtmlPurifierAbstractLibWrapper::__construct ( )

Constructor.

public

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

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

35  {
36  $this->setPurifier(
38  );
39  }
getPurifierConfigInstance()
Has to be implemented by subclasses to build the HTMLPurifier_Config instance with object specific co...
setPurifier(HTMLPurifier $oPurifier)
Set the purifier by subclass.
HTMLPurifier($html, $config=null)
Purify HTML.
+ 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 public

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

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

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

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

protected

Referenced by __construct(), and purifyArray().

+ Here is the caller graph for this function:

◆ makeElementListTinyMceCompliant()

ilHtmlPurifierAbstractLibWrapper::makeElementListTinyMceCompliant (   $elements)
protected

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

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

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  }
+ 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.

public

Parameters
string$a_htmlHTML snippet/document
Returns
string purified html

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.

public

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

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

References getPurifierConfigInstance().

65  {
66  return $this->oPurifier->purifyArray($a_array_of_html, $a_config);
67  }
+ Here is the call graph for this function:

◆ removeUnsupportedElements()

ilHtmlPurifierAbstractLibWrapper::removeUnsupportedElements (   $a_array)
finalprotected

Removes all unsupported elements.

Parameters
Array$a_arrayarray of all elements
Returns
Array array of supported elements protected

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

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

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  }
+ 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 protected

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

References $oPurifier.

Referenced by __construct().

89  {
90  $this->oPurifier = $oPurifier;
91  return $this;
92  }
+ 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: