forked from thoth-pub/thoth-omp-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThothPlugin.php
More file actions
106 lines (89 loc) · 2.76 KB
/
ThothPlugin.php
File metadata and controls
106 lines (89 loc) · 2.76 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* @file plugins/generic/thoth/ThothPlugin.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Copyright (c) 2024-2026 Lepidus Tecnologia
* Copyright (c) 2024-2026 Thoth
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ThothPlugin
*
* @ingroup plugins_generic_thoth
*
* @brief Plugin for integration with Thoth for communication and synchronization of book data between the two platforms
*/
namespace APP\plugins\generic\thoth;
use APP\plugins\generic\thoth\classes\hooks\HookRegistrant;
use PKP\core\JSONMessage;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
class ThothPlugin extends \PKP\plugins\GenericPlugin
{
public function register($category, $path, $mainContextId = null)
{
$success = parent::register($category, $path);
if ($success && $this->getEnabled()) {
$hookRegistrant = new HookRegistrant($this);
$hookRegistrant->register();
}
return $success;
}
public function getDisplayName()
{
return __('plugins.generic.thoth.name');
}
public function getDescription()
{
return __('plugins.generic.thoth.description');
}
public function getActions($request, $verb)
{
$parentActions = parent::getActions($request, $verb);
if (!$this->getEnabled()) {
return $parentActions;
}
$router = $request->getRouter();
$linkAction = new LinkAction(
'settings',
new AjaxModal(
$router->url(
$request,
null,
null,
'manage',
null,
[
'verb' => 'settings',
'plugin' => $this->getName(),
'category' => 'generic'
]
),
$this->getDisplayName()
),
__('manager.plugins.settings'),
null
);
array_unshift($parentActions, $linkAction);
return $parentActions;
}
public function manage($args, $request)
{
if ($request->getUserVar('verb') !== 'settings') {
return parent::manage($args, $request);
}
$context = $request->getContext();
$form = new ThothSettingsForm($this, $context->getId());
if ($request->getUserVar('save')) {
$form->readInputData();
if ($form->validate()) {
$form->execute();
return new JSONMessage(true);
}
} else {
$form->initData();
}
return new JSONMessage(true, $form->fetch($request));
}
}