-
Notifications
You must be signed in to change notification settings - Fork 6
/
fedora_api.module
executable file
·101 lines (93 loc) · 3.11 KB
/
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
100
101
<?php
// $Id:$
/**
* $file
*
* A wrapper for the Fedora Repository's API-A and API-M calls. Function names
* match the naming and capitalization conventions of the SOAP functions.
*/
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function fedora_api_permission() {
$permissions = array();
$permissions['administer fedora'] = array (
'title' => t('Administer Fedora Commons Repository'),
'description' => t('Set up the connection to a Fedora Commons repository and define default collection information for this site.'),
'restrict access' => TRUE,
);
return $permissions;
}
/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
*/
function fedora_api_menu() {
$items = array();
$items['admin/config/fedora_repository/server'] = array(
'title' => t('Fedora Server Settings'),
'description' => t('Enter the Fedora Collection information here'),
'page callback' => 'drupal_get_form',
'page arguments' => array('fedora_api_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/config/fedora_repository/server'] = array(
'title' => 'Fedora Server Settings',
'description' => 'Configure Fedora Repository API server',
'page callback' => 'drupal_get_form',
'page arguments' => array('fedora_api_settings'),
'type' => MENU_LOCAL_TASK,
'weight' => 0,
'access arguments' => array('administer fedora api'),
);
return $items;
}
/**
* Creates teh administration settings page to let the user specify the location
* of the Feodra Repository server.
*/
function fedora_api_settings($form, &$form_state) {
$form = array();
$form['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,
'#weight' => -10,
);
$form['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. Only set this if you wish to bypass the Fedora Drupal Servlet Filter'),
'#required' => FALSE,
'#weight' => -9,
);
$form['fedora_password'] = array(
'#type' => 'textfield',
'#title' => 'Password',
'#default_value' => variable_get('fedora_password', ''),
'#description' => t('Password for this Fedora user.'),
'#required' => FALSE,
'#weight' => -8,
);
//$form['#submit'][] = 'fedora_repository_admin_settings_submit';
$form['#weight'] = 10;
return system_settings_form($form);
}
/**
* TRUE if the given string is of the correct format for a Fedora PID,
* e.g., namespace:identifier
* @param string $pid
* @return boolean
*/
function fedora_api_valid_pid($pid) {
$valid = FALSE;
if (strlen(trim($pid)) <= 64 && preg_match('/^([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+$/', trim($pid))) {
$valid = TRUE;
}
return $valid;
}