-
Notifications
You must be signed in to change notification settings - Fork 41
/
islandora_pdf.module
196 lines (186 loc) · 6.16 KB
/
islandora_pdf.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
<?php
/**
* @file
* Handles the creation/display of islandora:sp-pdf objects.
*/
/**
* Implements hook_menu().
*/
function islandora_pdf_menu() {
return array(
'admin/islandora/solution_pack_config/pdf' => array(
'title' => 'PDF Solution Pack',
'description' => 'Define ingest behavior and configure preview display.',
'page callback' => 'drupal_get_form',
'access arguments' => array('administer site configuration'),
'page arguments' => array('islandora_pdf_admin'),
'file' => 'includes/admin.form.inc',
'type' => MENU_NORMAL_ITEM,
),
);
}
/**
* Implements hook_theme().
*/
function islandora_pdf_theme($existing, $type, $theme, $path) {
return array(
'islandora_pdf' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-pdf',
'pattern' => 'islandora_pdf__',
'variables' => array('islandora_object' => NULL),
),
'islandora_pdf_print' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-pdf-print',
'pattern' => 'islandora_pdf_print__',
'variables' => array('islandora_object' => NULL),
),
);
}
/**
* Implements hook_islandora_required_objects().
*/
function islandora_pdf_islandora_required_objects(IslandoraTuque $connection) {
$module_path = drupal_get_path('module', 'islandora_pdf');
// PDF Content Model.
$pdf_content_model = $connection->repository->constructObject('islandora:sp_pdf');
$pdf_content_model->owner = 'fedoraAdmin';
$pdf_content_model->label = 'Islandora PDF Content Model';
$pdf_content_model->models = 'fedora-system:ContentModel-3.0';
// DS-COMPOSITE-MODEL Datastream.
$datastream = $pdf_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'X');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'application/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_pdf_ds_composite_model.xml", FALSE);
$pdf_content_model->ingestDatastream($datastream);
// PDF Collection.
$pdf_collection = $connection->repository->constructObject('islandora:sp_pdf_collection');
$pdf_collection->owner = 'fedoraAdmin';
$pdf_collection->label = 'PDF Collection';
$pdf_collection->models = 'islandora:collectionCModel';
$pdf_collection->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:root');
// Collection Policy Datastream.
$datastream = $pdf_collection->constructDatastream('COLLECTION_POLICY', 'X');
$datastream->label = 'Collection policy';
$datastream->mimetype = 'application/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_pdf_collection_policy.xml", FALSE);
$pdf_collection->ingestDatastream($datastream);
// TN Datastream.
$datastream = $pdf_collection->constructDatastream('TN', 'M');
$datastream->label = 'Thumbnail';
$datastream->mimetype = 'image/png';
$datastream->setContentFromFile("$module_path/images/folder.png", FALSE);
$pdf_collection->ingestDatastream($datastream);
return array(
'islandora_pdf' => array(
'title' => 'Islandora PDF',
'objects' => array(
$pdf_content_model,
$pdf_collection,
),
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
*/
function islandora_pdf_islandora_sp_pdf_islandora_view_object($object, $page_number, $page_size) {
$output = theme('islandora_pdf', array('islandora_object' => $object));
return array('' => $output);
}
/**
* Implements hook_islandora_view_print_object().
*/
function islandora_pdf_islandora_view_print_object($object) {
$output = theme('islandora_pdf_print', array('islandora_object' => $object));
return array('pdf' => $output);
}
/**
* Implements hook_xml_form_builder_forms().
*/
function islandora_pdf_xml_form_builder_forms() {
$module_path = drupal_get_path('module', 'islandora_pdf');
return array(
'PDF MODS form' => array(
'form_file' => "$module_path/xml/islandora_pdf_form_mods.xml",
),
);
}
/**
* Implements hook_xml_form_builder_form_associations().
*/
function islandora_pdf_xml_form_builder_form_associations() {
return array(
'islandora_pdf_mods_form' => array(
'content_model' => 'islandora:sp_pdf',
'form_name' => 'PDF 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_ingest_steps().
*/
function islandora_pdf_islandora_sp_pdf_islandora_ingest_steps() {
return array(
'islandora_pdf_file_upload' => array(
'weight' => 10,
'type' => 'form',
'form_id' => 'islandora_pdf_pdf_upload_form',
'module' => 'islandora_pdf',
'file' => 'includes/pdf_upload.form.inc',
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_derivative().
*/
function islandora_pdf_islandora_sp_pdf_islandora_derivative() {
$derivatives = array();
$derivatives[] = array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'TN',
'weight' => '0',
'function' => array(
'islandora_pdf_add_tn_derivative',
),
'file' => drupal_get_path('module', 'islandora_pdf') . '/includes/derivatives.inc',
);
$derivatives[] = array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'PREVIEW',
'weight' => '1',
'function' => array(
'islandora_pdf_add_preview_derivative',
),
'file' => drupal_get_path('module', 'islandora_pdf') . '/includes/derivatives.inc',
);
if (variable_get('islandora_pdf_create_fulltext', FALSE)) {
$derivatives[] = array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'FULL_TEXT',
'weight' => '2',
'function' => array(
'islandora_pdf_add_fulltext_derivative',
),
'file' => drupal_get_path('module', 'islandora_pdf') . '/includes/derivatives.inc',
);
}
if (variable_get('islandora_pdf_create_pdfa', FALSE)) {
$derivatives[] = array(
'source_dsid' => 'OBJ',
'destination_dsid' => 'PDFA',
'weight' => '2',
'function' => array(
'islandora_pdf_add_pdfa_derivative',
),
'file' => drupal_get_path('module', 'islandora_pdf') . '/includes/derivatives.inc',
);
}
return $derivatives;
}