Commit 1822330f authored by Charles Bourdot's avatar Charles Bourdot
Browse files

Correctifs variés

parent 0c0bcb5c
Loading
Loading
Loading
Loading
+12 −2
Changes for BookImageDataHandler.inc.php: 12 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -28,10 +28,15 @@ class BookImageDataHandler extends Handler
     */
    public function zimage(array $args, Request $request)
    {
        $submissionId = (int)$args[0];
        $pubId = $args[1];
        $imgName = $args[2];
        $submission = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_SUBMISSION);

        $submission = Repo::submission()->get($submissionId);
        if (!$submission) {
            header('HTTP/1.0 404 Not Found');
            exit;
        }

        $pubFormatFiles = Repo::submissionFile()
            ->getCollector()
@@ -41,11 +46,16 @@ class BookImageDataHandler extends Handler

        $publicationFile = NULL;
        foreach ($pubFormatFiles as $file){
            if($file->getData('assocId') == $pubId) {
            if($file->getBestId() == $pubId) {
                $publicationFile = $file;
            }
        }

        if (!$publicationFile) {
            header('HTTP/1.0 404 Not Found');
            exit;
        }

        $pathInfo = pathinfo($publicationFile->getData('path'));
        $imagePath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $pathInfo['filename'] . DIRECTORY_SEPARATOR . $imgName;
        ImageUtils::downloadImage($this->fs, $imagePath, $imgName);
+67 −6
Changes for XML2HTMLPlugin.php: 67 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ require_once(__DIR__ . '/BookImageDataHandler.inc.php');

use APP\core\Application;
use APP\core\Request;
use APP\facades\Repo;
use APP\plugins\generic\xml2html\ArticleImageDataHandler;
use APP\template\TemplateManager;
use PKP\core\JSONMessage;
@@ -37,7 +38,7 @@ class XML2HTMLPlugin extends GenericPlugin
        $context = Application::get()->getRequest()->getContext();
        $landingEnabled = false;
            if ($context) {
                $landingEnabled = $this->getSetting($context->getId(), 'enableLandingPage');
                $landingEnabled = $this->getSetting($context->getId(), 'landingpage');
            }

        if ($success && $this->getEnabled()) {
@@ -45,6 +46,7 @@ class XML2HTMLPlugin extends GenericPlugin
            
            if ($landingEnabled) {
                Hook::add('ArticleHandler::view', array($this, 'landingPageHandler'));
                Hook::add('CatalogBookHandler::book', array($this, 'landingPageHandlerOMP'));
            }

            Hook::add('CatalogBookHandler::view', array($this, 'catalogHandler'));
@@ -120,6 +122,56 @@ class XML2HTMLPlugin extends GenericPlugin
        }
    }

    public function landingPageHandlerOMP($hookName, $params): bool
    {
        $submission =& $params[1];
        $chapter =& $params[3];

        try {
            $submissionFile = $this->getBookFullTextFile($submission, $chapter);
            if (!$submissionFile) {
                return false;
            }

            $this->landingPageView(
                $submissionFile->getData('path'),
                $submission->getId(),
                $submissionFile->getBestId(),
                'catalog',
                'LandingPageBook.tpl'
            );
            return true;

        } catch (\Exception $e) {
            error_log('XML2HTMLPlugin error: ' . $e->getMessage());
            return false;
        }
    }

    private function getBookFullTextFile($submission, $chapter)
    {
        $pubFormatFiles = Repo::submissionFile()
            ->getCollector()
            ->filterBySubmissionIds([$submission->getId()])
            ->filterByAssoc(Application::ASSOC_TYPE_PUBLICATION_FORMAT)
            ->getMany();

        foreach ($pubFormatFiles as $file) {
            if ($file->getData('mimetype') !== 'application/zip') {
                continue;
            }
            $fileChapterId = $file->getData('chapterId');
            if ($chapter) {
                if ($fileChapterId == $chapter->getId()) {
                    return $file;
                }
            } elseif (!$fileChapterId) {
                return $file;
            }
        }
        return null;
    }


    public function catalogHandler($hookName, $params): bool
    {
@@ -129,7 +181,7 @@ class XML2HTMLPlugin extends GenericPlugin
        $submissionFile =& $params[3];
        $zipMode = $submissionFile->getData('mimetype') === "application/zip";
        if ($zipMode) {
            $this->archiveView($submissionFile->getData('path'), $submission->getId(), $galley->getId(), 'catalog');
            $this->archiveView($submissionFile->getData('path'), $submission->getId(), $submissionFile->getBestId(), 'catalog');
            return true;
        } else
            return false;
@@ -165,6 +217,7 @@ class XML2HTMLPlugin extends GenericPlugin
            //store transfo result
            file_put_contents($htmlFile, $html, LOCK_EX);
        }
        $submission = Repo::submission()->get($submissionId);
        $templateMgr = TemplateManager::getManager($this->getRequest());
        $templateMgr->assign('assetsPath', $this->getPluginAssetsPath($this->getRequest()));
        $templateMgr->assign('source', $html);
@@ -172,10 +225,12 @@ class XML2HTMLPlugin extends GenericPlugin
        $templateMgr->assign('cssLandingPageUrl', $this->getCssFileUrl($this->getRequest(), 'cssLandingPageFile'));
        $templateMgr->assign('cssSideViewUrl', $this->getCssFileUrl($this->getRequest(), 'cssSideViewFile'));
        $templateMgr->assign('metadataUrl', $this->getMetadataUrl($submissionId, $op));
        $templateMgr->assign('breadcrumbOp', $op);
        $templateMgr->assign('currentTitle', $submission ? $submission->getCurrentPublication()->getLocalizedFullTitle() : '');
        $templateMgr->display($this->getTemplateResource('HTMLGalleyView.tpl'));
    }

    private function landingPageView(string $filePath, int $submissionId, int $galleyId, string $op)
    private function landingPageView(string $filePath, int $submissionId, int $galleyId, string $op, string $template = 'LandingPage.tpl')
    {
        $htmlFile = XML2HTMLPlugin::getHTMLPathFromZipPath($filePath);
        $html = file_get_contents($htmlFile);
@@ -213,16 +268,22 @@ class XML2HTMLPlugin extends GenericPlugin
        $templateMgr->assign('text', $html);
        $templateMgr->assign('cssLandingPageUrl', $this->getCssFileUrl($this->getRequest(), 'cssLandingPageFile'));
        $templateMgr->assign('cssSideViewUrl', $this->getCssFileUrl($this->getRequest(), 'cssSideViewFile'));
        $templateMgr->display($this->getTemplateResource('LandingPage.tpl'));
        $templateMgr->display($this->getTemplateResource($template));
        exit;

    }

    /**
     * @brief Build the URL back to the submission's metadata page, used by
     * the close/back button on the full-text reading (side) view.
     */
    private function getMetadataUrl(int $submissionId, string $op): string
    {
        $request = $this->getRequest();
        $page = $op === 'catalog' ? 'catalog' : 'article';
        return $request->url(null, $page, 'view', [$submissionId]);
        if ($op === 'catalog') {
            return $request->url(null, 'catalog', 'book', [$submissionId]);
        }
        return $request->url(null, 'article', 'view', [$submissionId]);
    }

    /**
+52 −10
Changes for resources/javascript/xml_2_html.js: 52 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -257,6 +257,10 @@ window.addEventListener('DOMContentLoaded', (event) => {
    // Appel fonction pour les indicateurs de scrollbar biblio
    initBibScrollIndicators();

    initializeIndexLinks();
    bindIndexToggleButtons();
    hideHtmlDownloadLinks();

    //toc hightlighing on scroll
    document.querySelector('.left-contents').addEventListener("scroll", () => {
        let scrollTop = document.querySelector('.left-contents').scrollTop;
@@ -495,7 +499,29 @@ function initialiseTableaux() {
/////////////////////////////////////////////////////////////
//////    Fonctions pour les index (collapsible)   [EC]   ///
/////////////////////////////////////////////////////////////
function toggleIndexItem(li) {
function initializeIndexLinks() {
  var indexSection = document.getElementById('index');
  if (!indexSection) return;

  indexSection.querySelectorAll('a[href^="#"]').forEach(function (link) {
    link.addEventListener('click', function (e) {
      var targetId = this.getAttribute('href').substring(1);
      var target = document.getElementById(targetId);
      if (!target) return;

      e.preventDefault();

      var tabPanel = target.closest('.content-tab');
      if (tabPanel && tabPanel.id !== 'index') {
        openTab(tabPanel.id);
      }

      target.scrollIntoView({ block: 'center', behavior: 'smooth' });
    });
  });
}

function toggleIndexItem(li, event) {
    const subLists = li.querySelectorAll(':scope > .index-level2');
    if (!subLists.length) return;

@@ -506,8 +532,30 @@ function toggleIndexItem(li) {
        ul.style.display = isCollapsed ? 'block' : 'none';
    });

    // Empêcher la propagation si on clique sur un lien enfant
    event.stopPropagation();
    const toggleBtn = li.querySelector(':scope > .toggle-button');
    if (toggleBtn) {
        toggleBtn.textContent = isCollapsed ? ' [-]' : ' [+]';
    }

    if (event) event.stopPropagation();
}

function bindIndexToggleButtons() {
    document.querySelectorAll('.toggle-button').forEach(function (btn) {
        btn.addEventListener('click', function (e) {
            const li = this.closest('li');
            if (li) toggleIndexItem(li, e);
        });
    });
}

function hideHtmlDownloadLinks() {
    document.querySelectorAll('.cmp_download_link, .obj_galley_link, .remote_resource').forEach(function (link) {
        if (link.textContent.trim().toUpperCase().includes('HTML')) {
            const wrapper = link.closest('[class*="pub_format_"], li, .sub_item') || link;
            wrapper.style.display = 'none';
        }
    });
}


@@ -793,7 +841,7 @@ async function toggleBibliometrics() {
        <li>Vues HTML : ${data.htmlViews ?? 0}</li>
        <li>Vues PDF : ${data.pdfViews ?? 0}</li>
        <li>Autres téléchargements : ${data.otherViews ?? 0}</li>
        <li>Total galley : ${data.galleyViews ?? 0}</li>`;
        <li>Total des consultations : ${data.galleyViews ?? 0}</li>`;
    } catch (e) {}
  }

@@ -840,12 +888,6 @@ function closeGalleyIframe() {
  btn.classList.remove('active');
}

document.querySelectorAll('.galleys_links li').forEach(li => {
  if (li.textContent.trim() === 'HTML') {
    li.style.display = 'none';
  }
});

function openModal(url) {
  // Crée la modale si elle n'existe pas encore
  if (!document.getElementById('iframeModal')) {
+34 −8
Changes for resources/styles/landingpage.css: 34 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -1115,14 +1115,6 @@ body.dark .landingPage div[id^="footnotes"] .label {
    color: var(--third-color);
}

.landingPage .expanded .toggle-button::after {
    content: "[-]";
}

.landingPage .collapsed .toggle-button::after {
    content: "[+]";
}

body.dark .landingPage .journal-meta {
    background-color: var(--dark-bg-secondary);
}
@@ -1974,3 +1966,37 @@ body.dark .landingPage #refs li.bibl.focus {
    border-top: none !important;
    border-bottom: none !important;
}

.landingPage .left-contents figure header h1:not(div.boxed-text *) {
    margin-bottom: 0;
    padding-bottom: 0;
}

.landingPage figure > figure + figure {
    margin-top: 0em;
} 

.landingPage section.body figure[role="group"] figure + p:not(div.boxed-text *, .caption, .credits, .stage, details *, .front-matter *) {
    margin-top : -1em;
}

.landingPage .article-wrap figure > header h1 {
    display: revert;
}

div[id*="figures"] figure figcaption {
    text-align: left;
    align-self: flex-start;
}

.bib-scroll-marker {
    position: absolute;
    right: 0;
    width: 8px;
    height: 3px;
    background-color: var(--third-color);
    border-radius: 1px;
    cursor: pointer;
    pointer-events: auto;
}
+44 −9
Changes for resources/styles/xml_2_html.css: 44 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -1118,14 +1118,6 @@ div[id^="footnotes"] li .label:after {
    color: var(--third-color);
}

.expanded .toggle-button::after {
    content: "[-]";
}

.collapsed .toggle-button::after {
    content: "[+]";
}

body.dark .journal-meta {
    background-color: var(--dark-bg-secondary);
}
@@ -1342,16 +1334,22 @@ body.dark #drag-bar:hover {
    text-align: right;
}

a {
a,
span.fig-call {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

label span.fig-call {
    color: var(--text-primary);
}

a:hover {
    color: var(--primary-hover);
}


body.dark a {
    color: var(--accent-color);
}
@@ -1457,3 +1455,40 @@ div.idno {
.filter-bar {
  display: none;
}

.bib-scroll-marker {
  position: absolute;
  right: 0;
  width: 8px;
  height: 3px;
  background-color: var(--third-color);
  border-radius: 1px;
  cursor: pointer;
  pointer-events: auto;
}

pre {
    margin-top: var(--spacing-md);
}

code {
    font-size: 0.9rem;
}

.left-contents figure header h1:not(div.boxed-text *) {
    margin-bottom: 0;
    padding-bottom: 0;
}

figure > figure + figure {
    margin-top: 0em;
} 

section.body figure[role="group"] figure + p:not(div.boxed-text *, .caption, .credits, .stage, details *, .front-matter *) {
    margin-top : -1em;
}

.landingPage div[id*="figures"] figure figcaption {
    text-align: left;
    align-self: flex-start;
}
Loading