-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRequiredMetadataPlugin.php
More file actions
52 lines (46 loc) · 1.59 KB
/
RequiredMetadataPlugin.php
File metadata and controls
52 lines (46 loc) · 1.59 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
<?php
class RequiredMetadataPlugin extends Omeka_Plugin_AbstractPlugin
{
protected $_hooks = array(
'before_save_item'
);
protected $_filters = array(
//'requiredItemValidator' => array('Validate', 'Item', 'CAVPP_PB Core', 'Institution'),
//'itemTitleLengthValidator' => array('Validate', 'Item', 'CAVPP _PBCore', 'Title'),
//'requiredItemValidator' => array('Validate', 'Item', 'CAVPP_PB Core', 'Date Created'),
//'itemTitleLengthValidator' => array('Validate', 'Item', 'Dublin Core', 'Title'),
//'itemTitleLengthValidator' => array('Validate', 'Item', 'Dublin Core', 'Subject'),
//'requiredItemValidator' => array('Validate', 'Item', 'Dublin C ore', 'Title'),
//'addIsbnToDCId'=>array('Save', 'Item', 'Dublin Core', 'Identifie r'),
);
public function hookBeforeSaveItem($args)
{
$item = $args['record'];
$title = metadata($item, array('Dublin Core', 'Title'));
if(empty($title)) {
$item->addError("DC Title", 'DC Title cannot be empty!');
}
}
public function itemTitleLengthValidator($isValid, $args)
{
$text = $args['text'];
if(strlen($text) < 10 ) {
return false;
}
return true;
}
public function requiredItemValidator($isValid, $args)
{
$text = $args['text'];
if(!isset($text) || $text == null || $text == false) {
return false;
}
return true;
}
/******
public function addIsbnToDCId($text, $args)
{
return "ISBN: $text";
}
*******/
}