-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCrossrefReferenceLinkingSettingsForm.php
83 lines (78 loc) · 2.99 KB
/
CrossrefReferenceLinkingSettingsForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* @file CrossrefReferenceLinkingSettingsForm.inc.php
*
* Copyright (c) 2014-2023 Simon Fraser University
* Copyright (c) 2003-2023 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
*
* @class CrossrefReferenceLinkingSettingsForm
* @ingroup plugins_generic_crossrefReferenceLinking
*
* @brief Form for journal managers to setup the reference linking plugin
*/
namespace APP\plugins\generic\crossrefReferenceLinking;
use APP\core\Application;
use APP\template\TemplateManager;
use PKP\form\Form;
use PKP\form\validation\FormValidatorCSRF;
use PKP\form\validation\FormValidatorPost;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\RedirectAction;
class CrossrefReferenceLinkingSettingsForm extends Form
{
public function __construct(public CrossrefReferenceLinkingPlugin $plugin, public int $contextId)
{
parent::__construct($plugin->getTemplateResource('settingsForm.tpl'));
$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
}
/**
* @copydoc Form::fetch()
*/
public function fetch($request, $template = null, $display = false): string
{
$dispatcher = $request->getDispatcher();
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('pluginName', $this->plugin->getName());
if (!$this->plugin->hasCrossrefCredentials($this->contextId)) {
// Settings > Distribution > DOIs > Registration
$crossrefSettingsLinkAction = new LinkAction(
'settings',
new RedirectAction($dispatcher->url(
$request,
Application::ROUTE_PAGE,
null,
'management',
'settings',
'distribution',
[],
'dois/doisRegistration' // Anchor for tab
)),
__('plugins.generic.crossrefReferenceLinking.settings.form.crossrefSettings'),
null
);
$templateMgr->assign('crossrefSettingsLinkAction', $crossrefSettingsLinkAction);
}
if (!$this->plugin->citationsEnabled($this->contextId)) {
// Settings > Workflow > Submission > Metadata
$submissionSettingsLinkAction = new LinkAction(
'settings',
new RedirectAction($dispatcher->url(
$request,
Application::ROUTE_PAGE,
null,
'management',
'settings',
'workflow',
[],
'submission/metadata' // Anchor for tab
)),
__('plugins.generic.crossrefReferenceLinking.settings.form.submissionSettings'),
null
);
$templateMgr->assign('submissionSettingsLinkAction', $submissionSettingsLinkAction);
}
return parent::fetch($request);
}
}