-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCAVPP_MD_MinimalElementSetPlugin.php
More file actions
88 lines (76 loc) · 2.26 KB
/
CAVPP_MD_MinimalElementSetPlugin.php
File metadata and controls
88 lines (76 loc) · 2.26 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
<?php
/**
* CAVPP PBCore Minimal Descriptive Metadata Element Set plugin
*
* Creates a custom minimal element set for
* California Audiovisual Preservation Project based on
* PBCore (Public Broadcasting Metadata Dictionary),
* a standard for digitalized documents (see http://pbcore.org).
*
* copyright LibraryHost, 2014
* Based on PBCore Element Set by Pop Up Archive, 2012
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*/
/**
* The CAVPP PBCore Minimal Descriptive Metadata Element Set plugin.
* @package Omeka\Plugins\CAVPP_PBCoreElementSet
*/
class CAVPP_MD_MinimalElementSetPlugin extends Omeka_Plugin_AbstractPlugin
{
private $_elementSetName = 'Minimal Descriptive Metadata';
/**
* @var array Hooks for the plugin.
*/
protected $_hooks = array(
'install',
'uninstall',
'after_save_item'
);
/**
* Install the plugin.
*/
public function hookInstall()
{
$this->_installOptions();
// Load elements to add.
require_once('elements.php');
// Don't install if an element set already exists.
if ($this->_getElementSet($this->_elementSetName)) {
throw new Omeka_Plugin_Installer_Exception('An element set by the name "' . $this->_elementSetName . '" already exists. You must delete that element set to install this plugin.');
}
insert_element_set($elementSetMetadata, $elements);
}
/**
* Uninstall the plugin.
*/
public function hookUninstall()
{
$this->_deleteElementSet($this->_elementSetName);
$this->_uninstallOptions();
}
/**
* Saves the metadata
*/
public function hookAfterSaveItem($args)
{
$post = $args['post'];
$item = $args['record'];
}
private function _getElementSet($elementSetName)
{
return $this->_db
->getTable('ElementSet')
->findByName($elementSetName);
}
private function _deleteElementSet($elementSetName)
{
$elementSet = $this->_getElementSet($elementSetName);
if ($elementSet) {
$elements = $elementSet->getElements();
foreach ($elements as $element) {
$element->delete();
}
$elementSet->delete();
}
}
}