ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ilAssHtmlPurifier\getPurifierConfigInstance(), and ilHtmlForumPostPurifier\getPurifierConfigInstance().

118  {
119  if(!file_exists(ilUtil::getDataDir().'/HTMLPurifier') ||
120  !is_dir(ilUtil::getDataDir().'/HTMLPurifier'))
121  {
122  ilUtil::makeDirParents(ilUtil::getDataDir().'/HTMLPurifier');
123  }
124 
125  return ilUtil::getDataDir().'/HTMLPurifier';
126  }
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 165 of file class.ilHtmlPurifierAbstractLibWrapper.php.

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

166  {
167  // Bugfix #5945: Necessary because TinyMCE does not use the "u"
168  // html element but <span style="text-decoration: underline">E</span>
169 
170  if( in_array('u', $elements) && !in_array('span', $elements) )
171  {
172  $elements[] = 'span';
173  }
174 
175  return $elements;
176  }
+ 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 137 of file class.ilHtmlPurifierAbstractLibWrapper.php.

References array.

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

138  {
139  $supportedElements = array();
140 
141  $notSupportedTags = array(
142  'rp',
143  'rt',
144  'rb',
145  'rtc',
146  'rbc',
147  'ruby',
148  'u',
149  'strike',
150  'param',
151  'object'
152  );
153 
154  foreach($a_array as $element)
155  {
156  if(!in_array($element, $notSupportedTags))
157  {
158  $supportedElements[] = $element;
159  }
160  }
161 
162  return $supportedElements;
163  }
Create styles array
The data for the language used.
+ 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: