Loading XML2HTMLPlugin.php +33 −9 Changes for XML2HTMLPlugin.php: 33 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -99,7 +99,8 @@ class XML2HTMLPlugin extends GenericPlugin * @param $zipPath * @return string */ private static function getHTMLPathFromZipPath($zipPath){ private static function getHTMLPathFromZipPath($zipPath) { $fileMgr = new PrivateFileManager(); $filesDir = $fileMgr->getBasePath() . DIRECTORY_SEPARATOR; $fullZipPath = $filesDir . $zipPath; Loading Loading @@ -137,7 +138,8 @@ class XML2HTMLPlugin extends GenericPlugin * @param $verb * @return mixed */ public function getActions($request, $verb) { public function getActions($request, $verb) { $router = $request->getRouter(); import('lib.pkp.classes.linkAction.request.AjaxModal'); return array_merge( Loading Loading @@ -191,7 +193,8 @@ class XML2HTMLPlugin extends GenericPlugin } function getPluginAssetsPath($request) { function getPluginAssetsPath($request) { return $request->getBaseUrl() . '/' . $this->getPluginPath() . '/resources/'; } Loading Loading @@ -222,6 +225,11 @@ class XML2HTMLPlugin extends GenericPlugin } /** * @param string $path * @return string|void|null * @throws Exception */ static function unzipXMLArchive(string $path) { $fileManager = new FileManager(); Loading @@ -238,12 +246,20 @@ class XML2HTMLPlugin extends GenericPlugin } if ($zip->open($zipPath) === TRUE) { $archiveFolderName = NULL; if ($zip->numFiles > 0) {//gets zip top folder name $archiveFolderName = $zip->getNameIndex(0); } else { throw new \Exception("Bad zip Submission file."); } $nbFiles = $zip->numFiles; if ($nbFiles > 0) { //a zipped file if ($nbFiles == 1 && str_ends_with($zip->getNameIndex(0), '.xml')) { $basePath = $zipPathParts['dirname'] . DIRECTORY_SEPARATOR . $zipPathParts['filename'] . '/'; $zip->extractTo($basePath); rename( $basePath . $zip->getNameIndex(0), $basePath . $zipPathParts['filename'] . '.xml' ); return $basePath . $zipPathParts['filename'] . '.xml'; } //a zipped folder else if (str_ends_with($zip->getNameIndex(0), '/')) { $archiveFolderName = $zip->getNameIndex(0); //gets root folder name $zip->extractTo($zipPathParts['dirname']); rename( $zipPathParts['dirname'] . DIRECTORY_SEPARATOR . $archiveFolderName, Loading @@ -263,6 +279,14 @@ class XML2HTMLPlugin extends GenericPlugin } } } else { throw new \Exception("Bad zip Submission file."); } } else { throw new \Exception("Bad zip Submission file."); } } else { return NULL; } Loading Loading
XML2HTMLPlugin.php +33 −9 Changes for XML2HTMLPlugin.php: 33 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -99,7 +99,8 @@ class XML2HTMLPlugin extends GenericPlugin * @param $zipPath * @return string */ private static function getHTMLPathFromZipPath($zipPath){ private static function getHTMLPathFromZipPath($zipPath) { $fileMgr = new PrivateFileManager(); $filesDir = $fileMgr->getBasePath() . DIRECTORY_SEPARATOR; $fullZipPath = $filesDir . $zipPath; Loading Loading @@ -137,7 +138,8 @@ class XML2HTMLPlugin extends GenericPlugin * @param $verb * @return mixed */ public function getActions($request, $verb) { public function getActions($request, $verb) { $router = $request->getRouter(); import('lib.pkp.classes.linkAction.request.AjaxModal'); return array_merge( Loading Loading @@ -191,7 +193,8 @@ class XML2HTMLPlugin extends GenericPlugin } function getPluginAssetsPath($request) { function getPluginAssetsPath($request) { return $request->getBaseUrl() . '/' . $this->getPluginPath() . '/resources/'; } Loading Loading @@ -222,6 +225,11 @@ class XML2HTMLPlugin extends GenericPlugin } /** * @param string $path * @return string|void|null * @throws Exception */ static function unzipXMLArchive(string $path) { $fileManager = new FileManager(); Loading @@ -238,12 +246,20 @@ class XML2HTMLPlugin extends GenericPlugin } if ($zip->open($zipPath) === TRUE) { $archiveFolderName = NULL; if ($zip->numFiles > 0) {//gets zip top folder name $archiveFolderName = $zip->getNameIndex(0); } else { throw new \Exception("Bad zip Submission file."); } $nbFiles = $zip->numFiles; if ($nbFiles > 0) { //a zipped file if ($nbFiles == 1 && str_ends_with($zip->getNameIndex(0), '.xml')) { $basePath = $zipPathParts['dirname'] . DIRECTORY_SEPARATOR . $zipPathParts['filename'] . '/'; $zip->extractTo($basePath); rename( $basePath . $zip->getNameIndex(0), $basePath . $zipPathParts['filename'] . '.xml' ); return $basePath . $zipPathParts['filename'] . '.xml'; } //a zipped folder else if (str_ends_with($zip->getNameIndex(0), '/')) { $archiveFolderName = $zip->getNameIndex(0); //gets root folder name $zip->extractTo($zipPathParts['dirname']); rename( $zipPathParts['dirname'] . DIRECTORY_SEPARATOR . $archiveFolderName, Loading @@ -263,6 +279,14 @@ class XML2HTMLPlugin extends GenericPlugin } } } else { throw new \Exception("Bad zip Submission file."); } } else { throw new \Exception("Bad zip Submission file."); } } else { return NULL; } Loading