/
jsonKeywordsPlugin.inc.php
64 lines (47 loc) · 1.61 KB
/
jsonKeywordsPlugin.inc.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
<?php
/**
* @file jsonKeywordsPlugin.inc.php
*
* Copyright (c) 2016 Antti-Jussi Nygård
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class jsonKeywordsPlugin
* @ingroup plugins_generic_jsonKeywords
* @brief jsonKeywords plugin class
*
*
*/
import('classes.plugins.GenericPlugin');
class jsonKeywordsPlugin extends GenericPlugin {
function getName() {
return 'jsonKeywordsPlugin';
}
function getDisplayName() {
return "jsonKeywords (YSO/Finto)";
}
function getDescription() {
return "Activates autocomplete function in keyword metadata fields. Hard coded to use the Finnish Finto API.";
}
function register($category, $path) {
if (parent::register($category, $path)) {
$this->addLocaleData();
if ($this->getEnabled()) {
HookRegistry::register('TemplateManager::display',array(&$this, 'callback'));
}
return true;
}
return false;
}
function callback($hookName, $args) {
$templateMgr =& $args[0];
$op = Request::getRequestedOp();
$currentJournal = $templateMgr->get_template_vars('currentJournal');
if (!empty($currentJournal) AND (($op == 'viewMetadata') OR ($op == 'submit'))) {
$additionalHeadData = $templateMgr->get_template_vars('additionalHeadData');
$additionalHeadData .= $templateMgr->fetch('../plugins/generic/jsonKeywords/jsonKeywordsHeader.tpl');
$templateMgr->assign('additionalHeadData', $additionalHeadData);
}
return false;
}
}
?>