Skip to content

Commit

Permalink
Merge pull request #25 from lepidus/stable-3_3_0
Browse files Browse the repository at this point in the history
Feature/added page for bulk register (OMP 3.3.0)
  • Loading branch information
thiagolepidus authored Feb 18, 2025
2 parents 4314e65 + c04eb9b commit df5bd1d
Show file tree
Hide file tree
Showing 121 changed files with 6,620 additions and 3,557 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ After metadata is published, a link to the book on Thoth will appear at the top

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

### Bulk register

On the Thoth page, you can bulk submit a selection of titles from OMP into Thoth.

![page](/images/page.png)

## OMP-Thoth Mapping

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

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

Copyright (c) 2024 Lepidus Tecnologia
Copyright (c) 2024-2025 Lepidus Tecnologia

Copyright (c) 2024 Thoth
Copyright (c) 2024-2025 Thoth
148 changes: 125 additions & 23 deletions ThothPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Copyright (c) 2024 Lepidus Tecnologia
* Copyright (c) 2024 Thoth
* Copyright (c) 2024-2025 Lepidus Tecnologia
* Copyright (c) 2024-2025 Thoth
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ThothPlugin
Expand All @@ -18,10 +18,13 @@
require_once(__DIR__ . '/vendor/autoload.php');

import('lib.pkp.classes.plugins.GenericPlugin');
import('plugins.generic.thoth.classes.ThothBadgeRender');
import('plugins.generic.thoth.classes.ThothNotification');
import('plugins.generic.thoth.classes.ThothRegister');
import('plugins.generic.thoth.classes.ThothUpdater');
import('plugins.generic.thoth.classes.api.ThothEndpoint');
import('plugins.generic.thoth.classes.components.forms.config.PublishFormConfig');
import('plugins.generic.thoth.classes.filters.ThothSectionFilter');
import('plugins.generic.thoth.classes.listeners.PublicationEditListener');
import('plugins.generic.thoth.classes.listeners.PublicationPublishListener');
import('plugins.generic.thoth.classes.notification.ThothNotification');
import('plugins.generic.thoth.classes.schema.ThothSchema');

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

if ($success && $this->getEnabled()) {
$thothRegister = new ThothRegister($this);
HookRegistry::register('Schema::get::submission', [$thothRegister, 'addWorkIdToSchema']);
HookRegistry::register('Form::config::before', [$thothRegister, 'addThothField']);
HookRegistry::register('Publication::validatePublish', [$thothRegister, 'validateRegister']);
HookRegistry::register('TemplateManager::display', [$thothRegister, 'addResources']);
HookRegistry::register('Publication::publish', [$thothRegister, 'registerOnPublish']);
HookRegistry::register('LoadHandler', [$thothRegister, 'setupHandler']);
HookRegistry::register('APIHandler::endpoints', [$thothRegister, 'addThothEndpoint']);

$thothUpdater = new ThothUpdater($this);
HookRegistry::register('Publication::edit', [$thothUpdater, 'updateWork']);

$thothBadgeRender = new ThothBadgeRender($this);
HookRegistry::register('TemplateManager::display', [$thothBadgeRender, 'addThothBadge']);

$thothNotification = new ThothNotification($this);
HookRegistry::register('TemplateManager::display', [$thothNotification, 'addNotificationScript']);
HookRegistry::register('TemplateManager::display', [$this, 'addScripts']);
HookRegistry::register('TemplateManager::display', [$this, 'addTemplateFilters']);
HookRegistry::register('TemplateManager::display', [$this, 'addMenu']);
HookRegistry::register('LoadHandler', [$this, 'addHandlers']);

$this->addToSchema();
$this->addFormConfig();
$this->addEndpoints();
$this->addListeners();
}

return $success;
Expand Down Expand Up @@ -121,4 +116,111 @@ public function manage($args, $request)
}
return parent::manage($args, $request);
}

public function addTemplateFilters($hookName, $args)
{
$templateMgr = $args[0];
$template = $args[1];

$thothSectionFilter = new ThothSectionFilter();
$thothSectionFilter->registerFilter($templateMgr, $template, $this);
}

public function addToSchema()
{
$thothSchema = new ThothSchema();
HookRegistry::register('Schema::get::submission', [$thothSchema, 'addWorkIdToSchema']);
HookRegistry::register('Submission::getBackendListProperties::properties', [$thothSchema, 'addToBackendProps']);
}

public function addFormConfig()
{
$publishFormConfig = new PublishFormConfig();
HookRegistry::register('Form::config::before', [$publishFormConfig, 'addConfig']);
}

public function addEndpoints()
{
$thothEndpoint = new ThothEndpoint();
HookRegistry::register('APIHandler::endpoints', [$thothEndpoint, 'addEndpoints']);
}

public function addScripts($hookName, $args)
{
$templateMgr = $args[0];
$template = $args[1];
$request = Application::get()->getRequest();

$thothNotification = new ThothNotification();
$thothNotification->addJavaScriptData($request, $templateMgr);
$thothNotification->addJavaScript($request, $templateMgr, $this);

$thothSectionFilter = new ThothSectionFilter();
$thothSectionFilter->addJavaScriptData($request, $templateMgr, $template);
$thothSectionFilter->addJavaScript($request, $templateMgr, $this);
$thothSectionFilter->addStyleSheet($request, $templateMgr, $this);
}

public function addListeners()
{
$publicationPublishListener = new PublicationPublishListener();
HookRegistry::register('Publication::validatePublish', [$publicationPublishListener, 'validate']);
HookRegistry::register('Publication::publish', [$publicationPublishListener, 'registerThothBook']);

$publicationEditListener = new PublicationEditListener();
HookRegistry::register('Publication::edit', [$publicationEditListener, 'updateThothBook']);
}

public function addHandlers($hookName, $args)
{
$page = $args[0];
$op = $args[1];

if (!$this->getEnabled() || $page !== 'thoth') {
return false;
}

if ($op === 'register') {
$this->import('controllers/modal/RegisterHandler');
define('HANDLER_CLASS', 'RegisterHandler');
return true;
}

if ($op === 'index') {
$this->import('pages/thoth/ThothHandler');
define('HANDLER_CLASS', 'ThothHandler');
return true;
}

return false;
}

public function addMenu($hookName, $args)
{
$templateMgr = $args[0];

$request = Application::get()->getRequest();
$router = $request->getRouter();
$userRoles = (array) $router->getHandler()->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);

$menu = $templateMgr->getState('menu');

if (empty($menu)) {
return false;
}

if (in_array(ROLE_ID_MANAGER, $userRoles)) {
$menu = array_slice($menu, 0, 2, true) +
[
'thoth' => [
'name' => __('plugins.generic.thoth.navigation.thoth'),
'url' => $router->url($request, null, 'thoth'),
'isCurrent' => $router->getRequestedPage($request) === 'thoth',
]
] +
array_slice($menu, 2, null, true);
}

$templateMgr->setState(['menu' => $menu]);
}
}
4 changes: 2 additions & 2 deletions ThothSettingsForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Copyright (c) 2024 Lepidus Tecnologia
* Copyright (c) 2024 Thoth
* Copyright (c) 2024-2025 Lepidus Tecnologia
* Copyright (c) 2024-2025 Thoth
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ThothSettingsForm
Expand Down
62 changes: 0 additions & 62 deletions classes/ThothBadgeRender.inc.php

This file was deleted.

74 changes: 0 additions & 74 deletions classes/ThothNotification.inc.php

This file was deleted.

Loading

0 comments on commit df5bd1d

Please sign in to comment.