-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathislandora_entities.install
executable file
·221 lines (209 loc) · 7.44 KB
/
islandora_entities.install
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
<?php
/**
* @file
* Handles the install and uninstall of islandora_entities.
*/
/**
* Implements hook_install().
*
* @see islandora_book_islandora_required_objects()
*/
function islandora_entities_install() {
module_load_include('inc', 'islandora', 'includes/solution_packs');
islandora_entities_install_solr_metadata_config('Scholar', 'scholar', islandora_entities_get_scholar_config_fields());
islandora_entities_install_solr_metadata_config('Department', 'department', islandora_entities_get_dept_config_fields());
islandora_install_solution_pack('islandora_entities');
}
/**
* Implements hook_uninstall().
*/
function islandora_entities_uninstall() {
$drupal_variables = array(
'islandora_entities_query_field',
'islandora_entities_people_collection',
'islandora_entities_events_collection',
'islandora_entities_organizations_collection',
'islandora_entities_places_collection',
'islandora_entities_scholar_title_solr_field',
'islandora_entities_department_solr_field',
'islandora_entities_disambiguated_solr_field',
'islandora_entities_last_name_solr_field',
'islandora_entities_query_sort',
'islandora_entities_query_sort_direction',
'islandora_entities_citation_number',
'islandora_entities_citation_author_solr_field',
'islandora_entities_linking_content_solr_field',
);
foreach ($drupal_variables as $drupal_variable) {
variable_del($drupal_variable);
}
}
/**
* Installs Solr Metatdata configuration.
*
* @param string $config_name
* configuration name
* @param string $machine_name
* machine name associated with configuration
* @param array $configs
* An associative array of configuration details, including
* - cmodels
* - fields
*/
function islandora_entities_install_solr_metadata_config($config_name, $machine_name, $configs) {
module_load_include('inc', 'islandora_solr_metadata', 'includes/db');
$t = get_t();
if (islandora_solr_metadata_retrieve_configuration_from_machine_name($machine_name)) {
drupal_set_message($t("Configuration '@config' already exists on this machine. It was not reinstalled", array('@config' => $config_name)));
return;
}
$configuration_id = islandora_solr_metadata_add_configuration($config_name, $machine_name);
islandora_solr_metadata_add_content_models($configuration_id, $configs['cmodels']);
islandora_solr_metadata_add_fields($configuration_id, $configs['fields']);
islandora_solr_metadata_update_description($configuration_id, $configs['description']['field'], $configs['description']['display_label'], $configs['description']['data']);
drupal_set_message($t("Configuration '@config' installed.", array('@config' => $config_name)));
}
/**
* Gets all config paramaters for Scholar Solr Metadata.
*
* @return array
* Associative array with content models and fields
*/
function islandora_entities_get_scholar_config_fields() {
$content_models = array(array('cmodel' => 'islandora:personCModel'));
$fields = array();
$weight = 0;
$fields['MADS_title_ms'] = array(
'remove_field' => 0,
'display_label' => 'Name',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_title_ms',
);
$fields['MADS_email_ms'] = array(
'remove_field' => 0,
'display_label' => 'Email',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_email_ms',
);
$fields['MADS_position_ms'] = array(
'remove_field' => 0,
'display_label' => 'Position',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_position_ms',
);
$fields['MADS_organization_ms'] = array(
'remove_field' => 0,
'display_label' => 'Department(s)',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_organization_ms',
);
$fields['MADS_phone_ms'] = array(
'remove_field' => 0,
'display_label' => 'Phone',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_phone_ms',
);
$fields['MADS_address_ms'] = array(
'remove_field' => 0,
'display_label' => 'Building',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_address_ms',
);
$fields['MADS_url_ms'] = array(
'remove_field' => 0,
'display_label' => 'URL',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_url_ms',
);
$configs['description'] = array(
'field' => 'MADS_history_ms',
'display_label' => 'Biography',
'data' => array(),
);
$configs['fields'] = $fields;
$configs['cmodels'] = $content_models;
return $configs;
}
/**
* Gets all config paramaters for Scholar Solr Metadata.
*
* @return array
* Associative array with content models and fields
*/
function islandora_entities_get_dept_config_fields() {
$content_models = array(array('cmodel' => 'islandora:organizationCModel'));
$fields = array();
$weight = 0;
$fields['MADS_department_ms'] = array(
'remove_field' => 0,
'display_label' => 'Name',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_department_ms',
);
$fields['MADS_date_ms'] = array(
'remove_field' => 0,
'display_label' => 'Date',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_date_ms',
);
$fields['MADS_historical_mt'] = array(
'remove_field' => 0,
'display_label' => 'Historical Note',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_historical_mt',
);
$fields['MADS_url_ms'] = array(
'remove_field' => 0,
'display_label' => 'URL',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_url_ms',
);
$fields['MADS_parent_institution_ms'] = array(
'remove_field' => 0,
'display_label' => 'Parent school/faculty',
'hyperlink' => 0,
'weight' => ++$weight,
'solr_field' => 'MADS_parent_institution_ms',
);
$configs['fields'] = $fields;
$configs['cmodels'] = $content_models;
return $configs;
}
/**
* Add the default description field to the Scholar solr metadata profile.
*/
function islandora_entities_update_7100() {
module_load_include('inc', 'islandora_solr_metadata', 'includes/db');
$config_id = islandora_solr_metadata_retrieve_configuration_from_machine_name('Scholar');
if ($config_id) {
$description = islandora_solr_metadata_retrieve_description($config_id);
if (!$description['description_field']) {
islandora_solr_metadata_update_description($config_id, 'MADS_history_ms', 'Biography', $description['data']);
}
}
}
/**
* Print and log a message about potential lost Position data.
*
* @see https://jira.duraspace.org/browse/ISLANDORA-2137
*/
function islandora_entities_update_7200(&$sandbox) {
$t = get_t();
watchdog('islandora_entities', 'The original default form used two-word labels in the Position element, but removed spaces in the MADS XML. This has been fixed as of 7.x-1.13. When editing existing objects with the new form, older values under Position will not be read and will be discarded.', array(), WATCHDOG_NOTICE, l(t('ISLANDORA-2137'), 'https://jira.duraspace.org/browse/ISLANDORA-2317', array('external' => TRUE)));
return $t('The original default form used two-word labels in the Position element, but removed spaces in the MADS XML. This has been fixed as of 7.x-1.13. When editing existing objects with the new form, older values under Position will not be read and will be discarded. Please consult the !url for further information.',
array(
'!url' => l(t('ticket'), 'https://jira.duraspace.org/browse/ISLANDORA-2137', array('absolute' => TRUE)),
)
);
}