Commit ae44eee2 authored by Jérôme Chauveau's avatar Jérôme Chauveau
Browse files

nettoyage

parent aef8c04c
Loading
Loading
Loading
Loading
+9 −30
Changes for XML2HTMLPlugin.php: 9 added lines, 30 removed lines.
Original line number Diff line number Diff line
@@ -19,15 +19,8 @@ class XML2HTMLPlugin extends GenericPlugin

        if ($success && $this->getEnabled()) {
            HookRegistry::register('ArticleHandler::view::galley', array($this, 'articleHandler'));
            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('ArticleHandler::download', array($this, 'articleDownloadCallback'), HOOK_SEQUENCE_LATE);
            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'));

        }
@@ -35,37 +28,27 @@ class XML2HTMLPlugin extends GenericPlugin
        return $success;
    }

    public function articleDownloadHandler($hookName, $params)
    {

    }
//    public function articleDownloadHandler($hookName, $params)
//    {
//
//    }

    /**
     * @throws Exception
     */
    public function articleHandler($hookName, $params)
    public function articleHandler($hookName, $params): bool
    {
        $request =& $params[0];
        $galley =& $params[2];
        $submission = &$params[3];
        $templateMgr = TemplateManager::getManager($request);
        //handle only on zip galleys - supposed to be an xml archive (source + images)
        $zipMode = $galley && $galley->getFileType() === 'application/zip';
        if ($zipMode) {
            $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;
        } else return false;
    }

    public function catalogHandler($hookName, $params)
    public function catalogHandler($hookName, $params): bool
    {

        $submission = &$params[1];
@@ -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());
        $xmlFilePath = XML2HTMLPlugin::unzipXMLArchive($filePath);
        $html = $this->resolveZipImagePaths(
@@ -118,7 +102,6 @@ class XML2HTMLPlugin extends GenericPlugin
    }



    static function transform(
        string $xmlFilePath
    )
@@ -140,7 +123,6 @@ class XML2HTMLPlugin extends GenericPlugin
    }



    static function unzipXMLArchive(string $path)
    {
        $fileManager = new FileManager();
@@ -282,8 +264,6 @@ class XML2HTMLPlugin extends GenericPlugin
                        $file
                    )
                );


                $pattern = preg_quote(rawurlencode($file));
                $htmlString = preg_replace(
                    '/([Ss][Rr][Cc]|[Hh][Rr][Ee][Ff]|[Dd][Aa][Tt][Aa])\s*=\s*"([^"]*' . $pattern . ')"/',
@@ -295,6 +275,5 @@ class XML2HTMLPlugin extends GenericPlugin
        return $htmlString;
    }


}