Skip to content

Commit 0c69efd

Browse files
Internal: Ensure text/html MIME for HTML docs created from learnpath
1 parent cfbecb4 commit 0c69efd

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

public/main/lp/learnpath.class.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5110,6 +5110,11 @@ public function create_document(
51105110
);
51115111
}
51125112

5113+
$ext = strtolower((string) $extension);
5114+
if (in_array($ext, ['html','htm'], true)) {
5115+
$docFiletype = 'html';
5116+
}
5117+
51135118
$document = DocumentManager::addDocument(
51145119
$courseInfo,
51155120
null,
@@ -5127,6 +5132,19 @@ public function create_document(
51275132
$parentId
51285133
);
51295134

5135+
if ($document && in_array($ext, ['html','htm'], true)) {
5136+
$em = Database::getManager();
5137+
$docRepo = Container::getDocumentRepository();
5138+
$docEntity = $docRepo->find($document->getIid());
5139+
if ($docEntity && $docEntity->hasResourceNode()) {
5140+
$rf = $docEntity->getResourceNode()->getResourceFiles()->first();
5141+
if ($rf && $rf->getMimeType() !== 'text/html') {
5142+
$rf->setMimeType('text/html');
5143+
$em->flush();
5144+
}
5145+
}
5146+
}
5147+
51305148
$document_id = $document->getIid();
51315149
if ($document_id) {
51325150
$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';

public/main/lp/lp_controller.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
}
175175

176176
$__returnTo = $_GET['returnTo'] ?? '';
177-
$__listUrlForSpa = $listUrl; // el de resources/lp/...
177+
$__listUrlForSpa = $listUrl;
178178
$goList = static function () use ($__listUrlForSpa, $__returnTo) {
179179
header('Location: '.$__listUrlForSpa);
180180
exit;
@@ -589,7 +589,10 @@
589589
$goList();
590590
} else {
591591
Session::write('refresh', 1);
592-
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($oLP->lp_id).'&'.api_get_cidreq();
592+
$url = api_get_self()
593+
.'?action=add_item&type=step&lp_id='.intval($oLP->lp_id)
594+
.'&'.api_get_cidreq()
595+
.'&isStudentView=false';
593596
header('Location: '.$url);
594597
exit;
595598
}

0 commit comments

Comments
 (0)