This repository was archived by the owner on Nov 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKudlIdentityClientPlugin.php
More file actions
74 lines (64 loc) · 2.13 KB
/
KudlIdentityClientPlugin.php
File metadata and controls
74 lines (64 loc) · 2.13 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
<?php
/**
* Kudl Identity Client
*
* @copyright 2015 MLE Slone <m.slone@gmail.com>
* @license http://opensource.org/licenses/MIT MIT
* @package Omeka\Plugins\Kudl IdentityClient
*/
class KudlIdentityClientPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array(
'install',
'config_form',
'config',
'uninstall',
);
protected $_filters = array(
'ensureCollectionIdentifier' => array('Save', 'Item', 'Item Type Metadata', 'Collection ARK Identifier'),
'ensureSeriesIdentifier' => array('Save', 'Item', 'Item Type Metadata', 'Series ARK Identifier'),
'ensureInterviewIdentifier' => array('Save', 'Item', 'Item Type Metadata', 'Interview ARK Identifier'),
);
public function hookInstall()
{
$config = parse_ini_file(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.ini');
set_option('kudl_identity_library_path', $config['kudl_identity_library_path']);
}
public function hookUninstall()
{
delete_option('kudl_identity_library_path');
}
public function hookConfig($args)
{
set_option('kudl_identity_library_path', trim($args['post']['kudl_identity_library_path']));
}
public function hookConfigForm()
{
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config_form.php';
}
public function ensureIdentifier($text, $args)
{
if ($text === "") {
define('DS', DIRECTORY_SEPARATOR);
$path = get_option('kudl_identity_library_path');
require_once($path . DS . 'lib' . DS . 'Minter.php');
$minter = new Minter($path . DS . 'config' . DS . 'connection.ini');
return $minter->mint();
}
else {
return $text;
}
}
public function ensureCollectionIdentifier($text, $args)
{
return $this->ensureIdentifier($text, $args);
}
public function ensureSeriesIdentifier($text, $args)
{
return $this->ensureIdentifier($text, $args);
}
public function ensureInterviewIdentifier($text, $args)
{
return $this->ensureIdentifier($text, $args);
}
}