-
Notifications
You must be signed in to change notification settings - Fork 37
/
islandora_video.module
197 lines (187 loc) · 6.31 KB
/
islandora_video.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
<?php
/**
* @file
* Hooks and callbacks for this module.
*/
/**
* Implements hook_menu().
*/
function islandora_video_menu() {
$items = array();
$items['admin/islandora/solution_pack_config/video'] = array(
'title' => 'Video Solution Pack',
'description' => 'Define ingest behavior and select video player.',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_video_admin'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.form.inc',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Implements hook_theme().
*/
function islandora_video_theme($existing, $type, $theme, $path) {
return array(
'islandora_video' => array(
'template' => 'theme/islandora-video',
'file' => 'theme/theme.inc',
'pattern' => 'islandora_video__',
'variables' => array('object' => NULL),
),
);
}
/**
* Implements hook_islandora_required_objects().
*/
function islandora_video_islandora_required_objects(IslandoraTuque $connection) {
$module_path = drupal_get_path('module', 'islandora_video');
// Video Content Model.
$video_content_model = $connection->repository->constructObject('islandora:sp_videoCModel');
$video_content_model->owner = 'fedoraAdmin';
$video_content_model->label = 'Islandora Video Content Model';
$video_content_model->models = 'fedora-system:ContentModel-3.0';
// DS-COMPOSITE-MODEL Datastream.
$datastream = $video_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'X');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'application/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_video_ds_composite_model.xml", FALSE);
$video_content_model->ingestDatastream($datastream);
// Video Collection.
$video_collection = $connection->repository->constructObject('islandora:video_collection');
$video_collection->owner = 'fedoraAdmin';
$video_collection->label = 'Video Collection';
$video_collection->models = 'islandora:collectionCModel';
$video_collection->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:root');
// Collection Policy Datastream.
$datastream = $video_collection->constructDatastream('COLLECTION_POLICY', 'X');
$datastream->label = 'Collection policy';
$datastream->mimetype = 'application/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_video_collection_policy.xml", FALSE);
$video_collection->ingestDatastream($datastream);
// TN Datastream.
$datastream = $video_collection->constructDatastream('TN', 'M');
$datastream->label = 'Thumbnail';
$datastream->mimetype = 'image/png';
$datastream->setContentFromFile("$module_path/images/folder.png", FALSE);
$video_collection->ingestDatastream($datastream);
return array(
'islandora_video' => array(
'title' => 'Islandora Video',
'objects' => array(
$video_content_model,
$video_collection,
),
),
);
}
/**
* Implements hook_xml_form_builder_forms().
*/
function islandora_video_xml_form_builder_forms() {
$module_path = drupal_get_path('module', 'islandora_video');
return array(
'Video MODS form' => array(
'form_file' => "$module_path/xml/islandora_video_form_mods.xml",
),
);
}
/**
* Implements hook_xml_form_builder_form_associations().
*/
function islandora_video_xml_form_builder_form_associations() {
return array(
'islandora_video_mods_form' => array(
'content_model' => 'islandora:sp_videoCModel',
'form_name' => 'Video 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_CMODEL_PID_islandora_view_object().
*/
function islandora_video_islandora_sp_videocmodel_islandora_view_object($object, $page_number, $page_size) {
$output = theme('islandora_video', array('object' => $object));
return array('' => $output);
}
/**
* Implements hook_islandora_ingest_steps().
*/
function islandora_video_islandora_sp_videocmodel_islandora_ingest_steps() {
return array(
'islandora_video_upload' => array(
'weight' => 10,
'type' => 'form',
'form_id' => 'islandora_video_upload_form',
'module' => 'islandora_video',
'file' => 'includes/video_upload.form.inc',
),
);
}
/**
* Implements hook_islandora_CMODEL_PID_derivative().
*/
function islandora_video_islandora_sp_videocmodel_islandora_derivative() {
$derivatives = array();
if (variable_get('islandora_video_make_thumbnail_locally', TRUE)) {
$derivatives[] = array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'TN',
'weight' => '0',
'function' => array(
'islandora_video_create_thumbnail',
),
'file' => drupal_get_path('module', 'islandora_video') . '/includes/derivatives.inc',
);
}
if (variable_get('islandora_video_make_mp4_locally', TRUE)) {
$derivatives[] = array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'MP4',
'weight' => '1',
'function' => array(
'islandora_video_create_mp4',
),
'file' => drupal_get_path('module', 'islandora_video') . '/includes/derivatives.inc',
);
}
if (variable_get('islandora_video_make_ogg_locally', FALSE)) {
$derivatives[] = array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'OGG',
'weight' => '2',
'function' => array(
'islandora_video_create_ogg',
),
'file' => drupal_get_path('module', 'islandora_video') . '/includes/derivatives.inc',
);
}
if (variable_get('islandora_video_make_archive', TRUE)) {
$derivatives[] = array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'MKV',
'weight' => '3',
'function' => array(
'islandora_video_create_mkv',
),
'file' => drupal_get_path('module', 'islandora_video') . '/includes/derivatives.inc',
);
}
return $derivatives;
}
/**
* Implements hook_file_mimetype_mapping_alter().
*/
function islandora_video_file_mimetype_mapping_alter(&$mapping) {
// Make sure the mapping is sensible for video/mp4 by removing
// it from array and adding it to end so it has priority.
$code = $mapping['extensions']['mp4'];
unset($mapping['extensions']['mp4']);
$mapping['extensions']['mp4'] = $code;
}