-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathislandora_ead.module
149 lines (133 loc) · 4.71 KB
/
islandora_ead.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
<?php
/**
* @file
* Hooks and callbacks for this module.
*
* This file is part of the Islandora EAD Solution Pack.
* Copyright (C) 2015 Drexel University.
*
* The Islandora EAD Solution Pack is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* The Islandora EAD Solution Pack is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with The Islandora EAD Solution Pack; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* Implements hook_menu().
*/
function islandora_ead_menu() {
$items = array();
$items['islandora/ead/lookup'] = array(
'type' => MENU_CALLBACK,
'title' => 'EAD Lookup by ID',
'file' => 'includes/utilities.inc',
'page callback' => 'islandora_ead_id_lookup',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS),
);
$items['islandora/object/%islandora_object/manage/ead'] = array(
'type' => MENU_LOCAL_TASK,
'title' => 'EAD',
'file' => 'includes/manage.form.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_ead_manage_form', 2),
'access callback' => 'islandora_ead_manage_access_callback',
'access arguments' => array(2),
);
$items['islandora/object/%islandora_object/manage/ead/%'] = array(
'type' => MENU_CALLBACK,
'title' => 'Modify Association',
'file' => 'includes/association_upload.form.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_ead_association_upload_form', 2, 5),
'access callback' => 'islandora_ead_manage_access_callback',
'access arguments' => array(2),
);
return $items;
}
/**
* Implements hook_theme().
*/
function islandora_ead_theme() {
return array(
'islandora_ead' => array(
'arguments' => array('object' => NULL),
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-ead',
),
);
}
/**
* Implements hook_islandora_required_objects().
*/
function islandora_ead_islandora_required_objects(IslandoraTuque $connection) {
$module_path = drupal_get_path('module', 'islandora_ead');
$datastreams_path = "$module_path/xml";
// EAD Content Model.
$ead_content_model = $connection->repository->constructObject('islandora:eadCModel');
$ead_content_model->owner = 'fedoraAdmin';
$ead_content_model->label = 'Islandora EAD Content Model';
$ead_content_model->models = 'fedora-system:ContentModel-3.0';
// DS-COMPOSITE-MODEL Datastream.
$datastream = $ead_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'M');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$datastreams_path/islandora_eadCModel_ds_composite_model.xml", FALSE);
$ead_content_model->ingestDatastream($datastream);
return array(
'islandora_ead' => array(
'title' => 'Islandora EAD Content Model',
'objects' => array($ead_content_model),
),
);
}
/**
* Implements hook_islandora_ingest_steps().
*/
function islandora_ead_islandora_eadcmodel_islandora_ingest_steps() {
return array(
'islandora_ead' => array(
'weight' => 10,
'type' => 'form',
'form_id' => 'islandora_ead_upload_form',
'module' => 'islandora_ead',
'file' => 'includes/ead_upload.form.inc',
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
*/
function islandora_ead_islandora_eadcmodel_islandora_view_object($object) {
$output = theme('islandora_ead', array('object' => $object));
return array('islandora_ead' => $output);
}
/**
* Callback to limit access to EAD management interfaces.
*/
function islandora_ead_manage_access_callback($object) {
$permissions = array(
ISLANDORA_ADD_DS,
ISLANDORA_METADATA_EDIT,
ISLANDORA_PURGE,
);
$content_models = array('islandora:eadCModel');
return islandora_user_access($object, $permissions, $content_models);
}
/**
* Implements hook_islandora_solr_object_result_alter().
*/
function islandora_ead_islandora_solr_object_result_alter(&$search_result, $query_processor) {
if (array_key_exists('ispartof_display', $search_result['solr_doc'])) {
$ead_pid = $search_result['solr_doc']['ispartof_pid'];
$ead_title = $search_result['solr_doc']['ispartof_display'];
$search_result['solr_doc']['ispartof_display'] = l($ead_title, "islandora/object/$ead_pid");
}
}