config()->editor_config; if($editorConfig) return HtmlEditorConfig::get($editorConfig); return HtmlEditorConfig::get_active(); } /** * Safely sanitise html content, if enabled * * @param string $content Raw html * @return string Safely sanitised html */ protected function sanitiseContent($content) { // Check if sanitisation is enabled if(!HtmlEditorField::config()->sanitise_server_side) return $content; // Perform sanitisation $htmlValue = Injector::inst()->create('HTMLValue', $content); $santiser = Injector::inst()->create('HtmlEditorSanitiser', $this->getEditorConfig()); $santiser->sanitise($htmlValue); return $htmlValue->getContent(); } /** * Get HTML Content of this literal field * * @return string */ public function getContent() { // Apply html editor sanitisation rules $content = $this->getSetting('Content'); return $this->sanitiseContent($content); } /** * Set the content with the given value * * @param string $content */ public function setContent($content) { // Apply html editor sanitisation rules $content = $this->sanitiseContent($content); $this->setSetting('Content', $content); } public function getFieldConfiguration() { $textAreaField = new HTMLEditorField( $this->getSettingName('Content'), "HTML", $this->getContent() ); $textAreaField->setRows(4); $textAreaField->setColumns(20); return new FieldList( $textAreaField, new CheckboxField( $this->getSettingName('HideFromReports'), _t('EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?'), $this->getSetting('HideFromReports') ) ); } public function getFormField() { $label = $this->Title ? "":""; $classes = $this->Title ? "" : " nolabel"; return new LiteralField("LiteralField[$this->ID]", "