-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCitationManagerPlugin.php
executable file
·125 lines (103 loc) · 4.8 KB
/
CitationManagerPlugin.php
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* @file CitationManagerPlugin.php
*
* @copyright (c) 2021+ TIB Hannover
* @copyright (c) 2021+ Gazi Yücel
* @license Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class CitationManagerPlugin
* @brief Plugin for structuring, enriching and depositing Citations from and to external services.
*/
namespace APP\plugins\generic\citationManager;
define('CITATION_MANAGER_PLUGIN_NAME', basename(__FILE__, '.php'));
require_once(CitationManagerPlugin::autoloadFile());
use APP\plugins\generic\citationManager\classes\Db\PluginSchema;
use APP\plugins\generic\citationManager\classes\FrontEnd\ArticleView;
use APP\plugins\generic\citationManager\classes\Handlers\PluginAPIHandler;
use APP\plugins\generic\citationManager\classes\Settings\Actions;
use APP\plugins\generic\citationManager\classes\Settings\Manage;
use APP\plugins\generic\citationManager\classes\Settings\PluginConfig;
use APP\plugins\generic\citationManager\classes\Workflow\SubmissionWizard;
use APP\plugins\generic\citationManager\classes\Workflow\WorkflowSave;
use APP\plugins\generic\citationManager\classes\Workflow\WorkflowTab;
use PKP\core\JSONMessage;
use PKP\plugins\GenericPlugin;
use PKP\plugins\Hook;
use PKP\security\Role;
class CitationManagerPlugin extends GenericPlugin
{
/** @var string Whether show the structured or the raw citations */
public const FRONTEND_SHOW_STRUCTURED = CITATION_MANAGER_PLUGIN_NAME . '_FrontEndShowStructured';
/** @var string Key for structured citations saved in publications */
public const CITATIONS_STRUCTURED = 'citationsStructured';
/** @var array Roles which can access PluginApiHandler */
public const apiRoles = [Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT, Role::ROLE_ID_REVIEWER, Role::ROLE_ID_AUTHOR];
/** @copydoc Plugin::register */
public function register($category, $path, $mainContextId = null): bool
{
if (parent::register($category, $path, $mainContextId)) {
if ($this->getEnabled()) {
$pluginSchema = new PluginSchema();
Hook::add('Schema::get::publication', [$pluginSchema, 'addToSchemaPublication']);
Hook::add('Schema::get::author', [$pluginSchema, 'addToSchemaAuthor']);
Hook::add('Schema::get::context', [$pluginSchema, 'addToSchemaJournal']);
$submissionWizard = new SubmissionWizard($this);
Hook::add('Template::SubmissionWizard::Section', [$submissionWizard, 'execute']);
$workflowTab = new WorkflowTab($this);
Hook::add('Template::Workflow', [$workflowTab, 'execute']);
$workflowSave = new WorkflowSave($this);
Hook::add('Publication::edit', [$workflowSave, 'execute']);
$articlePage = new ArticleView($this);
Hook::add('TemplateManager::display', [$articlePage, 'execute']);
$pluginApiHandler = new PluginAPIHandler();
Hook::add('Dispatcher::dispatch', [$pluginApiHandler, 'register']);
// // task scheduler; not working as expected
// Hook::add('AcronPlugin::parseCronTab', function ($hookName, $args) {
// $taskFilesPath =& $args[0];
// $taskFilesPath[] = $this->getPluginPath() . DIRECTORY_SEPARATOR . 'scheduledTasks.xml';
// return false;
// });
}
return true;
}
return false;
}
/** @copydoc Plugin::getActions() */
public function getActions($request, $actionArgs): array
{
if (!$this->getEnabled()) return parent::getActions($request, $actionArgs);
$actions = new Actions($this);
return $actions->execute($request, $actionArgs, parent::getActions($request, $actionArgs));
}
/** @copydoc Plugin::manage() */
public function manage($args, $request): JSONMessage
{
$manage = new Manage($this);
return $manage->execute($args, $request);
}
/** @copydoc PKPPlugin::getDescription */
public function getDescription(): string
{
return __('plugins.generic.citationManager.description');
}
/** @copydoc PKPPlugin::getDisplayName */
public function getDisplayName(): string
{
return __('plugins.generic.citationManager.displayName');
}
/**
* Return composer autoload file path
*
* @return string
*/
public static function autoloadFile(): string
{
if (PluginConfig::isTestMode()) return __DIR__ . '/tests/vendor/autoload.php';
return __DIR__ . '/vendor/autoload.php';
}
}
// For backwards compatibility -- expect this to be removed approx. OJS/OMP/OPS 3.6
if (!PKP_STRICT_MODE) {
class_alias('\APP\plugins\generic\citationManager\CitationManagerPlugin', '\CitationManagerPlugin');
}