-
Notifications
You must be signed in to change notification settings - Fork 4
/
islandora_datastreams_io.module
139 lines (133 loc) · 5.7 KB
/
islandora_datastreams_io.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
<?php
// Permissions.
define('ISLANDORA_DATASTREAMS_IO', 'datastreams input output');
define('ISLANDORA_DATASTREAMS_IO_EXPORT', 'datastreams output');
define('ISLANDORA_DATASTREAMS_IO_IMPORT', 'datastreams input');
// pids_fetch_methods:
define('ISLANDORA_DATASTREAMS_IO_FETCH_LISTPIDS', 0);
define('ISLANDORA_DATASTREAMS_IO_FETCH_SOLR', 1);
define('ISLANDORA_DATASTREAMS_IO_FETCH_COLLECTION', 2);
define('ISLANDORA_DATASTREAMS_IO_FETCH_MODEL', 3);
/**
* Implements hook_menu().
*/
function islandora_datastreams_io_menu() {
return array(
'admin/islandora/datastreams_io' => array(
'title' => 'Islandora Datastreams Input/Output & Object Relationships',
'description' => 'Settings for the Islandora Datastreams Input/Output & Object Relationships module.',
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_datastreams_io_admin_form'),
'access arguments' => array(ISLANDORA_DATASTREAMS_IO),
'file' => 'includes/admin.form.inc',
),
'admin/islandora/datastreams_io/export' => array(
'title' => t('Export Datastreams'),
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_datastreams_io_export_form'),
'file' => 'includes/export.form.inc',
'access arguments' => array(ISLANDORA_DATASTREAMS_IO_EXPORT),
),
// ZIP file download handler
'admin/islandora/datastreams_io/download_export/%' => array(
'title' => t('Download export'),
'type' => MENU_NORMAL_ITEM,
'page callback' => 'islandora_datastreams_io_download_export',
'page arguments' => array(4),
'file' => 'includes/download_export.inc',
'access arguments' => array(ISLANDORA_DATASTREAMS_IO_EXPORT),
),
'admin/islandora/datastreams_io/import' => array(
'title' => t('Import Datastreams'),
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_datastreams_io_import_form'),
'file' => 'includes/import.form.inc',
'access arguments' => array(ISLANDORA_DATASTREAMS_IO_IMPORT),
),
'admin/islandora/datastreams_io/relationships' => array(
'title' => t('Object Relationships'),
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_datastreams_io_relationships_form'),
'file' => 'includes/relationships.form.inc',
'access arguments' => array(ISLANDORA_DATASTREAMS_IO_IMPORT),
),
'admin/islandora/datastreams_io/transform' => array(
'title' => t('Transform Datastreams'),
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_datastreams_io_transform_form'),
'file' => 'includes/transform.form.inc',
'access arguments' => array(ISLANDORA_DATASTREAMS_IO_IMPORT),
),
'admin/islandora/datastreams_io/update_label' => array(
'title' => t('Update Object label from MODS titleInfo/title'),
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_datastreams_io_update_label_form'),
'file' => 'includes/update_label.form.inc',
'access arguments' => array(ISLANDORA_DATASTREAMS_IO_EXPORT),
),
);
}
/**
* Implements hook_permission().
*/
function islandora_datastreams_io_permission() {
return array(
ISLANDORA_DATASTREAMS_IO => array(
'title' => t('Use the datastreams import and export tool'),
'description' => t('User can import / export selected datastreams per ' .
'collection, model type, Solr query (if installed), or by list of PID values.'),
),
ISLANDORA_DATASTREAMS_IO_EXPORT => array(
'title' => t('Use to export object datastreams.'),
'description' => t('User can export selected objects\' datastreams.'),
),
ISLANDORA_DATASTREAMS_IO_IMPORT => array(
'title' => t('Use the import object datastreams.'),
'description' => t('User can import selected objects\' datastreams.'),
),
);
}
/**
* Implements hook_presprocess_theme().
*
* This code will add the javascript if on a datastreams_io page.
*/
function islandora_datastreams_io_preprocess_page(&$vars) {
$item = menu_get_item();
if (is_array($item)) {
$path = drupal_get_path('module', 'islandora_datastreams_io');
if ($item['path'] == 'admin/islandora/datastreams_io/export/batch/%' ||
$item['path'] == 'admin/islandora/datastreams_io/export' ||
$item['path'] == 'admin/islandora/datastreams_io/relationships' ||
$item['path'] == 'admin/islandora/datastreams_io/transform' ||
$item['path'] == 'admin/islandora/datastreams_io/update_label' ||
$item['path'] == 'admin/islandora/datastreams_io/delete_datastreams') {
drupal_add_js($path . '/js/batch_functions.js');
drupal_add_css($path . '/css/datastreams_io.css');
}
elseif ($item['path'] == 'admin/islandora/datastreams_io') {
drupal_add_js($path . '/js/admin_functions.js');
}
}
}
/**
* Helper function that will populate the PIDS and PIDS fetch method for the export form.
* This is intended to be called from units that want to pre-populate and use the export form.
*
* The allowable fetch methods are:
* define('ISLANDORA_DATASTREAMS_IO_FETCH_SOLR', 0);
define('ISLANDORA_DATASTREAMS_IO_FETCH_LISTPIDS', 1);
define('ISLANDORA_DATASTREAMS_IO_FETCH_COLLECTION', 2);
define('ISLANDORA_DATASTREAMS_IO_FETCH_MODEL', 3);
*/
function islandora_datastreams_io_pids_to_export_form($pids_value, $pids_fetch_method) {
$_SESSION['pids_value'] = json_encode($pids_value);
$_SESSION['pids_fetch_method'] = $pids_fetch_method;
drupal_goto('/admin/islandora/datastreams_io/export');
}