Browse Source

Merge branch 'master' of github.com:Islandora/islandora

pull/105/head
mroy 14 years ago
parent
commit
58e61752ef
  1. 9
      ObjectHelper.inc
  2. 12
      api/fedora_utils.inc
  3. 125
      fedora_repository.module
  4. 56
      ilives/fedora_ilives.install
  5. 87
      ilives/fedora_ilives.module
  6. 2
      plugins/pidfield/pidfield.module

9
ObjectHelper.inc

@ -61,7 +61,7 @@ class ObjectHelper {
}
if (variable_get('fedora_object_restrict_datastreams', TRUE) == TRUE ) {
if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE ) {
if (($cm = ContentModel::loadFromObject($pid)) == FALSE) {
drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error');
drupal_access_denied();
@ -498,8 +498,9 @@ class ObjectHelper {
$allow= fedora_fesl_check_roles($object_pid,'write');
}
if ($allow) {
$purgeObject = '<a title="' . t('Purge Object ') . $object_pid . '" href="' . base_path() . 'fedora/repository/purgeObject/' .
$object_pid . '"><img src="' . $base_url . '/' . $path . '/images/purge_big.png" alt="' . t('Purge Object') . '" class="icon">' . t('Purge Object') . '</a>';
//$purgeObject = '<a title="' . t('Purge Object ') . $object_pid . '" href="' . base_path() . 'fedora/repository/purgeObject/' .
//$object_pid . '"><img src="' . $base_url . '/' . $path . '/images/purge_big.png" alt="' . t('Purge Object') . '" class="icon">' . t('Purge Object') . '</a>';
$purgeObject = drupal_get_form('fedora_repository_purge_object_form', $object_pid, check_plain(substr(request_uri(), strlen(base_path()))));
}
} else {
$purgeObject = '&nbsp;';
@ -731,7 +732,7 @@ class ObjectHelper {
// $ingestObject = '<a title="'. t('Ingest a New object into ') . $collectionName . ' '. $collection_pid . '" href="'. base_path() .
$ingestObject = '<a title="' . t('Ingest a New object into !collection_name PID !collection_pid', array('!collection_name' => $collectionName, '!collection_pid' => $collection_pid)) . '" href="' . base_path() .
'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '"><img src="' . $base_url . '/' . $path .
'/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon">' . t('Add to this Collection') . '</a>';
'/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon"></a>' . t(' Add to this Collection');
}
}
}

12
api/fedora_utils.inc

@ -66,9 +66,21 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post
}
function fedora_available() {
$ret = do_curl(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/management?wsdl'), 1);
// A bit of a hack but the SOAP parser will cause a fatal error if you give it the wrong URL.
return (strpos($ret, 'wsdl:definitions') != FALSE);
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
$connection_helper = new ConnectionHelper();
$soap_client = $connection_helper->getSoapClient( variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) {
$result = $soap_client->__soapCall('describeRepository');
echo $result;
}
else {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection."));
return NULL;
}
}
/**

125
fedora_repository.module

@ -62,6 +62,7 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) {
'%name' => $name,
'%pid' => $pid)
);
$output .= drupal_get_form('fedora_repository_purge_object_form', $pid);
return $output;
}
@ -233,20 +234,41 @@ function fedora_repository_ingest_form(&$form_state, $collection_pid, $collectio
return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state);
}
function fedora_repository_purge_object_form(&$form_state, $pid, $collectionPid = NULL) {
function fedora_repository_purge_object_form(&$form_state, $pid, $referrer) {
global $base_url;
// $form['#redirect'] = "fedora/repository/$collectionPid/";
$form['pid'] = array(
'#type' => 'hidden',
'#value' => "$pid"
);
if (!strstr( drupal_get_destination(), urlencode('fedora/repository'))) {
$form['referrer'] = array(
'#type' => 'hidden',
'#value' => $referrer,
);
}
if(!isset($form_state['storage']['confirm'])) {
// do your normal $form definition here
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Purge')
);
if ($collectionPid == NULL) {
$collectionPid = $_SESSION['fedora_collection'];
$form['submit'] = array(
'#type' => 'image_button',
'#src' => drupal_get_path('module', 'fedora_repository').'/images/purge_big.png',
'#value' => t('Purge'),
'#suffix' => 'Purge this object',
);
if ($collectionPid == NULL) {
$collectionPid = $_SESSION['fedora_collection'];
}
//$form['#redirect'] = $referrer;
return $form;
}
else {
// ALSO do $form definition here. Your final submit handler (after user clicks Yes, I Confirm) will only see $form_state info defined here. Form you create here passed as param1 to confirm_form
return confirm_form($form, 'Confirm Purge Object', $referrer, 'Are you sure you want to delete this object? This action cannot be undone.', 'Delete', 'Cancel'); //Had better luck leaving off last param 'name'
}
// $form['#redirect'] = "fedora/repository/$collectionPid/";
return $form;
}
@ -384,31 +406,40 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$pid = $form_state['values']['pid'];
$params = array(
"pid" => $pid,
"logMessage" => "Purged",
"force" => ""
);
try {
$soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$object = $client->__soapCall('purgeObject', array(
$params
)
if (!isset($form_state['storage']['confirm'])) {
$form_state['storage']['confirm'] = TRUE; // this will cause the form to be rebuilt, entering the confirm part of the form
$form_state['rebuild'] = TRUE; // along with this
}
else {
// this is where you do your processing after they have pressed the confirm button
$params = array(
"pid" => $pid,
"logMessage" => "Purged",
"force" => ""
);
} catch (exception $e) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/',$e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error');
} else {
drupal_set_message(t($e->getMessage()), 'error');
try {
$soapHelper = new ConnectionHelper();
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
$object = $client->__soapCall('purgeObject', array($params));
unset($form_state['storage']['confirm']);
} catch (exception $e) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error');
} else {
drupal_set_message(t($e->getMessage()), 'error');
}
return;
}
if (empty($collectionPid)) {
$collectionPid = $_SESSION['fedora_collection'];
}
if (!empty($form_state['values']['referrer'])) {
$form_state['redirect'] = $form_state['values']['referrer'];
}
else {
$form_state['redirect'] = "fedora/repository/$collectionPid/";
}
return;
}
if (empty($collectionPid)) {
$collectionPid = $_SESSION['fedora_collection'];
}
$form_state['redirect'] = "fedora/repository/$collectionPid/";
}
function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) {
@ -1242,31 +1273,33 @@ function fedora_repository_demo_objects_form() {
}
} else {
$form['install_demos']['smileynote'] = array(
'#value' => '<p>If you install the <a href="http://www.fedora-commons.org/documentation/3.0b1/userdocs/distribution/installation.html#running.demo">Fedora demo objects</a> Islandora can display them as a collection.'
'#value' => '<p>If you install the '.l('fedora demo objects', 'https://wiki.duraspace.org/display/FCR30/Demonstration+Objects').' Islandora can display them as a collection.</p>'
);
}
if (!empty($form['install_demos']['demo_collections']['#options'])) {
$form['install_demos']['ingest'] = array(
'#type' => 'submit',
'#name' => 'install_demos',
'#value' => 'Install Selected Demos',
);
}
$form['install_demos']['ingest'] = array(
'#type' => 'submit',
'#name' => 'install_demos',
'#value' => 'Install Selected Demos',
'#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE,
);
$links_to_existing_demos = '<ul>';
$form['existing_demos'] = array(
'#prefix' => '<p>Demo collections already installed in this repository:</p><ul>',
'#suffix' => '</ul>',
);
if (!empty($existing_demos)) {
foreach ($existing_demos as $pid => $demo_object) {
$links_to_existing_demos .= '<li><a href="' . $demo_object->url() . '">' . $demo_object->pid . '</a></li>';
$form['existing_demos'][$demo_object->pid] = array (
'#prefix' => '<li>',
'#value' => l($demo_object->pid, $demo_object->url()),
'#suffix' => '</li>',
);
}
}
$links_to_existing_demos .= '</ul>';
$form['install_demos']['existing'] = array(
'#value' => '<p>Demo collections already installed in this repository:</p>' . $links_to_existing_demos,
);
return $form;
}

56
ilives/fedora_ilives.install

@ -11,55 +11,9 @@
* definitions and deployment objects if necessary.
*/
function fedora_ilives_enable() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$allowed_pids_str = variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ');
$allowed_pids = explode(' ', $allowed_pids_str);
if (!in_array('ilives:', $allowed_pids)) {
variable_set('fedora_pids_allowed', $allowed_pids_str . ' ilives:');
drupal_set_message('Added ilives: to the set of allowed pidnamespaces.', 'info');
}
if (!Fedora_Item::fedora_item_exists('ilives:bookCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_bookCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:pageCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_pageCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:jp2Sdef')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_jp2Sdef.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:tei2htmlSdef')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_tei2htmlSdef.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:tei2htmlSdep-pageCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_tei2htmlSdep-pageCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:viewerSdef')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_viewerSdef.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:viewerSdep-bookCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_viewerSdep-bookCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:viewerSdep-pageCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_viewerSdep-pageCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:collection')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_collection.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:CollectionModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_CollectionModel.xml');
}
module_load_include('inc', 'fedora_reposiotry', 'api/fedora_utils');
if (fedora_available()) {
module_load_include('module', 'fedora_ilives', 'fedora_ilives');
install_book_content_model_objects();
}
}

87
ilives/fedora_ilives.module

@ -508,3 +508,90 @@ function fedora_ilives_retrieve_unapi_submit($form, &$form_state) {
$form_state['rebuild'] = TRUE; // set to true to make sure the form gets rebuild
return $mods_save;
}
function fedora_ilives_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'fedora_repository_admin') {
# Custom settings for book module.
}
elseif ($form_id == 'fedora_repository_demo_objects_form') {
if (!Fedora_Item::fedora_item_exists('ilives:bookCModel')) {
$form['install_demos']['demo_collections']['#options']['ilives:bookCModel'] = 'Book-related content models and service objects';
$form['install_demos']['ingest']['#disabled'] = FALSE;
$form['#submit'][] = 'fedora_ilives_install_demos_form_submit';
}
else {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$book_item = new Fedora_Item('ilives:bookCModel');
$form['existing_demos']['ilives:bookCModel'] = array(
'#prefix' => '<li>',
'#value' => l($book_item->pid, $book_item->url()),
'#suffix' => '</li>',
);
}
}
}
function fedora_ilives_install_demos_form_submit($form, &$form_state) {
if ($form_state['values']['demo_collections']['ilives:bookCModel'] == 'ilives:bookCModel' ) {
# The ilives:bookCModel checkbox was checked
install_book_content_model_objects();
}
}
function install_book_content_model_objects() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$allowed_pids_str = variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ');
$allowed_pids = explode(' ', $allowed_pids_str);
if (!in_array('ilives:', $allowed_pids)) {
variable_set('fedora_pids_allowed', $allowed_pids_str . ' ilives:');
drupal_set_message('Added ilives: to the set of allowed pidnamespaces.', 'info');
}
if (!Fedora_Item::fedora_item_exists('ilives:bookCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_bookCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:pageCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_pageCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:jp2Sdef')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_jp2Sdef.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:tei2htmlSdef')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_tei2htmlSdef.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:tei2htmlSdep-pageCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_tei2htmlSdep-pageCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:viewerSdef')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_viewerSdef.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:viewerSdep-bookCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_viewerSdep-bookCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:viewerSdep-pageCModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_viewerSdep-pageCModel.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:collection')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_collection.xml');
}
if (!Fedora_Item::fedora_item_exists('ilives:CollectionModel')) {
Fedora_Item::ingest_from_foxml_file(drupal_get_path('module', 'fedora_ilives') . '/xml/ilives_CollectionModel.xml');
}
}

2
plugins/pidfield/pidfield.module

@ -281,7 +281,7 @@ function theme_pidfield_formatter_default($element) {
$item = new Fedora_Item($pid);
return fedora_repository_get_items($pid);
//return $item->objectProfile->objLabel;
}
return null;
}

Loading…
Cancel
Save