-
Notifications
You must be signed in to change notification settings - Fork 0
/
islandora_solution_pack_xml.module
188 lines (178 loc) · 6.63 KB
/
islandora_solution_pack_xml.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
<?php
/**
* @file
* Handles the creation and display of simple XML objects.
*/
/**
* Implements hook_menu().
*/
function islandora_solution_pack_xml_menu() {
$items = array();
$items['admin/islandora/solution_pack_config/xml'] = array(
'title' => 'Simple XML Solution Pack',
'description' => 'Configure the Simple XML Object Solution Pack.',
'page callback' => 'drupal_get_form',
'access arguments' => array('administer site configuration'),
'page arguments' => array('islandora_solution_pack_xml_admin'),
'file' => 'includes/admin.form.inc',
'type' => MENU_NORMAL_ITEM,
);
$items['islandora/object/%islandora_object/datastreams/OBJ/edit'] = array(
'title' => 'Edit XML file',
'file' => 'includes/xml_object_edit.form.inc',
'page callback' => 'islandora_solution_pack_xml_edit_xml',
'page arguments' => array(2),
'access callback' => 'islandora_object_manage_access_callback',
'access arguments' => array(
array(
ISLANDORA_METADATA_EDIT,
ISLANDORA_ADD_DS,
ISLANDORA_PURGE,
), 2),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements hook_islandora_edit_datastream_registry().
*/
function islandora_solution_pack_xml_islandora_edit_datastream_registry($object, $dsid) {
if (in_array('islandora:sp_simple_xml', $object->models) &&
$dsid->id == 'OBJ') {
return array(
array(
'name' => t('XML Edit form'),
'url' => "islandora/object/{$object->id}/datastreams/OBJ/edit",
),
);
}
}
/**
* Implements hook_theme().
*
* We supply a pattern so we can overide templates at the theme level if needed.
* We can append a pid to a template and the new template file will be called
* (the pid's colon should be replaced with a dash).
* An example template might be named:
* "islandora-simple-xml--islandora-100.tpl.php".
*/
function islandora_solution_pack_xml_theme($existing, $type, $theme, $path) {
return array(
'islandora_solution_pack_xml_default' => array(
'template' => 'theme/islandora-solution-pack-xml-default',
'file' => 'theme/theme.inc',
'pattern' => 'islandora_solution_pack_xml__',
'variables' => array('islandora_object' => NULL),
),
);
}
/**
* Implements hook_permission().
*/
function islandora_solution_pack_xml_permission() {
return array(
'upload RENDER_STYLESHEET datasteams' => array(
'title' => t('Upload RENDER_STYLESHEET datasteams'),
'description' => t('Upload XSLT stylesheets on simple XML objects'),
),
'upload simple XML thumbnails' => array(
'title' => t('Upload object-specific thumbnails'),
'description' => t('Upload object-specific custom thumbnails'),
),
);
}
/**
* Implements hook_islandora_required_objects().
*/
function islandora_solution_pack_xml_islandora_required_objects(IslandoraTuque $connection) {
$module_path = drupal_get_path('module', 'islandora_solution_pack_xml');
// Islandora Simple XML Content Model.
$simple_xml_content_model = $connection->repository->constructObject('islandora:sp_simple_xml');
$simple_xml_content_model->owner = 'fedoraAdmin';
$simple_xml_content_model->label = 'Islandora Simple XML Content Model';
$simple_xml_content_model->models = 'fedora-system:ContentModel-3.0';
// DS-COMPOSITE-MODEL Datastream.
$datastream = $simple_xml_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'X');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'application/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_simple_xml_ds_composite_model.xml", FALSE);
$simple_xml_content_model->ingestDatastream($datastream);
// Simple XML Collection.
$simple_xml_collection = $connection->repository->constructObject('islandora:sp_simple_xml_collection');
$simple_xml_collection->owner = 'fedoraAdmin';
$simple_xml_collection->label = 'Simple XML Collection';
$simple_xml_collection->models = 'islandora:collectionCModel';
$top_level_collection = variable_get('islandora_repository_pid', 'islandora:root');
$simple_xml_collection->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', $top_level_collection);
// Collection Policy Datastream.
$datastream = $simple_xml_collection->constructDatastream('COLLECTION_POLICY', 'X');
$datastream->label = 'Collection policy';
$datastream->mimetype = 'application/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_simple_xml_collection_policy.xml", FALSE);
$simple_xml_collection->ingestDatastream($datastream);
// TN Datastream.
$datastream = $simple_xml_collection->constructDatastream('TN', 'M');
$datastream->label = 'Thumbnail';
$datastream->mimetype = 'image/png';
$datastream->setContentFromFile("$module_path/images/xml.png", FALSE);
$simple_xml_collection->ingestDatastream($datastream);
return array(
'islandora_solution_pack_xml' => array(
'title' => 'Islandora Simple XML',
'objects' => array(
$simple_xml_content_model,
$simple_xml_collection,
),
),
);
}
/**
* Implements hook_islandora_xml_form_builder_forms().
*/
function islandora_solution_pack_xml_islandora_xml_form_builder_forms() {
$module_path = drupal_get_path('module', 'islandora_solution_pack_xml');
return array(
'Islandora Simple XML Object MODS form' => array(
'form_file' => "$module_path/xml/islandora_simple_xml_form_mods.xml",
),
);
}
/**
* Implements hook_islandora_xml_form_builder_form_associations().
*/
function islandora_solution_pack_xml_islandora_xml_form_builder_form_associations() {
return array(
'islandora_simple_xml_mods_form' => array(
'content_model' => 'islandora:sp_simple_xml',
'form_name' => 'Islandora Simple XML Object MODS form',
'dsid' => 'MODS',
'title_field' => array(
'titleInfo', 'title',
),
'transform' => 'mods_to_dc.xsl',
'self_transform' => 'cleanup_mods.xsl',
'template' => FALSE,
),
);
}
/**
* Implements hook_cmodel_pid_islandora_ingest_steps().
*/
function islandora_solution_pack_xml_islandora_sp_simple_xml_islandora_ingest_steps() {
return array(
'islandora_solution_pack_xml_obj_upload' => array(
'weight' => 10,
'type' => 'form',
'form_id' => 'islandora_solution_pack_xml_xml_upload_form',
'module' => 'islandora_solution_pack_xml',
'file' => 'includes/xml_object_upload.form.inc',
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
*/
function islandora_solution_pack_xml_islandora_sp_simple_xml_islandora_view_object($object, $page_number, $page_size) {
$output = theme('islandora_solution_pack_xml_default', array('islandora_object' => $object));
return array('' => $output);
}