Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xml2html-pkp-plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FNSO
FAIREST
xml2html-pkp-plugin
Commits
9fcde7fc
Commit
9fcde7fc
authored
Dec 14, 2023
by
Jerome Chauveau
Browse files
Options
Downloads
Patches
Plain Diff
store HTML result on FS.
#2
parent
bc7138d2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
XML2HTMLPlugin.php
+35
-16
35 additions, 16 deletions
XML2HTMLPlugin.php
with
35 additions
and
16 deletions
XML2HTMLPlugin.php
+
35
−
16
View file @
9fcde7fc
...
...
@@ -28,11 +28,6 @@ class XML2HTMLPlugin extends GenericPlugin
return
$success
;
}
// public function articleDownloadHandler($hookName, $params)
// {
//
// }
/**
* @throws Exception
*/
...
...
@@ -65,7 +60,10 @@ class XML2HTMLPlugin extends GenericPlugin
private
function
archiveView
(
string
$filePath
,
int
$submissionId
,
int
$galleyId
,
string
$op
)
{
$templateMgr
=
TemplateManager
::
getManager
(
$this
->
getRequest
());
$htmlFile
=
XML2HTMLPlugin
::
getHTMLPathFromZipPath
(
$filePath
);
$html
=
file_get_contents
(
$htmlFile
);
//make transfo only if html does not exist
if
(
!
$html
)
{
$xmlFilePath
=
XML2HTMLPlugin
::
unzipXMLArchive
(
$filePath
);
$html
=
$this
->
resolveZipImagePaths
(
XML2HTMLPlugin
::
transform
(
$xmlFilePath
),
...
...
@@ -73,14 +71,31 @@ class XML2HTMLPlugin extends GenericPlugin
$galleyId
,
$xmlFilePath
,
$this
->
getRequest
(),
$op
);
$baseUrl
=
$this
->
getRequest
()
->
getBaseUrl
()
.
'/'
.
$this
->
getPluginPath
();
// $templateMgr->addStyleSheet('xml2htmlStyles', $baseUrl . '/resources/styles/xml_2_html.css');
// $templateMgr->addJavaScript('xml2htmlJavascript', $baseUrl . '/resources/javascript/xml_2_html.js');
//store transfo result
file_put_contents
(
$htmlFile
,
$html
,
LOCK_EX
);
}
$templateMgr
=
TemplateManager
::
getManager
(
$this
->
getRequest
());
$templateMgr
->
assign
(
'assetsPath'
,
$this
->
getPluginAssetsPath
(
$this
->
getRequest
()));
$templateMgr
->
assign
(
'text'
,
$html
);
$templateMgr
->
display
(
$this
->
getTemplateResource
(
'HTMLGalleyView.tpl'
));
}
/**
* get HTML file path from its zip one
* exemple : a/b/c/1234.zip -> ojs/files/dir/a/b/c/1234/1234.html
* @param $zipPath
* @return string
*/
private
static
function
getHTMLPathFromZipPath
(
$zipPath
){
$fileMgr
=
new
PrivateFileManager
();
$filesDir
=
$fileMgr
->
getBasePath
()
.
DIRECTORY_SEPARATOR
;
$fullZipPath
=
$filesDir
.
$zipPath
;
$fullPrefixPath
=
str_replace
(
'.zip'
,
''
,
$fullZipPath
);
$pathInfo
=
pathinfo
(
$fullZipPath
);
$zipName
=
$pathInfo
[
'filename'
];
return
str_replace
(
$pathInfo
[
'filename'
],
$zipName
.
DIRECTORY_SEPARATOR
.
$zipName
.
'.html'
,
$fullPrefixPath
);
}
/**
* Provide a name for this plugin
...
...
@@ -112,6 +127,10 @@ class XML2HTMLPlugin extends GenericPlugin
string
$xmlFilePath
)
{
// $xml = simplexml_load_file($xmlFilePath);
// var_dump($xml->getName());
////// xslt transfo
$xsltPath
=
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'2html.xsl'
;
// Load the XML source
...
...
@@ -119,7 +138,7 @@ class XML2HTMLPlugin extends GenericPlugin
$xml
->
load
(
$xmlFilePath
);
$xsl
=
new
DOMDocument
;
$xsl
->
load
(
$xsltPath
);
$xsl
->
load
(
$xsltPath
,
LIBXML_DTDATTR
);
// Configure the transformer
$proc
=
new
XSLTProcessor
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment