-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREDIBPlugin.inc.php
70 lines (60 loc) · 1.92 KB
/
REDIBPlugin.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
65
66
67
68
69
70
<?php
/**
* @file plugins/generic/REDIB/REDIBPlugin.inc.php
*
* Distributed under the GNU GPL v2. For full terms see the file LICENSE.txt
*
* @class REDIBPlugin
* @ingroup plugins_generic_REDIB
*
* @brief REDIB plugin class
*/
import('lib.pkp.classes.plugins.GenericPlugin');
class REDIBPlugin extends GenericPlugin {
/**
* Called as a plugin is registered to the registry
* @param $category String Name of category plugin was registered to
* @return boolean True if plugin initialized successfully; if false,
* the plugin will not be registered.
*/
function register($category, $path) {
$success = parent::register($category, $path);
//$this->addLocaleData();
if ($success && $this->getEnabled()) {
// Change Dc11Desctiption -- include REDIB references
HookRegistry::register('Dc11SchemaArticleAdapter::extractMetadataFromDataObject', array($this, 'changeDc11Description'));
}
return $success;
}
function getDisplayName() {
return 'REDIB Plugin';
}
function getDescription() {
return 'Add REDIB bibliographic references to DC11 metadata';
}
/**
* Change Dc11 Description to consider the OpenAIRE elements
*/
function changeDc11Description($hookName, $params) {
$adapter =& $params[0];
$article = $params[1];
$journal = $params[2];
$issue = $params[3];
$dc11Description =& $params[4];
if ($article->getCitations()!='') {
$references = preg_replace("/((\r\n)|\r\n)/", "-JUMP-", $article->getCitations());
$reference = preg_split("/(-JUMP-)+\s*(-JUMP-)+/", $references);
foreach($reference as $value) {
$value = trim($value);
$value = str_replace("-JUMP-", " ", $value);
$value = preg_replace("/^(\(\s*[0-9]*\s*\)|\[\s*[0-9]*\s*\]|[0-9]*\s*\.|[0-9]*\s*\))\s*/", "", $value);
if (!preg_match("/^(http.*|<a\s+href.*)/", $value)) {
$relation = '/*ref*/' . $value;
$dc11Description->addStatement('dc:relation', $relation);
}
}
}
return false;
}
}
?>