ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $this->purifiers[] = $a_purifier;
38 return true;
39 }
40
41 return false;
42 }
43
52 public function removePurifier(ilHtmlPurifierInterface $a_purifier)
53 {
54 $key = array_search($a_purifier, $this->purifiers);
55 if (false === $key) {
56 return false;
57 }
58 unset($this->purifiers[$key]);
59
60 return true;
61 }
62
71 public function purify($a_html)
72 {
73 foreach ($this->purifiers as $oPurifier) {
74 $a_html = $oPurifier->purify($a_html);
75 }
76
77 return $a_html;
78 }
79
88 public function purifyArray(array $a_array_of_html)
89 {
90 foreach ($a_array_of_html as $key => $html) {
91 foreach ($this->purifiers as $oPurifier) {
92 $html = $oPurifier->purify($html);
93 }
94
95 $a_array_of_html[$key] = $html;
96 }
97
98 return $a_array_of_html;
99 }
100}
An exception for terminatinating execution or to throw for unit testing.
Composite for nesting multiple purifiers.
removePurifier(ilHtmlPurifierInterface $a_purifier)
Removes a node from composite.
purify($a_html)
Filters an HTML snippet/document to be XSS-free and standards-compliant.
addPurifier(ilHtmlPurifierInterface $a_purifier)
Adds a node to composite.
purifyArray(array $a_array_of_html)
Filters an array of HTML snippets/documents to be XSS-free and standards-compliant.
$key
Definition: croninfo.php:18
$html
Definition: example_001.php:87
Interface for html sanitizing functionality.