-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfedora_object_functions.inc
68 lines (64 loc) · 1.75 KB
/
fedora_object_functions.inc
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
<?php
/**
* @file
* This file should hold object level helper functions.
*/
/**
* This code was being used allot in the module for feedback to the user
* so it has been pulled out into a utility function. It will send a
* drupal_set_message with the object's label, PID and the message supplied.
* This is more about insuring a consistent UI than clean code.
*
* @TODO
* Provide a link to the object in the message.
*
* @param string $PID
* The Fedora PID of the object to write the Drupal message about.
* @param string $message
* Please include the appropriate ending punctuation.
* @param string $label
* Defaults to NULL, if it is not set the function will try and get the
* object's label.
*/
function islandora_workflow_DSM_about_object($PID, $message, $label = NULL) {
// Set $label if it is not supplied.
if (is_null($label)) {
$label = islandora_workflow_get_object_label($PID);
if (!$label) {
$label = '';
}
}
// Send the drupal_set_message
drupal_set_message(
t('The object %label (%PID) %message',
array(
'%label' => $label,
'%PID' => $PID,
'%message' => $message,
)
)
);
}
/**
* Get the label for a Fedora object with a given PID.
*
* @param string $object_id
* The object to get the label of
*
* @return string $label
* The label of the object specified.
*
* @return boolean
* FALSE if the Fedora item does not exist.
*/
function islandora_workflow_get_object_label($object_id) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($object_id);
if (!$item->exists()) {
return FALSE;
}
if (!isset($item->objectProfile->objLabel)) {
return '';
}
return $item->objectProfile->objLabel;
}