-
Notifications
You must be signed in to change notification settings - Fork 8
/
islandora_relationship_editor.module
201 lines (185 loc) · 8.69 KB
/
islandora_relationship_editor.module
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
/**
* @file
*
*/
// Namespace for adding relationships
define('MYNS_URI', 'http://islandora.ca/BDH/RELS/temp/');
/**
* Implements hook_menu().
*/
function islandora_relationship_editor_menu() {
$items['islandora/object/%/manage/relationships'] = array(
'title' => 'Relationships',
'description' => 'Add, remove, or validate related objects',
'file' => 'Main.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_relationship_editor_display_relationships', 2),
'access arguments' => array(ISLANDORA_METADATA_EDIT),
'type' => MENU_LOCAL_TASK,
);
$items['islandora/object/%/manage/relationships/add'] = array(
'title' => t('Add relationships'),
'description' => t('Add a new related object'),
'file' => 'Add.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_relationship_editor_add_relationships', 2),
'access arguments' => array(ISLANDORA_METADATA_EDIT),
'type' => MENU_LOCAL_ACTION,
);
$items['islandora/object/%/manage/relationships/delete/%/%/%'] = array(
'title' => t('Delete relationship'),
'description' => t('Delete a relationship'),
'file' => 'Delete.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_relationship_editor_delete_relationships', 2, 6, 7, 8),
'access arguments' => array(ISLANDORA_METADATA_EDIT),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements hook_theme().
*/
function islandora_relationship_editor_theme() {
return array(
'relationship_editor_table' => array(
'variables' => array('relationships' => NULL),
'template' => 'relationship-editor-table',
'path' => drupal_get_path('module', 'islandora_relationship_editor') . '/theme',
),
'islandora_relationship_editor_related_objects' => array(
'variables' => array('islandora_object' => NULL),
'template' => 'theme/related-objects',
'file' => 'theme/related_objects.theme.inc',
),
);
}
/**
* Creates the delete menu path for a relationship.
*/
function islandora_relationship_editor_get_delete_path($object_pid, $namespace, $relationship, $target_pid) {
$namespace = $namespace ? urlencode($namespace) : 'NULL';
$relationship = $relationship ? urlencode($relationship) : 'NULL';
$target_pid = $target_pid ? $target_pid : 'NULL';
return 'islandora/object/' . $object_pid . '/manage/relationships/delete/' . $namespace . '/' . $relationship . '/' . $target_pid;
}
/**
* Returns the list of relationships that can be added to this object.
*
* @param string $object_pid
* the Fedora pid of the object to which the relationship will apply.
*/
function get_possible_relationships($object_pid) {
$object = islandora_object_load($object_pid);
if (!$object) {
return array();
}
$options = array();
if (in_array('islandora:sp_basic_image', $object->models) or in_array('islandora:sp_large_image_cmodel', $object->models)) {
$options['CIDOC:P138_represents'] = t('represents (is an image or video of) [two-way]');
}
if (in_array('islandora:personCModel', $object->models)) {
$options['tempHasStyle'] = t('has Fiddling Style');
$options['CIDOC:P107i_is_current_or_former_member_of'] = t('is member of group');
//$options['CIDOC:P138i_has_representation'] = t('has representation (is in image) [two-way]');
$options['hasRepresentativeImage'] = t('has featured image');
//$options['isSpeakerIn'] = t('is the main speaking voice in in [Deprecated!]');
//$options['isFiddlerIn'] = t('is the main fiddler in [Deprecated!]');
//$options['tempAuthored'] = t('Authored (tune)');
}
if (in_array('islandora:BDHTuneCModel', $object->models)) {
$options['tempHasAuthor'] = t('has Author');
$options['isVariantOf'] = t('is a variant of (tune) [two-way]');
$options['hasVariant'] = t('has a variant (tune) [two-way]');
//$options['FRBROO:R3_is_realised_in'] = t('is realised (notated) in [two-way]'); // namespace FRBROO
$options['R3xi_variant-is_realised_in'] = t('has a variant that is realised (notated) in [two-way]'); // namespace FRBROO
//$options['is_incorporated_in'] = t('is incorporated in recording [two-way]'); // namespace TEMP
$options['variantIsIncorporatedIn'] = t('has a variant that is incorporated in recording [two-way]'); // namespace TEMP
}
if (in_array('bdh:audioSnippetCModel', $object->models) or in_array('islandora:sp-audioCModel', $object->models)) {
$options['hasMainMusician'] = t('has main musician');
$options['hasAccompanist'] = t('has second fiddler');
$options['incorporates'] = t('incorporates (tune)');
$options['incorporatesVariantOf'] = t('incorporates ("parent" tune)');
$options['hasSpeaker'] = t('has speaker (person)');
}
if (in_array('bdh:videoSnippetCModel', $object->models)) {
$options['hasMainMusician'] = t('has main musician');
$options['hasAccompanist'] = t('has second fiddler');
$options['incorporates'] = t('incorporates (tune)');
$options['incorporatesVariantOf'] = t('incorporates ("parent" tune)');
$options['hasSpeaker'] = t('has speaker (person).');
}
if (in_array('islandora:BDHNotationCModel', $object->models)) {
$options['FRBROO:R3i_realises'] = t('is notation for (tune or tune version)');
$options['R3xi_realises_variant_of'] = t('is notation for variant of (parent tune)');
}
if (in_array('islandora:organizationCModel', $object->models)) {
$options['CIDOC:P107_has_current_or_former_member'] = t('has current or former group member');
}
return $options;
}
/**
* Returns the list of relationships that can point to this object.
*
* @param string $object_pid
* the Fedora pid of the object to which the relationship will apply.
*/
function get_possible_reverse_relationships($object_pid) {
$object = islandora_object_load($object_pid);
if (!$object) {
return array();
}
$options = array();
if (in_array('islandora:sp_basic_image', $object->models) or in_array('islandora:sp_large_image_cmodel', $object->models)) {
$options['CIDOC:P138i_has_representation'] = t('has representation (is depicted in)');
}
if (in_array('islandora:personCModel', $object->models)) {
$options['tempHasAuthor'] = t('has Author');
$options['CIDOC:P138_represents'] = t('represents (is an image or video of)');
$options['CIDOC:P107_has_current_or_former_member'] = t('has current or former group member');
$options['hasMainMusician'] = t('has main musician');
$options['hasAccompanist'] = t('has second fiddler');
$options['hasSpeaker'] = t('has speaker (person)');
}
if (in_array('islandora:BDHTuneCModel', $object->models)) {
$options['tempAuthored'] = t('Authored');
$options['isVariantOf'] = t('is a variant of (tune)');
$options['hasVariant'] = t('has a variant (tune)');
$options['FRBROO:R3i_realises'] = t('is notation for (tune or tune version)');
$options['R3xi_realises_variant_of'] = t('is notation for variant of (parent tune)');
$options['incorporates'] = t('incorporates (tune)');
$options['incorporatesVariantOf'] = t('incorporates ("parent" tune)');
}
if (in_array('bdh:audioSnippetCModel', $object->models)) {
$options['isSpeakerIn'] = t('is the main fiddler in [Deprecated!]');
$options['is_incorporated_in'] = t('is incorporated in recording [Deprecated!]'); // namespace TEMP
$options['variantIsIncorporatedIn'] = t('has a variant that is incorporated in recording [Deprecated!]'); // namespace TEMP
}
if (in_array('bdh:videoSnippetCModel', $object->models)) {
$options['isSpeakerIn'] = t('is the main fiddler in [Deprecated!]');
$options['is_incorporated_in'] = t('is incorporated in recording [Deprecated!]'); // namespace TEMP
$options['variantIsIncorporatedIn'] = t('has a variant that is incorporated in recording [Deprecated!]'); // namespace TEMP
}
if (in_array('islandora:organizationCModel', $object->models)) {
$options['CIDOC:P107i_is_current_or_former_member'] = t('is member of group');
$options['CIDOC:P138_represents'] = t('represents (is an image or video of)');
}
if (in_array('islandora:BDHNotationCModel', $object->models)) {
$options['FRBROO:R3_is_realised_in'] = t('is realised (notated) in'); // namespace FRBROO
$options['R3xi_variant-is_realised_in'] = t('has a variant that is realised (notated) in'); // namespace FRBROO
}
return $options;
}
/**
* Implements hook_islandora_view_object().
*/
function islandora_relationship_editor_islandora_view_object($object, $page_number, $page_size) {
return NULL;
$output = theme('islandora_relationship_editor_related_objects', array('islandora_object' => $object));
return array('Related objects' => $output);
}
function islandora_relationships_switch_callback($form, &$form_state) {
return $form['target'];
}