ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilWebDAVMountInstructionsDocumentPurifier.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  private array $allowedTags;
24  protected string $cacheDirectory;
25 
26  public function __construct(array $allowedTags = null, string $cacheDirectory = null)
27  {
28  $this->cacheDirectory = $cacheDirectory ?? ilHtmlPurifierAbstractLibWrapper::_getCacheDirectory();
29  $this->allowedTags = $allowedTags ?? ilObjAdvancedEditing::_getUsedHTMLTags('textarea');
30 
32  }
33 
35  {
36  $config = HTMLPurifier_Config::createDefault();
37  $config->set('HTML.DefinitionID', 'ilias termsofservice document');
38  $config->set('HTML.DefinitionRev', 1);
39  $config->set('HTML.TargetBlank', true);
40  $config->set('Cache.SerializerPath', $this->cacheDirectory);
41  $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
42 
43  $tags = $this->allowedTags;
44  $tags = $this->makeElementListTinyMceCompliant($tags);
45 
46  $tags[] = 'b';
47  $tags[] = 'i';
48 
49  $config->set('HTML.AllowedElements', $this->removeUnsupportedElements($tags));
50  $config->set('HTML.ForbiddenAttributes', 'div@style');
51 
52  if ($def = $config->maybeGetRawHTMLDefinition()) {
53  $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
54  }
55 
56  return $config;
57  }
58 }
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(array $allowedTags=null, string $cacheDirectory=null)
__construct(Container $dic, ilPlugin $plugin)
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.