Loading XML2HTMLPlugin.php +29 −10 Changes for XML2HTMLPlugin.php: 29 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -28,11 +28,6 @@ class XML2HTMLPlugin extends GenericPlugin return $success; } // public function articleDownloadHandler($hookName, $params) // { // // } /** * @throws Exception */ Loading Loading @@ -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), Loading @@ -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 Loading Loading @@ -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 Loading @@ -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; Loading Loading
XML2HTMLPlugin.php +29 −10 Changes for XML2HTMLPlugin.php: 29 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -28,11 +28,6 @@ class XML2HTMLPlugin extends GenericPlugin return $success; } // public function articleDownloadHandler($hookName, $params) // { // // } /** * @throws Exception */ Loading Loading @@ -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), Loading @@ -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 Loading Loading @@ -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 Loading @@ -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; Loading