-
Notifications
You must be signed in to change notification settings - Fork 1
/
islandora_json_to_list_viewer.module
executable file
·63 lines (59 loc) · 1.69 KB
/
islandora_json_to_list_viewer.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
<?php
/**
* @file
* @author: William Panting
* This is the global code for islandora_json_to_list_viewer
*/
/**
* This function is the hook into the 'islandora viewer sphere' it reports that
* this module can handle the JSON mime type and the theme function to call
* to use it.
*
* @param string $mime_type
* The mime_type that is being queried for
*
* @return mixed
* array: 'application/json'=>'islandora_JSON_to_list'
* string : 'islandora_JSON_to_list'
*/
function islandora_json_to_list_viewer_islandora_viewers($mime_type = NULL) {
if ($mime_type == NULL) {
return array('application/json' => 'islandora_JSON_to_list');
}
elseif ($mime_type == 'application/json') {
return 'islandora_JSON_to_list';
}
}
/**
* This function makes available the islandora_JSON_to_list theme.
* The theme will display an HTML unordered list
*
* @return array
* the themes available from this module
*/
function islandora_json_to_list_viewer_theme() {
return array(
'islandora_JSON_to_list' => array(
'arguments' => array(
'pid' => NULL,
'dsid' => 'SWF',
),
'template' => 'islandora_JSON_to_list',
),
);
}
/**
* This is a preprocessor function that
* will prepare to display JSON data as an HTML list
*
* It will take the JSON and format as a nested array
* in preparation for themeing.
*
* @param array $vars
* The variables to prepare for themeing
*/
function islandora_json_to_list_viewer_preprocess_islandora_JSON_to_list(&$vars) {
module_load_include('inc', 'fedora_repository', 'api/tuque');
$Fedora_object = islandora_object_load($vars['pid']);
$vars['JSON_datastream'] = json_decode($Fedora_object[$vars['dsid']]->content);
}