Skip to content

Commit bdaad94

Browse files
committed
Merge branch 'fix_register_errors_3_3_0' into 'stable-3_3_0'
Refactoring to fix errors in book register See merge request softwares-pkp/plugins_ojs/thoth-omp-plugin!50
2 parents 0839b29 + 45382da commit bdaad94

110 files changed

Lines changed: 5562 additions & 3487 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ Developed by [Lepidus Tecnologia](https://github.com/lepidus).
120120

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

123-
Copyright (c) 2024 Lepidus Tecnologia
123+
Copyright (c) 2024-2025 Lepidus Tecnologia
124124

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

ThothPlugin.inc.php

Lines changed: 86 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,13 @@ 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+
$this->addTemplateFilters();
37+
$this->addToSchema();
38+
$this->addFormConfig();
39+
$this->addEndpoints();
40+
$this->addScripts();
41+
$this->addListeners();
42+
$this->addHandlers();
5043
}
5144

5245
return $success;
@@ -121,4 +114,74 @@ public function manage($args, $request)
121114
}
122115
return parent::manage($args, $request);
123116
}
117+
118+
public function addTemplateFilters()
119+
{
120+
HookRegistry::register('TemplateManager::display', function ($hookName, $args) {
121+
$templateMgr = $args[0];
122+
$template = $args[1];
123+
124+
$thothSectionFilter = new ThothSectionFilter();
125+
$thothSectionFilter->registerFilter($templateMgr, $template, $this);
126+
});
127+
}
128+
129+
public function addToSchema()
130+
{
131+
$thothSchema = new ThothSchema();
132+
HookRegistry::register('Schema::get::submission', [$thothSchema, 'addWorkIdToSchema']);
133+
}
134+
135+
public function addFormConfig()
136+
{
137+
$publishFormConfig = new PublishFormConfig();
138+
HookRegistry::register('Form::config::before', [$publishFormConfig, 'addConfig']);
139+
}
140+
141+
public function addEndpoints()
142+
{
143+
$thothEndpoint = new ThothEndpoint();
144+
HookRegistry::register('APIHandler::endpoints', [$thothEndpoint, 'addEndpoints']);
145+
}
146+
147+
public function addScripts()
148+
{
149+
HookRegistry::register('TemplateManager::display', function ($hookName, $args) {
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+
165+
public function addListeners()
166+
{
167+
$publicationPublishListener = new PublicationPublishListener();
168+
HookRegistry::register('Publication::validatePublish', [$publicationPublishListener, 'validate']);
169+
HookRegistry::register('Publication::publish', [$publicationPublishListener, 'registerThothBook']);
170+
171+
$publicationEditListener = new PublicationEditListener();
172+
HookRegistry::register('Publication::edit', [$publicationEditListener, 'updateThothBook']);
173+
}
174+
175+
public function addHandlers()
176+
{
177+
HookRegistry::register('LoadHandler', function ($hookName, $args) {
178+
$page = $args[0];
179+
if ($this->getEnabled() && $page === 'thoth') {
180+
$this->import('controllers/modal/RegisterHandler');
181+
define('HANDLER_CLASS', 'RegisterHandler');
182+
return true;
183+
}
184+
return false;
185+
});
186+
}
124187
}

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.

0 commit comments

Comments
 (0)