From 1e732730486b2a8a8cc9e285c44bae376ee2f410 Mon Sep 17 00:00:00 2001 From: Nate Wright Date: Tue, 10 Dec 2024 16:21:53 +0000 Subject: [PATCH] pkp/pkp-lib#10675 Fix: scripts and inline styles don't work in HTML galleys --- classes/template/PKPTemplateManager.inc.php | 27 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/classes/template/PKPTemplateManager.inc.php b/classes/template/PKPTemplateManager.inc.php index e0f18445ce1..f146e0a1f98 100644 --- a/classes/template/PKPTemplateManager.inc.php +++ b/classes/template/PKPTemplateManager.inc.php @@ -1988,19 +1988,40 @@ function loadHtmlGalleyStyles($htmlContent, $embeddedFiles) { return $htmlContent; } - $links = ''; $styles = $this->getResourcesByContext($this->_styleSheets, 'htmlGalley'); if (!empty($styles)) { ksort($styles); + $links = ''; foreach ($styles as $priorityGroup) { foreach ($priorityGroup as $htmlStyle) { - $links .= '' . "\n"; + $links .= !empty($htmlStyle['inline']) + ? '' + : ''; + $links .= "\n"; } } + $htmlContent = str_ireplace('', '' . "\n" . $links, $htmlContent); } - return str_ireplace('', '' . "\n" . $links, $htmlContent); + + $scripts = $this->getResourcesByContext($this->_javaScripts, 'htmlGalley'); + + if (!empty($scripts)) { + $links = ''; + ksort($scripts); + foreach ($scripts as $priorityGroup) { + foreach ($priorityGroup as $script) { + $links .= !empty($script['inline']) + ? '' + : ''; + $links .= "\n"; + } + } + $htmlContent = str_ireplace('', $links . "\n", $htmlContent); + } + + return $htmlContent; } /**