ILIAS  release_8 Revision v8.23
class.ilWebDAVMountInstructionsDocumentPurifier.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 
23 {
24  private array $allowedTags;
25  protected string $cacheDirectory;
26 
27  public function __construct(array $allowedTags = null, string $cacheDirectory = null)
28  {
29  $this->cacheDirectory = $cacheDirectory ?? ilHtmlPurifierAbstractLibWrapper::_getCacheDirectory();
30  $this->allowedTags = $allowedTags ?? ilObjAdvancedEditing::_getUsedHTMLTags('textarea');
31 
33  }
34 
35  protected function getPurifierConfigInstance(): HTMLPurifier_Config
36  {
37  $config = HTMLPurifier_Config::createDefault();
38  $config->set('HTML.DefinitionID', 'ilias termsofservice document');
39  $config->set('HTML.DefinitionRev', 1);
40  $config->set('HTML.TargetBlank', true);
41  $config->set('Cache.SerializerPath', $this->cacheDirectory);
42  $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
43 
44  $tags = $this->allowedTags;
45  $tags = $this->makeElementListTinyMceCompliant($tags);
46 
47  $tags[] = 'b';
48  $tags[] = 'i';
49 
50  $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
51  $config->set('HTML.ForbiddenAttributes', 'div@style');
52 
53  if ($def = $config->maybeGetRawHTMLDefinition()) {
54  $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
55  }
56 
57  return $config;
58  }
59 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
Abstract class wrapping the HTMLPurifier instance.
__construct(array $allowedTags=null, string $cacheDirectory=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.