From db25456f88865f2a89f7503a37d65f04b4aa3247 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Chauveau?= <jerome.chauveau@unicaen.fr>
Date: Wed, 17 Jan 2024 14:09:33 +0100
Subject: [PATCH] xsl file path built from plugin setting

---
 2html.xsl                             |  1 -
 XML2HTMLPlugin.php                    | 23 ++++++++++++++++++++---
 certic-jats2html.xsl => jats2html.xsl |  0
 3 files changed, 20 insertions(+), 4 deletions(-)
 delete mode 120000 2html.xsl
 rename certic-jats2html.xsl => jats2html.xsl (100%)

diff --git a/2html.xsl b/2html.xsl
deleted file mode 120000
index b49720f..0000000
--- a/2html.xsl
+++ /dev/null
@@ -1 +0,0 @@
-certic-jats2html.xsl
\ No newline at end of file
diff --git a/XML2HTMLPlugin.php b/XML2HTMLPlugin.php
index dc7b9b2..cc0c93c 100644
--- a/XML2HTMLPlugin.php
+++ b/XML2HTMLPlugin.php
@@ -64,9 +64,22 @@ class XML2HTMLPlugin extends GenericPlugin
         $html = file_get_contents($htmlFile);
         //make transfo only if html does not exist
         if(!$html) {
+            //get sources format from settings
+            $context = Application::get()
+                ->getRequest()
+                ->getContext();
+
+            $format = $this->getSetting(
+                $context->getId(),
+                'format'
+            );
+
+            if($format == NULL || $format == '')
+                $format = 'JATS';//default value is JATS
+
             $xmlFilePath = XML2HTMLPlugin::unzipXMLArchive($filePath);
             $html = $this->resolveZipImagePaths(
-                XML2HTMLPlugin::transform($xmlFilePath),
+                XML2HTMLPlugin::transform($xmlFilePath, $format),
                 $submissionId,
                 $galleyId,
                 $xmlFilePath, $this->getRequest(),
@@ -183,11 +196,15 @@ class XML2HTMLPlugin extends GenericPlugin
     }
 
     static function transform(
-        string $xmlFilePath
+        string $xmlFilePath,
+        string $format
     )
     {
+
+
+        $xslFileName = strtolower($format) . '2html.xsl';
         ////// xslt transfo
-        $xsltPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '2html.xsl';
+        $xsltPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . $xslFileName;
         // Load the XML source
         $xml = new DOMDocument;
         $xml->load($xmlFilePath);
diff --git a/certic-jats2html.xsl b/jats2html.xsl
similarity index 100%
rename from certic-jats2html.xsl
rename to jats2html.xsl
-- 
GitLab