forked from Islandora/islandora_solution_pack_video
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme.inc
90 lines (82 loc) · 3.12 KB
/
theme.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* @file
* Theme hooks.
*/
/**
* Implements template_preprocess_HOOK().
*/
function template_preprocess_islandora_video(array &$variables) {
module_load_include('inc', 'islandora', 'includes/datastream');
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora', 'includes/solution_packs');
module_load_include('inc', 'islandora', 'includes/authtokens');
module_load_include('inc', 'islandora', 'includes/metadata');
drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js');
$object = $variables['object'];
$repository = $object->repository;
// We should eventually remove the DC object and dc_array code as it only
// exists to not break legacy implementations.
try {
if (isset($object['DC']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object['DC'])) {
$dc = $object['DC']->content;
$dc_object = DublinCore::importFromXmlString($dc);
}
}
catch (Exception $e) {
drupal_set_message(t('Error retriveing object %s %t', array('%s' => $object->id, '%t' => $e->getMessage())), 'error', FALSE);
}
$variables['islandora_dublin_core'] = isset($dc_object) ? $dc_object : NULL;
$variables['dc_array'] = isset($dc_object) ? $dc_object->asArray() : array();
$variables['islandora_object_label'] = $object->label;
$variables['theme_hook_suggestions'][] = 'islandora_video__' . str_replace(':', '_', $object->id);
$variables['parent_collections'] = islandora_get_parents_from_rels_ext($object);
$variables['metadata'] = islandora_retrieve_metadata_markup($object);
$variables['description'] = islandora_retrieve_description_markup($object);
$viewer_dsid = 'MP4';
if (!$object['MP4']) {
if (variable_get('islandora_video_play_obj', TRUE)) {
if ($object['OBJ'] && $object['OBJ']->mimetype == 'video/mp4') {
$max_file_size = ((int) variable_get('islandora_video_max_obj_size', 500)) * 1024 * 1024;
if ($object['OBJ']->size < $max_file_size) {
$viewer_dsid = 'OBJ';
}
}
}
}
$mime = 'video/mp4';
if (isset($object['PEAKS'])) {
$peaks_url = url("islandora/object/{$object->id}/datastream/PEAKS", array('absolute' => TRUE));
}
else {
$peaks_url = null;
}
$video_params = array(
'pid' => $object->id,
);
// Video player.
if (isset($object[$viewer_dsid]) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$viewer_dsid])) {
$video_url = url("islandora/object/{$object->id}/datastream/$viewer_dsid/view");
$video_params += array(
'mime' => $mime,
'url' => $video_url,
'peaks' => $peaks_url,
);
}
// Thumbnail.
if (isset($object['TN']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object['TN'])) {
$video_params += array(
'tn' => url("islandora/object/{$object->id}/datastream/TN/view", array('absolute' => TRUE)),
);
}
$viewer = islandora_get_viewer($video_params, 'islandora_video_viewers', $object);
$variables['islandora_content'] = '';
if ($viewer) {
$variables['islandora_content'] = $viewer;
}
else {
$variables['islandora_content'] = NULL;
}
return array('' => $viewer);
}