ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAssHtmlPurifier.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  protected function getPurifierType(): string
28  {
29  return 'assessment';
30  }
31 
35  protected function getPurifierConfigInstance(): HTMLPurifier_Config
36  {
37  $config = HTMLPurifier_Config::createDefault();
38  $config->set('HTML.DefinitionID', $this->getPurifierType());
39  $config->set('HTML.DefinitionRev', 1);
40  $config->set('Cache.SerializerPath', ilHtmlPurifierAbstractLibWrapper::_getCacheDirectory());
41  $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
42  $config->set('HTML.AllowedElements', $this->getAllowedElements());
43  $config->set('HTML.ForbiddenAttributes', 'div@style');
44  $config->autoFinalize = false;
45  $config->set(
46  'URI.AllowedSchemes',
47  array_merge(
48  $config->get('URI.AllowedSchemes'),
49  ['data' => true]
50  )
51  );
52  $config->autoFinalize = true;
53  if ($def = $config->maybeGetRawHTMLDefinition()) {
54  $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
55  }
56 
57  return $config;
58  }
59 
60  private function getAllowedElements(): array
61  {
62  $allowedElements = $this->getElementsUsedForAdvancedEditing();
63 
64  $allowedElements = $this->makeElementListTinyMceCompliant($allowedElements);
65  $allowedElements = $this->removeUnsupportedElements($allowedElements);
66 
67  return $allowedElements;
68  }
69 
70  private function getElementsUsedForAdvancedEditing(): array
71  {
72  include_once 'Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php';
74  }
75 }
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.
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.