forked from alxp/fedora_api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
islandora_fedora_api.module
99 lines (88 loc) · 3.36 KB
/
islandora_fedora_api.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
<?php
/**
* $file
* Main module file for the Islandora Fedora API.
*/
/**
* Implements hook_form_FORM_ID_alter().
*
* This hook adds the fedora settings to the Islandora settings page
* when this module is used with Islandora core. If it is used on its own
* it is up to the user to pass the Fedora information to the API.
*
* @todo Implement namespace restrictions.
* @todo Make sure we save a value for islandora_repository_title
* @todo Shouldn't this be implemented using module_invoke_all instead of for alter
*/
function fedora_api_form_islandora_admin_settings_alter(&$form, &$form_state, $form_id) {
// get the current value of fedora_drupal_filter for the AJAX callback
$fedora_drupal_filter = isset($form_state['values']['fedora_drupal_filter']) ?
$form_state['values']['fedora_drupal_filter'] : variable_get('fedora_drupal_filter', 1);
$form['fedora'] = array(
'#type' => 'fieldset',
'#title' => t('Fedora'),
'#weight' => -8,
'#group' => 'settings',
);
$form['fedora']['fedora_server_url'] = array(
'#type' => 'textfield',
'#title' => t('Fedora server URL'),
'#default_value' => variable_get('fedora_server_url', 'http://localhost:8080/fedora'),
'#description' => t('The Fedora server URL'),
'#required' => TRUE,
'#suffix' => '<div id="check-url-div"></div>',
'#ajax' => array(
'callback' => 'fedora_api_check_url_callback',
'wrapper' => 'check-url-div',
'effect' => 'none',
'progress' => array('type' => 'throbber', 'message' => '', ),
),
);
$form['fedora']['fedora_drupal_filter'] = array(
'#type' => 'checkbox',
'#title' => t('Use Drupal Filter'),
'#description' => t('Uncheck this box if you would like to bypass the drupal servlet filter when connecting
to the fedora repository. (Not recommended.)'),
'#default_value' => variable_get('fedora_drupal_filter', 1),
'#ajax' => array(
'callback' => 'fedora_api_filter_callback',
'wrapper' => 'drupal-filter-div',
'effect' => 'slide',
'speed' => 'fast',
'progress' => array('type' => 'none'),
),
);
// add the fieldset for the ajax callback to the form array
$form['fedora']['filter_fieldset'] = array(
'#prefix' => '<div id="drupal-filter-div">',
'#suffix' => '</div>',
'#type' => 'fieldset',
);
if ($fedora_drupal_filter == 0) {
$form['fedora']['filter_fieldset']['fedora_user'] = array(
'#type' => 'textfield',
'#title' => 'Fedora User',
'#default_value' => variable_get('fedora_user', 'fedoraAdmin'),
'#description' => t('The username to use when connecting to the Fedora server'),
'#required' => FALSE,
);
$form['fedora']['filter_fieldset']['fedora_password'] = array(
'#type' => 'password',
'#title' => 'Password',
'#default_value' => variable_get('fedora_password', ''),
'#description' => t('Password for this Fedora user.'),
'#required' => FALSE,
);
}
}
/**
* Implements a AJAX callback that is called when the don't use drupal filter box is checked.
*
* @todo get this working. currently doesn't save when enabled through ajax.
*/
function fedora_api_filter_callback($form, $form_state) {
return $form['fedora']['filter_fieldset'];
}
function fedora_api_check_url_callback($form, $form_state) {
return '<div id="check-url-div"><img src="' . url('misc/watchdog-ok.png') . '"/></div><p>';
}