ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilHtmlPurifierAbstractLibWrapper.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Html/HtmlPurifier/library/HTMLPurifier.safe-includes.php';
5 require_once 'Services/Html/interfaces/interface.ilHtmlPurifierInterface.php';
6 
16 {
17 
26  protected $oPurifier = null;
27 
34  public function __construct()
35  {
36  $this->setPurifier(
38  );
39  }
40 
50  final public function purify($a_html, $a_config = null)
51  {
52  return $this->oPurifier->purify($a_html, $a_config);
53  }
54 
64  final public function purifyArray(Array $a_array_of_html, $a_config = null)
65  {
66  return $this->oPurifier->purifyArray($a_array_of_html, $a_config);
67  }
68 
77  abstract protected function getPurifierConfigInstance();
78 
88  protected function setPurifier(HTMLPurifier $oPurifier)
89  {
90  $this->oPurifier = $oPurifier;
91  return $this;
92  }
93 
102  protected function getPurifier()
103  {
104  return $this->oPurifier;
105  }
106 
117  final static public function _getCacheDirectory()
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  }
127 
137  final protected function removeUnsupportedElements($a_array)
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  }
164 }
165 ?>