-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathislandora_binary_object.module
170 lines (162 loc) · 5.85 KB
/
islandora_binary_object.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
<?php
/**
* @file
* Handles the creation and display of binary_object Islandora objects.
*/
/**
* Implements hook_menu().
*/
function islandora_binary_object_menu() {
$items = array();
$items['admin/islandora/tools/binary-object-storage'] = array(
'title' => 'Binary Object Collection',
'description' => 'Configure settings for Islandora Binary Object',
'access arguments' => array('administer site configuration'),
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_binary_object_admin'),
'file' => 'includes/admin.inc',
);
$items['admin/islandora/tools/binary-object-storage/delete-association/%'] = array(
'title' => 'Delete Binary Object Association',
'description' => 'Confirm form for deleting a thumbnail association',
'access arguments' => array('administer site configuration'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'islandora_binary_object_delete_association_form',
4,
5,
),
'file' => 'includes/admin.inc',
);
return $items;
}
/**
* Implements hook_theme().
*/
function islandora_binary_object_theme($existing, $type, $theme, $path) {
return array(
'islandora_binary_object' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-binary-object',
'pattern' => 'islandora_binary_object__',
'variables' => array('islandora_object' => NULL),
),
);
}
/**
* Implements hook_islandora_required_objects().
*/
function islandora_binary_object_islandora_required_objects(IslandoraTuque $connection) {
$module_path = drupal_get_path('module', 'islandora_binary_object');
$islandora_path = drupal_get_path('module', 'islandora');
// Binary Object Content Model.
$binary_object_content_model = $connection->repository->constructObject('islandora:binaryObjectCModel');
$binary_object_content_model->owner = 'fedoraAdmin';
$binary_object_content_model->label = 'Islandora Binary Object Content Model';
$binary_object_content_model->models = 'fedora-system:ContentModel-3.0';
// DS-COMPOSITE-MODEL Datastream.
$datastream = $binary_object_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'X');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_binary_object_ds_composite_model.xml", FALSE);
$binary_object_content_model->ingestDatastream($datastream);
// Image Collection.
$binary_object_collection = $connection->repository->constructObject('islandora:binary_object_collection');
$binary_object_collection->owner = 'fedoraAdmin';
$binary_object_collection->label = 'Binary Object Collection';
$binary_object_collection->models = 'islandora:collectionCModel';
$binary_object_collection->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:root');
// Collection Policy Datastream.
$datastream = $binary_object_collection->constructDatastream('COLLECTION_POLICY', 'X');
$datastream->label = 'Collection policy';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_binary_object_collection_policy.xml", FALSE);
$binary_object_collection->ingestDatastream($datastream);
// TN Datastream.
$datastream = $binary_object_collection->constructDatastream('TN', 'M');
$datastream->label = 'Thumbnail';
$datastream->mimetype = 'image/png';
$datastream->setContentFromFile("$islandora_path/images/folder.png", FALSE);
$binary_object_collection->ingestDatastream($datastream);
return array(
'islandora_binary_object' => array(
'title' => 'Islandora Binary Object',
'objects' => array(
$binary_object_content_model,
$binary_object_collection,
),
),
);
}
/**
* Implements hook_xml_form_builder_form_associations().
*/
function islandora_binary_object_xml_form_builder_form_associations() {
return array(
'islandora_binary_object_mods_form' => array(
'content_model' => 'islandora:binaryObjectCModel',
'form_name' => 'Binary Object MODS form',
'dsid' => 'MODS',
'title_field' => array('titleInfo', 'title'),
'transform' => 'mods_to_dc.xsl',
'self_transform' => 'islandora_cleanup_mods_extended.xsl',
'template' => FALSE,
),
);
}
/**
* Implements hook_xml_form_builder_forms().
*/
function islandora_binary_object_xml_form_builder_forms() {
$module_path = drupal_get_path('module', 'islandora_binary_object');
return array(
'Binary Object MODS form' => array(
'form_file' => "$module_path/xml/islandora_binary_object_form_mods.xml",
),
);
}
/**
* Implements hook_islandora_ingest_steps().
*/
function islandora_binary_object_islandora_binaryObjectCModel_islandora_ingest_steps() {
return array(
'islandora_binary_object' => array(
'weight' => 10,
'type' => 'form',
'form_id' => 'islandora_binary_object_upload_form',
'module' => 'islandora_binary_object',
'file' => 'includes/binary_object_upload.form.inc',
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
*/
function islandora_binary_object_islandora_binaryObjectCModel_islandora_view_object(AbstractObject $object) {
return array(
// XXX: Because islandora_as_renderable_array isn't the best we are going to
// wrap this in an array.
'' => array(
array(
'#theme' => 'islandora_binary_object',
'#islandora_object' => $object,
),
),
);
}
/**
* Implements hook_islandora_CMODEL_PID_derivative().
*/
function islandora_binary_object_islandora_binaryObjectCModel_islandora_derivative() {
return array(
array(
'source_dsid' => NULL,
'destination_dsid' => 'TN',
'weight' => '0',
'function' => array(
'islandora_binary_object_create_thumbnail',
),
'file' => drupal_get_path('module', 'islandora_binary_object') . '/includes/derivatives.inc',
),
);
}