Skip to content

Commit df5bd1d

Browse files
Merge pull request #25 from lepidus/stable-3_3_0
Feature/added page for bulk register (OMP 3.3.0)
2 parents 4314e65 + c04eb9b commit df5bd1d

121 files changed

Lines changed: 6620 additions & 3557 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ After metadata is published, a link to the book on Thoth will appear at the top
6060

6161
![link](/images/link.png)
6262

63+
### Bulk register
64+
65+
On the Thoth page, you can bulk submit a selection of titles from OMP into Thoth.
66+
67+
![page](/images/page.png)
68+
6369
## OMP-Thoth Mapping
6470

6571
<details>
@@ -120,6 +126,6 @@ Developed by [Lepidus Tecnologia](https://github.com/lepidus).
120126

121127
This plugin is licensed under the GNU General Public License v3.0 - [See the License file.](/LICENSE)
122128

123-
Copyright (c) 2024 Lepidus Tecnologia
129+
Copyright (c) 2024-2025 Lepidus Tecnologia
124130

125-
Copyright (c) 2024 Thoth
131+
Copyright (c) 2024-2025 Thoth

ThothPlugin.inc.php

Lines changed: 125 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*
66
* Copyright (c) 2014-2020 Simon Fraser University
77
* Copyright (c) 2003-2020 John Willinsky
8-
* Copyright (c) 2024 Lepidus Tecnologia
9-
* Copyright (c) 2024 Thoth
8+
* Copyright (c) 2024-2025 Lepidus Tecnologia
9+
* Copyright (c) 2024-2025 Thoth
1010
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
1111
*
1212
* @class ThothPlugin
@@ -18,10 +18,13 @@
1818
require_once(__DIR__ . '/vendor/autoload.php');
1919

2020
import('lib.pkp.classes.plugins.GenericPlugin');
21-
import('plugins.generic.thoth.classes.ThothBadgeRender');
22-
import('plugins.generic.thoth.classes.ThothNotification');
23-
import('plugins.generic.thoth.classes.ThothRegister');
24-
import('plugins.generic.thoth.classes.ThothUpdater');
21+
import('plugins.generic.thoth.classes.api.ThothEndpoint');
22+
import('plugins.generic.thoth.classes.components.forms.config.PublishFormConfig');
23+
import('plugins.generic.thoth.classes.filters.ThothSectionFilter');
24+
import('plugins.generic.thoth.classes.listeners.PublicationEditListener');
25+
import('plugins.generic.thoth.classes.listeners.PublicationPublishListener');
26+
import('plugins.generic.thoth.classes.notification.ThothNotification');
27+
import('plugins.generic.thoth.classes.schema.ThothSchema');
2528

2629
class ThothPlugin extends GenericPlugin
2730
{
@@ -30,23 +33,15 @@ public function register($category, $path, $mainContextId = null)
3033
$success = parent::register($category, $path);
3134

3235
if ($success && $this->getEnabled()) {
33-
$thothRegister = new ThothRegister($this);
34-
HookRegistry::register('Schema::get::submission', [$thothRegister, 'addWorkIdToSchema']);
35-
HookRegistry::register('Form::config::before', [$thothRegister, 'addThothField']);
36-
HookRegistry::register('Publication::validatePublish', [$thothRegister, 'validateRegister']);
37-
HookRegistry::register('TemplateManager::display', [$thothRegister, 'addResources']);
38-
HookRegistry::register('Publication::publish', [$thothRegister, 'registerOnPublish']);
39-
HookRegistry::register('LoadHandler', [$thothRegister, 'setupHandler']);
40-
HookRegistry::register('APIHandler::endpoints', [$thothRegister, 'addThothEndpoint']);
41-
42-
$thothUpdater = new ThothUpdater($this);
43-
HookRegistry::register('Publication::edit', [$thothUpdater, 'updateWork']);
44-
45-
$thothBadgeRender = new ThothBadgeRender($this);
46-
HookRegistry::register('TemplateManager::display', [$thothBadgeRender, 'addThothBadge']);
47-
48-
$thothNotification = new ThothNotification($this);
49-
HookRegistry::register('TemplateManager::display', [$thothNotification, 'addNotificationScript']);
36+
HookRegistry::register('TemplateManager::display', [$this, 'addScripts']);
37+
HookRegistry::register('TemplateManager::display', [$this, 'addTemplateFilters']);
38+
HookRegistry::register('TemplateManager::display', [$this, 'addMenu']);
39+
HookRegistry::register('LoadHandler', [$this, 'addHandlers']);
40+
41+
$this->addToSchema();
42+
$this->addFormConfig();
43+
$this->addEndpoints();
44+
$this->addListeners();
5045
}
5146

5247
return $success;
@@ -121,4 +116,111 @@ public function manage($args, $request)
121116
}
122117
return parent::manage($args, $request);
123118
}
119+
120+
public function addTemplateFilters($hookName, $args)
121+
{
122+
$templateMgr = $args[0];
123+
$template = $args[1];
124+
125+
$thothSectionFilter = new ThothSectionFilter();
126+
$thothSectionFilter->registerFilter($templateMgr, $template, $this);
127+
}
128+
129+
public function addToSchema()
130+
{
131+
$thothSchema = new ThothSchema();
132+
HookRegistry::register('Schema::get::submission', [$thothSchema, 'addWorkIdToSchema']);
133+
HookRegistry::register('Submission::getBackendListProperties::properties', [$thothSchema, 'addToBackendProps']);
134+
}
135+
136+
public function addFormConfig()
137+
{
138+
$publishFormConfig = new PublishFormConfig();
139+
HookRegistry::register('Form::config::before', [$publishFormConfig, 'addConfig']);
140+
}
141+
142+
public function addEndpoints()
143+
{
144+
$thothEndpoint = new ThothEndpoint();
145+
HookRegistry::register('APIHandler::endpoints', [$thothEndpoint, 'addEndpoints']);
146+
}
147+
148+
public function addScripts($hookName, $args)
149+
{
150+
$templateMgr = $args[0];
151+
$template = $args[1];
152+
$request = Application::get()->getRequest();
153+
154+
$thothNotification = new ThothNotification();
155+
$thothNotification->addJavaScriptData($request, $templateMgr);
156+
$thothNotification->addJavaScript($request, $templateMgr, $this);
157+
158+
$thothSectionFilter = new ThothSectionFilter();
159+
$thothSectionFilter->addJavaScriptData($request, $templateMgr, $template);
160+
$thothSectionFilter->addJavaScript($request, $templateMgr, $this);
161+
$thothSectionFilter->addStyleSheet($request, $templateMgr, $this);
162+
}
163+
164+
public function addListeners()
165+
{
166+
$publicationPublishListener = new PublicationPublishListener();
167+
HookRegistry::register('Publication::validatePublish', [$publicationPublishListener, 'validate']);
168+
HookRegistry::register('Publication::publish', [$publicationPublishListener, 'registerThothBook']);
169+
170+
$publicationEditListener = new PublicationEditListener();
171+
HookRegistry::register('Publication::edit', [$publicationEditListener, 'updateThothBook']);
172+
}
173+
174+
public function addHandlers($hookName, $args)
175+
{
176+
$page = $args[0];
177+
$op = $args[1];
178+
179+
if (!$this->getEnabled() || $page !== 'thoth') {
180+
return false;
181+
}
182+
183+
if ($op === 'register') {
184+
$this->import('controllers/modal/RegisterHandler');
185+
define('HANDLER_CLASS', 'RegisterHandler');
186+
return true;
187+
}
188+
189+
if ($op === 'index') {
190+
$this->import('pages/thoth/ThothHandler');
191+
define('HANDLER_CLASS', 'ThothHandler');
192+
return true;
193+
}
194+
195+
return false;
196+
}
197+
198+
public function addMenu($hookName, $args)
199+
{
200+
$templateMgr = $args[0];
201+
202+
$request = Application::get()->getRequest();
203+
$router = $request->getRouter();
204+
$userRoles = (array) $router->getHandler()->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);
205+
206+
$menu = $templateMgr->getState('menu');
207+
208+
if (empty($menu)) {
209+
return false;
210+
}
211+
212+
if (in_array(ROLE_ID_MANAGER, $userRoles)) {
213+
$menu = array_slice($menu, 0, 2, true) +
214+
[
215+
'thoth' => [
216+
'name' => __('plugins.generic.thoth.navigation.thoth'),
217+
'url' => $router->url($request, null, 'thoth'),
218+
'isCurrent' => $router->getRequestedPage($request) === 'thoth',
219+
]
220+
] +
221+
array_slice($menu, 2, null, true);
222+
}
223+
224+
$templateMgr->setState(['menu' => $menu]);
225+
}
124226
}

ThothSettingsForm.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*
66
* Copyright (c) 2014-2020 Simon Fraser University
77
* Copyright (c) 2003-2020 John Willinsky
8-
* Copyright (c) 2024 Lepidus Tecnologia
9-
* Copyright (c) 2024 Thoth
8+
* Copyright (c) 2024-2025 Lepidus Tecnologia
9+
* Copyright (c) 2024-2025 Thoth
1010
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
1111
*
1212
* @class ThothSettingsForm

classes/ThothBadgeRender.inc.php

Lines changed: 0 additions & 62 deletions
This file was deleted.

classes/ThothNotification.inc.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)