Skip to content
Snippets Groups Projects
Commit ae44eee2 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

nettoyage

parent aef8c04c
No related branches found
No related tags found
No related merge requests found
...@@ -19,15 +19,8 @@ class XML2HTMLPlugin extends GenericPlugin ...@@ -19,15 +19,8 @@ class XML2HTMLPlugin extends GenericPlugin
if ($success && $this->getEnabled()) { if ($success && $this->getEnabled()) {
HookRegistry::register('ArticleHandler::view::galley', array($this, 'articleHandler')); HookRegistry::register('ArticleHandler::view::galley', array($this, 'articleHandler'));
HookRegistry::register('ArticleHandler::download', array($this, 'articleDownloadCallback'), HOOK_SEQUENCE_LATE); //HookRegistry::register('ArticleHandler::download', array($this, 'articleDownloadCallback'), HOOK_SEQUENCE_LATE);
// HookRegistry::register('Templates::Article::Main', array($this, 'xml2html'));
// HookRegistry::register('TemplateManager::display', array($this, 'xml2htmlImports'));
HookRegistry::register('LoadHandler', array($this, 'loadImageHandler')); HookRegistry::register('LoadHandler', array($this, 'loadImageHandler'));
// HookRegistry::register('SubmissionFile::add', array($this, 'uploadHandler'));
// HookRegistry::register('LoadHandler', array($this, 'setPageHandler'));
//HookRegistry::register('LoadHandler', array($this, 'setPageHandler'));
HookRegistry::register('CatalogBookHandler::view', array($this, 'catalogHandler')); HookRegistry::register('CatalogBookHandler::view', array($this, 'catalogHandler'));
} }
...@@ -35,37 +28,27 @@ class XML2HTMLPlugin extends GenericPlugin ...@@ -35,37 +28,27 @@ class XML2HTMLPlugin extends GenericPlugin
return $success; return $success;
} }
public function articleDownloadHandler($hookName, $params) // public function articleDownloadHandler($hookName, $params)
{ // {
//
} // }
/** /**
* @throws Exception * @throws Exception
*/ */
public function articleHandler($hookName, $params) public function articleHandler($hookName, $params): bool
{ {
$request =& $params[0];
$galley =& $params[2]; $galley =& $params[2];
$submission = &$params[3]; $submission = &$params[3];
$templateMgr = TemplateManager::getManager($request);
//handle only on zip galleys - supposed to be an xml archive (source + images) //handle only on zip galleys - supposed to be an xml archive (source + images)
$zipMode = $galley && $galley->getFileType() === 'application/zip'; $zipMode = $galley && $galley->getFileType() === 'application/zip';
if ($zipMode) { if ($zipMode) {
$this->archiveView($galley->getFile()->getData('path'), $submission->getId(), 'article'); $this->archiveView($galley->getFile()->getData('path'), $submission->getId(), 'article');
// $filePath = $galley->getFile()->getData('path');
// $xmlFilePath = XML2HTMLPlugin::unzipXMLArchive($filePath);
// $html = $this->resolveZipImagePaths(XML2HTMLPlugin::transform($xmlFilePath), $submission->getId(), $xmlFilePath, $this->getRequest());
// $baseUrl = $request->getBaseUrl() . '/' . $this->getPluginPath();
// $templateMgr->addStyleSheet('xml2htmlStyles', $baseUrl . '/resources/styles/article.css');
// $templateMgr->addJavaScript('xml2htmlJavascript', $baseUrl . '/resources/javascript/xml_2_html.js');
// $templateMgr->assign('text', $html);
// $templateMgr->display($this->getTemplateResource('HTMLGalleyView.tpl'));
return true; return true;
} else return false; } else return false;
} }
public function catalogHandler($hookName, $params) public function catalogHandler($hookName, $params): bool
{ {
$submission = &$params[1]; $submission = &$params[1];
...@@ -79,7 +62,8 @@ class XML2HTMLPlugin extends GenericPlugin ...@@ -79,7 +62,8 @@ class XML2HTMLPlugin extends GenericPlugin
} }
private function archiveView(string $filePath, int $submissionId, string $op){ private function archiveView(string $filePath, int $submissionId, string $op)
{
$templateMgr = TemplateManager::getManager($this->getRequest()); $templateMgr = TemplateManager::getManager($this->getRequest());
$xmlFilePath = XML2HTMLPlugin::unzipXMLArchive($filePath); $xmlFilePath = XML2HTMLPlugin::unzipXMLArchive($filePath);
$html = $this->resolveZipImagePaths( $html = $this->resolveZipImagePaths(
...@@ -118,7 +102,6 @@ class XML2HTMLPlugin extends GenericPlugin ...@@ -118,7 +102,6 @@ class XML2HTMLPlugin extends GenericPlugin
} }
static function transform( static function transform(
string $xmlFilePath string $xmlFilePath
) )
...@@ -140,7 +123,6 @@ class XML2HTMLPlugin extends GenericPlugin ...@@ -140,7 +123,6 @@ class XML2HTMLPlugin extends GenericPlugin
} }
static function unzipXMLArchive(string $path) static function unzipXMLArchive(string $path)
{ {
$fileManager = new FileManager(); $fileManager = new FileManager();
...@@ -282,8 +264,6 @@ class XML2HTMLPlugin extends GenericPlugin ...@@ -282,8 +264,6 @@ class XML2HTMLPlugin extends GenericPlugin
$file $file
) )
); );
$pattern = preg_quote(rawurlencode($file)); $pattern = preg_quote(rawurlencode($file));
$htmlString = preg_replace( $htmlString = preg_replace(
'/([Ss][Rr][Cc]|[Hh][Rr][Ee][Ff]|[Dd][Aa][Tt][Aa])\s*=\s*"([^"]*' . $pattern . ')"/', '/([Ss][Rr][Cc]|[Hh][Rr][Ee][Ff]|[Dd][Aa][Tt][Aa])\s*=\s*"([^"]*' . $pattern . ')"/',
...@@ -295,6 +275,5 @@ class XML2HTMLPlugin extends GenericPlugin ...@@ -295,6 +275,5 @@ class XML2HTMLPlugin extends GenericPlugin
return $htmlString; return $htmlString;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment