ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAssHtmlPurifier.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Html/classes/class.ilHtmlPurifierAbstractLibWrapper.php';
5 
13 {
14  protected function getPurifierType()
15  {
16  return 'assessment';
17  }
18 
22  protected function getPurifierConfigInstance() : HTMLPurifier_Config
23  {
24  $config = HTMLPurifier_Config::createDefault();
25  $config->set('HTML.DefinitionID', $this->getPurifierType());
26  $config->set('HTML.DefinitionRev', 1);
27  $config->set('Cache.SerializerPath', ilHtmlPurifierAbstractLibWrapper::_getCacheDirectory());
28  $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
29  $config->set('HTML.AllowedElements', $this->getAllowedElements());
30  $config->set('HTML.ForbiddenAttributes', 'div@style');
31  $config->autoFinalize = false;
32  $config->set(
33  'URI.AllowedSchemes',
34  array_merge(
35  $config->get('URI.AllowedSchemes'),
36  ['data' => true]
37  )
38  );
39  $config->autoFinalize = true;
40  if ($def = $config->maybeGetRawHTMLDefinition()) {
41  $def->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
42  }
43 
44  return $config;
45  }
46 
47  private function getAllowedElements()
48  {
49  $allowedElements = $this->getElementsUsedForAdvancedEditing();
50 
51  $allowedElements = $this->makeElementListTinyMceCompliant($allowedElements);
52  $allowedElements = $this->removeUnsupportedElements($allowedElements);
53 
54  return $allowedElements;
55  }
56 
58  {
59  include_once 'Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php';
61  }
62 }
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
removeUnsupportedElements(array $elements)
Removes all unsupported elements.
Abstract class wrapping the HTMLPurifier instance.