wrapper and the
// select box it contains
$changed_elements = $form['mods']['mods_record'];
-
+
unset($changed_elements['#prefix'], $changed_elements['suffix']); // we'll unset the div to make sure it won't be repeated!
// the actual JSON call
$javascript = drupal_add_js(NULL, NULL, 'header');
drupal_json(array(
- 'status' => TRUE,
- 'data' => theme('status_messages') . drupal_render($changed_elements), // rebuild just the part that needs to be changed
+ 'status' => TRUE,
+ 'data' => theme('status_messages') . drupal_render($changed_elements), // rebuild just the part that needs to be changed
'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
));
}
/**
* This is the handler for the 'type' box: pressing this will refresh the
kind wrapper.
- **/
+ * */
function fedora_ilives_retrieve_unapi_submit($form, &$form_state) {
unset($form_state['submit_handlers']); // unset all the submit handlers in the form
@@ -509,90 +466,35 @@ function fedora_ilives_retrieve_unapi_submit($form, &$form_state) {
return $mods_save;
}
-function fedora_ilives_form_alter(&$form, &$form_state, $form_id) {
+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';
+ $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' => '
',
- '#value' => l($book_item->pid, $book_item->url()),
- '#suffix' => '',
+ '#prefix' => '
',
+ '#value' => l($book_item->pid, $book_item->url()),
+ '#suffix' => '',
);
}
}
}
function fedora_ilives_install_demos_form_submit($form, &$form_state) {
- if ($form_state['values']['demo_collections']['ilives:bookCModel'] == 'ilives:bookCModel' ) {
+ 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');
}
}
@@ -626,7 +528,7 @@ function fedora_ilives_requirements($phase) {
if (!_fedora_ilives_viewer_available()) {
$requirements['iiv-war']['value'] = ("Not available");
$requirements['iiv-war']['severity'] = REQUIREMENT_ERROR;
- $requirements['iiv-war']['description'] = t('Ensure that Fedora is running and that the
IIV app is deployed.',
+ $requirements['iiv-war']['description'] = t('Ensure that Fedora is running and that the
IIV app is deployed.',
array('@iiv-home' => 'http://github.com/islandora/iiv'));
}
else {
@@ -642,4 +544,206 @@ function _fedora_ilives_viewer_available() {
$fedora_host = ("{$url['scheme']}://{$url['host']}" . (!empty($url['port']) ? ":{$url['port']}/" : '/'));
$response = drupal_http_request("$fedora_host/iiv/images/loading.gif");
return empty($response->error);
-}
\ No newline at end of file
+}
+
+function fedora_ilives_required_fedora_objects() {
+ // array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required)
+ $module_path = drupal_get_path('module', 'fedora_ilives');
+ return array(
+ 'fedora_ilives' => array(
+ 'module' => 'fedora_ilives',
+ 'title' => 'Island Lives Books',
+ 'objects' => array(
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_pageCModel.xml",
+ 'pid' => 'ilives:pageCModel',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_bookCModel.xml",
+ 'pid' => 'ilives:bookCModel',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_jp2Sdef.xml",
+ 'pid' => 'ilives:jp2Sdef',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_viewerSdef.xml",
+ 'pid' => 'ilives:viewerSdef',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_viewerSdep-bookCModel.xml",
+ 'pid' => 'ilives:viewerSdep-bookCModel',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_viewerSdep-pageCModel.xml",
+ 'pid' => 'ilives:viewerSdep-pageCModel',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_tei2htmlSdef.xml",
+ 'pid' => 'ilives:tei2htmlSdef',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_tei2htmlSdep-pageCModel.xml",
+ 'pid' => 'ilives:tei2htmlSdep-pageCModel',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_collection.xml",
+ 'pid' => 'ilives:collection',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'foxml_file' => "$module_path/xml/ilives_CollectionModel.xml",
+ 'pid' => 'ilives:CollectionModel',
+ 'dsid' => NULL,
+ 'datastream_file' => NULL,
+ 'dsversion' => NULL,
+ ),
+ array(
+ 'pid' => 'books:collection',
+ 'label' => 'Book Collection',
+ 'cmodel' => 'islandora:collectionCModel',
+ 'parent' => 'islandora:demos',
+ 'datastreams' => array(
+ array(
+ 'dsid' => 'COLLECTION_POLICY',
+ 'datastream_file' => "$module_path/xml/book_collection_policy.xml",
+ ),
+ array(
+ 'dsid' => 'TN',
+ 'datastream_file' => "$module_path/Crystal_Clear_mimetype_man.png",
+ 'mimetype' => 'image/png',
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+}
+
+function fedora_ilives_purge_pages_form(&$form_state, $pid, $referrer = NULL) {
+ global $base_url;
+ if (!user_access('purge objects and datastreams')) {
+ return NULL;
+ }
+ if ($pid == NULL) {
+ return NULL;
+ }
+ $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' => 'image_button',
+ '#src' => drupal_get_path('module', 'fedora_repository') . '/images/purge_big.png',
+ '#value' => t('Purge'),
+ '#suffix' => 'Purge all pages associated with this book',
+ );
+
+ 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 ALL pages?', $referrer, 'Are you sure you want to delete these objects? This action cannot be undone.', 'Purge Pages', 'Cancel'); //Had better luck leaving off last param 'name'
+ }
+ return $form;
+}
+
+function fedora_ilives_purge_pages_form_submit($form, &$form_state) {
+ module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
+ $pid = $form_state['values']['pid'];
+ 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 {
+
+ $query = <<
+ where (\$object \$title
+ and \$object
+ and \$object )
+ order by \$title
+
+XML;
+
+ // this is where you do your processing after they have pressed the confirm button
+ module_load_include('inc', 'fedora_repoitory', 'CollectionClass');
+ $collection = new CollectionClass($pid);
+ $contents = $collection->getRelatedItems($pid, $query);
+ $results_xml = simplexml_load_string($contents);
+ $resultsarray = array();
+ foreach ($results_xml->results->result as $result) {
+ $pid_to_delete = str_replace('info:fedora/', '', $result->object->attributes()->uri);
+
+ //parse contents
+
+ $params = array(
+ "pid" => $pid_to_delete,
+ "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));
+ 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($form_state['values']['referrer'])) {
+ $form_state['redirect'] = $form_state['values']['referrer'];
+ }
+ elseif (empty($collectionPid) && !empty($_SESSION['fedora_collection']) && $_SESSION['fedora_collection'] != $pid) {
+ $collectionPid = $_SESSION['fedora_collection'];
+
+ $form_state['redirect'] = "fedora/repository/$collectionPid/";
+ }
+ else {
+ $form_state['redirect'] = 'fedora/repository/';
+ }
+ }
+}