Browse Source

Added book content model to demo objects form.

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
095913faa7
  1. 12
      api/fedora_utils.inc
  2. 34
      fedora_repository.module
  3. 56
      ilives/fedora_ilives.install
  4. 87
      ilives/fedora_ilives.module

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() { function fedora_available() {
$ret = do_curl(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/management?wsdl'), 1); $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. // 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); 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;
}
} }
/** /**

34
fedora_repository.module

@ -1242,31 +1242,33 @@ function fedora_repository_demo_objects_form() {
} }
} else { } else {
$form['install_demos']['smileynote'] = array( $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(
$form['install_demos']['ingest'] = array( '#type' => 'submit',
'#type' => 'submit', '#name' => 'install_demos',
'#name' => 'install_demos', '#value' => 'Install Selected 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)) { if (!empty($existing_demos)) {
foreach ($existing_demos as $pid => $demo_object) { 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; return $form;
} }

56
ilives/fedora_ilives.install

@ -11,55 +11,9 @@
* definitions and deployment objects if necessary. * definitions and deployment objects if necessary.
*/ */
function fedora_ilives_enable() { function fedora_ilives_enable() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_reposiotry', 'api/fedora_utils');
$allowed_pids_str = variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: '); if (fedora_available()) {
$allowed_pids = explode(' ', $allowed_pids_str); module_load_include('module', 'fedora_ilives', 'fedora_ilives');
install_book_content_model_objects();
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');
}
} }

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 $form_state['rebuild'] = TRUE; // set to true to make sure the form gets rebuild
return $mods_save; 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');
}
}
Loading…
Cancel
Save