You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
6.1 KiB
186 lines
6.1 KiB
13 years ago
|
<?php
|
||
|
|
||
|
/**
|
||
12 years ago
|
* @file
|
||
12 years ago
|
* This administration form for this module.
|
||
13 years ago
|
*/
|
||
|
|
||
12 years ago
|
/**
|
||
12 years ago
|
* The administration form for the fedora repository connection.
|
||
|
*
|
||
|
* @param array $form
|
||
|
* The Drupal form definition.
|
||
|
* @param array $form_state
|
||
|
* The Drupal form state.
|
||
12 years ago
|
*
|
||
12 years ago
|
* @return array
|
||
12 years ago
|
* The Drupal form definition.
|
||
12 years ago
|
*/
|
||
12 years ago
|
function islandora_repository_admin(array $form, array &$form_state) {
|
||
13 years ago
|
module_load_include('inc', 'islandora', 'includes/utilities');
|
||
12 years ago
|
drupal_add_css(drupal_get_path('module', 'islandora') . '/css/islandora.admin.css');
|
||
13 years ago
|
|
||
|
$form = array();
|
||
12 years ago
|
if (isset($form_state['values']['islandora_base_url'])) {
|
||
13 years ago
|
$url = $form_state['values']['islandora_base_url'];
|
||
|
}
|
||
|
else {
|
||
|
$url = variable_get('islandora_base_url', 'http://localhost:8080/fedora');
|
||
|
}
|
||
|
|
||
12 years ago
|
$connection = islandora_get_tuque_connection(NULL, $url);
|
||
12 years ago
|
if (!$connection) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
13 years ago
|
try {
|
||
|
$info = $connection->api->a->describeRepository();
|
||
|
}
|
||
|
catch (RepositoryException $e) {
|
||
|
$info = FALSE;
|
||
|
}
|
||
|
|
||
12 years ago
|
if ($info) {
|
||
13 years ago
|
try {
|
||
|
$dc = $connection->api->m->getDatastream('fedora-system:ContentModel-3.0', 'DC');
|
||
|
}
|
||
|
catch (RepositoryException $e) {
|
||
|
$dc = FALSE;
|
||
|
}
|
||
|
}
|
||
12 years ago
|
|
||
|
if ($info) {
|
||
|
if ($dc) {
|
||
12 years ago
|
$confirmation_message = theme_image(array('path' => 'misc/watchdog-ok.png', 'attributes' => array()));
|
||
|
$confirmation_message .= t('Successfully connected to Fedora Server (Version !version).', array(
|
||
|
'!version' => $info['repositoryVersion']));
|
||
13 years ago
|
}
|
||
|
else {
|
||
12 years ago
|
$confirmation_message = theme_image(array('path' => 'misc/watchdog-warning.png', 'attributes' => array()));
|
||
|
$confirmation_message .= t('Unable to authenticate when connecting to to Fedora Server (Version !version). Please configure the !filter.',
|
||
|
array('!version' => $info['repositoryVersion'], '!filter' => 'Drupal Filter'));
|
||
13 years ago
|
}
|
||
13 years ago
|
}
|
||
|
else {
|
||
12 years ago
|
$confirmation_message = theme_image(array('path' => 'misc/watchdog-error.png', 'attributes' => array()));
|
||
|
$confirmation_message .= t('Unable to connect to Fedora server at !islandora_url', array(
|
||
|
'!islandora_url' => $url));
|
||
13 years ago
|
}
|
||
|
|
||
|
$form['islandora_tabs'] = array(
|
||
|
'#type' => 'vertical_tabs',
|
||
|
);
|
||
|
|
||
|
$form['islandora_tabs']['islandora_general'] = array(
|
||
|
'#type' => 'fieldset',
|
||
|
'#title' => t('General Configuarion'),
|
||
|
);
|
||
|
|
||
12 years ago
|
// Ajax wrapper for url checking.
|
||
13 years ago
|
$form['islandora_tabs']['islandora_general']['wrapper'] = array(
|
||
|
'#prefix' => '<div id="islandora-url">',
|
||
|
'#suffix' => '</div>',
|
||
|
'#type' => 'markup',
|
||
|
);
|
||
|
|
||
|
$form['islandora_tabs']['islandora_general']['wrapper']['islandora_base_url'] = array(
|
||
|
'#type' => 'textfield',
|
||
|
'#title' => t('Fedora base URL'),
|
||
|
'#default_value' => variable_get('islandora_base_url', 'http://localhost:8080/fedora'),
|
||
12 years ago
|
'#description' => t('The URL to use for REST connections <br /> !confirmation_message', array(
|
||
|
'!confirmation_message' => $confirmation_message,
|
||
|
)),
|
||
13 years ago
|
'#required' => TRUE,
|
||
|
'#ajax' => array(
|
||
|
'callback' => 'islandora_update_url_div',
|
||
|
'wrapper' => 'islandora-url',
|
||
|
'effect' => 'fade',
|
||
|
'event' => 'blur',
|
||
|
'progress' => array('type' => 'throbber'),
|
||
|
),
|
||
|
);
|
||
|
|
||
|
$form['islandora_tabs']['islandora_general']['islandora_repository_pid'] = array(
|
||
|
'#type' => 'textfield',
|
||
|
'#title' => t('Root Collection PID'),
|
||
|
'#default_value' => variable_get('islandora_repository_pid', 'islandora:root'),
|
||
|
'#description' => t('The PID of the Root Collection Object'),
|
||
|
'#required' => TRUE,
|
||
|
);
|
||
|
|
||
13 years ago
|
$form['islandora_tabs']['islandora_namespace'] = array(
|
||
|
'#type' => 'fieldset',
|
||
|
'#title' => t('Namespaces'),
|
||
|
);
|
||
|
|
||
|
$form['islandora_tabs']['islandora_namespace']['wrapper'] = array(
|
||
|
'#type' => 'markup',
|
||
|
'#prefix' => '<div id="islandora-namespace">',
|
||
|
'#suffix' => '</div>',
|
||
|
);
|
||
|
|
||
|
$form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_namespace_restriction_enforced'] = array(
|
||
13 years ago
|
'#weight' => -1,
|
||
|
'#type' => 'checkbox',
|
||
|
'#title' => t('Enforce namespace restrictions'),
|
||
12 years ago
|
'#description' => t("Allow administrator to restrict user's access to the PID namepaces listed below"),
|
||
13 years ago
|
'#default_value' => variable_get('islandora_namespace_restriction_enforced', FALSE),
|
||
13 years ago
|
'#ajax' => array(
|
||
|
'callback' => 'islandora_update_namespace_div',
|
||
|
'wrapper' => 'islandora-namespace',
|
||
|
'effect' => 'fade',
|
||
|
'event' => 'change',
|
||
|
'progress' => array('type' => 'throbber'),
|
||
|
),
|
||
13 years ago
|
);
|
||
12 years ago
|
|
||
|
if (isset($form_state['values']['islandora_namespace_restriction_enforced'])) {
|
||
13 years ago
|
$namespaces = $form_state['values']['islandora_namespace_restriction_enforced'];
|
||
|
}
|
||
|
else {
|
||
|
$namespaces = variable_get('islandora_namespace_restriction_enforced', FALSE);
|
||
|
}
|
||
13 years ago
|
|
||
12 years ago
|
if ($namespaces) {
|
||
13 years ago
|
$form['islandora_tabs']['islandora_namespace']['wrapper']['islandora_pids_allowed'] = array(
|
||
|
'#type' => 'textfield',
|
||
|
'#title' => t('PID namespaces allowed in this Drupal install'),
|
||
|
'#default_value' => variable_get('islandora_pids_allowed', 'default: demo: changeme: ilives: islandora-book: books: newspapers: '),
|
||
12 years ago
|
'#description' => t('A space separated list of PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos. <br /> islandora: is reserved and is always allowed.'),
|
||
13 years ago
|
'#weight' => 0,
|
||
|
);
|
||
|
}
|
||
13 years ago
|
|
||
|
return system_settings_form($form);
|
||
|
}
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Get the element to render for the AJAX event that triggered this callback.
|
||
|
*
|
||
|
* @param array $form
|
||
|
* The Drupal form definition.
|
||
|
* @param array $form_state
|
||
|
* The Drupal form state.
|
||
|
*
|
||
|
* @return array
|
||
|
* The form element to render.
|
||
13 years ago
|
*/
|
||
12 years ago
|
function islandora_update_url_div(array $form, array $form_state) {
|
||
13 years ago
|
return $form['islandora_tabs']['islandora_general']['wrapper'];
|
||
13 years ago
|
}
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Get the element to render for the AJAX event that triggered this callback.
|
||
|
*
|
||
|
* @param array $form
|
||
|
* The Drupal form definition.
|
||
|
* @param array $form_state
|
||
|
* The Drupal form state.
|
||
|
*
|
||
|
* @return array
|
||
|
* The form element to render.
|
||
13 years ago
|
*/
|
||
12 years ago
|
function islandora_update_namespace_div(array $form, array $form_state) {
|
||
13 years ago
|
return $form['islandora_tabs']['islandora_namespace']['wrapper'];
|
||
12 years ago
|
}
|