Repository navigation
Expand file tree
/
Copy pathZenodoPlugin.php
More file actions
96 lines (86 loc) · 2.8 KB
/
Copy pathZenodoPlugin.php
File metadata and controls
96 lines (86 loc) · 2.8 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
<?php
/**
* @file plugins/generic/zenodo/ZenodoPlugin.php
*
* Copyright (c) 2025-2026 Simon Fraser University
* Copyright (c) 2025-2026 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
*
* @class ZenodoPlugin
*
* @brief Plugin to export articles to Zenodo.
*
*/
namespace APP\plugins\generic\zenodo;
use APP\plugins\generic\zenodo\controllers\grid\ZenodoPublicationsListGridHandler;
use APP\plugins\generic\zenodo\controllers\grid\ZenodoSubmissionsListGridHandler;
use APP\plugins\PubObjectsExportGenericPlugin;
use PKP\plugins\Hook;
use PKP\plugins\PluginRegistry;
class ZenodoPlugin extends PubObjectsExportGenericPlugin
{
/**
* @copydoc Plugin::register()
*
* @param null|mixed $mainContextId
*/
public function register($category, $path, $mainContextId = null)
{
$success = parent::register($category, $path, $mainContextId);
if ($success && $this->getEnabled($mainContextId)) {
Hook::add('LoadComponentHandler', $this->setupGridHandler(...));
}
return $success;
}
/**
* Serve the export grids with the plugin's Zenodo record column.
*/
public function setupGridHandler(string $hookName, array $params): bool
{
$component = &$params[0];
$componentInstance = &$params[2];
$handlerClass = match ($component) {
'plugins.generic.zenodo.controllers.grid.ZenodoPublicationsListGridHandler' => ZenodoPublicationsListGridHandler::class,
'plugins.generic.zenodo.controllers.grid.ZenodoSubmissionsListGridHandler' => ZenodoSubmissionsListGridHandler::class,
default => null,
};
if (!$handlerClass) {
return false;
}
$componentInstance = new $handlerClass();
return true;
}
/**
* @copydoc Plugin::getDisplayName()
*/
public function getDisplayName(): string
{
return __('plugins.generic.zenodo.displayName');
}
/**
* @copydoc Plugin::getDescription()
*/
public function getDescription(): string
{
return __('plugins.generic.zenodo.description');
}
protected function setExportPlugin(): void
{
PluginRegistry::register('importexport', new ZenodoExportPlugin(), $this->getPluginPath());
$this->exportPlugin = PluginRegistry::getPlugin('importexport', 'ZenodoExportPlugin');
}
/**
* @copydoc Plugin::getContextSpecificPluginSettingsFile()
*/
public function getContextSpecificPluginSettingsFile(): string
{
return $this->getPluginPath() . '/settings.xml';
}
/**
* @copydoc Plugin::getInstallSitePluginSettingsFile()
*/
public function getInstallSitePluginSettingsFile(): string
{
return $this->getPluginPath() . '/settings.xml';
}
}