forked from discoverygarden/sfudora
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sfudora.module
182 lines (169 loc) · 5.8 KB
/
sfudora.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
<?php
/**
* @file
* Module used to house customizations for Simon Fraser University.
*/
define('SFUDORA_INGEST_PATH', 'sfudora/ingest');
define('SFUDORA_XACML_FOLDER', '/xacml');
define('SFUDORA_AJXP_URI', 'http://ajaxplorer.info#');
define('SFUDORA_AJXP_FRAME', 'sfudora/ajaxplorer');
/**
* Implements hook_menu().
*/
function sfudora_menu() {
$items = array();
$items[SFUDORA_INGEST_PATH] = array(
'title' => 'Ingest',
'access callback' => 'sfudora_ajaxplorer_access_callback',
'page callback' => 'sfudora_ajaxplorer_ingest',
'file' => 'includes/ajaxplorer_ingest.inc',
'type' => MENU_CALLBACK,
);
$items[SFUDORA_AJXP_FRAME] = array(
'title' => 'AjaXplorer',
'access callback' => 'sfudora_ajaxplorer_access_callback',
'page callback' => 'sfudora_ajaxplorer_frame',
'file' => 'includes/iframe.inc',
'type' => MENU_NORMAL_ITEM,
);
$items['admin/islandora/sfudora'] = array(
'title' => 'Simon Fraser University Settings',
'description' => 'Configure settings for the sfudora module.',
'page callback' => 'drupal_get_form',
'page arguments' => array('sfudora_admin_form'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.form.inc',
);
return $items;
}
/**
* Implements hook_islandora_required_objects().
*/
function sfudora_islandora_required_objects(IslandoraTuque $connection) {
$module_path = drupal_get_path('module', 'sfudora');
// SFU Generic Content Model.
$generic_cmodel = $connection->repository->constructObject('sfu:genericCModel');
$generic_cmodel->owner = 'fedoraAdmin';
$generic_cmodel->label = 'Islandora Miscellaneous File Format Content Model';
$generic_cmodel->models = 'fedora-system:ContentModel-3.0';
$datastream = $generic_cmodel->constructDatastream('DS-COMPOSITE-MODEL', 'X');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/data/datastreams/generic_CModel/DS-COMPOSITE-MODEL.xml", FALSE);
$generic_cmodel->ingestDatastream($datastream);
return array(
'sfudora' => array(
'title' => 'Simon Fraser University',
'objects' => array(
$generic_cmodel,
),
),
);
}
/**
* Menu access callback.
*/
function sfudora_ajaxplorer_access_callback() {
global $user;
$object = islandora_object_load(variable_get('sfudora_repository_pid', 'islandora:44'));
return in_array('authenticated user', $user->roles) && islandora_object_access(ISLANDORA_INGEST, $object, $user);
}
/**
* Implements hook_islandora_xml_form_builder_forms().
*/
function sfudora_islandora_xml_form_builder_forms() {
$module_path = drupal_get_path('module', 'sfudora');
return array(
'SFU DDI form' => array(
'form_file' => "$module_path/xml/DDI_final.xml",
),
);
}
/**
* Implements hook_islandora_content_model_forms_form_associations().
*/
function sfudora_islandora_content_model_forms_form_associations() {
return array(
'sfudora_generic_form' => array(
'content_model' => 'islandora:binaryObjectCModel',
'form_name' => 'SFU DDI form',
'dsid' => 'DDI',
'title_field' => array('stdyDscr', 'citation', 'titlStmt', 'titl'),
'transform' => 'ddi_to_dc.xsl',
'self_transform' => 'cleanup_ddi.xsl',
'template' => FALSE,
),
'sfudora_basic_image_form' => array(
'content_model' => 'islandora:sp_basic_image',
'form_name' => 'SFU DDI form',
'dsid' => 'DDI',
'title_field' => array('stdyDscr', 'citation', 'titlStmt', 'titl'),
'transform' => 'ddi_to_dc.xsl',
'self_transform' => 'cleanup_ddi.xsl',
'template' => FALSE,
),
'sfudora_large_image_form' => array(
'content_model' => 'islandora:sp_large_image_cmodel',
'form_name' => 'SFU DDI form',
'dsid' => 'DDI',
'title_field' => array('stdyDscr', 'citation', 'titlStmt', 'titl'),
'transform' => 'ddi_to_dc.xsl',
'self_transform' => 'cleanup_ddi.xsl',
'template' => FALSE,
),
'sfudora_pdf_form' => array(
'content_model' => 'islandora:sp_pdf',
'form_name' => 'SFU DDI form',
'dsid' => 'DDI',
'title_field' => array('stdyDscr', 'citation', 'titlStmt', 'titl'),
'transform' => 'ddi_to_dc.xsl',
'self_transform' => 'cleanup_ddi.xsl',
'template' => FALSE,
),
'sfudora_video_form' => array(
'content_model' => 'islandora:sp_videoCModel',
'form_name' => 'SFU DDI form',
'dsid' => 'DDI',
'title_field' => array('stdyDscr', 'citation', 'titlStmt', 'titl'),
'transform' => 'ddi_to_dc.xsl',
'self_transform' => 'cleanup_ddi.xsl',
'template' => FALSE,
),
'sfudora_audio_form' => array(
'content_model' => 'islandora:sp-audioCModel',
'form_name' => 'SFU DDI form',
'dsid' => 'DDI',
'title_field' => array('stdyDscr', 'citation', 'titlStmt', 'titl'),
'transform' => 'ddi_to_dc.xsl',
'self_transform' => 'cleanup_ddi.xsl',
'template' => FALSE,
),
'sfudora_data_form' => array(
'content_model' => 'islandora:sp_data',
'form_name' => 'SFU DDI form',
'dsid' => 'DDI',
'title_field' => array('stdyDscr', 'citation', 'titlStmt', 'titl'),
'transform' => 'ddi_to_dc.xsl',
'self_transform' => 'cleanup_ddi.xsl',
'template' => FALSE,
),
);
}
/**
* Implements hook_islandora_xml_form_builder_get_transforms().
*/
function sfudora_islandora_xml_form_builder_get_transforms() {
$module_path = drupal_get_path('module', 'sfudora');
return array(
'ddi_to_dc.xsl' => "$module_path/xml/ddi_to_dc.xsl",
);
}
/**
* Implements hook_xml_form_builder_get_self_transforms().
*/
function sfudora_xml_form_builder_get_self_transforms() {
$module_path = drupal_get_path('module', 'sfudora');
return array(
'cleanup_ddi.xsl' => "$module_path/xml/cleanup_ddi.xsl",
);
}