From 6d82a9e7df907ce58addf5100bde00566a193c43 Mon Sep 17 00:00:00 2001 From: christianbeeznst Date: Wed, 24 Apr 2024 14:44:52 -0500 Subject: [PATCH] Internal: Disable full-page mode in BaseTinyEditor for intro forms - refs BT#21569 --- assets/vue/components/ctoolintro/Form.vue | 1 + .../Controller/CourseController.php | 30 +------------------ 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/assets/vue/components/ctoolintro/Form.vue b/assets/vue/components/ctoolintro/Form.vue index 9337c7423c..ed43da97ee 100644 --- a/assets/vue/components/ctoolintro/Form.vue +++ b/assets/vue/components/ctoolintro/Form.vue @@ -3,6 +3,7 @@ diff --git a/src/CoreBundle/Controller/CourseController.php b/src/CoreBundle/Controller/CourseController.php index d8d8cc2e3f..a83cc7ecb4 100644 --- a/src/CoreBundle/Controller/CourseController.php +++ b/src/CoreBundle/Controller/CourseController.php @@ -579,12 +579,9 @@ class CourseController extends ToolBaseController /** @var CToolIntro $ctoolintro */ $ctoolintro = $ctoolintroRepo->findOneBy(['courseTool' => $ctool]); if ($ctoolintro) { - $introText = $ctoolintro->getIntroText(); - $cleanedHtml = $this->processHtmlContent($introText); - $responseData = [ 'iid' => $ctoolintro->getIid(), - 'introText' => $cleanedHtml, + 'introText' => $ctoolintro->getIntroText(), 'createInSession' => $createInSession, 'cToolId' => $ctool->getIid(), ]; @@ -975,29 +972,4 @@ class CourseController extends ToolBaseController return $enrollmentCount > 0; } - - private function processHtmlContent($htmlText): array|string|null - { - $doc = new \DOMDocument(); - libxml_use_internal_errors(true); - $doc->loadHTML(mb_convert_encoding($htmlText, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); - libxml_clear_errors(); - - // Extract everything inside the element, if present, or fallback to the document itself - $htmlContent = ''; - $html = $doc->getElementsByTagName('html')->item(0); - if ($html) { - foreach ($html->childNodes as $child) { - $htmlContent .= $doc->saveHTML($child); - } - } else { - $htmlContent = $doc->saveHTML($doc->documentElement); - } - - // Remove , , and tags manually - $htmlContent = preg_replace('/<\/?(html|head|body)[^>]*>/i', '', $htmlContent); - - return $htmlContent; - } - }