ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
123 }
124
125 return ilUtil::getDataDir().'/HTMLPurifier';
126 }
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 165 of file class.ilHtmlPurifierAbstractLibWrapper.php.

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 }

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 137 of file class.ilHtmlPurifierAbstractLibWrapper.php.

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 }

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: