ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilHtmlPurifierComposite.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 'Services/Html/interfaces/interface.ilHtmlPurifierInterface.php';
5
14{
23 protected $purifiers = array();
24
33 public function addPurifier(ilHtmlPurifierInterface $a_purifier)
34 {
35 $key = array_search($a_purifier, $this->purifiers);
36 if(false === $key)
37 {
38 $this->purifiers[] = $a_purifier;
39 return true;
40 }
41
42 return false;
43 }
44
53 public function removePurifier(ilHtmlPurifierInterface $a_purifier)
54 {
55 $key = array_search($a_purifier, $this->purifiers);
56 if(false === $key)
57 {
58 return false;
59 }
60 unset($this->purifiers[$key]);
61
62 return true;
63 }
64
73 public function purify($a_html)
74 {
75 foreach($this->purifiers as $oPurifier)
76 {
77 $a_html = $oPurifier->purify($a_html);
78 }
79
80 return $a_html;
81 }
82
91 public function purifyArray(Array $a_array_of_html)
92 {
93 foreach($a_array_of_html as $key => $html)
94 {
95 foreach($this->purifiers as $oPurifier)
96 {
97 $html = $oPurifier->purify($html);
98 }
99
100 $a_array_of_html[$key] = $html;
101 }
102
103 return $a_array_of_html;
104 }
105}
106?>
Composite for nesting multiple purifiers.
removePurifier(ilHtmlPurifierInterface $a_purifier)
Removes a node from composite.
purifyArray(Array $a_array_of_html)
Filters an array of HTML snippets/documents to be XSS-free and standards-compliant.
purify($a_html)
Filters an HTML snippet/document to be XSS-free and standards-compliant.
addPurifier(ilHtmlPurifierInterface $a_purifier)
Adds a node to composite.
$html
Definition: example_001.php:87
Interface for html sanitizing functionality.