From 1031e16807128f3cf78d8ad4109ea619432a4ed3 Mon Sep 17 00:00:00 2001 From: Jhon Date: Fri, 11 Oct 2024 15:30:20 -0400 Subject: [PATCH] Refactors adding of stylesheet on questionnaire page Issue: documentacao-e-tarefas/scielo#696 Signed-off-by: Jhon --- pages/demographic/QuestionnaireHandler.php | 20 ++++++++++++++++++++ templates/questionnairePage/deleteData.tpl | 1 - templates/questionnairePage/index.tpl | 1 - templates/questionnairePage/responses.tpl | 1 - 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/pages/demographic/QuestionnaireHandler.php b/pages/demographic/QuestionnaireHandler.php index ddbcb26..8a39467 100644 --- a/pages/demographic/QuestionnaireHandler.php +++ b/pages/demographic/QuestionnaireHandler.php @@ -24,6 +24,7 @@ public function index($args, $request) $queryParams = $request->getQueryArray(); $author = Repo::author()->get((int) $queryParams['authorId']); + $this->addQuestionnairePageStyleSheet($plugin, $request, $templateMgr); $demographicDataService = new DemographicDataService(); $authorToken = $queryParams['authorToken']; @@ -103,6 +104,8 @@ public function saveQuestionnaire($args, $request) $plugin = PluginRegistry::getPlugin('generic', 'demographicdataplugin'); $templateMgr = TemplateManager::getManager($request); + $this->addQuestionnairePageStyleSheet($plugin, $request, $templateMgr); + if (!$this->authorTokenIsValid($author, $authorToken)) { $templateMgr->assign('messageToDisplay', __('plugins.generic.demographicData.questionnairePage.accessDenied')); return $templateMgr->display($plugin->getTemplateResource('questionnairePage/displayMessage.tpl')); @@ -142,6 +145,8 @@ public function deleteData($args, $request) $plugin = PluginRegistry::getPlugin('generic', 'demographicdataplugin'); $templateMgr = TemplateManager::getManager($request); + $this->addQuestionnairePageStyleSheet($plugin, $request, $templateMgr); + if (!$this->authorTokenIsValid($author, $authorToken)) { $templateMgr->assign('messageToDisplay', __('plugins.generic.demographicData.questionnairePage.accessDenied')); return $templateMgr->display($plugin->getTemplateResource('questionnairePage/displayMessage.tpl')); @@ -182,6 +187,8 @@ public function orcidVerify($args, $request) $templateMgr = TemplateManager::getManager($request); $contextId = $request->getContext()->getId(); + $this->addQuestionnairePageStyleSheet($plugin, $request, $templateMgr); + if ($request->getUserVar('error') == 'access_denied') { $templateMgr->assign('messageToDisplay', __('plugins.generic.demographicData.questionnairePage.orcidAccessDenied')); return $templateMgr->display($plugin->getTemplateResource('questionnairePage/displayMessage.tpl')); @@ -220,4 +227,17 @@ public function orcidVerify($args, $request) $request->redirect(null, null, 'index', null, ['authorId' => $author->getId(), 'authorToken' => $request->getUserVar('authorToken')]); } + + private function addQuestionnairePageStyleSheet($plugin, $request, $templateMgr) + { + $templateMgr->addStyleSheet( + 'questionnairePageStyleSheet', + $request->getBaseUrl() . '/' . $plugin->getPluginPath() . '/styles/questionnairePage.css', + [ + 'priority' => TemplateManager::STYLE_SEQUENCE_LAST, + 'contexts' => ['frontend'], + 'inline' => false, + ] + ); + } } diff --git a/templates/questionnairePage/deleteData.tpl b/templates/questionnairePage/deleteData.tpl index 984f9f8..470df9c 100644 --- a/templates/questionnairePage/deleteData.tpl +++ b/templates/questionnairePage/deleteData.tpl @@ -2,7 +2,6 @@ {translate key="plugins.generic.demographicData.questionnairePage.deleteData.title"} {/capture} - {include file="frontend/components/header.tpl" pageTitleTranslated=$pageTitle}
diff --git a/templates/questionnairePage/index.tpl b/templates/questionnairePage/index.tpl index 9623c9d..1a24414 100644 --- a/templates/questionnairePage/index.tpl +++ b/templates/questionnairePage/index.tpl @@ -2,7 +2,6 @@ {translate key="plugins.generic.demographicData.questionnairePage.index.title"} {/capture} - {include file="frontend/components/header.tpl" pageTitleTranslated=$pageTitle}
diff --git a/templates/questionnairePage/responses.tpl b/templates/questionnairePage/responses.tpl index c1d388d..b350bb4 100644 --- a/templates/questionnairePage/responses.tpl +++ b/templates/questionnairePage/responses.tpl @@ -2,7 +2,6 @@ {translate key="plugins.generic.demographicData.questionnairePage.responses.title"} {/capture} - {include file="frontend/components/header.tpl" pageTitleTranslated=$pageTitle}