-
Notifications
You must be signed in to change notification settings - Fork 57
/
islandora_scholar.module
327 lines (304 loc) · 11.8 KB
/
islandora_scholar.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?php
/**
* @file
* The islandora_scholar moudule.
*/
/**
* Implements hook_menu().
*/
function islandora_scholar_menu() {
return array(
'admin/islandora/solution_pack_config/scholar' => array(
'title' => 'Scholar',
'description' => 'Configure Islandora Scholar settings such as RoMEO and Google Search',
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_scholar_admin_form'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.form.inc',
),
'admin/islandora/solution_pack_config/scholar/base' => array(
'title' => 'Basic Configuration',
'type' => MENU_DEFAULT_LOCAL_TASK,
),
'admin/islandora/solution_pack_config/scholar/xpaths' => array(
'title' => 'XPath Configuration',
'description' => 'Configure Islandora Scholar XPaths',
'type' => MENU_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_scholar_admin_xpath_form'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.form.inc',
),
'admin/islandora/solution_pack_config/scholar/pdf' => array(
'title' => 'PDF Configuration',
'type' => MENU_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_scholar_admin_pdf_form'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.form.inc',
),
'islandora/object/%islandora_object/islandora_scholar_romeo' => array(
'title' => 'RoMEO',
'type' => MENU_LOCAL_TASK,
'page callback' => 'islandora_scholar_romeo_view',
'page arguments' => array(2),
'access callback' => 'islandora_scholar_romeo_access',
'access arguments' => array(2),
'file' => 'includes/romeo.tab.inc',
),
'islandora/object/%islandora_object/islandora_scholar_upload' => array(
'title' => 'Document',
'type' => MENU_LOCAL_TASK,
'page callback' => 'islandora_scholar_upload_view',
'page arguments' => array(2),
'access callback' => 'islandora_scholar_upload_access',
'access arguments' => array(2),
'file' => 'includes/upload.tab.inc',
),
'islandora/object/%islandora_object/islandora_scholar_citation' => array(
'title' => 'Citation',
'type' => MENU_CALLBACK,
'page callback' => 'islandora_scholar_get_citation',
'page arguments' => array(2),
'access callback' => 'islandora_scholar_citation_access',
'access arguments' => array(2),
'file' => 'includes/callbacks.inc',
),
'gs_years' => array(
'title' => 'Scholarly article publications by year',
'page callback' => '_islandora_google_scholar_page_years',
'file' => 'includes/page_callbacks.inc',
'access arguments' => array(
'access content',
),
'type' => MENU_CALLBACK,
),
'gs_updated' => array(
'title' => 'Google Scholar Articles Added/Updated',
'page callback' => '_islandora_google_scholar_updated',
'file' => 'includes/page_callbacks.inc',
'access arguments' => array(
'access content',
),
'type' => MENU_CALLBACK,
),
'gs_year' => array(
'title' => 'Google Scholar Year',
'page callback' => '_islandora_google_scholar_page_year',
'file' => 'includes/page_callbacks.inc',
'access arguments' => array(
'access content',
),
'type' => MENU_CALLBACK,
),
'gs_abstract/%' => array(
'title' => 'Abstract',
'page callback' => '_islandora_google_scholar_abstract',
'page arguments' => array(1),
'file' => 'includes/page_callbacks.inc',
'access arguments' => array(
'access content',
),
'type' => MENU_CALLBACK,
),
);
}
/**
* Implements hook_xml_form_builder_forms().
*/
function islandora_scholar_xml_form_builder_forms() {
$module_path = drupal_get_path('module', 'islandora_scholar');
return array(
'Citation MODS form' => array(
'form_file' => "$module_path/xml/citation_form.xml",
),
'Thesis MODS form' => array(
'form_file' => "$module_path/xml/thesis_form.xml",
),
'Thesis MODS recovery form' => array(
'form_file' => "$module_path/xml/thesis_form_ISLANDORA1350.xml",
),
);
}
/**
* Implements hook_xml_form_builder_form_associations().
*/
function islandora_scholar_xml_form_builder_form_associations() {
return array(
'islandora_scholar_mods_form' => array(
'content_model' => 'ir:citationCModel',
'form_name' => 'Citation MODS form',
'dsid' => 'MODS',
'title_field' => array('titleInfo', 'title'),
'transform' => 'mods_to_dc.xsl',
'self_transform' => 'islandora_cleanup_mods_extended.xsl',
'template' => FALSE,
),
'islandora_thesis_mods_form' => array(
'content_model' => 'ir:thesisCModel',
'form_name' => 'Thesis 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_islandora_xml_form_builder_get_transforms().
*/
function islandora_scholar_xml_form_builder_get_self_transforms() {
return array(
'cleanup_thesis_form.xslt' => drupal_get_path('module', 'islandora_scholar') . '/xsl/cleanup_thesis_form_ISLANDORA1350.xslt',
);
}
/**
* Implements hook_islandora_required_objects().
*/
function islandora_scholar_islandora_required_objects(IslandoraTuque $connection) {
// Build a thumbnail datastream.
$module_path = drupal_get_path('module', 'islandora_scholar');
$citation_content_model = $connection->repository->constructObject('ir:citationCModel');
$citation_content_model->owner = 'fedoraAdmin';
$citation_content_model->label = 'Citation Content Model';
$citation_content_model->models = 'fedora-system:ContentModel-3.0';
// ISLANDORACM Datastream.
$datastream = $citation_content_model->constructDatastream('ISLANDORACM', 'X');
$datastream->label = 'Islandora content model';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/ISLANDORACM.xml", FALSE);
$citation_content_model->ingestDatastream($datastream);
// DS-COMPOSITE-MODEL Datastream.
$datastream = $citation_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'M');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/DS-COMPOSITE-MODEL.xml", FALSE);
$citation_content_model->ingestDatastream($datastream);
// Thesis Content model.
$thesis_content_model = $connection->repository->constructObject('ir:thesisCModel');
$thesis_content_model->owner = 'fedoraAdmin';
$thesis_content_model->label = 'Thesis Content Model';
$thesis_content_model->models = 'fedora-system:ContentModel-3.0';
// DS-COMPOSITE-MODEL Datastream.
$datastream = $thesis_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'M');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/DS-COMPOSITE-MODEL.xml", FALSE);
$thesis_content_model->ingestDatastream($datastream);
// Citation Collection.
$citation_collection = $connection->repository->constructObject('ir:citationCollection');
$citation_collection->owner = 'fedoraAdmin';
$citation_collection->label = 'Citations';
$citation_collection->models = 'islandora:collectionCModel';
$citation_collection->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:root');
$datastream = $citation_collection->constructDatastream('COLLECTION_POLICY', 'X');
// Collection Policy Datastream.
$datastream->label = 'Collection Policy';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/COLLECTION_POLICY.xml", FALSE);
$citation_collection->ingestDatastream($datastream);
$datastream = $citation_collection->constructDatastream('TN', 'M');
$datastream->label = 'Thumbnail';
$datastream->mimetype = 'image/png';
$datastream->setContentFromFile("$module_path/images/Crystal_Clear_filesystem_folder_grey.png", FALSE);
$citation_collection->ingestDatastream($datastream);
return array(
'islandora_scholar' => array(
'title' => 'Islandora Scholar',
'objects' => array(
$citation_content_model,
$thesis_content_model,
$citation_collection,
),
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
*/
function islandora_scholar_ir_citationCModel_islandora_view_object($object) {
module_load_include('inc', 'islandora_scholar', 'includes/utilities');
if (variable_get('islandora_scholar_google_scholar_metatags_enabled', TRUE)) {
module_load_include('inc', 'islandora_scholar', 'includes/google_scholar');
$tags = islandora_scholar_create_meta_tags($object);
islandora_scholar_embed_tags($tags);
}
return islandora_scholar_get_view($object);
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
*/
function islandora_scholar_ir_thesisCModel_islandora_view_object($object) {
module_load_include('inc', 'islandora_scholar', 'includes/utilities');
if (variable_get('islandora_scholar_google_scholar_metatags_enabled', TRUE)) {
module_load_include('inc', 'islandora_scholar', 'includes/google_scholar');
$tags = islandora_scholar_create_meta_tags($object);
islandora_scholar_embed_tags($tags);
}
return islandora_scholar_get_view($object);
}
/**
* Access callback for upload tab.
*
* Allow if the user's allowed to add datastreams or is the object's owner.
*/
function islandora_scholar_upload_access($object) {
$allowed_models = array('ir:citationCModel', 'ir:thesisCModel');
return is_object($object) && count(array_intersect($allowed_models, $object->models)) > 0 &&
islandora_object_access(ISLANDORA_ADD_DS, $object);
}
/**
* Access callback, to determine whether or not to create the RoMEO tab.
*
* Checks if it's enabled, we have the relevant content model, and we have an
* ISSN to look up.
*/
function islandora_scholar_romeo_access($object) {
module_load_include('inc', 'islandora_scholar', 'includes/romeo.tab');
return variable_get('islandora_scholar_romeo_enable', FALSE) &&
in_array('ir:citationCModel', $object->models) &&
isset($object['MODS']) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object['MODS']) &&
RomeoView::getISSN($object);
}
/**
* Access callback for retrieving citations.
*
* @param AbstractObject $object
* The object we are trying to access.
*/
function islandora_scholar_citation_access($object) {
return variable_get('islandora_scholar_users_choose_display_csl', FALSE) &&
array_intersect(array('ir:citationCModel', 'ir:thesisCModel'), $object->models) &&
isset($object['MODS']) &&
islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object['MODS']);
}
/**
* Implements hook_islandora_ingest_steps().
*/
function islandora_scholar_ir_citationCModel_islandora_ingest_steps() {
module_load_include('inc', 'islandora_scholar', 'includes/utilities');
return islandora_scholar_get_ingest_steps();
}
/**
* Implements hook_islandora_ingest_steps().
*/
function islandora_scholar_ir_thesisCModel_islandora_ingest_steps() {
module_load_include('inc', 'islandora_scholar', 'includes/utilities');
return islandora_scholar_get_ingest_steps();
}
/**
* Implements hook_CMODEL_PID_islandora_derivative().
*/
function islandora_scholar_ir_citationCModel_islandora_derivative() {
module_load_include('inc', 'islandora_scholar', 'includes/utilities');
return islandora_scholar_get_derivatives();
}
/**
* Implements hook_CMODEL_PID_islandora_derivative().
*/
function islandora_scholar_ir_thesisCModel_islandora_derivative() {
module_load_include('inc', 'islandora_scholar', 'includes/utilities');
return islandora_scholar_get_derivatives();
}