Skip to content

Commit

Permalink
Refactors adding of stylesheet on questionnaire page
Browse files Browse the repository at this point in the history
Issue: documentacao-e-tarefas/scielo#696

Signed-off-by: Jhon <[email protected]>
  • Loading branch information
JhonathanLepidus committed Oct 11, 2024
1 parent df092d6 commit 1031e16
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
20 changes: 20 additions & 0 deletions pages/demographic/QuestionnaireHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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,
]
);
}
}
1 change: 0 additions & 1 deletion templates/questionnairePage/deleteData.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{translate key="plugins.generic.demographicData.questionnairePage.deleteData.title"}
{/capture}

<link rel="stylesheet" type="text/css" href="/plugins/generic/demographicData/styles/questionnairePage.css">
{include file="frontend/components/header.tpl" pageTitleTranslated=$pageTitle}

<div class="page">
Expand Down
1 change: 0 additions & 1 deletion templates/questionnairePage/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{translate key="plugins.generic.demographicData.questionnairePage.index.title"}
{/capture}

<link rel="stylesheet" type="text/css" href="/plugins/generic/demographicData/styles/questionnairePage.css">
{include file="frontend/components/header.tpl" pageTitleTranslated=$pageTitle}

<div class="page">
Expand Down
1 change: 0 additions & 1 deletion templates/questionnairePage/responses.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{translate key="plugins.generic.demographicData.questionnairePage.responses.title"}
{/capture}

<link rel="stylesheet" type="text/css" href="/plugins/generic/demographicData/styles/questionnairePage.css">
{include file="frontend/components/header.tpl" pageTitleTranslated=$pageTitle}

<div class="page">
Expand Down

0 comments on commit 1031e16

Please sign in to comment.