From b765fbb65b51a70adcac38e09f5d17cc640e40c1 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 3 Oct 2011 13:17:34 -0300 Subject: [PATCH 01/46] Moved the files to the appropriate name --- digital_repository.info | 9 + digital_repository.install | 158 ++ digital_repository.module | 2251 ++++++++++++++++++++++++++ digital_repository.solutionpacks.inc | 175 ++ 4 files changed, 2593 insertions(+) create mode 100644 digital_repository.info create mode 100644 digital_repository.install create mode 100644 digital_repository.module create mode 100644 digital_repository.solutionpacks.inc diff --git a/digital_repository.info b/digital_repository.info new file mode 100644 index 00000000..20ff4d30 --- /dev/null +++ b/digital_repository.info @@ -0,0 +1,9 @@ +; $Id$ +name = Digital Repository +dependencies[] = imageapi +dependencies[] = tabs +dependencies[] = islandora_content_model_forms +description = Shows a list of items in a fedora collection. +package = Islandora +version = 11.2.beta1 +core = 6.x diff --git a/digital_repository.install b/digital_repository.install new file mode 100644 index 00000000..43bbcf70 --- /dev/null +++ b/digital_repository.install @@ -0,0 +1,158 @@ +&-", $return_value); + $requirements['imagick']['title'] = t("Image Magick library"); + if ($return_value) { + $requirements['imagick']['value'] = t("Not installed"); + $requirements['imagick']['severity'] = REQUIREMENT_WARNING; + $requirements['imagick']['description'] = t('Ensure that the Image Magick library is installed.'); + } + else { + $requirements['imagick']['value'] = t("Installed"); + $requirements['imagick']['severity'] = REQUIREMENT_OK; + } + + // Test for Kakadu + system("hash kdu_compress 2>&-", $return_value); + $requirements['kakadu']['title'] = t("Kakadu library"); + if ($return_value) { + $requirements['kakadu']['value'] = t("Not installed"); + $requirements['kakadu']['severity'] = REQUIREMENT_WARNING; + $requirements['kakadu']['description'] = t('Ensure that the Kakadu library is installed.'); + } + else { + $requirements['kakadu']['value'] = t("Installed"); + $requirements['kakadu']['severity'] = REQUIREMENT_OK; + } + } + elseif ($phase == 'runtime') { + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + + $requirements['fedora-repository']['title'] = t("Fedora server"); + if (!fedora_available()) { + $requirements['fedora-repository']['value'] = t("Not available"); + $requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR; + $requirements['fedora-repository']['description'] = t('Ensure that Fedora is running and that the collection settings are correct.', array('@collection-settings' => $base_url . '/admin/settings/fedora_repository')); + } + else { + $requirements['fedora-repository']['value'] = t("Available"); + $requirements['fedora-repository']['severity'] = REQUIREMENT_OK; + } + + // Check for ImageMagick + $requirements['fedora-imagemagick']['title'] = t("ImageMagick convert in \$PATH"); + $result = exec('convert'); + if (!$result) { + $requirements['fedora-imagemagick']['value'] = t('Not in $PATH'); + $requirements['fedora-imagemagick']['description'] = t('Islandora will not be able to create thumbnails. Ensure that ImageMagick is installed and the convert command is executable by the web server user.'); + $requirements['fedora-imagemagick']['severity'] = REQUIREMENT_WARNING; + } + else { + $requirements['fedora-imagemagick']['value'] = t("Available"); + $requirements['fedora-imagemagick']['severity'] = REQUIREMENT_OK; + } + + $requirements['fedora-kakadu']['title'] = 'Kakadu kdu_compress in $PATH'; + $kdu_res = exec('kdu_compress -v'); + if (!$kdu_res) { + $requirements['fedora-kakadu']['value'] = ('Not in $PATH'); + $requirements['fedora-kakadu']['description'] = t('Islandora cannot convert TIFF image files to JPEG2000 format. Ensure Kakadu is installed and the kdu_compress command is executable by the web server user.'); + $requirements['fedora-kakadu']['severity'] = REQUIREMENT_WARNING; + } + else { + $requirements['fedora-kakadu']['value'] = t("Available"); + $requirements['fedora-kakadu']['severity'] = REQUIREMENT_OK; + } + } + + return $requirements; +} diff --git a/digital_repository.module b/digital_repository.module new file mode 100644 index 00000000..ea1c15c5 --- /dev/null +++ b/digital_repository.module @@ -0,0 +1,2251 @@ +createAdminForm(); +} + +/** + * drupal hook + * calls the fedora_repositorys_admin form + */ +function fedora_repository_menu() { + module_load_include('inc', 'fedora_repository', 'formClass'); + $adminMenu = new formClass(); + return $adminMenu->createMenu(); +} + +/** + * drupal hook to show help + * + * @param type $path + * @param type $arg + * @return type + */ +function fedora_repository_help($path, $arg) { + switch ($path) { + case 'admin/modules#description' : + return t('Grabs a list of items from a collection in Drupal that are presented on the home page.'); + case 'node/add#fedora_repository' : + return t('Use this page to grab a list of items from a Fedora collection.'); + } +} + +/** + * fedora repository purge object + * @param type $pid + * @param type $name + * @return type + */ +function fedora_repository_purge_object($pid = NULL, $name = NULL) { + if (!user_access('purge objects and datastreams')) { + drupal_set_message(t('You do not have access to add a datastream to this object.'), 'error'); + return ''; + } + if ($pid == NULL) { + drupal_set_message(t('You must specify an object pid to purge an object.'), 'error'); + return ''; + } + $output = t('Are you sure you wish to purge object %name %pid!
This cannot be undone
', + array( + '%name' => $name, + '%pid' => $pid) + ); + + $output .= drupal_get_form('fedora_repository_purge_object_form', $pid); + return $output; +} + +/** + * fedora repository collection view + * @global type $user + * @param type $pid + * @param type $collection + * @param type $pageNumber + * @return type + */ +function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pageNumber = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + global $user; + if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); + return ' '; + } + + $objectHelper = new ObjectHelper(); + if ($pid == NULL) { + $pid = variable_get('fedora_repository_pid', 'islandora:root'); + } + + $content = ''; + + module_load_include('inc', 'fedora_repository', 'CollectionClass'); + $collectionClass = new CollectionClass(); + $results = $collectionClass->getRelatedItems($pid, NULL); + $content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber); + + return $content; +} + +/** + * fedora repository ingest object + * @param type $collection_pid + * @param type $collection_label + * @param type $content_model + * @return type + */ +function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + if (!user_access('ingest new fedora objects')) { + drupal_set_message(t('You do not have permission to ingest.'), 'error'); + return ''; + } + + if (!valid_pid($collection_pid)) { + if (valid_pid(urldecode($collection_pid))) { + $collection_pid = urldecode($collection_pid); + } + else { + drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error'); + return ' '; + } + } + + if ($collection_pid == NULL) { + drupal_set_message(t('You must specify a collection object pid to ingest an object.'), 'error'); + return ''; + } + $output = drupal_get_form('fedora_repository_ingest_form', $collection_pid, $collection_label, $content_model); + + $breadcrumbs = array(); + $objectHelper = new ObjectHelper(); + $objectHelper->getBreadcrumbs($collection_pid, $breadcrumbs); + drupal_set_breadcrumb(array_reverse($breadcrumbs)); + + return $output; +} + +/** + * fedora repository ingest form submit + * @global type $base_url + * @global type $user + * @param array $form + * @param array $form_state + */ +function fedora_repository_ingest_form_submit(array $form, array &$form_state) { +//only validate the form if the submit button was pressed (other buttons may be used for AHAH + if ($form_state['storage']['xml']) { + if (module_exists('islandora_content_model_forms')) { + module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); + $xml_form = new IngestObjectMetadataForm(); + $xml_form->submit($form, $form_state); + } + } + else if ($form_state['clicked_button']['#id'] == 'edit-submit') { + global $base_url; + module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + + $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); + $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); + $err = TRUE; + $redirect = TRUE; + if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) { + $relationship = $cp->getRelationship(); + + if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { + $pid = $cp->getNextPid($contentModelDsid); + global $user; + $form_state['values']['user_id'] = $user->name; + $form_state['values']['pid'] = $pid; + $form_state['values']['content_model_pid'] = $contentModelPid; + $form_state['values']['relationship'] = $relationship; + + $err = (!$cm->execFormHandler($form_state['values'], $form_state)); + + $_SESSION['fedora_ingest_files'] = ''; //empty this variable + + $attr = $cm->getIngestFormAttributes(); + $redirect = $attr['redirect']; + + if ($redirect) { + $form_state['storage'] = NULL; + } + } + } + + if ($redirect) { + $form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}"; + } + } +} + +/** + * fedora repository ingest form validate + * @param type $form + * @param type $form_state + * @return type + */ +function fedora_repository_ingest_form_validate($form, &$form_state) { +//only validate the form if the submit button was pressed (other buttons may be used for AHAH + if ($form_state['clicked_button']['#id'] == 'edit-submit') { + switch ($form_state['storage']['step']) { + case 1: + $form_state['storage']['step']++; + $form_state['rebuild'] = TRUE; + break; + + case 2: +// XML based form. + if ($form_state['storage']['xml']) { + module_load_include('inc', 'xml_form_api', 'XMLForm'); + $xml_form = new XMLForm($form_state); + $xml_form->validate($form, $form_state); + } +// Get the uploaded file. + $validators = array(); + + if (!empty($_FILES['files']['name']['ingest-file-location'])) { + $fileObject = file_save_upload('ingest-file-location', $validators); + + file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME'); + $form_state['values']['ingest-file-location'] = $fileObject->filepath; + } + + if (isset($form_state['values']['ingest-file-location']) && file_exists($form_state['values']['ingest-file-location'])) { + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); + + $file = $form_state['values']['ingest-file-location']; + + $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); + $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); + + if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { + $allowedMimeTypes = $cm->getMimetypes(); + + $mimetype = new MimeClass(); + $dformat = $mimetype->getType($file); + + if (!empty($file)) { + if (!in_array($dformat, $allowedMimeTypes)) { + form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' . + implode(' ', $allowedMimeTypes))); + file_delete($file); + return; + } + elseif (!$cm->execIngestRules($file, $dformat)) { + drupal_set_message(t('Error following Content Model Rules'), 'error'); + foreach (ContentModel::$errors as $err) { + drupal_set_message($err, 'error'); + } + } + } + } + } + $form_state['rebuild'] = FALSE; + break; + } + } +} + +/** + * fedora repository ingest form + * @param type $form_state + * @param type $collection_pid + * @param type $collection_label + * @param type $content_model + * @return type + */ +function fedora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) { + module_load_include('inc', 'fedora_repository', 'formClass'); +// For the sake of easily maintaining the module in different core versions create our own form_values variable. + if (empty($form_state['storage']['step'])) { + $form_state['storage']['step'] = 1; + } + $ingestForm = new formClass(); + $form_state['storage']['content_model'] = $content_model; + $form_state['storage']['collection_pid'] = $collection_pid; + return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state); +} + +/** + * fedora repository purge object form + * @global type $base_url + * @param type $form_state + * @param type $pid + * @param type $referrer + * @return type + */ +function fedora_repository_purge_object_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 this object', + ); + if (!empty($collectionPid)) { + $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' + } + return $form; +} + +/** + * add stream + * @param type $collection_pid + * @param type $collectionName + * @return type + */ +function add_stream($collection_pid=NULL, $collectionName=NULL) { + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + if (!valid_pid($collection_pid)) { + drupal_set_message(t("This PID is not valid!"), 'error'); + return ' '; + } + if (!user_access('ingest new fedora objects')) { + drupal_set_message(t('You do not have permission to ingest.'), 'error'); + return ''; + } + if ($collection_pid == NULL) { + drupal_set_message(t('You must specify an collection object pid to ingest an object.'), 'error'); + return ''; + } + $output .= drupal_get_form('fedora_repository_add_stream_form', $pid); + + return $output; +} + +/** + * add stream form submit + * @global type $base_url + * @param type $form + * @param type $form_state + * @return type + */ +function add_stream_form_submit($form, &$form_state) { + global $base_url; + if (!empty($form_state['submit']) && $form_state['submit'] == 'OK') { + $form_state['rebuild'] = TRUE; + return; + } + module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + $pathToModule = drupal_get_path('module', 'fedora_repository'); + + $file = $form_state['values']['add-stream-file-location']; + + $pid = $form_state['values']['pid']; + $dsid = $form_state['values']['stream_id']; + $dsLabel = $form_state['values']['stream_label'] . substr($file, strrpos($file, '.')); // Add the file extention to the end of the label.; + $file_basename = basename($file); + $file_directory = dirname($file); + $streamUrl = $base_url . '/' . $file_directory . '/' . drupal_urlencode($file_basename); + + /* ----------------------------------------------------------------- + * need a better way to get mimetypes + */ + $mimetype = new MimeClass(); + $dformat = $mimetype->getType($file); + $controlGroup = "M"; + if ($dformat == 'text/xml') { + $controlGroup = 'X'; + } + try { + $item = new Fedora_Item($pid); + $item->add_datastream_from_url($streamUrl, $dsid, $dsLabel, $dformat, $controlGroup); + + $object_helper = new ObjectHelper(); + $object_helper->get_and_do_datastream_rules($pid, $dsid, $file); + + file_delete($file); + } catch (exception $e) { + drupal_set_message(t($e->getMessage()), 'error'); + return; + } + $form_state['rebuild'] = TRUE; +} + +/** + * add stream form + * @param type $form_state + * @param type $pid + * @return type + */ +function add_stream_form(&$form_state, $pid) { + module_load_include('inc', 'fedora_repository', 'formClass'); + $addDataStreamForm = new formClass(); + return $addDataStreamForm->createAddDataStreamForm($pid, $form_state); +} + +/** + * add stream form validate + * @param type $form + * @param type $form_state + * @return type + */ +function add_stream_form_validate($form, &$form_state) { + if ($form_state['clicked_button']['#value'] == 'OK') { + $form_state['rebuild'] = TRUE; + return; + } + $dsid = $form_state['values']['stream_id']; + $dsLabel = $form_state['values']['stream_label']; + if (strlen($dsid) > 64) { + form_set_error('', t('Data stream ID cannot be more than 64 characters.')); + return FALSE; + } + if (!(preg_match("/^[a-zA-Z]/", $dsid))) { + form_set_error('', t("Data stream ID ($dsid) has to start with a letter.")); + return FALSE; + } + if (strlen($dsLabel) > 64) { + form_set_error('', t('Data stream Label cannot be more than 64 characters.')); + return FALSE; + } + if (strpos($dsLabel, '/')) { + form_set_error('', t('Data stream Label cannot contain a "/".')); + return FALSE; + } + $validators = array( + // 'file_validate_is_image' => array(), + // 'file_validate_image_resolution' => array('85x85'), + // 'file_validate_size' => array(30 * 1024), + ); + + $fileObject = file_save_upload('add-stream-file-location', $validators); + +// Move the uploaded file to Drupal's files directory. + file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME'); + $form_state['values']['add-stream-file-location'] = $fileObject->filepath; +// TODO: Add error checking here. + $form_state['rebuild'] = FALSE; +} + +/** + * fedora repository purge stream + * @global type $user + * @param type $pid + * @param type $dsId + * @param type $name + * @return type + */ +function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + global $user; + if ($pid == NULL || $dsId == NULL) { + drupal_set_message(t('You must specify an object pid and DataStream ID to purge a datastream'), 'error'); + return ' '; + } + if (!fedora_repository_access(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) { + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to purge objects."), 'error'); + return ' '; + } + + $output = t('Are you sure you wish to purge this datastream %name
', + array( + '%name' => $name) + ); + $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); + return $output; +} + +/** + * fedora repository purge object form submit + * @param type $form + * @param type $form_state + * @return type + */ +function fedora_repository_purge_object_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 { +// this is where you do your processing after they have pressed the confirm button + $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)); + 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/'; + } + } +} + +/** + * fedora repository purge stream form + * @param type $form_state + * @param type $pid + * @param type $dsId + * @return type + */ +function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) { + $form['pid'] = array( + '#type' => 'hidden', + '#value' => "$pid" + ); + $form['dsid'] = array( + '#type' => 'hidden', + '#value' => "$dsId" + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Purge') + ); + + return $form; +} + +/** + * fedora repository purge stream form submit + * @global type $base_url + * @param type $form + * @param array $form_state + */ +function fedora_repository_purge_stream_form_submit($form, &$form_state) { + global $base_url; + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); +//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + $pid = $form_state['values']['pid']; + $item = new Fedora_Item($pid); + $dsid = $form_state['values']['dsid']; + try { + $item->purge_datastream($dsid); + } catch (exception $e) { + drupal_set_message(t($e->getMessage()), 'error'); + } + $form_state['redirect'] = $base_url . "/fedora/repository/$pid"; +} + +/** + * fedora repository replace stream + * @param type $pid + * @param type $dsId + * @param type $dsLabel + * @param type $collectionName + * @return type + */ +function fedora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) { + if ($pid == NULL || $dsId == NULL) { + drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error'); + return ''; + } + $output = drupal_get_form('fedora_repository_replace_stream_form', $pid, $dsId, $dsLabel); + + return $output; +} + +/** + * fedora repository replace stream form + * @param type $form_state + * @param type $pid + * @param type $dsId + * @param type $dsLabel + * @return type + */ +function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) { +//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'fedora_repository', ''); + module_load_include('inc', 'Fedora_Repository', 'formClass'); +//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + $replaceDataStreamForm = new formClass(); + return $replaceDataStreamForm->createReplaceDataStreamForm($pid, $dsId, $dsLabel, $form_state); +} + +/** + * fedora repository replace stream form validate + * @param type $form + * @param type $form_state + * @return type + */ +function fedora_repository_replace_stream_form_validate($form, &$form_state) { +// If a file was uploaded, process it. + if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name']['file'])) { + +// attempt to save the uploaded file + $file = file_save_upload('file', array(), file_directory_path()); + +// set error is file was not uploaded + if (!$file) { + form_set_error('file', 'Error uploading file.'); + return; + } + + $doc = new DOMDocument(); + module_load_include('inc', 'Fedora_Repository', 'MimeClass'); + $mime = new MimeClass(); + if ($mime->getType($file->filepath) == 'text/xml' && !$doc->load($file->filepath)) { + form_set_error('file', 'Invalid XML format.'); + return; + } + +// set files to form_state, to process when form is submitted + $form_state['values']['file'] = $file; + } +} + +/** + * fedora repository replace stream form submit + * @global type $base_url + * @param type $form + * @param array $form_state + */ +function fedora_repository_replace_stream_form_submit($form, &$form_state) { + global $base_url; + $file = $form_state['values']['file']; + $pid = $form_state['values']['pid']; + $dsid = $form_state['values']['dsId']; + $dsLabel = $form_state['values']['dsLabel']; + // Remove the original file extension from the label and add the new one + $indexOfDot = strrpos($dsLabel, '.'); //use strrpos to get the last dot + if ($indexOfDot !== FALSE) { + $dsLabel = substr($dsLabel, 0, $indexOfDot); + $dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.; + } + module_load_include('inc', 'Fedora_Repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + + $file_basename = basename($file->filepath); + $file_directory = dirname($file->filepath); + $streamUrl = $base_url . '/' . $file_directory . '/' . urlencode($file_basename); + + /* ----------------------------------------------------------------- + * TODO: need a better way to get mimetypes + */ + $mimetype = new MimeClass(); + $dformat = $mimetype->getType($file->filepath); + + $item = new Fedora_Item($pid); + + $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); + + $form_state['redirect'] = 'fedora/repository/' . $pid; +} + +/** + * fedora repository edit qdc page + * @global type $user + * @param type $pid + * @param type $dsId + * @return type + */ +function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + global $user; + if ($pid == NULL || $dsId == NULL) { + drupal_set_message(t('You must specify an object pid and a Dublin Core DataStream ID to edit metadata'), 'error'); + return ' '; + } + if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); + return ' '; + } + $output = drupal_get_form('fedora_repository_edit_qdc_form', $pid, $dsId); + + return $output; +} + +/** + * fedora repository edit qdc form + * @global type $user + * @param type $form_state + * @param type $pid + * @param type $dsId + * @return type + */ +function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + if ($pid == NULL) { + drupal_set_message(t('You must specify an object pid!'), 'error'); + } + global $user; + if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); + return ' '; + } + + module_load_include('inc', 'fedora_repository', 'formClass'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + $soapHelper = new ConnectionHelper(); + $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); +// Check if there is a custom edit metadata function defined in the content model. + + $breadcrumbs = array(); + $objectHelper = new ObjectHelper(); + $objectHelper->getBreadcrumbs($pid, $breadcrumbs); + drupal_set_breadcrumb(array_reverse($breadcrumbs)); + + + $output = ''; + if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { + $output = $cm->buildEditMetadataForm($pid, $dsId); + } + + if (empty($output)) { +// There is no custom function, so just load the standard QDC form. + $metaDataForm = new formClass(); +//currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now. + return $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state); + } + return $output; +} + +/** + * fedora repository edit qdc form validate + * @param type $form + * @param boolean $form_state + */ +function fedora_repository_edit_qdc_form_validate($form, &$form_state) { + if ($form_state['storage']['xml']) { + if ($form_state['storage']['step'] == 1) { + $form_state['storage']['step']++; + $form_state['rebuild'] = TRUE; + } + module_load_include('inc', 'xml_form_api', 'XMLForm'); + $xml_form = new XMLForm($form_state); + $xml_form->validate($form, $form_state); + } +} + +/** + * Check if there is a custom edit metadata function defined in the content model. If so, + * call it, if not do the submit action for the standard QDC metadata. Custom forms will + * need to implement their own equivalent to the FormClass->updateMetaData function + * + * @param array $form + * @param array $form_state + * @return + */ +function fedora_repository_edit_qdc_form_submit($form, &$form_state) { + if ($form_state['storage']['xml']) { + module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm'); + $xml_form = new EditObjectMetadataForm($form_state); + $xml_form->submit($form, $form_state); + } + else { + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + global $base_url; + if (strstr($form_state['clicked_button']['#id'], 'edit-submit')) { + +//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + $soap_helper = new ConnectionHelper(); + $client = $soap_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + +// Check the content model for a custom edit metadata form submit function. + if (isset($form_state['values']['pid'])) { + module_load_include('inc', 'fedora_repository', 'ContentModel'); + if (($cm = ContentModel::loadFromObject($form_state['values']['pid'])) !== FALSE) { + return $cm->handleEditMetadataForm($form_state['values']['form_id'], $form_state, $client); + } + } + + module_load_include('inc', 'fedora_repository', 'formClass'); + $metaDataForm = new formClass(); + $return_value = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $client); + $form_state['storage'] = NULL; + $form_state['redirect'] = $base_url . '/fedora/repository/' . $form_state['values']['pid']; + + return $return_value; + } + } +} + +/** + * drupal hook + * creates a new permission than can be assigned to roles + */ +function fedora_repository_perm() { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + return array( + OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, + OBJECTHELPER::$EDIT_FEDORA_METADATA, + OBJECTHELPER::$PURGE_FEDORA_OBJECTSANDSTREAMS, + OBJECTHELPER::$ADD_FEDORA_STREAMS, + OBJECTHELPER::$INGEST_FEDORA_OBJECTS, + OBJECTHELPER::$EDIT_TAGS_DATASTREAM, + OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, + OBJECTHELPER::$MANAGE_COLLECTIONS, + OBJECTHELPER::$DELETE_ENTIRE_COLLECTIONS, + OBJECTHELPER::$CREATE_BATCH_PROCESS, + ); +} + +/** + * drupal hook + * determines if a user has access to what they are asking for + * + * @param type $op + * @param type $node + * @param type $account + * @return type + */ +function fedora_repository_access($op, $node, $account) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + $objectHelper = new ObjectHelper(); + return $objectHelper->fedora_repository_access($op, $node, $account); +} + +/** + * Grabs a stream from fedora sets the mimetype and returns it. $dsID is the + * datastream id. + * @param $pid String + * @param $dsID String + */ +function makeObject($pid, $dsID) { + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + if (!valid_pid($pid)) { + drupal_set_message(t("Invalid PID!"), 'error'); + return ' '; + } + + if (!valid_dsid($dsID)) { + drupal_set_message(t("Invalid dsID!"), 'error'); + return ' '; + } + + if ($pid == NULL || $dsID == NULL) { + drupal_set_message(t("No pid or dsid given to create an object with.")); + return ' '; + } + global $user; + if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + drupal_access_denied(); + return; + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace."), 'error'); + return ' '; + } + + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + $objectHelper = new ObjectHelper(); + $objectHelper->makeObject($pid, $dsID); +} + +/** + * Sends an ITQL query to the Fedora Resource index (can only communicate with Kowari or mulgara) + * Reads the pid and datastream id as url parameters. Queries the collection object for the query + * if there is no query datastream falls back to the query shipped with the module. + * + * @global type $user + * @param type $pid + * @param type $dsId + * @param type $collection + * @param type $page_number + * @param type $limit + * @return type + */ +function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $page_number = NULL, $limit = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + global $user; + + if (!fedora_available()) { + drupal_set_message(t('The Fedora repository server is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); + return ''; + } + + if (!risearch_available()) { + drupal_set_message(t('The Fedora resource index search is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); + return ''; + } + + if ($pid == NULL) { + $pid = variable_get('fedora_repository_pid', 'islandora:root'); + } + + $item = new fedora_item($pid); + if (!$item->exists()) { + drupal_not_found(); + exit(); + } + + if ($pid & !valid_pid($pid)) { + drupal_set_message(t("Invalid PID!"), 'error'); + return ' '; + } + + if ($dsId & !valid_dsid($dsId)) { + drupal_set_message(t("Invalid dsID!"), 'error'); + return ' '; + } + if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (user_access('access administration pages')) { + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); + } + drupal_access_denied(); + exit; + return ' '; + } + + $objectHelper = new ObjectHelper(); + if ($pid == NULL) { + $pid = variable_get('fedora_repository_pid', 'islandora:root'); + } + $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); + if (in_array(-1, $headers)) { + drupal_access_denied(); + exit; + return ' '; + } + if ($dsId != NULL && $dsId != '-') { //if we have a dsID return the stream otherwise query for a collection of objects +//probably should check pid as well here. + return makeObject($pid, $dsId); + } + + $content = '
'; + + module_load_include('inc', 'fedora_repository', 'CollectionClass'); + $collectionClass = new CollectionClass(); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent'); + $breadcrumbs = array(); + $objectHelper->getBreadcrumbs($pid, $breadcrumbs); + drupal_set_breadcrumb(array_reverse($breadcrumbs)); + + $offset = $limit * $page_number; + $content_models = $objectHelper->get_content_models_list($pid); +// Each content model may return either a tabset array or plain HTML. If it's HTML, stick it in a tab. + $cmodels_tabs = array( + '#type' => 'tabset', + ); + foreach ($content_models as $content_model) { + $content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number); + if (is_array($content_model_fieldset)) { + $cmodels_tabs = array_merge($cmodels_tabs, $content_model_fieldset); + } + else { + $cmodels_tabs[$content_model->pid] = array( + '#type' => 'tabpage', + '#title' => $content_model->name, + '#content' => $content_model_fieldset, + ); + } + } +// Add a 'manage object' tab for all objects, where detailed list of content is shown. + $obj = new FedoraObjectDetailedContent($pid); + $object_details = $obj->showFieldSets(); + if ($object_details['fedora_object_details']['#selected'] == true){ + foreach($cmodels_tabs as $cmodel_tab){ + if (is_array($cmodel_tab)){ + $cmodel_tab['#selected'] = FALSE; + } + + } + } + $cmodels_tabs = array_merge($cmodels_tabs, $object_details); + + + return tabs_render($cmodels_tabs); +} + +/** + * fedora repository urlencode string + * @param type $str + * @return type + */ +function fedora_repository_urlencode_string($str) { + return htmlentities($str); +} + +/** + * Uses makeobject to get a stream. Sets the Content Disposition in the header so it suggests a filename + * and sends it as an attachment. This should prompt for a download of the object. + * + * @global type $user + * @param type $pid + * @param type $dsId + * @param type $label + * @param type $version + * @return type + */ +function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) { + global $user; + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + + if ($pid == NULL || $dsId == NULL) { + drupal_set_message(t("no pid or dsid given to create an object with!")); + return ' '; + } + + $objectHelper = new ObjectHelper(); + $objectHelper->makeObject($pid, $dsId, 1, $label, FALSE, $version); +} + +/** + * repository page + * @param type $pid + * @param type $dsId + * @param type $collection + * @param type $pageNumber + * @return type + */ +function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL) { +//do security check at fedora_repository_get_items function as it has to be called there in case +//someone trys to come in a back door. + return fedora_repository_get_items($pid, $dsId, $collection, $pageNumber); +} + +/** + * repository service + * @global type $user + * @param type $pid + * @param type $servicePid + * @param type $serviceMethod + * @return type + */ +function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + global $user; + + if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { +//drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error'); + drupal_access_denied(); + if (user_access('access administration pages')) { + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'error'); + } + return ' '; + } + if ($pid == NULL) { + $pid = variable_get('fedora_repository_pid', 'islandora:root'); + } + $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); + if (in_array(-1, $headers)) { + drupal_access_denied(); + exit; + return ' '; + } + + + $item = new Fedora_Item($pid); + if ($item !== FALSE) { + echo $item->get_dissemination($servicePid, $serviceMethod); + } + + exit(); +} + +//Search Stuff ******************************************************************** + +/** + * Implementation of hook_search(). + * sends a search query to fedora fgsearch which is backed by Lucene + * In our implementation of Fedora we have api-a and api-m locked down + * to authorized users but at the object level. We can query Lucene and the + * RI index to get a list of results without authorization but to view any + * datastreams users must be authorized. + * + * @param type $op + * @param type $keys + * @return array + */ +function fedora_repository_search($op = 'search', $keys = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + + switch ($op) { + case 'name': + if (user_access('view fedora collection')) { + return t('Digital Repository', array('-9')); + } + case 'search': + if (user_access('view fedora collection')) { +//demo search string ?operation=gfindObjects&indexName=DemoOnLucene&query=fgs.DS.first.text%3Achristmas&hitPageStart=11&hitPageSize=10 + $resultData = NULL; + $numberOfHitsPerPage = NULL; + $index = strpos($keys, '.'); + $test = substr($keys, 0, $index + 1); + $type = NULL; + if ($index > 0) { + $index = strpos($keys, ':'); + $type = substr($keys, 0, $index); + $keys = substr($keys, $index + 1); + } + + $index = strpos($keys, ':'); + $startPage = substr($keys, 0, $index); + if ($index > 1) { + $keys = substr($keys, $index + 1); + } + + if (!$startPage) { + $startPage = 1; + } + + $xmlDoc = NULL; + + $path = drupal_get_path('module', 'fedora_repository'); + $xmlDoc = new DomDocument(); + $xmlDoc->load($path . '/searchTerms.xml'); + $nodeList = $xmlDoc->getElementsByTagName('default'); + if (!$type) { +//$type = 'dc.description'; + $type = $nodeList->item(0)->nodeValue; + } + $nodeList = $xmlDoc->getElementsByTagName('number_of_results'); + $numberOfHitsPerPage = $nodeList->item(0)->nodeValue; + + $indexName = variable_get('fedora_index_name', 'DemoOnLucene'); + $keys = htmlentities(urlencode($keys)); + $searchQuery = NULL; + if (isset($type) && strcmp($type, ':')) { + $searchQuery = $type . ':' . $keys; + } + else { + $searchQuery = $keys; + } +//$searchQuery.=" AND (PID:vre OR PID:vre:ref OR PID:demo OR PID:changeme)"; + + $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest'); + $searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=copyXml&query=' . $searchQuery; + $searchString .= '&hitPageSize=' . $numberOfHitsPerPage . '&hitPageStart=' . $startPage; +//$searchString = htmlentities(urlencode($searchString)); + $searchUrl .= $searchString; + $objectHelper = new ObjectHelper(); + $resultData = do_curl($searchUrl); + + $results[] = array( + array( + 'data' => $resultData, + 'colspan' => 2 + ) + ); + return $results; + } + } // switch ($op) +} + +/** + * Implementation of hook_search_page(). + * Display the search results + * + * @param type $resultData + * @return array + */ +function fedora_repository_search_page($resultData) { + $path = drupal_get_path('module', 'fedora_repository'); + $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); + $proc = NULL; + if (!$resultData[0][0]['data']) { + return ''; //no results + } + $text = utf8_encode($resultData[0][0]['data']); + + try { + $proc = new XsltProcessor(); + } catch (Exception $e) { + $out[] = array( + array( + 'data' => $e->getMessage(), + 'colspan' => 2 + ) + ); + return $out; + } + +//inject into xsl stylesheet + $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on + $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl + $proc->setParameter('', 'objectsPage', base_path()); + $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); + $proc->registerPHPFunctions(); + $xsl = new DomDocument(); + if ($isRestricted) { + $xsl->load($path . '/xsl/results.xsl'); + } + else { + $xsl->load($path . '/xsl/unfilteredresults.xsl'); + } + + $input = new DomDocument(); + $didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data'])); + + if (!$didLoadOk) { + $results[] = array( + array( + 'data' => 'Error parsing results', + 'colspan' => 2 + ) + ); + } + else { + $xsl = $proc->importStylesheet($xsl); + $newdom = $proc->transformToDoc($input); + + $results[] = array( + array( + 'data' => $newdom->saveHTML(), + 'colspan' => 2 + ) + ); + } + + $header = array( + array( + 'data' => t('Collection results'), + NULL, + ), + (NULL) + ); + + $output .= theme('table', $header, $results); + return $output; +} + +/** + * Implementation of hook_form_alter(). + * allows the advanced search form in drupal + * + * @param type $form + * @param type $form_state + * @param type $form_id + */ +function fedora_repository_form_alter(&$form, &$form_state, $form_id) { +// Advanced node search form + module_load_include('inc', 'fedora_repository', 'SearchClass'); + $path = drupal_get_path('module', 'fedora_repository'); + if ($form_id == 'search_form' && arg(1) == 'fedora_repository' && user_access('use advanced search')) { + $default_value = $form['basic']['inline']['keys']['#default_value']; + $index = strpos($default_value, '.'); + $test = substr($default_value, 0, $index + 1); + $type = NULL; + if ($index > 0) { + $index = strpos($default_value, ':'); + $type = substr($default_value, 0, $index); + $default_value = substr($default_value, $index + 1); + } + $form['basic']['inline']['keys']['#default_value'] = $default_value; +// Keyword boxes: + $form['advanced'] = array( + '#type' => 'fieldset', + '#title' => t('Advanced search'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#attributes' => array( + 'class' => 'search-advanced' + ), + ); + $form['advanced']['keywords'] = array( + '#prefix' => '
', + '#suffix' => '
', + ); + $xmlDoc = new DomDocument(); + $xmlDoc->load($path . '/searchTerms.xml'); + $nodeList = $xmlDoc->getElementsByTagName('term'); + $searchClass = new SearchClass(); + $types = $searchClass->get_search_terms_array(); + + $form['advanced']['type'] = array( + '#type' => 'select', + '#title' => t('Choose a field to search'), + '#prefix' => '
', '#suffix' => '
', '#options' => $types, + '#default_value' => $type, + ); + $form['advanced']['submit'] = array( + '#type' => 'submit', + '#value' => t('Advanced search'), + '#prefix' => '
', '#suffix' => '
', + ); + $form['#validate'][] = 'fedora_repository_search_validate'; + } +} + +/** + * Implementation of hook_search_validate() + * + * @param type $form + * @param type $form_state + */ +function fedora_repository_search_validate($form, &$form_state) { +// Initialise using any existing basic search keywords. + $keys = $form_state['values']['processed_keys']; + + if (isset($form_state['values']['type'])) { + $type = $form_state['values']['type']; + if ($type) { + $keys = $type . ':' . $keys; + } + } + + if (!empty($keys)) { + form_set_value($form['basic']['inline']['processed_keys'], trim($keys), $form_state); //set the form string + } +} + +/** + * fedora repository theme + * @return type + */ +function fedora_repository_theme() { + return array( + 'fedora_repository_mnpl_advanced_search_form' => array( + 'arguments' => array( + 'form' => NULL, + ), + ), + 'fedora_repository_time' => array( + 'arguments' => array( + 'element' => NULL + ), + 'fedora_repository_solution_packs_list' => array( + 'arguments' => array( + 'solution_packs' => NULL, + ), + ), + ), + ); +} + +/** + * Get a list of terms from a lucene index + * + * @param type $field + * @param type $startTerm + * @param type $displayName + * @return type + */ +function fedora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) { + module_load_include('inc', 'fedora_repository', 'SearchClass'); + $searchClass = new SearchClass(); + return $searchClass->getTerms($field, $startTerm, $displayName); +} + +/** + * fedora repository mnpl advanced search form + * @return type + */ +function fedora_repository_mnpl_advanced_search_form() { + module_load_include('inc', 'fedora_repository', 'SearchClass'); + $searchClass = new SearchClass(); + return $searchClass->build_advanced_search_form(); +} + +/** + * theme fedora repository mnpl advanced search form + * @param type $form + * @return type + */ +function theme_fedora_repository_mnpl_advanced_search_form($form) { + module_load_include('inc', 'fedora_repository', 'SearchClass'); + $advanced_search_form = new SearchClass(); + return $advanced_search_form->theme_advanced_search_form($form); +} + +/** + * fedora repository mnpl advanced search + * @param type $query + * @param type $startPage + * @return type + */ +function fedora_repository_mnpl_advanced_search($query, $startPage = 1) { + module_load_include('inc', 'fedora_repository', 'SearchClass'); + $searchClass = new SearchClass(); + $retVal = $searchClass->custom_search($query, $startPage); + return $searchClass->custom_search($query, $startPage); +} + +/** + * fedora repository mnpl_advanced search form submit + * @param type $form + * @param type $form_state + */ +function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state) { + $type_id = $form_state['values']['type']; + $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3')); + $searchString = $form_state['values']['type1'] . ':' . $form_state['values']['fedora_terms1']; + if ($form_state['values']['fedora_terms2'] != '') { + $searchString .=' +' . $form_state['values']['andor1'] . '+' . $form_state['values']['type2'] . ':' . $form_state['values']['fedora_terms2']; + } + if ($repeat > 2 && $repeat < 9) { + for ($i = 3; $i < $repeat + 1; $i++) { + $t = $i - 1; + if ($form_state['values']["fedora_terms$i"] != '') { + $searchString .= '+' . $form_state['values']["andor$t"] . '+' . $form_state['values']["type$i"] . ':' . $form_state['values']["fedora_terms$i"]; + } + } + } + drupal_goto("fedora/repository/mnpl_advanced_search/$searchString"); +} + +/** + * fedora repository install demo page + * @return type + */ +function fedora_repository_install_demos_page() { + $output = drupal_get_form('fedora_repository_demo_objects_form'); + return $output; +} + +/** + * fedora repository demo objects form + * @return string + */ +function fedora_repository_demo_objects_form() { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + $form = array(); + $existing_demos = array(); + + $form['install_demos'] = array( + '#title' => t('Islandora Demo Collections'), + '#type' => 'fieldset', + '#description' => t('Install demo image and document collections and content models.'), + ); + $demo_objects = array(); +// Check if the top-level islandora collection exists. If not, display a button to ingest. + + $form['install_demos']['demo_collections'] = array( + '#type' => 'checkboxes', + '#title' => t('Collections to ingest'), + '#options' => array(), + '#description' => t('Choose which demo collections you would like ingested into the repository.'), + ); + + foreach (array( + 'islandora:collectionCModel' => 'Islandora default content models', + 'islandora:root' => 'Islandora top-level collection', + 'islandora:demos' => 'Islandora demos collection', + 'islandora:largeimages' => 'Sample large image content model (requires Djatoka and Kakadu.)', + ) + as $available_demo => $available_demo_desc) { + try { + $demo_objects[$available_demo] = new Fedora_Item($available_demo); + } catch (exception $e) { + + } + + if (empty($demo_objects[$available_demo]->objectProfile)) { +//The demo objects collection does not exist in the repository, display a button to ingest them. + $form['install_demos']['demo_collections']['#options'][$available_demo] = $available_demo_desc; + } + else { + array_push($existing_demos, $demo_objects[$available_demo]); + } + } + +// Check if the SmileyStuff collectoin exists, and if it has a COLLECTION_VIEW datastream. If it doesn't then we can add it. + + $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); + if (!empty($smiley_stuff->objectProfile)) { + $datastreams_list = $smiley_stuff->get_datastreams_list_as_array(); + if (empty($datastreams_list['COLLECTION_VIEW'])) { + $form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection'; + } + else { + $demo_objects['demo:SmileyStuff'] = $smiley_stuff; + } + } + else { + $form['install_demos']['smileynote'] = array( + '#value' => '

If you install the ' . l('fedora demo objects', 'https://wiki.duraspace.org/display/FCR30/Demonstration+Objects') . ' Islandora can display them as a collection.

' + ); + } + + $form['install_demos']['ingest'] = array( + '#type' => 'submit', + '#name' => 'install_demos', + '#value' => 'Install Selected Demos', + '#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE, + ); + + $form['existing_demos'] = array( + '#prefix' => '

Demo collections already installed in this repository:

', + ); + + if (!empty($existing_demos)) { + foreach ($existing_demos as $pid => $demo_object) { + + $form['existing_demos'][$demo_object->pid] = array( + '#prefix' => '
  • ', + '#value' => l($demo_object->pid, $demo_object->url()), + '#suffix' => '
  • ', + ); + } + } + + return $form; +} + +/** + * fedora repository demo objects form submit + * @global type $base_url + * @param type $form + * @param type $form_state + */ +function fedora_repository_demo_objects_form_submit($form, &$form_state) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/dublin_core'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + global $base_url; + if ($form_state['clicked_button']['#name'] == 'install_demos') { + if (!empty($form_state['values']['demo_collections']['islandora:collectionCModel'])) { + try { + $collectioncm = Fedora_Item::ingest_new_item('islandora:collectionCModel', 'A', 'Islandora Collection Content Model'); + $collectioncm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); + $collectioncm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + } catch (exception $e) { + + } + try { + $strictpdfcm = Fedora_Item::ingest_new_item('islandora:strict_pdf', 'A', 'Strict PDF Content Model'); + $strictpdfcm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); + $strictpdfcm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STRICT_PDFCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + } catch (exception $e) { + + } + +// Install a collection object that points to all content model objects + try { + $cmodel_collection_xml = Fedora_Item::create_object_FOXML('islandora:ContentModelCollection'); + $cmodel_collection = Fedora_Item::ingest_from_FOXML($cmodel_collection_xml); + +//$dc = new Dublin_Core(new Fedora_Item('islandora:ContentModelCollection')); + $dc = new Dublin_Core($cmodel_collection); + $dc->set_element('dc:title', array('Installed Content Model')); + $dc->save(); + $cmodel_collection->add_datastream_from_string('select $object $title from <#ri> + where ($object $title + and ($object + or $object ) + and $object ) + order by $title', 'QUERY', 'Content Model Collection Query', 'text/plain'); + $cmodel_collection->add_relationship('isMemberOfCollection', 'islandora:root'); + $cmodel_collection->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); + $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); + $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M'); + drupal_set_message(t("Successfully installed islandora:ContentModelCollection."), 'message'); + } catch (exception $e) { + + } + } + + if (!empty($form_state['values']['demo_collections']['islandora:root'])) { + $new_item = Fedora_Item::ingest_new_item('islandora:root', 'A', 'Islandora Top-level Collection'); + $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + try { + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + drupal_set_message(t("Successfully installed islandora:root."), 'message'); + } catch (exception $e) { + + } + } + + if (!empty($form_state['values']['demo_collections']['islandora:demos'])) { + $new_item = fedora_item::ingest_new_item('islandora:demos', 'A', 'Islandora Demo Collection'); + $new_item->add_relationship('isMemberOfCollection', 'islandora:root'); + $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + +// $cv = $new_item->add_datastream_from_file( drupal_get_path('module', 'fedora_repository') . '/collection_views/COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View.xml', 'text/xml', 'X'); + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + try { + $new_item = Fedora_Item::ingest_new_item('islandora:pdf_collection', 'A', 'PDF Collection'); + $new_item->add_relationship('isMemberOfCollection', 'islandora:demos'); + $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + drupal_set_message(t("Successfully installed islandora:demos."), 'message'); + } catch (exception $e) { + + } + } + + if (!empty($form_state['values']['demo_collections']['demo:SmileyStuff'])) { + $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); + $new_item = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/SmileyStuff-COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); + $smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos'); + $tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + $cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X'); + + $cm = new Fedora_Item('demo:DualResImage'); + try { + $cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X'); + } catch (exception $e) { + + } + $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection'); + try { + $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + drupal_set_message(t("Successfully installed demo:SmileyStuff collection view."), 'message'); + } catch (exception $e) { + + } + } + + if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) { + $error = ''; + foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml', + 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) { + try { + $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/' . $foxml_file); + } catch (exception $e) { + $error .= " - Problem ingesting $foxml_file"; + } + } + try { + $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/islandora_largeimages.xml'); + $tn = $item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + drupal_set_message(t("Successfully installed islandora:largeimages."), 'message'); + } catch (exception $e) { + $error .= " - Problem ingesting islandora:largeimages collection"; + } + } + + if (!empty($error)) { + drupal_set_message(t('Some problems occurred: ' . $error)); + } + } +} + +/** + * fedora repository required fedora objects + * @return type + */ +function fedora_repository_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_repository'); + return array( + 'fedora_repository' => array( + 'module' => 'fedora_repository', + 'title' => 'Islandora Core', + 'objects' => array( + array( + 'pid' => 'islandora:collectionCModel', + 'label' => 'Islandora Collection Content Model', + 'dsid' => 'ISLANDORACM', + 'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml", + 'dsversion' => 2, + 'cmodel' => 'fedora-system:ContentModel-3.0', + ), + + array( + 'pid' => 'islandora:root', + 'label' => 'Islandora Top-level Collection', + 'cmodel' => 'islandora:collectionCModel', + 'datastreams' => array( + array( + 'dsid' => 'COLLECTION_POLICY', + 'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", + ), + array( + 'dsid' => 'TN', + 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", + 'mimetype' => 'image/png', + ), + ), + ), + ), + ), + ); +} + +/** + * Functions to create a time selector form element type. + */ +function fedora_repository_elements() { + $type['fedora_repository_time'] = array( + "#input" => TRUE, + "#process" => array("fedora_repository_expand_time"), + ); + + return $type; +} + +/** + * fedora repository expand time + * @param type $element + * @return string + */ +function fedora_repository_expand_time($element) { +// Default to current time, check default_value but set value so that if +// default value is present it will override value + if (empty($element['#default_value'])) { + $element['#value'] = array( + 'hour' => intval(format_date(time(), 'custom', 'h')), + 'minute' => intval(format_date(time(), 'custom', 'i')), + ); + } + + $element['#tree'] = TRUE; + + foreach ($element['#value'] as $type => $value) { + switch ($type) { + case 'hour': + $options = drupal_map_assoc(range(1, 24)); + break; + case 'minute': + $options = range(0, 59); + break; + } + + if ($type != 'meridiem') { + foreach ($options as $option) { + strlen($option) <= 1 ? $options[$option] = 0 . $option : ''; + } + } + + $element[$type] = array( + '#type' => 'select', + '#default_value' => $element['#value'][$type], + '#options' => $options, + ); + } + + return $element; +} + +/** + * fedora repository time + * @param type $element + * @return type + */ +function fedora_repository_time($element) { + $output = '
    ' . $element['#children'] . '
    '; + return theme('form_element', $element, $output); +} + +/** + * theme fedora repository time + * @param type $element + * @return type + */ +function theme_fedora_repository_time($element) { + $output = '
    ' . $element['#children'] . '
    '; + return theme('form_element', $element, $output); +} + +/* Export (basket) functionality */ + +/** + * fedora repository remove item from basket + * @param type $pid + */ +function fedora_repository_remove_item_from_basket($pid) { + + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; + + $objectHelper = new ObjectHelper(); +// getting child PIDs if any + $cpids = $objectHelper->get_child_pids(array($pid)); + + if (array_key_exists($pid, $pids)) { +// remove item from basket + unset($_SESSION['basket']['processed'][$pid]); + } + if (!empty($cpids)) { // there are children + foreach ($cpids as $child_pid => $value) { +// remove child item from basket recursively + fedora_repository_remove_item_from_basket($child_pid); + } + } +} + +/** + * fedora repository basket + * @return type + */ +function fedora_repository_basket() { + $pids = _fedora_repository_get_basket_pids(); + $output = drupal_get_form('fedora_repository_basket_form', $pids); + + return $output; +} + +function fedora_repository_basket_form($form_state, $pids) { + $form = array(); + + if (!empty($pids)) { + $form['pid'] = array(); + $form['title'] = array(); + $form['desc'] = array(); + } + else { + return; + } + + ksort($pids); + foreach ($pids as $pid => $arr) { + $cbs[$pid] = ''; + + $form['pid'][$pid] = array('#value' => l($pid, "fedora/repository/$pid")); + $form['title'][$pid] = array('#value' => $arr['title']); + $form['desc'][$pid] = array('#value' => $arr['desc']); + } + + $form['remove'] = array( + '#type' => 'checkboxes', + '#options' => $cbs, + ); + + $form['remove_submit'] = array( + '#type' => 'submit', + '#value' => t('Remove selected'), + ); + + $form['remove_all'] = array( + '#type' => 'submit', + '#value' => t('Empty basket'), + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Export selected'), + ); + + $form['submit_all'] = array( + '#type' => 'submit', + '#value' => t('Export all'), + ); + + return $form; +} + +/** + * theme fedora repository basket form + * @param type $form + * @return string + */ +function theme_fedora_repository_basket_form($form) { + $header = array( + theme('table_select_header_cell'), + t('PID'), + t('Title'), + t('Description'), + ); + + if (isset($form['pid']) && is_array($form['pid'])) { + foreach (element_children($form['pid']) as $key) { + $rows[] = array( + drupal_render($form['remove'][$key]), + drupal_render($form['pid'][$key]), + drupal_render($form['title'][$key]), + drupal_render($form['desc'][$key]), + ); + } + } + else { + $rows[] = array(array('data' => t('Your basket is empty.'), 'colspan' => '4')); + } + + $output = theme('table', $header, $rows); + + $frm = drupal_render($form); + $output = $frm . $output . $frm; + + return $output; +} + +/** + * fedora repository basket form validate + * @param type $form + * @param type $form_state + */ +function fedora_repository_basket_form_validate($form, &$form_state) { + +} + +/** + * fedora repository basket form submit + * @global type $user + * @param type $form + * @param type $form_state + * @return type + */ +function fedora_repository_basket_form_submit($form, &$form_state) { + if ($form_state['values']['op'] == $form_state['values']['remove_submit']) { + $pids = $form_state['clicked_button']['#post']['remove']; + + if (isset($pids)) { + foreach ($pids as $pid) { + fedora_repository_remove_from_basket($pid); + } + drupal_set_message(t("Selected objects removed")); + return; + } + } + + if ($form_state['values']['op'] == $form_state['values']['remove_all']) { + _fedora_repository_empty_basket(); + drupal_set_message(t("Basket emptied")); + return; + } + + if ($form_state['values']['op'] == $form_state['values']['submit_all']) { + $msg = t("All objects exported to staging area"); + $pids = _fedora_repository_get_basket_pids(); + } + elseif ($form_state['values']['op'] == $form_state['values']['submit']) { + $msg = t("Selected objects exported to staging area"); + $pids = array_filter($form_state['values']['remove']); + } + + if (!empty($pids)) { + global $user; + $log = array(); + $success = TRUE; + $export_dir = variable_get('export_area', file_directory_path() . '/fedora_export_area') . '/' . $user->name . '/' . date("Ymd-His"); + $foxml_dir = $export_dir . '/foxml'; + + if (!file_exists($foxml_dir) && !@mkdir($foxml_dir, 0775, TRUE)) { + drupal_set_message(t("Failed to create foxml dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $foxml_dir)), 'error'); + return FALSE; + } + + module_load_include('inc', 'fedora_repository', 'api/fedora_export'); + foreach ($pids as $pid => $arr) { + + $objects_dir = $export_dir . '/objects/' . $pid; + if (!file_exists($objects_dir) && !@mkdir($objects_dir, 0775, TRUE)) { + drupal_set_message(t("Failed to create objects dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $objects_dir)), 'error'); + return FALSE; + } + + if (!export_to_export_area($pid, $foxml_dir, $objects_dir, $log)) { + $success = FALSE; + } + } + $msg = $success ? $msg : t("Failed to export objects to staging area"); + $msg .= ":
    " . implode("
    ", $log); + + drupal_set_message($msg, $success ? 'info' : 'error'); +//_fedora_repository_empty_basket(); + } + else { + drupal_set_message(t("No objects selected or basket empty"), 'error'); + } + + return; +} + +/** + * Get all pids saved to the basket. + * + * @return type + */ +function _fedora_repository_get_basket_pids() { + +// Set empty defaults if basket elements are missing + $_SESSION['basket'] = isset($_SESSION['basket']) ? $_SESSION['basket'] : array('processed' => array(), 'unprocessed' => array()); + $_SESSION['basket']['processed'] = isset($_SESSION['basket']['processed']) ? $_SESSION['basket']['processed'] : array(); + $_SESSION['basket']['unprocessed'] = isset($_SESSION['basket']['unprocessed']) ? $_SESSION['basket']['unprocessed'] : array(); + + $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; + + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + $ob = new ObjectHelper(); + foreach ($_SESSION['basket']['unprocessed'] as $pid) { +// Check if the pid already exists in the tree + if (array_key_exists($pid, $pids)) { + continue; + } + + $pids += $ob->get_all_related_pids($pid); +// $pids += array($pid); + } + + $_SESSION['basket']['processed'] = $pids; + $_SESSION['basket']['unprocessed'] = array(); + + return $pids; +} + +/** + * fedora repository empty basket + */ +function _fedora_repository_empty_basket() { + unset($_SESSION['basket']); +} + +/** + * fedora repository add to basket + * @param type $pid + * @param type $warn + * @param type $searchResultsFlag + */ +function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) { + if ($warn && _is_added_to_basket($pid)) { + drupal_set_message(t("Object already in basket")); + } + + if (!isset($_SESSION['basket'])) { + $_SESSION['basket'] = array(); + $_SESSION['basket']['unprocessed'] = array($pid => $pid); + } + else { + $_SESSION['basket']['unprocessed'][$pid] = $pid; + } + + if (!$searchResultsFlag) { + drupal_goto('fedora/basket'); + } +} + +/** + * fedora repository remove from basket + * @param type $pid + * @return type + */ +function fedora_repository_remove_from_basket($pid) { + if (isset($_SESSION['basket']['unprocessed'][$pid])) { + unset($_SESSION['basket']['unprocessed'][$pid]); + } + + if (isset($_SESSION['basket']['processed'][$pid])) { + unset($_SESSION['basket']['processed'][$pid]); + } + return; +} + +/** + * theme add to basket link + * @param type $pid + * @param type $type + * @return type + */ +function theme_add_to_basket_link($pid, $type = 'object') { + $object = t($type); + $path = drupal_urlencode($pid); + + $save = "export_big.png"; + $saved = "exported_big.png"; +// $path = drupal_get_path('module', 'Fedora_Repository').'/images/'.$save ; + /* + var_dump($path); + var_dump(theme('image',drupal_get_path('module', 'Fedora_Repository').'/images/'.$save)); + die(); + */ + if (!_is_added_to_basket($pid)) { + return l( + theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), + "fedora/repository/addToBasket/" . $path, + array('html' => TRUE) + ); + } + + return theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $saved, t("In basket"), t("This @object is already in your basket", array('@object' => $object))); +} + +/** + * is added to basket + * @param type $pid + * @param type $account + * @return type + */ +function _is_added_to_basket($pid, $account = NULL) { + return isset($_SESSION['basket']['unprocessed'][$pid]) || isset($_SESSION['basket']['processed'][$pid]); +// return db_result(db_query("SELECT uid FROM {repository_basket} WHERE uid = %d AND pid = '%s'", $account->uid, $pid)); +} + +/** + * fedora repository display schema + * @param type $file + * @return type + */ +function fedora_repository_display_schema($file) { + $path = drupal_get_path('module', 'fedora_repository'); + if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) { + drupal_goto($path . '/' . $file); + } + else { + drupal_goto(); + } + return; +} + +/** + * fedora repository batch reingest object + * @param type $object + * @param type $context + * @return type + */ +function fedora_repository_batch_reingest_object($object, &$context) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + if (!empty($object) && is_array($object)) { + $pid = $object['pid']; + if (!valid_pid($pid)) { + return NULL; + } +// Does the object exist? If so, purge it. + $item = new Fedora_Item($pid); + if ($item->exists()) { + $item->purge(t('Remove during re-install batch job')); + } + +// Ingest the object from the source file. + if (!empty($object['foxml_file'])) { + $foxml_file = $object['foxml_file']; + $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file); + if ($new_item->exists()) { +// Batch operation was successful. + $context['message'][] = "$new_item->pid installed."; + } + } + if (!empty($object['dsid']) && !empty($object['datastream_file'])) { + $datastreams = array( + array( + 'dsid' => $object['dsid'], + 'datastream_file' => $object['datastream_file'], + ) + ); + } + elseif (!empty($object['datastreams'])) { + $datastreams = $object['datastreams']; + } + + if (!empty($datastreams) && is_array($datastreams)) { + $label = !empty($object['label']) ? $object['label'] : ''; + if (empty($object['foxml_file']) && !isset($new_item)) { + $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); + } + if (!empty($object['cmodel'])) { + $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); + } + if (!empty($object['parent'])) { + $new_item->add_relationship('isMemberOfCollection', $object['parent']); + } + foreach ($datastreams as $ds) { + if ($ds['dsid'] == 'DC') { + $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml'); + } + else { + $new_item->add_datastream_from_file($ds['datastream_file'], $ds['dsid'], !empty($ds['label']) ? $ds['label'] : '', !empty($ds['mimetype']) ? $ds['mimetype'] : 'text/xml'); + } + } + } + } +} + +/** + * Content model, collection view and collection policy datastreams may now optionally define a version + * number in their top-level XML element as an attribute, as in: + * get_datastream_dissemination($dsid)); + } + elseif (isset($datastream_file)) { + $doc = simplexml_load_file($datastream_file); + } + + if (!empty($doc)) { + $attrs = $doc->attributes(); + foreach ($attrs as $name => $value) { + if ($name == 'version') { + $return = (int) $value; + break; + } + } + } + return $return; +} + +/** + * theme fedora repository solution pack list + * @param type $solution_packs + * @return string + */ +function theme_fedora_repository_solution_packs_list($solution_packs) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + $output = ''; + $header = array(); + $rows = array(); + + + + + drupal_add_css(drupal_get_path('module', 'update') . '/update.css'); + return $output; +} + +/** + * Implementation of hook_forms() + * @param string $form_id + * @return array + */ +function fedora_repository_forms($form_id) { + $forms = array(); + if (strpos($form_id, 'fedora_repository_solution_pack_form_') === 0) { + $forms[$form_id] = array( + 'callback' => 'fedora_repository_solution_pack_form', + ); + } + return $forms; +} diff --git a/digital_repository.solutionpacks.inc b/digital_repository.solutionpacks.inc new file mode 100644 index 00000000..de4ce137 --- /dev/null +++ b/digital_repository.solutionpacks.inc @@ -0,0 +1,175 @@ + $solution_pack_info) { + $objects = array(); + foreach ($solution_pack_info as $field => $value) { + switch ($field) { + case 'title': + $solution_pack_name = $value; + break; + case 'objects': + $objects = $value; + break; + } + } + $output .= drupal_get_form('fedora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects); + } + + return $output; +} + +/** + * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. + * @param array $solution_pack + */ +function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { + // Check each object to see if it is in the repository. + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + global $base_path; + $needs_update = FALSE; + $needs_install = FALSE; + $form = array(); + $form['solution_pack_module'] = array( + '#type' => 'hidden', + '#value' => $solution_pack_module, + ); + + if (!$form_state['submitted']) { + $form['soluction_pack_name'] = array( + '#type' => 'markup', + '#value' => t($solution_pack_name), + '#prefix' => '

    ', + '#suffix' => '

    ', + ); + $form['objects'] = array( + '#type' => 'fieldset', + '#title' => "Objects", + '#weight' => 10, + '#attributes' => array('class' => 'collapsed'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $table_header = array('PID', 'Status'); + $table_rows = array(); + + + foreach ($objects as $object) { + $datastreams = NULL; + if (isset($object['pid'])) { + $pid = $object['pid']; + + $item = new Fedora_Item($pid); + $table_row = array($object['pid']); + $object_status = t('Up-to-date'); + if (!$item->exists()) { + $object_status = 'Missing'; + $needs_install = TRUE; + } + else { + if (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { + $datastreams = array( + array( + 'dsid' => $object['dsid'], + 'datastream_file' => $object['datastream_file'], + 'dsversion' => $object['dsversion'], + ), + ); + } + elseif (!empty($object['datastreams'])) { + $datastreams = $object['datastreams']; + } + if (!empty($datastreams) && is_array($datastreams)) { + foreach ($datastreams as $ds) { + $ds_list = $item->get_datastreams_list_as_array(); + if (!array_key_exists($ds['dsid'], $ds_list)) { + $needs_update = TRUE; + $object_status = 'Missing datastream'; + break; + } + if (isset($ds['dsversion'])) { + // Check if the datastream is versioned and needs updating. + $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); + $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); + if ($available_version > $installed_version) { + $needs_update = TRUE; + $object_status = 'Out of date'; + break; + } + } + } + } + } + array_push($table_row, $object_status); + $table_rows[] = $table_row; + } + } + $form['objects']['table'] = array( + '#type' => 'markup', + '#value' => theme_table($table_header, $table_rows), + ); + } + + $form['install_status'] = array( + '#type' => 'markup', + '#prefix' => '' . t('Object status:') . ' ', + '#suffix' => ' ', + ); + if (!$needs_install && !$needs_update) { + $form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.'); + } + else { + $form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.'); + } + $form['submit'] = array( + '#value' => t('Install'), + '#disabled' => !$needs_install && !$needs_update, + '#type' => 'submit', + '#name' => $solution_pack_module, + ); + + $form['#submit'] = array( + 'fedora_repository_solution_pack_form_submit', + ); + return $form; +} + +function fedora_repository_solution_pack_form_submit($form, &$form_state) { + $what = $form_state; + $module_name = $form_state['values']['solution_pack_module']; + $solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); + $batch = array( + 'title' => t('Installing / updating solution pack objects'), + 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', + 'operations' => array(), + ); + + + foreach ($solution_pack_info[$module_name]['objects'] as $object) { + // Add this object to the batch job queue. + $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); + } + batch_set($batch); +} From 19f735cd49820349b134d45e9d30638ac122b3f0 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 3 Oct 2011 13:18:21 -0300 Subject: [PATCH 02/46] Removed old file names --- fedora_repository.info | 9 - fedora_repository.install | 158 -- fedora_repository.module | 2251 --------------------------- fedora_repository.solutionpacks.inc | 175 --- 4 files changed, 2593 deletions(-) delete mode 100644 fedora_repository.info delete mode 100644 fedora_repository.install delete mode 100644 fedora_repository.module delete mode 100644 fedora_repository.solutionpacks.inc diff --git a/fedora_repository.info b/fedora_repository.info deleted file mode 100644 index 20ff4d30..00000000 --- a/fedora_repository.info +++ /dev/null @@ -1,9 +0,0 @@ -; $Id$ -name = Digital Repository -dependencies[] = imageapi -dependencies[] = tabs -dependencies[] = islandora_content_model_forms -description = Shows a list of items in a fedora collection. -package = Islandora -version = 11.2.beta1 -core = 6.x diff --git a/fedora_repository.install b/fedora_repository.install deleted file mode 100644 index 43bbcf70..00000000 --- a/fedora_repository.install +++ /dev/null @@ -1,158 +0,0 @@ -&-", $return_value); - $requirements['imagick']['title'] = t("Image Magick library"); - if ($return_value) { - $requirements['imagick']['value'] = t("Not installed"); - $requirements['imagick']['severity'] = REQUIREMENT_WARNING; - $requirements['imagick']['description'] = t('Ensure that the Image Magick library is installed.'); - } - else { - $requirements['imagick']['value'] = t("Installed"); - $requirements['imagick']['severity'] = REQUIREMENT_OK; - } - - // Test for Kakadu - system("hash kdu_compress 2>&-", $return_value); - $requirements['kakadu']['title'] = t("Kakadu library"); - if ($return_value) { - $requirements['kakadu']['value'] = t("Not installed"); - $requirements['kakadu']['severity'] = REQUIREMENT_WARNING; - $requirements['kakadu']['description'] = t('Ensure that the Kakadu library is installed.'); - } - else { - $requirements['kakadu']['value'] = t("Installed"); - $requirements['kakadu']['severity'] = REQUIREMENT_OK; - } - } - elseif ($phase == 'runtime') { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - - $requirements['fedora-repository']['title'] = t("Fedora server"); - if (!fedora_available()) { - $requirements['fedora-repository']['value'] = t("Not available"); - $requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR; - $requirements['fedora-repository']['description'] = t('Ensure that Fedora is running and that the collection settings are correct.', array('@collection-settings' => $base_url . '/admin/settings/fedora_repository')); - } - else { - $requirements['fedora-repository']['value'] = t("Available"); - $requirements['fedora-repository']['severity'] = REQUIREMENT_OK; - } - - // Check for ImageMagick - $requirements['fedora-imagemagick']['title'] = t("ImageMagick convert in \$PATH"); - $result = exec('convert'); - if (!$result) { - $requirements['fedora-imagemagick']['value'] = t('Not in $PATH'); - $requirements['fedora-imagemagick']['description'] = t('Islandora will not be able to create thumbnails. Ensure that ImageMagick is installed and the convert command is executable by the web server user.'); - $requirements['fedora-imagemagick']['severity'] = REQUIREMENT_WARNING; - } - else { - $requirements['fedora-imagemagick']['value'] = t("Available"); - $requirements['fedora-imagemagick']['severity'] = REQUIREMENT_OK; - } - - $requirements['fedora-kakadu']['title'] = 'Kakadu kdu_compress in $PATH'; - $kdu_res = exec('kdu_compress -v'); - if (!$kdu_res) { - $requirements['fedora-kakadu']['value'] = ('Not in $PATH'); - $requirements['fedora-kakadu']['description'] = t('Islandora cannot convert TIFF image files to JPEG2000 format. Ensure Kakadu is installed and the kdu_compress command is executable by the web server user.'); - $requirements['fedora-kakadu']['severity'] = REQUIREMENT_WARNING; - } - else { - $requirements['fedora-kakadu']['value'] = t("Available"); - $requirements['fedora-kakadu']['severity'] = REQUIREMENT_OK; - } - } - - return $requirements; -} diff --git a/fedora_repository.module b/fedora_repository.module deleted file mode 100644 index ea1c15c5..00000000 --- a/fedora_repository.module +++ /dev/null @@ -1,2251 +0,0 @@ -createAdminForm(); -} - -/** - * drupal hook - * calls the fedora_repositorys_admin form - */ -function fedora_repository_menu() { - module_load_include('inc', 'fedora_repository', 'formClass'); - $adminMenu = new formClass(); - return $adminMenu->createMenu(); -} - -/** - * drupal hook to show help - * - * @param type $path - * @param type $arg - * @return type - */ -function fedora_repository_help($path, $arg) { - switch ($path) { - case 'admin/modules#description' : - return t('Grabs a list of items from a collection in Drupal that are presented on the home page.'); - case 'node/add#fedora_repository' : - return t('Use this page to grab a list of items from a Fedora collection.'); - } -} - -/** - * fedora repository purge object - * @param type $pid - * @param type $name - * @return type - */ -function fedora_repository_purge_object($pid = NULL, $name = NULL) { - if (!user_access('purge objects and datastreams')) { - drupal_set_message(t('You do not have access to add a datastream to this object.'), 'error'); - return ''; - } - if ($pid == NULL) { - drupal_set_message(t('You must specify an object pid to purge an object.'), 'error'); - return ''; - } - $output = t('Are you sure you wish to purge object %name %pid!
    This cannot be undone
    ', - array( - '%name' => $name, - '%pid' => $pid) - ); - - $output .= drupal_get_form('fedora_repository_purge_object_form', $pid); - return $output; -} - -/** - * fedora repository collection view - * @global type $user - * @param type $pid - * @param type $collection - * @param type $pageNumber - * @return type - */ -function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pageNumber = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); - return ' '; - } - - $objectHelper = new ObjectHelper(); - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - - $content = ''; - - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - $collectionClass = new CollectionClass(); - $results = $collectionClass->getRelatedItems($pid, NULL); - $content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber); - - return $content; -} - -/** - * fedora repository ingest object - * @param type $collection_pid - * @param type $collection_label - * @param type $content_model - * @return type - */ -function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - if (!user_access('ingest new fedora objects')) { - drupal_set_message(t('You do not have permission to ingest.'), 'error'); - return ''; - } - - if (!valid_pid($collection_pid)) { - if (valid_pid(urldecode($collection_pid))) { - $collection_pid = urldecode($collection_pid); - } - else { - drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error'); - return ' '; - } - } - - if ($collection_pid == NULL) { - drupal_set_message(t('You must specify a collection object pid to ingest an object.'), 'error'); - return ''; - } - $output = drupal_get_form('fedora_repository_ingest_form', $collection_pid, $collection_label, $content_model); - - $breadcrumbs = array(); - $objectHelper = new ObjectHelper(); - $objectHelper->getBreadcrumbs($collection_pid, $breadcrumbs); - drupal_set_breadcrumb(array_reverse($breadcrumbs)); - - return $output; -} - -/** - * fedora repository ingest form submit - * @global type $base_url - * @global type $user - * @param array $form - * @param array $form_state - */ -function fedora_repository_ingest_form_submit(array $form, array &$form_state) { -//only validate the form if the submit button was pressed (other buttons may be used for AHAH - if ($form_state['storage']['xml']) { - if (module_exists('islandora_content_model_forms')) { - module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); - $xml_form = new IngestObjectMetadataForm(); - $xml_form->submit($form, $form_state); - } - } - else if ($form_state['clicked_button']['#id'] == 'edit-submit') { - global $base_url; - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); - module_load_include('inc', 'fedora_repository', 'ContentModel'); - - $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); - $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); - $err = TRUE; - $redirect = TRUE; - if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) { - $relationship = $cp->getRelationship(); - - if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { - $pid = $cp->getNextPid($contentModelDsid); - global $user; - $form_state['values']['user_id'] = $user->name; - $form_state['values']['pid'] = $pid; - $form_state['values']['content_model_pid'] = $contentModelPid; - $form_state['values']['relationship'] = $relationship; - - $err = (!$cm->execFormHandler($form_state['values'], $form_state)); - - $_SESSION['fedora_ingest_files'] = ''; //empty this variable - - $attr = $cm->getIngestFormAttributes(); - $redirect = $attr['redirect']; - - if ($redirect) { - $form_state['storage'] = NULL; - } - } - } - - if ($redirect) { - $form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}"; - } - } -} - -/** - * fedora repository ingest form validate - * @param type $form - * @param type $form_state - * @return type - */ -function fedora_repository_ingest_form_validate($form, &$form_state) { -//only validate the form if the submit button was pressed (other buttons may be used for AHAH - if ($form_state['clicked_button']['#id'] == 'edit-submit') { - switch ($form_state['storage']['step']) { - case 1: - $form_state['storage']['step']++; - $form_state['rebuild'] = TRUE; - break; - - case 2: -// XML based form. - if ($form_state['storage']['xml']) { - module_load_include('inc', 'xml_form_api', 'XMLForm'); - $xml_form = new XMLForm($form_state); - $xml_form->validate($form, $form_state); - } -// Get the uploaded file. - $validators = array(); - - if (!empty($_FILES['files']['name']['ingest-file-location'])) { - $fileObject = file_save_upload('ingest-file-location', $validators); - - file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME'); - $form_state['values']['ingest-file-location'] = $fileObject->filepath; - } - - if (isset($form_state['values']['ingest-file-location']) && file_exists($form_state['values']['ingest-file-location'])) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'MimeClass'); - - $file = $form_state['values']['ingest-file-location']; - - $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); - $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); - - if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { - $allowedMimeTypes = $cm->getMimetypes(); - - $mimetype = new MimeClass(); - $dformat = $mimetype->getType($file); - - if (!empty($file)) { - if (!in_array($dformat, $allowedMimeTypes)) { - form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' . - implode(' ', $allowedMimeTypes))); - file_delete($file); - return; - } - elseif (!$cm->execIngestRules($file, $dformat)) { - drupal_set_message(t('Error following Content Model Rules'), 'error'); - foreach (ContentModel::$errors as $err) { - drupal_set_message($err, 'error'); - } - } - } - } - } - $form_state['rebuild'] = FALSE; - break; - } - } -} - -/** - * fedora repository ingest form - * @param type $form_state - * @param type $collection_pid - * @param type $collection_label - * @param type $content_model - * @return type - */ -function fedora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) { - module_load_include('inc', 'fedora_repository', 'formClass'); -// For the sake of easily maintaining the module in different core versions create our own form_values variable. - if (empty($form_state['storage']['step'])) { - $form_state['storage']['step'] = 1; - } - $ingestForm = new formClass(); - $form_state['storage']['content_model'] = $content_model; - $form_state['storage']['collection_pid'] = $collection_pid; - return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state); -} - -/** - * fedora repository purge object form - * @global type $base_url - * @param type $form_state - * @param type $pid - * @param type $referrer - * @return type - */ -function fedora_repository_purge_object_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 this object', - ); - if (!empty($collectionPid)) { - $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' - } - return $form; -} - -/** - * add stream - * @param type $collection_pid - * @param type $collectionName - * @return type - */ -function add_stream($collection_pid=NULL, $collectionName=NULL) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - if (!valid_pid($collection_pid)) { - drupal_set_message(t("This PID is not valid!"), 'error'); - return ' '; - } - if (!user_access('ingest new fedora objects')) { - drupal_set_message(t('You do not have permission to ingest.'), 'error'); - return ''; - } - if ($collection_pid == NULL) { - drupal_set_message(t('You must specify an collection object pid to ingest an object.'), 'error'); - return ''; - } - $output .= drupal_get_form('fedora_repository_add_stream_form', $pid); - - return $output; -} - -/** - * add stream form submit - * @global type $base_url - * @param type $form - * @param type $form_state - * @return type - */ -function add_stream_form_submit($form, &$form_state) { - global $base_url; - if (!empty($form_state['submit']) && $form_state['submit'] == 'OK') { - $form_state['rebuild'] = TRUE; - return; - } - module_load_include('inc', 'fedora_repository', 'MimeClass'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - $pathToModule = drupal_get_path('module', 'fedora_repository'); - - $file = $form_state['values']['add-stream-file-location']; - - $pid = $form_state['values']['pid']; - $dsid = $form_state['values']['stream_id']; - $dsLabel = $form_state['values']['stream_label'] . substr($file, strrpos($file, '.')); // Add the file extention to the end of the label.; - $file_basename = basename($file); - $file_directory = dirname($file); - $streamUrl = $base_url . '/' . $file_directory . '/' . drupal_urlencode($file_basename); - - /* ----------------------------------------------------------------- - * need a better way to get mimetypes - */ - $mimetype = new MimeClass(); - $dformat = $mimetype->getType($file); - $controlGroup = "M"; - if ($dformat == 'text/xml') { - $controlGroup = 'X'; - } - try { - $item = new Fedora_Item($pid); - $item->add_datastream_from_url($streamUrl, $dsid, $dsLabel, $dformat, $controlGroup); - - $object_helper = new ObjectHelper(); - $object_helper->get_and_do_datastream_rules($pid, $dsid, $file); - - file_delete($file); - } catch (exception $e) { - drupal_set_message(t($e->getMessage()), 'error'); - return; - } - $form_state['rebuild'] = TRUE; -} - -/** - * add stream form - * @param type $form_state - * @param type $pid - * @return type - */ -function add_stream_form(&$form_state, $pid) { - module_load_include('inc', 'fedora_repository', 'formClass'); - $addDataStreamForm = new formClass(); - return $addDataStreamForm->createAddDataStreamForm($pid, $form_state); -} - -/** - * add stream form validate - * @param type $form - * @param type $form_state - * @return type - */ -function add_stream_form_validate($form, &$form_state) { - if ($form_state['clicked_button']['#value'] == 'OK') { - $form_state['rebuild'] = TRUE; - return; - } - $dsid = $form_state['values']['stream_id']; - $dsLabel = $form_state['values']['stream_label']; - if (strlen($dsid) > 64) { - form_set_error('', t('Data stream ID cannot be more than 64 characters.')); - return FALSE; - } - if (!(preg_match("/^[a-zA-Z]/", $dsid))) { - form_set_error('', t("Data stream ID ($dsid) has to start with a letter.")); - return FALSE; - } - if (strlen($dsLabel) > 64) { - form_set_error('', t('Data stream Label cannot be more than 64 characters.')); - return FALSE; - } - if (strpos($dsLabel, '/')) { - form_set_error('', t('Data stream Label cannot contain a "/".')); - return FALSE; - } - $validators = array( - // 'file_validate_is_image' => array(), - // 'file_validate_image_resolution' => array('85x85'), - // 'file_validate_size' => array(30 * 1024), - ); - - $fileObject = file_save_upload('add-stream-file-location', $validators); - -// Move the uploaded file to Drupal's files directory. - file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME'); - $form_state['values']['add-stream-file-location'] = $fileObject->filepath; -// TODO: Add error checking here. - $form_state['rebuild'] = FALSE; -} - -/** - * fedora repository purge stream - * @global type $user - * @param type $pid - * @param type $dsId - * @param type $name - * @return type - */ -function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - if ($pid == NULL || $dsId == NULL) { - drupal_set_message(t('You must specify an object pid and DataStream ID to purge a datastream'), 'error'); - return ' '; - } - if (!fedora_repository_access(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to purge objects."), 'error'); - return ' '; - } - - $output = t('Are you sure you wish to purge this datastream %name
    ', - array( - '%name' => $name) - ); - $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); - return $output; -} - -/** - * fedora repository purge object form submit - * @param type $form - * @param type $form_state - * @return type - */ -function fedora_repository_purge_object_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 { -// this is where you do your processing after they have pressed the confirm button - $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)); - 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/'; - } - } -} - -/** - * fedora repository purge stream form - * @param type $form_state - * @param type $pid - * @param type $dsId - * @return type - */ -function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) { - $form['pid'] = array( - '#type' => 'hidden', - '#value' => "$pid" - ); - $form['dsid'] = array( - '#type' => 'hidden', - '#value' => "$dsId" - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Purge') - ); - - return $form; -} - -/** - * fedora repository purge stream form submit - * @global type $base_url - * @param type $form - * @param array $form_state - */ -function fedora_repository_purge_stream_form_submit($form, &$form_state) { - global $base_url; - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); -//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $pid = $form_state['values']['pid']; - $item = new Fedora_Item($pid); - $dsid = $form_state['values']['dsid']; - try { - $item->purge_datastream($dsid); - } catch (exception $e) { - drupal_set_message(t($e->getMessage()), 'error'); - } - $form_state['redirect'] = $base_url . "/fedora/repository/$pid"; -} - -/** - * fedora repository replace stream - * @param type $pid - * @param type $dsId - * @param type $dsLabel - * @param type $collectionName - * @return type - */ -function fedora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) { - if ($pid == NULL || $dsId == NULL) { - drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error'); - return ''; - } - $output = drupal_get_form('fedora_repository_replace_stream_form', $pid, $dsId, $dsLabel); - - return $output; -} - -/** - * fedora repository replace stream form - * @param type $form_state - * @param type $pid - * @param type $dsId - * @param type $dsLabel - * @return type - */ -function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) { -//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'fedora_repository', ''); - module_load_include('inc', 'Fedora_Repository', 'formClass'); -//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $replaceDataStreamForm = new formClass(); - return $replaceDataStreamForm->createReplaceDataStreamForm($pid, $dsId, $dsLabel, $form_state); -} - -/** - * fedora repository replace stream form validate - * @param type $form - * @param type $form_state - * @return type - */ -function fedora_repository_replace_stream_form_validate($form, &$form_state) { -// If a file was uploaded, process it. - if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name']['file'])) { - -// attempt to save the uploaded file - $file = file_save_upload('file', array(), file_directory_path()); - -// set error is file was not uploaded - if (!$file) { - form_set_error('file', 'Error uploading file.'); - return; - } - - $doc = new DOMDocument(); - module_load_include('inc', 'Fedora_Repository', 'MimeClass'); - $mime = new MimeClass(); - if ($mime->getType($file->filepath) == 'text/xml' && !$doc->load($file->filepath)) { - form_set_error('file', 'Invalid XML format.'); - return; - } - -// set files to form_state, to process when form is submitted - $form_state['values']['file'] = $file; - } -} - -/** - * fedora repository replace stream form submit - * @global type $base_url - * @param type $form - * @param array $form_state - */ -function fedora_repository_replace_stream_form_submit($form, &$form_state) { - global $base_url; - $file = $form_state['values']['file']; - $pid = $form_state['values']['pid']; - $dsid = $form_state['values']['dsId']; - $dsLabel = $form_state['values']['dsLabel']; - // Remove the original file extension from the label and add the new one - $indexOfDot = strrpos($dsLabel, '.'); //use strrpos to get the last dot - if ($indexOfDot !== FALSE) { - $dsLabel = substr($dsLabel, 0, $indexOfDot); - $dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.; - } - module_load_include('inc', 'Fedora_Repository', 'MimeClass'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - - $file_basename = basename($file->filepath); - $file_directory = dirname($file->filepath); - $streamUrl = $base_url . '/' . $file_directory . '/' . urlencode($file_basename); - - /* ----------------------------------------------------------------- - * TODO: need a better way to get mimetypes - */ - $mimetype = new MimeClass(); - $dformat = $mimetype->getType($file->filepath); - - $item = new Fedora_Item($pid); - - $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); - - $form_state['redirect'] = 'fedora/repository/' . $pid; -} - -/** - * fedora repository edit qdc page - * @global type $user - * @param type $pid - * @param type $dsId - * @return type - */ -function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - if ($pid == NULL || $dsId == NULL) { - drupal_set_message(t('You must specify an object pid and a Dublin Core DataStream ID to edit metadata'), 'error'); - return ' '; - } - if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); - return ' '; - } - $output = drupal_get_form('fedora_repository_edit_qdc_form', $pid, $dsId); - - return $output; -} - -/** - * fedora repository edit qdc form - * @global type $user - * @param type $form_state - * @param type $pid - * @param type $dsId - * @return type - */ -function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - if ($pid == NULL) { - drupal_set_message(t('You must specify an object pid!'), 'error'); - } - global $user; - if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); - return ' '; - } - - module_load_include('inc', 'fedora_repository', 'formClass'); - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); - $soapHelper = new ConnectionHelper(); - $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); -// Check if there is a custom edit metadata function defined in the content model. - - $breadcrumbs = array(); - $objectHelper = new ObjectHelper(); - $objectHelper->getBreadcrumbs($pid, $breadcrumbs); - drupal_set_breadcrumb(array_reverse($breadcrumbs)); - - - $output = ''; - if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { - $output = $cm->buildEditMetadataForm($pid, $dsId); - } - - if (empty($output)) { -// There is no custom function, so just load the standard QDC form. - $metaDataForm = new formClass(); -//currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now. - return $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state); - } - return $output; -} - -/** - * fedora repository edit qdc form validate - * @param type $form - * @param boolean $form_state - */ -function fedora_repository_edit_qdc_form_validate($form, &$form_state) { - if ($form_state['storage']['xml']) { - if ($form_state['storage']['step'] == 1) { - $form_state['storage']['step']++; - $form_state['rebuild'] = TRUE; - } - module_load_include('inc', 'xml_form_api', 'XMLForm'); - $xml_form = new XMLForm($form_state); - $xml_form->validate($form, $form_state); - } -} - -/** - * Check if there is a custom edit metadata function defined in the content model. If so, - * call it, if not do the submit action for the standard QDC metadata. Custom forms will - * need to implement their own equivalent to the FormClass->updateMetaData function - * - * @param array $form - * @param array $form_state - * @return - */ -function fedora_repository_edit_qdc_form_submit($form, &$form_state) { - if ($form_state['storage']['xml']) { - module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm'); - $xml_form = new EditObjectMetadataForm($form_state); - $xml_form->submit($form, $form_state); - } - else { - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); - global $base_url; - if (strstr($form_state['clicked_button']['#id'], 'edit-submit')) { - -//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $soap_helper = new ConnectionHelper(); - $client = $soap_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - -// Check the content model for a custom edit metadata form submit function. - if (isset($form_state['values']['pid'])) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - if (($cm = ContentModel::loadFromObject($form_state['values']['pid'])) !== FALSE) { - return $cm->handleEditMetadataForm($form_state['values']['form_id'], $form_state, $client); - } - } - - module_load_include('inc', 'fedora_repository', 'formClass'); - $metaDataForm = new formClass(); - $return_value = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $client); - $form_state['storage'] = NULL; - $form_state['redirect'] = $base_url . '/fedora/repository/' . $form_state['values']['pid']; - - return $return_value; - } - } -} - -/** - * drupal hook - * creates a new permission than can be assigned to roles - */ -function fedora_repository_perm() { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - return array( - OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, - OBJECTHELPER::$EDIT_FEDORA_METADATA, - OBJECTHELPER::$PURGE_FEDORA_OBJECTSANDSTREAMS, - OBJECTHELPER::$ADD_FEDORA_STREAMS, - OBJECTHELPER::$INGEST_FEDORA_OBJECTS, - OBJECTHELPER::$EDIT_TAGS_DATASTREAM, - OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, - OBJECTHELPER::$MANAGE_COLLECTIONS, - OBJECTHELPER::$DELETE_ENTIRE_COLLECTIONS, - OBJECTHELPER::$CREATE_BATCH_PROCESS, - ); -} - -/** - * drupal hook - * determines if a user has access to what they are asking for - * - * @param type $op - * @param type $node - * @param type $account - * @return type - */ -function fedora_repository_access($op, $node, $account) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - $objectHelper = new ObjectHelper(); - return $objectHelper->fedora_repository_access($op, $node, $account); -} - -/** - * Grabs a stream from fedora sets the mimetype and returns it. $dsID is the - * datastream id. - * @param $pid String - * @param $dsID String - */ -function makeObject($pid, $dsID) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - if (!valid_pid($pid)) { - drupal_set_message(t("Invalid PID!"), 'error'); - return ' '; - } - - if (!valid_dsid($dsID)) { - drupal_set_message(t("Invalid dsID!"), 'error'); - return ' '; - } - - if ($pid == NULL || $dsID == NULL) { - drupal_set_message(t("No pid or dsid given to create an object with.")); - return ' '; - } - global $user; - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { - drupal_access_denied(); - return; - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace."), 'error'); - return ' '; - } - - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - $objectHelper = new ObjectHelper(); - $objectHelper->makeObject($pid, $dsID); -} - -/** - * Sends an ITQL query to the Fedora Resource index (can only communicate with Kowari or mulgara) - * Reads the pid and datastream id as url parameters. Queries the collection object for the query - * if there is no query datastream falls back to the query shipped with the module. - * - * @global type $user - * @param type $pid - * @param type $dsId - * @param type $collection - * @param type $page_number - * @param type $limit - * @return type - */ -function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $page_number = NULL, $limit = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - global $user; - - if (!fedora_available()) { - drupal_set_message(t('The Fedora repository server is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); - return ''; - } - - if (!risearch_available()) { - drupal_set_message(t('The Fedora resource index search is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); - return ''; - } - - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - - $item = new fedora_item($pid); - if (!$item->exists()) { - drupal_not_found(); - exit(); - } - - if ($pid & !valid_pid($pid)) { - drupal_set_message(t("Invalid PID!"), 'error'); - return ' '; - } - - if ($dsId & !valid_dsid($dsId)) { - drupal_set_message(t("Invalid dsID!"), 'error'); - return ' '; - } - if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { - if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); - } - drupal_access_denied(); - exit; - return ' '; - } - - $objectHelper = new ObjectHelper(); - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); - if (in_array(-1, $headers)) { - drupal_access_denied(); - exit; - return ' '; - } - if ($dsId != NULL && $dsId != '-') { //if we have a dsID return the stream otherwise query for a collection of objects -//probably should check pid as well here. - return makeObject($pid, $dsId); - } - - $content = '
    '; - - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - $collectionClass = new CollectionClass(); - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent'); - $breadcrumbs = array(); - $objectHelper->getBreadcrumbs($pid, $breadcrumbs); - drupal_set_breadcrumb(array_reverse($breadcrumbs)); - - $offset = $limit * $page_number; - $content_models = $objectHelper->get_content_models_list($pid); -// Each content model may return either a tabset array or plain HTML. If it's HTML, stick it in a tab. - $cmodels_tabs = array( - '#type' => 'tabset', - ); - foreach ($content_models as $content_model) { - $content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number); - if (is_array($content_model_fieldset)) { - $cmodels_tabs = array_merge($cmodels_tabs, $content_model_fieldset); - } - else { - $cmodels_tabs[$content_model->pid] = array( - '#type' => 'tabpage', - '#title' => $content_model->name, - '#content' => $content_model_fieldset, - ); - } - } -// Add a 'manage object' tab for all objects, where detailed list of content is shown. - $obj = new FedoraObjectDetailedContent($pid); - $object_details = $obj->showFieldSets(); - if ($object_details['fedora_object_details']['#selected'] == true){ - foreach($cmodels_tabs as $cmodel_tab){ - if (is_array($cmodel_tab)){ - $cmodel_tab['#selected'] = FALSE; - } - - } - } - $cmodels_tabs = array_merge($cmodels_tabs, $object_details); - - - return tabs_render($cmodels_tabs); -} - -/** - * fedora repository urlencode string - * @param type $str - * @return type - */ -function fedora_repository_urlencode_string($str) { - return htmlentities($str); -} - -/** - * Uses makeobject to get a stream. Sets the Content Disposition in the header so it suggests a filename - * and sends it as an attachment. This should prompt for a download of the object. - * - * @global type $user - * @param type $pid - * @param type $dsId - * @param type $label - * @param type $version - * @return type - */ -function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) { - global $user; - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - - if ($pid == NULL || $dsId == NULL) { - drupal_set_message(t("no pid or dsid given to create an object with!")); - return ' '; - } - - $objectHelper = new ObjectHelper(); - $objectHelper->makeObject($pid, $dsId, 1, $label, FALSE, $version); -} - -/** - * repository page - * @param type $pid - * @param type $dsId - * @param type $collection - * @param type $pageNumber - * @return type - */ -function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL) { -//do security check at fedora_repository_get_items function as it has to be called there in case -//someone trys to come in a back door. - return fedora_repository_get_items($pid, $dsId, $collection, $pageNumber); -} - -/** - * repository service - * @global type $user - * @param type $pid - * @param type $servicePid - * @param type $serviceMethod - * @return type - */ -function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - - if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { -//drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error'); - drupal_access_denied(); - if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'error'); - } - return ' '; - } - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); - if (in_array(-1, $headers)) { - drupal_access_denied(); - exit; - return ' '; - } - - - $item = new Fedora_Item($pid); - if ($item !== FALSE) { - echo $item->get_dissemination($servicePid, $serviceMethod); - } - - exit(); -} - -//Search Stuff ******************************************************************** - -/** - * Implementation of hook_search(). - * sends a search query to fedora fgsearch which is backed by Lucene - * In our implementation of Fedora we have api-a and api-m locked down - * to authorized users but at the object level. We can query Lucene and the - * RI index to get a list of results without authorization but to view any - * datastreams users must be authorized. - * - * @param type $op - * @param type $keys - * @return array - */ -function fedora_repository_search($op = 'search', $keys = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - - switch ($op) { - case 'name': - if (user_access('view fedora collection')) { - return t('Digital Repository', array('-9')); - } - case 'search': - if (user_access('view fedora collection')) { -//demo search string ?operation=gfindObjects&indexName=DemoOnLucene&query=fgs.DS.first.text%3Achristmas&hitPageStart=11&hitPageSize=10 - $resultData = NULL; - $numberOfHitsPerPage = NULL; - $index = strpos($keys, '.'); - $test = substr($keys, 0, $index + 1); - $type = NULL; - if ($index > 0) { - $index = strpos($keys, ':'); - $type = substr($keys, 0, $index); - $keys = substr($keys, $index + 1); - } - - $index = strpos($keys, ':'); - $startPage = substr($keys, 0, $index); - if ($index > 1) { - $keys = substr($keys, $index + 1); - } - - if (!$startPage) { - $startPage = 1; - } - - $xmlDoc = NULL; - - $path = drupal_get_path('module', 'fedora_repository'); - $xmlDoc = new DomDocument(); - $xmlDoc->load($path . '/searchTerms.xml'); - $nodeList = $xmlDoc->getElementsByTagName('default'); - if (!$type) { -//$type = 'dc.description'; - $type = $nodeList->item(0)->nodeValue; - } - $nodeList = $xmlDoc->getElementsByTagName('number_of_results'); - $numberOfHitsPerPage = $nodeList->item(0)->nodeValue; - - $indexName = variable_get('fedora_index_name', 'DemoOnLucene'); - $keys = htmlentities(urlencode($keys)); - $searchQuery = NULL; - if (isset($type) && strcmp($type, ':')) { - $searchQuery = $type . ':' . $keys; - } - else { - $searchQuery = $keys; - } -//$searchQuery.=" AND (PID:vre OR PID:vre:ref OR PID:demo OR PID:changeme)"; - - $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest'); - $searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=copyXml&query=' . $searchQuery; - $searchString .= '&hitPageSize=' . $numberOfHitsPerPage . '&hitPageStart=' . $startPage; -//$searchString = htmlentities(urlencode($searchString)); - $searchUrl .= $searchString; - $objectHelper = new ObjectHelper(); - $resultData = do_curl($searchUrl); - - $results[] = array( - array( - 'data' => $resultData, - 'colspan' => 2 - ) - ); - return $results; - } - } // switch ($op) -} - -/** - * Implementation of hook_search_page(). - * Display the search results - * - * @param type $resultData - * @return array - */ -function fedora_repository_search_page($resultData) { - $path = drupal_get_path('module', 'fedora_repository'); - $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); - $proc = NULL; - if (!$resultData[0][0]['data']) { - return ''; //no results - } - $text = utf8_encode($resultData[0][0]['data']); - - try { - $proc = new XsltProcessor(); - } catch (Exception $e) { - $out[] = array( - array( - 'data' => $e->getMessage(), - 'colspan' => 2 - ) - ); - return $out; - } - -//inject into xsl stylesheet - $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on - $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl - $proc->setParameter('', 'objectsPage', base_path()); - $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); - $proc->registerPHPFunctions(); - $xsl = new DomDocument(); - if ($isRestricted) { - $xsl->load($path . '/xsl/results.xsl'); - } - else { - $xsl->load($path . '/xsl/unfilteredresults.xsl'); - } - - $input = new DomDocument(); - $didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data'])); - - if (!$didLoadOk) { - $results[] = array( - array( - 'data' => 'Error parsing results', - 'colspan' => 2 - ) - ); - } - else { - $xsl = $proc->importStylesheet($xsl); - $newdom = $proc->transformToDoc($input); - - $results[] = array( - array( - 'data' => $newdom->saveHTML(), - 'colspan' => 2 - ) - ); - } - - $header = array( - array( - 'data' => t('Collection results'), - NULL, - ), - (NULL) - ); - - $output .= theme('table', $header, $results); - return $output; -} - -/** - * Implementation of hook_form_alter(). - * allows the advanced search form in drupal - * - * @param type $form - * @param type $form_state - * @param type $form_id - */ -function fedora_repository_form_alter(&$form, &$form_state, $form_id) { -// Advanced node search form - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $path = drupal_get_path('module', 'fedora_repository'); - if ($form_id == 'search_form' && arg(1) == 'fedora_repository' && user_access('use advanced search')) { - $default_value = $form['basic']['inline']['keys']['#default_value']; - $index = strpos($default_value, '.'); - $test = substr($default_value, 0, $index + 1); - $type = NULL; - if ($index > 0) { - $index = strpos($default_value, ':'); - $type = substr($default_value, 0, $index); - $default_value = substr($default_value, $index + 1); - } - $form['basic']['inline']['keys']['#default_value'] = $default_value; -// Keyword boxes: - $form['advanced'] = array( - '#type' => 'fieldset', - '#title' => t('Advanced search'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#attributes' => array( - 'class' => 'search-advanced' - ), - ); - $form['advanced']['keywords'] = array( - '#prefix' => '
    ', - '#suffix' => '
    ', - ); - $xmlDoc = new DomDocument(); - $xmlDoc->load($path . '/searchTerms.xml'); - $nodeList = $xmlDoc->getElementsByTagName('term'); - $searchClass = new SearchClass(); - $types = $searchClass->get_search_terms_array(); - - $form['advanced']['type'] = array( - '#type' => 'select', - '#title' => t('Choose a field to search'), - '#prefix' => '
    ', '#suffix' => '
    ', '#options' => $types, - '#default_value' => $type, - ); - $form['advanced']['submit'] = array( - '#type' => 'submit', - '#value' => t('Advanced search'), - '#prefix' => '
    ', '#suffix' => '
    ', - ); - $form['#validate'][] = 'fedora_repository_search_validate'; - } -} - -/** - * Implementation of hook_search_validate() - * - * @param type $form - * @param type $form_state - */ -function fedora_repository_search_validate($form, &$form_state) { -// Initialise using any existing basic search keywords. - $keys = $form_state['values']['processed_keys']; - - if (isset($form_state['values']['type'])) { - $type = $form_state['values']['type']; - if ($type) { - $keys = $type . ':' . $keys; - } - } - - if (!empty($keys)) { - form_set_value($form['basic']['inline']['processed_keys'], trim($keys), $form_state); //set the form string - } -} - -/** - * fedora repository theme - * @return type - */ -function fedora_repository_theme() { - return array( - 'fedora_repository_mnpl_advanced_search_form' => array( - 'arguments' => array( - 'form' => NULL, - ), - ), - 'fedora_repository_time' => array( - 'arguments' => array( - 'element' => NULL - ), - 'fedora_repository_solution_packs_list' => array( - 'arguments' => array( - 'solution_packs' => NULL, - ), - ), - ), - ); -} - -/** - * Get a list of terms from a lucene index - * - * @param type $field - * @param type $startTerm - * @param type $displayName - * @return type - */ -function fedora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) { - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $searchClass = new SearchClass(); - return $searchClass->getTerms($field, $startTerm, $displayName); -} - -/** - * fedora repository mnpl advanced search form - * @return type - */ -function fedora_repository_mnpl_advanced_search_form() { - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $searchClass = new SearchClass(); - return $searchClass->build_advanced_search_form(); -} - -/** - * theme fedora repository mnpl advanced search form - * @param type $form - * @return type - */ -function theme_fedora_repository_mnpl_advanced_search_form($form) { - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $advanced_search_form = new SearchClass(); - return $advanced_search_form->theme_advanced_search_form($form); -} - -/** - * fedora repository mnpl advanced search - * @param type $query - * @param type $startPage - * @return type - */ -function fedora_repository_mnpl_advanced_search($query, $startPage = 1) { - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $searchClass = new SearchClass(); - $retVal = $searchClass->custom_search($query, $startPage); - return $searchClass->custom_search($query, $startPage); -} - -/** - * fedora repository mnpl_advanced search form submit - * @param type $form - * @param type $form_state - */ -function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state) { - $type_id = $form_state['values']['type']; - $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3')); - $searchString = $form_state['values']['type1'] . ':' . $form_state['values']['fedora_terms1']; - if ($form_state['values']['fedora_terms2'] != '') { - $searchString .=' +' . $form_state['values']['andor1'] . '+' . $form_state['values']['type2'] . ':' . $form_state['values']['fedora_terms2']; - } - if ($repeat > 2 && $repeat < 9) { - for ($i = 3; $i < $repeat + 1; $i++) { - $t = $i - 1; - if ($form_state['values']["fedora_terms$i"] != '') { - $searchString .= '+' . $form_state['values']["andor$t"] . '+' . $form_state['values']["type$i"] . ':' . $form_state['values']["fedora_terms$i"]; - } - } - } - drupal_goto("fedora/repository/mnpl_advanced_search/$searchString"); -} - -/** - * fedora repository install demo page - * @return type - */ -function fedora_repository_install_demos_page() { - $output = drupal_get_form('fedora_repository_demo_objects_form'); - return $output; -} - -/** - * fedora repository demo objects form - * @return string - */ -function fedora_repository_demo_objects_form() { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - $form = array(); - $existing_demos = array(); - - $form['install_demos'] = array( - '#title' => t('Islandora Demo Collections'), - '#type' => 'fieldset', - '#description' => t('Install demo image and document collections and content models.'), - ); - $demo_objects = array(); -// Check if the top-level islandora collection exists. If not, display a button to ingest. - - $form['install_demos']['demo_collections'] = array( - '#type' => 'checkboxes', - '#title' => t('Collections to ingest'), - '#options' => array(), - '#description' => t('Choose which demo collections you would like ingested into the repository.'), - ); - - foreach (array( - 'islandora:collectionCModel' => 'Islandora default content models', - 'islandora:root' => 'Islandora top-level collection', - 'islandora:demos' => 'Islandora demos collection', - 'islandora:largeimages' => 'Sample large image content model (requires Djatoka and Kakadu.)', - ) - as $available_demo => $available_demo_desc) { - try { - $demo_objects[$available_demo] = new Fedora_Item($available_demo); - } catch (exception $e) { - - } - - if (empty($demo_objects[$available_demo]->objectProfile)) { -//The demo objects collection does not exist in the repository, display a button to ingest them. - $form['install_demos']['demo_collections']['#options'][$available_demo] = $available_demo_desc; - } - else { - array_push($existing_demos, $demo_objects[$available_demo]); - } - } - -// Check if the SmileyStuff collectoin exists, and if it has a COLLECTION_VIEW datastream. If it doesn't then we can add it. - - $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); - if (!empty($smiley_stuff->objectProfile)) { - $datastreams_list = $smiley_stuff->get_datastreams_list_as_array(); - if (empty($datastreams_list['COLLECTION_VIEW'])) { - $form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection'; - } - else { - $demo_objects['demo:SmileyStuff'] = $smiley_stuff; - } - } - else { - $form['install_demos']['smileynote'] = array( - '#value' => '

    If you install the ' . l('fedora demo objects', 'https://wiki.duraspace.org/display/FCR30/Demonstration+Objects') . ' Islandora can display them as a collection.

    ' - ); - } - - $form['install_demos']['ingest'] = array( - '#type' => 'submit', - '#name' => 'install_demos', - '#value' => 'Install Selected Demos', - '#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE, - ); - - $form['existing_demos'] = array( - '#prefix' => '

    Demo collections already installed in this repository:

      ', - '#suffix' => '
    ', - ); - - if (!empty($existing_demos)) { - foreach ($existing_demos as $pid => $demo_object) { - - $form['existing_demos'][$demo_object->pid] = array( - '#prefix' => '
  • ', - '#value' => l($demo_object->pid, $demo_object->url()), - '#suffix' => '
  • ', - ); - } - } - - return $form; -} - -/** - * fedora repository demo objects form submit - * @global type $base_url - * @param type $form - * @param type $form_state - */ -function fedora_repository_demo_objects_form_submit($form, &$form_state) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/dublin_core'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - global $base_url; - if ($form_state['clicked_button']['#name'] == 'install_demos') { - if (!empty($form_state['values']['demo_collections']['islandora:collectionCModel'])) { - try { - $collectioncm = Fedora_Item::ingest_new_item('islandora:collectionCModel', 'A', 'Islandora Collection Content Model'); - $collectioncm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); - $collectioncm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); - } catch (exception $e) { - - } - try { - $strictpdfcm = Fedora_Item::ingest_new_item('islandora:strict_pdf', 'A', 'Strict PDF Content Model'); - $strictpdfcm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); - $strictpdfcm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STRICT_PDFCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); - } catch (exception $e) { - - } - -// Install a collection object that points to all content model objects - try { - $cmodel_collection_xml = Fedora_Item::create_object_FOXML('islandora:ContentModelCollection'); - $cmodel_collection = Fedora_Item::ingest_from_FOXML($cmodel_collection_xml); - -//$dc = new Dublin_Core(new Fedora_Item('islandora:ContentModelCollection')); - $dc = new Dublin_Core($cmodel_collection); - $dc->set_element('dc:title', array('Installed Content Model')); - $dc->save(); - $cmodel_collection->add_datastream_from_string('select $object $title from <#ri> - where ($object $title - and ($object - or $object ) - and $object ) - order by $title', 'QUERY', 'Content Model Collection Query', 'text/plain'); - $cmodel_collection->add_relationship('isMemberOfCollection', 'islandora:root'); - $cmodel_collection->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); - $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M'); - drupal_set_message(t("Successfully installed islandora:ContentModelCollection."), 'message'); - } catch (exception $e) { - - } - } - - if (!empty($form_state['values']['demo_collections']['islandora:root'])) { - $new_item = Fedora_Item::ingest_new_item('islandora:root', 'A', 'Islandora Top-level Collection'); - $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); - try { - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed islandora:root."), 'message'); - } catch (exception $e) { - - } - } - - if (!empty($form_state['values']['demo_collections']['islandora:demos'])) { - $new_item = fedora_item::ingest_new_item('islandora:demos', 'A', 'Islandora Demo Collection'); - $new_item->add_relationship('isMemberOfCollection', 'islandora:root'); - $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); - -// $cv = $new_item->add_datastream_from_file( drupal_get_path('module', 'fedora_repository') . '/collection_views/COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View.xml', 'text/xml', 'X'); - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - try { - $new_item = Fedora_Item::ingest_new_item('islandora:pdf_collection', 'A', 'PDF Collection'); - $new_item->add_relationship('isMemberOfCollection', 'islandora:demos'); - $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed islandora:demos."), 'message'); - } catch (exception $e) { - - } - } - - if (!empty($form_state['values']['demo_collections']['demo:SmileyStuff'])) { - $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); - $new_item = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/SmileyStuff-COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); - $smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos'); - $tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - $cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X'); - - $cm = new Fedora_Item('demo:DualResImage'); - try { - $cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X'); - } catch (exception $e) { - - } - $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection'); - try { - $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); - drupal_set_message(t("Successfully installed demo:SmileyStuff collection view."), 'message'); - } catch (exception $e) { - - } - } - - if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) { - $error = ''; - foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml', - 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) { - try { - $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/' . $foxml_file); - } catch (exception $e) { - $error .= " - Problem ingesting $foxml_file"; - } - } - try { - $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/islandora_largeimages.xml'); - $tn = $item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed islandora:largeimages."), 'message'); - } catch (exception $e) { - $error .= " - Problem ingesting islandora:largeimages collection"; - } - } - - if (!empty($error)) { - drupal_set_message(t('Some problems occurred: ' . $error)); - } - } -} - -/** - * fedora repository required fedora objects - * @return type - */ -function fedora_repository_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_repository'); - return array( - 'fedora_repository' => array( - 'module' => 'fedora_repository', - 'title' => 'Islandora Core', - 'objects' => array( - array( - 'pid' => 'islandora:collectionCModel', - 'label' => 'Islandora Collection Content Model', - 'dsid' => 'ISLANDORACM', - 'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml", - 'dsversion' => 2, - 'cmodel' => 'fedora-system:ContentModel-3.0', - ), - - array( - 'pid' => 'islandora:root', - 'label' => 'Islandora Top-level Collection', - 'cmodel' => 'islandora:collectionCModel', - 'datastreams' => array( - array( - 'dsid' => 'COLLECTION_POLICY', - 'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", - ), - array( - 'dsid' => 'TN', - 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", - 'mimetype' => 'image/png', - ), - ), - ), - ), - ), - ); -} - -/** - * Functions to create a time selector form element type. - */ -function fedora_repository_elements() { - $type['fedora_repository_time'] = array( - "#input" => TRUE, - "#process" => array("fedora_repository_expand_time"), - ); - - return $type; -} - -/** - * fedora repository expand time - * @param type $element - * @return string - */ -function fedora_repository_expand_time($element) { -// Default to current time, check default_value but set value so that if -// default value is present it will override value - if (empty($element['#default_value'])) { - $element['#value'] = array( - 'hour' => intval(format_date(time(), 'custom', 'h')), - 'minute' => intval(format_date(time(), 'custom', 'i')), - ); - } - - $element['#tree'] = TRUE; - - foreach ($element['#value'] as $type => $value) { - switch ($type) { - case 'hour': - $options = drupal_map_assoc(range(1, 24)); - break; - case 'minute': - $options = range(0, 59); - break; - } - - if ($type != 'meridiem') { - foreach ($options as $option) { - strlen($option) <= 1 ? $options[$option] = 0 . $option : ''; - } - } - - $element[$type] = array( - '#type' => 'select', - '#default_value' => $element['#value'][$type], - '#options' => $options, - ); - } - - return $element; -} - -/** - * fedora repository time - * @param type $element - * @return type - */ -function fedora_repository_time($element) { - $output = '
    ' . $element['#children'] . '
    '; - return theme('form_element', $element, $output); -} - -/** - * theme fedora repository time - * @param type $element - * @return type - */ -function theme_fedora_repository_time($element) { - $output = '
    ' . $element['#children'] . '
    '; - return theme('form_element', $element, $output); -} - -/* Export (basket) functionality */ - -/** - * fedora repository remove item from basket - * @param type $pid - */ -function fedora_repository_remove_item_from_basket($pid) { - - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; - - $objectHelper = new ObjectHelper(); -// getting child PIDs if any - $cpids = $objectHelper->get_child_pids(array($pid)); - - if (array_key_exists($pid, $pids)) { -// remove item from basket - unset($_SESSION['basket']['processed'][$pid]); - } - if (!empty($cpids)) { // there are children - foreach ($cpids as $child_pid => $value) { -// remove child item from basket recursively - fedora_repository_remove_item_from_basket($child_pid); - } - } -} - -/** - * fedora repository basket - * @return type - */ -function fedora_repository_basket() { - $pids = _fedora_repository_get_basket_pids(); - $output = drupal_get_form('fedora_repository_basket_form', $pids); - - return $output; -} - -function fedora_repository_basket_form($form_state, $pids) { - $form = array(); - - if (!empty($pids)) { - $form['pid'] = array(); - $form['title'] = array(); - $form['desc'] = array(); - } - else { - return; - } - - ksort($pids); - foreach ($pids as $pid => $arr) { - $cbs[$pid] = ''; - - $form['pid'][$pid] = array('#value' => l($pid, "fedora/repository/$pid")); - $form['title'][$pid] = array('#value' => $arr['title']); - $form['desc'][$pid] = array('#value' => $arr['desc']); - } - - $form['remove'] = array( - '#type' => 'checkboxes', - '#options' => $cbs, - ); - - $form['remove_submit'] = array( - '#type' => 'submit', - '#value' => t('Remove selected'), - ); - - $form['remove_all'] = array( - '#type' => 'submit', - '#value' => t('Empty basket'), - ); - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Export selected'), - ); - - $form['submit_all'] = array( - '#type' => 'submit', - '#value' => t('Export all'), - ); - - return $form; -} - -/** - * theme fedora repository basket form - * @param type $form - * @return string - */ -function theme_fedora_repository_basket_form($form) { - $header = array( - theme('table_select_header_cell'), - t('PID'), - t('Title'), - t('Description'), - ); - - if (isset($form['pid']) && is_array($form['pid'])) { - foreach (element_children($form['pid']) as $key) { - $rows[] = array( - drupal_render($form['remove'][$key]), - drupal_render($form['pid'][$key]), - drupal_render($form['title'][$key]), - drupal_render($form['desc'][$key]), - ); - } - } - else { - $rows[] = array(array('data' => t('Your basket is empty.'), 'colspan' => '4')); - } - - $output = theme('table', $header, $rows); - - $frm = drupal_render($form); - $output = $frm . $output . $frm; - - return $output; -} - -/** - * fedora repository basket form validate - * @param type $form - * @param type $form_state - */ -function fedora_repository_basket_form_validate($form, &$form_state) { - -} - -/** - * fedora repository basket form submit - * @global type $user - * @param type $form - * @param type $form_state - * @return type - */ -function fedora_repository_basket_form_submit($form, &$form_state) { - if ($form_state['values']['op'] == $form_state['values']['remove_submit']) { - $pids = $form_state['clicked_button']['#post']['remove']; - - if (isset($pids)) { - foreach ($pids as $pid) { - fedora_repository_remove_from_basket($pid); - } - drupal_set_message(t("Selected objects removed")); - return; - } - } - - if ($form_state['values']['op'] == $form_state['values']['remove_all']) { - _fedora_repository_empty_basket(); - drupal_set_message(t("Basket emptied")); - return; - } - - if ($form_state['values']['op'] == $form_state['values']['submit_all']) { - $msg = t("All objects exported to staging area"); - $pids = _fedora_repository_get_basket_pids(); - } - elseif ($form_state['values']['op'] == $form_state['values']['submit']) { - $msg = t("Selected objects exported to staging area"); - $pids = array_filter($form_state['values']['remove']); - } - - if (!empty($pids)) { - global $user; - $log = array(); - $success = TRUE; - $export_dir = variable_get('export_area', file_directory_path() . '/fedora_export_area') . '/' . $user->name . '/' . date("Ymd-His"); - $foxml_dir = $export_dir . '/foxml'; - - if (!file_exists($foxml_dir) && !@mkdir($foxml_dir, 0775, TRUE)) { - drupal_set_message(t("Failed to create foxml dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $foxml_dir)), 'error'); - return FALSE; - } - - module_load_include('inc', 'fedora_repository', 'api/fedora_export'); - foreach ($pids as $pid => $arr) { - - $objects_dir = $export_dir . '/objects/' . $pid; - if (!file_exists($objects_dir) && !@mkdir($objects_dir, 0775, TRUE)) { - drupal_set_message(t("Failed to create objects dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $objects_dir)), 'error'); - return FALSE; - } - - if (!export_to_export_area($pid, $foxml_dir, $objects_dir, $log)) { - $success = FALSE; - } - } - $msg = $success ? $msg : t("Failed to export objects to staging area"); - $msg .= ":
    " . implode("
    ", $log); - - drupal_set_message($msg, $success ? 'info' : 'error'); -//_fedora_repository_empty_basket(); - } - else { - drupal_set_message(t("No objects selected or basket empty"), 'error'); - } - - return; -} - -/** - * Get all pids saved to the basket. - * - * @return type - */ -function _fedora_repository_get_basket_pids() { - -// Set empty defaults if basket elements are missing - $_SESSION['basket'] = isset($_SESSION['basket']) ? $_SESSION['basket'] : array('processed' => array(), 'unprocessed' => array()); - $_SESSION['basket']['processed'] = isset($_SESSION['basket']['processed']) ? $_SESSION['basket']['processed'] : array(); - $_SESSION['basket']['unprocessed'] = isset($_SESSION['basket']['unprocessed']) ? $_SESSION['basket']['unprocessed'] : array(); - - $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; - - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - $ob = new ObjectHelper(); - foreach ($_SESSION['basket']['unprocessed'] as $pid) { -// Check if the pid already exists in the tree - if (array_key_exists($pid, $pids)) { - continue; - } - - $pids += $ob->get_all_related_pids($pid); -// $pids += array($pid); - } - - $_SESSION['basket']['processed'] = $pids; - $_SESSION['basket']['unprocessed'] = array(); - - return $pids; -} - -/** - * fedora repository empty basket - */ -function _fedora_repository_empty_basket() { - unset($_SESSION['basket']); -} - -/** - * fedora repository add to basket - * @param type $pid - * @param type $warn - * @param type $searchResultsFlag - */ -function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) { - if ($warn && _is_added_to_basket($pid)) { - drupal_set_message(t("Object already in basket")); - } - - if (!isset($_SESSION['basket'])) { - $_SESSION['basket'] = array(); - $_SESSION['basket']['unprocessed'] = array($pid => $pid); - } - else { - $_SESSION['basket']['unprocessed'][$pid] = $pid; - } - - if (!$searchResultsFlag) { - drupal_goto('fedora/basket'); - } -} - -/** - * fedora repository remove from basket - * @param type $pid - * @return type - */ -function fedora_repository_remove_from_basket($pid) { - if (isset($_SESSION['basket']['unprocessed'][$pid])) { - unset($_SESSION['basket']['unprocessed'][$pid]); - } - - if (isset($_SESSION['basket']['processed'][$pid])) { - unset($_SESSION['basket']['processed'][$pid]); - } - return; -} - -/** - * theme add to basket link - * @param type $pid - * @param type $type - * @return type - */ -function theme_add_to_basket_link($pid, $type = 'object') { - $object = t($type); - $path = drupal_urlencode($pid); - - $save = "export_big.png"; - $saved = "exported_big.png"; -// $path = drupal_get_path('module', 'Fedora_Repository').'/images/'.$save ; - /* - var_dump($path); - var_dump(theme('image',drupal_get_path('module', 'Fedora_Repository').'/images/'.$save)); - die(); - */ - if (!_is_added_to_basket($pid)) { - return l( - theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), - "fedora/repository/addToBasket/" . $path, - array('html' => TRUE) - ); - } - - return theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $saved, t("In basket"), t("This @object is already in your basket", array('@object' => $object))); -} - -/** - * is added to basket - * @param type $pid - * @param type $account - * @return type - */ -function _is_added_to_basket($pid, $account = NULL) { - return isset($_SESSION['basket']['unprocessed'][$pid]) || isset($_SESSION['basket']['processed'][$pid]); -// return db_result(db_query("SELECT uid FROM {repository_basket} WHERE uid = %d AND pid = '%s'", $account->uid, $pid)); -} - -/** - * fedora repository display schema - * @param type $file - * @return type - */ -function fedora_repository_display_schema($file) { - $path = drupal_get_path('module', 'fedora_repository'); - if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) { - drupal_goto($path . '/' . $file); - } - else { - drupal_goto(); - } - return; -} - -/** - * fedora repository batch reingest object - * @param type $object - * @param type $context - * @return type - */ -function fedora_repository_batch_reingest_object($object, &$context) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - if (!empty($object) && is_array($object)) { - $pid = $object['pid']; - if (!valid_pid($pid)) { - return NULL; - } -// Does the object exist? If so, purge it. - $item = new Fedora_Item($pid); - if ($item->exists()) { - $item->purge(t('Remove during re-install batch job')); - } - -// Ingest the object from the source file. - if (!empty($object['foxml_file'])) { - $foxml_file = $object['foxml_file']; - $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file); - if ($new_item->exists()) { -// Batch operation was successful. - $context['message'][] = "$new_item->pid installed."; - } - } - if (!empty($object['dsid']) && !empty($object['datastream_file'])) { - $datastreams = array( - array( - 'dsid' => $object['dsid'], - 'datastream_file' => $object['datastream_file'], - ) - ); - } - elseif (!empty($object['datastreams'])) { - $datastreams = $object['datastreams']; - } - - if (!empty($datastreams) && is_array($datastreams)) { - $label = !empty($object['label']) ? $object['label'] : ''; - if (empty($object['foxml_file']) && !isset($new_item)) { - $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); - } - if (!empty($object['cmodel'])) { - $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); - } - if (!empty($object['parent'])) { - $new_item->add_relationship('isMemberOfCollection', $object['parent']); - } - foreach ($datastreams as $ds) { - if ($ds['dsid'] == 'DC') { - $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml'); - } - else { - $new_item->add_datastream_from_file($ds['datastream_file'], $ds['dsid'], !empty($ds['label']) ? $ds['label'] : '', !empty($ds['mimetype']) ? $ds['mimetype'] : 'text/xml'); - } - } - } - } -} - -/** - * Content model, collection view and collection policy datastreams may now optionally define a version - * number in their top-level XML element as an attribute, as in: - * get_datastream_dissemination($dsid)); - } - elseif (isset($datastream_file)) { - $doc = simplexml_load_file($datastream_file); - } - - if (!empty($doc)) { - $attrs = $doc->attributes(); - foreach ($attrs as $name => $value) { - if ($name == 'version') { - $return = (int) $value; - break; - } - } - } - return $return; -} - -/** - * theme fedora repository solution pack list - * @param type $solution_packs - * @return string - */ -function theme_fedora_repository_solution_packs_list($solution_packs) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - $output = ''; - $header = array(); - $rows = array(); - - - - - drupal_add_css(drupal_get_path('module', 'update') . '/update.css'); - return $output; -} - -/** - * Implementation of hook_forms() - * @param string $form_id - * @return array - */ -function fedora_repository_forms($form_id) { - $forms = array(); - if (strpos($form_id, 'fedora_repository_solution_pack_form_') === 0) { - $forms[$form_id] = array( - 'callback' => 'fedora_repository_solution_pack_form', - ); - } - return $forms; -} diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc deleted file mode 100644 index de4ce137..00000000 --- a/fedora_repository.solutionpacks.inc +++ /dev/null @@ -1,175 +0,0 @@ - $solution_pack_info) { - $objects = array(); - foreach ($solution_pack_info as $field => $value) { - switch ($field) { - case 'title': - $solution_pack_name = $value; - break; - case 'objects': - $objects = $value; - break; - } - } - $output .= drupal_get_form('fedora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects); - } - - return $output; -} - -/** - * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. - * @param array $solution_pack - */ -function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { - // Check each object to see if it is in the repository. - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - global $base_path; - $needs_update = FALSE; - $needs_install = FALSE; - $form = array(); - $form['solution_pack_module'] = array( - '#type' => 'hidden', - '#value' => $solution_pack_module, - ); - - if (!$form_state['submitted']) { - $form['soluction_pack_name'] = array( - '#type' => 'markup', - '#value' => t($solution_pack_name), - '#prefix' => '

    ', - '#suffix' => '

    ', - ); - $form['objects'] = array( - '#type' => 'fieldset', - '#title' => "Objects", - '#weight' => 10, - '#attributes' => array('class' => 'collapsed'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $table_header = array('PID', 'Status'); - $table_rows = array(); - - - foreach ($objects as $object) { - $datastreams = NULL; - if (isset($object['pid'])) { - $pid = $object['pid']; - - $item = new Fedora_Item($pid); - $table_row = array($object['pid']); - $object_status = t('Up-to-date'); - if (!$item->exists()) { - $object_status = 'Missing'; - $needs_install = TRUE; - } - else { - if (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { - $datastreams = array( - array( - 'dsid' => $object['dsid'], - 'datastream_file' => $object['datastream_file'], - 'dsversion' => $object['dsversion'], - ), - ); - } - elseif (!empty($object['datastreams'])) { - $datastreams = $object['datastreams']; - } - if (!empty($datastreams) && is_array($datastreams)) { - foreach ($datastreams as $ds) { - $ds_list = $item->get_datastreams_list_as_array(); - if (!array_key_exists($ds['dsid'], $ds_list)) { - $needs_update = TRUE; - $object_status = 'Missing datastream'; - break; - } - if (isset($ds['dsversion'])) { - // Check if the datastream is versioned and needs updating. - $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); - $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); - if ($available_version > $installed_version) { - $needs_update = TRUE; - $object_status = 'Out of date'; - break; - } - } - } - } - } - array_push($table_row, $object_status); - $table_rows[] = $table_row; - } - } - $form['objects']['table'] = array( - '#type' => 'markup', - '#value' => theme_table($table_header, $table_rows), - ); - } - - $form['install_status'] = array( - '#type' => 'markup', - '#prefix' => '' . t('Object status:') . ' ', - '#suffix' => ' ', - ); - if (!$needs_install && !$needs_update) { - $form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.'); - } - else { - $form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.'); - } - $form['submit'] = array( - '#value' => t('Install'), - '#disabled' => !$needs_install && !$needs_update, - '#type' => 'submit', - '#name' => $solution_pack_module, - ); - - $form['#submit'] = array( - 'fedora_repository_solution_pack_form_submit', - ); - return $form; -} - -function fedora_repository_solution_pack_form_submit($form, &$form_state) { - $what = $form_state; - $module_name = $form_state['values']['solution_pack_module']; - $solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); - $batch = array( - 'title' => t('Installing / updating solution pack objects'), - 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', - 'operations' => array(), - ); - - - foreach ($solution_pack_info[$module_name]['objects'] as $object) { - // Add this object to the batch job queue. - $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); - } - batch_set($batch); -} From 625edabf3977e775ae30d3b03bd770cf9d204d14 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Fri, 7 Oct 2011 16:25:13 -0300 Subject: [PATCH 03/46] Remote the extra tests --- digital_repository.install | 51 -------------------------------------- 1 file changed, 51 deletions(-) diff --git a/digital_repository.install b/digital_repository.install index 43bbcf70..164ce02e 100644 --- a/digital_repository.install +++ b/digital_repository.install @@ -87,32 +87,6 @@ function fedora_repository_requirements($phase) { $requirements['xslt']['value'] = t("Installed"); $requirements['xslt']['severity'] = REQUIREMENT_OK; } - - // Test for Imagick - system("hash convert 2>&-", $return_value); - $requirements['imagick']['title'] = t("Image Magick library"); - if ($return_value) { - $requirements['imagick']['value'] = t("Not installed"); - $requirements['imagick']['severity'] = REQUIREMENT_WARNING; - $requirements['imagick']['description'] = t('Ensure that the Image Magick library is installed.'); - } - else { - $requirements['imagick']['value'] = t("Installed"); - $requirements['imagick']['severity'] = REQUIREMENT_OK; - } - - // Test for Kakadu - system("hash kdu_compress 2>&-", $return_value); - $requirements['kakadu']['title'] = t("Kakadu library"); - if ($return_value) { - $requirements['kakadu']['value'] = t("Not installed"); - $requirements['kakadu']['severity'] = REQUIREMENT_WARNING; - $requirements['kakadu']['description'] = t('Ensure that the Kakadu library is installed.'); - } - else { - $requirements['kakadu']['value'] = t("Installed"); - $requirements['kakadu']['severity'] = REQUIREMENT_OK; - } } elseif ($phase == 'runtime') { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); @@ -127,31 +101,6 @@ function fedora_repository_requirements($phase) { $requirements['fedora-repository']['value'] = t("Available"); $requirements['fedora-repository']['severity'] = REQUIREMENT_OK; } - - // Check for ImageMagick - $requirements['fedora-imagemagick']['title'] = t("ImageMagick convert in \$PATH"); - $result = exec('convert'); - if (!$result) { - $requirements['fedora-imagemagick']['value'] = t('Not in $PATH'); - $requirements['fedora-imagemagick']['description'] = t('Islandora will not be able to create thumbnails. Ensure that ImageMagick is installed and the convert command is executable by the web server user.'); - $requirements['fedora-imagemagick']['severity'] = REQUIREMENT_WARNING; - } - else { - $requirements['fedora-imagemagick']['value'] = t("Available"); - $requirements['fedora-imagemagick']['severity'] = REQUIREMENT_OK; - } - - $requirements['fedora-kakadu']['title'] = 'Kakadu kdu_compress in $PATH'; - $kdu_res = exec('kdu_compress -v'); - if (!$kdu_res) { - $requirements['fedora-kakadu']['value'] = ('Not in $PATH'); - $requirements['fedora-kakadu']['description'] = t('Islandora cannot convert TIFF image files to JPEG2000 format. Ensure Kakadu is installed and the kdu_compress command is executable by the web server user.'); - $requirements['fedora-kakadu']['severity'] = REQUIREMENT_WARNING; - } - else { - $requirements['fedora-kakadu']['value'] = t("Available"); - $requirements['fedora-kakadu']['severity'] = REQUIREMENT_OK; - } } return $requirements; From fae0efb144f7edc8635df821e38dfda567240229 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Tue, 11 Oct 2011 10:20:35 -0300 Subject: [PATCH 04/46] switched to islandora_repository --- BatchIngest.inc | 20 +-- CollectionClass.inc | 42 +++--- CollectionManagement.inc | 24 ++-- CollectionPolicy.inc | 18 +-- ContentModel.inc | 50 +++---- ObjectHelper.inc | 68 +++++----- SearchClass.inc | 30 ++--- SecurityClass.inc | 2 +- XMLDatastream.inc | 8 +- formClass.inc | 78 +++++------ islandora_repository.solutionpacks.inc | 175 +++++++++++++++++++++++++ 11 files changed, 345 insertions(+), 170 deletions(-) create mode 100644 islandora_repository.solutionpacks.inc diff --git a/BatchIngest.inc b/BatchIngest.inc index 31daa608..f3d63cc0 100644 --- a/BatchIngest.inc +++ b/BatchIngest.inc @@ -9,8 +9,8 @@ * @param array $content_models */ function batch_creation_form(&$form_state, $collection_pid, $content_models) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); $cm_options = array(); $name_mappings = array(); foreach ($content_models as $content_model) { @@ -95,8 +95,8 @@ function batch_creation_form_validate($form, &$form_state) { } function batch_creation_form_submit($form, &$form_state) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); global $user; $namespace_mappings = array(); $content_model = $form_state['values']['content_model']; @@ -150,7 +150,7 @@ function batch_creation_form_submit($form, &$form_state) { $batch = array( 'title' => 'Ingesting Objects', 'operations' => array(), - 'file' => drupal_get_path('module', 'fedora_repository') . '/BatchIngest.inc', + 'file' => drupal_get_path('module', 'islandora_repository') . '/BatchIngest.inc', ); @@ -176,8 +176,8 @@ function batch_creation_form_submit($form, &$form_state) { function create_batch_objects($label, $content_model, $object_files, $collection_pid, $namespace, $metadata) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); $cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM'); $allowedMimeTypes = $cm->getMimetypes(); $mime_helper = new MimeClass(); @@ -227,9 +227,9 @@ function create_batch_objects($label, $content_model, $object_files, $collection function batch_create_dc_from_mods($mods_xml) { - $path = drupal_get_path('module', 'fedora_repository'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'CollectionClass'); + $path = drupal_get_path('module', 'islandora_repository'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'CollectionClass'); if ($xmlstr == NULL || strlen($xmlstr) < 5) { return " "; diff --git a/CollectionClass.inc b/CollectionClass.inc index 4251eea4..df438aca 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -29,7 +29,7 @@ class CollectionClass { */ function __construct($pid = NULL) { if (!empty($pid)) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $this->collectionObject = new ObjectHelper($pid); $this->pid = $pid; } @@ -45,7 +45,7 @@ class CollectionClass { * @return type */ function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); if (!isset($itqlquery)) { // $query_string = $objectHelper->getStream($pid, 'QUERY', 0); @@ -65,8 +65,8 @@ class CollectionClass { * @return type */ function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); if (!isset($limit)) { $limit = 1000; } @@ -74,7 +74,7 @@ class CollectionClass { $offset = 0; } global $user; - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); return ' '; } @@ -101,7 +101,7 @@ class CollectionClass { $query_string = htmlentities(urlencode($query_string)); $content = ''; - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=Sparql&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query_string; $content .= do_curl($url); @@ -156,7 +156,7 @@ class CollectionClass { * @return type */ function getStream($pid, $dsid, $showError = 1) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $item = new fedora_item($pid); return isset($item->datastreams[$dsid]) ? $item->get_datastream_dissemination($dsid) : NULL; } @@ -223,7 +223,7 @@ class CollectionClass { module_load_include('inc', 'Fedora_Repository', 'ConnectionHelper'); $pidNameSpace = $this->getPidNameSpace($pid, $dsid); $pname = substr($pidNameSpace, 0, strpos($pidNameSpace, ":")); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); return Fedora_Item::get_next_pid_in_namespace($pname); } @@ -339,7 +339,7 @@ class CollectionClass { } } // module_load_include( $phpFile, 'Fedora_Repository', ' '); - require_once(drupal_get_path('module', 'fedora_repository') . '/' . $phpFile); + require_once(drupal_get_path('module', 'islandora_repository') . '/' . $phpFile); $thisClass = new $phpClass (); $returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext); if (!$returnValue) { @@ -409,7 +409,7 @@ class CollectionClass { $ingest_form = $xml->ingest_form; //should only be one $drupal_module = strip_tags($ingest_form->form_builder_method->module->asXML()); if (empty($drupal_module)) { - $drupal_module = 'fedora_repository'; + $drupal_module = 'islandora_repository'; } $phpFile = strip_tags($ingest_form->form_builder_method->file->asXML()); $phpClass = strip_tags($ingest_form->form_builder_method->class_name->asXML()); @@ -437,11 +437,11 @@ class CollectionClass { 'name' => variable_get('fedora_admin_user', 'fedoraAdmin') ); $admin_user = user_load($username); - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); $connectionHelper = new ConnectionHelper(); try { $soapClient = $connectionHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $pidNameSpace = variable_get('fedora_repository_pid', 'vre:'); + $pidNameSpace = variable_get('islandora_repository_pid', 'vre:'); $pidNameSpace = substr($pidNameSpace, 0, strpos($pidNameSpace, ":")); $params = array( 'numPIDs' => '', @@ -460,7 +460,7 @@ class CollectionClass { $personal_collection_pid = array( 'fedora_personal_pid' => $pid ); - module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass'); + module_load_include('inc', 'islandora_repository', 'plugins/PersonalCollectionClass'); $personalCollectionClass = new PersonalCollectionClass(); if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) { drupal_set_message("Did not create a personal collection object for !u", array('!u' => $user->name)); @@ -480,7 +480,7 @@ class CollectionClass { * @return type */ function getXslContent($pid, $path, $canUseDefault = TRUE) { - module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'islandora_repository', 'CollectionClass'); $collectionClass = new CollectionClass(); $xslContent = $collectionClass->getCollectionViewStream($pid); if (!$xslContent && $canUseDefault) { //no xslt so we will use the default sent with the module @@ -497,9 +497,9 @@ class CollectionClass { * @return string */ function showFieldSets($page_number) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'CollectionManagement'); - module_load_include('inc', 'fedora_repository', 'BatchIngest'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'CollectionManagement'); + module_load_include('inc', 'islandora_repository', 'BatchIngest'); global $base_url; $tabset = array(); global $user; @@ -514,7 +514,7 @@ class CollectionClass { $collection_items = $this->renderCollection($results, $this->pid, NULL, NULL, $page_number); $collection_item = new Fedora_Item($this->pid); // Check the form post to see if we are in the middle of an ingest operation. - $show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form'); + $show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'islandora_repository_ingest_form'); $add_to_collection = $this->getIngestInterface(); $show_batch_tab = TRUE; @@ -586,7 +586,7 @@ class CollectionClass { $allow = fedora_fesl_check_roles($this->pid, 'write'); } if ($allow) { - $ingestObject = drupal_get_form('fedora_repository_ingest_form', $this->pid); + $ingestObject = drupal_get_form('islandora_repository_ingest_form', $this->pid); } } } @@ -608,7 +608,7 @@ class CollectionClass { * @return type */ function renderCollection($content, $pid, $dsId, $collection, $pageNumber = NULL) { - $path = drupal_get_path('module', 'fedora_repository'); + $path = drupal_get_path('module', 'islandora_repository'); global $base_url; $collection_pid = $pid; //we will be changing the pid later maybe $objectHelper = new ObjectHelper(); @@ -628,7 +628,7 @@ class CollectionClass { } if (!isset($collectionName)) { - $collectionName = variable_get('fedora_repository_name', 'Collection'); + $collectionName = variable_get('islandora_repository_name', 'Collection'); } $xslContent = $this->getXslContent($pid, $path); diff --git a/CollectionManagement.inc b/CollectionManagement.inc index 83bb9952..bb89a9fd 100644 --- a/CollectionManagement.inc +++ b/CollectionManagement.inc @@ -8,7 +8,7 @@ * @return array */ function collection_management_form(&$form_state, $this_collection_pid, $content_models) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); $restricted = FALSE; if (variable_get('fedora_namespace_restriction_enforced', true)) { $restricted = true; @@ -20,8 +20,8 @@ function collection_management_form(&$form_state, $this_collection_pid, $content } } } - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); $item = new Fedora_Item($this_collection_pid); $collection_name = $item->objectProfile->objLabel; $new_content_models = get_content_models_as_option_array(); @@ -224,8 +224,8 @@ function collection_management_form(&$form_state, $this_collection_pid, $content */ function collection_management_form_validate($form, &$form_state) { if ($form_state['clicked_button']['#id'] == 'create_class') { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); $pid = $form_state['values']['new_collection_pid']; $item = new fedora_item($pid); if ($item->exists()) { @@ -252,14 +252,14 @@ function collection_management_form_validate($form, &$form_state) { * @param type $form_state */ function collection_management_form_submit($form, &$form_state) { - module_load_include('inc', 'fedora_repository', 'api/fedora_collection'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/dublin_core'); + module_load_include('inc', 'islandora_repository', 'api/fedora_collection'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/dublin_core'); global $user; $collection_pid = $form_state['values']['parent_collection']; $policy = CollectionPolicy::loadFromCollection($collection_pid, TRUE); if ($form_state['clicked_button']['#id'] == 'create_class') { - $module_path = drupal_get_path('module', 'fedora_repository'); + $module_path = drupal_get_path('module', 'islandora_repository'); $thumbnail = drupal_get_path('module', 'Fedora_Repository') . '/images/Crystal_Clear_filesystem_folder_grey.png'; $new_collection_pid = $form_state['values']['new_collection_pid']; $new_collection_label = $form_state['values']['collection_name']; @@ -345,7 +345,7 @@ function collection_management_form_submit($form, &$form_state) { $query = htmlentities(urlencode($query)); $content = ''; - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=csv&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query; $content .= do_curl($url); $results = explode("\n", $content); @@ -370,7 +370,7 @@ function collection_management_form_submit($form, &$form_state) { $batch = array( 'title' => "Deleting Objects from $name", 'operations' => array(), - 'file' => drupal_get_path('module', 'fedora_repository') . '/CollectionManagement.inc', + 'file' => drupal_get_path('module', 'islandora_repository') . '/CollectionManagement.inc', ); @@ -389,7 +389,7 @@ function collection_management_form_submit($form, &$form_state) { * @param $pid */ function delete_objects_as_batch($pid) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $name = $user->name; $item_to_delete = new Fedora_Item($pid); $models = $item_to_delete->get_models(); diff --git a/CollectionPolicy.inc b/CollectionPolicy.inc index b801eaff..0612a733 100644 --- a/CollectionPolicy.inc +++ b/CollectionPolicy.inc @@ -4,7 +4,7 @@ * @file * Collection Policy Class */ -module_load_include('inc', 'fedora_repository', 'XMLDatastream'); +module_load_include('inc', 'islandora_repository', 'XMLDatastream'); /** * Collection Policy class ?? @@ -36,7 +36,7 @@ class CollectionPolicy extends XMLDatastream { */ static function loadFromCollection($pid, $preFetch=TRUE) { $ret = FALSE; - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); try { if (self::valid_pid($pid)) { @@ -80,7 +80,7 @@ class CollectionPolicy extends XMLDatastream { $rootEl = $cp->xml->getElementsByTagName('collection_policy')->item(0); $rootEl->setAttribute('name', $name); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cp->dumpXml(), $cpDsid, $name, 'text/xml', 'X'); $ret = $cp; @@ -110,7 +110,7 @@ class CollectionPolicy extends XMLDatastream { $cp = new CollectionPolicy($newDom, $pid, $cpDsid); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cp->dumpXml(), $cpDsid, $name, 'text/xml', 'X'); $ret = $cp; @@ -137,7 +137,7 @@ class CollectionPolicy extends XMLDatastream { public static function ingestBlankPolicy($pid, $name, $policyDsid, $model_pid, $model_namespace, $relationship, $searchField, $searchValue) { $ret = FALSE; if (($cp = self::loadFromCollection($pid)) === FALSE) { //removed second, non-existant variable - module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); if (($cm = ContentModel::loadFromModel($model_pid)) !== FALSE && $cm->validate()) { $newDom = new DOMDocument('1.0', 'utf-8'); $newDom->formatOutput = TRUE; @@ -171,7 +171,7 @@ class CollectionPolicy extends XMLDatastream { $cp = new CollectionPolicy($newDom, $pid, $policyDsid); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); @@ -299,7 +299,7 @@ class CollectionPolicy extends XMLDatastream { $this->staging_area = trim($stagingEl->item(0)->nodeValue); } elseif ($recurse) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $item = new Fedora_Item($this->pid); $rels = $item->get_relationships(); if (count($rels) > 0) { @@ -373,7 +373,7 @@ class CollectionPolicy extends XMLDatastream { $pname = substr($namespace, 0, strpos($namespace, ":")); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $ret = Fedora_Item::get_next_pid_in_namespace($pname); } return $ret; @@ -443,7 +443,7 @@ class CollectionPolicy extends XMLDatastream { if ($recurse && count($ret) == 0) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $item = new Fedora_Item($this->pid); $rels = $item->get_relationships(); if (count($rels) > 0) { diff --git a/ContentModel.inc b/ContentModel.inc index b1f28074..66bd9569 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -8,7 +8,7 @@ * @file * Content Model Class */ -module_load_include('inc', 'fedora_repository', 'XMLDatastream'); +module_load_include('inc', 'islandora_repository', 'XMLDatastream'); /** * Conent Model ?? @@ -41,7 +41,7 @@ class ContentModel extends XMLDatastream { public static function loadFromObject($pid) { $ret = FALSE; if (self::valid_pid($pid)) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $content_models = $objectHelper->get_content_models_list($pid); @@ -73,7 +73,7 @@ class ContentModel extends XMLDatastream { $rootEl = $cm->xml->getElementsByTagName('content_model')->item(0); $rootEl->setAttribute('name', $name); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cm->dumpXml(), $modelDsid, $name, 'text/xml', 'X'); $ret = $cm; @@ -102,7 +102,7 @@ class ContentModel extends XMLDatastream { $cm = new ContentModel($newDom, $pid, $modelDsid); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cm->dumpXml(), $modelDsid, $name, 'text/xml', 'X'); $ret = $cm; @@ -172,7 +172,7 @@ class ContentModel extends XMLDatastream { $cm = new ContentModel($newDom, $pid, $modelDsid); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cm->dumpXml(), $modelDsid, $name, 'text/xml', 'X'); $ret = $cm; @@ -199,7 +199,7 @@ class ContentModel extends XMLDatastream { */ public static function loadFromModel($pid, $dsid = NULL, $pid_namespace = NULL, $name = NULL) { $ret = FALSE; - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); try { if (self::valid_pid($pid)) { $fedoraItem = new Fedora_Item($pid); @@ -436,7 +436,7 @@ class ContentModel extends XMLDatastream { and $object ) order by $title'; - module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'islandora_repository', 'CollectionClass'); $collectionHelper = new CollectionClass(); $xml = simplexml_load_string($collectionHelper->getRelatedItems($this->pid, $query)); @@ -1070,7 +1070,7 @@ class ContentModel extends XMLDatastream { $method = $ingest_form->getElementsByTagName('form_builder_method')->item(0); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Build Ingest Form: file \'' . $path . '\' does not exist.'; } @@ -1110,7 +1110,7 @@ class ContentModel extends XMLDatastream { if ($method->length > 0 && $method->item(0)->getAttribute('dsid') == $dsid) { $method = $method->item(0); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Build Edit Metadata Form: file \'' . $path . '\' does not exist.'; } @@ -1153,7 +1153,7 @@ class ContentModel extends XMLDatastream { if ($method->length > 0) { $method = $method->item(0); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Handle Edit Metadata Form: file \'' . $path . '\' does not exist.'; } @@ -1177,7 +1177,7 @@ class ContentModel extends XMLDatastream { } else { // Assume DC form if none is specified. - module_load_include('inc', 'fedora_repository', 'formClass'); + module_load_include('inc', 'islandora_repository', 'formClass'); $metaDataForm = new formClass(); $ret = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $soap_client); $form_state['storage'] = NULL; @@ -1198,7 +1198,7 @@ class ContentModel extends XMLDatastream { $method = $this->xml->getElementsByTagName('content_model')->item(0)->getElementsByTagName('edit_metadata_method'); if ($method->length > 0) { $method = $method->item(0); - $ret = array('module' => $method->getAttribute('module') == '' ? 'fedora_repository' : $method->getAttribute('module'), + $ret = array('module' => $method->getAttribute('module') == '' ? 'islandora_repository' : $method->getAttribute('module'), 'file' => $method->getAttribute('file'), 'class' => $method->getAttribute('class'), 'method' => $method->getAttribute('method'), @@ -1282,7 +1282,7 @@ class ContentModel extends XMLDatastream { } } $module = $addMethod->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $addMethod->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $addMethod->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Execute Add Datastream Methods: file \'' . $path . '\' does not exist.'; } @@ -1351,9 +1351,9 @@ class ContentModel extends XMLDatastream { if (!$preview || isset($param_array['preview'])) { $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); - if (!file_exists($path) || substr_compare($path, 'fedora_repository/', -strlen('fedora_repository/'), strlen('fedora_repository/')) === 0) { + if (!file_exists($path) || substr_compare($path, 'islandora_repository/', -strlen('islandora_repository/'), strlen('islandora_repository/')) === 0) { self::$errors[] = 'Execute Ingest Rules: file \'' . $path . '\' does not exist.'; $ret = FALSE; } @@ -1399,7 +1399,7 @@ class ContentModel extends XMLDatastream { if ($this->validate()) { $method = $this->xml->getElementsByTagName('ingest_form')->item(0)->getElementsByTagName('form_builder_method')->item(0); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Execute Form Handler: file \'' . $path . '\' does not exist.'; } @@ -1469,7 +1469,7 @@ class ContentModel extends XMLDatastream { for ($j = 0; $j < $dispMethods->length; $j++) { $method = $dispMethods->item($j); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Execute Form Handler: file \'' . $path . '\' does not exist.'; } @@ -1588,7 +1588,7 @@ class ContentModel extends XMLDatastream { $ret = array(); $dispMethods = $ds->getElementsByTagName('display_method'); for ($i = 0; $i < $dispMethods->length; $i++) { - $ret[] = array('module' => $dispMethods->item($i)->getAttribute('module') == '' ? 'fedora_repository' : $dispMethods->item($i)->getAttribute('module'), + $ret[] = array('module' => $dispMethods->item($i)->getAttribute('module') == '' ? 'islandora_repository' : $dispMethods->item($i)->getAttribute('module'), 'file' => $dispMethods->item($i)->getAttribute('file'), 'class' => $dispMethods->item($i)->getAttribute('class'), 'method' => $dispMethods->item($i)->getAttribute('method'), @@ -1694,7 +1694,7 @@ class ContentModel extends XMLDatastream { $found = FALSE; $dispMethods = $ds->getElementsByTagName('display_method'); for ($i = 0; !$found && $i < $dispMethods->length; $i++) { - if ($module == ($dispMethods->item($i)->getAttribute('module') == '' ? 'fedora_repository' : $dispMethods->item($i)->getAttribute('module')) && + if ($module == ($dispMethods->item($i)->getAttribute('module') == '' ? 'islandora_repository' : $dispMethods->item($i)->getAttribute('module')) && $file == $dispMethods->item($i)->getAttribute('file') && $class == $dispMethods->item($i)->getAttribute('class') && $method == $dispMethods->item($i)->getAttribute('method')) { @@ -1732,7 +1732,7 @@ class ContentModel extends XMLDatastream { $found = FALSE; $dispMethods = $ds->getElementsByTagName('display_method'); for ($i = 0; !$found && $i < $dispMethods->length; $i++) { - if ($module == ($dispMethods->item($i)->getAttribute('module') == '' ? 'fedora_repository' : $dispMethods->item($i)->getAttribute('module') == '') && + if ($module == ($dispMethods->item($i)->getAttribute('module') == '' ? 'islandora_repository' : $dispMethods->item($i)->getAttribute('module') == '') && $file == $dispMethods->item($i)->getAttribute('file') && $class == $dispMethods->item($i)->getAttribute('class') && $method == $dispMethods->item($i)->getAttribute('method')) { @@ -1785,7 +1785,7 @@ class ContentModel extends XMLDatastream { if (($ds = $this->getDSModel($ds)) !== FALSE) { $addDsMethod = $ds->getElementsByTagName('add_datastream_method'); if ($addDsMethod !== FALSE && $addDsMethod->length > 0) { - $ret = array('module' => $addDsMethod->item(0)->getAttribute('module') == '' ? 'fedora_repository' : $addDsMethod->item(0)->getAttribute('module'), + $ret = array('module' => $addDsMethod->item(0)->getAttribute('module') == '' ? 'islandora_repository' : $addDsMethod->item(0)->getAttribute('module'), 'file' => $addDsMethod->item(0)->getAttribute('file'), 'class' => $addDsMethod->item(0)->getAttribute('class'), 'method' => $addDsMethod->item(0)->getAttribute('method'), @@ -1936,7 +1936,7 @@ class ContentModel extends XMLDatastream { $methods = $rule->getElementsByTagName('ingest_methods')->item(0)->getElementsByTagName('ingest_method'); $found = FALSE; for ($i = 0; $found === FALSE && $i < $methods->length; $i++) { - if (($methods->item($i)->getAttribute('module') == '' ? 'fedora_repository' : $methods->item($i)->getAttribute('module')) == $module && + if (($methods->item($i)->getAttribute('module') == '' ? 'islandora_repository' : $methods->item($i)->getAttribute('module')) == $module && $methods->item($i)->getAttribute('file') == $file && $methods->item($i)->getAttribute('class') == $class && $methods->item($i)->getAttribute('method') == $method) { @@ -1989,7 +1989,7 @@ class ContentModel extends XMLDatastream { $methodsEl = $rule->getElementsByTagName('ingest_methods')->item(0); $methods = $methodsEl->getElementsByTagName('ingest_method'); for ($i = 0; !$found && $i < $methods->length; $i++) { - if (( trim($methods->item($i)->getAttribute('module')) == $module || (trim($methods->item($i)->getAttribute('module')) == '' && $module == 'fedora_repository')) && trim($methods->item($i)->getAttribute('file')) == $file && trim($methods->item($i)->getAttribute('class')) == $class && trim($methods->item($i)->getAttribute('method')) == $method) { + if (( trim($methods->item($i)->getAttribute('module')) == $module || (trim($methods->item($i)->getAttribute('module')) == '' && $module == 'islandora_repository')) && trim($methods->item($i)->getAttribute('file')) == $file && trim($methods->item($i)->getAttribute('class')) == $class && trim($methods->item($i)->getAttribute('method')) == $method) { $found = $methods->item($i); } } @@ -2077,7 +2077,7 @@ class ContentModel extends XMLDatastream { $methods = $rules->item($i)->getElementsByTagName('ingest_methods')->item(0)->getElementsByTagName('ingest_method'); for ($j = 0; $j < $methods->length; $j++) { - $method = array('module' => $methods->item($j)->getAttribute('module') == '' ? 'fedora_repository' : $methods->item($j)->getAttribute('module'), + $method = array('module' => $methods->item($j)->getAttribute('module') == '' ? 'islandora_repository' : $methods->item($j)->getAttribute('module'), 'file' => $methods->item($j)->getAttribute('file'), 'class' => $methods->item($j)->getAttribute('class'), 'method' => $methods->item($j)->getAttribute('method'), @@ -2157,7 +2157,7 @@ class ContentModel extends XMLDatastream { $ret = FALSE; if ($this->validate()) { $method = $this->xml->getElementsByTagName('ingest_form')->item(0)->getElementsByTagName('form_builder_method')->item(0); - $ret = array('module' => ($method->getAttribute('module') == '' ? 'fedora_repository' : $method->getAttribute('module')), + $ret = array('module' => ($method->getAttribute('module') == '' ? 'islandora_repository' : $method->getAttribute('module')), 'file' => $method->getAttribute('file'), 'class' => $method->getAttribute('class'), 'method' => $method->getAttribute('method'), diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 9e9995b7..da56852b 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -33,7 +33,7 @@ class ObjectHelper { */ function ObjectHelper() { drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); $connectionHelper = new ConnectionHelper(); //$this->fedoraUser = $connectionHelper->getUser(); //$this->fedoraPass = $connectionHelper->getPassword(); @@ -56,7 +56,7 @@ class ObjectHelper { */ function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = TRUE) { global $user; - module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); if ($pid == NULL || $dsID == NULL) { drupal_set_message(t("no pid or dsid given to create an object with"), 'error'); return ' '; @@ -69,7 +69,7 @@ class ObjectHelper { return ' '; } - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t("You do not have access Fedora objects within the attempted namespace."), 'error'); drupal_access_denied(); return ' '; @@ -91,7 +91,7 @@ class ObjectHelper { } } - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $item = new Fedora_Item($pid); @@ -176,7 +176,7 @@ class ObjectHelper { * for the mimetype in question. */ if ($pos === FALSE) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); $mimeclass = new MimeClass(); $ext = $mimeclass->get_extension($mimeType); $suggestedFileName = "$label.$ext"; @@ -207,7 +207,7 @@ class ObjectHelper { * @return type */ function getCollectionInfo($pid, $query = NULL) { - module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'islandora_repository', 'CollectionClass'); $collectionClass = new CollectionClass(); $results = $collectionClass->getRelatedItems($pid, $query); return $results; @@ -227,12 +227,12 @@ class ObjectHelper { drupal_set_message(t('You must specify an object pid and datastream ID.'), 'error'); return ''; } - if (!fedora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!islandora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t('You do not have the appropriate permissions'), 'error'); return; } - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $item = new fedora_item($pid); $datastream_list = $item->get_datastreams_list_as_SimpleXML(); if (!isset($datastream_list)) { @@ -262,12 +262,12 @@ class ObjectHelper { drupal_set_message(t('You must specify an object pid and datastream ID.'), 'error'); return ''; } - if (!fedora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!islandora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t('You do not have the appropriate permissions'), 'error'); return; } - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $item = new fedora_item($pid); $datastream_list = $item->get_datastreams_list_as_SimpleXML(); if (!isset($datastream_list)) { @@ -291,7 +291,7 @@ class ObjectHelper { */ function create_link_for_ds($pid, $dataStreamValue) { global $base_url; - $path = drupal_get_path('module', 'fedora_repository'); + $path = drupal_get_path('module', 'islandora_repository'); require_once($path . '/api/fedora_item.inc'); $item = new Fedora_Item($pid); @@ -359,8 +359,8 @@ class ObjectHelper { */ function getFormattedDC($item) { global $base_url; - $path = drupal_get_path('module', 'fedora_repository'); - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + $path = drupal_get_path('module', 'islandora_repository'); + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); $dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC'; $xmlstr = $item->get_datastream_dissemination($dsid); @@ -408,7 +408,7 @@ class ObjectHelper { $ds_list = $item->get_datastreams_list_as_array(); $output = $this->getFormattedDC($item); $dsid = array_key_exists('QDC', $ds_list) ? 'QDC' : 'DC'; - $path = drupal_get_path('module', 'fedora_repository'); + $path = drupal_get_path('module', 'islandora_repository'); //$baseUrl=substr($baseUrl, 0, (strpos($baseUrl, "/")-1)); if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) { @@ -440,12 +440,12 @@ class ObjectHelper { */ function get_formatted_datastream_list($object_pid, $contentModels, &$fedoraItem) { global $fedoraUser, $fedoraPass, $base_url, $user; - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); - $path = drupal_get_path('module', 'fedora_repository'); + $path = drupal_get_path('module', 'islandora_repository'); $dataStreamBody = ''; $fedoraItem = new Fedora_Item($object_pid); @@ -514,7 +514,7 @@ class ObjectHelper { * */ function getStream($pid, $dsid, $showError = FALSE) { - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); $soapHelper = new ConnectionHelper(); try { $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); @@ -548,7 +548,7 @@ class ObjectHelper { * @return array */ function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { - module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'islandora_repository', 'CollectionClass'); $collectionHelper = new CollectionClass(); $pids = array(); $query = 'select $object from <#ri> @@ -593,7 +593,7 @@ class ObjectHelper { * @param type $pid * @return type */ - function fedora_repository_access($op, $pid) { + function islandora_repository_access($op, $pid) { global $user; $returnValue = FALSE; @@ -602,7 +602,7 @@ class ObjectHelper { $namespaceAccess = TRUE; } if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); + $pid = variable_get('islandora_repository_pid', 'islandora:root'); } $nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $pos = NULL; @@ -632,7 +632,7 @@ class ObjectHelper { * @param $content String */ function parseContent($content, $pid, $dsId, $collection, $pageNumber = NULL) { - $path = drupal_get_path('module', 'fedora_repository'); + $path = drupal_get_path('module', 'islandora_repository'); global $base_url; $collection_pid = $pid; //we will be changing the pid later maybe //module_load_include('php', ''Fedora_Repository'', 'ObjectHelper'); @@ -790,7 +790,7 @@ class ObjectHelper { return NULL; } $output = ''; - module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); if (($cm = ContentModel :: loadFromModel($contentModel)) !== FALSE && $cm->validate()) { $output .= $cm->displayExtraFieldset($pid, $page_number); } @@ -810,7 +810,7 @@ class ObjectHelper { return FALSE; } - module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); if ($dsid != NULL && $pid != NULL && ($cm = ContentModel::loadFromObject($pid)) !== FALSE) { $cm->execAddDatastreamMethods($dsid, $file); } @@ -826,7 +826,7 @@ class ObjectHelper { if (!$pid) { return FALSE; } - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); // Get title and descriptions for $pid $query_string = 'select $title $desc from <#ri> @@ -834,7 +834,7 @@ class ObjectHelper { and $o $desc and $o '; - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query_string))); @@ -868,7 +868,7 @@ class ObjectHelper { } $query_string = substr($query_string, 0, -3) . ' )'; - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; $url .= htmlentities(urlencode($query_string)); $content = $this->doCurl($url); @@ -905,7 +905,7 @@ class ObjectHelper { * @return type */ function getObject($pid, $context = 'archive', $format = FOXML_11) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/objects/' . $pid . '/export?context=' . $context . '&format=' . $format; $result_data = do_curl($url); @@ -921,10 +921,10 @@ class ObjectHelper { * @param type $level */ function getBreadcrumbs($pid, &$breadcrumbs, $level=10) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); // Before executing the query, we hve a base case of accessing the top-level collection global $base_url; - if ($pid == variable_get('fedora_repository_pid', 'islandora:root')) { + if ($pid == variable_get('islandora_repository_pid', 'islandora:root')) { $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); $breadcrumbs[] = l(t('Home'), $base_url); } @@ -940,7 +940,7 @@ class ObjectHelper { order by $title'; $query_string = htmlentities(urlencode($query_string)); - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=CSV&limit=1&offset=0&lang=itql&stream=on&query=" . $query_string; $result = preg_split('/[\r\n]+/', do_curl($url)); @@ -950,7 +950,7 @@ class ObjectHelper { $parent = preg_replace('/^info:fedora\//', '', $matches[0]); $breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); - if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) { + if ($parent == variable_get('islandora_repository_pid', 'islandora:root')) { $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); $breadcrumbs[] = l(t('Home'), $base_url); } diff --git a/SearchClass.inc b/SearchClass.inc index 3f1c78d5..794d292a 100644 --- a/SearchClass.inc +++ b/SearchClass.inc @@ -25,14 +25,14 @@ class SearchClass { function solr_search($query, $startPage=1, $fq = NULL, $dismax = NULL) { $solrFile = trim(variable_get('islandora_solr_search_block_handler_file', 'plugins/SolrResults.inc')); - // Don't let us bust out of fedora_repository modules directory when looking for a handler + // Don't let us bust out of islandora_repository modules directory when looking for a handler if (strpos($solrField, '../')) { drupal_set_message(t('You have illegal characters in your solr handler function in the Islandora solr block config.'), 'error'); } $solrClass = trim(variable_get('islandora_solr_search_block_handler_class', 'SolrResults')); $solrFunction = trim(variable_get('islandora_solr_search_block_handler_function', 'SearchAndDisplay')); - require_once(drupal_get_path('module', 'fedora_repository') . '/' . $solrFile); + require_once(drupal_get_path('module', 'islandora_repository') . '/' . $solrFile); try { $implementation = new $solrClass(); } catch (Exception $e) { @@ -185,8 +185,8 @@ class SearchClass { * @return type */ function quickSearch($type, $query, $showForm = 1, $orderBy = 0, & $userArray) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); if (user_access('view fedora collection')) { $numberOfHistPerPage = '5000'; //hack for IR they do not want next button $luceneQuery = NULL; @@ -222,7 +222,7 @@ class SearchClass { } } if ($showForm) { - $output = 'Quick Search
    ' . drupal_get_form('fedora_repository_quick_search_form') . '
    '; + $output = 'Quick Search
    ' . drupal_get_form('islandora_repository_quick_search_form') . '
    '; } $output .= $this->applyXSLT($resultData, $orderBy); return $output; @@ -237,8 +237,8 @@ class SearchClass { * @return type */ function getTerms($fieldName, $startTerm, $displayName = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); $indexName = variable_get('fedora_index_name', 'DemoOnLucene'); $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest'); if ($startTerm == NULL) { @@ -269,8 +269,8 @@ class SearchClass { * @return type */ function custom_search($query, $startPage=1, $xslt= '/xsl/advanced_search_results.xsl', $numberOfHistPerPage = 50) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); if (user_access('view fedora collection')) { //$numberOfHistPerPage = '50';//hack for IR they do not want next button @@ -322,7 +322,7 @@ class SearchClass { return ' '; } - //$proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl + //$proc->setParameter('', 'searchUrl', url('search') . '/islandora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'userID', $user->uid); if (isset($displayName)) { @@ -390,8 +390,8 @@ class SearchClass { //inject into xsl stylesheet global $user; $proc->setParameter('', 'userID', $user->uid); - $proc->setParameter('', 'searchToken', drupal_get_token('fedora_repository_advanced_search')); //token generated by Drupal, keeps tack of what tab etc we are on - $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl + $proc->setParameter('', 'searchToken', drupal_get_token('islandora_repository_advanced_search')); //token generated by Drupal, keeps tack of what tab etc we are on + $proc->setParameter('', 'searchUrl', url('search') . '/islandora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $proc->setParameter('', 'hitPageStart', $startPage); @@ -441,7 +441,7 @@ class SearchClass { //inject into xsl stylesheet //$proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on $proc->setParameter('', 'userID', $user->uid); - $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl + $proc->setParameter('', 'searchUrl', url('search') . '/islandora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $proc->setParameter('', 'orderBy', $orderBy); @@ -475,7 +475,7 @@ class SearchClass { */ function theme_advanced_search_form($form, $repeat=NULL) { if (!isset($repeat)) { - $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3')); + $repeat = variable_get('islandora_repository_advanced_block_repeat', t('3')); } $output = drupal_render($form['search_type']['type1']); @@ -515,7 +515,7 @@ class SearchClass { $form = array(); if (!isset($repeat)) { - $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3')); + $repeat = variable_get('islandora_repository_advanced_block_repeat', t('3')); } $var0 = explode(':', $queryArray[0]); $var1 = explode(':', $queryArray[1]); diff --git a/SecurityClass.inc b/SecurityClass.inc index 0cdb2cbe..fbc6d3b8 100644 --- a/SecurityClass.inc +++ b/SecurityClass.inc @@ -30,7 +30,7 @@ class SecurityClass { */ function canIngestHere($collection_pid) { global $user; - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); // get the childsecurity policy from the collection. $policyStream = $objectHelper->getStream($collection_pid, SECURITYCLASS :: $SECURITY_CLASS_SECURITY_STREAM, FALSE); diff --git a/XMLDatastream.inc b/XMLDatastream.inc index d3afed09..9376aa83 100644 --- a/XMLDatastream.inc +++ b/XMLDatastream.inc @@ -168,7 +168,7 @@ abstract class XMLDatastream { //$tmpname = substr($this->pid, strpos($this->pid, ':') + 1); $tmpname = user_password(10); $this->convertFromOldSchema(); - drupal_add_js("fedora_repository_print_new_schema_$tmpname = function(tagID) { + drupal_add_js("islandora_repository_print_new_schema_$tmpname = function(tagID) { var target = document.getElementById(tagID); var content = target.innerHTML; var text = 'Title' + @@ -179,7 +179,7 @@ abstract class XMLDatastream { }", 'inline'); if (user_access('administer site configuration')) { - drupal_set_message('<span id="new_schema_' . $tmpname . '" style="display: none;">' . htmlentities($this->xml->saveXML()) . '</span>Warning: XMLDatastream performed conversion of \'' . $this->getIdentifier() . '\' from old schema. Please update the datastream. The new datastream contents are <a href="javascript:fedora_repository_print_new_schema_' . $tmpname . '(\'new_schema_' . $tmpname . '\')">here.</a> '); + drupal_set_message('<span id="new_schema_' . $tmpname . '" style="display: none;">' . htmlentities($this->xml->saveXML()) . '</span>Warning: XMLDatastream performed conversion of \'' . $this->getIdentifier() . '\' from old schema. Please update the datastream. The new datastream contents are <a href="javascript:islandora_repository_print_new_schema_' . $tmpname . '(\'new_schema_' . $tmpname . '\')">here.</a> '); } $rootEl = $this->xml->firstChild; @@ -246,7 +246,7 @@ abstract class XMLDatastream { * @return boolean $valid */ public function purgeVersions($start_date, $end_date = NULL) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $fedora_item = new Fedora_Item($this->pid); return $fedora_item->purge_datastream($this->dsid, $start_date, $end_date); } @@ -258,7 +258,7 @@ abstract class XMLDatastream { * @return string[] $ret */ public function getHistory() { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $fedora_item = new Fedora_Item($this->pid); $history = $fedora_item->get_datastream_history($this->dsid); diff --git a/formClass.inc b/formClass.inc index 762f1252..93b68316 100644 --- a/formClass.inc +++ b/formClass.inc @@ -24,15 +24,15 @@ class formClass { function createMenu() { $items = array(); - $items['admin/settings/fedora_repository'] = array( + $items['admin/settings/islandora_repository'] = array( 'title' => t('Configure Islandora'), 'description' => t('Enter the Islandora Collection information here'), 'page callback' => 'drupal_get_form', - 'page arguments' => array('fedora_repository_admin'), + 'page arguments' => array('islandora_repository_admin'), 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); - $items['admin/settings/fedora_repository/collection'] = array( + $items['admin/settings/islandora_repository/collection'] = array( 'title' => t('Collection list'), 'description' => t('Enter the Islandora collection information here.'), 'access arguments' => array('administer site configuration'), @@ -40,18 +40,18 @@ class formClass { 'weight' => 0, ); - $items['admin/settings/fedora_repository/demoobjects'] = array( + $items['admin/settings/islandora_repository/demoobjects'] = array( 'title' => t('Solution Packs'), 'description' => t('Install content models and collections required by installed solution packs.'), - 'page callback' => 'fedora_repository_solution_packs_page', + 'page callback' => 'islandora_repository_solution_packs_page', 'access arguments' => array('add fedora datastreams'), - 'file' => 'fedora_repository.solutionpacks.inc', + 'file' => 'islandora_repository.solutionpacks.inc', 'type' => MENU_LOCAL_TASK, ); $items['islandoracm.xsd'] = array( 'title' => t('Islandora Content Model XML Schema Definition'), - 'page callback' => 'fedora_repository_display_schema', + 'page callback' => 'islandora_repository_display_schema', 'page arguments' => array('islandoracm.xsd'), 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), @@ -59,7 +59,7 @@ class formClass { $items['collection_policy.xsd'] = array( 'title' => t('Islandora Content Model XML Schema Definition'), - 'page callback' => 'fedora_repository_display_schema', + 'page callback' => 'islandora_repository_display_schema', 'page arguments' => array('collection_policy.xsd'), 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), @@ -70,7 +70,7 @@ class formClass { 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); - $repository_title = variable_get('fedora_repository_title', 'Digital repository'); + $repository_title = variable_get('islandora_repository_title', 'Digital repository'); if (trim($repository_title) != '') { $respository_title = t($repository_title); } @@ -100,7 +100,7 @@ class formClass { $items['fedora/repository/editmetadata'] = array( 'title' => t('Edit metadata'), - 'page callback' => 'fedora_repository_edit_qdc_page', + 'page callback' => 'islandora_repository_edit_qdc_page', // 'page arguments' => array(1), //'type' => MENU_LOCAL_TASK, 'type' => MENU_CALLBACK, @@ -109,21 +109,21 @@ class formClass { $items['fedora/repository/purgeStream'] = array( 'title' => t('Purge data stream'), - 'page callback' => 'fedora_repository_purge_stream', + 'page callback' => 'islandora_repository_purge_stream', 'type' => MENU_CALLBACK, 'access arguments' => array('purge objects and datastreams') ); $items['fedora/repository/replaceStream'] = array( 'title' => t('Replace Stream'), - 'page callback' => 'fedora_repository_replace_stream', + 'page callback' => 'islandora_repository_replace_stream', 'type' => MENU_CALLBACK, 'access arguments' => array('add fedora datastreams'), ); $items['fedora/repository/purgeObject'] = array( 'title' => t('Purge object'), - 'page callback' => 'fedora_repository_purge_object', + 'page callback' => 'islandora_repository_purge_object', // 'type' => MENU_LOCAL_TASK, 'type' => MENU_CALLBACK, 'access arguments' => array('purge objects and datastreams') @@ -147,21 +147,21 @@ class formClass { //new for mnpl****************************************** $items['fedora/repository/mnpl_advanced_search'] = array( 'title' => t('Repository advanced search'), - 'page callback' => 'fedora_repository_mnpl_advanced_search', + 'page callback' => 'islandora_repository_mnpl_advanced_search', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection') ); $items['fedora/ingestObject'] = array( 'title' => t('Ingest object'), - 'page callback' => 'fedora_repository_ingest_object', + 'page callback' => 'islandora_repository_ingest_object', 'type' => MENU_CALLBACK, 'access arguments' => array('add fedora datastreams') ); $items['fedora/repository/list_terms'] = array( 'title' => t('List terms'), - 'page callback' => 'fedora_repository_list_terms', + 'page callback' => 'islandora_repository_list_terms', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection') ); @@ -170,25 +170,25 @@ class formClass { $items['fedora/basket'] = array( 'title' => t('Fedora Basket'), 'description' => t('View and download objects added to your basket'), - 'page callback' => 'fedora_repository_basket', + 'page callback' => 'islandora_repository_basket', 'access arguments' => array('view fedora collection'), 'type' => MENU_CALLBACK, ); $items['fedora/repository/addToBasket'] = array( - 'page callback' => 'fedora_repository_add_to_basket', + 'page callback' => 'islandora_repository_add_to_basket', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); $items['fedora/repository/removeFromBasket'] = array( - 'page callback' => 'fedora_repository_remove_from_basket', + 'page callback' => 'islandora_repository_remove_from_basket', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); $items['fedora/repository/add_search_results_to_basket'] = array( - 'page callback' => 'fedora_repository_add_search_results_to_basket', + 'page callback' => 'islandora_repository_add_search_results_to_basket', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); @@ -205,21 +205,21 @@ class formClass { drupal_set_message(t('You must be a site administrator to edit the Fedora collecitons list.'), 'error'); return; } - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $form = array(); - $form['fedora_repository_name'] = array( + $form['islandora_repository_name'] = array( '#type' => 'textfield', '#title' => t('Root Collection Name'), - '#default_value' => variable_get('fedora_repository_name', 'Islandora demos collection'), + '#default_value' => variable_get('islandora_repository_name', 'Islandora demos collection'), '#description' => t('The Name of the Root Collection Object'), '#required' => TRUE, '#weight' => -20 ); - $form['fedora_repository_pid'] = array( + $form['islandora_repository_pid'] = array( '#type' => 'textfield', '#title' => t('Root Collection PID'), - '#default_value' => variable_get('fedora_repository_pid', 'islandora:root'), + '#default_value' => variable_get('islandora_repository_pid', 'islandora:root'), '#description' => t('The PID of the Root Collection Object'), '#required' => TRUE, '#weight' => -18 @@ -235,10 +235,10 @@ class formClass { ); - $form['fedora_repository_url'] = array( + $form['islandora_repository_url'] = array( '#type' => 'textfield', '#title' => t('Fedora RISearch URL'), - '#default_value' => variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'), + '#default_value' => variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'), '#description' => t('The url of the Fedora server'), '#required' => TRUE, '#weight' => -14 ); @@ -296,10 +296,10 @@ class formClass { '#weight' => 0 ); } - $form['fedora_repository_title'] = array( + $form['islandora_repository_title'] = array( '#type' => 'textfield', '#title' => t('Digital Repository Title'), - '#default_value' => variable_get('fedora_repository_title', 'Digital Repository'), + '#default_value' => variable_get('islandora_repository_title', 'Digital Repository'), '#description' => t('The title displayed when viewing collections and objects in /fedora/repository. Leave blank to display no title. Note that the menus must be rebuilt after changing this variable.'), ); $form['advanced'] = array( @@ -432,7 +432,7 @@ class formClass { * @return type */ function can_ingest_here($collection_pid) { - module_load_include('inc', 'fedora_repository', 'SecurityClass'); + module_load_include('inc', 'islandora_repository', 'SecurityClass'); $securityClass = new SecurityClass(); return $securityClass->canIngestHere($collection_pid); } @@ -447,7 +447,7 @@ class formClass { drupal_set_message(t('You do not have permission to ingest.'), 'error'); return FALSE; } - module_load_include('inc', 'fedora_repository', 'SecurityClass'); + module_load_include('inc', 'islandora_repository', 'SecurityClass'); $security_class = new SecurityClass(); if (!$security_class->canIngestHere($collection_pid)) { // Queries the collection object for a child security datastream and if found parses it @@ -507,7 +507,7 @@ class formClass { ), 'submit' => array( '#type' => 'submit', - '#submit' => array('fedora_repository_ingest_form_submit'), + '#submit' => array('islandora_repository_ingest_form_submit'), '#value' => t('Next') ), ); @@ -523,7 +523,7 @@ class formClass { * @return array */ function createQDCIngestFormPageTwo($collection_pid, $collection_label, array &$form_state) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); $form = array(); $content_model_pid = ContentModel::getPidFromIdentifier($form_state['values']['models']); $content_model_dsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); @@ -541,7 +541,7 @@ class formClass { ); $form['submit'] = array( '#type' => 'submit', - '#submit' => array('fedora_repository_ingest_form_submit'), + '#submit' => array('islandora_repository_ingest_form_submit'), '#value' => t('Ingest') ); } @@ -558,7 +558,7 @@ class formClass { * @return array */ function createQDCIngestForm($collection_pid, $collection_label, array &$form_state) { - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); + module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); $form_state['storage']['step'] = empty($form_state['storage']['step']) ? 1 : $form_state['storage']['step']; if ($form_state['storage']['step'] == 1) { return $this->createQDCIngestFormPageOne($collection_pid, $collection_label, $form_state); @@ -603,9 +603,9 @@ class formClass { //dump_vars($form_state); // Populate the list of datastream IDs. - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $obj_helper = new ObjectHelper(); $content_models = $obj_helper->get_content_models_list($pid); diff --git a/islandora_repository.solutionpacks.inc b/islandora_repository.solutionpacks.inc new file mode 100644 index 00000000..633d28fe --- /dev/null +++ b/islandora_repository.solutionpacks.inc @@ -0,0 +1,175 @@ +<?php + +/** + * @file + * Invokes a hook to any dependent modules asking them if their installations require + * any fedora objects to be present. Modules implementing this hook should return an array + * of arrays of the form: + * + * array( 'pid', 'path-to-foxml-file', 'dsid', 'path-to-datastream-file', int dsversion) + * + * where the last three options are optional. A module can either point to a simple + * foxml file to install, or can specify a datastreamstream to check for, with a + * path to load the datastream from if it isn't there. Optionally a version number + * can be included, to enable updating of content model or collection policy streams + * that may have been updated. THis is a simple whole number that should be incremented + * when changed. This value appears in as an attribute of the topmost element of the stream, + * e.g.,: + * + * <?xml version="1.0" encoding="utf-8"?> <content_model name="Collection" version="2" ... + * + * Datastreams which don't have this element are assumed to be at version 0. + */ +function islandora_repository_solution_packs_page() { + $enabled_solution_packs = module_invoke_all('required_fedora_objects'); + $output = ''; + foreach ($enabled_solution_packs as $solution_pack_module => $solution_pack_info) { + $objects = array(); + foreach ($solution_pack_info as $field => $value) { + switch ($field) { + case 'title': + $solution_pack_name = $value; + break; + case 'objects': + $objects = $value; + break; + } + } + $output .= drupal_get_form('islandora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects); + } + + return $output; +} + +/** + * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. + * @param array $solution_pack + */ +function islandora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { + // Check each object to see if it is in the repository. + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + global $base_path; + $needs_update = FALSE; + $needs_install = FALSE; + $form = array(); + $form['solution_pack_module'] = array( + '#type' => 'hidden', + '#value' => $solution_pack_module, + ); + + if (!$form_state['submitted']) { + $form['soluction_pack_name'] = array( + '#type' => 'markup', + '#value' => t($solution_pack_name), + '#prefix' => '<h3>', + '#suffix' => '</h3>', + ); + $form['objects'] = array( + '#type' => 'fieldset', + '#title' => "Objects", + '#weight' => 10, + '#attributes' => array('class' => 'collapsed'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $table_header = array('PID', 'Status'); + $table_rows = array(); + + + foreach ($objects as $object) { + $datastreams = NULL; + if (isset($object['pid'])) { + $pid = $object['pid']; + + $item = new Fedora_Item($pid); + $table_row = array($object['pid']); + $object_status = t('Up-to-date'); + if (!$item->exists()) { + $object_status = 'Missing'; + $needs_install = TRUE; + } + else { + if (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { + $datastreams = array( + array( + 'dsid' => $object['dsid'], + 'datastream_file' => $object['datastream_file'], + 'dsversion' => $object['dsversion'], + ), + ); + } + elseif (!empty($object['datastreams'])) { + $datastreams = $object['datastreams']; + } + if (!empty($datastreams) && is_array($datastreams)) { + foreach ($datastreams as $ds) { + $ds_list = $item->get_datastreams_list_as_array(); + if (!array_key_exists($ds['dsid'], $ds_list)) { + $needs_update = TRUE; + $object_status = 'Missing datastream'; + break; + } + if (isset($ds['dsversion'])) { + // Check if the datastream is versioned and needs updating. + $installed_version = islandora_repository_get_islandora_datastream_version($item, $ds['dsid']); + $available_version = islandora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); + if ($available_version > $installed_version) { + $needs_update = TRUE; + $object_status = 'Out of date'; + break; + } + } + } + } + } + array_push($table_row, $object_status); + $table_rows[] = $table_row; + } + } + $form['objects']['table'] = array( + '#type' => 'markup', + '#value' => theme_table($table_header, $table_rows), + ); + } + + $form['install_status'] = array( + '#type' => 'markup', + '#prefix' => '<strong>' . t('Object status:') . ' </strong>', + '#suffix' => ' ', + ); + if (!$needs_install && !$needs_update) { + $form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.'); + } + else { + $form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.'); + } + $form['submit'] = array( + '#value' => t('Install'), + '#disabled' => !$needs_install && !$needs_update, + '#type' => 'submit', + '#name' => $solution_pack_module, + ); + + $form['#submit'] = array( + 'islandora_repository_solution_pack_form_submit', + ); + return $form; +} + +function islandora_repository_solution_pack_form_submit($form, &$form_state) { + $what = $form_state; + $module_name = $form_state['values']['solution_pack_module']; + $solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); + $batch = array( + 'title' => t('Installing / updating solution pack objects'), + 'file' => drupal_get_path('module', 'islandora_repository') . '/islandora_repository.module', + 'operations' => array(), + ); + + + foreach ($solution_pack_info[$module_name]['objects'] as $object) { + // Add this object to the batch job queue. + $batch['operations'][] = array('islandora_repository_batch_reingest_object', array($object)); + } + batch_set($batch); +} From ab131a672fa427db1fbeb9476488e5bc60b7bf0e Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Tue, 11 Oct 2011 10:21:27 -0300 Subject: [PATCH 05/46] switched to islandora repository --- api/fedora_collection.inc | 14 +- api/fedora_export.inc | 4 +- api/fedora_item.inc | 10 +- api/fedora_utils.inc | 12 +- islandora_repository.info | 9 + islandora_repository.install | 107 ++ islandora_repository.module | 2251 +++++++++++++++++++++++ islandoracm.xsd | 10 +- plugins/CollectionFormBuilder.inc | 4 +- plugins/DarwinCore.inc | 8 +- plugins/DemoFormBuilder.inc | 6 +- plugins/DocumentConverter.inc | 2 +- plugins/Exiftool.inc | 2 +- plugins/FedoraObjectDetailedContent.inc | 12 +- plugins/Flv.inc | 2 +- plugins/FlvFormBuilder.inc | 6 +- plugins/FormBuilder.inc | 8 +- plugins/ImageManipulation.inc | 2 +- plugins/ModsFormBuilder.inc | 16 +- plugins/PersonalCollectionClass.inc | 2 +- plugins/QtFormBuilder.php | 4 +- plugins/Refworks.inc | 12 +- plugins/ShowStreamsInFieldSets.inc | 18 +- plugins/herbarium.inc | 28 +- plugins/islandora_imageapi.info | 7 + plugins/islandora_imageapi.module | 116 ++ plugins/map_viewer.inc | 10 +- plugins/qt_viewer.inc | 6 +- plugins/slide_viewer.inc | 6 +- plugins/tagging_form.inc | 22 +- tests/README_TESTING.txt | 2 +- tests/fedora_repository.test | 20 +- 32 files changed, 2614 insertions(+), 124 deletions(-) create mode 100644 islandora_repository.info create mode 100644 islandora_repository.install create mode 100644 islandora_repository.module create mode 100644 plugins/islandora_imageapi.info create mode 100644 plugins/islandora_imageapi.module diff --git a/api/fedora_collection.inc b/api/fedora_collection.inc index b8afc5c4..2efd2acb 100644 --- a/api/fedora_collection.inc +++ b/api/fedora_collection.inc @@ -4,10 +4,10 @@ * @file * Operations that affect a Fedora repository at a collection level. */ -module_load_include('inc', 'fedora_repository', 'CollectionClass'); -module_load_include('inc', 'fedora_repository', 'api/fedora_item'); -module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); -module_load_include('module', 'fedora_repository'); +module_load_include('inc', 'islandora_repository', 'CollectionClass'); +module_load_include('inc', 'islandora_repository', 'api/fedora_item'); +module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); +module_load_include('module', 'islandora_repository'); /** * Exports a fedora collection object and all of its children in a format @@ -68,10 +68,10 @@ function export_collection($collection_pid, $relationship = 'isMemberOfCollectio * @param <type> $query_format R */ function get_related_items_as_xml($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); global $user; - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); return array(); } @@ -111,7 +111,7 @@ function get_related_items_as_xml($collection_pid, $relationship = array('isMemb $content = ''; - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=Sparql&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query_string; $content .= do_curl($url); diff --git a/api/fedora_export.inc b/api/fedora_export.inc index e1ed3cbd..bc4fd00f 100644 --- a/api/fedora_export.inc +++ b/api/fedora_export.inc @@ -41,7 +41,7 @@ function export_to_export_area($pid, $foxml_dir, $ob_dir, &$log = array()) { * @return string */ function export_objects_for_pid($pid, $dir, &$log) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $item = new Fedora_Item($pid); if (!$object = $item->get_datastreams_list_as_SimpleXML($pid)) { $log[] = log_line(t("Failed to get datastream %dsid for pid %pid", array('%dsid' => $ds->ID, '%pid' => $pid)), 'error'); @@ -85,7 +85,7 @@ function export_objects_for_pid($pid, $dir, &$log) { * @return type */ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $remove_islandora = FALSE) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $ob_helper = new ObjectHelper(); if (!$object_xml = $ob_helper->getObject($pid, 'migrate', $format)) { $log[] = log_line(t("Failed to get foxml for %pid", array('%pid' => $pid)), 'error'); diff --git a/api/fedora_item.inc b/api/fedora_item.inc index 4dacca8c..fdf7074c 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -28,8 +28,8 @@ class Fedora_Item { */ function __construct($pid) { drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); $this->pid = $pid; if (isset(Fedora_Item::$instantiated_pids[$pid])) { @@ -75,7 +75,7 @@ class Fedora_Item { * @return type */ function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); if (!is_file($datastream_file)) { drupal_set_message("$datastream_file not found<br />", 'warning'); return; @@ -285,7 +285,7 @@ class Fedora_Item { * @return Array of pid => title pairs that match the results */ static function find_objects_by_pattern($pattern = '*', $field = 'pid', $max_results = 100, $resultFields = array()) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); $pattern = drupal_urlencode($pattern); $done = FALSE; @@ -848,7 +848,7 @@ class Fedora_Item { */ static function soap_call($function_name, $params_array, $quiet = FALSE) { if (!self::$connection_helper) { - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); self::$connection_helper = new ConnectionHelper(); } switch ($function_name) { diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index c8ce7d0e..91a8f05f 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -158,7 +158,7 @@ function fedora_available() { */ function risearch_available() { - $response = do_curl_ext(variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch')); + $response = do_curl_ext(variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch')); return ($response != NULL) ? ($response[1] == 0): FALSE; } @@ -238,13 +238,13 @@ function fix_dsid($dsid) { * @return array */ function get_collections_as_option_array() { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); $query = 'select $object $title from <#ri> where ($object <dc:title> $title and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) order by $title'; - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query))); $list = explode("\n", $content); @@ -269,8 +269,8 @@ function get_collections_as_option_array() { * @return array */ function get_content_models_as_option_array() { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); $restricted = variable_get('fedora_namespace_restriction_enforced', true); $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); @@ -286,7 +286,7 @@ function get_content_models_as_option_array() { and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) order by $title'; - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query))); $list = explode("\n", $content); diff --git a/islandora_repository.info b/islandora_repository.info new file mode 100644 index 00000000..6fcf223f --- /dev/null +++ b/islandora_repository.info @@ -0,0 +1,9 @@ +; $Id$ +name = Islandora Repository +dependencies[] = imageapi +dependencies[] = tabs +dependencies[] = islandora_content_model_forms +description = Shows a list of items in a fedora collection. +package = Islandora +version = 11.2.beta2 +core = 6.x diff --git a/islandora_repository.install b/islandora_repository.install new file mode 100644 index 00000000..e8e26ad2 --- /dev/null +++ b/islandora_repository.install @@ -0,0 +1,107 @@ +<?php + +/** + * @file islandora_repository.install + */ + +/** + * Implementation of hook_enable(). + */ +function fedora_collections_enable() { + //nothing to do as we do not currently touch the drupal database. + //other than the variables table +} + +/** + * Implementation of hook_requirements(). + * + * @return + * An array describing the status of the site regarding available updates. + * If there is no update data, only one record will be returned, indicating + * that the status of core can't be determined. If data is available, there + * will be two records: one for core, and another for all of contrib + * (assuming there are any contributed modules or themes enabled on the + * site). In addition to the fields expected by hook_requirements ('value', + * 'severity', and optionally 'description'), this array will contain a + * 'reason' attribute, which is an integer constant to indicate why the + * given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or + * UPDATE_UNKNOWN). This is used for generating the appropriate e-mail + * notification messages during update_cron(), and might be useful for other + * modules that invoke update_requirements() to find out if the site is up + * to date or not. + * + * @see _update_message_text() + * @see _update_cron_notify() + */ +function islandora_repository_requirements($phase) { + global $base_url; + + $requirements = array(); + + if ($phase == 'install') { + + // Test for SOAP + $requirements['fedora-soap']['title'] = t("PHP SOAP extension library"); + if (!class_exists('SoapClient')) { + $requirements['fedora-soap']['value'] = t("Not installed"); + $requirements['fedora-soap']['severity'] = REQUIREMENT_ERROR; + $requirements['fedora-soap']['description'] = t('Ensure that the PHP SOAP extension is installed.'); + } + else { + $requirements['fedora-soap']['value'] = t("Installed"); + $requirements['fedora-soap']['severity'] = REQUIREMENT_OK; + } + + // Test for Curl + $requirements['curl']['title'] = "PHP Curl extension library"; + if (!function_exists('curl_init')) { + $requirements['curl']['value'] = t("Not installed"); + $requirements['curl']['severity'] = REQUIREMENT_ERROR; + $requirements['curl']['description'] = t("Ensure that the PHP Curl extension is installed."); + } + else { + $requirements['curl']['value'] = t("Installed"); + $requirements['curl']['severity'] = REQUIREMENT_OK; + } + + // Test for DOM + $requirements['dom']['title'] = "PHP DOM XML extension library"; + if (!method_exists('DOMDocument', 'loadHTML')) { + $requirements['dom']['value'] = t("Not installed"); + $requirements['dom']['severity'] = REQUIREMENT_ERROR; + $requirements['dom']['description'] = t("Ensure that the PHP DOM XML extension is installed."); + } + else { + $requirements['dom']['value'] = t("Installed"); + $requirements['dom']['severity'] = REQUIREMENT_OK; + } + + // Test for XSLT + $requirements['xsl']['title'] = "PHP XSL extension library"; + if (!class_exists('XSLTProcessor')) { + $requirements['xslt']['value'] = t("Not installed"); + $requirements['xslt']['severity'] = REQUIREMENT_ERROR; + $requirements['xslt']['description'] = t("Ensure that the PHP XSL extension is installed."); + } + else { + $requirements['xslt']['value'] = t("Installed"); + $requirements['xslt']['severity'] = REQUIREMENT_OK; + } + } + elseif ($phase == 'runtime') { + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + + $requirements['fedora-repository']['title'] = t("Fedora server"); + if (!fedora_available()) { + $requirements['fedora-repository']['value'] = t("Not available"); + $requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR; + $requirements['fedora-repository']['description'] = t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => $base_url . '/admin/settings/islandora_repository')); + } + else { + $requirements['fedora-repository']['value'] = t("Available"); + $requirements['fedora-repository']['severity'] = REQUIREMENT_OK; + } + } + + return $requirements; +} diff --git a/islandora_repository.module b/islandora_repository.module new file mode 100644 index 00000000..6fa13988 --- /dev/null +++ b/islandora_repository.module @@ -0,0 +1,2251 @@ +<?php + +/** + * Drupal hook for admin form + * islandora_repository_name is the name of the top level collection this module will query + * islandora_repository_pid is the name of the top level pid. + * Stores this info in the drupal variables table. + * the name and pid can also be passed as url parameters + */ +function islandora_repository_admin() { + module_load_include('inc', 'islandora_repository', 'formClass'); + $adminForm = new formClass(); + return $adminForm->createAdminForm(); +} + +/** + * drupal hook + * calls the islandora_repositorys_admin form + */ +function islandora_repository_menu() { + module_load_include('inc', 'islandora_repository', 'formClass'); + $adminMenu = new formClass(); + return $adminMenu->createMenu(); +} + +/** + * drupal hook to show help + * + * @param type $path + * @param type $arg + * @return type + */ +function islandora_repository_help($path, $arg) { + switch ($path) { + case 'admin/modules#description' : + return t('Grabs a list of items from a collection in Drupal that are presented on the home page.'); + case 'node/add#islandora_repository' : + return t('Use this page to grab a list of items from a Fedora collection.'); + } +} + +/** + * fedora repository purge object + * @param type $pid + * @param type $name + * @return type + */ +function islandora_repository_purge_object($pid = NULL, $name = NULL) { + if (!user_access('purge objects and datastreams')) { + drupal_set_message(t('You do not have access to add a datastream to this object.'), 'error'); + return ''; + } + if ($pid == NULL) { + drupal_set_message(t('You must specify an object pid to purge an object.'), 'error'); + return ''; + } + $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', + array( + '%name' => $name, + '%pid' => $pid) + ); + + $output .= drupal_get_form('islandora_repository_purge_object_form', $pid); + return $output; +} + +/** + * fedora repository collection view + * @global type $user + * @param type $pid + * @param type $collection + * @param type $pageNumber + * @return type + */ +function islandora_repository_collection_view($pid = NULL, $collection = NULL, $pageNumber = NULL) { + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + global $user; + if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); + return ' '; + } + + $objectHelper = new ObjectHelper(); + if ($pid == NULL) { + $pid = variable_get('islandora_repository_pid', 'islandora:root'); + } + + $content = ''; + + module_load_include('inc', 'islandora_repository', 'CollectionClass'); + $collectionClass = new CollectionClass(); + $results = $collectionClass->getRelatedItems($pid, NULL); + $content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber); + + return $content; +} + +/** + * fedora repository ingest object + * @param type $collection_pid + * @param type $collection_label + * @param type $content_model + * @return type + */ +function islandora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + if (!user_access('ingest new fedora objects')) { + drupal_set_message(t('You do not have permission to ingest.'), 'error'); + return ''; + } + + if (!valid_pid($collection_pid)) { + if (valid_pid(urldecode($collection_pid))) { + $collection_pid = urldecode($collection_pid); + } + else { + drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error'); + return ' '; + } + } + + if ($collection_pid == NULL) { + drupal_set_message(t('You must specify a collection object pid to ingest an object.'), 'error'); + return ''; + } + $output = drupal_get_form('islandora_repository_ingest_form', $collection_pid, $collection_label, $content_model); + + $breadcrumbs = array(); + $objectHelper = new ObjectHelper(); + $objectHelper->getBreadcrumbs($collection_pid, $breadcrumbs); + drupal_set_breadcrumb(array_reverse($breadcrumbs)); + + return $output; +} + +/** + * fedora repository ingest form submit + * @global type $base_url + * @global type $user + * @param array $form + * @param array $form_state + */ +function islandora_repository_ingest_form_submit(array $form, array &$form_state) { +//only validate the form if the submit button was pressed (other buttons may be used for AHAH + if ($form_state['storage']['xml']) { + if (module_exists('islandora_content_model_forms')) { + module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); + $xml_form = new IngestObjectMetadataForm(); + $xml_form->submit($form, $form_state); + } + } + else if ($form_state['clicked_button']['#id'] == 'edit-submit') { + global $base_url; + module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); + + $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); + $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); + $err = TRUE; + $redirect = TRUE; + if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) { + $relationship = $cp->getRelationship(); + + if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { + $pid = $cp->getNextPid($contentModelDsid); + global $user; + $form_state['values']['user_id'] = $user->name; + $form_state['values']['pid'] = $pid; + $form_state['values']['content_model_pid'] = $contentModelPid; + $form_state['values']['relationship'] = $relationship; + + $err = (!$cm->execFormHandler($form_state['values'], $form_state)); + + $_SESSION['fedora_ingest_files'] = ''; //empty this variable + + $attr = $cm->getIngestFormAttributes(); + $redirect = $attr['redirect']; + + if ($redirect) { + $form_state['storage'] = NULL; + } + } + } + + if ($redirect) { + $form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}"; + } + } +} + +/** + * fedora repository ingest form validate + * @param type $form + * @param type $form_state + * @return type + */ +function islandora_repository_ingest_form_validate($form, &$form_state) { +//only validate the form if the submit button was pressed (other buttons may be used for AHAH + if ($form_state['clicked_button']['#id'] == 'edit-submit') { + switch ($form_state['storage']['step']) { + case 1: + $form_state['storage']['step']++; + $form_state['rebuild'] = TRUE; + break; + + case 2: +// XML based form. + if ($form_state['storage']['xml']) { + module_load_include('inc', 'xml_form_api', 'XMLForm'); + $xml_form = new XMLForm($form_state); + $xml_form->validate($form, $form_state); + } +// Get the uploaded file. + $validators = array(); + + if (!empty($_FILES['files']['name']['ingest-file-location'])) { + $fileObject = file_save_upload('ingest-file-location', $validators); + + file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME'); + $form_state['values']['ingest-file-location'] = $fileObject->filepath; + } + + if (isset($form_state['values']['ingest-file-location']) && file_exists($form_state['values']['ingest-file-location'])) { + module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); + + $file = $form_state['values']['ingest-file-location']; + + $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); + $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); + + if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { + $allowedMimeTypes = $cm->getMimetypes(); + + $mimetype = new MimeClass(); + $dformat = $mimetype->getType($file); + + if (!empty($file)) { + if (!in_array($dformat, $allowedMimeTypes)) { + form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' . + implode(' ', $allowedMimeTypes))); + file_delete($file); + return; + } + elseif (!$cm->execIngestRules($file, $dformat)) { + drupal_set_message(t('Error following Content Model Rules'), 'error'); + foreach (ContentModel::$errors as $err) { + drupal_set_message($err, 'error'); + } + } + } + } + } + $form_state['rebuild'] = FALSE; + break; + } + } +} + +/** + * fedora repository ingest form + * @param type $form_state + * @param type $collection_pid + * @param type $collection_label + * @param type $content_model + * @return type + */ +function islandora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) { + module_load_include('inc', 'islandora_repository', 'formClass'); +// For the sake of easily maintaining the module in different core versions create our own form_values variable. + if (empty($form_state['storage']['step'])) { + $form_state['storage']['step'] = 1; + } + $ingestForm = new formClass(); + $form_state['storage']['content_model'] = $content_model; + $form_state['storage']['collection_pid'] = $collection_pid; + return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state); +} + +/** + * fedora repository purge object form + * @global type $base_url + * @param type $form_state + * @param type $pid + * @param type $referrer + * @return type + */ +function islandora_repository_purge_object_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', 'islandora_repository') . '/images/purge_big.png', + '#value' => t('Purge'), + '#suffix' => 'Purge this object', + ); + if (!empty($collectionPid)) { + $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' + } + return $form; +} + +/** + * add stream + * @param type $collection_pid + * @param type $collectionName + * @return type + */ +function add_stream($collection_pid=NULL, $collectionName=NULL) { + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + if (!valid_pid($collection_pid)) { + drupal_set_message(t("This PID is not valid!"), 'error'); + return ' '; + } + if (!user_access('ingest new fedora objects')) { + drupal_set_message(t('You do not have permission to ingest.'), 'error'); + return ''; + } + if ($collection_pid == NULL) { + drupal_set_message(t('You must specify an collection object pid to ingest an object.'), 'error'); + return ''; + } + $output .= drupal_get_form('islandora_repository_add_stream_form', $pid); + + return $output; +} + +/** + * add stream form submit + * @global type $base_url + * @param type $form + * @param type $form_state + * @return type + */ +function add_stream_form_submit($form, &$form_state) { + global $base_url; + if (!empty($form_state['submit']) && $form_state['submit'] == 'OK') { + $form_state['rebuild'] = TRUE; + return; + } + module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + $pathToModule = drupal_get_path('module', 'islandora_repository'); + + $file = $form_state['values']['add-stream-file-location']; + + $pid = $form_state['values']['pid']; + $dsid = $form_state['values']['stream_id']; + $dsLabel = $form_state['values']['stream_label'] . substr($file, strrpos($file, '.')); // Add the file extention to the end of the label.; + $file_basename = basename($file); + $file_directory = dirname($file); + $streamUrl = $base_url . '/' . $file_directory . '/' . drupal_urlencode($file_basename); + + /* ----------------------------------------------------------------- + * need a better way to get mimetypes + */ + $mimetype = new MimeClass(); + $dformat = $mimetype->getType($file); + $controlGroup = "M"; + if ($dformat == 'text/xml') { + $controlGroup = 'X'; + } + try { + $item = new Fedora_Item($pid); + $item->add_datastream_from_url($streamUrl, $dsid, $dsLabel, $dformat, $controlGroup); + + $object_helper = new ObjectHelper(); + $object_helper->get_and_do_datastream_rules($pid, $dsid, $file); + + file_delete($file); + } catch (exception $e) { + drupal_set_message(t($e->getMessage()), 'error'); + return; + } + $form_state['rebuild'] = TRUE; +} + +/** + * add stream form + * @param type $form_state + * @param type $pid + * @return type + */ +function add_stream_form(&$form_state, $pid) { + module_load_include('inc', 'islandora_repository', 'formClass'); + $addDataStreamForm = new formClass(); + return $addDataStreamForm->createAddDataStreamForm($pid, $form_state); +} + +/** + * add stream form validate + * @param type $form + * @param type $form_state + * @return type + */ +function add_stream_form_validate($form, &$form_state) { + if ($form_state['clicked_button']['#value'] == 'OK') { + $form_state['rebuild'] = TRUE; + return; + } + $dsid = $form_state['values']['stream_id']; + $dsLabel = $form_state['values']['stream_label']; + if (strlen($dsid) > 64) { + form_set_error('', t('Data stream ID cannot be more than 64 characters.')); + return FALSE; + } + if (!(preg_match("/^[a-zA-Z]/", $dsid))) { + form_set_error('', t("Data stream ID ($dsid) has to start with a letter.")); + return FALSE; + } + if (strlen($dsLabel) > 64) { + form_set_error('', t('Data stream Label cannot be more than 64 characters.')); + return FALSE; + } + if (strpos($dsLabel, '/')) { + form_set_error('', t('Data stream Label cannot contain a "/".')); + return FALSE; + } + $validators = array( + // 'file_validate_is_image' => array(), + // 'file_validate_image_resolution' => array('85x85'), + // 'file_validate_size' => array(30 * 1024), + ); + + $fileObject = file_save_upload('add-stream-file-location', $validators); + +// Move the uploaded file to Drupal's files directory. + file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME'); + $form_state['values']['add-stream-file-location'] = $fileObject->filepath; +// TODO: Add error checking here. + $form_state['rebuild'] = FALSE; +} + +/** + * fedora repository purge stream + * @global type $user + * @param type $pid + * @param type $dsId + * @param type $name + * @return type + */ +function islandora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) { + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + global $user; + if ($pid == NULL || $dsId == NULL) { + drupal_set_message(t('You must specify an object pid and DataStream ID to purge a datastream'), 'error'); + return ' '; + } + if (!islandora_repository_access(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) { + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to purge objects."), 'error'); + return ' '; + } + + $output = t('Are you sure you wish to purge this datastream %name<br />', + array( + '%name' => $name) + ); + $output .= drupal_get_form('islandora_repository_purge_stream_form', $pid, $dsId); + return $output; +} + +/** + * fedora repository purge object form submit + * @param type $form + * @param type $form_state + * @return type + */ +function islandora_repository_purge_object_form_submit($form, &$form_state) { + module_load_include('inc', 'islandora_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 { +// this is where you do your processing after they have pressed the confirm button + $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)); + 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/'; + } + } +} + +/** + * fedora repository purge stream form + * @param type $form_state + * @param type $pid + * @param type $dsId + * @return type + */ +function islandora_repository_purge_stream_form(&$form_state, $pid, $dsId) { + $form['pid'] = array( + '#type' => 'hidden', + '#value' => "$pid" + ); + $form['dsid'] = array( + '#type' => 'hidden', + '#value' => "$dsId" + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Purge') + ); + + return $form; +} + +/** + * fedora repository purge stream form submit + * @global type $base_url + * @param type $form + * @param array $form_state + */ +function islandora_repository_purge_stream_form_submit($form, &$form_state) { + global $base_url; + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); +//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + $pid = $form_state['values']['pid']; + $item = new Fedora_Item($pid); + $dsid = $form_state['values']['dsid']; + try { + $item->purge_datastream($dsid); + } catch (exception $e) { + drupal_set_message(t($e->getMessage()), 'error'); + } + $form_state['redirect'] = $base_url . "/fedora/repository/$pid"; +} + +/** + * fedora repository replace stream + * @param type $pid + * @param type $dsId + * @param type $dsLabel + * @param type $collectionName + * @return type + */ +function islandora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) { + if ($pid == NULL || $dsId == NULL) { + drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error'); + return ''; + } + $output = drupal_get_form('islandora_repository_replace_stream_form', $pid, $dsId, $dsLabel); + + return $output; +} + +/** + * fedora repository replace stream form + * @param type $form_state + * @param type $pid + * @param type $dsId + * @param type $dsLabel + * @return type + */ +function islandora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) { +//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'islandora_repository', ''); + module_load_include('inc', 'Fedora_Repository', 'formClass'); +//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + $replaceDataStreamForm = new formClass(); + return $replaceDataStreamForm->createReplaceDataStreamForm($pid, $dsId, $dsLabel, $form_state); +} + +/** + * fedora repository replace stream form validate + * @param type $form + * @param type $form_state + * @return type + */ +function islandora_repository_replace_stream_form_validate($form, &$form_state) { +// If a file was uploaded, process it. + if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name']['file'])) { + +// attempt to save the uploaded file + $file = file_save_upload('file', array(), file_directory_path()); + +// set error is file was not uploaded + if (!$file) { + form_set_error('file', 'Error uploading file.'); + return; + } + + $doc = new DOMDocument(); + module_load_include('inc', 'Fedora_Repository', 'MimeClass'); + $mime = new MimeClass(); + if ($mime->getType($file->filepath) == 'text/xml' && !$doc->load($file->filepath)) { + form_set_error('file', 'Invalid XML format.'); + return; + } + +// set files to form_state, to process when form is submitted + $form_state['values']['file'] = $file; + } +} + +/** + * fedora repository replace stream form submit + * @global type $base_url + * @param type $form + * @param array $form_state + */ +function islandora_repository_replace_stream_form_submit($form, &$form_state) { + global $base_url; + $file = $form_state['values']['file']; + $pid = $form_state['values']['pid']; + $dsid = $form_state['values']['dsId']; + $dsLabel = $form_state['values']['dsLabel']; + // Remove the original file extension from the label and add the new one + $indexOfDot = strrpos($dsLabel, '.'); //use strrpos to get the last dot + if ($indexOfDot !== FALSE) { + $dsLabel = substr($dsLabel, 0, $indexOfDot); + $dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.; + } + module_load_include('inc', 'Fedora_Repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + + $file_basename = basename($file->filepath); + $file_directory = dirname($file->filepath); + $streamUrl = $base_url . '/' . $file_directory . '/' . urlencode($file_basename); + + /* ----------------------------------------------------------------- + * TODO: need a better way to get mimetypes + */ + $mimetype = new MimeClass(); + $dformat = $mimetype->getType($file->filepath); + + $item = new Fedora_Item($pid); + + $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); + + $form_state['redirect'] = 'fedora/repository/' . $pid; +} + +/** + * fedora repository edit qdc page + * @global type $user + * @param type $pid + * @param type $dsId + * @return type + */ +function islandora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + global $user; + if ($pid == NULL || $dsId == NULL) { + drupal_set_message(t('You must specify an object pid and a Dublin Core DataStream ID to edit metadata'), 'error'); + return ' '; + } + if (!islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); + return ' '; + } + $output = drupal_get_form('islandora_repository_edit_qdc_form', $pid, $dsId); + + return $output; +} + +/** + * fedora repository edit qdc form + * @global type $user + * @param type $form_state + * @param type $pid + * @param type $dsId + * @return type + */ +function islandora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { + module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + if ($pid == NULL) { + drupal_set_message(t('You must specify an object pid!'), 'error'); + } + global $user; + if (!islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); + return ' '; + } + + module_load_include('inc', 'islandora_repository', 'formClass'); + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + $soapHelper = new ConnectionHelper(); + $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); +// Check if there is a custom edit metadata function defined in the content model. + + $breadcrumbs = array(); + $objectHelper = new ObjectHelper(); + $objectHelper->getBreadcrumbs($pid, $breadcrumbs); + drupal_set_breadcrumb(array_reverse($breadcrumbs)); + + + $output = ''; + if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { + $output = $cm->buildEditMetadataForm($pid, $dsId); + } + + if (empty($output)) { +// There is no custom function, so just load the standard QDC form. + $metaDataForm = new formClass(); +//currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now. + return $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state); + } + return $output; +} + +/** + * fedora repository edit qdc form validate + * @param type $form + * @param boolean $form_state + */ +function islandora_repository_edit_qdc_form_validate($form, &$form_state) { + if ($form_state['storage']['xml']) { + if ($form_state['storage']['step'] == 1) { + $form_state['storage']['step']++; + $form_state['rebuild'] = TRUE; + } + module_load_include('inc', 'xml_form_api', 'XMLForm'); + $xml_form = new XMLForm($form_state); + $xml_form->validate($form, $form_state); + } +} + +/** + * Check if there is a custom edit metadata function defined in the content model. If so, + * call it, if not do the submit action for the standard QDC metadata. Custom forms will + * need to implement their own equivalent to the FormClass->updateMetaData function + * + * @param array $form + * @param array $form_state + * @return + */ +function islandora_repository_edit_qdc_form_submit($form, &$form_state) { + if ($form_state['storage']['xml']) { + module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm'); + $xml_form = new EditObjectMetadataForm($form_state); + $xml_form->submit($form, $form_state); + } + else { + module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + global $base_url; + if (strstr($form_state['clicked_button']['#id'], 'edit-submit')) { + +//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + $soap_helper = new ConnectionHelper(); + $client = $soap_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); + +// Check the content model for a custom edit metadata form submit function. + if (isset($form_state['values']['pid'])) { + module_load_include('inc', 'islandora_repository', 'ContentModel'); + if (($cm = ContentModel::loadFromObject($form_state['values']['pid'])) !== FALSE) { + return $cm->handleEditMetadataForm($form_state['values']['form_id'], $form_state, $client); + } + } + + module_load_include('inc', 'islandora_repository', 'formClass'); + $metaDataForm = new formClass(); + $return_value = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $client); + $form_state['storage'] = NULL; + $form_state['redirect'] = $base_url . '/fedora/repository/' . $form_state['values']['pid']; + + return $return_value; + } + } +} + +/** + * drupal hook + * creates a new permission than can be assigned to roles + */ +function islandora_repository_perm() { + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + return array( + OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, + OBJECTHELPER::$EDIT_FEDORA_METADATA, + OBJECTHELPER::$PURGE_FEDORA_OBJECTSANDSTREAMS, + OBJECTHELPER::$ADD_FEDORA_STREAMS, + OBJECTHELPER::$INGEST_FEDORA_OBJECTS, + OBJECTHELPER::$EDIT_TAGS_DATASTREAM, + OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, + OBJECTHELPER::$MANAGE_COLLECTIONS, + OBJECTHELPER::$DELETE_ENTIRE_COLLECTIONS, + OBJECTHELPER::$CREATE_BATCH_PROCESS, + ); +} + +/** + * drupal hook + * determines if a user has access to what they are asking for + * + * @param type $op + * @param type $node + * @param type $account + * @return type + */ +function islandora_repository_access($op, $node, $account) { + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + $objectHelper = new ObjectHelper(); + return $objectHelper->islandora_repository_access($op, $node, $account); +} + +/** + * Grabs a stream from fedora sets the mimetype and returns it. $dsID is the + * datastream id. + * @param $pid String + * @param $dsID String + */ +function makeObject($pid, $dsID) { + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + if (!valid_pid($pid)) { + drupal_set_message(t("Invalid PID!"), 'error'); + return ' '; + } + + if (!valid_dsid($dsID)) { + drupal_set_message(t("Invalid dsID!"), 'error'); + return ' '; + } + + if ($pid == NULL || $dsID == NULL) { + drupal_set_message(t("No pid or dsid given to create an object with.")); + return ' '; + } + global $user; + if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + drupal_access_denied(); + return; + drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace."), 'error'); + return ' '; + } + + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + $objectHelper = new ObjectHelper(); + $objectHelper->makeObject($pid, $dsID); +} + +/** + * Sends an ITQL query to the Fedora Resource index (can only communicate with Kowari or mulgara) + * Reads the pid and datastream id as url parameters. Queries the collection object for the query + * if there is no query datastream falls back to the query shipped with the module. + * + * @global type $user + * @param type $pid + * @param type $dsId + * @param type $collection + * @param type $page_number + * @param type $limit + * @return type + */ +function islandora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $page_number = NULL, $limit = NULL) { + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + global $user; + + if (!fedora_available()) { + drupal_set_message(t('The Fedora repository server is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); + return ''; + } + + if (!risearch_available()) { + drupal_set_message(t('The Fedora resource index search is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); + return ''; + } + + if ($pid == NULL) { + $pid = variable_get('islandora_repository_pid', 'islandora:root'); + } + + $item = new fedora_item($pid); + if (!$item->exists()) { + drupal_not_found(); + exit(); + } + + if ($pid & !valid_pid($pid)) { + drupal_set_message(t("Invalid PID!"), 'error'); + return ' '; + } + + if ($dsId & !valid_dsid($dsId)) { + drupal_set_message(t("Invalid dsID!"), 'error'); + return ' '; + } + if (!islandora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (user_access('access administration pages')) { + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/islandora_repository'))), 'warning'); + } + drupal_access_denied(); + exit; + return ' '; + } + + $objectHelper = new ObjectHelper(); + if ($pid == NULL) { + $pid = variable_get('islandora_repository_pid', 'islandora:root'); + } + $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); + if (in_array(-1, $headers)) { + drupal_access_denied(); + exit; + return ' '; + } + if ($dsId != NULL && $dsId != '-') { //if we have a dsID return the stream otherwise query for a collection of objects +//probably should check pid as well here. + return makeObject($pid, $dsId); + } + + $content = '<div id="content-fedora">'; + + module_load_include('inc', 'islandora_repository', 'CollectionClass'); + $collectionClass = new CollectionClass(); + module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'plugins/FedoraObjectDetailedContent'); + $breadcrumbs = array(); + $objectHelper->getBreadcrumbs($pid, $breadcrumbs); + drupal_set_breadcrumb(array_reverse($breadcrumbs)); + + $offset = $limit * $page_number; + $content_models = $objectHelper->get_content_models_list($pid); +// Each content model may return either a tabset array or plain HTML. If it's HTML, stick it in a tab. + $cmodels_tabs = array( + '#type' => 'tabset', + ); + foreach ($content_models as $content_model) { + $content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number); + if (is_array($content_model_fieldset)) { + $cmodels_tabs = array_merge($cmodels_tabs, $content_model_fieldset); + } + else { + $cmodels_tabs[$content_model->pid] = array( + '#type' => 'tabpage', + '#title' => $content_model->name, + '#content' => $content_model_fieldset, + ); + } + } +// Add a 'manage object' tab for all objects, where detailed list of content is shown. + $obj = new FedoraObjectDetailedContent($pid); + $object_details = $obj->showFieldSets(); + if ($object_details['fedora_object_details']['#selected'] == true){ + foreach($cmodels_tabs as $cmodel_tab){ + if (is_array($cmodel_tab)){ + $cmodel_tab['#selected'] = FALSE; + } + + } + } + $cmodels_tabs = array_merge($cmodels_tabs, $object_details); + + + return tabs_render($cmodels_tabs); +} + +/** + * fedora repository urlencode string + * @param type $str + * @return type + */ +function islandora_repository_urlencode_string($str) { + return htmlentities($str); +} + +/** + * Uses makeobject to get a stream. Sets the Content Disposition in the header so it suggests a filename + * and sends it as an attachment. This should prompt for a download of the object. + * + * @global type $user + * @param type $pid + * @param type $dsId + * @param type $label + * @param type $version + * @return type + */ +function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) { + global $user; + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + + if ($pid == NULL || $dsId == NULL) { + drupal_set_message(t("no pid or dsid given to create an object with!")); + return ' '; + } + + $objectHelper = new ObjectHelper(); + $objectHelper->makeObject($pid, $dsId, 1, $label, FALSE, $version); +} + +/** + * repository page + * @param type $pid + * @param type $dsId + * @param type $collection + * @param type $pageNumber + * @return type + */ +function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL) { +//do security check at islandora_repository_get_items function as it has to be called there in case +//someone trys to come in a back door. + return islandora_repository_get_items($pid, $dsId, $collection, $pageNumber); +} + +/** + * repository service + * @global type $user + * @param type $pid + * @param type $servicePid + * @param type $serviceMethod + * @return type + */ +function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) { + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + global $user; + + if (!islandora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { +//drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error'); + drupal_access_denied(); + if (user_access('access administration pages')) { + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/islandora_repository'))), 'error'); + } + return ' '; + } + if ($pid == NULL) { + $pid = variable_get('islandora_repository_pid', 'islandora:root'); + } + $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); + if (in_array(-1, $headers)) { + drupal_access_denied(); + exit; + return ' '; + } + + + $item = new Fedora_Item($pid); + if ($item !== FALSE) { + echo $item->get_dissemination($servicePid, $serviceMethod); + } + + exit(); +} + +//Search Stuff ******************************************************************** + +/** + * Implementation of hook_search(). + * sends a search query to fedora fgsearch which is backed by Lucene + * In our implementation of Fedora we have api-a and api-m locked down + * to authorized users but at the object level. We can query Lucene and the + * RI index to get a list of results without authorization but to view any + * datastreams users must be authorized. + * + * @param type $op + * @param type $keys + * @return array + */ +function islandora_repository_search($op = 'search', $keys = NULL) { + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + + switch ($op) { + case 'name': + if (user_access('view fedora collection')) { + return t('Digital Repository', array('-9')); + } + case 'search': + if (user_access('view fedora collection')) { +//demo search string ?operation=gfindObjects&indexName=DemoOnLucene&query=fgs.DS.first.text%3Achristmas&hitPageStart=11&hitPageSize=10 + $resultData = NULL; + $numberOfHitsPerPage = NULL; + $index = strpos($keys, '.'); + $test = substr($keys, 0, $index + 1); + $type = NULL; + if ($index > 0) { + $index = strpos($keys, ':'); + $type = substr($keys, 0, $index); + $keys = substr($keys, $index + 1); + } + + $index = strpos($keys, ':'); + $startPage = substr($keys, 0, $index); + if ($index > 1) { + $keys = substr($keys, $index + 1); + } + + if (!$startPage) { + $startPage = 1; + } + + $xmlDoc = NULL; + + $path = drupal_get_path('module', 'islandora_repository'); + $xmlDoc = new DomDocument(); + $xmlDoc->load($path . '/searchTerms.xml'); + $nodeList = $xmlDoc->getElementsByTagName('default'); + if (!$type) { +//$type = 'dc.description'; + $type = $nodeList->item(0)->nodeValue; + } + $nodeList = $xmlDoc->getElementsByTagName('number_of_results'); + $numberOfHitsPerPage = $nodeList->item(0)->nodeValue; + + $indexName = variable_get('fedora_index_name', 'DemoOnLucene'); + $keys = htmlentities(urlencode($keys)); + $searchQuery = NULL; + if (isset($type) && strcmp($type, ':')) { + $searchQuery = $type . ':' . $keys; + } + else { + $searchQuery = $keys; + } +//$searchQuery.=" AND (PID:vre OR PID:vre:ref OR PID:demo OR PID:changeme)"; + + $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest'); + $searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=copyXml&query=' . $searchQuery; + $searchString .= '&hitPageSize=' . $numberOfHitsPerPage . '&hitPageStart=' . $startPage; +//$searchString = htmlentities(urlencode($searchString)); + $searchUrl .= $searchString; + $objectHelper = new ObjectHelper(); + $resultData = do_curl($searchUrl); + + $results[] = array( + array( + 'data' => $resultData, + 'colspan' => 2 + ) + ); + return $results; + } + } // switch ($op) +} + +/** + * Implementation of hook_search_page(). + * Display the search results + * + * @param type $resultData + * @return array + */ +function islandora_repository_search_page($resultData) { + $path = drupal_get_path('module', 'islandora_repository'); + $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); + $proc = NULL; + if (!$resultData[0][0]['data']) { + return ''; //no results + } + $text = utf8_encode($resultData[0][0]['data']); + + try { + $proc = new XsltProcessor(); + } catch (Exception $e) { + $out[] = array( + array( + 'data' => $e->getMessage(), + 'colspan' => 2 + ) + ); + return $out; + } + +//inject into xsl stylesheet + $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on + $proc->setParameter('', 'searchUrl', url('search') . '/islandora_repository'); //needed in our xsl + $proc->setParameter('', 'objectsPage', base_path()); + $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); + $proc->registerPHPFunctions(); + $xsl = new DomDocument(); + if ($isRestricted) { + $xsl->load($path . '/xsl/results.xsl'); + } + else { + $xsl->load($path . '/xsl/unfilteredresults.xsl'); + } + + $input = new DomDocument(); + $didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data'])); + + if (!$didLoadOk) { + $results[] = array( + array( + 'data' => 'Error parsing results', + 'colspan' => 2 + ) + ); + } + else { + $xsl = $proc->importStylesheet($xsl); + $newdom = $proc->transformToDoc($input); + + $results[] = array( + array( + 'data' => $newdom->saveHTML(), + 'colspan' => 2 + ) + ); + } + + $header = array( + array( + 'data' => t('Collection results'), + NULL, + ), + (NULL) + ); + + $output .= theme('table', $header, $results); + return $output; +} + +/** + * Implementation of hook_form_alter(). + * allows the advanced search form in drupal + * + * @param type $form + * @param type $form_state + * @param type $form_id + */ +function islandora_repository_form_alter(&$form, &$form_state, $form_id) { +// Advanced node search form + module_load_include('inc', 'islandora_repository', 'SearchClass'); + $path = drupal_get_path('module', 'islandora_repository'); + if ($form_id == 'search_form' && arg(1) == 'islandora_repository' && user_access('use advanced search')) { + $default_value = $form['basic']['inline']['keys']['#default_value']; + $index = strpos($default_value, '.'); + $test = substr($default_value, 0, $index + 1); + $type = NULL; + if ($index > 0) { + $index = strpos($default_value, ':'); + $type = substr($default_value, 0, $index); + $default_value = substr($default_value, $index + 1); + } + $form['basic']['inline']['keys']['#default_value'] = $default_value; +// Keyword boxes: + $form['advanced'] = array( + '#type' => 'fieldset', + '#title' => t('Advanced search'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#attributes' => array( + 'class' => 'search-advanced' + ), + ); + $form['advanced']['keywords'] = array( + '#prefix' => '<div class="criterion">', + '#suffix' => '</div>', + ); + $xmlDoc = new DomDocument(); + $xmlDoc->load($path . '/searchTerms.xml'); + $nodeList = $xmlDoc->getElementsByTagName('term'); + $searchClass = new SearchClass(); + $types = $searchClass->get_search_terms_array(); + + $form['advanced']['type'] = array( + '#type' => 'select', + '#title' => t('Choose a field to search'), + '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $types, + '#default_value' => $type, + ); + $form['advanced']['submit'] = array( + '#type' => 'submit', + '#value' => t('Advanced search'), + '#prefix' => '<div class="action clear-block">', '#suffix' => '</div>', + ); + $form['#validate'][] = 'islandora_repository_search_validate'; + } +} + +/** + * Implementation of hook_search_validate() + * + * @param type $form + * @param type $form_state + */ +function islandora_repository_search_validate($form, &$form_state) { +// Initialise using any existing basic search keywords. + $keys = $form_state['values']['processed_keys']; + + if (isset($form_state['values']['type'])) { + $type = $form_state['values']['type']; + if ($type) { + $keys = $type . ':' . $keys; + } + } + + if (!empty($keys)) { + form_set_value($form['basic']['inline']['processed_keys'], trim($keys), $form_state); //set the form string + } +} + +/** + * fedora repository theme + * @return type + */ +function islandora_repository_theme() { + return array( + 'islandora_repository_mnpl_advanced_search_form' => array( + 'arguments' => array( + 'form' => NULL, + ), + ), + 'islandora_repository_time' => array( + 'arguments' => array( + 'element' => NULL + ), + 'islandora_repository_solution_packs_list' => array( + 'arguments' => array( + 'solution_packs' => NULL, + ), + ), + ), + ); +} + +/** + * Get a list of terms from a lucene index + * + * @param type $field + * @param type $startTerm + * @param type $displayName + * @return type + */ +function islandora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) { + module_load_include('inc', 'islandora_repository', 'SearchClass'); + $searchClass = new SearchClass(); + return $searchClass->getTerms($field, $startTerm, $displayName); +} + +/** + * fedora repository mnpl advanced search form + * @return type + */ +function islandora_repository_mnpl_advanced_search_form() { + module_load_include('inc', 'islandora_repository', 'SearchClass'); + $searchClass = new SearchClass(); + return $searchClass->build_advanced_search_form(); +} + +/** + * theme fedora repository mnpl advanced search form + * @param type $form + * @return type + */ +function theme_islandora_repository_mnpl_advanced_search_form($form) { + module_load_include('inc', 'islandora_repository', 'SearchClass'); + $advanced_search_form = new SearchClass(); + return $advanced_search_form->theme_advanced_search_form($form); +} + +/** + * fedora repository mnpl advanced search + * @param type $query + * @param type $startPage + * @return type + */ +function islandora_repository_mnpl_advanced_search($query, $startPage = 1) { + module_load_include('inc', 'islandora_repository', 'SearchClass'); + $searchClass = new SearchClass(); + $retVal = $searchClass->custom_search($query, $startPage); + return $searchClass->custom_search($query, $startPage); +} + +/** + * fedora repository mnpl_advanced search form submit + * @param type $form + * @param type $form_state + */ +function islandora_repository_mnpl_advanced_search_form_submit($form, &$form_state) { + $type_id = $form_state['values']['type']; + $repeat = variable_get('islandora_repository_advanced_block_repeat', t('3')); + $searchString = $form_state['values']['type1'] . ':' . $form_state['values']['fedora_terms1']; + if ($form_state['values']['fedora_terms2'] != '') { + $searchString .=' +' . $form_state['values']['andor1'] . '+' . $form_state['values']['type2'] . ':' . $form_state['values']['fedora_terms2']; + } + if ($repeat > 2 && $repeat < 9) { + for ($i = 3; $i < $repeat + 1; $i++) { + $t = $i - 1; + if ($form_state['values']["fedora_terms$i"] != '') { + $searchString .= '+' . $form_state['values']["andor$t"] . '+' . $form_state['values']["type$i"] . ':' . $form_state['values']["fedora_terms$i"]; + } + } + } + drupal_goto("fedora/repository/mnpl_advanced_search/$searchString"); +} + +/** + * fedora repository install demo page + * @return type + */ +function islandora_repository_install_demos_page() { + $output = drupal_get_form('islandora_repository_demo_objects_form'); + return $output; +} + +/** + * fedora repository demo objects form + * @return string + */ +function islandora_repository_demo_objects_form() { + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + $form = array(); + $existing_demos = array(); + + $form['install_demos'] = array( + '#title' => t('Islandora Demo Collections'), + '#type' => 'fieldset', + '#description' => t('Install demo image and document collections and content models.'), + ); + $demo_objects = array(); +// Check if the top-level islandora collection exists. If not, display a button to ingest. + + $form['install_demos']['demo_collections'] = array( + '#type' => 'checkboxes', + '#title' => t('Collections to ingest'), + '#options' => array(), + '#description' => t('Choose which demo collections you would like ingested into the repository.'), + ); + + foreach (array( + 'islandora:collectionCModel' => 'Islandora default content models', + 'islandora:root' => 'Islandora top-level collection', + 'islandora:demos' => 'Islandora demos collection', + 'islandora:largeimages' => 'Sample large image content model (requires <a href="http://sourceforge.net/projects/djatoka/">Djatoka</a> and <a href="http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=26&Itemid=22">Kakadu</a>.)', + ) + as $available_demo => $available_demo_desc) { + try { + $demo_objects[$available_demo] = new Fedora_Item($available_demo); + } catch (exception $e) { + + } + + if (empty($demo_objects[$available_demo]->objectProfile)) { +//The demo objects collection does not exist in the repository, display a button to ingest them. + $form['install_demos']['demo_collections']['#options'][$available_demo] = $available_demo_desc; + } + else { + array_push($existing_demos, $demo_objects[$available_demo]); + } + } + +// Check if the SmileyStuff collectoin exists, and if it has a COLLECTION_VIEW datastream. If it doesn't then we can add it. + + $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); + if (!empty($smiley_stuff->objectProfile)) { + $datastreams_list = $smiley_stuff->get_datastreams_list_as_array(); + if (empty($datastreams_list['COLLECTION_VIEW'])) { + $form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection'; + } + else { + $demo_objects['demo:SmileyStuff'] = $smiley_stuff; + } + } + else { + $form['install_demos']['smileynote'] = array( + '#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>' + ); + } + + $form['install_demos']['ingest'] = array( + '#type' => 'submit', + '#name' => 'install_demos', + '#value' => 'Install Selected Demos', + '#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE, + ); + + $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) { + + $form['existing_demos'][$demo_object->pid] = array( + '#prefix' => '<li>', + '#value' => l($demo_object->pid, $demo_object->url()), + '#suffix' => '</li>', + ); + } + } + + return $form; +} + +/** + * fedora repository demo objects form submit + * @global type $base_url + * @param type $form + * @param type $form_state + */ +function islandora_repository_demo_objects_form_submit($form, &$form_state) { + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/dublin_core'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + global $base_url; + if ($form_state['clicked_button']['#name'] == 'install_demos') { + if (!empty($form_state['values']['demo_collections']['islandora:collectionCModel'])) { + try { + $collectioncm = Fedora_Item::ingest_new_item('islandora:collectionCModel', 'A', 'Islandora Collection Content Model'); + $collectioncm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); + $collectioncm->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + } catch (exception $e) { + + } + try { + $strictpdfcm = Fedora_Item::ingest_new_item('islandora:strict_pdf', 'A', 'Strict PDF Content Model'); + $strictpdfcm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); + $strictpdfcm->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/content_models/STRICT_PDFCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + } catch (exception $e) { + + } + +// Install a collection object that points to all content model objects + try { + $cmodel_collection_xml = Fedora_Item::create_object_FOXML('islandora:ContentModelCollection'); + $cmodel_collection = Fedora_Item::ingest_from_FOXML($cmodel_collection_xml); + +//$dc = new Dublin_Core(new Fedora_Item('islandora:ContentModelCollection')); + $dc = new Dublin_Core($cmodel_collection); + $dc->set_element('dc:title', array('Installed Content Model')); + $dc->save(); + $cmodel_collection->add_datastream_from_string('select $object $title from <#ri> + where ($object <dc:title> $title + and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> + or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) + and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) + order by $title', 'QUERY', 'Content Model Collection Query', 'text/plain'); + $cmodel_collection->add_relationship('isMemberOfCollection', 'islandora:root'); + $cmodel_collection->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); + $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); + $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M'); + drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:ContentModelCollection\">islandora:ContentModelCollection</a>."), 'message'); + } catch (exception $e) { + + } + } + + if (!empty($form_state['values']['demo_collections']['islandora:root'])) { + $new_item = Fedora_Item::ingest_new_item('islandora:root', 'A', 'Islandora Top-level Collection'); + $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + try { + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:root\">islandora:root</a>."), 'message'); + } catch (exception $e) { + + } + } + + if (!empty($form_state['values']['demo_collections']['islandora:demos'])) { + $new_item = fedora_item::ingest_new_item('islandora:demos', 'A', 'Islandora Demo Collection'); + $new_item->add_relationship('isMemberOfCollection', 'islandora:root'); + $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + +// $cv = $new_item->add_datastream_from_file( drupal_get_path('module', 'islandora_repository') . '/collection_views/COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View.xml', 'text/xml', 'X'); + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + try { + $new_item = Fedora_Item::ingest_new_item('islandora:pdf_collection', 'A', 'PDF Collection'); + $new_item->add_relationship('isMemberOfCollection', 'islandora:demos'); + $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:demos\">islandora:demos</a>."), 'message'); + } catch (exception $e) { + + } + } + + if (!empty($form_state['values']['demo_collections']['demo:SmileyStuff'])) { + $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); + $new_item = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_views/SmileyStuff-COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); + $smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos'); + $tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + $cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X'); + + $cm = new Fedora_Item('demo:DualResImage'); + try { + $cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X'); + } catch (exception $e) { + + } + $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection'); + try { + $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view."), 'message'); + } catch (exception $e) { + + } + } + + if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) { + $error = ''; + foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml', + 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) { + try { + $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'islandora_repository') . '/content_models/' . $foxml_file); + } catch (exception $e) { + $error .= " - Problem ingesting $foxml_file"; + } + } + try { + $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'islandora_repository') . '/content_models/islandora_largeimages.xml'); + $tn = $item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:largeimages\">islandora:largeimages</a>."), 'message'); + } catch (exception $e) { + $error .= " - Problem ingesting islandora:largeimages collection"; + } + } + + if (!empty($error)) { + drupal_set_message(t('Some problems occurred: ' . $error)); + } + } +} + +/** + * fedora repository required fedora objects + * @return type + */ +function islandora_repository_required_fedora_objects() { +// array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required) + $module_path = drupal_get_path('module', 'islandora_repository'); + return array( + 'islandora_repository' => array( + 'module' => 'islandora_repository', + 'title' => 'Islandora Core', + 'objects' => array( + array( + 'pid' => 'islandora:collectionCModel', + 'label' => 'Islandora Collection Content Model', + 'dsid' => 'ISLANDORACM', + 'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml", + 'dsversion' => 2, + 'cmodel' => 'fedora-system:ContentModel-3.0', + ), + + array( + 'pid' => 'islandora:root', + 'label' => 'Islandora Top-level Collection', + 'cmodel' => 'islandora:collectionCModel', + 'datastreams' => array( + array( + 'dsid' => 'COLLECTION_POLICY', + 'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", + ), + array( + 'dsid' => 'TN', + 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", + 'mimetype' => 'image/png', + ), + ), + ), + ), + ), + ); +} + +/** + * Functions to create a time selector form element type. + */ +function islandora_repository_elements() { + $type['islandora_repository_time'] = array( + "#input" => TRUE, + "#process" => array("islandora_repository_expand_time"), + ); + + return $type; +} + +/** + * fedora repository expand time + * @param type $element + * @return string + */ +function islandora_repository_expand_time($element) { +// Default to current time, check default_value but set value so that if +// default value is present it will override value + if (empty($element['#default_value'])) { + $element['#value'] = array( + 'hour' => intval(format_date(time(), 'custom', 'h')), + 'minute' => intval(format_date(time(), 'custom', 'i')), + ); + } + + $element['#tree'] = TRUE; + + foreach ($element['#value'] as $type => $value) { + switch ($type) { + case 'hour': + $options = drupal_map_assoc(range(1, 24)); + break; + case 'minute': + $options = range(0, 59); + break; + } + + if ($type != 'meridiem') { + foreach ($options as $option) { + strlen($option) <= 1 ? $options[$option] = 0 . $option : ''; + } + } + + $element[$type] = array( + '#type' => 'select', + '#default_value' => $element['#value'][$type], + '#options' => $options, + ); + } + + return $element; +} + +/** + * fedora repository time + * @param type $element + * @return type + */ +function islandora_repository_time($element) { + $output = '<div class="container-inline">' . $element['#children'] . '</div>'; + return theme('form_element', $element, $output); +} + +/** + * theme fedora repository time + * @param type $element + * @return type + */ +function theme_islandora_repository_time($element) { + $output = '<div class="container-inline">' . $element['#children'] . '</div>'; + return theme('form_element', $element, $output); +} + +/* Export (basket) functionality */ + +/** + * fedora repository remove item from basket + * @param type $pid + */ +function islandora_repository_remove_item_from_basket($pid) { + + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; + + $objectHelper = new ObjectHelper(); +// getting child PIDs if any + $cpids = $objectHelper->get_child_pids(array($pid)); + + if (array_key_exists($pid, $pids)) { +// remove item from basket + unset($_SESSION['basket']['processed'][$pid]); + } + if (!empty($cpids)) { // there are children + foreach ($cpids as $child_pid => $value) { +// remove child item from basket recursively + islandora_repository_remove_item_from_basket($child_pid); + } + } +} + +/** + * fedora repository basket + * @return type + */ +function islandora_repository_basket() { + $pids = _islandora_repository_get_basket_pids(); + $output = drupal_get_form('islandora_repository_basket_form', $pids); + + return $output; +} + +function islandora_repository_basket_form($form_state, $pids) { + $form = array(); + + if (!empty($pids)) { + $form['pid'] = array(); + $form['title'] = array(); + $form['desc'] = array(); + } + else { + return; + } + + ksort($pids); + foreach ($pids as $pid => $arr) { + $cbs[$pid] = ''; + + $form['pid'][$pid] = array('#value' => l($pid, "fedora/repository/$pid")); + $form['title'][$pid] = array('#value' => $arr['title']); + $form['desc'][$pid] = array('#value' => $arr['desc']); + } + + $form['remove'] = array( + '#type' => 'checkboxes', + '#options' => $cbs, + ); + + $form['remove_submit'] = array( + '#type' => 'submit', + '#value' => t('Remove selected'), + ); + + $form['remove_all'] = array( + '#type' => 'submit', + '#value' => t('Empty basket'), + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Export selected'), + ); + + $form['submit_all'] = array( + '#type' => 'submit', + '#value' => t('Export all'), + ); + + return $form; +} + +/** + * theme fedora repository basket form + * @param type $form + * @return string + */ +function theme_islandora_repository_basket_form($form) { + $header = array( + theme('table_select_header_cell'), + t('PID'), + t('Title'), + t('Description'), + ); + + if (isset($form['pid']) && is_array($form['pid'])) { + foreach (element_children($form['pid']) as $key) { + $rows[] = array( + drupal_render($form['remove'][$key]), + drupal_render($form['pid'][$key]), + drupal_render($form['title'][$key]), + drupal_render($form['desc'][$key]), + ); + } + } + else { + $rows[] = array(array('data' => t('Your basket is empty.'), 'colspan' => '4')); + } + + $output = theme('table', $header, $rows); + + $frm = drupal_render($form); + $output = $frm . $output . $frm; + + return $output; +} + +/** + * fedora repository basket form validate + * @param type $form + * @param type $form_state + */ +function islandora_repository_basket_form_validate($form, &$form_state) { + +} + +/** + * fedora repository basket form submit + * @global type $user + * @param type $form + * @param type $form_state + * @return type + */ +function islandora_repository_basket_form_submit($form, &$form_state) { + if ($form_state['values']['op'] == $form_state['values']['remove_submit']) { + $pids = $form_state['clicked_button']['#post']['remove']; + + if (isset($pids)) { + foreach ($pids as $pid) { + islandora_repository_remove_from_basket($pid); + } + drupal_set_message(t("Selected objects removed")); + return; + } + } + + if ($form_state['values']['op'] == $form_state['values']['remove_all']) { + _islandora_repository_empty_basket(); + drupal_set_message(t("Basket emptied")); + return; + } + + if ($form_state['values']['op'] == $form_state['values']['submit_all']) { + $msg = t("All objects exported to staging area"); + $pids = _islandora_repository_get_basket_pids(); + } + elseif ($form_state['values']['op'] == $form_state['values']['submit']) { + $msg = t("Selected objects exported to staging area"); + $pids = array_filter($form_state['values']['remove']); + } + + if (!empty($pids)) { + global $user; + $log = array(); + $success = TRUE; + $export_dir = variable_get('export_area', file_directory_path() . '/fedora_export_area') . '/' . $user->name . '/' . date("Ymd-His"); + $foxml_dir = $export_dir . '/foxml'; + + if (!file_exists($foxml_dir) && !@mkdir($foxml_dir, 0775, TRUE)) { + drupal_set_message(t("Failed to create foxml dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $foxml_dir)), 'error'); + return FALSE; + } + + module_load_include('inc', 'islandora_repository', 'api/fedora_export'); + foreach ($pids as $pid => $arr) { + + $objects_dir = $export_dir . '/objects/' . $pid; + if (!file_exists($objects_dir) && !@mkdir($objects_dir, 0775, TRUE)) { + drupal_set_message(t("Failed to create objects dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $objects_dir)), 'error'); + return FALSE; + } + + if (!export_to_export_area($pid, $foxml_dir, $objects_dir, $log)) { + $success = FALSE; + } + } + $msg = $success ? $msg : t("Failed to export objects to staging area"); + $msg .= ":<br/>" . implode("<br/>", $log); + + drupal_set_message($msg, $success ? 'info' : 'error'); +//_islandora_repository_empty_basket(); + } + else { + drupal_set_message(t("No objects selected or basket empty"), 'error'); + } + + return; +} + +/** + * Get all pids saved to the basket. + * + * @return type + */ +function _islandora_repository_get_basket_pids() { + +// Set empty defaults if basket elements are missing + $_SESSION['basket'] = isset($_SESSION['basket']) ? $_SESSION['basket'] : array('processed' => array(), 'unprocessed' => array()); + $_SESSION['basket']['processed'] = isset($_SESSION['basket']['processed']) ? $_SESSION['basket']['processed'] : array(); + $_SESSION['basket']['unprocessed'] = isset($_SESSION['basket']['unprocessed']) ? $_SESSION['basket']['unprocessed'] : array(); + + $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; + + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + $ob = new ObjectHelper(); + foreach ($_SESSION['basket']['unprocessed'] as $pid) { +// Check if the pid already exists in the tree + if (array_key_exists($pid, $pids)) { + continue; + } + + $pids += $ob->get_all_related_pids($pid); +// $pids += array($pid); + } + + $_SESSION['basket']['processed'] = $pids; + $_SESSION['basket']['unprocessed'] = array(); + + return $pids; +} + +/** + * fedora repository empty basket + */ +function _islandora_repository_empty_basket() { + unset($_SESSION['basket']); +} + +/** + * fedora repository add to basket + * @param type $pid + * @param type $warn + * @param type $searchResultsFlag + */ +function islandora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) { + if ($warn && _is_added_to_basket($pid)) { + drupal_set_message(t("Object already in basket")); + } + + if (!isset($_SESSION['basket'])) { + $_SESSION['basket'] = array(); + $_SESSION['basket']['unprocessed'] = array($pid => $pid); + } + else { + $_SESSION['basket']['unprocessed'][$pid] = $pid; + } + + if (!$searchResultsFlag) { + drupal_goto('fedora/basket'); + } +} + +/** + * fedora repository remove from basket + * @param type $pid + * @return type + */ +function islandora_repository_remove_from_basket($pid) { + if (isset($_SESSION['basket']['unprocessed'][$pid])) { + unset($_SESSION['basket']['unprocessed'][$pid]); + } + + if (isset($_SESSION['basket']['processed'][$pid])) { + unset($_SESSION['basket']['processed'][$pid]); + } + return; +} + +/** + * theme add to basket link + * @param type $pid + * @param type $type + * @return type + */ +function theme_add_to_basket_link($pid, $type = 'object') { + $object = t($type); + $path = drupal_urlencode($pid); + + $save = "export_big.png"; + $saved = "exported_big.png"; +// $path = drupal_get_path('module', 'Fedora_Repository').'/images/'.$save ; + /* + var_dump($path); + var_dump(theme('image',drupal_get_path('module', 'Fedora_Repository').'/images/'.$save)); + die(); + */ + if (!_is_added_to_basket($pid)) { + return l( + theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), + "fedora/repository/addToBasket/" . $path, + array('html' => TRUE) + ); + } + + return theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $saved, t("In basket"), t("This @object is already in your basket", array('@object' => $object))); +} + +/** + * is added to basket + * @param type $pid + * @param type $account + * @return type + */ +function _is_added_to_basket($pid, $account = NULL) { + return isset($_SESSION['basket']['unprocessed'][$pid]) || isset($_SESSION['basket']['processed'][$pid]); +// return db_result(db_query("SELECT uid FROM {repository_basket} WHERE uid = %d AND pid = '%s'", $account->uid, $pid)); +} + +/** + * fedora repository display schema + * @param type $file + * @return type + */ +function islandora_repository_display_schema($file) { + $path = drupal_get_path('module', 'islandora_repository'); + if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) { + drupal_goto($path . '/' . $file); + } + else { + drupal_goto(); + } + return; +} + +/** + * fedora repository batch reingest object + * @param type $object + * @param type $context + * @return type + */ +function islandora_repository_batch_reingest_object($object, &$context) { + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + if (!empty($object) && is_array($object)) { + $pid = $object['pid']; + if (!valid_pid($pid)) { + return NULL; + } +// Does the object exist? If so, purge it. + $item = new Fedora_Item($pid); + if ($item->exists()) { + $item->purge(t('Remove during re-install batch job')); + } + +// Ingest the object from the source file. + if (!empty($object['foxml_file'])) { + $foxml_file = $object['foxml_file']; + $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file); + if ($new_item->exists()) { +// Batch operation was successful. + $context['message'][] = "$new_item->pid installed."; + } + } + if (!empty($object['dsid']) && !empty($object['datastream_file'])) { + $datastreams = array( + array( + 'dsid' => $object['dsid'], + 'datastream_file' => $object['datastream_file'], + ) + ); + } + elseif (!empty($object['datastreams'])) { + $datastreams = $object['datastreams']; + } + + if (!empty($datastreams) && is_array($datastreams)) { + $label = !empty($object['label']) ? $object['label'] : ''; + if (empty($object['foxml_file']) && !isset($new_item)) { + $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); + } + if (!empty($object['cmodel'])) { + $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); + } + if (!empty($object['parent'])) { + $new_item->add_relationship('isMemberOfCollection', $object['parent']); + } + foreach ($datastreams as $ds) { + if ($ds['dsid'] == 'DC') { + $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml'); + } + else { + $new_item->add_datastream_from_file($ds['datastream_file'], $ds['dsid'], !empty($ds['label']) ? $ds['label'] : '', !empty($ds['mimetype']) ? $ds['mimetype'] : 'text/xml'); + } + } + } + } +} + +/** + * Content model, collection view and collection policy datastreams may now optionally define a version + * number in their top-level XML element as an attribute, as in: + * <content_model name="Collection" version="2" ... + * + * @param Fedora_Item $item + * @param string $dsid + * @param string $datastream_file + * @return int, or NULL if no version attribute was found. + */ +function islandora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { + $return = NULL; + if (isset($item)) { + $doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); + } + elseif (isset($datastream_file)) { + $doc = simplexml_load_file($datastream_file); + } + + if (!empty($doc)) { + $attrs = $doc->attributes(); + foreach ($attrs as $name => $value) { + if ($name == 'version') { + $return = (int) $value; + break; + } + } + } + return $return; +} + +/** + * theme fedora repository solution pack list + * @param type $solution_packs + * @return string + */ +function theme_islandora_repository_solution_packs_list($solution_packs) { + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + $output = ''; + $header = array(); + $rows = array(); + + + + + drupal_add_css(drupal_get_path('module', 'update') . '/update.css'); + return $output; +} + +/** + * Implementation of hook_forms() + * @param string $form_id + * @return array + */ +function islandora_repository_forms($form_id) { + $forms = array(); + if (strpos($form_id, 'islandora_repository_solution_pack_form_') === 0) { + $forms[$form_id] = array( + 'callback' => 'islandora_repository_solution_pack_form', + ); + } + return $forms; +} diff --git a/islandoracm.xsd b/islandoracm.xsd index bce83136..21ab6661 100644 --- a/islandoracm.xsd +++ b/islandoracm.xsd @@ -48,14 +48,14 @@ </xsd:complexType> <xsd:complexType name="form_builder_methodType"> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="handler" type="xsd:normalizedString" use="required"/> </xsd:complexType> <xsd:complexType name="edit_metadata_methodType"> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="handler" type="xsd:normalizedString" use="required"/> @@ -118,7 +118,7 @@ </xsd:all> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="dsid" type="xsd:normalizedString" use="required"/> @@ -149,7 +149,7 @@ <xsd:element name="parameters" type="parametersType" minOccurs="0"/> </xsd:all> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="dsid" type="xsd:normalizedString" use="required"/> @@ -171,7 +171,7 @@ <xsd:complexContent> <xsd:restriction base="xsd:anyType"> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="default" type="xsd:boolean" default="false"/> diff --git a/plugins/CollectionFormBuilder.inc b/plugins/CollectionFormBuilder.inc index a385aa26..6d901b21 100644 --- a/plugins/CollectionFormBuilder.inc +++ b/plugins/CollectionFormBuilder.inc @@ -7,7 +7,7 @@ * Collection Form Builder */ -module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml @@ -32,7 +32,7 @@ class CollectionFormBuilder extends FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); diff --git a/plugins/DarwinCore.inc b/plugins/DarwinCore.inc index 5ab525b6..814e9dfb 100644 --- a/plugins/DarwinCore.inc +++ b/plugins/DarwinCore.inc @@ -21,7 +21,7 @@ class DarwinCore { * @param type $item */ function __construct($item = NULL) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); if (!empty($item)) { $this->owner = $item; if (array_key_exists('DARWIN_CORE', $item->get_datastreams_list_as_array())) { @@ -200,7 +200,7 @@ class DarwinCore { * @param type $form_values */ public function handleForm($form_values) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); global $user; //$new_item = Fedora_Item::ingest_new_item($form_values['pid'], 'A', $form_values['dwc:institutionCode'].':'.$form_values['dwc:collectionCode'].':'.$form_values['dwc:catalogNumber'], $user->name); //$new_item->add_datastream_from_string($this->darwinCoreXML, 'DARWIN_CORE', 'Darwin Core Metadata', 'text/xml', 'X'); @@ -248,8 +248,8 @@ class DarwinCore { */ public function asHTML() { $path = drupal_get_path('module', 'Fedora_Repository'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'CollectionClass'); $xmlstr = $this->darwinCoreXML; html_entity_decode($xmlstr); diff --git a/plugins/DemoFormBuilder.inc b/plugins/DemoFormBuilder.inc index ccc74ba2..d2d7f738 100644 --- a/plugins/DemoFormBuilder.inc +++ b/plugins/DemoFormBuilder.inc @@ -6,7 +6,7 @@ * @file * */ -module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml @@ -19,7 +19,7 @@ class DemoFormBuilder extends FormBuilder { * Constructor */ function DemoFormBuilder() { - module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); + module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); } @@ -31,7 +31,7 @@ class DemoFormBuilder extends FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); $server = NULL; diff --git a/plugins/DocumentConverter.inc b/plugins/DocumentConverter.inc index f258441a..e64517c6 100644 --- a/plugins/DocumentConverter.inc +++ b/plugins/DocumentConverter.inc @@ -32,7 +32,7 @@ class DocumentConverter { * @return string */ function convert($parameterArray = NULL, $dsid, $file, $output_ext) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); #debug: #drupal_set_message("Sending $file to ". $this->converter_service_url ." for convertsion to $output_ext", 'status'); diff --git a/plugins/Exiftool.inc b/plugins/Exiftool.inc index c0b98981..5db3d600 100644 --- a/plugins/Exiftool.inc +++ b/plugins/Exiftool.inc @@ -22,7 +22,7 @@ class Exiftool { function __construct($pid) { //drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $this->pid = $pid; - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $this->item = new Fedora_Item($this->pid); } diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc index 855d508c..de8d10a7 100644 --- a/plugins/FedoraObjectDetailedContent.inc +++ b/plugins/FedoraObjectDetailedContent.inc @@ -19,7 +19,7 @@ class FedoraObjectDetailedContent { * @param type $pid */ function __construct($pid = '') { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); if (!empty($pid)) { $this->pid = $pid; @@ -36,9 +36,9 @@ class FedoraObjectDetailedContent { global $user; $objectHelper = new ObjectHelper(); $tabset = array(); - $show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_purge_object_form'); - $show_edit_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_edit_qdc_form'); - $purge_form = drupal_get_form('fedora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path())))); + $show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'islandora_repository_purge_object_form'); + $show_edit_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'islandora_repository_edit_qdc_form'); + $purge_form = drupal_get_form('islandora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path())))); $tabset['fedora_object_details'] = array( '#type' => 'tabpage', @@ -59,8 +59,8 @@ class FedoraObjectDetailedContent { '#content' => $dc_html . $ds_list . $purge_form, ); - if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { - $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); + if (islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { + $editform = drupal_get_form('islandora_repository_edit_qdc_form', $this->pid, 'DC'); $tabset['fedora_object_details']['tabset']['edit'] = array( '#type' => 'tabpage', '#title' => t('Edit'), diff --git a/plugins/Flv.inc b/plugins/Flv.inc index d8f2b06b..d1dc03d3 100644 --- a/plugins/Flv.inc +++ b/plugins/Flv.inc @@ -138,7 +138,7 @@ class FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); $mimetype = new MimeClass(); $server = NULL; $file = $form_values['ingest-file-location']; diff --git a/plugins/FlvFormBuilder.inc b/plugins/FlvFormBuilder.inc index c259328c..f9d13e56 100644 --- a/plugins/FlvFormBuilder.inc +++ b/plugins/FlvFormBuilder.inc @@ -6,7 +6,7 @@ * @file * FLVFormBuilder */ -module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml @@ -19,7 +19,7 @@ class FlvFormBuilder extends FormBuilder { * Constructor */ function FlvFormBuilder() { - module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); + module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); } @@ -32,7 +32,7 @@ class FlvFormBuilder extends FormBuilder { */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); $server = NULL; diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index 382733b4..695fa2c6 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -84,7 +84,7 @@ class FormBuilder { * @return type */ function createPolicy($collectionPid, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $dsid = 'CHILD_SECURITY'; @@ -135,8 +135,8 @@ class FormBuilder { * @return type */ function handleQDCForm($form_values) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = TRUE; @@ -196,7 +196,7 @@ class FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); $server = NULL; diff --git a/plugins/ImageManipulation.inc b/plugins/ImageManipulation.inc index 8f97ab94..c67e4911 100644 --- a/plugins/ImageManipulation.inc +++ b/plugins/ImageManipulation.inc @@ -16,7 +16,7 @@ class ImageManipulation { * Constructor */ function ImageManipulation() { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); } /** diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index d49869e2..26662cf2 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -6,7 +6,7 @@ * @file * ModsFormBuilder class */ -module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); /** * ModsFormBuilder class ??? @@ -25,8 +25,8 @@ class ModsFormBuilder extends FormBuilder { function __construct($pid=NULL) { parent::__construct(); if ($pid !== NULL) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $this->pid = $pid; $this->cm = ContentModel::loadFromObject($pid); @@ -241,7 +241,7 @@ class ModsFormBuilder extends FormBuilder { $form['submit'] = array( '#type' => 'submit', - '#submit' => array('fedora_repository_edit_qdc_form_submit'), + '#submit' => array('islandora_repository_edit_qdc_form_submit'), '#value' => 'Save Metadata' ); @@ -256,8 +256,8 @@ class ModsFormBuilder extends FormBuilder { * @param &$form_state */ function handleModsForm(&$form_values, &$form_state) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); $form_state['storage']['people'] = NULL; //clears out old entities for the next run of the formbuilder. @@ -329,7 +329,7 @@ class ModsFormBuilder extends FormBuilder { * @param &$rootElement */ function createCollectionPolicy($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $model = new fedora_item($form_values['content_model_pid']); $ds_list = $model->get_datastreams_list_as_array(); if (isset($ds_list['COLLECTION_POLICY_TMPL'])) { @@ -364,7 +364,7 @@ class ModsFormBuilder extends FormBuilder { * @param &$rootElement */ function createWorkflowStream($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $model = new fedora_item($form_values['content_model_pid']); $ds_list = $model->get_datastreams_list_as_array(); if (isset($ds_list['WORKFLOW_TMPL'])) { diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index 68ae5528..b4742711 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/plugins/PersonalCollectionClass.inc @@ -120,7 +120,7 @@ class PersonalCollectionClass { * @return type */ function createPolicyStream($user, $dom, $rootElement) { - module_load_include('inc', 'fedora_repository', 'SecurityClass'); + module_load_include('inc', 'islandora_repository', 'SecurityClass'); $securityClass = new SecurityClass(); $policyStreamDoc = $securityClass->createPersonalPolicy($user); diff --git a/plugins/QtFormBuilder.php b/plugins/QtFormBuilder.php index 28645d6b..954f28e4 100644 --- a/plugins/QtFormBuilder.php +++ b/plugins/QtFormBuilder.php @@ -6,7 +6,7 @@ * @file * QTFormBuilder class */ -module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); /** * Implements methods from content model ingest form xml @@ -30,7 +30,7 @@ class QtFormBuilder extends FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); $server = null; diff --git a/plugins/Refworks.inc b/plugins/Refworks.inc index 592a7e99..4f0d6fc3 100644 --- a/plugins/Refworks.inc +++ b/plugins/Refworks.inc @@ -7,7 +7,7 @@ * Refworks class */ -module_load_include('inc', 'fedora_repository', 'SecurityClass'); +module_load_include('inc', 'islandora_repository', 'SecurityClass'); /** * Refworks class ??? @@ -222,9 +222,9 @@ class Refworks { */ function handleForm(&$form_values) { $errorMessage = NULL; - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $contentModelPid = ContentModel::getPidFromIdentifier($form_values['models']); $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_values['models']); $collectionHelper = new CollectionClass(); @@ -238,7 +238,7 @@ class Refworks { $collection_item = new Fedora_Item($collection_pid); $this->collectionPolicyStream = $collection_item->get_datastream_dissemination('CHILD_SECURITY'); if (empty($this->collectionPolicyStream)) { - $this->collectionPolicyStream = file_get_contents(drupal_get_path('module', 'fedora_repository') . '/policies/noObjectEditPolicy.xml'); + $this->collectionPolicyStream = file_get_contents(drupal_get_path('module', 'islandora_repository') . '/policies/noObjectEditPolicy.xml'); } $success = 0; $errors = 0; @@ -388,7 +388,7 @@ class Refworks { */ function createFedoraDataStreams($form_values, &$dom, &$rootElement, $reference) { global $base_url; - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); $mimetype = new MimeClass(); $server = NULL; $this->createRomeoDataStream($dom, $rootElement); diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index 77eada60..efa1ab7e 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -87,7 +87,7 @@ class ShowStreamsInFieldSets { global $base_url; global $base_path; global $user; - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $tabset = array(); @@ -105,7 +105,7 @@ class ShowStreamsInFieldSets { $tn_url = $base_url . '/fedora/repository/' . $item->pid . '/TN'; } else { - $tn_url = $base_path . drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_app_download_manager.png'; + $tn_url = $base_path . drupal_get_path('module', 'islandora_repository') . '/images/Crystal_Clear_app_download_manager.png'; } $dc_html = $objectHelper->getFormattedDC($item); @@ -117,8 +117,8 @@ class ShowStreamsInFieldSets { '#content' => $dl_link . $dc_html, ); - if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { - $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); + if (islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { + $editform = drupal_get_form('islandora_repository_edit_qdc_form', $this->pid, 'DC'); $tabset['first_tab']['tabs']['edit'] = array( '#type' => 'tabpage', '#title' => t('Edit'), @@ -142,7 +142,7 @@ class ShowStreamsInFieldSets { * @return type */ function showQdc() { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $content = $objectHelper->getQDC($this->pid); $collection_fieldset = array( @@ -161,7 +161,7 @@ class ShowStreamsInFieldSets { */ function showOBJLink() { global $base_url; - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $item = new Fedora_Item($this->pid); $streams = $item->get_datastreams_list_as_array(); return "<a href='" . $base_url . "/fedora/repository/" . $this->pid . "/OBJ/" . $streams['OBJ']['label'] . "'>" . $streams['OBJ']['label'] . "</a>"; @@ -172,8 +172,8 @@ class ShowStreamsInFieldSets { * @return type */ function showRefworks() { - $path = drupal_get_path('module', 'fedora_repository'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + $path = drupal_get_path('module', 'islandora_repository'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $collectionHelper = new CollectionClass(); $xmlstr = $collectionHelper->getStream($this->pid, "refworks"); html_entity_decode($xmlstr); @@ -226,7 +226,7 @@ class ShowStreamsInFieldSets { */ function showRomeo($collapsed = FALSE) { $path = drupal_get_path('module', 'Fedora_Repository'); - module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'islandora_repository', 'CollectionClass'); $collectionHelper = new CollectionClass(); $xmlstr = $collectionHelper->getStream($this->pid, "ROMEO", 0); diff --git a/plugins/herbarium.inc b/plugins/herbarium.inc index f7a6d685..f831bc59 100644 --- a/plugins/herbarium.inc +++ b/plugins/herbarium.inc @@ -16,7 +16,7 @@ class Herbarium { function __construct($pid = '') { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); if (!empty($pid)) { $this->pid = $pid; $this->item = new Fedora_Item($pid); @@ -32,7 +32,7 @@ class Herbarium { public function buildDrupalForm($form = array(), $form_state = array()) { // We don't need to add anything beyond the standard Darwin Core form so just pass this through // If we wanted to we could add other fields. - module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); + module_load_include('inc', 'islandora_repository', 'plugins/DarwinCore'); $dwc = new DarwinCore($this->item); return $dwc->buildDrupalForm($form); @@ -73,9 +73,9 @@ class Herbarium { * Process the metadata form * Update the datastreams */ - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); - module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'plugins/DarwinCore'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); global $user; $mimetype = new MimeClass(); $dwc = new DarwinCore($this->item); @@ -97,9 +97,9 @@ class Herbarium { * Create fedora object * Add the datastreams */ - module_load_include('inc', 'fedora_repository', 'MimeClass'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); + module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'plugins/DarwinCore'); global $user; $mimetype = new MimeClass(); $dwc = new DarwinCore(); @@ -141,8 +141,8 @@ class Herbarium { * @return string */ public function showFieldSets() { - module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); - module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); + module_load_include('inc', 'islandora_repository', 'plugins/tagging_form'); + module_load_include('inc', 'islandora_repository', 'plugins/DarwinCore'); global $base_url; $tabset = array(); @@ -167,7 +167,7 @@ class Herbarium { '#title' => t('View'), // This will be the content of the tab. '#content' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/FULL_JPG/"><img src="' . $base_url . '/fedora/imageapi/' . - $this->pid . '/JPG/JPG.jpg' . '" /></a>' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>', + $this->pid . '/JPG/JPG.jpg' . '" /></a>' . '<p>' . drupal_get_form('islandora_repository_image_tagging_form', $this->pid) . '</p>', ); $dwc = new DarwinCore($this->item); @@ -184,10 +184,10 @@ class Herbarium { '#title' => t('Darwin Core'), '#content' => $dwc->asHTML(), ); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'islandora_repository', 'ObjectHelper'); $obj = new ObjectHelper(); - if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { - $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DARWIN_CORE'); + if (islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { + $editform = drupal_get_form('islandora_repository_edit_qdc_form', $this->pid, 'DARWIN_CORE'); $tabset['third_tab']['tabset']['edit'] = array( '#type' => 'tabpage', '#title' => t('Edit'), diff --git a/plugins/islandora_imageapi.info b/plugins/islandora_imageapi.info new file mode 100644 index 00000000..5519ad85 --- /dev/null +++ b/plugins/islandora_imageapi.info @@ -0,0 +1,7 @@ +name = Fedora ImageAPI +description = Adds image manipulation support through a REST interface +package = Islandora Dependencies +dependencies[] = islandora_repository +dependencies[] = imageapi +version = 11.2.beta2 +core = 6.x diff --git a/plugins/islandora_imageapi.module b/plugins/islandora_imageapi.module new file mode 100644 index 00000000..cbe6225d --- /dev/null +++ b/plugins/islandora_imageapi.module @@ -0,0 +1,116 @@ +<?php + + + +function fedora_imageapi_menu() { + $items = array(); + $items['fedora/imageapi'] = array( + 'title' => t('Image manipulation functions'), + 'page callback' => 'islandora_repository_image_manip', + 'type' => MENU_CALLBACK, + 'access arguments' => array('view fedora collection'), + ); + return $items; +} + +/** + * Call out to the Drupal ImageAPI module and return the resulting image as a stream. + * + * @param string $pid + * @param string $dsid + * @param string $op + * @param string $params + */ +function islandora_repository_image_manip($pid = '', $dsid = '', $op = '', $params = '') { + module_load_include('inc', 'Fedora_Repository', 'ObjectHelper'); + module_load_include('module', 'imageapi'); + $obj = new ObjectHelper(); + $mimetype = $obj->getMimeType($pid, $dsid); + $ext = substr(strstr($mimetype, '/'), 1); + $op = (!empty($_GET['op']) ? $_GET['op'] : ''); + $safe_pid = str_replace(':', '_', $pid); + + $cache_key = 'islandora_repository_image_manip_' . md5($safe_pid . '_' . $dsid . '_' . $ext . '_' . $op . (isset($_GET['width']) ? '_' . $_GET['width'] : '') . (isset($_GET['height']) ? '_' . $_GET['height'] : '')); + if (($file = cache_get($cache_key)) === 0) { + //added the slash as sys_get_temp_dir in linux does not seem to include the slash + $tmp_file_name = sys_get_temp_dir() . '/' . $safe_pid . '_' . $dsid . '.' . $ext; + $handle = fopen($tmp_file_name, "w"); + $numbytes = fwrite($handle, $obj->getStream($pid, $dsid)); + fclose($handle); + if ($numbytes == 0) { + return; + } + + + $image = imageapi_image_open($tmp_file_name); + + switch ($op) { + case 'scale': + if (!empty($_GET['height']) || !empty($_GET['width'])) { + imageapi_image_scale($image, $_GET['width'], $_GET['height']); + } + case 'centerscale': + if (!empty($_GET['height']) && !empty($_GET['width'])) { + imageapi_image_scale_and_crop($image, $_GET['width'], $_GET['height']); + } + } + imageapi_image_close($image); + $file = file_get_contents($tmp_file_name); + cache_set($cache_key, $file, 'cache', time() + variable_get('fedora_image_blocks_cache_time', 3600)); + file_delete($tmp_file_name); + } + else { + $file = $file->data; + } + + + header("Content-type: $mimetype"); + header('Content-Disposition: attachment; filename="' . $dsid . '.' . $ext . '"'); + echo $file; + + +// return "$numbytes bytes written to ".sys_get_temp_dir()."$pid_$dsid.$ext\n"; +} + +/** + * Implementation of hook_form_alter + * + * @param unknown_type $form + * @param unknown_type $form_state + * @param unknown_type $form_id + */ +/* + function fedora_imageapi_form_alter( &$form, $form_state, $form_id) { + + switch ( $form_id ) { + case 'islandora_repository_admin': + + $fedora_base_url = $form['fedora_base_url']['#default_value']; + + $fedora_server_url = substr($fedora_base_url,0,strpos($fedora_base_url,'/',7)); + // Add the Djatoka server location. Set it to default to the same server as fedora. + $form['djatoka_server_url'] = array ( + '#type' => 'textfield', + '#title' => '<h3>'.t('Fedora Image API Module').'</h3><br />'.t('aDORe Djatoka image server resolver URL'), + '#default_value' => variable_get('djatoka_server_url', $fedora_server_url.'/adore-djatoka/resolver' ), + '#description' => t('The location of your <a href="http://african.lanl.gov/aDORe/projects/djatoka/" title="aDORe Djatoka Home Page">aDORe Djatoka</a> image server, if you have one installed.'), + '#weight' => 1, + ); + $form['openlayers_server_url'] = array( + '#type' => 'textfield', + '#title' => t('OpenLayers servlet URL'), + '#default_value' => variable_get('openlayers_server_url', $fedora_server_url.'/islandora/OpenLayers'), + '#description' => t('URL of your installation of the <a href="http://openlayers.org/">OpenLayers</a> servlet, if you have one.'), + '#weight' => 1, + ); + $form['buttons']['#weight'] = 2; + break; + } + } + + function show_openlayers_viewer() { + $output = 'Hi.'; + + return $output; + } + */ diff --git a/plugins/map_viewer.inc b/plugins/map_viewer.inc index 3e9bcfb6..2ad56c0a 100644 --- a/plugins/map_viewer.inc +++ b/plugins/map_viewer.inc @@ -29,9 +29,9 @@ class ShowMapStreamsInFieldSets { * @return type */ function showJPG() { - module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); - module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'plugins/tagging_form'); + module_load_include('inc', 'islandora_repository', 'plugins/ShowStreamsInFieldSets'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); global $base_url; @@ -51,8 +51,8 @@ class ShowMapStreamsInFieldSets { $html = '<iframe src="' . $viewer_url . '" scrolling="no" frameborder="0" style="width: 100%; height: 800px;">Errors: unable to load viewer</iframe>'; drupal_add_css(path_to_theme() . '/header-viewer.css', 'theme'); - drupal_add_css(drupal_get_path('module', 'fedora_repository') . '/js/iiv/css/jquery-ui/smoothness/jquery-ui-1.7.2.custom.css'); - drupal_add_css(drupal_get_path('module', 'fedora_repository') . '/js/iiv/css/iiv.css'); + drupal_add_css(drupal_get_path('module', 'islandora_repository') . '/js/iiv/css/jquery-ui/smoothness/jquery-ui-1.7.2.custom.css'); + drupal_add_css(drupal_get_path('module', 'islandora_repository') . '/js/iiv/css/iiv.css'); $tabset['my_tabset']['second_tab'] = array( diff --git a/plugins/qt_viewer.inc b/plugins/qt_viewer.inc index ec321ca1..09d24cca 100644 --- a/plugins/qt_viewer.inc +++ b/plugins/qt_viewer.inc @@ -112,9 +112,9 @@ class ShowQtStreamsInFieldSets { * @return type */ function showQt() { - module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); - module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'plugins/tagging_form'); + module_load_include('inc', 'islandora_repository', 'plugins/ShowStreamsInFieldSets'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); $info = $this->technicalMetadata(array('width' => 640, 'height' => 480)); $width = $info['width']; diff --git a/plugins/slide_viewer.inc b/plugins/slide_viewer.inc index 1d23b227..ef569487 100644 --- a/plugins/slide_viewer.inc +++ b/plugins/slide_viewer.inc @@ -30,8 +30,8 @@ class ShowSlideStreamsInFieldSets { * @return type */ function showJPG() { - module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); - module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); + module_load_include('inc', 'islandora_repository', 'plugins/tagging_form'); + module_load_include('inc', 'islandora_repository', 'plugins/ShowStreamsInFieldSets'); global $base_url; global $user; @@ -58,7 +58,7 @@ class ShowSlideStreamsInFieldSets { '#title' => t('View'), // This will be the content of the tab. '#content' => '<img src="' . $base_url . - '/fedora/imageapi/' . $this->pid . '/JPG/JPG.jpg' . '" />' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>', + '/fedora/imageapi/' . $this->pid . '/JPG/JPG.jpg' . '" />' . '<p>' . drupal_get_form('islandora_repository_image_tagging_form', $this->pid) . '</p>', ); return $tabset; diff --git a/plugins/tagging_form.inc b/plugins/tagging_form.inc index 0a421105..ca32ecd5 100644 --- a/plugins/tagging_form.inc +++ b/plugins/tagging_form.inc @@ -13,9 +13,9 @@ * @return string */ function _show_subject_tags($pid) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/dublin_core'); - module_load_include('inc', 'fedora_repository', 'api/tagging'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/dublin_core'); + module_load_include('inc', 'islandora_repository', 'api/tagging'); $obj = new Fedora_Item($pid); $tags = new TagSet($obj); if (!empty($tags->tags)) { @@ -35,10 +35,10 @@ function _show_subject_tags($pid) { * @param type $pid * @return type */ -function fedora_repository_image_tagging_form($form_state, $pid) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/dublin_core'); - module_load_include('inc', 'fedora_repository', 'api/tagging'); +function islandora_repository_image_tagging_form($form_state, $pid) { + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/dublin_core'); + module_load_include('inc', 'islandora_repository', 'api/tagging'); global $base_url; if (!empty($form_state['post']['pid'])) { @@ -71,7 +71,7 @@ function fedora_repository_image_tagging_form($form_state, $pid) { // Delete button for each existing tag. $form['tags-wrapper']['tags'][$tag['name']]['delete'] = array( '#type' => 'imagebutton', - '#image' => $base_url . '/' . drupal_get_path('module', 'fedora_repository') . '/images/remove_icon.png', + '#image' => $base_url . '/' . drupal_get_path('module', 'islandora_repository') . '/images/remove_icon.png', '#default_value' => $tag['name'], '#title' => t('Delete this tag'), ); @@ -122,9 +122,9 @@ function hook_imagebutton_process($form) { * @param type $form * @param type $form_state */ -function fedora_repository_image_tagging_form_submit($form, &$form_state) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/tagging'); +function islandora_repository_image_tagging_form_submit($form, &$form_state) { + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/tagging'); global $user; $item = new Fedora_Item($form_state['values']['pid']); diff --git a/tests/README_TESTING.txt b/tests/README_TESTING.txt index bd69c57e..a88a244c 100644 --- a/tests/README_TESTING.txt +++ b/tests/README_TESTING.txt @@ -21,7 +21,7 @@ $FEDORA_HOME/server/config/fedora-users.xml: </attribute> </user> -If you look in the fedora_repository.test file we see that we are creating +If you look in the islandora_repository.test file we see that we are creating a user with a password set to 'simpletestpass'. Fedora requires the hashed version of this password to do a servlet filter-based authentication. diff --git a/tests/fedora_repository.test b/tests/fedora_repository.test index 91d91b61..2bfab51f 100644 --- a/tests/fedora_repository.test +++ b/tests/fedora_repository.test @@ -16,9 +16,9 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('tabs', 'fedora_repository'); + parent::setUp('tabs', 'islandora_repository'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'islandora_repository', 'api/fedora_item'); // Create and login user. $repository_user = $this->drupalCreateFedoraUser(array('add fedora datastreams', @@ -57,11 +57,11 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $ingest_form_step_2['dc:title'] = $this->randomName(32); $ingest_form_step_2['dc:description'] = $this->randomName(256); - $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_repository') . '/tests/test_files/lorem_ipsum.pdf'); + $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'islandora_repository') . '/tests/test_files/lorem_ipsum.pdf'); $this->drupalPost(NULL, $ingest_form_step_2, 'Ingest'); $this->assertText('mimetype (application/pdf) is not associated with this Content Model', 'PDF mime type not accepted in collection content model.', 'message'); - $this->outputScreenContents('Initial ingest form submit step 2', 'fedora_repository'); + $this->outputScreenContents('Initial ingest form submit step 2', 'islandora_repository'); // Now try ingesting a proper collection policy. $ingest_form = array(); @@ -72,9 +72,9 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $ingest_form_step_2 = array(); $ingest_form_step_2['dc:title'] = $this->randomName(32); $ingest_form_step_2['dc:description'] = $this->randomName(256); - $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml'); + $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'islandora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml'); $this->drupalPost(NULL, $ingest_form_step_2, 'Ingest'); - //$this->outputScreenContents('Initial ingest form submit step 2 - PDF collection', 'fedora_repository'); + //$this->outputScreenContents('Initial ingest form submit step 2 - PDF collection', 'islandora_repository'); $this->assertPattern('/Item .* created successfully./', "Verified item created."); $pid = $this->getIngestedPid(); @@ -88,7 +88,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $ingest_form_step_2 = array(); $ingest_form_step_2['dc:title'] = "Lorem Ipsum"; $ingest_form_step_2['dc:description'] = $this->randomName(256); - $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_repository') . '/tests/test_files/lorem_ipsum.pdf'); + $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'islandora_repository') . '/tests/test_files/lorem_ipsum.pdf'); $this->drupalPost(NULL, $ingest_form_step_2, 'Ingest'); $pid = $this->getIngestedPid(); $pid_list[] = $pid; @@ -104,7 +104,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $admin_tester = $this->drupalCreateUser(array('administer site configuration', 'view fedora collection')); $this->drupalLogin($admin_tester); - $pageContent = $this->drupalGet('admin/settings/fedora_repository'); + $pageContent = $this->drupalGet('admin/settings/islandora_repository'); $hasOption = preg_match('/Enforce namespace restrictions/', $pageContent); @@ -115,13 +115,13 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $this->pass('Removal of namespace restrictions is enabled'); $inVal['fedora_namespace_restriction_enforced'] = TRUE; $inVal['fedora_pids_allowed'] = 'simpletest:'; - $this->drupalPost('admin/settings/fedora_repository', $inVal, 'Save configuration'); + $this->drupalPost('admin/settings/islandora_repository', $inVal, 'Save configuration'); $this->assertPattern('/The configuration options have been saved./', 'The configuration options have been saved.'); $this->drupalGet('fedora/repository/islandora:largeimages/'); $this->assertPattern('/Access denied/', 'No access to Large image Collection Collection'); $inVal['fedora_namespace_restriction_enforced'] = 0; - $this->drupalPost('admin/settings/fedora_repository', $inVal, 'Save configuration'); + $this->drupalPost('admin/settings/islandora_repository', $inVal, 'Save configuration'); $this->assertPattern('/The configuration options have been saved./', 'The configuration options have been saved.'); $this->drupalLogin($this->repository_user); $this->drupalGet('fedora/repository/islandora:largeimages/'); From 0a45be6b3d78af6daeaaae342e23851f0dfbc15e Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Tue, 11 Oct 2011 10:22:44 -0300 Subject: [PATCH 06/46] Renamed the files --- digital_repository.info | 9 - digital_repository.install | 107 -- digital_repository.module | 2251 -------------------------- digital_repository.solutionpacks.inc | 175 -- plugins/fedora_imageapi.info | 7 - plugins/fedora_imageapi.module | 116 -- 6 files changed, 2665 deletions(-) delete mode 100644 digital_repository.info delete mode 100644 digital_repository.install delete mode 100644 digital_repository.module delete mode 100644 digital_repository.solutionpacks.inc delete mode 100644 plugins/fedora_imageapi.info delete mode 100644 plugins/fedora_imageapi.module diff --git a/digital_repository.info b/digital_repository.info deleted file mode 100644 index 20ff4d30..00000000 --- a/digital_repository.info +++ /dev/null @@ -1,9 +0,0 @@ -; $Id$ -name = Digital Repository -dependencies[] = imageapi -dependencies[] = tabs -dependencies[] = islandora_content_model_forms -description = Shows a list of items in a fedora collection. -package = Islandora -version = 11.2.beta1 -core = 6.x diff --git a/digital_repository.install b/digital_repository.install deleted file mode 100644 index 164ce02e..00000000 --- a/digital_repository.install +++ /dev/null @@ -1,107 +0,0 @@ -<?php - -/** - * @file fedora_repository.install - */ - -/** - * Implementation of hook_enable(). - */ -function fedora_collections_enable() { - //nothing to do as we do not currently touch the drupal database. - //other than the variables table -} - -/** - * Implementation of hook_requirements(). - * - * @return - * An array describing the status of the site regarding available updates. - * If there is no update data, only one record will be returned, indicating - * that the status of core can't be determined. If data is available, there - * will be two records: one for core, and another for all of contrib - * (assuming there are any contributed modules or themes enabled on the - * site). In addition to the fields expected by hook_requirements ('value', - * 'severity', and optionally 'description'), this array will contain a - * 'reason' attribute, which is an integer constant to indicate why the - * given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or - * UPDATE_UNKNOWN). This is used for generating the appropriate e-mail - * notification messages during update_cron(), and might be useful for other - * modules that invoke update_requirements() to find out if the site is up - * to date or not. - * - * @see _update_message_text() - * @see _update_cron_notify() - */ -function fedora_repository_requirements($phase) { - global $base_url; - - $requirements = array(); - - if ($phase == 'install') { - - // Test for SOAP - $requirements['fedora-soap']['title'] = t("PHP SOAP extension library"); - if (!class_exists('SoapClient')) { - $requirements['fedora-soap']['value'] = t("Not installed"); - $requirements['fedora-soap']['severity'] = REQUIREMENT_ERROR; - $requirements['fedora-soap']['description'] = t('Ensure that the PHP SOAP extension is installed.'); - } - else { - $requirements['fedora-soap']['value'] = t("Installed"); - $requirements['fedora-soap']['severity'] = REQUIREMENT_OK; - } - - // Test for Curl - $requirements['curl']['title'] = "PHP Curl extension library"; - if (!function_exists('curl_init')) { - $requirements['curl']['value'] = t("Not installed"); - $requirements['curl']['severity'] = REQUIREMENT_ERROR; - $requirements['curl']['description'] = t("Ensure that the PHP Curl extension is installed."); - } - else { - $requirements['curl']['value'] = t("Installed"); - $requirements['curl']['severity'] = REQUIREMENT_OK; - } - - // Test for DOM - $requirements['dom']['title'] = "PHP DOM XML extension library"; - if (!method_exists('DOMDocument', 'loadHTML')) { - $requirements['dom']['value'] = t("Not installed"); - $requirements['dom']['severity'] = REQUIREMENT_ERROR; - $requirements['dom']['description'] = t("Ensure that the PHP DOM XML extension is installed."); - } - else { - $requirements['dom']['value'] = t("Installed"); - $requirements['dom']['severity'] = REQUIREMENT_OK; - } - - // Test for XSLT - $requirements['xsl']['title'] = "PHP XSL extension library"; - if (!class_exists('XSLTProcessor')) { - $requirements['xslt']['value'] = t("Not installed"); - $requirements['xslt']['severity'] = REQUIREMENT_ERROR; - $requirements['xslt']['description'] = t("Ensure that the PHP XSL extension is installed."); - } - else { - $requirements['xslt']['value'] = t("Installed"); - $requirements['xslt']['severity'] = REQUIREMENT_OK; - } - } - elseif ($phase == 'runtime') { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - - $requirements['fedora-repository']['title'] = t("Fedora server"); - if (!fedora_available()) { - $requirements['fedora-repository']['value'] = t("Not available"); - $requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR; - $requirements['fedora-repository']['description'] = t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => $base_url . '/admin/settings/fedora_repository')); - } - else { - $requirements['fedora-repository']['value'] = t("Available"); - $requirements['fedora-repository']['severity'] = REQUIREMENT_OK; - } - } - - return $requirements; -} diff --git a/digital_repository.module b/digital_repository.module deleted file mode 100644 index ea1c15c5..00000000 --- a/digital_repository.module +++ /dev/null @@ -1,2251 +0,0 @@ -<?php - -/** - * Drupal hook for admin form - * fedora_repository_name is the name of the top level collection this module will query - * fedora_repository_pid is the name of the top level pid. - * Stores this info in the drupal variables table. - * the name and pid can also be passed as url parameters - */ -function fedora_repository_admin() { - module_load_include('inc', 'fedora_repository', 'formClass'); - $adminForm = new formClass(); - return $adminForm->createAdminForm(); -} - -/** - * drupal hook - * calls the fedora_repositorys_admin form - */ -function fedora_repository_menu() { - module_load_include('inc', 'fedora_repository', 'formClass'); - $adminMenu = new formClass(); - return $adminMenu->createMenu(); -} - -/** - * drupal hook to show help - * - * @param type $path - * @param type $arg - * @return type - */ -function fedora_repository_help($path, $arg) { - switch ($path) { - case 'admin/modules#description' : - return t('Grabs a list of items from a collection in Drupal that are presented on the home page.'); - case 'node/add#fedora_repository' : - return t('Use this page to grab a list of items from a Fedora collection.'); - } -} - -/** - * fedora repository purge object - * @param type $pid - * @param type $name - * @return type - */ -function fedora_repository_purge_object($pid = NULL, $name = NULL) { - if (!user_access('purge objects and datastreams')) { - drupal_set_message(t('You do not have access to add a datastream to this object.'), 'error'); - return ''; - } - if ($pid == NULL) { - drupal_set_message(t('You must specify an object pid to purge an object.'), 'error'); - return ''; - } - $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', - array( - '%name' => $name, - '%pid' => $pid) - ); - - $output .= drupal_get_form('fedora_repository_purge_object_form', $pid); - return $output; -} - -/** - * fedora repository collection view - * @global type $user - * @param type $pid - * @param type $collection - * @param type $pageNumber - * @return type - */ -function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pageNumber = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); - return ' '; - } - - $objectHelper = new ObjectHelper(); - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - - $content = ''; - - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - $collectionClass = new CollectionClass(); - $results = $collectionClass->getRelatedItems($pid, NULL); - $content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber); - - return $content; -} - -/** - * fedora repository ingest object - * @param type $collection_pid - * @param type $collection_label - * @param type $content_model - * @return type - */ -function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - if (!user_access('ingest new fedora objects')) { - drupal_set_message(t('You do not have permission to ingest.'), 'error'); - return ''; - } - - if (!valid_pid($collection_pid)) { - if (valid_pid(urldecode($collection_pid))) { - $collection_pid = urldecode($collection_pid); - } - else { - drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error'); - return ' '; - } - } - - if ($collection_pid == NULL) { - drupal_set_message(t('You must specify a collection object pid to ingest an object.'), 'error'); - return ''; - } - $output = drupal_get_form('fedora_repository_ingest_form', $collection_pid, $collection_label, $content_model); - - $breadcrumbs = array(); - $objectHelper = new ObjectHelper(); - $objectHelper->getBreadcrumbs($collection_pid, $breadcrumbs); - drupal_set_breadcrumb(array_reverse($breadcrumbs)); - - return $output; -} - -/** - * fedora repository ingest form submit - * @global type $base_url - * @global type $user - * @param array $form - * @param array $form_state - */ -function fedora_repository_ingest_form_submit(array $form, array &$form_state) { -//only validate the form if the submit button was pressed (other buttons may be used for AHAH - if ($form_state['storage']['xml']) { - if (module_exists('islandora_content_model_forms')) { - module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); - $xml_form = new IngestObjectMetadataForm(); - $xml_form->submit($form, $form_state); - } - } - else if ($form_state['clicked_button']['#id'] == 'edit-submit') { - global $base_url; - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); - module_load_include('inc', 'fedora_repository', 'ContentModel'); - - $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); - $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); - $err = TRUE; - $redirect = TRUE; - if (($cp = CollectionPolicy::loadFromCollection($form_state['values']['collection_pid'])) !== FALSE) { - $relationship = $cp->getRelationship(); - - if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { - $pid = $cp->getNextPid($contentModelDsid); - global $user; - $form_state['values']['user_id'] = $user->name; - $form_state['values']['pid'] = $pid; - $form_state['values']['content_model_pid'] = $contentModelPid; - $form_state['values']['relationship'] = $relationship; - - $err = (!$cm->execFormHandler($form_state['values'], $form_state)); - - $_SESSION['fedora_ingest_files'] = ''; //empty this variable - - $attr = $cm->getIngestFormAttributes(); - $redirect = $attr['redirect']; - - if ($redirect) { - $form_state['storage'] = NULL; - } - } - } - - if ($redirect) { - $form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}"; - } - } -} - -/** - * fedora repository ingest form validate - * @param type $form - * @param type $form_state - * @return type - */ -function fedora_repository_ingest_form_validate($form, &$form_state) { -//only validate the form if the submit button was pressed (other buttons may be used for AHAH - if ($form_state['clicked_button']['#id'] == 'edit-submit') { - switch ($form_state['storage']['step']) { - case 1: - $form_state['storage']['step']++; - $form_state['rebuild'] = TRUE; - break; - - case 2: -// XML based form. - if ($form_state['storage']['xml']) { - module_load_include('inc', 'xml_form_api', 'XMLForm'); - $xml_form = new XMLForm($form_state); - $xml_form->validate($form, $form_state); - } -// Get the uploaded file. - $validators = array(); - - if (!empty($_FILES['files']['name']['ingest-file-location'])) { - $fileObject = file_save_upload('ingest-file-location', $validators); - - file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME'); - $form_state['values']['ingest-file-location'] = $fileObject->filepath; - } - - if (isset($form_state['values']['ingest-file-location']) && file_exists($form_state['values']['ingest-file-location'])) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'MimeClass'); - - $file = $form_state['values']['ingest-file-location']; - - $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); - $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); - - if (($cm = ContentModel::loadFromModel($contentModelPid, $contentModelDsid)) !== FALSE) { - $allowedMimeTypes = $cm->getMimetypes(); - - $mimetype = new MimeClass(); - $dformat = $mimetype->getType($file); - - if (!empty($file)) { - if (!in_array($dformat, $allowedMimeTypes)) { - form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' . - implode(' ', $allowedMimeTypes))); - file_delete($file); - return; - } - elseif (!$cm->execIngestRules($file, $dformat)) { - drupal_set_message(t('Error following Content Model Rules'), 'error'); - foreach (ContentModel::$errors as $err) { - drupal_set_message($err, 'error'); - } - } - } - } - } - $form_state['rebuild'] = FALSE; - break; - } - } -} - -/** - * fedora repository ingest form - * @param type $form_state - * @param type $collection_pid - * @param type $collection_label - * @param type $content_model - * @return type - */ -function fedora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) { - module_load_include('inc', 'fedora_repository', 'formClass'); -// For the sake of easily maintaining the module in different core versions create our own form_values variable. - if (empty($form_state['storage']['step'])) { - $form_state['storage']['step'] = 1; - } - $ingestForm = new formClass(); - $form_state['storage']['content_model'] = $content_model; - $form_state['storage']['collection_pid'] = $collection_pid; - return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state); -} - -/** - * fedora repository purge object form - * @global type $base_url - * @param type $form_state - * @param type $pid - * @param type $referrer - * @return type - */ -function fedora_repository_purge_object_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 this object', - ); - if (!empty($collectionPid)) { - $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' - } - return $form; -} - -/** - * add stream - * @param type $collection_pid - * @param type $collectionName - * @return type - */ -function add_stream($collection_pid=NULL, $collectionName=NULL) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - if (!valid_pid($collection_pid)) { - drupal_set_message(t("This PID is not valid!"), 'error'); - return ' '; - } - if (!user_access('ingest new fedora objects')) { - drupal_set_message(t('You do not have permission to ingest.'), 'error'); - return ''; - } - if ($collection_pid == NULL) { - drupal_set_message(t('You must specify an collection object pid to ingest an object.'), 'error'); - return ''; - } - $output .= drupal_get_form('fedora_repository_add_stream_form', $pid); - - return $output; -} - -/** - * add stream form submit - * @global type $base_url - * @param type $form - * @param type $form_state - * @return type - */ -function add_stream_form_submit($form, &$form_state) { - global $base_url; - if (!empty($form_state['submit']) && $form_state['submit'] == 'OK') { - $form_state['rebuild'] = TRUE; - return; - } - module_load_include('inc', 'fedora_repository', 'MimeClass'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - $pathToModule = drupal_get_path('module', 'fedora_repository'); - - $file = $form_state['values']['add-stream-file-location']; - - $pid = $form_state['values']['pid']; - $dsid = $form_state['values']['stream_id']; - $dsLabel = $form_state['values']['stream_label'] . substr($file, strrpos($file, '.')); // Add the file extention to the end of the label.; - $file_basename = basename($file); - $file_directory = dirname($file); - $streamUrl = $base_url . '/' . $file_directory . '/' . drupal_urlencode($file_basename); - - /* ----------------------------------------------------------------- - * need a better way to get mimetypes - */ - $mimetype = new MimeClass(); - $dformat = $mimetype->getType($file); - $controlGroup = "M"; - if ($dformat == 'text/xml') { - $controlGroup = 'X'; - } - try { - $item = new Fedora_Item($pid); - $item->add_datastream_from_url($streamUrl, $dsid, $dsLabel, $dformat, $controlGroup); - - $object_helper = new ObjectHelper(); - $object_helper->get_and_do_datastream_rules($pid, $dsid, $file); - - file_delete($file); - } catch (exception $e) { - drupal_set_message(t($e->getMessage()), 'error'); - return; - } - $form_state['rebuild'] = TRUE; -} - -/** - * add stream form - * @param type $form_state - * @param type $pid - * @return type - */ -function add_stream_form(&$form_state, $pid) { - module_load_include('inc', 'fedora_repository', 'formClass'); - $addDataStreamForm = new formClass(); - return $addDataStreamForm->createAddDataStreamForm($pid, $form_state); -} - -/** - * add stream form validate - * @param type $form - * @param type $form_state - * @return type - */ -function add_stream_form_validate($form, &$form_state) { - if ($form_state['clicked_button']['#value'] == 'OK') { - $form_state['rebuild'] = TRUE; - return; - } - $dsid = $form_state['values']['stream_id']; - $dsLabel = $form_state['values']['stream_label']; - if (strlen($dsid) > 64) { - form_set_error('', t('Data stream ID cannot be more than 64 characters.')); - return FALSE; - } - if (!(preg_match("/^[a-zA-Z]/", $dsid))) { - form_set_error('', t("Data stream ID ($dsid) has to start with a letter.")); - return FALSE; - } - if (strlen($dsLabel) > 64) { - form_set_error('', t('Data stream Label cannot be more than 64 characters.')); - return FALSE; - } - if (strpos($dsLabel, '/')) { - form_set_error('', t('Data stream Label cannot contain a "/".')); - return FALSE; - } - $validators = array( - // 'file_validate_is_image' => array(), - // 'file_validate_image_resolution' => array('85x85'), - // 'file_validate_size' => array(30 * 1024), - ); - - $fileObject = file_save_upload('add-stream-file-location', $validators); - -// Move the uploaded file to Drupal's files directory. - file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME'); - $form_state['values']['add-stream-file-location'] = $fileObject->filepath; -// TODO: Add error checking here. - $form_state['rebuild'] = FALSE; -} - -/** - * fedora repository purge stream - * @global type $user - * @param type $pid - * @param type $dsId - * @param type $name - * @return type - */ -function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - if ($pid == NULL || $dsId == NULL) { - drupal_set_message(t('You must specify an object pid and DataStream ID to purge a datastream'), 'error'); - return ' '; - } - if (!fedora_repository_access(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to purge objects."), 'error'); - return ' '; - } - - $output = t('Are you sure you wish to purge this datastream %name<br />', - array( - '%name' => $name) - ); - $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); - return $output; -} - -/** - * fedora repository purge object form submit - * @param type $form - * @param type $form_state - * @return type - */ -function fedora_repository_purge_object_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 { -// this is where you do your processing after they have pressed the confirm button - $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)); - 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/'; - } - } -} - -/** - * fedora repository purge stream form - * @param type $form_state - * @param type $pid - * @param type $dsId - * @return type - */ -function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) { - $form['pid'] = array( - '#type' => 'hidden', - '#value' => "$pid" - ); - $form['dsid'] = array( - '#type' => 'hidden', - '#value' => "$dsId" - ); - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Purge') - ); - - return $form; -} - -/** - * fedora repository purge stream form submit - * @global type $base_url - * @param type $form - * @param array $form_state - */ -function fedora_repository_purge_stream_form_submit($form, &$form_state) { - global $base_url; - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); -//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $pid = $form_state['values']['pid']; - $item = new Fedora_Item($pid); - $dsid = $form_state['values']['dsid']; - try { - $item->purge_datastream($dsid); - } catch (exception $e) { - drupal_set_message(t($e->getMessage()), 'error'); - } - $form_state['redirect'] = $base_url . "/fedora/repository/$pid"; -} - -/** - * fedora repository replace stream - * @param type $pid - * @param type $dsId - * @param type $dsLabel - * @param type $collectionName - * @return type - */ -function fedora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) { - if ($pid == NULL || $dsId == NULL) { - drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error'); - return ''; - } - $output = drupal_get_form('fedora_repository_replace_stream_form', $pid, $dsId, $dsLabel); - - return $output; -} - -/** - * fedora repository replace stream form - * @param type $form_state - * @param type $pid - * @param type $dsId - * @param type $dsLabel - * @return type - */ -function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) { -//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'fedora_repository', ''); - module_load_include('inc', 'Fedora_Repository', 'formClass'); -//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $replaceDataStreamForm = new formClass(); - return $replaceDataStreamForm->createReplaceDataStreamForm($pid, $dsId, $dsLabel, $form_state); -} - -/** - * fedora repository replace stream form validate - * @param type $form - * @param type $form_state - * @return type - */ -function fedora_repository_replace_stream_form_validate($form, &$form_state) { -// If a file was uploaded, process it. - if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name']['file'])) { - -// attempt to save the uploaded file - $file = file_save_upload('file', array(), file_directory_path()); - -// set error is file was not uploaded - if (!$file) { - form_set_error('file', 'Error uploading file.'); - return; - } - - $doc = new DOMDocument(); - module_load_include('inc', 'Fedora_Repository', 'MimeClass'); - $mime = new MimeClass(); - if ($mime->getType($file->filepath) == 'text/xml' && !$doc->load($file->filepath)) { - form_set_error('file', 'Invalid XML format.'); - return; - } - -// set files to form_state, to process when form is submitted - $form_state['values']['file'] = $file; - } -} - -/** - * fedora repository replace stream form submit - * @global type $base_url - * @param type $form - * @param array $form_state - */ -function fedora_repository_replace_stream_form_submit($form, &$form_state) { - global $base_url; - $file = $form_state['values']['file']; - $pid = $form_state['values']['pid']; - $dsid = $form_state['values']['dsId']; - $dsLabel = $form_state['values']['dsLabel']; - // Remove the original file extension from the label and add the new one - $indexOfDot = strrpos($dsLabel, '.'); //use strrpos to get the last dot - if ($indexOfDot !== FALSE) { - $dsLabel = substr($dsLabel, 0, $indexOfDot); - $dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.; - } - module_load_include('inc', 'Fedora_Repository', 'MimeClass'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - - $file_basename = basename($file->filepath); - $file_directory = dirname($file->filepath); - $streamUrl = $base_url . '/' . $file_directory . '/' . urlencode($file_basename); - - /* ----------------------------------------------------------------- - * TODO: need a better way to get mimetypes - */ - $mimetype = new MimeClass(); - $dformat = $mimetype->getType($file->filepath); - - $item = new Fedora_Item($pid); - - $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); - - $form_state['redirect'] = 'fedora/repository/' . $pid; -} - -/** - * fedora repository edit qdc page - * @global type $user - * @param type $pid - * @param type $dsId - * @return type - */ -function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - if ($pid == NULL || $dsId == NULL) { - drupal_set_message(t('You must specify an object pid and a Dublin Core DataStream ID to edit metadata'), 'error'); - return ' '; - } - if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); - return ' '; - } - $output = drupal_get_form('fedora_repository_edit_qdc_form', $pid, $dsId); - - return $output; -} - -/** - * fedora repository edit qdc form - * @global type $user - * @param type $form_state - * @param type $pid - * @param type $dsId - * @return type - */ -function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - if ($pid == NULL) { - drupal_set_message(t('You must specify an object pid!'), 'error'); - } - global $user; - if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); - return ' '; - } - - module_load_include('inc', 'fedora_repository', 'formClass'); - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); - $soapHelper = new ConnectionHelper(); - $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); -// Check if there is a custom edit metadata function defined in the content model. - - $breadcrumbs = array(); - $objectHelper = new ObjectHelper(); - $objectHelper->getBreadcrumbs($pid, $breadcrumbs); - drupal_set_breadcrumb(array_reverse($breadcrumbs)); - - - $output = ''; - if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { - $output = $cm->buildEditMetadataForm($pid, $dsId); - } - - if (empty($output)) { -// There is no custom function, so just load the standard QDC form. - $metaDataForm = new formClass(); -//currently we only edit the dc metadata. If you defined a custom form with a custom handler you are sol for now. - return $metaDataForm->createMetaDataForm($pid, $dsId, $client, $form_state); - } - return $output; -} - -/** - * fedora repository edit qdc form validate - * @param type $form - * @param boolean $form_state - */ -function fedora_repository_edit_qdc_form_validate($form, &$form_state) { - if ($form_state['storage']['xml']) { - if ($form_state['storage']['step'] == 1) { - $form_state['storage']['step']++; - $form_state['rebuild'] = TRUE; - } - module_load_include('inc', 'xml_form_api', 'XMLForm'); - $xml_form = new XMLForm($form_state); - $xml_form->validate($form, $form_state); - } -} - -/** - * Check if there is a custom edit metadata function defined in the content model. If so, - * call it, if not do the submit action for the standard QDC metadata. Custom forms will - * need to implement their own equivalent to the FormClass->updateMetaData function - * - * @param array $form - * @param array $form_state - * @return - */ -function fedora_repository_edit_qdc_form_submit($form, &$form_state) { - if ($form_state['storage']['xml']) { - module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm'); - $xml_form = new EditObjectMetadataForm($form_state); - $xml_form->submit($form, $form_state); - } - else { - module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); - global $base_url; - if (strstr($form_state['clicked_button']['#id'], 'edit-submit')) { - -//$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $soap_helper = new ConnectionHelper(); - $client = $soap_helper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - -// Check the content model for a custom edit metadata form submit function. - if (isset($form_state['values']['pid'])) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - if (($cm = ContentModel::loadFromObject($form_state['values']['pid'])) !== FALSE) { - return $cm->handleEditMetadataForm($form_state['values']['form_id'], $form_state, $client); - } - } - - module_load_include('inc', 'fedora_repository', 'formClass'); - $metaDataForm = new formClass(); - $return_value = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $client); - $form_state['storage'] = NULL; - $form_state['redirect'] = $base_url . '/fedora/repository/' . $form_state['values']['pid']; - - return $return_value; - } - } -} - -/** - * drupal hook - * creates a new permission than can be assigned to roles - */ -function fedora_repository_perm() { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - return array( - OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, - OBJECTHELPER::$EDIT_FEDORA_METADATA, - OBJECTHELPER::$PURGE_FEDORA_OBJECTSANDSTREAMS, - OBJECTHELPER::$ADD_FEDORA_STREAMS, - OBJECTHELPER::$INGEST_FEDORA_OBJECTS, - OBJECTHELPER::$EDIT_TAGS_DATASTREAM, - OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, - OBJECTHELPER::$MANAGE_COLLECTIONS, - OBJECTHELPER::$DELETE_ENTIRE_COLLECTIONS, - OBJECTHELPER::$CREATE_BATCH_PROCESS, - ); -} - -/** - * drupal hook - * determines if a user has access to what they are asking for - * - * @param type $op - * @param type $node - * @param type $account - * @return type - */ -function fedora_repository_access($op, $node, $account) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - $objectHelper = new ObjectHelper(); - return $objectHelper->fedora_repository_access($op, $node, $account); -} - -/** - * Grabs a stream from fedora sets the mimetype and returns it. $dsID is the - * datastream id. - * @param $pid String - * @param $dsID String - */ -function makeObject($pid, $dsID) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - if (!valid_pid($pid)) { - drupal_set_message(t("Invalid PID!"), 'error'); - return ' '; - } - - if (!valid_dsid($dsID)) { - drupal_set_message(t("Invalid dsID!"), 'error'); - return ' '; - } - - if ($pid == NULL || $dsID == NULL) { - drupal_set_message(t("No pid or dsid given to create an object with.")); - return ' '; - } - global $user; - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { - drupal_access_denied(); - return; - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace."), 'error'); - return ' '; - } - - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - $objectHelper = new ObjectHelper(); - $objectHelper->makeObject($pid, $dsID); -} - -/** - * Sends an ITQL query to the Fedora Resource index (can only communicate with Kowari or mulgara) - * Reads the pid and datastream id as url parameters. Queries the collection object for the query - * if there is no query datastream falls back to the query shipped with the module. - * - * @global type $user - * @param type $pid - * @param type $dsId - * @param type $collection - * @param type $page_number - * @param type $limit - * @return type - */ -function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $page_number = NULL, $limit = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - global $user; - - if (!fedora_available()) { - drupal_set_message(t('The Fedora repository server is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); - return ''; - } - - if (!risearch_available()) { - drupal_set_message(t('The Fedora resource index search is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); - return ''; - } - - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - - $item = new fedora_item($pid); - if (!$item->exists()) { - drupal_not_found(); - exit(); - } - - if ($pid & !valid_pid($pid)) { - drupal_set_message(t("Invalid PID!"), 'error'); - return ' '; - } - - if ($dsId & !valid_dsid($dsId)) { - drupal_set_message(t("Invalid dsID!"), 'error'); - return ' '; - } - if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { - if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); - } - drupal_access_denied(); - exit; - return ' '; - } - - $objectHelper = new ObjectHelper(); - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); - if (in_array(-1, $headers)) { - drupal_access_denied(); - exit; - return ' '; - } - if ($dsId != NULL && $dsId != '-') { //if we have a dsID return the stream otherwise query for a collection of objects -//probably should check pid as well here. - return makeObject($pid, $dsId); - } - - $content = '<div id="content-fedora">'; - - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - $collectionClass = new CollectionClass(); - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent'); - $breadcrumbs = array(); - $objectHelper->getBreadcrumbs($pid, $breadcrumbs); - drupal_set_breadcrumb(array_reverse($breadcrumbs)); - - $offset = $limit * $page_number; - $content_models = $objectHelper->get_content_models_list($pid); -// Each content model may return either a tabset array or plain HTML. If it's HTML, stick it in a tab. - $cmodels_tabs = array( - '#type' => 'tabset', - ); - foreach ($content_models as $content_model) { - $content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number); - if (is_array($content_model_fieldset)) { - $cmodels_tabs = array_merge($cmodels_tabs, $content_model_fieldset); - } - else { - $cmodels_tabs[$content_model->pid] = array( - '#type' => 'tabpage', - '#title' => $content_model->name, - '#content' => $content_model_fieldset, - ); - } - } -// Add a 'manage object' tab for all objects, where detailed list of content is shown. - $obj = new FedoraObjectDetailedContent($pid); - $object_details = $obj->showFieldSets(); - if ($object_details['fedora_object_details']['#selected'] == true){ - foreach($cmodels_tabs as $cmodel_tab){ - if (is_array($cmodel_tab)){ - $cmodel_tab['#selected'] = FALSE; - } - - } - } - $cmodels_tabs = array_merge($cmodels_tabs, $object_details); - - - return tabs_render($cmodels_tabs); -} - -/** - * fedora repository urlencode string - * @param type $str - * @return type - */ -function fedora_repository_urlencode_string($str) { - return htmlentities($str); -} - -/** - * Uses makeobject to get a stream. Sets the Content Disposition in the header so it suggests a filename - * and sends it as an attachment. This should prompt for a download of the object. - * - * @global type $user - * @param type $pid - * @param type $dsId - * @param type $label - * @param type $version - * @return type - */ -function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) { - global $user; - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - - if ($pid == NULL || $dsId == NULL) { - drupal_set_message(t("no pid or dsid given to create an object with!")); - return ' '; - } - - $objectHelper = new ObjectHelper(); - $objectHelper->makeObject($pid, $dsId, 1, $label, FALSE, $version); -} - -/** - * repository page - * @param type $pid - * @param type $dsId - * @param type $collection - * @param type $pageNumber - * @return type - */ -function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL) { -//do security check at fedora_repository_get_items function as it has to be called there in case -//someone trys to come in a back door. - return fedora_repository_get_items($pid, $dsId, $collection, $pageNumber); -} - -/** - * repository service - * @global type $user - * @param type $pid - * @param type $servicePid - * @param type $serviceMethod - * @return type - */ -function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - - if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { -//drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error'); - drupal_access_denied(); - if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'error'); - } - return ' '; - } - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); - if (in_array(-1, $headers)) { - drupal_access_denied(); - exit; - return ' '; - } - - - $item = new Fedora_Item($pid); - if ($item !== FALSE) { - echo $item->get_dissemination($servicePid, $serviceMethod); - } - - exit(); -} - -//Search Stuff ******************************************************************** - -/** - * Implementation of hook_search(). - * sends a search query to fedora fgsearch which is backed by Lucene - * In our implementation of Fedora we have api-a and api-m locked down - * to authorized users but at the object level. We can query Lucene and the - * RI index to get a list of results without authorization but to view any - * datastreams users must be authorized. - * - * @param type $op - * @param type $keys - * @return array - */ -function fedora_repository_search($op = 'search', $keys = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - - switch ($op) { - case 'name': - if (user_access('view fedora collection')) { - return t('Digital Repository', array('-9')); - } - case 'search': - if (user_access('view fedora collection')) { -//demo search string ?operation=gfindObjects&indexName=DemoOnLucene&query=fgs.DS.first.text%3Achristmas&hitPageStart=11&hitPageSize=10 - $resultData = NULL; - $numberOfHitsPerPage = NULL; - $index = strpos($keys, '.'); - $test = substr($keys, 0, $index + 1); - $type = NULL; - if ($index > 0) { - $index = strpos($keys, ':'); - $type = substr($keys, 0, $index); - $keys = substr($keys, $index + 1); - } - - $index = strpos($keys, ':'); - $startPage = substr($keys, 0, $index); - if ($index > 1) { - $keys = substr($keys, $index + 1); - } - - if (!$startPage) { - $startPage = 1; - } - - $xmlDoc = NULL; - - $path = drupal_get_path('module', 'fedora_repository'); - $xmlDoc = new DomDocument(); - $xmlDoc->load($path . '/searchTerms.xml'); - $nodeList = $xmlDoc->getElementsByTagName('default'); - if (!$type) { -//$type = 'dc.description'; - $type = $nodeList->item(0)->nodeValue; - } - $nodeList = $xmlDoc->getElementsByTagName('number_of_results'); - $numberOfHitsPerPage = $nodeList->item(0)->nodeValue; - - $indexName = variable_get('fedora_index_name', 'DemoOnLucene'); - $keys = htmlentities(urlencode($keys)); - $searchQuery = NULL; - if (isset($type) && strcmp($type, ':')) { - $searchQuery = $type . ':' . $keys; - } - else { - $searchQuery = $keys; - } -//$searchQuery.=" AND (PID:vre OR PID:vre:ref OR PID:demo OR PID:changeme)"; - - $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest'); - $searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=copyXml&query=' . $searchQuery; - $searchString .= '&hitPageSize=' . $numberOfHitsPerPage . '&hitPageStart=' . $startPage; -//$searchString = htmlentities(urlencode($searchString)); - $searchUrl .= $searchString; - $objectHelper = new ObjectHelper(); - $resultData = do_curl($searchUrl); - - $results[] = array( - array( - 'data' => $resultData, - 'colspan' => 2 - ) - ); - return $results; - } - } // switch ($op) -} - -/** - * Implementation of hook_search_page(). - * Display the search results - * - * @param type $resultData - * @return array - */ -function fedora_repository_search_page($resultData) { - $path = drupal_get_path('module', 'fedora_repository'); - $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); - $proc = NULL; - if (!$resultData[0][0]['data']) { - return ''; //no results - } - $text = utf8_encode($resultData[0][0]['data']); - - try { - $proc = new XsltProcessor(); - } catch (Exception $e) { - $out[] = array( - array( - 'data' => $e->getMessage(), - 'colspan' => 2 - ) - ); - return $out; - } - -//inject into xsl stylesheet - $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on - $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl - $proc->setParameter('', 'objectsPage', base_path()); - $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); - $proc->registerPHPFunctions(); - $xsl = new DomDocument(); - if ($isRestricted) { - $xsl->load($path . '/xsl/results.xsl'); - } - else { - $xsl->load($path . '/xsl/unfilteredresults.xsl'); - } - - $input = new DomDocument(); - $didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data'])); - - if (!$didLoadOk) { - $results[] = array( - array( - 'data' => 'Error parsing results', - 'colspan' => 2 - ) - ); - } - else { - $xsl = $proc->importStylesheet($xsl); - $newdom = $proc->transformToDoc($input); - - $results[] = array( - array( - 'data' => $newdom->saveHTML(), - 'colspan' => 2 - ) - ); - } - - $header = array( - array( - 'data' => t('Collection results'), - NULL, - ), - (NULL) - ); - - $output .= theme('table', $header, $results); - return $output; -} - -/** - * Implementation of hook_form_alter(). - * allows the advanced search form in drupal - * - * @param type $form - * @param type $form_state - * @param type $form_id - */ -function fedora_repository_form_alter(&$form, &$form_state, $form_id) { -// Advanced node search form - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $path = drupal_get_path('module', 'fedora_repository'); - if ($form_id == 'search_form' && arg(1) == 'fedora_repository' && user_access('use advanced search')) { - $default_value = $form['basic']['inline']['keys']['#default_value']; - $index = strpos($default_value, '.'); - $test = substr($default_value, 0, $index + 1); - $type = NULL; - if ($index > 0) { - $index = strpos($default_value, ':'); - $type = substr($default_value, 0, $index); - $default_value = substr($default_value, $index + 1); - } - $form['basic']['inline']['keys']['#default_value'] = $default_value; -// Keyword boxes: - $form['advanced'] = array( - '#type' => 'fieldset', - '#title' => t('Advanced search'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#attributes' => array( - 'class' => 'search-advanced' - ), - ); - $form['advanced']['keywords'] = array( - '#prefix' => '<div class="criterion">', - '#suffix' => '</div>', - ); - $xmlDoc = new DomDocument(); - $xmlDoc->load($path . '/searchTerms.xml'); - $nodeList = $xmlDoc->getElementsByTagName('term'); - $searchClass = new SearchClass(); - $types = $searchClass->get_search_terms_array(); - - $form['advanced']['type'] = array( - '#type' => 'select', - '#title' => t('Choose a field to search'), - '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $types, - '#default_value' => $type, - ); - $form['advanced']['submit'] = array( - '#type' => 'submit', - '#value' => t('Advanced search'), - '#prefix' => '<div class="action clear-block">', '#suffix' => '</div>', - ); - $form['#validate'][] = 'fedora_repository_search_validate'; - } -} - -/** - * Implementation of hook_search_validate() - * - * @param type $form - * @param type $form_state - */ -function fedora_repository_search_validate($form, &$form_state) { -// Initialise using any existing basic search keywords. - $keys = $form_state['values']['processed_keys']; - - if (isset($form_state['values']['type'])) { - $type = $form_state['values']['type']; - if ($type) { - $keys = $type . ':' . $keys; - } - } - - if (!empty($keys)) { - form_set_value($form['basic']['inline']['processed_keys'], trim($keys), $form_state); //set the form string - } -} - -/** - * fedora repository theme - * @return type - */ -function fedora_repository_theme() { - return array( - 'fedora_repository_mnpl_advanced_search_form' => array( - 'arguments' => array( - 'form' => NULL, - ), - ), - 'fedora_repository_time' => array( - 'arguments' => array( - 'element' => NULL - ), - 'fedora_repository_solution_packs_list' => array( - 'arguments' => array( - 'solution_packs' => NULL, - ), - ), - ), - ); -} - -/** - * Get a list of terms from a lucene index - * - * @param type $field - * @param type $startTerm - * @param type $displayName - * @return type - */ -function fedora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) { - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $searchClass = new SearchClass(); - return $searchClass->getTerms($field, $startTerm, $displayName); -} - -/** - * fedora repository mnpl advanced search form - * @return type - */ -function fedora_repository_mnpl_advanced_search_form() { - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $searchClass = new SearchClass(); - return $searchClass->build_advanced_search_form(); -} - -/** - * theme fedora repository mnpl advanced search form - * @param type $form - * @return type - */ -function theme_fedora_repository_mnpl_advanced_search_form($form) { - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $advanced_search_form = new SearchClass(); - return $advanced_search_form->theme_advanced_search_form($form); -} - -/** - * fedora repository mnpl advanced search - * @param type $query - * @param type $startPage - * @return type - */ -function fedora_repository_mnpl_advanced_search($query, $startPage = 1) { - module_load_include('inc', 'fedora_repository', 'SearchClass'); - $searchClass = new SearchClass(); - $retVal = $searchClass->custom_search($query, $startPage); - return $searchClass->custom_search($query, $startPage); -} - -/** - * fedora repository mnpl_advanced search form submit - * @param type $form - * @param type $form_state - */ -function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state) { - $type_id = $form_state['values']['type']; - $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3')); - $searchString = $form_state['values']['type1'] . ':' . $form_state['values']['fedora_terms1']; - if ($form_state['values']['fedora_terms2'] != '') { - $searchString .=' +' . $form_state['values']['andor1'] . '+' . $form_state['values']['type2'] . ':' . $form_state['values']['fedora_terms2']; - } - if ($repeat > 2 && $repeat < 9) { - for ($i = 3; $i < $repeat + 1; $i++) { - $t = $i - 1; - if ($form_state['values']["fedora_terms$i"] != '') { - $searchString .= '+' . $form_state['values']["andor$t"] . '+' . $form_state['values']["type$i"] . ':' . $form_state['values']["fedora_terms$i"]; - } - } - } - drupal_goto("fedora/repository/mnpl_advanced_search/$searchString"); -} - -/** - * fedora repository install demo page - * @return type - */ -function fedora_repository_install_demos_page() { - $output = drupal_get_form('fedora_repository_demo_objects_form'); - return $output; -} - -/** - * fedora repository demo objects form - * @return string - */ -function fedora_repository_demo_objects_form() { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - $form = array(); - $existing_demos = array(); - - $form['install_demos'] = array( - '#title' => t('Islandora Demo Collections'), - '#type' => 'fieldset', - '#description' => t('Install demo image and document collections and content models.'), - ); - $demo_objects = array(); -// Check if the top-level islandora collection exists. If not, display a button to ingest. - - $form['install_demos']['demo_collections'] = array( - '#type' => 'checkboxes', - '#title' => t('Collections to ingest'), - '#options' => array(), - '#description' => t('Choose which demo collections you would like ingested into the repository.'), - ); - - foreach (array( - 'islandora:collectionCModel' => 'Islandora default content models', - 'islandora:root' => 'Islandora top-level collection', - 'islandora:demos' => 'Islandora demos collection', - 'islandora:largeimages' => 'Sample large image content model (requires <a href="http://sourceforge.net/projects/djatoka/">Djatoka</a> and <a href="http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=26&Itemid=22">Kakadu</a>.)', - ) - as $available_demo => $available_demo_desc) { - try { - $demo_objects[$available_demo] = new Fedora_Item($available_demo); - } catch (exception $e) { - - } - - if (empty($demo_objects[$available_demo]->objectProfile)) { -//The demo objects collection does not exist in the repository, display a button to ingest them. - $form['install_demos']['demo_collections']['#options'][$available_demo] = $available_demo_desc; - } - else { - array_push($existing_demos, $demo_objects[$available_demo]); - } - } - -// Check if the SmileyStuff collectoin exists, and if it has a COLLECTION_VIEW datastream. If it doesn't then we can add it. - - $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); - if (!empty($smiley_stuff->objectProfile)) { - $datastreams_list = $smiley_stuff->get_datastreams_list_as_array(); - if (empty($datastreams_list['COLLECTION_VIEW'])) { - $form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection'; - } - else { - $demo_objects['demo:SmileyStuff'] = $smiley_stuff; - } - } - else { - $form['install_demos']['smileynote'] = array( - '#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>' - ); - } - - $form['install_demos']['ingest'] = array( - '#type' => 'submit', - '#name' => 'install_demos', - '#value' => 'Install Selected Demos', - '#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE, - ); - - $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) { - - $form['existing_demos'][$demo_object->pid] = array( - '#prefix' => '<li>', - '#value' => l($demo_object->pid, $demo_object->url()), - '#suffix' => '</li>', - ); - } - } - - return $form; -} - -/** - * fedora repository demo objects form submit - * @global type $base_url - * @param type $form - * @param type $form_state - */ -function fedora_repository_demo_objects_form_submit($form, &$form_state) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/dublin_core'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - global $base_url; - if ($form_state['clicked_button']['#name'] == 'install_demos') { - if (!empty($form_state['values']['demo_collections']['islandora:collectionCModel'])) { - try { - $collectioncm = Fedora_Item::ingest_new_item('islandora:collectionCModel', 'A', 'Islandora Collection Content Model'); - $collectioncm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); - $collectioncm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); - } catch (exception $e) { - - } - try { - $strictpdfcm = Fedora_Item::ingest_new_item('islandora:strict_pdf', 'A', 'Strict PDF Content Model'); - $strictpdfcm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); - $strictpdfcm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STRICT_PDFCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); - } catch (exception $e) { - - } - -// Install a collection object that points to all content model objects - try { - $cmodel_collection_xml = Fedora_Item::create_object_FOXML('islandora:ContentModelCollection'); - $cmodel_collection = Fedora_Item::ingest_from_FOXML($cmodel_collection_xml); - -//$dc = new Dublin_Core(new Fedora_Item('islandora:ContentModelCollection')); - $dc = new Dublin_Core($cmodel_collection); - $dc->set_element('dc:title', array('Installed Content Model')); - $dc->save(); - $cmodel_collection->add_datastream_from_string('select $object $title from <#ri> - where ($object <dc:title> $title - and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> - or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) - and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) - order by $title', 'QUERY', 'Content Model Collection Query', 'text/plain'); - $cmodel_collection->add_relationship('isMemberOfCollection', 'islandora:root'); - $cmodel_collection->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); - $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:ContentModelCollection\">islandora:ContentModelCollection</a>."), 'message'); - } catch (exception $e) { - - } - } - - if (!empty($form_state['values']['demo_collections']['islandora:root'])) { - $new_item = Fedora_Item::ingest_new_item('islandora:root', 'A', 'Islandora Top-level Collection'); - $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); - try { - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:root\">islandora:root</a>."), 'message'); - } catch (exception $e) { - - } - } - - if (!empty($form_state['values']['demo_collections']['islandora:demos'])) { - $new_item = fedora_item::ingest_new_item('islandora:demos', 'A', 'Islandora Demo Collection'); - $new_item->add_relationship('isMemberOfCollection', 'islandora:root'); - $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); - -// $cv = $new_item->add_datastream_from_file( drupal_get_path('module', 'fedora_repository') . '/collection_views/COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View.xml', 'text/xml', 'X'); - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - try { - $new_item = Fedora_Item::ingest_new_item('islandora:pdf_collection', 'A', 'PDF Collection'); - $new_item->add_relationship('isMemberOfCollection', 'islandora:demos'); - $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:demos\">islandora:demos</a>."), 'message'); - } catch (exception $e) { - - } - } - - if (!empty($form_state['values']['demo_collections']['demo:SmileyStuff'])) { - $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); - $new_item = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/SmileyStuff-COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); - $smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos'); - $tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - $cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X'); - - $cm = new Fedora_Item('demo:DualResImage'); - try { - $cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X'); - } catch (exception $e) { - - } - $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection'); - try { - $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view."), 'message'); - } catch (exception $e) { - - } - } - - if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) { - $error = ''; - foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml', - 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) { - try { - $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/' . $foxml_file); - } catch (exception $e) { - $error .= " - Problem ingesting $foxml_file"; - } - } - try { - $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/islandora_largeimages.xml'); - $tn = $item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:largeimages\">islandora:largeimages</a>."), 'message'); - } catch (exception $e) { - $error .= " - Problem ingesting islandora:largeimages collection"; - } - } - - if (!empty($error)) { - drupal_set_message(t('Some problems occurred: ' . $error)); - } - } -} - -/** - * fedora repository required fedora objects - * @return type - */ -function fedora_repository_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_repository'); - return array( - 'fedora_repository' => array( - 'module' => 'fedora_repository', - 'title' => 'Islandora Core', - 'objects' => array( - array( - 'pid' => 'islandora:collectionCModel', - 'label' => 'Islandora Collection Content Model', - 'dsid' => 'ISLANDORACM', - 'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml", - 'dsversion' => 2, - 'cmodel' => 'fedora-system:ContentModel-3.0', - ), - - array( - 'pid' => 'islandora:root', - 'label' => 'Islandora Top-level Collection', - 'cmodel' => 'islandora:collectionCModel', - 'datastreams' => array( - array( - 'dsid' => 'COLLECTION_POLICY', - 'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", - ), - array( - 'dsid' => 'TN', - 'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", - 'mimetype' => 'image/png', - ), - ), - ), - ), - ), - ); -} - -/** - * Functions to create a time selector form element type. - */ -function fedora_repository_elements() { - $type['fedora_repository_time'] = array( - "#input" => TRUE, - "#process" => array("fedora_repository_expand_time"), - ); - - return $type; -} - -/** - * fedora repository expand time - * @param type $element - * @return string - */ -function fedora_repository_expand_time($element) { -// Default to current time, check default_value but set value so that if -// default value is present it will override value - if (empty($element['#default_value'])) { - $element['#value'] = array( - 'hour' => intval(format_date(time(), 'custom', 'h')), - 'minute' => intval(format_date(time(), 'custom', 'i')), - ); - } - - $element['#tree'] = TRUE; - - foreach ($element['#value'] as $type => $value) { - switch ($type) { - case 'hour': - $options = drupal_map_assoc(range(1, 24)); - break; - case 'minute': - $options = range(0, 59); - break; - } - - if ($type != 'meridiem') { - foreach ($options as $option) { - strlen($option) <= 1 ? $options[$option] = 0 . $option : ''; - } - } - - $element[$type] = array( - '#type' => 'select', - '#default_value' => $element['#value'][$type], - '#options' => $options, - ); - } - - return $element; -} - -/** - * fedora repository time - * @param type $element - * @return type - */ -function fedora_repository_time($element) { - $output = '<div class="container-inline">' . $element['#children'] . '</div>'; - return theme('form_element', $element, $output); -} - -/** - * theme fedora repository time - * @param type $element - * @return type - */ -function theme_fedora_repository_time($element) { - $output = '<div class="container-inline">' . $element['#children'] . '</div>'; - return theme('form_element', $element, $output); -} - -/* Export (basket) functionality */ - -/** - * fedora repository remove item from basket - * @param type $pid - */ -function fedora_repository_remove_item_from_basket($pid) { - - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; - - $objectHelper = new ObjectHelper(); -// getting child PIDs if any - $cpids = $objectHelper->get_child_pids(array($pid)); - - if (array_key_exists($pid, $pids)) { -// remove item from basket - unset($_SESSION['basket']['processed'][$pid]); - } - if (!empty($cpids)) { // there are children - foreach ($cpids as $child_pid => $value) { -// remove child item from basket recursively - fedora_repository_remove_item_from_basket($child_pid); - } - } -} - -/** - * fedora repository basket - * @return type - */ -function fedora_repository_basket() { - $pids = _fedora_repository_get_basket_pids(); - $output = drupal_get_form('fedora_repository_basket_form', $pids); - - return $output; -} - -function fedora_repository_basket_form($form_state, $pids) { - $form = array(); - - if (!empty($pids)) { - $form['pid'] = array(); - $form['title'] = array(); - $form['desc'] = array(); - } - else { - return; - } - - ksort($pids); - foreach ($pids as $pid => $arr) { - $cbs[$pid] = ''; - - $form['pid'][$pid] = array('#value' => l($pid, "fedora/repository/$pid")); - $form['title'][$pid] = array('#value' => $arr['title']); - $form['desc'][$pid] = array('#value' => $arr['desc']); - } - - $form['remove'] = array( - '#type' => 'checkboxes', - '#options' => $cbs, - ); - - $form['remove_submit'] = array( - '#type' => 'submit', - '#value' => t('Remove selected'), - ); - - $form['remove_all'] = array( - '#type' => 'submit', - '#value' => t('Empty basket'), - ); - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Export selected'), - ); - - $form['submit_all'] = array( - '#type' => 'submit', - '#value' => t('Export all'), - ); - - return $form; -} - -/** - * theme fedora repository basket form - * @param type $form - * @return string - */ -function theme_fedora_repository_basket_form($form) { - $header = array( - theme('table_select_header_cell'), - t('PID'), - t('Title'), - t('Description'), - ); - - if (isset($form['pid']) && is_array($form['pid'])) { - foreach (element_children($form['pid']) as $key) { - $rows[] = array( - drupal_render($form['remove'][$key]), - drupal_render($form['pid'][$key]), - drupal_render($form['title'][$key]), - drupal_render($form['desc'][$key]), - ); - } - } - else { - $rows[] = array(array('data' => t('Your basket is empty.'), 'colspan' => '4')); - } - - $output = theme('table', $header, $rows); - - $frm = drupal_render($form); - $output = $frm . $output . $frm; - - return $output; -} - -/** - * fedora repository basket form validate - * @param type $form - * @param type $form_state - */ -function fedora_repository_basket_form_validate($form, &$form_state) { - -} - -/** - * fedora repository basket form submit - * @global type $user - * @param type $form - * @param type $form_state - * @return type - */ -function fedora_repository_basket_form_submit($form, &$form_state) { - if ($form_state['values']['op'] == $form_state['values']['remove_submit']) { - $pids = $form_state['clicked_button']['#post']['remove']; - - if (isset($pids)) { - foreach ($pids as $pid) { - fedora_repository_remove_from_basket($pid); - } - drupal_set_message(t("Selected objects removed")); - return; - } - } - - if ($form_state['values']['op'] == $form_state['values']['remove_all']) { - _fedora_repository_empty_basket(); - drupal_set_message(t("Basket emptied")); - return; - } - - if ($form_state['values']['op'] == $form_state['values']['submit_all']) { - $msg = t("All objects exported to staging area"); - $pids = _fedora_repository_get_basket_pids(); - } - elseif ($form_state['values']['op'] == $form_state['values']['submit']) { - $msg = t("Selected objects exported to staging area"); - $pids = array_filter($form_state['values']['remove']); - } - - if (!empty($pids)) { - global $user; - $log = array(); - $success = TRUE; - $export_dir = variable_get('export_area', file_directory_path() . '/fedora_export_area') . '/' . $user->name . '/' . date("Ymd-His"); - $foxml_dir = $export_dir . '/foxml'; - - if (!file_exists($foxml_dir) && !@mkdir($foxml_dir, 0775, TRUE)) { - drupal_set_message(t("Failed to create foxml dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $foxml_dir)), 'error'); - return FALSE; - } - - module_load_include('inc', 'fedora_repository', 'api/fedora_export'); - foreach ($pids as $pid => $arr) { - - $objects_dir = $export_dir . '/objects/' . $pid; - if (!file_exists($objects_dir) && !@mkdir($objects_dir, 0775, TRUE)) { - drupal_set_message(t("Failed to create objects dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $objects_dir)), 'error'); - return FALSE; - } - - if (!export_to_export_area($pid, $foxml_dir, $objects_dir, $log)) { - $success = FALSE; - } - } - $msg = $success ? $msg : t("Failed to export objects to staging area"); - $msg .= ":<br/>" . implode("<br/>", $log); - - drupal_set_message($msg, $success ? 'info' : 'error'); -//_fedora_repository_empty_basket(); - } - else { - drupal_set_message(t("No objects selected or basket empty"), 'error'); - } - - return; -} - -/** - * Get all pids saved to the basket. - * - * @return type - */ -function _fedora_repository_get_basket_pids() { - -// Set empty defaults if basket elements are missing - $_SESSION['basket'] = isset($_SESSION['basket']) ? $_SESSION['basket'] : array('processed' => array(), 'unprocessed' => array()); - $_SESSION['basket']['processed'] = isset($_SESSION['basket']['processed']) ? $_SESSION['basket']['processed'] : array(); - $_SESSION['basket']['unprocessed'] = isset($_SESSION['basket']['unprocessed']) ? $_SESSION['basket']['unprocessed'] : array(); - - $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; - - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - $ob = new ObjectHelper(); - foreach ($_SESSION['basket']['unprocessed'] as $pid) { -// Check if the pid already exists in the tree - if (array_key_exists($pid, $pids)) { - continue; - } - - $pids += $ob->get_all_related_pids($pid); -// $pids += array($pid); - } - - $_SESSION['basket']['processed'] = $pids; - $_SESSION['basket']['unprocessed'] = array(); - - return $pids; -} - -/** - * fedora repository empty basket - */ -function _fedora_repository_empty_basket() { - unset($_SESSION['basket']); -} - -/** - * fedora repository add to basket - * @param type $pid - * @param type $warn - * @param type $searchResultsFlag - */ -function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) { - if ($warn && _is_added_to_basket($pid)) { - drupal_set_message(t("Object already in basket")); - } - - if (!isset($_SESSION['basket'])) { - $_SESSION['basket'] = array(); - $_SESSION['basket']['unprocessed'] = array($pid => $pid); - } - else { - $_SESSION['basket']['unprocessed'][$pid] = $pid; - } - - if (!$searchResultsFlag) { - drupal_goto('fedora/basket'); - } -} - -/** - * fedora repository remove from basket - * @param type $pid - * @return type - */ -function fedora_repository_remove_from_basket($pid) { - if (isset($_SESSION['basket']['unprocessed'][$pid])) { - unset($_SESSION['basket']['unprocessed'][$pid]); - } - - if (isset($_SESSION['basket']['processed'][$pid])) { - unset($_SESSION['basket']['processed'][$pid]); - } - return; -} - -/** - * theme add to basket link - * @param type $pid - * @param type $type - * @return type - */ -function theme_add_to_basket_link($pid, $type = 'object') { - $object = t($type); - $path = drupal_urlencode($pid); - - $save = "export_big.png"; - $saved = "exported_big.png"; -// $path = drupal_get_path('module', 'Fedora_Repository').'/images/'.$save ; - /* - var_dump($path); - var_dump(theme('image',drupal_get_path('module', 'Fedora_Repository').'/images/'.$save)); - die(); - */ - if (!_is_added_to_basket($pid)) { - return l( - theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), - "fedora/repository/addToBasket/" . $path, - array('html' => TRUE) - ); - } - - return theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $saved, t("In basket"), t("This @object is already in your basket", array('@object' => $object))); -} - -/** - * is added to basket - * @param type $pid - * @param type $account - * @return type - */ -function _is_added_to_basket($pid, $account = NULL) { - return isset($_SESSION['basket']['unprocessed'][$pid]) || isset($_SESSION['basket']['processed'][$pid]); -// return db_result(db_query("SELECT uid FROM {repository_basket} WHERE uid = %d AND pid = '%s'", $account->uid, $pid)); -} - -/** - * fedora repository display schema - * @param type $file - * @return type - */ -function fedora_repository_display_schema($file) { - $path = drupal_get_path('module', 'fedora_repository'); - if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) { - drupal_goto($path . '/' . $file); - } - else { - drupal_goto(); - } - return; -} - -/** - * fedora repository batch reingest object - * @param type $object - * @param type $context - * @return type - */ -function fedora_repository_batch_reingest_object($object, &$context) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - if (!empty($object) && is_array($object)) { - $pid = $object['pid']; - if (!valid_pid($pid)) { - return NULL; - } -// Does the object exist? If so, purge it. - $item = new Fedora_Item($pid); - if ($item->exists()) { - $item->purge(t('Remove during re-install batch job')); - } - -// Ingest the object from the source file. - if (!empty($object['foxml_file'])) { - $foxml_file = $object['foxml_file']; - $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file); - if ($new_item->exists()) { -// Batch operation was successful. - $context['message'][] = "$new_item->pid installed."; - } - } - if (!empty($object['dsid']) && !empty($object['datastream_file'])) { - $datastreams = array( - array( - 'dsid' => $object['dsid'], - 'datastream_file' => $object['datastream_file'], - ) - ); - } - elseif (!empty($object['datastreams'])) { - $datastreams = $object['datastreams']; - } - - if (!empty($datastreams) && is_array($datastreams)) { - $label = !empty($object['label']) ? $object['label'] : ''; - if (empty($object['foxml_file']) && !isset($new_item)) { - $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); - } - if (!empty($object['cmodel'])) { - $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); - } - if (!empty($object['parent'])) { - $new_item->add_relationship('isMemberOfCollection', $object['parent']); - } - foreach ($datastreams as $ds) { - if ($ds['dsid'] == 'DC') { - $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml'); - } - else { - $new_item->add_datastream_from_file($ds['datastream_file'], $ds['dsid'], !empty($ds['label']) ? $ds['label'] : '', !empty($ds['mimetype']) ? $ds['mimetype'] : 'text/xml'); - } - } - } - } -} - -/** - * Content model, collection view and collection policy datastreams may now optionally define a version - * number in their top-level XML element as an attribute, as in: - * <content_model name="Collection" version="2" ... - * - * @param Fedora_Item $item - * @param string $dsid - * @param string $datastream_file - * @return int, or NULL if no version attribute was found. - */ -function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { - $return = NULL; - if (isset($item)) { - $doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); - } - elseif (isset($datastream_file)) { - $doc = simplexml_load_file($datastream_file); - } - - if (!empty($doc)) { - $attrs = $doc->attributes(); - foreach ($attrs as $name => $value) { - if ($name == 'version') { - $return = (int) $value; - break; - } - } - } - return $return; -} - -/** - * theme fedora repository solution pack list - * @param type $solution_packs - * @return string - */ -function theme_fedora_repository_solution_packs_list($solution_packs) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - $output = ''; - $header = array(); - $rows = array(); - - - - - drupal_add_css(drupal_get_path('module', 'update') . '/update.css'); - return $output; -} - -/** - * Implementation of hook_forms() - * @param string $form_id - * @return array - */ -function fedora_repository_forms($form_id) { - $forms = array(); - if (strpos($form_id, 'fedora_repository_solution_pack_form_') === 0) { - $forms[$form_id] = array( - 'callback' => 'fedora_repository_solution_pack_form', - ); - } - return $forms; -} diff --git a/digital_repository.solutionpacks.inc b/digital_repository.solutionpacks.inc deleted file mode 100644 index de4ce137..00000000 --- a/digital_repository.solutionpacks.inc +++ /dev/null @@ -1,175 +0,0 @@ -<?php - -/** - * @file - * Invokes a hook to any dependent modules asking them if their installations require - * any fedora objects to be present. Modules implementing this hook should return an array - * of arrays of the form: - * - * array( 'pid', 'path-to-foxml-file', 'dsid', 'path-to-datastream-file', int dsversion) - * - * where the last three options are optional. A module can either point to a simple - * foxml file to install, or can specify a datastreamstream to check for, with a - * path to load the datastream from if it isn't there. Optionally a version number - * can be included, to enable updating of content model or collection policy streams - * that may have been updated. THis is a simple whole number that should be incremented - * when changed. This value appears in as an attribute of the topmost element of the stream, - * e.g.,: - * - * <?xml version="1.0" encoding="utf-8"?> <content_model name="Collection" version="2" ... - * - * Datastreams which don't have this element are assumed to be at version 0. - */ -function fedora_repository_solution_packs_page() { - $enabled_solution_packs = module_invoke_all('required_fedora_objects'); - $output = ''; - foreach ($enabled_solution_packs as $solution_pack_module => $solution_pack_info) { - $objects = array(); - foreach ($solution_pack_info as $field => $value) { - switch ($field) { - case 'title': - $solution_pack_name = $value; - break; - case 'objects': - $objects = $value; - break; - } - } - $output .= drupal_get_form('fedora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects); - } - - return $output; -} - -/** - * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. - * @param array $solution_pack - */ -function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { - // Check each object to see if it is in the repository. - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - global $base_path; - $needs_update = FALSE; - $needs_install = FALSE; - $form = array(); - $form['solution_pack_module'] = array( - '#type' => 'hidden', - '#value' => $solution_pack_module, - ); - - if (!$form_state['submitted']) { - $form['soluction_pack_name'] = array( - '#type' => 'markup', - '#value' => t($solution_pack_name), - '#prefix' => '<h3>', - '#suffix' => '</h3>', - ); - $form['objects'] = array( - '#type' => 'fieldset', - '#title' => "Objects", - '#weight' => 10, - '#attributes' => array('class' => 'collapsed'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $table_header = array('PID', 'Status'); - $table_rows = array(); - - - foreach ($objects as $object) { - $datastreams = NULL; - if (isset($object['pid'])) { - $pid = $object['pid']; - - $item = new Fedora_Item($pid); - $table_row = array($object['pid']); - $object_status = t('Up-to-date'); - if (!$item->exists()) { - $object_status = 'Missing'; - $needs_install = TRUE; - } - else { - if (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { - $datastreams = array( - array( - 'dsid' => $object['dsid'], - 'datastream_file' => $object['datastream_file'], - 'dsversion' => $object['dsversion'], - ), - ); - } - elseif (!empty($object['datastreams'])) { - $datastreams = $object['datastreams']; - } - if (!empty($datastreams) && is_array($datastreams)) { - foreach ($datastreams as $ds) { - $ds_list = $item->get_datastreams_list_as_array(); - if (!array_key_exists($ds['dsid'], $ds_list)) { - $needs_update = TRUE; - $object_status = 'Missing datastream'; - break; - } - if (isset($ds['dsversion'])) { - // Check if the datastream is versioned and needs updating. - $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); - $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); - if ($available_version > $installed_version) { - $needs_update = TRUE; - $object_status = 'Out of date'; - break; - } - } - } - } - } - array_push($table_row, $object_status); - $table_rows[] = $table_row; - } - } - $form['objects']['table'] = array( - '#type' => 'markup', - '#value' => theme_table($table_header, $table_rows), - ); - } - - $form['install_status'] = array( - '#type' => 'markup', - '#prefix' => '<strong>' . t('Object status:') . ' </strong>', - '#suffix' => ' ', - ); - if (!$needs_install && !$needs_update) { - $form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.'); - } - else { - $form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.'); - } - $form['submit'] = array( - '#value' => t('Install'), - '#disabled' => !$needs_install && !$needs_update, - '#type' => 'submit', - '#name' => $solution_pack_module, - ); - - $form['#submit'] = array( - 'fedora_repository_solution_pack_form_submit', - ); - return $form; -} - -function fedora_repository_solution_pack_form_submit($form, &$form_state) { - $what = $form_state; - $module_name = $form_state['values']['solution_pack_module']; - $solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); - $batch = array( - 'title' => t('Installing / updating solution pack objects'), - 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', - 'operations' => array(), - ); - - - foreach ($solution_pack_info[$module_name]['objects'] as $object) { - // Add this object to the batch job queue. - $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); - } - batch_set($batch); -} diff --git a/plugins/fedora_imageapi.info b/plugins/fedora_imageapi.info deleted file mode 100644 index e54e3f05..00000000 --- a/plugins/fedora_imageapi.info +++ /dev/null @@ -1,7 +0,0 @@ -name = Fedora ImageAPI -description = Adds image manipulation support through a REST interface -package = Islandora Dependencies -dependencies[] = fedora_repository -dependencies[] = imageapi -version = 11.2.beta1 -core = 6.x diff --git a/plugins/fedora_imageapi.module b/plugins/fedora_imageapi.module deleted file mode 100644 index f3bd4481..00000000 --- a/plugins/fedora_imageapi.module +++ /dev/null @@ -1,116 +0,0 @@ -<?php - - - -function fedora_imageapi_menu() { - $items = array(); - $items['fedora/imageapi'] = array( - 'title' => t('Image manipulation functions'), - 'page callback' => 'fedora_repository_image_manip', - 'type' => MENU_CALLBACK, - 'access arguments' => array('view fedora collection'), - ); - return $items; -} - -/** - * Call out to the Drupal ImageAPI module and return the resulting image as a stream. - * - * @param string $pid - * @param string $dsid - * @param string $op - * @param string $params - */ -function fedora_repository_image_manip($pid = '', $dsid = '', $op = '', $params = '') { - module_load_include('inc', 'Fedora_Repository', 'ObjectHelper'); - module_load_include('module', 'imageapi'); - $obj = new ObjectHelper(); - $mimetype = $obj->getMimeType($pid, $dsid); - $ext = substr(strstr($mimetype, '/'), 1); - $op = (!empty($_GET['op']) ? $_GET['op'] : ''); - $safe_pid = str_replace(':', '_', $pid); - - $cache_key = 'fedora_repository_image_manip_' . md5($safe_pid . '_' . $dsid . '_' . $ext . '_' . $op . (isset($_GET['width']) ? '_' . $_GET['width'] : '') . (isset($_GET['height']) ? '_' . $_GET['height'] : '')); - if (($file = cache_get($cache_key)) === 0) { - //added the slash as sys_get_temp_dir in linux does not seem to include the slash - $tmp_file_name = sys_get_temp_dir() . '/' . $safe_pid . '_' . $dsid . '.' . $ext; - $handle = fopen($tmp_file_name, "w"); - $numbytes = fwrite($handle, $obj->getStream($pid, $dsid)); - fclose($handle); - if ($numbytes == 0) { - return; - } - - - $image = imageapi_image_open($tmp_file_name); - - switch ($op) { - case 'scale': - if (!empty($_GET['height']) || !empty($_GET['width'])) { - imageapi_image_scale($image, $_GET['width'], $_GET['height']); - } - case 'centerscale': - if (!empty($_GET['height']) && !empty($_GET['width'])) { - imageapi_image_scale_and_crop($image, $_GET['width'], $_GET['height']); - } - } - imageapi_image_close($image); - $file = file_get_contents($tmp_file_name); - cache_set($cache_key, $file, 'cache', time() + variable_get('fedora_image_blocks_cache_time', 3600)); - file_delete($tmp_file_name); - } - else { - $file = $file->data; - } - - - header("Content-type: $mimetype"); - header('Content-Disposition: attachment; filename="' . $dsid . '.' . $ext . '"'); - echo $file; - - -// return "$numbytes bytes written to ".sys_get_temp_dir()."$pid_$dsid.$ext\n"; -} - -/** - * Implementation of hook_form_alter - * - * @param unknown_type $form - * @param unknown_type $form_state - * @param unknown_type $form_id - */ -/* - function fedora_imageapi_form_alter( &$form, $form_state, $form_id) { - - switch ( $form_id ) { - case 'fedora_repository_admin': - - $fedora_base_url = $form['fedora_base_url']['#default_value']; - - $fedora_server_url = substr($fedora_base_url,0,strpos($fedora_base_url,'/',7)); - // Add the Djatoka server location. Set it to default to the same server as fedora. - $form['djatoka_server_url'] = array ( - '#type' => 'textfield', - '#title' => '<h3>'.t('Fedora Image API Module').'</h3><br />'.t('aDORe Djatoka image server resolver URL'), - '#default_value' => variable_get('djatoka_server_url', $fedora_server_url.'/adore-djatoka/resolver' ), - '#description' => t('The location of your <a href="http://african.lanl.gov/aDORe/projects/djatoka/" title="aDORe Djatoka Home Page">aDORe Djatoka</a> image server, if you have one installed.'), - '#weight' => 1, - ); - $form['openlayers_server_url'] = array( - '#type' => 'textfield', - '#title' => t('OpenLayers servlet URL'), - '#default_value' => variable_get('openlayers_server_url', $fedora_server_url.'/islandora/OpenLayers'), - '#description' => t('URL of your installation of the <a href="http://openlayers.org/">OpenLayers</a> servlet, if you have one.'), - '#weight' => 1, - ); - $form['buttons']['#weight'] = 2; - break; - } - } - - function show_openlayers_viewer() { - $output = 'Hi.'; - - return $output; - } - */ From 7b550d7346bb73029f084aca9a791581dd4982e1 Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Tue, 11 Oct 2011 11:01:11 -0300 Subject: [PATCH 07/46] Modified BatchIngest to allow collections without metadata to be batch ingested --- BatchIngest.inc | 49 +++++++++++++++++------------------------- CollectionClass.inc | 1 + xsl/sparql_to_html.xsl | 5 +++-- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/BatchIngest.inc b/BatchIngest.inc index 31daa608..ed768294 100644 --- a/BatchIngest.inc +++ b/BatchIngest.inc @@ -1,13 +1,12 @@ <?php - /** * batch creation form submit * @global type $user * @param array $form * @param array $form_state * @param array $content_models -*/ + */ function batch_creation_form(&$form_state, $collection_pid, $content_models) { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); @@ -35,13 +34,6 @@ function batch_creation_form(&$form_state, $collection_pid, $content_models) { '#type' => 'hidden', '#value' => $mappings, ); - $form['metadata_type'] = array( - '#title' => "Choose Metadata Type", - '#type' => 'radios', - '#options' => array('MODS' => 'MODS', "DC" => "DUBLIN CORE"), - '#required' => true, - '#description' => t("Select primary metadata schema"), - ); $form['content_model'] = array( '#title' => "Choose content model to be associated with objects ingested", '#type' => 'select', @@ -70,8 +62,7 @@ function batch_creation_form(&$form_state, $collection_pid, $content_models) { /** * @param array $form * @param array $form_state -*/ - + */ function batch_creation_form_validate($form, &$form_state) { $fieldName = 'file-location'; @@ -155,9 +146,7 @@ function batch_creation_form_submit($form, &$form_state) { foreach ($file_list as $label => $object_files) { - if ($object_files['xml']) { - $batch['operations'][] = array('create_batch_objects', array($label, $content_model, $object_files, $collection_pid, $namespace, $metadata)); - } + $batch['operations'][] = array('create_batch_objects', array($label, $content_model, $object_files, $collection_pid, $namespace, $metadata)); } $batch['operations'][] = array('recursive_directory_delete', array($tmpDir)); batch_set($batch); @@ -173,28 +162,33 @@ function batch_creation_form_submit($form, &$form_state) { * @param <string> $namespace * @param <string> $metadata */ - - function create_batch_objects($label, $content_model, $object_files, $collection_pid, $namespace, $metadata) { module_load_include('inc', 'fedora_repository', 'ContentModel'); module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_reppository', 'api/fedora_item'); + $cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM'); $allowedMimeTypes = $cm->getMimetypes(); $mime_helper = new MimeClass(); $pid = fedora_item::get_next_PID_in_namespace($namespace); - module_load_include('inc', 'fedora_reppository', 'api/fedora_item'); + $item = Fedora_item::ingest_new_item($pid, 'A', $label, $owner); $item->add_relationship('hasModel', $content_model, FEDORA_MODEL_URI); $item->add_relationship('isMemberOfCollection', $collection_pid); - if ($metadata == 'DC') { - $dc_xml = file_get_contents($object_files['xml']); - $item->modify_datastream_by_value($dc_xml, 'DC', "Dublin Core", 'text/xml'); - } - if ($metadata == 'MODS') { - $mods_xml = file_get_contents($object_files['xml']); - $item->add_datastream_from_string($mods_xml, 'MODS'); - $dc_xml = batch_create_dc_from_mods($mods_xml); + if ($object_files['xml']) { + $data = file_get_contents($object_files['xml']); + $xml = simplexml_load_string($data); + $identifier = $xml->getName(); + if ($identifier == 'dc') { + $item->modify_datastream_by_value($data, 'DC', "Dublin Core", 'text/xml'); + } + if ($identifier == 'mods') { + $item->add_datastream_from_string($mods_xml, 'MODS'); + $dc_xml = batch_create_dc_from_mods($mods_xml); + $item->modify_datastream_by_value($dc_xml, 'DC', "Dublin Core", 'text/xml'); + } } + unset($object_files['xml']); $use_primary = TRUE; foreach ($object_files as $ext => $filename) { @@ -206,7 +200,7 @@ function create_batch_objects($label, $content_model, $object_files, $collection $item->purge("$pid $label not ingested. $file_mimetype not permitted in objects associated with $content_model"); continue; } - $ds_label = $use_primary ? $cm->getDatastreamNameDSID():$ext; + $ds_label = $use_primary ? $cm->getDatastreamNameDSID() : $ext; $item->add_datastream_from_file($filename, $ds_label); $use_primary = FALSE; @@ -223,9 +217,6 @@ function create_batch_objects($label, $content_model, $object_files, $collection * @param <string> $mods_xml * @return <string> */ - - - function batch_create_dc_from_mods($mods_xml) { $path = drupal_get_path('module', 'fedora_repository'); module_load_include('inc', 'fedora_repository', 'ObjectHelper'); diff --git a/CollectionClass.inc b/CollectionClass.inc index 4251eea4..4216733d 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -623,6 +623,7 @@ class CollectionClass { $collectionName = $collection; + if (!$pageNumber) { $pageNumber = 1; } diff --git a/xsl/sparql_to_html.xsl b/xsl/sparql_to_html.xsl index 0c037f3e..71f94a30 100644 --- a/xsl/sparql_to_html.xsl +++ b/xsl/sparql_to_html.xsl @@ -8,7 +8,7 @@ <xsl:value-of select="$path"/> </xsl:variable> <xsl:variable name="thisPid" select="$collectionPid"/> - <xsl:variable name="thisTitle" select="$collectionTitle"/> + <xsl:variable name="thisTitle" select="Collection"/> <xsl:variable name="size" select="20"/> <xsl:variable name="page" select="$hitPage"/> <xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> @@ -161,6 +161,7 @@ <xsl:with-param name="from" select="'_'"/> <xsl:with-param name="to" select="' '"/> </xsl:call-template> + </xsl:variable> <xsl:variable name="cleanTitle"> <xsl:value-of select="php:functionString('fedora_repository_urlencode_string', $newTitle)"/> @@ -168,7 +169,7 @@ <xsl:variable name="linkUrl"> <xsl:choose> <xsl:when test="($CONTENTMODEL='islandora:collectionCModel')"> - <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/> + <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="'collection'"/> </xsl:when> <xsl:otherwise> <!--the below is an example of going straight to a datastream instead of the details page. From e6e30cb5014d502d957a5d98138dc23e6c7ae6e0 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Tue, 11 Oct 2011 11:04:17 -0300 Subject: [PATCH 08/46] Changed the configuration name --- formClass.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/formClass.inc b/formClass.inc index 93b68316..a7abe947 100644 --- a/formClass.inc +++ b/formClass.inc @@ -25,7 +25,7 @@ class formClass { $items = array(); $items['admin/settings/islandora_repository'] = array( - 'title' => t('Configure Islandora'), + 'title' => t('Islandora Configure'), 'description' => t('Enter the Islandora Collection information here'), 'page callback' => 'drupal_get_form', 'page arguments' => array('islandora_repository_admin'), From 2f8563224a220329f5d1d2dfeacb466df67a1546 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Tue, 11 Oct 2011 11:09:19 -0300 Subject: [PATCH 09/46] Changed from islandora top to islandora root --- .../foxml/{islandora-top.xml => islandora-root.xml} | 8 ++++---- tests/README_TESTING.txt | 2 +- tests/fedora_repository.test | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename installer_files/foxml/{islandora-top.xml => islandora-root.xml} (97%) diff --git a/installer_files/foxml/islandora-top.xml b/installer_files/foxml/islandora-root.xml similarity index 97% rename from installer_files/foxml/islandora-top.xml rename to installer_files/foxml/islandora-root.xml index 5d8c69b3..8c7fa1ac 100644 --- a/installer_files/foxml/islandora-top.xml +++ b/installer_files/foxml/islandora-root.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<foxml:digitalObject PID="islandora:top" VERSION="1.1" xmlns:foxml="info:fedora/fedora-system:def/foxml#" +<foxml:digitalObject PID="islandora:root" VERSION="1.1" xmlns:foxml="info:fedora/fedora-system:def/foxml#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd"> <foxml:objectProperties> <foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/> @@ -97,7 +97,7 @@ xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> <dc:title>Islandora Top-Level Collection</dc:title> - <dc:identifier>islandora:top</dc:identifier> + <dc:identifier>islandora:root</dc:identifier> </oai_dc:dc> </foxml:xmlContent> </foxml:datastreamVersion> @@ -107,7 +107,7 @@ ID="RELS-EXT.0" LABEL="RDF Statements about this object" MIMETYPE="application/rdf+xml" SIZE="314"> <foxml:xmlContent> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> - <rdf:Description rdf:about="info:fedora/islandora:top"> + <rdf:Description rdf:about="info:fedora/islandora:root"> <hasModel rdf:resource="info:fedora/islandora:collectionCModel" xmlns="info:fedora/fedora-system:def/model#"/> </rdf:Description> </rdf:RDF> @@ -144,7 +144,7 @@ </foxml:datastream> <foxml:datastream CONTROL_GROUP="M" ID="TN" STATE="A" VERSIONABLE="true"> <foxml:datastreamVersion CREATED="2010-10-11T23:08:15.373Z" ID="TN.0" LABEL="Thumbnail.png" MIMETYPE="image/png" SIZE="16243"> - <foxml:contentLocation REF="http://localhost:8080/fedora/get/islandora:top/TN/2010-10-11T23:08:15.373Z" TYPE="INTERNAL_ID"/> + <foxml:contentLocation REF="http://localhost:8080/fedora/get/islandora:root/TN/2010-10-11T23:08:15.373Z" TYPE="INTERNAL_ID"/> </foxml:datastreamVersion> </foxml:datastream> </foxml:digitalObject> diff --git a/tests/README_TESTING.txt b/tests/README_TESTING.txt index a88a244c..f38af855 100644 --- a/tests/README_TESTING.txt +++ b/tests/README_TESTING.txt @@ -5,7 +5,7 @@ Fedora Installation The test sets up the islandora module with the default server settings. This means it will expect a Fedora server to be running on localhost:8080 with the usual defaults. The tests also expect the Islandora demo objects, i.e., -islandora:top, islandora:demos collections, etc. to be installed. (Go to +islandora:root, islandora:demos collections, etc. to be installed. (Go to Administer -> Site Configuration -> Fedora Colleciton List and click the Install Demos tab and follow the instructions.) diff --git a/tests/fedora_repository.test b/tests/fedora_repository.test index 2bfab51f..d5e59bc8 100644 --- a/tests/fedora_repository.test +++ b/tests/fedora_repository.test @@ -45,11 +45,11 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $pid_list = array(); // Create a collection for ingesting PDF content model objects. - //$this->drupalGet('fedora/ingestObject/islandora:top/Islandora%20Top-Level%20Collection'); + //$this->drupalGet('fedora/ingestObject/islandora:root/Islandora%20Top-Level%20Collection'); $ingest_form = array(); $ingest_form['models'] = 'islandora:collectionCModel/ISLANDORACM'; - $this->drupalPost('fedora/ingestObject/islandora:top/Islandora%20Top-Level%20Collection', $ingest_form, 'Next'); + $this->drupalPost('fedora/ingestObject/islandora:root/Islandora%20Top-Level%20Collection', $ingest_form, 'Next'); // Add a sample PDF object via the web ingest form. // Required fields are file location, dc:title and dc:description @@ -67,7 +67,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $ingest_form = array(); $ingest_form['models'] = 'islandora:collectionCModel/ISLANDORACM'; - $this->drupalPost('fedora/ingestObject/islandora:top/Islandora%20Top-Level%20Collection', $ingest_form, 'Next'); + $this->drupalPost('fedora/ingestObject/islandora:root/Islandora%20Top-Level%20Collection', $ingest_form, 'Next'); // Required fields are file location, dc:title and dc:description $ingest_form_step_2 = array(); $ingest_form_step_2['dc:title'] = $this->randomName(32); From 8a80b1913488e6f3f622a81cee4009ac3a6ba0c6 Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Tue, 11 Oct 2011 12:16:19 -0300 Subject: [PATCH 10/46] Added installation methods for xml_forms and associations --- fedora_repository.solutionpacks.inc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index de4ce137..fb09528d 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -173,3 +173,30 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) { } batch_set($batch); } + +function solution_pack_add_form($form_name, $form_xml) { + $result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name)); + if (!$result) { + $object = new stdClass(); + $object->name = $form_name; + $object->form = $form_xml; + $result = drupal_write_record('xml_forms', $object); + drupal_set_message("Added $name"); + } +} + +function solution_pack_add_form_association($content_model, $form_name) { + $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', + $content_model, $form_name)); + if (!$result) { + $object = new stdClass(); + $object->content_model = $content_model; + $object->form_name = $form_name; + $object->dsid = 'MODS'; + $object->title_field = "['titleInfo']['title']"; + $object->transform = 'mods_to_dc.xsl'; + $result = drupal_write_record('islandora_content_model_forms', $object); + drupal_set_message("Added association between $content_model$name"); + } +} + From 27d9520519e3ab8115cd97247ef43e106a87084b Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Tue, 11 Oct 2011 13:34:45 -0300 Subject: [PATCH 11/46] Swiched back to fedora_repository --- BatchIngest.inc | 20 +- CollectionClass.inc | 42 +- CollectionManagement.inc | 24 +- CollectionPolicy.inc | 18 +- ContentModel.inc | 50 +-- ObjectHelper.inc | 68 +-- SearchClass.inc | 30 +- SecurityClass.inc | 2 +- XMLDatastream.inc | 8 +- api/fedora_collection.inc | 14 +- api/fedora_export.inc | 4 +- api/fedora_item.inc | 10 +- api/fedora_utils.inc | 12 +- ..._repository.info => fedora_repository.info | 0 ...itory.install => fedora_repository.install | 8 +- ...ository.module => fedora_repository.module | 388 +++++++++--------- ...inc => fedora_repository.solutionpacks.inc | 20 +- formClass.inc | 78 ++-- islandoracm.xsd | 10 +- plugins/CollectionFormBuilder.inc | 4 +- plugins/DarwinCore.inc | 8 +- plugins/DemoFormBuilder.inc | 6 +- plugins/DocumentConverter.inc | 2 +- plugins/Exiftool.inc | 2 +- plugins/FedoraObjectDetailedContent.inc | 12 +- plugins/Flv.inc | 2 +- plugins/FlvFormBuilder.inc | 6 +- plugins/FormBuilder.inc | 8 +- plugins/ImageManipulation.inc | 2 +- plugins/ModsFormBuilder.inc | 16 +- plugins/PersonalCollectionClass.inc | 2 +- plugins/QtFormBuilder.php | 4 +- plugins/Refworks.inc | 12 +- plugins/ShowStreamsInFieldSets.inc | 18 +- ...ora_imageapi.info => fedora_imageapi.info} | 2 +- ...imageapi.module => fedora_imageapi.module} | 8 +- plugins/herbarium.inc | 28 +- plugins/map_viewer.inc | 10 +- plugins/qt_viewer.inc | 6 +- plugins/slide_viewer.inc | 6 +- plugins/tagging_form.inc | 22 +- tests/README_TESTING.txt | 2 +- tests/fedora_repository.test | 20 +- 43 files changed, 507 insertions(+), 507 deletions(-) rename islandora_repository.info => fedora_repository.info (100%) rename islandora_repository.install => fedora_repository.install (92%) rename islandora_repository.module => fedora_repository.module (81%) rename islandora_repository.solutionpacks.inc => fedora_repository.solutionpacks.inc (84%) rename plugins/{islandora_imageapi.info => fedora_imageapi.info} (82%) rename plugins/{islandora_imageapi.module => fedora_imageapi.module} (89%) diff --git a/BatchIngest.inc b/BatchIngest.inc index f3d63cc0..31daa608 100644 --- a/BatchIngest.inc +++ b/BatchIngest.inc @@ -9,8 +9,8 @@ * @param array $content_models */ function batch_creation_form(&$form_state, $collection_pid, $content_models) { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); - module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); $cm_options = array(); $name_mappings = array(); foreach ($content_models as $content_model) { @@ -95,8 +95,8 @@ function batch_creation_form_validate($form, &$form_state) { } function batch_creation_form_submit($form, &$form_state) { - module_load_include('inc', 'islandora_repository', 'ContentModel'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); global $user; $namespace_mappings = array(); $content_model = $form_state['values']['content_model']; @@ -150,7 +150,7 @@ function batch_creation_form_submit($form, &$form_state) { $batch = array( 'title' => 'Ingesting Objects', 'operations' => array(), - 'file' => drupal_get_path('module', 'islandora_repository') . '/BatchIngest.inc', + 'file' => drupal_get_path('module', 'fedora_repository') . '/BatchIngest.inc', ); @@ -176,8 +176,8 @@ function batch_creation_form_submit($form, &$form_state) { function create_batch_objects($label, $content_model, $object_files, $collection_pid, $namespace, $metadata) { - module_load_include('inc', 'islandora_repository', 'ContentModel'); - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); $cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM'); $allowedMimeTypes = $cm->getMimetypes(); $mime_helper = new MimeClass(); @@ -227,9 +227,9 @@ function create_batch_objects($label, $content_model, $object_files, $collection function batch_create_dc_from_mods($mods_xml) { - $path = drupal_get_path('module', 'islandora_repository'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + $path = drupal_get_path('module', 'fedora_repository'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); if ($xmlstr == NULL || strlen($xmlstr) < 5) { return " "; diff --git a/CollectionClass.inc b/CollectionClass.inc index df438aca..4251eea4 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -29,7 +29,7 @@ class CollectionClass { */ function __construct($pid = NULL) { if (!empty($pid)) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $this->collectionObject = new ObjectHelper($pid); $this->pid = $pid; } @@ -45,7 +45,7 @@ class CollectionClass { * @return type */ function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); if (!isset($itqlquery)) { // $query_string = $objectHelper->getStream($pid, 'QUERY', 0); @@ -65,8 +65,8 @@ class CollectionClass { * @return type */ function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); if (!isset($limit)) { $limit = 1000; } @@ -74,7 +74,7 @@ class CollectionClass { $offset = 0; } global $user; - if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); return ' '; } @@ -101,7 +101,7 @@ class CollectionClass { $query_string = htmlentities(urlencode($query_string)); $content = ''; - $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=Sparql&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query_string; $content .= do_curl($url); @@ -156,7 +156,7 @@ class CollectionClass { * @return type */ function getStream($pid, $dsid, $showError = 1) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new fedora_item($pid); return isset($item->datastreams[$dsid]) ? $item->get_datastream_dissemination($dsid) : NULL; } @@ -223,7 +223,7 @@ class CollectionClass { module_load_include('inc', 'Fedora_Repository', 'ConnectionHelper'); $pidNameSpace = $this->getPidNameSpace($pid, $dsid); $pname = substr($pidNameSpace, 0, strpos($pidNameSpace, ":")); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); return Fedora_Item::get_next_pid_in_namespace($pname); } @@ -339,7 +339,7 @@ class CollectionClass { } } // module_load_include( $phpFile, 'Fedora_Repository', ' '); - require_once(drupal_get_path('module', 'islandora_repository') . '/' . $phpFile); + require_once(drupal_get_path('module', 'fedora_repository') . '/' . $phpFile); $thisClass = new $phpClass (); $returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext); if (!$returnValue) { @@ -409,7 +409,7 @@ class CollectionClass { $ingest_form = $xml->ingest_form; //should only be one $drupal_module = strip_tags($ingest_form->form_builder_method->module->asXML()); if (empty($drupal_module)) { - $drupal_module = 'islandora_repository'; + $drupal_module = 'fedora_repository'; } $phpFile = strip_tags($ingest_form->form_builder_method->file->asXML()); $phpClass = strip_tags($ingest_form->form_builder_method->class_name->asXML()); @@ -437,11 +437,11 @@ class CollectionClass { 'name' => variable_get('fedora_admin_user', 'fedoraAdmin') ); $admin_user = user_load($username); - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); $connectionHelper = new ConnectionHelper(); try { $soapClient = $connectionHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); - $pidNameSpace = variable_get('islandora_repository_pid', 'vre:'); + $pidNameSpace = variable_get('fedora_repository_pid', 'vre:'); $pidNameSpace = substr($pidNameSpace, 0, strpos($pidNameSpace, ":")); $params = array( 'numPIDs' => '', @@ -460,7 +460,7 @@ class CollectionClass { $personal_collection_pid = array( 'fedora_personal_pid' => $pid ); - module_load_include('inc', 'islandora_repository', 'plugins/PersonalCollectionClass'); + module_load_include('inc', 'fedora_repository', 'plugins/PersonalCollectionClass'); $personalCollectionClass = new PersonalCollectionClass(); if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) { drupal_set_message("Did not create a personal collection object for !u", array('!u' => $user->name)); @@ -480,7 +480,7 @@ class CollectionClass { * @return type */ function getXslContent($pid, $path, $canUseDefault = TRUE) { - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); $collectionClass = new CollectionClass(); $xslContent = $collectionClass->getCollectionViewStream($pid); if (!$xslContent && $canUseDefault) { //no xslt so we will use the default sent with the module @@ -497,9 +497,9 @@ class CollectionClass { * @return string */ function showFieldSets($page_number) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'CollectionManagement'); - module_load_include('inc', 'islandora_repository', 'BatchIngest'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'CollectionManagement'); + module_load_include('inc', 'fedora_repository', 'BatchIngest'); global $base_url; $tabset = array(); global $user; @@ -514,7 +514,7 @@ class CollectionClass { $collection_items = $this->renderCollection($results, $this->pid, NULL, NULL, $page_number); $collection_item = new Fedora_Item($this->pid); // Check the form post to see if we are in the middle of an ingest operation. - $show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'islandora_repository_ingest_form'); + $show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form'); $add_to_collection = $this->getIngestInterface(); $show_batch_tab = TRUE; @@ -586,7 +586,7 @@ class CollectionClass { $allow = fedora_fesl_check_roles($this->pid, 'write'); } if ($allow) { - $ingestObject = drupal_get_form('islandora_repository_ingest_form', $this->pid); + $ingestObject = drupal_get_form('fedora_repository_ingest_form', $this->pid); } } } @@ -608,7 +608,7 @@ class CollectionClass { * @return type */ function renderCollection($content, $pid, $dsId, $collection, $pageNumber = NULL) { - $path = drupal_get_path('module', 'islandora_repository'); + $path = drupal_get_path('module', 'fedora_repository'); global $base_url; $collection_pid = $pid; //we will be changing the pid later maybe $objectHelper = new ObjectHelper(); @@ -628,7 +628,7 @@ class CollectionClass { } if (!isset($collectionName)) { - $collectionName = variable_get('islandora_repository_name', 'Collection'); + $collectionName = variable_get('fedora_repository_name', 'Collection'); } $xslContent = $this->getXslContent($pid, $path); diff --git a/CollectionManagement.inc b/CollectionManagement.inc index bb89a9fd..83bb9952 100644 --- a/CollectionManagement.inc +++ b/CollectionManagement.inc @@ -8,7 +8,7 @@ * @return array */ function collection_management_form(&$form_state, $this_collection_pid, $content_models) { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $restricted = FALSE; if (variable_get('fedora_namespace_restriction_enforced', true)) { $restricted = true; @@ -20,8 +20,8 @@ function collection_management_form(&$form_state, $this_collection_pid, $content } } } - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); - module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); $item = new Fedora_Item($this_collection_pid); $collection_name = $item->objectProfile->objLabel; $new_content_models = get_content_models_as_option_array(); @@ -224,8 +224,8 @@ function collection_management_form(&$form_state, $this_collection_pid, $content */ function collection_management_form_validate($form, &$form_state) { if ($form_state['clicked_button']['#id'] == 'create_class') { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $pid = $form_state['values']['new_collection_pid']; $item = new fedora_item($pid); if ($item->exists()) { @@ -252,14 +252,14 @@ function collection_management_form_validate($form, &$form_state) { * @param type $form_state */ function collection_management_form_submit($form, &$form_state) { - module_load_include('inc', 'islandora_repository', 'api/fedora_collection'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/dublin_core'); + module_load_include('inc', 'fedora_repository', 'api/fedora_collection'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/dublin_core'); global $user; $collection_pid = $form_state['values']['parent_collection']; $policy = CollectionPolicy::loadFromCollection($collection_pid, TRUE); if ($form_state['clicked_button']['#id'] == 'create_class') { - $module_path = drupal_get_path('module', 'islandora_repository'); + $module_path = drupal_get_path('module', 'fedora_repository'); $thumbnail = drupal_get_path('module', 'Fedora_Repository') . '/images/Crystal_Clear_filesystem_folder_grey.png'; $new_collection_pid = $form_state['values']['new_collection_pid']; $new_collection_label = $form_state['values']['collection_name']; @@ -345,7 +345,7 @@ function collection_management_form_submit($form, &$form_state) { $query = htmlentities(urlencode($query)); $content = ''; - $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=csv&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query; $content .= do_curl($url); $results = explode("\n", $content); @@ -370,7 +370,7 @@ function collection_management_form_submit($form, &$form_state) { $batch = array( 'title' => "Deleting Objects from $name", 'operations' => array(), - 'file' => drupal_get_path('module', 'islandora_repository') . '/CollectionManagement.inc', + 'file' => drupal_get_path('module', 'fedora_repository') . '/CollectionManagement.inc', ); @@ -389,7 +389,7 @@ function collection_management_form_submit($form, &$form_state) { * @param <type> $pid */ function delete_objects_as_batch($pid) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $name = $user->name; $item_to_delete = new Fedora_Item($pid); $models = $item_to_delete->get_models(); diff --git a/CollectionPolicy.inc b/CollectionPolicy.inc index 0612a733..b801eaff 100644 --- a/CollectionPolicy.inc +++ b/CollectionPolicy.inc @@ -4,7 +4,7 @@ * @file * Collection Policy Class */ -module_load_include('inc', 'islandora_repository', 'XMLDatastream'); +module_load_include('inc', 'fedora_repository', 'XMLDatastream'); /** * Collection Policy class ?? @@ -36,7 +36,7 @@ class CollectionPolicy extends XMLDatastream { */ static function loadFromCollection($pid, $preFetch=TRUE) { $ret = FALSE; - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); try { if (self::valid_pid($pid)) { @@ -80,7 +80,7 @@ class CollectionPolicy extends XMLDatastream { $rootEl = $cp->xml->getElementsByTagName('collection_policy')->item(0); $rootEl->setAttribute('name', $name); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cp->dumpXml(), $cpDsid, $name, 'text/xml', 'X'); $ret = $cp; @@ -110,7 +110,7 @@ class CollectionPolicy extends XMLDatastream { $cp = new CollectionPolicy($newDom, $pid, $cpDsid); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cp->dumpXml(), $cpDsid, $name, 'text/xml', 'X'); $ret = $cp; @@ -137,7 +137,7 @@ class CollectionPolicy extends XMLDatastream { public static function ingestBlankPolicy($pid, $name, $policyDsid, $model_pid, $model_namespace, $relationship, $searchField, $searchValue) { $ret = FALSE; if (($cp = self::loadFromCollection($pid)) === FALSE) { //removed second, non-existant variable - module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); if (($cm = ContentModel::loadFromModel($model_pid)) !== FALSE && $cm->validate()) { $newDom = new DOMDocument('1.0', 'utf-8'); $newDom->formatOutput = TRUE; @@ -171,7 +171,7 @@ class CollectionPolicy extends XMLDatastream { $cp = new CollectionPolicy($newDom, $pid, $policyDsid); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); @@ -299,7 +299,7 @@ class CollectionPolicy extends XMLDatastream { $this->staging_area = trim($stagingEl->item(0)->nodeValue); } elseif ($recurse) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($this->pid); $rels = $item->get_relationships(); if (count($rels) > 0) { @@ -373,7 +373,7 @@ class CollectionPolicy extends XMLDatastream { $pname = substr($namespace, 0, strpos($namespace, ":")); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $ret = Fedora_Item::get_next_pid_in_namespace($pname); } return $ret; @@ -443,7 +443,7 @@ class CollectionPolicy extends XMLDatastream { if ($recurse && count($ret) == 0) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($this->pid); $rels = $item->get_relationships(); if (count($rels) > 0) { diff --git a/ContentModel.inc b/ContentModel.inc index 66bd9569..b1f28074 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -8,7 +8,7 @@ * @file * Content Model Class */ -module_load_include('inc', 'islandora_repository', 'XMLDatastream'); +module_load_include('inc', 'fedora_repository', 'XMLDatastream'); /** * Conent Model ?? @@ -41,7 +41,7 @@ class ContentModel extends XMLDatastream { public static function loadFromObject($pid) { $ret = FALSE; if (self::valid_pid($pid)) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $content_models = $objectHelper->get_content_models_list($pid); @@ -73,7 +73,7 @@ class ContentModel extends XMLDatastream { $rootEl = $cm->xml->getElementsByTagName('content_model')->item(0); $rootEl->setAttribute('name', $name); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cm->dumpXml(), $modelDsid, $name, 'text/xml', 'X'); $ret = $cm; @@ -102,7 +102,7 @@ class ContentModel extends XMLDatastream { $cm = new ContentModel($newDom, $pid, $modelDsid); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cm->dumpXml(), $modelDsid, $name, 'text/xml', 'X'); $ret = $cm; @@ -172,7 +172,7 @@ class ContentModel extends XMLDatastream { $cm = new ContentModel($newDom, $pid, $modelDsid); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $fedoraItem = new Fedora_Item($pid); $fedoraItem->add_datastream_from_string($cm->dumpXml(), $modelDsid, $name, 'text/xml', 'X'); $ret = $cm; @@ -199,7 +199,7 @@ class ContentModel extends XMLDatastream { */ public static function loadFromModel($pid, $dsid = NULL, $pid_namespace = NULL, $name = NULL) { $ret = FALSE; - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); try { if (self::valid_pid($pid)) { $fedoraItem = new Fedora_Item($pid); @@ -436,7 +436,7 @@ class ContentModel extends XMLDatastream { and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) order by $title'; - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); $collectionHelper = new CollectionClass(); $xml = simplexml_load_string($collectionHelper->getRelatedItems($this->pid, $query)); @@ -1070,7 +1070,7 @@ class ContentModel extends XMLDatastream { $method = $ingest_form->getElementsByTagName('form_builder_method')->item(0); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Build Ingest Form: file \'' . $path . '\' does not exist.'; } @@ -1110,7 +1110,7 @@ class ContentModel extends XMLDatastream { if ($method->length > 0 && $method->item(0)->getAttribute('dsid') == $dsid) { $method = $method->item(0); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Build Edit Metadata Form: file \'' . $path . '\' does not exist.'; } @@ -1153,7 +1153,7 @@ class ContentModel extends XMLDatastream { if ($method->length > 0) { $method = $method->item(0); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Handle Edit Metadata Form: file \'' . $path . '\' does not exist.'; } @@ -1177,7 +1177,7 @@ class ContentModel extends XMLDatastream { } else { // Assume DC form if none is specified. - module_load_include('inc', 'islandora_repository', 'formClass'); + module_load_include('inc', 'fedora_repository', 'formClass'); $metaDataForm = new formClass(); $ret = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $soap_client); $form_state['storage'] = NULL; @@ -1198,7 +1198,7 @@ class ContentModel extends XMLDatastream { $method = $this->xml->getElementsByTagName('content_model')->item(0)->getElementsByTagName('edit_metadata_method'); if ($method->length > 0) { $method = $method->item(0); - $ret = array('module' => $method->getAttribute('module') == '' ? 'islandora_repository' : $method->getAttribute('module'), + $ret = array('module' => $method->getAttribute('module') == '' ? 'fedora_repository' : $method->getAttribute('module'), 'file' => $method->getAttribute('file'), 'class' => $method->getAttribute('class'), 'method' => $method->getAttribute('method'), @@ -1282,7 +1282,7 @@ class ContentModel extends XMLDatastream { } } $module = $addMethod->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $addMethod->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $addMethod->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Execute Add Datastream Methods: file \'' . $path . '\' does not exist.'; } @@ -1351,9 +1351,9 @@ class ContentModel extends XMLDatastream { if (!$preview || isset($param_array['preview'])) { $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); - if (!file_exists($path) || substr_compare($path, 'islandora_repository/', -strlen('islandora_repository/'), strlen('islandora_repository/')) === 0) { + if (!file_exists($path) || substr_compare($path, 'fedora_repository/', -strlen('fedora_repository/'), strlen('fedora_repository/')) === 0) { self::$errors[] = 'Execute Ingest Rules: file \'' . $path . '\' does not exist.'; $ret = FALSE; } @@ -1399,7 +1399,7 @@ class ContentModel extends XMLDatastream { if ($this->validate()) { $method = $this->xml->getElementsByTagName('ingest_form')->item(0)->getElementsByTagName('form_builder_method')->item(0); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Execute Form Handler: file \'' . $path . '\' does not exist.'; } @@ -1469,7 +1469,7 @@ class ContentModel extends XMLDatastream { for ($j = 0; $j < $dispMethods->length; $j++) { $method = $dispMethods->item($j); $module = $method->getAttribute('module'); - $path = drupal_get_path('module', !empty($module) ? $module : 'islandora_repository') . '/' . $method->getAttribute('file'); + $path = drupal_get_path('module', !empty($module) ? $module : 'fedora_repository') . '/' . $method->getAttribute('file'); if (!file_exists($path)) { self::$errors[] = 'Execute Form Handler: file \'' . $path . '\' does not exist.'; } @@ -1588,7 +1588,7 @@ class ContentModel extends XMLDatastream { $ret = array(); $dispMethods = $ds->getElementsByTagName('display_method'); for ($i = 0; $i < $dispMethods->length; $i++) { - $ret[] = array('module' => $dispMethods->item($i)->getAttribute('module') == '' ? 'islandora_repository' : $dispMethods->item($i)->getAttribute('module'), + $ret[] = array('module' => $dispMethods->item($i)->getAttribute('module') == '' ? 'fedora_repository' : $dispMethods->item($i)->getAttribute('module'), 'file' => $dispMethods->item($i)->getAttribute('file'), 'class' => $dispMethods->item($i)->getAttribute('class'), 'method' => $dispMethods->item($i)->getAttribute('method'), @@ -1694,7 +1694,7 @@ class ContentModel extends XMLDatastream { $found = FALSE; $dispMethods = $ds->getElementsByTagName('display_method'); for ($i = 0; !$found && $i < $dispMethods->length; $i++) { - if ($module == ($dispMethods->item($i)->getAttribute('module') == '' ? 'islandora_repository' : $dispMethods->item($i)->getAttribute('module')) && + if ($module == ($dispMethods->item($i)->getAttribute('module') == '' ? 'fedora_repository' : $dispMethods->item($i)->getAttribute('module')) && $file == $dispMethods->item($i)->getAttribute('file') && $class == $dispMethods->item($i)->getAttribute('class') && $method == $dispMethods->item($i)->getAttribute('method')) { @@ -1732,7 +1732,7 @@ class ContentModel extends XMLDatastream { $found = FALSE; $dispMethods = $ds->getElementsByTagName('display_method'); for ($i = 0; !$found && $i < $dispMethods->length; $i++) { - if ($module == ($dispMethods->item($i)->getAttribute('module') == '' ? 'islandora_repository' : $dispMethods->item($i)->getAttribute('module') == '') && + if ($module == ($dispMethods->item($i)->getAttribute('module') == '' ? 'fedora_repository' : $dispMethods->item($i)->getAttribute('module') == '') && $file == $dispMethods->item($i)->getAttribute('file') && $class == $dispMethods->item($i)->getAttribute('class') && $method == $dispMethods->item($i)->getAttribute('method')) { @@ -1785,7 +1785,7 @@ class ContentModel extends XMLDatastream { if (($ds = $this->getDSModel($ds)) !== FALSE) { $addDsMethod = $ds->getElementsByTagName('add_datastream_method'); if ($addDsMethod !== FALSE && $addDsMethod->length > 0) { - $ret = array('module' => $addDsMethod->item(0)->getAttribute('module') == '' ? 'islandora_repository' : $addDsMethod->item(0)->getAttribute('module'), + $ret = array('module' => $addDsMethod->item(0)->getAttribute('module') == '' ? 'fedora_repository' : $addDsMethod->item(0)->getAttribute('module'), 'file' => $addDsMethod->item(0)->getAttribute('file'), 'class' => $addDsMethod->item(0)->getAttribute('class'), 'method' => $addDsMethod->item(0)->getAttribute('method'), @@ -1936,7 +1936,7 @@ class ContentModel extends XMLDatastream { $methods = $rule->getElementsByTagName('ingest_methods')->item(0)->getElementsByTagName('ingest_method'); $found = FALSE; for ($i = 0; $found === FALSE && $i < $methods->length; $i++) { - if (($methods->item($i)->getAttribute('module') == '' ? 'islandora_repository' : $methods->item($i)->getAttribute('module')) == $module && + if (($methods->item($i)->getAttribute('module') == '' ? 'fedora_repository' : $methods->item($i)->getAttribute('module')) == $module && $methods->item($i)->getAttribute('file') == $file && $methods->item($i)->getAttribute('class') == $class && $methods->item($i)->getAttribute('method') == $method) { @@ -1989,7 +1989,7 @@ class ContentModel extends XMLDatastream { $methodsEl = $rule->getElementsByTagName('ingest_methods')->item(0); $methods = $methodsEl->getElementsByTagName('ingest_method'); for ($i = 0; !$found && $i < $methods->length; $i++) { - if (( trim($methods->item($i)->getAttribute('module')) == $module || (trim($methods->item($i)->getAttribute('module')) == '' && $module == 'islandora_repository')) && trim($methods->item($i)->getAttribute('file')) == $file && trim($methods->item($i)->getAttribute('class')) == $class && trim($methods->item($i)->getAttribute('method')) == $method) { + if (( trim($methods->item($i)->getAttribute('module')) == $module || (trim($methods->item($i)->getAttribute('module')) == '' && $module == 'fedora_repository')) && trim($methods->item($i)->getAttribute('file')) == $file && trim($methods->item($i)->getAttribute('class')) == $class && trim($methods->item($i)->getAttribute('method')) == $method) { $found = $methods->item($i); } } @@ -2077,7 +2077,7 @@ class ContentModel extends XMLDatastream { $methods = $rules->item($i)->getElementsByTagName('ingest_methods')->item(0)->getElementsByTagName('ingest_method'); for ($j = 0; $j < $methods->length; $j++) { - $method = array('module' => $methods->item($j)->getAttribute('module') == '' ? 'islandora_repository' : $methods->item($j)->getAttribute('module'), + $method = array('module' => $methods->item($j)->getAttribute('module') == '' ? 'fedora_repository' : $methods->item($j)->getAttribute('module'), 'file' => $methods->item($j)->getAttribute('file'), 'class' => $methods->item($j)->getAttribute('class'), 'method' => $methods->item($j)->getAttribute('method'), @@ -2157,7 +2157,7 @@ class ContentModel extends XMLDatastream { $ret = FALSE; if ($this->validate()) { $method = $this->xml->getElementsByTagName('ingest_form')->item(0)->getElementsByTagName('form_builder_method')->item(0); - $ret = array('module' => ($method->getAttribute('module') == '' ? 'islandora_repository' : $method->getAttribute('module')), + $ret = array('module' => ($method->getAttribute('module') == '' ? 'fedora_repository' : $method->getAttribute('module')), 'file' => $method->getAttribute('file'), 'class' => $method->getAttribute('class'), 'method' => $method->getAttribute('method'), diff --git a/ObjectHelper.inc b/ObjectHelper.inc index da56852b..9e9995b7 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -33,7 +33,7 @@ class ObjectHelper { */ function ObjectHelper() { drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); $connectionHelper = new ConnectionHelper(); //$this->fedoraUser = $connectionHelper->getUser(); //$this->fedoraPass = $connectionHelper->getPassword(); @@ -56,7 +56,7 @@ class ObjectHelper { */ function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = TRUE) { global $user; - module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); if ($pid == NULL || $dsID == NULL) { drupal_set_message(t("no pid or dsid given to create an object with"), 'error'); return ' '; @@ -69,7 +69,7 @@ class ObjectHelper { return ' '; } - if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t("You do not have access Fedora objects within the attempted namespace."), 'error'); drupal_access_denied(); return ' '; @@ -91,7 +91,7 @@ class ObjectHelper { } } - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($pid); @@ -176,7 +176,7 @@ class ObjectHelper { * for the mimetype in question. */ if ($pos === FALSE) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); $mimeclass = new MimeClass(); $ext = $mimeclass->get_extension($mimeType); $suggestedFileName = "$label.$ext"; @@ -207,7 +207,7 @@ class ObjectHelper { * @return type */ function getCollectionInfo($pid, $query = NULL) { - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); $collectionClass = new CollectionClass(); $results = $collectionClass->getRelatedItems($pid, $query); return $results; @@ -227,12 +227,12 @@ class ObjectHelper { drupal_set_message(t('You must specify an object pid and datastream ID.'), 'error'); return ''; } - if (!islandora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t('You do not have the appropriate permissions'), 'error'); return; } - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new fedora_item($pid); $datastream_list = $item->get_datastreams_list_as_SimpleXML(); if (!isset($datastream_list)) { @@ -262,12 +262,12 @@ class ObjectHelper { drupal_set_message(t('You must specify an object pid and datastream ID.'), 'error'); return ''; } - if (!islandora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(ObjectHelper :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t('You do not have the appropriate permissions'), 'error'); return; } - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new fedora_item($pid); $datastream_list = $item->get_datastreams_list_as_SimpleXML(); if (!isset($datastream_list)) { @@ -291,7 +291,7 @@ class ObjectHelper { */ function create_link_for_ds($pid, $dataStreamValue) { global $base_url; - $path = drupal_get_path('module', 'islandora_repository'); + $path = drupal_get_path('module', 'fedora_repository'); require_once($path . '/api/fedora_item.inc'); $item = new Fedora_Item($pid); @@ -359,8 +359,8 @@ class ObjectHelper { */ function getFormattedDC($item) { global $base_url; - $path = drupal_get_path('module', 'islandora_repository'); - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + $path = drupal_get_path('module', 'fedora_repository'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); $dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC'; $xmlstr = $item->get_datastream_dissemination($dsid); @@ -408,7 +408,7 @@ class ObjectHelper { $ds_list = $item->get_datastreams_list_as_array(); $output = $this->getFormattedDC($item); $dsid = array_key_exists('QDC', $ds_list) ? 'QDC' : 'DC'; - $path = drupal_get_path('module', 'islandora_repository'); + $path = drupal_get_path('module', 'fedora_repository'); //$baseUrl=substr($baseUrl, 0, (strpos($baseUrl, "/")-1)); if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) { @@ -440,12 +440,12 @@ class ObjectHelper { */ function get_formatted_datastream_list($object_pid, $contentModels, &$fedoraItem) { global $fedoraUser, $fedoraPass, $base_url, $user; - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); - $path = drupal_get_path('module', 'islandora_repository'); + $path = drupal_get_path('module', 'fedora_repository'); $dataStreamBody = ''; $fedoraItem = new Fedora_Item($object_pid); @@ -514,7 +514,7 @@ class ObjectHelper { * */ function getStream($pid, $dsid, $showError = FALSE) { - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); $soapHelper = new ConnectionHelper(); try { $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); @@ -548,7 +548,7 @@ class ObjectHelper { * @return array */ function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); $collectionHelper = new CollectionClass(); $pids = array(); $query = 'select $object from <#ri> @@ -593,7 +593,7 @@ class ObjectHelper { * @param type $pid * @return type */ - function islandora_repository_access($op, $pid) { + function fedora_repository_access($op, $pid) { global $user; $returnValue = FALSE; @@ -602,7 +602,7 @@ class ObjectHelper { $namespaceAccess = TRUE; } if ($pid == NULL) { - $pid = variable_get('islandora_repository_pid', 'islandora:root'); + $pid = variable_get('fedora_repository_pid', 'islandora:root'); } $nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $pos = NULL; @@ -632,7 +632,7 @@ class ObjectHelper { * @param $content String */ function parseContent($content, $pid, $dsId, $collection, $pageNumber = NULL) { - $path = drupal_get_path('module', 'islandora_repository'); + $path = drupal_get_path('module', 'fedora_repository'); global $base_url; $collection_pid = $pid; //we will be changing the pid later maybe //module_load_include('php', ''Fedora_Repository'', 'ObjectHelper'); @@ -790,7 +790,7 @@ class ObjectHelper { return NULL; } $output = ''; - module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); if (($cm = ContentModel :: loadFromModel($contentModel)) !== FALSE && $cm->validate()) { $output .= $cm->displayExtraFieldset($pid, $page_number); } @@ -810,7 +810,7 @@ class ObjectHelper { return FALSE; } - module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); if ($dsid != NULL && $pid != NULL && ($cm = ContentModel::loadFromObject($pid)) !== FALSE) { $cm->execAddDatastreamMethods($dsid, $file); } @@ -826,7 +826,7 @@ class ObjectHelper { if (!$pid) { return FALSE; } - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); // Get title and descriptions for $pid $query_string = 'select $title $desc from <#ri> @@ -834,7 +834,7 @@ class ObjectHelper { and $o <dc:description> $desc and $o <mulgara:is> <info:fedora/' . $pid . '>'; - $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query_string))); @@ -868,7 +868,7 @@ class ObjectHelper { } $query_string = substr($query_string, 0, -3) . ' )'; - $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; $url .= htmlentities(urlencode($query_string)); $content = $this->doCurl($url); @@ -905,7 +905,7 @@ class ObjectHelper { * @return type */ function getObject($pid, $context = 'archive', $format = FOXML_11) { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/objects/' . $pid . '/export?context=' . $context . '&format=' . $format; $result_data = do_curl($url); @@ -921,10 +921,10 @@ class ObjectHelper { * @param type $level */ function getBreadcrumbs($pid, &$breadcrumbs, $level=10) { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); // Before executing the query, we hve a base case of accessing the top-level collection global $base_url; - if ($pid == variable_get('islandora_repository_pid', 'islandora:root')) { + if ($pid == variable_get('fedora_repository_pid', 'islandora:root')) { $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); $breadcrumbs[] = l(t('Home'), $base_url); } @@ -940,7 +940,7 @@ class ObjectHelper { order by $title'; $query_string = htmlentities(urlencode($query_string)); - $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=CSV&limit=1&offset=0&lang=itql&stream=on&query=" . $query_string; $result = preg_split('/[\r\n]+/', do_curl($url)); @@ -950,7 +950,7 @@ class ObjectHelper { $parent = preg_replace('/^info:fedora\//', '', $matches[0]); $breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); - if ($parent == variable_get('islandora_repository_pid', 'islandora:root')) { + if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) { $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); $breadcrumbs[] = l(t('Home'), $base_url); } diff --git a/SearchClass.inc b/SearchClass.inc index 794d292a..3f1c78d5 100644 --- a/SearchClass.inc +++ b/SearchClass.inc @@ -25,14 +25,14 @@ class SearchClass { function solr_search($query, $startPage=1, $fq = NULL, $dismax = NULL) { $solrFile = trim(variable_get('islandora_solr_search_block_handler_file', 'plugins/SolrResults.inc')); - // Don't let us bust out of islandora_repository modules directory when looking for a handler + // Don't let us bust out of fedora_repository modules directory when looking for a handler if (strpos($solrField, '../')) { drupal_set_message(t('You have illegal characters in your solr handler function in the Islandora solr block config.'), 'error'); } $solrClass = trim(variable_get('islandora_solr_search_block_handler_class', 'SolrResults')); $solrFunction = trim(variable_get('islandora_solr_search_block_handler_function', 'SearchAndDisplay')); - require_once(drupal_get_path('module', 'islandora_repository') . '/' . $solrFile); + require_once(drupal_get_path('module', 'fedora_repository') . '/' . $solrFile); try { $implementation = new $solrClass(); } catch (Exception $e) { @@ -185,8 +185,8 @@ class SearchClass { * @return type */ function quickSearch($type, $query, $showForm = 1, $orderBy = 0, & $userArray) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); if (user_access('view fedora collection')) { $numberOfHistPerPage = '5000'; //hack for IR they do not want next button $luceneQuery = NULL; @@ -222,7 +222,7 @@ class SearchClass { } } if ($showForm) { - $output = '<Strong>Quick Search</strong><br /><table class="table-form"><tr>' . drupal_get_form('islandora_repository_quick_search_form') . '</tr></table>'; + $output = '<Strong>Quick Search</strong><br /><table class="table-form"><tr>' . drupal_get_form('fedora_repository_quick_search_form') . '</tr></table>'; } $output .= $this->applyXSLT($resultData, $orderBy); return $output; @@ -237,8 +237,8 @@ class SearchClass { * @return type */ function getTerms($fieldName, $startTerm, $displayName = NULL) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $indexName = variable_get('fedora_index_name', 'DemoOnLucene'); $searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest'); if ($startTerm == NULL) { @@ -269,8 +269,8 @@ class SearchClass { * @return type */ function custom_search($query, $startPage=1, $xslt= '/xsl/advanced_search_results.xsl', $numberOfHistPerPage = 50) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); if (user_access('view fedora collection')) { //$numberOfHistPerPage = '50';//hack for IR they do not want next button @@ -322,7 +322,7 @@ class SearchClass { return ' '; } - //$proc->setParameter('', 'searchUrl', url('search') . '/islandora_repository'); //needed in our xsl + //$proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'userID', $user->uid); if (isset($displayName)) { @@ -390,8 +390,8 @@ class SearchClass { //inject into xsl stylesheet global $user; $proc->setParameter('', 'userID', $user->uid); - $proc->setParameter('', 'searchToken', drupal_get_token('islandora_repository_advanced_search')); //token generated by Drupal, keeps tack of what tab etc we are on - $proc->setParameter('', 'searchUrl', url('search') . '/islandora_repository'); //needed in our xsl + $proc->setParameter('', 'searchToken', drupal_get_token('fedora_repository_advanced_search')); //token generated by Drupal, keeps tack of what tab etc we are on + $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $proc->setParameter('', 'hitPageStart', $startPage); @@ -441,7 +441,7 @@ class SearchClass { //inject into xsl stylesheet //$proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on $proc->setParameter('', 'userID', $user->uid); - $proc->setParameter('', 'searchUrl', url('search') . '/islandora_repository'); //needed in our xsl + $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $proc->setParameter('', 'orderBy', $orderBy); @@ -475,7 +475,7 @@ class SearchClass { */ function theme_advanced_search_form($form, $repeat=NULL) { if (!isset($repeat)) { - $repeat = variable_get('islandora_repository_advanced_block_repeat', t('3')); + $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3')); } $output = drupal_render($form['search_type']['type1']); @@ -515,7 +515,7 @@ class SearchClass { $form = array(); if (!isset($repeat)) { - $repeat = variable_get('islandora_repository_advanced_block_repeat', t('3')); + $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3')); } $var0 = explode(':', $queryArray[0]); $var1 = explode(':', $queryArray[1]); diff --git a/SecurityClass.inc b/SecurityClass.inc index fbc6d3b8..0cdb2cbe 100644 --- a/SecurityClass.inc +++ b/SecurityClass.inc @@ -30,7 +30,7 @@ class SecurityClass { */ function canIngestHere($collection_pid) { global $user; - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); // get the childsecurity policy from the collection. $policyStream = $objectHelper->getStream($collection_pid, SECURITYCLASS :: $SECURITY_CLASS_SECURITY_STREAM, FALSE); diff --git a/XMLDatastream.inc b/XMLDatastream.inc index 9376aa83..d3afed09 100644 --- a/XMLDatastream.inc +++ b/XMLDatastream.inc @@ -168,7 +168,7 @@ abstract class XMLDatastream { //$tmpname = substr($this->pid, strpos($this->pid, ':') + 1); $tmpname = user_password(10); $this->convertFromOldSchema(); - drupal_add_js("islandora_repository_print_new_schema_$tmpname = function(tagID) { + drupal_add_js("fedora_repository_print_new_schema_$tmpname = function(tagID) { var target = document.getElementById(tagID); var content = target.innerHTML; var text = '<html><head><title>Title' + @@ -179,7 +179,7 @@ abstract class XMLDatastream { }", 'inline'); if (user_access('administer site configuration')) { - drupal_set_message('<span id="new_schema_' . $tmpname . '" style="display: none;">' . htmlentities($this->xml->saveXML()) . '</span>Warning: XMLDatastream performed conversion of \'' . $this->getIdentifier() . '\' from old schema. Please update the datastream. The new datastream contents are <a href="javascript:islandora_repository_print_new_schema_' . $tmpname . '(\'new_schema_' . $tmpname . '\')">here.</a> '); + drupal_set_message('<span id="new_schema_' . $tmpname . '" style="display: none;">' . htmlentities($this->xml->saveXML()) . '</span>Warning: XMLDatastream performed conversion of \'' . $this->getIdentifier() . '\' from old schema. Please update the datastream. The new datastream contents are <a href="javascript:fedora_repository_print_new_schema_' . $tmpname . '(\'new_schema_' . $tmpname . '\')">here.</a> '); } $rootEl = $this->xml->firstChild; @@ -246,7 +246,7 @@ abstract class XMLDatastream { * @return boolean $valid */ public function purgeVersions($start_date, $end_date = NULL) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $fedora_item = new Fedora_Item($this->pid); return $fedora_item->purge_datastream($this->dsid, $start_date, $end_date); } @@ -258,7 +258,7 @@ abstract class XMLDatastream { * @return string[] $ret */ public function getHistory() { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $fedora_item = new Fedora_Item($this->pid); $history = $fedora_item->get_datastream_history($this->dsid); diff --git a/api/fedora_collection.inc b/api/fedora_collection.inc index 2efd2acb..b8afc5c4 100644 --- a/api/fedora_collection.inc +++ b/api/fedora_collection.inc @@ -4,10 +4,10 @@ * @file * Operations that affect a Fedora repository at a collection level. */ -module_load_include('inc', 'islandora_repository', 'CollectionClass'); -module_load_include('inc', 'islandora_repository', 'api/fedora_item'); -module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); -module_load_include('module', 'islandora_repository'); +module_load_include('inc', 'fedora_repository', 'CollectionClass'); +module_load_include('inc', 'fedora_repository', 'api/fedora_item'); +module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); +module_load_include('module', 'fedora_repository'); /** * Exports a fedora collection object and all of its children in a format @@ -68,10 +68,10 @@ function export_collection($collection_pid, $relationship = 'isMemberOfCollectio * @param <type> $query_format R */ function get_related_items_as_xml($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE, $cmodel = NULL, $orderby = '$title') { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); global $user; - if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); return array(); } @@ -111,7 +111,7 @@ function get_related_items_as_xml($collection_pid, $relationship = array('isMemb $content = ''; - $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=Sparql&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query_string; $content .= do_curl($url); diff --git a/api/fedora_export.inc b/api/fedora_export.inc index bc4fd00f..e1ed3cbd 100644 --- a/api/fedora_export.inc +++ b/api/fedora_export.inc @@ -41,7 +41,7 @@ function export_to_export_area($pid, $foxml_dir, $ob_dir, &$log = array()) { * @return string */ function export_objects_for_pid($pid, $dir, &$log) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($pid); if (!$object = $item->get_datastreams_list_as_SimpleXML($pid)) { $log[] = log_line(t("Failed to get datastream %dsid for pid %pid", array('%dsid' => $ds->ID, '%pid' => $pid)), 'error'); @@ -85,7 +85,7 @@ function export_objects_for_pid($pid, $dir, &$log) { * @return type */ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $remove_islandora = FALSE) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $ob_helper = new ObjectHelper(); if (!$object_xml = $ob_helper->getObject($pid, 'migrate', $format)) { $log[] = log_line(t("Failed to get foxml for %pid", array('%pid' => $pid)), 'error'); diff --git a/api/fedora_item.inc b/api/fedora_item.inc index fdf7074c..4dacca8c 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -28,8 +28,8 @@ class Fedora_Item { */ function __construct($pid) { drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $this->pid = $pid; if (isset(Fedora_Item::$instantiated_pids[$pid])) { @@ -75,7 +75,7 @@ class Fedora_Item { * @return type */ function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = NULL) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); if (!is_file($datastream_file)) { drupal_set_message("$datastream_file not found<br />", 'warning'); return; @@ -285,7 +285,7 @@ class Fedora_Item { * @return Array of pid => title pairs that match the results */ static function find_objects_by_pattern($pattern = '*', $field = 'pid', $max_results = 100, $resultFields = array()) { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $pattern = drupal_urlencode($pattern); $done = FALSE; @@ -848,7 +848,7 @@ class Fedora_Item { */ static function soap_call($function_name, $params_array, $quiet = FALSE) { if (!self::$connection_helper) { - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); self::$connection_helper = new ConnectionHelper(); } switch ($function_name) { diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index 91a8f05f..c8ce7d0e 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -158,7 +158,7 @@ function fedora_available() { */ function risearch_available() { - $response = do_curl_ext(variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch')); + $response = do_curl_ext(variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch')); return ($response != NULL) ? ($response[1] == 0): FALSE; } @@ -238,13 +238,13 @@ function fix_dsid($dsid) { * @return array */ function get_collections_as_option_array() { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $query = 'select $object $title from <#ri> where ($object <dc:title> $title and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) order by $title'; - $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query))); $list = explode("\n", $content); @@ -269,8 +269,8 @@ function get_collections_as_option_array() { * @return array */ function get_content_models_as_option_array() { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $restricted = variable_get('fedora_namespace_restriction_enforced', true); $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); @@ -286,7 +286,7 @@ function get_content_models_as_option_array() { and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) order by $title'; - $url = variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query))); $list = explode("\n", $content); diff --git a/islandora_repository.info b/fedora_repository.info similarity index 100% rename from islandora_repository.info rename to fedora_repository.info diff --git a/islandora_repository.install b/fedora_repository.install similarity index 92% rename from islandora_repository.install rename to fedora_repository.install index e8e26ad2..164ce02e 100644 --- a/islandora_repository.install +++ b/fedora_repository.install @@ -1,7 +1,7 @@ <?php /** - * @file islandora_repository.install + * @file fedora_repository.install */ /** @@ -33,7 +33,7 @@ function fedora_collections_enable() { * @see _update_message_text() * @see _update_cron_notify() */ -function islandora_repository_requirements($phase) { +function fedora_repository_requirements($phase) { global $base_url; $requirements = array(); @@ -89,13 +89,13 @@ function islandora_repository_requirements($phase) { } } elseif ($phase == 'runtime') { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $requirements['fedora-repository']['title'] = t("Fedora server"); if (!fedora_available()) { $requirements['fedora-repository']['value'] = t("Not available"); $requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR; - $requirements['fedora-repository']['description'] = t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => $base_url . '/admin/settings/islandora_repository')); + $requirements['fedora-repository']['description'] = t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => $base_url . '/admin/settings/fedora_repository')); } else { $requirements['fedora-repository']['value'] = t("Available"); diff --git a/islandora_repository.module b/fedora_repository.module similarity index 81% rename from islandora_repository.module rename to fedora_repository.module index 6fa13988..ea1c15c5 100644 --- a/islandora_repository.module +++ b/fedora_repository.module @@ -2,23 +2,23 @@ /** * Drupal hook for admin form - * islandora_repository_name is the name of the top level collection this module will query - * islandora_repository_pid is the name of the top level pid. + * fedora_repository_name is the name of the top level collection this module will query + * fedora_repository_pid is the name of the top level pid. * Stores this info in the drupal variables table. * the name and pid can also be passed as url parameters */ -function islandora_repository_admin() { - module_load_include('inc', 'islandora_repository', 'formClass'); +function fedora_repository_admin() { + module_load_include('inc', 'fedora_repository', 'formClass'); $adminForm = new formClass(); return $adminForm->createAdminForm(); } /** * drupal hook - * calls the islandora_repositorys_admin form + * calls the fedora_repositorys_admin form */ -function islandora_repository_menu() { - module_load_include('inc', 'islandora_repository', 'formClass'); +function fedora_repository_menu() { + module_load_include('inc', 'fedora_repository', 'formClass'); $adminMenu = new formClass(); return $adminMenu->createMenu(); } @@ -30,11 +30,11 @@ function islandora_repository_menu() { * @param type $arg * @return type */ -function islandora_repository_help($path, $arg) { +function fedora_repository_help($path, $arg) { switch ($path) { case 'admin/modules#description' : return t('Grabs a list of items from a collection in Drupal that are presented on the home page.'); - case 'node/add#islandora_repository' : + case 'node/add#fedora_repository' : return t('Use this page to grab a list of items from a Fedora collection.'); } } @@ -45,7 +45,7 @@ function islandora_repository_help($path, $arg) { * @param type $name * @return type */ -function islandora_repository_purge_object($pid = NULL, $name = NULL) { +function fedora_repository_purge_object($pid = NULL, $name = NULL) { if (!user_access('purge objects and datastreams')) { drupal_set_message(t('You do not have access to add a datastream to this object.'), 'error'); return ''; @@ -60,7 +60,7 @@ function islandora_repository_purge_object($pid = NULL, $name = NULL) { '%pid' => $pid) ); - $output .= drupal_get_form('islandora_repository_purge_object_form', $pid); + $output .= drupal_get_form('fedora_repository_purge_object_form', $pid); return $output; } @@ -72,22 +72,22 @@ function islandora_repository_purge_object($pid = NULL, $name = NULL) { * @param type $pageNumber * @return type */ -function islandora_repository_collection_view($pid = NULL, $collection = NULL, $pageNumber = NULL) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); +function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pageNumber = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); global $user; - if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); return ' '; } $objectHelper = new ObjectHelper(); if ($pid == NULL) { - $pid = variable_get('islandora_repository_pid', 'islandora:root'); + $pid = variable_get('fedora_repository_pid', 'islandora:root'); } $content = ''; - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); $collectionClass = new CollectionClass(); $results = $collectionClass->getRelatedItems($pid, NULL); $content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber); @@ -102,9 +102,9 @@ function islandora_repository_collection_view($pid = NULL, $collection = NULL, $ * @param type $content_model * @return type */ -function islandora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); +function fedora_repository_ingest_object($collection_pid=NULL, $collection_label = NULL, $content_model = NULL) { + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); if (!user_access('ingest new fedora objects')) { drupal_set_message(t('You do not have permission to ingest.'), 'error'); return ''; @@ -124,7 +124,7 @@ function islandora_repository_ingest_object($collection_pid=NULL, $collection_la drupal_set_message(t('You must specify a collection object pid to ingest an object.'), 'error'); return ''; } - $output = drupal_get_form('islandora_repository_ingest_form', $collection_pid, $collection_label, $content_model); + $output = drupal_get_form('fedora_repository_ingest_form', $collection_pid, $collection_label, $content_model); $breadcrumbs = array(); $objectHelper = new ObjectHelper(); @@ -141,7 +141,7 @@ function islandora_repository_ingest_object($collection_pid=NULL, $collection_la * @param array $form * @param array $form_state */ -function islandora_repository_ingest_form_submit(array $form, array &$form_state) { +function fedora_repository_ingest_form_submit(array $form, array &$form_state) { //only validate the form if the submit button was pressed (other buttons may be used for AHAH if ($form_state['storage']['xml']) { if (module_exists('islandora_content_model_forms')) { @@ -152,9 +152,9 @@ function islandora_repository_ingest_form_submit(array $form, array &$form_state } else if ($form_state['clicked_button']['#id'] == 'edit-submit') { global $base_url; - module_load_include('inc', 'islandora_repository', 'CollectionClass'); - module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); - module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); $contentModelPid = ContentModel::getPidFromIdentifier($form_state['values']['models']); $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); @@ -196,7 +196,7 @@ function islandora_repository_ingest_form_submit(array $form, array &$form_state * @param type $form_state * @return type */ -function islandora_repository_ingest_form_validate($form, &$form_state) { +function fedora_repository_ingest_form_validate($form, &$form_state) { //only validate the form if the submit button was pressed (other buttons may be used for AHAH if ($form_state['clicked_button']['#id'] == 'edit-submit') { switch ($form_state['storage']['step']) { @@ -223,8 +223,8 @@ function islandora_repository_ingest_form_validate($form, &$form_state) { } if (isset($form_state['values']['ingest-file-location']) && file_exists($form_state['values']['ingest-file-location'])) { - module_load_include('inc', 'islandora_repository', 'ContentModel'); - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); $file = $form_state['values']['ingest-file-location']; @@ -267,8 +267,8 @@ function islandora_repository_ingest_form_validate($form, &$form_state) { * @param type $content_model * @return type */ -function islandora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) { - module_load_include('inc', 'islandora_repository', 'formClass'); +function fedora_repository_ingest_form(&$form_state, $collection_pid, $collection_label = NULL, $content_model = NULL) { + module_load_include('inc', 'fedora_repository', 'formClass'); // For the sake of easily maintaining the module in different core versions create our own form_values variable. if (empty($form_state['storage']['step'])) { $form_state['storage']['step'] = 1; @@ -287,7 +287,7 @@ function islandora_repository_ingest_form(&$form_state, $collection_pid, $collec * @param type $referrer * @return type */ -function islandora_repository_purge_object_form(&$form_state, $pid, $referrer = NULL) { +function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NULL) { global $base_url; if (!user_access('purge objects and datastreams')) { return NULL; @@ -311,7 +311,7 @@ function islandora_repository_purge_object_form(&$form_state, $pid, $referrer = $form['submit'] = array( '#type' => 'image_button', - '#src' => drupal_get_path('module', 'islandora_repository') . '/images/purge_big.png', + '#src' => drupal_get_path('module', 'fedora_repository') . '/images/purge_big.png', '#value' => t('Purge'), '#suffix' => 'Purge this object', ); @@ -337,7 +337,7 @@ function islandora_repository_purge_object_form(&$form_state, $pid, $referrer = * @return type */ function add_stream($collection_pid=NULL, $collectionName=NULL) { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); if (!valid_pid($collection_pid)) { drupal_set_message(t("This PID is not valid!"), 'error'); return ' '; @@ -350,7 +350,7 @@ function add_stream($collection_pid=NULL, $collectionName=NULL) { drupal_set_message(t('You must specify an collection object pid to ingest an object.'), 'error'); return ''; } - $output .= drupal_get_form('islandora_repository_add_stream_form', $pid); + $output .= drupal_get_form('fedora_repository_add_stream_form', $pid); return $output; } @@ -368,10 +368,10 @@ function add_stream_form_submit($form, &$form_state) { $form_state['rebuild'] = TRUE; return; } - module_load_include('inc', 'islandora_repository', 'MimeClass'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - $pathToModule = drupal_get_path('module', 'islandora_repository'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + $pathToModule = drupal_get_path('module', 'fedora_repository'); $file = $form_state['values']['add-stream-file-location']; @@ -413,7 +413,7 @@ function add_stream_form_submit($form, &$form_state) { * @return type */ function add_stream_form(&$form_state, $pid) { - module_load_include('inc', 'islandora_repository', 'formClass'); + module_load_include('inc', 'fedora_repository', 'formClass'); $addDataStreamForm = new formClass(); return $addDataStreamForm->createAddDataStreamForm($pid, $form_state); } @@ -470,14 +470,14 @@ function add_stream_form_validate($form, &$form_state) { * @param type $name * @return type */ -function islandora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); +function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); global $user; if ($pid == NULL || $dsId == NULL) { drupal_set_message(t('You must specify an object pid and DataStream ID to purge a datastream'), 'error'); return ' '; } - if (!islandora_repository_access(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER :: $PURGE_FEDORA_OBJECTSANDSTREAMS, $pid, $user)) { drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to purge objects."), 'error'); return ' '; } @@ -486,7 +486,7 @@ function islandora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NU array( '%name' => $name) ); - $output .= drupal_get_form('islandora_repository_purge_stream_form', $pid, $dsId); + $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); return $output; } @@ -496,8 +496,8 @@ function islandora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NU * @param type $form_state * @return type */ -function islandora_repository_purge_object_form_submit($form, &$form_state) { - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); +function fedora_repository_purge_object_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 @@ -545,7 +545,7 @@ function islandora_repository_purge_object_form_submit($form, &$form_state) { * @param type $dsId * @return type */ -function islandora_repository_purge_stream_form(&$form_state, $pid, $dsId) { +function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) { $form['pid'] = array( '#type' => 'hidden', '#value' => "$pid" @@ -568,9 +568,9 @@ function islandora_repository_purge_stream_form(&$form_state, $pid, $dsId) { * @param type $form * @param array $form_state */ -function islandora_repository_purge_stream_form_submit($form, &$form_state) { +function fedora_repository_purge_stream_form_submit($form, &$form_state) { global $base_url; - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); //$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); $pid = $form_state['values']['pid']; $item = new Fedora_Item($pid); @@ -591,12 +591,12 @@ function islandora_repository_purge_stream_form_submit($form, &$form_state) { * @param type $collectionName * @return type */ -function islandora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) { +function fedora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionName = NULL) { if ($pid == NULL || $dsId == NULL) { drupal_set_message(t('You must specify an pid and dsId to replace.'), 'error'); return ''; } - $output = drupal_get_form('islandora_repository_replace_stream_form', $pid, $dsId, $dsLabel); + $output = drupal_get_form('fedora_repository_replace_stream_form', $pid, $dsId, $dsLabel); return $output; } @@ -609,8 +609,8 @@ function islandora_repository_replace_stream($pid, $dsId, $dsLabel, $collectionN * @param type $dsLabel * @return type */ -function islandora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) { -//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'islandora_repository', ''); +function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) { +//module_load_module_load_include('hp', ''Fedora_Repository'', 'config', 'fedora_repository', ''); module_load_include('inc', 'Fedora_Repository', 'formClass'); //$client = getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); $replaceDataStreamForm = new formClass(); @@ -623,7 +623,7 @@ function islandora_repository_replace_stream_form(&$form_state, $pid, $dsId, $ds * @param type $form_state * @return type */ -function islandora_repository_replace_stream_form_validate($form, &$form_state) { +function fedora_repository_replace_stream_form_validate($form, &$form_state) { // If a file was uploaded, process it. if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name']['file'])) { @@ -655,7 +655,7 @@ function islandora_repository_replace_stream_form_validate($form, &$form_state) * @param type $form * @param array $form_state */ -function islandora_repository_replace_stream_form_submit($form, &$form_state) { +function fedora_repository_replace_stream_form_submit($form, &$form_state) { global $base_url; $file = $form_state['values']['file']; $pid = $form_state['values']['pid']; @@ -668,7 +668,7 @@ function islandora_repository_replace_stream_form_submit($form, &$form_state) { $dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.; } module_load_include('inc', 'Fedora_Repository', 'MimeClass'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $file_basename = basename($file->filepath); $file_directory = dirname($file->filepath); @@ -694,18 +694,18 @@ function islandora_repository_replace_stream_form_submit($form, &$form_state) { * @param type $dsId * @return type */ -function islandora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); +function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); global $user; if ($pid == NULL || $dsId == NULL) { drupal_set_message(t('You must specify an object pid and a Dublin Core DataStream ID to edit metadata'), 'error'); return ' '; } - if (!islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); return ' '; } - $output = drupal_get_form('islandora_repository_edit_qdc_form', $pid, $dsId); + $output = drupal_get_form('fedora_repository_edit_qdc_form', $pid, $dsId); return $output; } @@ -718,20 +718,20 @@ function islandora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { * @param type $dsId * @return type */ -function islandora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { - module_load_include('inc', 'islandora_repository', 'ContentModel'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); +function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); if ($pid == NULL) { drupal_set_message(t('You must specify an object pid!'), 'error'); } global $user; - if (!islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $pid, $user)) { drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or you do not have permission to edit meta data for this object."), 'error'); return ' '; } - module_load_include('inc', 'islandora_repository', 'formClass'); - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + module_load_include('inc', 'fedora_repository', 'formClass'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); $soapHelper = new ConnectionHelper(); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); // Check if there is a custom edit metadata function defined in the content model. @@ -761,7 +761,7 @@ function islandora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) { * @param type $form * @param boolean $form_state */ -function islandora_repository_edit_qdc_form_validate($form, &$form_state) { +function fedora_repository_edit_qdc_form_validate($form, &$form_state) { if ($form_state['storage']['xml']) { if ($form_state['storage']['step'] == 1) { $form_state['storage']['step']++; @@ -782,14 +782,14 @@ function islandora_repository_edit_qdc_form_validate($form, &$form_state) { * @param array $form_state * @return */ -function islandora_repository_edit_qdc_form_submit($form, &$form_state) { +function fedora_repository_edit_qdc_form_submit($form, &$form_state) { if ($form_state['storage']['xml']) { module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm'); $xml_form = new EditObjectMetadataForm($form_state); $xml_form->submit($form, $form_state); } else { - module_load_include('inc', 'islandora_repository', 'ConnectionHelper'); + module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); global $base_url; if (strstr($form_state['clicked_button']['#id'], 'edit-submit')) { @@ -799,13 +799,13 @@ function islandora_repository_edit_qdc_form_submit($form, &$form_state) { // Check the content model for a custom edit metadata form submit function. if (isset($form_state['values']['pid'])) { - module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); if (($cm = ContentModel::loadFromObject($form_state['values']['pid'])) !== FALSE) { return $cm->handleEditMetadataForm($form_state['values']['form_id'], $form_state, $client); } } - module_load_include('inc', 'islandora_repository', 'formClass'); + module_load_include('inc', 'fedora_repository', 'formClass'); $metaDataForm = new formClass(); $return_value = $metaDataForm->updateMetaData($form_state['values']['form_id'], $form_state['values'], $client); $form_state['storage'] = NULL; @@ -820,8 +820,8 @@ function islandora_repository_edit_qdc_form_submit($form, &$form_state) { * drupal hook * creates a new permission than can be assigned to roles */ -function islandora_repository_perm() { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); +function fedora_repository_perm() { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); return array( OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, OBJECTHELPER::$EDIT_FEDORA_METADATA, @@ -845,10 +845,10 @@ function islandora_repository_perm() { * @param type $account * @return type */ -function islandora_repository_access($op, $node, $account) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); +function fedora_repository_access($op, $node, $account) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); - return $objectHelper->islandora_repository_access($op, $node, $account); + return $objectHelper->fedora_repository_access($op, $node, $account); } /** @@ -858,7 +858,7 @@ function islandora_repository_access($op, $node, $account) { * @param $dsID String */ function makeObject($pid, $dsID) { - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); if (!valid_pid($pid)) { drupal_set_message(t("Invalid PID!"), 'error'); return ' '; @@ -874,14 +874,14 @@ function makeObject($pid, $dsID) { return ' '; } global $user; - if (!islandora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_access_denied(); return; drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace."), 'error'); return ' '; } - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $objectHelper->makeObject($pid, $dsID); } @@ -899,10 +899,10 @@ function makeObject($pid, $dsID) { * @param type $limit * @return type */ -function islandora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $page_number = NULL, $limit = NULL) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); +function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $page_number = NULL, $limit = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); global $user; if (!fedora_available()) { @@ -916,7 +916,7 @@ function islandora_repository_get_items($pid = NULL, $dsId = NULL, $collection = } if ($pid == NULL) { - $pid = variable_get('islandora_repository_pid', 'islandora:root'); + $pid = variable_get('fedora_repository_pid', 'islandora:root'); } $item = new fedora_item($pid); @@ -934,9 +934,9 @@ function islandora_repository_get_items($pid = NULL, $dsId = NULL, $collection = drupal_set_message(t("Invalid dsID!"), 'error'); return ' '; } - if (!islandora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/islandora_repository'))), 'warning'); + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); } drupal_access_denied(); exit; @@ -945,7 +945,7 @@ function islandora_repository_get_items($pid = NULL, $dsId = NULL, $collection = $objectHelper = new ObjectHelper(); if ($pid == NULL) { - $pid = variable_get('islandora_repository_pid', 'islandora:root'); + $pid = variable_get('fedora_repository_pid', 'islandora:root'); } $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); if (in_array(-1, $headers)) { @@ -960,10 +960,10 @@ function islandora_repository_get_items($pid = NULL, $dsId = NULL, $collection = $content = '<div id="content-fedora">'; - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); $collectionClass = new CollectionClass(); - module_load_include('inc', 'islandora_repository', 'ContentModel'); - module_load_include('inc', 'islandora_repository', 'plugins/FedoraObjectDetailedContent'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent'); $breadcrumbs = array(); $objectHelper->getBreadcrumbs($pid, $breadcrumbs); drupal_set_breadcrumb(array_reverse($breadcrumbs)); @@ -1009,7 +1009,7 @@ function islandora_repository_get_items($pid = NULL, $dsId = NULL, $collection = * @param type $str * @return type */ -function islandora_repository_urlencode_string($str) { +function fedora_repository_urlencode_string($str) { return htmlentities($str); } @@ -1026,7 +1026,7 @@ function islandora_repository_urlencode_string($str) { */ function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) { global $user; - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); if ($pid == NULL || $dsId == NULL) { drupal_set_message(t("no pid or dsid given to create an object with!")); @@ -1046,9 +1046,9 @@ function fedora_object_as_attachment($pid, $dsId, $label=NULL, $version=NULL) { * @return type */ function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL) { -//do security check at islandora_repository_get_items function as it has to be called there in case +//do security check at fedora_repository_get_items function as it has to be called there in case //someone trys to come in a back door. - return islandora_repository_get_items($pid, $dsId, $collection, $pageNumber); + return fedora_repository_get_items($pid, $dsId, $collection, $pageNumber); } /** @@ -1060,20 +1060,20 @@ function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNum * @return type */ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); global $user; - if (!islandora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { + if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { //drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error'); drupal_access_denied(); if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/islandora_repository'))), 'error'); + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'error'); } return ' '; } if ($pid == NULL) { - $pid = variable_get('islandora_repository_pid', 'islandora:root'); + $pid = variable_get('fedora_repository_pid', 'islandora:root'); } $headers = module_invoke_all('file_download', "/fedora/repository/$pid"); if (in_array(-1, $headers)) { @@ -1105,9 +1105,9 @@ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NU * @param type $keys * @return array */ -function islandora_repository_search($op = 'search', $keys = NULL) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); +function fedora_repository_search($op = 'search', $keys = NULL) { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); switch ($op) { case 'name': @@ -1140,7 +1140,7 @@ function islandora_repository_search($op = 'search', $keys = NULL) { $xmlDoc = NULL; - $path = drupal_get_path('module', 'islandora_repository'); + $path = drupal_get_path('module', 'fedora_repository'); $xmlDoc = new DomDocument(); $xmlDoc->load($path . '/searchTerms.xml'); $nodeList = $xmlDoc->getElementsByTagName('default'); @@ -1188,8 +1188,8 @@ function islandora_repository_search($op = 'search', $keys = NULL) { * @param type $resultData * @return array */ -function islandora_repository_search_page($resultData) { - $path = drupal_get_path('module', 'islandora_repository'); +function fedora_repository_search_page($resultData) { + $path = drupal_get_path('module', 'fedora_repository'); $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $proc = NULL; if (!$resultData[0][0]['data']) { @@ -1211,7 +1211,7 @@ function islandora_repository_search_page($resultData) { //inject into xsl stylesheet $proc->setParameter('', 'searchToken', drupal_get_token('search_form')); //token generated by Drupal, keeps tack of what tab etc we are on - $proc->setParameter('', 'searchUrl', url('search') . '/islandora_repository'); //needed in our xsl + $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: ')); $proc->registerPHPFunctions(); @@ -1266,11 +1266,11 @@ function islandora_repository_search_page($resultData) { * @param type $form_state * @param type $form_id */ -function islandora_repository_form_alter(&$form, &$form_state, $form_id) { +function fedora_repository_form_alter(&$form, &$form_state, $form_id) { // Advanced node search form - module_load_include('inc', 'islandora_repository', 'SearchClass'); - $path = drupal_get_path('module', 'islandora_repository'); - if ($form_id == 'search_form' && arg(1) == 'islandora_repository' && user_access('use advanced search')) { + module_load_include('inc', 'fedora_repository', 'SearchClass'); + $path = drupal_get_path('module', 'fedora_repository'); + if ($form_id == 'search_form' && arg(1) == 'fedora_repository' && user_access('use advanced search')) { $default_value = $form['basic']['inline']['keys']['#default_value']; $index = strpos($default_value, '.'); $test = substr($default_value, 0, $index + 1); @@ -1312,7 +1312,7 @@ function islandora_repository_form_alter(&$form, &$form_state, $form_id) { '#value' => t('Advanced search'), '#prefix' => '<div class="action clear-block">', '#suffix' => '</div>', ); - $form['#validate'][] = 'islandora_repository_search_validate'; + $form['#validate'][] = 'fedora_repository_search_validate'; } } @@ -1322,7 +1322,7 @@ function islandora_repository_form_alter(&$form, &$form_state, $form_id) { * @param type $form * @param type $form_state */ -function islandora_repository_search_validate($form, &$form_state) { +function fedora_repository_search_validate($form, &$form_state) { // Initialise using any existing basic search keywords. $keys = $form_state['values']['processed_keys']; @@ -1342,18 +1342,18 @@ function islandora_repository_search_validate($form, &$form_state) { * fedora repository theme * @return type */ -function islandora_repository_theme() { +function fedora_repository_theme() { return array( - 'islandora_repository_mnpl_advanced_search_form' => array( + 'fedora_repository_mnpl_advanced_search_form' => array( 'arguments' => array( 'form' => NULL, ), ), - 'islandora_repository_time' => array( + 'fedora_repository_time' => array( 'arguments' => array( 'element' => NULL ), - 'islandora_repository_solution_packs_list' => array( + 'fedora_repository_solution_packs_list' => array( 'arguments' => array( 'solution_packs' => NULL, ), @@ -1370,8 +1370,8 @@ function islandora_repository_theme() { * @param type $displayName * @return type */ -function islandora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) { - module_load_include('inc', 'islandora_repository', 'SearchClass'); +function fedora_repository_list_terms($field, $startTerm = NULL, $displayName = NULL) { + module_load_include('inc', 'fedora_repository', 'SearchClass'); $searchClass = new SearchClass(); return $searchClass->getTerms($field, $startTerm, $displayName); } @@ -1380,8 +1380,8 @@ function islandora_repository_list_terms($field, $startTerm = NULL, $displayName * fedora repository mnpl advanced search form * @return type */ -function islandora_repository_mnpl_advanced_search_form() { - module_load_include('inc', 'islandora_repository', 'SearchClass'); +function fedora_repository_mnpl_advanced_search_form() { + module_load_include('inc', 'fedora_repository', 'SearchClass'); $searchClass = new SearchClass(); return $searchClass->build_advanced_search_form(); } @@ -1391,8 +1391,8 @@ function islandora_repository_mnpl_advanced_search_form() { * @param type $form * @return type */ -function theme_islandora_repository_mnpl_advanced_search_form($form) { - module_load_include('inc', 'islandora_repository', 'SearchClass'); +function theme_fedora_repository_mnpl_advanced_search_form($form) { + module_load_include('inc', 'fedora_repository', 'SearchClass'); $advanced_search_form = new SearchClass(); return $advanced_search_form->theme_advanced_search_form($form); } @@ -1403,8 +1403,8 @@ function theme_islandora_repository_mnpl_advanced_search_form($form) { * @param type $startPage * @return type */ -function islandora_repository_mnpl_advanced_search($query, $startPage = 1) { - module_load_include('inc', 'islandora_repository', 'SearchClass'); +function fedora_repository_mnpl_advanced_search($query, $startPage = 1) { + module_load_include('inc', 'fedora_repository', 'SearchClass'); $searchClass = new SearchClass(); $retVal = $searchClass->custom_search($query, $startPage); return $searchClass->custom_search($query, $startPage); @@ -1415,9 +1415,9 @@ function islandora_repository_mnpl_advanced_search($query, $startPage = 1) { * @param type $form * @param type $form_state */ -function islandora_repository_mnpl_advanced_search_form_submit($form, &$form_state) { +function fedora_repository_mnpl_advanced_search_form_submit($form, &$form_state) { $type_id = $form_state['values']['type']; - $repeat = variable_get('islandora_repository_advanced_block_repeat', t('3')); + $repeat = variable_get('fedora_repository_advanced_block_repeat', t('3')); $searchString = $form_state['values']['type1'] . ':' . $form_state['values']['fedora_terms1']; if ($form_state['values']['fedora_terms2'] != '') { $searchString .=' +' . $form_state['values']['andor1'] . '+' . $form_state['values']['type2'] . ':' . $form_state['values']['fedora_terms2']; @@ -1437,8 +1437,8 @@ function islandora_repository_mnpl_advanced_search_form_submit($form, &$form_sta * fedora repository install demo page * @return type */ -function islandora_repository_install_demos_page() { - $output = drupal_get_form('islandora_repository_demo_objects_form'); +function fedora_repository_install_demos_page() { + $output = drupal_get_form('fedora_repository_demo_objects_form'); return $output; } @@ -1446,9 +1446,9 @@ function islandora_repository_install_demos_page() { * fedora repository demo objects form * @return string */ -function islandora_repository_demo_objects_form() { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); +function fedora_repository_demo_objects_form() { + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $form = array(); $existing_demos = array(); @@ -1539,24 +1539,24 @@ function islandora_repository_demo_objects_form() { * @param type $form * @param type $form_state */ -function islandora_repository_demo_objects_form_submit($form, &$form_state) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/dublin_core'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); +function fedora_repository_demo_objects_form_submit($form, &$form_state) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/dublin_core'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); global $base_url; if ($form_state['clicked_button']['#name'] == 'install_demos') { if (!empty($form_state['values']['demo_collections']['islandora:collectionCModel'])) { try { $collectioncm = Fedora_Item::ingest_new_item('islandora:collectionCModel', 'A', 'Islandora Collection Content Model'); $collectioncm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); - $collectioncm->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + $collectioncm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); } catch (exception $e) { } try { $strictpdfcm = Fedora_Item::ingest_new_item('islandora:strict_pdf', 'A', 'Strict PDF Content Model'); $strictpdfcm->add_relationship('hasModel', 'fedora-system:ContentModel-3.0', FEDORA_MODEL_URI); - $strictpdfcm->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/content_models/STRICT_PDFCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + $strictpdfcm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STRICT_PDFCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); } catch (exception $e) { } @@ -1578,8 +1578,8 @@ function islandora_repository_demo_objects_form_submit($form, &$form_state) { order by $title', 'QUERY', 'Content Model Collection Query', 'text/plain'); $cmodel_collection->add_relationship('isMemberOfCollection', 'islandora:root'); $cmodel_collection->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); - $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M'); + $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); + $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M'); drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:ContentModelCollection\">islandora:ContentModelCollection</a>."), 'message'); } catch (exception $e) { @@ -1589,9 +1589,9 @@ function islandora_repository_demo_objects_form_submit($form, &$form_state) { if (!empty($form_state['values']['demo_collections']['islandora:root'])) { $new_item = Fedora_Item::ingest_new_item('islandora:root', 'A', 'Islandora Top-level Collection'); $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); try { - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:root\">islandora:root</a>."), 'message'); } catch (exception $e) { @@ -1602,16 +1602,16 @@ function islandora_repository_demo_objects_form_submit($form, &$form_state) { $new_item = fedora_item::ingest_new_item('islandora:demos', 'A', 'Islandora Demo Collection'); $new_item->add_relationship('isMemberOfCollection', 'islandora:root'); $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); -// $cv = $new_item->add_datastream_from_file( drupal_get_path('module', 'islandora_repository') . '/collection_views/COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View.xml', 'text/xml', 'X'); - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); +// $cv = $new_item->add_datastream_from_file( drupal_get_path('module', 'fedora_repository') . '/collection_views/COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View.xml', 'text/xml', 'X'); + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); try { $new_item = Fedora_Item::ingest_new_item('islandora:pdf_collection', 'A', 'PDF Collection'); $new_item->add_relationship('isMemberOfCollection', 'islandora:demos'); $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); - $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); + $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:demos\">islandora:demos</a>."), 'message'); } catch (exception $e) { @@ -1620,20 +1620,20 @@ function islandora_repository_demo_objects_form_submit($form, &$form_state) { if (!empty($form_state['values']['demo_collections']['demo:SmileyStuff'])) { $smiley_stuff = new Fedora_Item('demo:SmileyStuff'); - $new_item = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_views/SmileyStuff-COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); + $new_item = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/SmileyStuff-COLLECTION_VIEW.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); $smiley_stuff->add_relationship('isMemberOfCollection', 'info:fedora/islandora:demos'); - $tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - $cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X'); + $tn = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/smileytn.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + $cp = $smiley_stuff->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/JPG-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy.xml', 'application/xml', 'X'); $cm = new Fedora_Item('demo:DualResImage'); try { - $cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X'); + $cmstream = $cm->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/STANDARD JPG.xml', 'ISLANDORACM', 'Content Model.xml', 'application/xml', 'X'); } catch (exception $e) { } $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection'); try { - $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); + $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view."), 'message'); } catch (exception $e) { @@ -1645,14 +1645,14 @@ function islandora_repository_demo_objects_form_submit($form, &$form_state) { foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml', 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) { try { - $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'islandora_repository') . '/content_models/' . $foxml_file); + $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/' . $foxml_file); } catch (exception $e) { $error .= " - Problem ingesting $foxml_file"; } } try { - $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'islandora_repository') . '/content_models/islandora_largeimages.xml'); - $tn = $item->add_datastream_from_file(drupal_get_path('module', 'islandora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); + $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/islandora_largeimages.xml'); + $tn = $item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:largeimages\">islandora:largeimages</a>."), 'message'); } catch (exception $e) { $error .= " - Problem ingesting islandora:largeimages collection"; @@ -1669,12 +1669,12 @@ function islandora_repository_demo_objects_form_submit($form, &$form_state) { * fedora repository required fedora objects * @return type */ -function islandora_repository_required_fedora_objects() { +function fedora_repository_required_fedora_objects() { // array( 'path-to-foxml-file', 'pid', 'dsid', 'path-to-datastream-file', int dsversion, boolean required) - $module_path = drupal_get_path('module', 'islandora_repository'); + $module_path = drupal_get_path('module', 'fedora_repository'); return array( - 'islandora_repository' => array( - 'module' => 'islandora_repository', + 'fedora_repository' => array( + 'module' => 'fedora_repository', 'title' => 'Islandora Core', 'objects' => array( array( @@ -1710,10 +1710,10 @@ function islandora_repository_required_fedora_objects() { /** * Functions to create a time selector form element type. */ -function islandora_repository_elements() { - $type['islandora_repository_time'] = array( +function fedora_repository_elements() { + $type['fedora_repository_time'] = array( "#input" => TRUE, - "#process" => array("islandora_repository_expand_time"), + "#process" => array("fedora_repository_expand_time"), ); return $type; @@ -1724,7 +1724,7 @@ function islandora_repository_elements() { * @param type $element * @return string */ -function islandora_repository_expand_time($element) { +function fedora_repository_expand_time($element) { // Default to current time, check default_value but set value so that if // default value is present it will override value if (empty($element['#default_value'])) { @@ -1767,7 +1767,7 @@ function islandora_repository_expand_time($element) { * @param type $element * @return type */ -function islandora_repository_time($element) { +function fedora_repository_time($element) { $output = '<div class="container-inline">' . $element['#children'] . '</div>'; return theme('form_element', $element, $output); } @@ -1777,7 +1777,7 @@ function islandora_repository_time($element) { * @param type $element * @return type */ -function theme_islandora_repository_time($element) { +function theme_fedora_repository_time($element) { $output = '<div class="container-inline">' . $element['#children'] . '</div>'; return theme('form_element', $element, $output); } @@ -1788,9 +1788,9 @@ function theme_islandora_repository_time($element) { * fedora repository remove item from basket * @param type $pid */ -function islandora_repository_remove_item_from_basket($pid) { +function fedora_repository_remove_item_from_basket($pid) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; $objectHelper = new ObjectHelper(); @@ -1804,7 +1804,7 @@ function islandora_repository_remove_item_from_basket($pid) { if (!empty($cpids)) { // there are children foreach ($cpids as $child_pid => $value) { // remove child item from basket recursively - islandora_repository_remove_item_from_basket($child_pid); + fedora_repository_remove_item_from_basket($child_pid); } } } @@ -1813,14 +1813,14 @@ function islandora_repository_remove_item_from_basket($pid) { * fedora repository basket * @return type */ -function islandora_repository_basket() { - $pids = _islandora_repository_get_basket_pids(); - $output = drupal_get_form('islandora_repository_basket_form', $pids); +function fedora_repository_basket() { + $pids = _fedora_repository_get_basket_pids(); + $output = drupal_get_form('fedora_repository_basket_form', $pids); return $output; } -function islandora_repository_basket_form($form_state, $pids) { +function fedora_repository_basket_form($form_state, $pids) { $form = array(); if (!empty($pids)) { @@ -1874,7 +1874,7 @@ function islandora_repository_basket_form($form_state, $pids) { * @param type $form * @return string */ -function theme_islandora_repository_basket_form($form) { +function theme_fedora_repository_basket_form($form) { $header = array( theme('table_select_header_cell'), t('PID'), @@ -1909,7 +1909,7 @@ function theme_islandora_repository_basket_form($form) { * @param type $form * @param type $form_state */ -function islandora_repository_basket_form_validate($form, &$form_state) { +function fedora_repository_basket_form_validate($form, &$form_state) { } @@ -1920,13 +1920,13 @@ function islandora_repository_basket_form_validate($form, &$form_state) { * @param type $form_state * @return type */ -function islandora_repository_basket_form_submit($form, &$form_state) { +function fedora_repository_basket_form_submit($form, &$form_state) { if ($form_state['values']['op'] == $form_state['values']['remove_submit']) { $pids = $form_state['clicked_button']['#post']['remove']; if (isset($pids)) { foreach ($pids as $pid) { - islandora_repository_remove_from_basket($pid); + fedora_repository_remove_from_basket($pid); } drupal_set_message(t("Selected objects removed")); return; @@ -1934,14 +1934,14 @@ function islandora_repository_basket_form_submit($form, &$form_state) { } if ($form_state['values']['op'] == $form_state['values']['remove_all']) { - _islandora_repository_empty_basket(); + _fedora_repository_empty_basket(); drupal_set_message(t("Basket emptied")); return; } if ($form_state['values']['op'] == $form_state['values']['submit_all']) { $msg = t("All objects exported to staging area"); - $pids = _islandora_repository_get_basket_pids(); + $pids = _fedora_repository_get_basket_pids(); } elseif ($form_state['values']['op'] == $form_state['values']['submit']) { $msg = t("Selected objects exported to staging area"); @@ -1960,7 +1960,7 @@ function islandora_repository_basket_form_submit($form, &$form_state) { return FALSE; } - module_load_include('inc', 'islandora_repository', 'api/fedora_export'); + module_load_include('inc', 'fedora_repository', 'api/fedora_export'); foreach ($pids as $pid => $arr) { $objects_dir = $export_dir . '/objects/' . $pid; @@ -1977,7 +1977,7 @@ function islandora_repository_basket_form_submit($form, &$form_state) { $msg .= ":<br/>" . implode("<br/>", $log); drupal_set_message($msg, $success ? 'info' : 'error'); -//_islandora_repository_empty_basket(); +//_fedora_repository_empty_basket(); } else { drupal_set_message(t("No objects selected or basket empty"), 'error'); @@ -1991,7 +1991,7 @@ function islandora_repository_basket_form_submit($form, &$form_state) { * * @return type */ -function _islandora_repository_get_basket_pids() { +function _fedora_repository_get_basket_pids() { // Set empty defaults if basket elements are missing $_SESSION['basket'] = isset($_SESSION['basket']) ? $_SESSION['basket'] : array('processed' => array(), 'unprocessed' => array()); @@ -2000,7 +2000,7 @@ function _islandora_repository_get_basket_pids() { $pids = empty($_SESSION['basket']['processed']) ? array() : $_SESSION['basket']['processed']; - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $ob = new ObjectHelper(); foreach ($_SESSION['basket']['unprocessed'] as $pid) { // Check if the pid already exists in the tree @@ -2021,7 +2021,7 @@ function _islandora_repository_get_basket_pids() { /** * fedora repository empty basket */ -function _islandora_repository_empty_basket() { +function _fedora_repository_empty_basket() { unset($_SESSION['basket']); } @@ -2031,7 +2031,7 @@ function _islandora_repository_empty_basket() { * @param type $warn * @param type $searchResultsFlag */ -function islandora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) { +function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag = FALSE) { if ($warn && _is_added_to_basket($pid)) { drupal_set_message(t("Object already in basket")); } @@ -2054,7 +2054,7 @@ function islandora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFl * @param type $pid * @return type */ -function islandora_repository_remove_from_basket($pid) { +function fedora_repository_remove_from_basket($pid) { if (isset($_SESSION['basket']['unprocessed'][$pid])) { unset($_SESSION['basket']['unprocessed'][$pid]); } @@ -2110,8 +2110,8 @@ function _is_added_to_basket($pid, $account = NULL) { * @param type $file * @return type */ -function islandora_repository_display_schema($file) { - $path = drupal_get_path('module', 'islandora_repository'); +function fedora_repository_display_schema($file) { + $path = drupal_get_path('module', 'fedora_repository'); if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) { drupal_goto($path . '/' . $file); } @@ -2127,9 +2127,9 @@ function islandora_repository_display_schema($file) { * @param type $context * @return type */ -function islandora_repository_batch_reingest_object($object, &$context) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); +function fedora_repository_batch_reingest_object($object, &$context) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); if (!empty($object) && is_array($object)) { $pid = $object['pid']; if (!valid_pid($pid)) { @@ -2195,7 +2195,7 @@ function islandora_repository_batch_reingest_object($object, &$context) { * @param string $datastream_file * @return int, or NULL if no version attribute was found. */ -function islandora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { +function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { $return = NULL; if (isset($item)) { $doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); @@ -2221,9 +2221,9 @@ function islandora_repository_get_islandora_datastream_version($item = NULL, $ds * @param type $solution_packs * @return string */ -function theme_islandora_repository_solution_packs_list($solution_packs) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); +function theme_fedora_repository_solution_packs_list($solution_packs) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $output = ''; $header = array(); $rows = array(); @@ -2240,11 +2240,11 @@ function theme_islandora_repository_solution_packs_list($solution_packs) { * @param string $form_id * @return array */ -function islandora_repository_forms($form_id) { +function fedora_repository_forms($form_id) { $forms = array(); - if (strpos($form_id, 'islandora_repository_solution_pack_form_') === 0) { + if (strpos($form_id, 'fedora_repository_solution_pack_form_') === 0) { $forms[$form_id] = array( - 'callback' => 'islandora_repository_solution_pack_form', + 'callback' => 'fedora_repository_solution_pack_form', ); } return $forms; diff --git a/islandora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc similarity index 84% rename from islandora_repository.solutionpacks.inc rename to fedora_repository.solutionpacks.inc index 633d28fe..de4ce137 100644 --- a/islandora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -20,7 +20,7 @@ * * Datastreams which don't have this element are assumed to be at version 0. */ -function islandora_repository_solution_packs_page() { +function fedora_repository_solution_packs_page() { $enabled_solution_packs = module_invoke_all('required_fedora_objects'); $output = ''; foreach ($enabled_solution_packs as $solution_pack_module => $solution_pack_info) { @@ -35,7 +35,7 @@ function islandora_repository_solution_packs_page() { break; } } - $output .= drupal_get_form('islandora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects); + $output .= drupal_get_form('fedora_repository_solution_pack_form_' . $solution_pack_module, $solution_pack_module, $solution_pack_name, $objects); } return $output; @@ -45,9 +45,9 @@ function islandora_repository_solution_packs_page() { * Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. * @param array $solution_pack */ -function islandora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { +function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { // Check each object to see if it is in the repository. - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); global $base_path; $needs_update = FALSE; $needs_install = FALSE; @@ -111,8 +111,8 @@ function islandora_repository_solution_pack_form(&$form_state, $solution_pack_mo } if (isset($ds['dsversion'])) { // Check if the datastream is versioned and needs updating. - $installed_version = islandora_repository_get_islandora_datastream_version($item, $ds['dsid']); - $available_version = islandora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); + $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); + $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); if ($available_version > $installed_version) { $needs_update = TRUE; $object_status = 'Out of date'; @@ -151,25 +151,25 @@ function islandora_repository_solution_pack_form(&$form_state, $solution_pack_mo ); $form['#submit'] = array( - 'islandora_repository_solution_pack_form_submit', + 'fedora_repository_solution_pack_form_submit', ); return $form; } -function islandora_repository_solution_pack_form_submit($form, &$form_state) { +function fedora_repository_solution_pack_form_submit($form, &$form_state) { $what = $form_state; $module_name = $form_state['values']['solution_pack_module']; $solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); $batch = array( 'title' => t('Installing / updating solution pack objects'), - 'file' => drupal_get_path('module', 'islandora_repository') . '/islandora_repository.module', + 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', 'operations' => array(), ); foreach ($solution_pack_info[$module_name]['objects'] as $object) { // Add this object to the batch job queue. - $batch['operations'][] = array('islandora_repository_batch_reingest_object', array($object)); + $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); } batch_set($batch); } diff --git a/formClass.inc b/formClass.inc index a7abe947..af0dc218 100644 --- a/formClass.inc +++ b/formClass.inc @@ -24,15 +24,15 @@ class formClass { function createMenu() { $items = array(); - $items['admin/settings/islandora_repository'] = array( + $items['admin/settings/fedora_repository'] = array( 'title' => t('Islandora Configure'), 'description' => t('Enter the Islandora Collection information here'), 'page callback' => 'drupal_get_form', - 'page arguments' => array('islandora_repository_admin'), + 'page arguments' => array('fedora_repository_admin'), 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); - $items['admin/settings/islandora_repository/collection'] = array( + $items['admin/settings/fedora_repository/collection'] = array( 'title' => t('Collection list'), 'description' => t('Enter the Islandora collection information here.'), 'access arguments' => array('administer site configuration'), @@ -40,18 +40,18 @@ class formClass { 'weight' => 0, ); - $items['admin/settings/islandora_repository/demoobjects'] = array( + $items['admin/settings/fedora_repository/demoobjects'] = array( 'title' => t('Solution Packs'), 'description' => t('Install content models and collections required by installed solution packs.'), - 'page callback' => 'islandora_repository_solution_packs_page', + 'page callback' => 'fedora_repository_solution_packs_page', 'access arguments' => array('add fedora datastreams'), - 'file' => 'islandora_repository.solutionpacks.inc', + 'file' => 'fedora_repository.solutionpacks.inc', 'type' => MENU_LOCAL_TASK, ); $items['islandoracm.xsd'] = array( 'title' => t('Islandora Content Model XML Schema Definition'), - 'page callback' => 'islandora_repository_display_schema', + 'page callback' => 'fedora_repository_display_schema', 'page arguments' => array('islandoracm.xsd'), 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), @@ -59,7 +59,7 @@ class formClass { $items['collection_policy.xsd'] = array( 'title' => t('Islandora Content Model XML Schema Definition'), - 'page callback' => 'islandora_repository_display_schema', + 'page callback' => 'fedora_repository_display_schema', 'page arguments' => array('collection_policy.xsd'), 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), @@ -70,7 +70,7 @@ class formClass { 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); - $repository_title = variable_get('islandora_repository_title', 'Digital repository'); + $repository_title = variable_get('fedora_repository_title', 'Digital repository'); if (trim($repository_title) != '') { $respository_title = t($repository_title); } @@ -100,7 +100,7 @@ class formClass { $items['fedora/repository/editmetadata'] = array( 'title' => t('Edit metadata'), - 'page callback' => 'islandora_repository_edit_qdc_page', + 'page callback' => 'fedora_repository_edit_qdc_page', // 'page arguments' => array(1), //'type' => MENU_LOCAL_TASK, 'type' => MENU_CALLBACK, @@ -109,21 +109,21 @@ class formClass { $items['fedora/repository/purgeStream'] = array( 'title' => t('Purge data stream'), - 'page callback' => 'islandora_repository_purge_stream', + 'page callback' => 'fedora_repository_purge_stream', 'type' => MENU_CALLBACK, 'access arguments' => array('purge objects and datastreams') ); $items['fedora/repository/replaceStream'] = array( 'title' => t('Replace Stream'), - 'page callback' => 'islandora_repository_replace_stream', + 'page callback' => 'fedora_repository_replace_stream', 'type' => MENU_CALLBACK, 'access arguments' => array('add fedora datastreams'), ); $items['fedora/repository/purgeObject'] = array( 'title' => t('Purge object'), - 'page callback' => 'islandora_repository_purge_object', + 'page callback' => 'fedora_repository_purge_object', // 'type' => MENU_LOCAL_TASK, 'type' => MENU_CALLBACK, 'access arguments' => array('purge objects and datastreams') @@ -147,21 +147,21 @@ class formClass { //new for mnpl****************************************** $items['fedora/repository/mnpl_advanced_search'] = array( 'title' => t('Repository advanced search'), - 'page callback' => 'islandora_repository_mnpl_advanced_search', + 'page callback' => 'fedora_repository_mnpl_advanced_search', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection') ); $items['fedora/ingestObject'] = array( 'title' => t('Ingest object'), - 'page callback' => 'islandora_repository_ingest_object', + 'page callback' => 'fedora_repository_ingest_object', 'type' => MENU_CALLBACK, 'access arguments' => array('add fedora datastreams') ); $items['fedora/repository/list_terms'] = array( 'title' => t('List terms'), - 'page callback' => 'islandora_repository_list_terms', + 'page callback' => 'fedora_repository_list_terms', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection') ); @@ -170,25 +170,25 @@ class formClass { $items['fedora/basket'] = array( 'title' => t('Fedora Basket'), 'description' => t('View and download objects added to your basket'), - 'page callback' => 'islandora_repository_basket', + 'page callback' => 'fedora_repository_basket', 'access arguments' => array('view fedora collection'), 'type' => MENU_CALLBACK, ); $items['fedora/repository/addToBasket'] = array( - 'page callback' => 'islandora_repository_add_to_basket', + 'page callback' => 'fedora_repository_add_to_basket', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); $items['fedora/repository/removeFromBasket'] = array( - 'page callback' => 'islandora_repository_remove_from_basket', + 'page callback' => 'fedora_repository_remove_from_basket', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); $items['fedora/repository/add_search_results_to_basket'] = array( - 'page callback' => 'islandora_repository_add_search_results_to_basket', + 'page callback' => 'fedora_repository_add_search_results_to_basket', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); @@ -205,21 +205,21 @@ class formClass { drupal_set_message(t('You must be a site administrator to edit the Fedora collecitons list.'), 'error'); return; } - module_load_include('inc', 'islandora_repository', 'api/fedora_utils'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $form = array(); - $form['islandora_repository_name'] = array( + $form['fedora_repository_name'] = array( '#type' => 'textfield', '#title' => t('Root Collection Name'), - '#default_value' => variable_get('islandora_repository_name', 'Islandora demos collection'), + '#default_value' => variable_get('fedora_repository_name', 'Islandora demos collection'), '#description' => t('The Name of the Root Collection Object'), '#required' => TRUE, '#weight' => -20 ); - $form['islandora_repository_pid'] = array( + $form['fedora_repository_pid'] = array( '#type' => 'textfield', '#title' => t('Root Collection PID'), - '#default_value' => variable_get('islandora_repository_pid', 'islandora:root'), + '#default_value' => variable_get('fedora_repository_pid', 'islandora:root'), '#description' => t('The PID of the Root Collection Object'), '#required' => TRUE, '#weight' => -18 @@ -235,10 +235,10 @@ class formClass { ); - $form['islandora_repository_url'] = array( + $form['fedora_repository_url'] = array( '#type' => 'textfield', '#title' => t('Fedora RISearch URL'), - '#default_value' => variable_get('islandora_repository_url', 'http://localhost:8080/fedora/risearch'), + '#default_value' => variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'), '#description' => t('The url of the Fedora server'), '#required' => TRUE, '#weight' => -14 ); @@ -296,10 +296,10 @@ class formClass { '#weight' => 0 ); } - $form['islandora_repository_title'] = array( + $form['fedora_repository_title'] = array( '#type' => 'textfield', '#title' => t('Digital Repository Title'), - '#default_value' => variable_get('islandora_repository_title', 'Digital Repository'), + '#default_value' => variable_get('fedora_repository_title', 'Digital Repository'), '#description' => t('The title displayed when viewing collections and objects in /fedora/repository. Leave blank to display no title. Note that the menus must be rebuilt after changing this variable.'), ); $form['advanced'] = array( @@ -432,7 +432,7 @@ class formClass { * @return type */ function can_ingest_here($collection_pid) { - module_load_include('inc', 'islandora_repository', 'SecurityClass'); + module_load_include('inc', 'fedora_repository', 'SecurityClass'); $securityClass = new SecurityClass(); return $securityClass->canIngestHere($collection_pid); } @@ -447,7 +447,7 @@ class formClass { drupal_set_message(t('You do not have permission to ingest.'), 'error'); return FALSE; } - module_load_include('inc', 'islandora_repository', 'SecurityClass'); + module_load_include('inc', 'fedora_repository', 'SecurityClass'); $security_class = new SecurityClass(); if (!$security_class->canIngestHere($collection_pid)) { // Queries the collection object for a child security datastream and if found parses it @@ -507,7 +507,7 @@ class formClass { ), 'submit' => array( '#type' => 'submit', - '#submit' => array('islandora_repository_ingest_form_submit'), + '#submit' => array('fedora_repository_ingest_form_submit'), '#value' => t('Next') ), ); @@ -523,7 +523,7 @@ class formClass { * @return array */ function createQDCIngestFormPageTwo($collection_pid, $collection_label, array &$form_state) { - module_load_include('inc', 'islandora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); $form = array(); $content_model_pid = ContentModel::getPidFromIdentifier($form_state['values']['models']); $content_model_dsid = ContentModel::getDSIDFromIdentifier($form_state['values']['models']); @@ -541,7 +541,7 @@ class formClass { ); $form['submit'] = array( '#type' => 'submit', - '#submit' => array('islandora_repository_ingest_form_submit'), + '#submit' => array('fedora_repository_ingest_form_submit'), '#value' => t('Ingest') ); } @@ -558,7 +558,7 @@ class formClass { * @return array */ function createQDCIngestForm($collection_pid, $collection_label, array &$form_state) { - module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); + module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); $form_state['storage']['step'] = empty($form_state['storage']['step']) ? 1 : $form_state['storage']['step']; if ($form_state['storage']['step'] == 1) { return $this->createQDCIngestFormPageOne($collection_pid, $collection_label, $form_state); @@ -603,9 +603,9 @@ class formClass { //dump_vars($form_state); // Populate the list of datastream IDs. - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'ContentModel'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $obj_helper = new ObjectHelper(); $content_models = $obj_helper->get_content_models_list($pid); diff --git a/islandoracm.xsd b/islandoracm.xsd index 21ab6661..bce83136 100644 --- a/islandoracm.xsd +++ b/islandoracm.xsd @@ -48,14 +48,14 @@ </xsd:complexType> <xsd:complexType name="form_builder_methodType"> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="handler" type="xsd:normalizedString" use="required"/> </xsd:complexType> <xsd:complexType name="edit_metadata_methodType"> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="handler" type="xsd:normalizedString" use="required"/> @@ -118,7 +118,7 @@ </xsd:all> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="dsid" type="xsd:normalizedString" use="required"/> @@ -149,7 +149,7 @@ <xsd:element name="parameters" type="parametersType" minOccurs="0"/> </xsd:all> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="dsid" type="xsd:normalizedString" use="required"/> @@ -171,7 +171,7 @@ <xsd:complexContent> <xsd:restriction base="xsd:anyType"> <xsd:attribute name="file" type="xsd:normalizedString" use="required"/> - <xsd:attribute name="module" type="xsd:normalizedString" default="islandora_repository"/> + <xsd:attribute name="module" type="xsd:normalizedString" default="fedora_repository"/> <xsd:attribute name="class" type="xsd:normalizedString" use="required"/> <xsd:attribute name="method" type="xsd:normalizedString" use="required"/> <xsd:attribute name="default" type="xsd:boolean" default="false"/> diff --git a/plugins/CollectionFormBuilder.inc b/plugins/CollectionFormBuilder.inc index 6d901b21..a385aa26 100644 --- a/plugins/CollectionFormBuilder.inc +++ b/plugins/CollectionFormBuilder.inc @@ -7,7 +7,7 @@ * Collection Form Builder */ -module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml @@ -32,7 +32,7 @@ class CollectionFormBuilder extends FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); diff --git a/plugins/DarwinCore.inc b/plugins/DarwinCore.inc index 814e9dfb..5ab525b6 100644 --- a/plugins/DarwinCore.inc +++ b/plugins/DarwinCore.inc @@ -21,7 +21,7 @@ class DarwinCore { * @param type $item */ function __construct($item = NULL) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); if (!empty($item)) { $this->owner = $item; if (array_key_exists('DARWIN_CORE', $item->get_datastreams_list_as_array())) { @@ -200,7 +200,7 @@ class DarwinCore { * @param type $form_values */ public function handleForm($form_values) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); global $user; //$new_item = Fedora_Item::ingest_new_item($form_values['pid'], 'A', $form_values['dwc:institutionCode'].':'.$form_values['dwc:collectionCode'].':'.$form_values['dwc:catalogNumber'], $user->name); //$new_item->add_datastream_from_string($this->darwinCoreXML, 'DARWIN_CORE', 'Darwin Core Metadata', 'text/xml', 'X'); @@ -248,8 +248,8 @@ class DarwinCore { */ public function asHTML() { $path = drupal_get_path('module', 'Fedora_Repository'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); $xmlstr = $this->darwinCoreXML; html_entity_decode($xmlstr); diff --git a/plugins/DemoFormBuilder.inc b/plugins/DemoFormBuilder.inc index d2d7f738..ccc74ba2 100644 --- a/plugins/DemoFormBuilder.inc +++ b/plugins/DemoFormBuilder.inc @@ -6,7 +6,7 @@ * @file * */ -module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml @@ -19,7 +19,7 @@ class DemoFormBuilder extends FormBuilder { * Constructor */ function DemoFormBuilder() { - module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); + module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); } @@ -31,7 +31,7 @@ class DemoFormBuilder extends FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); $server = NULL; diff --git a/plugins/DocumentConverter.inc b/plugins/DocumentConverter.inc index e64517c6..f258441a 100644 --- a/plugins/DocumentConverter.inc +++ b/plugins/DocumentConverter.inc @@ -32,7 +32,7 @@ class DocumentConverter { * @return string */ function convert($parameterArray = NULL, $dsid, $file, $output_ext) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); #debug: #drupal_set_message("Sending $file to ". $this->converter_service_url ." for convertsion to $output_ext", 'status'); diff --git a/plugins/Exiftool.inc b/plugins/Exiftool.inc index 5db3d600..c0b98981 100644 --- a/plugins/Exiftool.inc +++ b/plugins/Exiftool.inc @@ -22,7 +22,7 @@ class Exiftool { function __construct($pid) { //drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $this->pid = $pid; - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $this->item = new Fedora_Item($this->pid); } diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc index de8d10a7..855d508c 100644 --- a/plugins/FedoraObjectDetailedContent.inc +++ b/plugins/FedoraObjectDetailedContent.inc @@ -19,7 +19,7 @@ class FedoraObjectDetailedContent { * @param type $pid */ function __construct($pid = '') { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); if (!empty($pid)) { $this->pid = $pid; @@ -36,9 +36,9 @@ class FedoraObjectDetailedContent { global $user; $objectHelper = new ObjectHelper(); $tabset = array(); - $show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'islandora_repository_purge_object_form'); - $show_edit_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'islandora_repository_edit_qdc_form'); - $purge_form = drupal_get_form('islandora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path())))); + $show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_purge_object_form'); + $show_edit_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_edit_qdc_form'); + $purge_form = drupal_get_form('fedora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path())))); $tabset['fedora_object_details'] = array( '#type' => 'tabpage', @@ -59,8 +59,8 @@ class FedoraObjectDetailedContent { '#content' => $dc_html . $ds_list . $purge_form, ); - if (islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { - $editform = drupal_get_form('islandora_repository_edit_qdc_form', $this->pid, 'DC'); + if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { + $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); $tabset['fedora_object_details']['tabset']['edit'] = array( '#type' => 'tabpage', '#title' => t('Edit'), diff --git a/plugins/Flv.inc b/plugins/Flv.inc index d1dc03d3..d8f2b06b 100644 --- a/plugins/Flv.inc +++ b/plugins/Flv.inc @@ -138,7 +138,7 @@ class FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); $mimetype = new MimeClass(); $server = NULL; $file = $form_values['ingest-file-location']; diff --git a/plugins/FlvFormBuilder.inc b/plugins/FlvFormBuilder.inc index f9d13e56..c259328c 100644 --- a/plugins/FlvFormBuilder.inc +++ b/plugins/FlvFormBuilder.inc @@ -6,7 +6,7 @@ * @file * FLVFormBuilder */ -module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml @@ -19,7 +19,7 @@ class FlvFormBuilder extends FormBuilder { * Constructor */ function FlvFormBuilder() { - module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); + module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); } @@ -32,7 +32,7 @@ class FlvFormBuilder extends FormBuilder { */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); $server = NULL; diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index 695fa2c6..382733b4 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -84,7 +84,7 @@ class FormBuilder { * @return type */ function createPolicy($collectionPid, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $dsid = 'CHILD_SECURITY'; @@ -135,8 +135,8 @@ class FormBuilder { * @return type */ function handleQDCForm($form_values) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = TRUE; @@ -196,7 +196,7 @@ class FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); $server = NULL; diff --git a/plugins/ImageManipulation.inc b/plugins/ImageManipulation.inc index c67e4911..8f97ab94 100644 --- a/plugins/ImageManipulation.inc +++ b/plugins/ImageManipulation.inc @@ -16,7 +16,7 @@ class ImageManipulation { * Constructor */ function ImageManipulation() { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); } /** diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index 26662cf2..d49869e2 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -6,7 +6,7 @@ * @file * ModsFormBuilder class */ -module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * ModsFormBuilder class ??? @@ -25,8 +25,8 @@ class ModsFormBuilder extends FormBuilder { function __construct($pid=NULL) { parent::__construct(); if ($pid !== NULL) { - module_load_include('inc', 'islandora_repository', 'ContentModel'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $this->pid = $pid; $this->cm = ContentModel::loadFromObject($pid); @@ -241,7 +241,7 @@ class ModsFormBuilder extends FormBuilder { $form['submit'] = array( '#type' => 'submit', - '#submit' => array('islandora_repository_edit_qdc_form_submit'), + '#submit' => array('fedora_repository_edit_qdc_form_submit'), '#value' => 'Save Metadata' ); @@ -256,8 +256,8 @@ class ModsFormBuilder extends FormBuilder { * @param &$form_state */ function handleModsForm(&$form_values, &$form_state) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'CollectionPolicy'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); $form_state['storage']['people'] = NULL; //clears out old entities for the next run of the formbuilder. @@ -329,7 +329,7 @@ class ModsFormBuilder extends FormBuilder { * @param &$rootElement */ function createCollectionPolicy($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $model = new fedora_item($form_values['content_model_pid']); $ds_list = $model->get_datastreams_list_as_array(); if (isset($ds_list['COLLECTION_POLICY_TMPL'])) { @@ -364,7 +364,7 @@ class ModsFormBuilder extends FormBuilder { * @param &$rootElement */ function createWorkflowStream($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $model = new fedora_item($form_values['content_model_pid']); $ds_list = $model->get_datastreams_list_as_array(); if (isset($ds_list['WORKFLOW_TMPL'])) { diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index b4742711..68ae5528 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/plugins/PersonalCollectionClass.inc @@ -120,7 +120,7 @@ class PersonalCollectionClass { * @return type */ function createPolicyStream($user, $dom, $rootElement) { - module_load_include('inc', 'islandora_repository', 'SecurityClass'); + module_load_include('inc', 'fedora_repository', 'SecurityClass'); $securityClass = new SecurityClass(); $policyStreamDoc = $securityClass->createPersonalPolicy($user); diff --git a/plugins/QtFormBuilder.php b/plugins/QtFormBuilder.php index 954f28e4..28645d6b 100644 --- a/plugins/QtFormBuilder.php +++ b/plugins/QtFormBuilder.php @@ -6,7 +6,7 @@ * @file * QTFormBuilder class */ -module_load_include('inc', 'islandora_repository', 'plugins/FormBuilder'); +module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * Implements methods from content model ingest form xml @@ -30,7 +30,7 @@ class QtFormBuilder extends FormBuilder { * @param type $rootElement */ function createFedoraDataStreams($form_values, &$dom, &$rootElement) { - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); global $base_url; $mimetype = new MimeClass(); $server = null; diff --git a/plugins/Refworks.inc b/plugins/Refworks.inc index 4f0d6fc3..592a7e99 100644 --- a/plugins/Refworks.inc +++ b/plugins/Refworks.inc @@ -7,7 +7,7 @@ * Refworks class */ -module_load_include('inc', 'islandora_repository', 'SecurityClass'); +module_load_include('inc', 'fedora_repository', 'SecurityClass'); /** * Refworks class ??? @@ -222,9 +222,9 @@ class Refworks { */ function handleForm(&$form_values) { $errorMessage = NULL; - module_load_include('inc', 'islandora_repository', 'CollectionClass'); - module_load_include('inc', 'islandora_repository', 'ContentModel'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $contentModelPid = ContentModel::getPidFromIdentifier($form_values['models']); $contentModelDsid = ContentModel::getDSIDFromIdentifier($form_values['models']); $collectionHelper = new CollectionClass(); @@ -238,7 +238,7 @@ class Refworks { $collection_item = new Fedora_Item($collection_pid); $this->collectionPolicyStream = $collection_item->get_datastream_dissemination('CHILD_SECURITY'); if (empty($this->collectionPolicyStream)) { - $this->collectionPolicyStream = file_get_contents(drupal_get_path('module', 'islandora_repository') . '/policies/noObjectEditPolicy.xml'); + $this->collectionPolicyStream = file_get_contents(drupal_get_path('module', 'fedora_repository') . '/policies/noObjectEditPolicy.xml'); } $success = 0; $errors = 0; @@ -388,7 +388,7 @@ class Refworks { */ function createFedoraDataStreams($form_values, &$dom, &$rootElement, $reference) { global $base_url; - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); $mimetype = new MimeClass(); $server = NULL; $this->createRomeoDataStream($dom, $rootElement); diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index efa1ab7e..77eada60 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -87,7 +87,7 @@ class ShowStreamsInFieldSets { global $base_url; global $base_path; global $user; - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $tabset = array(); @@ -105,7 +105,7 @@ class ShowStreamsInFieldSets { $tn_url = $base_url . '/fedora/repository/' . $item->pid . '/TN'; } else { - $tn_url = $base_path . drupal_get_path('module', 'islandora_repository') . '/images/Crystal_Clear_app_download_manager.png'; + $tn_url = $base_path . drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_app_download_manager.png'; } $dc_html = $objectHelper->getFormattedDC($item); @@ -117,8 +117,8 @@ class ShowStreamsInFieldSets { '#content' => $dl_link . $dc_html, ); - if (islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { - $editform = drupal_get_form('islandora_repository_edit_qdc_form', $this->pid, 'DC'); + if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { + $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); $tabset['first_tab']['tabs']['edit'] = array( '#type' => 'tabpage', '#title' => t('Edit'), @@ -142,7 +142,7 @@ class ShowStreamsInFieldSets { * @return type */ function showQdc() { - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $content = $objectHelper->getQDC($this->pid); $collection_fieldset = array( @@ -161,7 +161,7 @@ class ShowStreamsInFieldSets { */ function showOBJLink() { global $base_url; - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $item = new Fedora_Item($this->pid); $streams = $item->get_datastreams_list_as_array(); return "<a href='" . $base_url . "/fedora/repository/" . $this->pid . "/OBJ/" . $streams['OBJ']['label'] . "'>" . $streams['OBJ']['label'] . "</a>"; @@ -172,8 +172,8 @@ class ShowStreamsInFieldSets { * @return type */ function showRefworks() { - $path = drupal_get_path('module', 'islandora_repository'); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + $path = drupal_get_path('module', 'fedora_repository'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $collectionHelper = new CollectionClass(); $xmlstr = $collectionHelper->getStream($this->pid, "refworks"); html_entity_decode($xmlstr); @@ -226,7 +226,7 @@ class ShowStreamsInFieldSets { */ function showRomeo($collapsed = FALSE) { $path = drupal_get_path('module', 'Fedora_Repository'); - module_load_include('inc', 'islandora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'CollectionClass'); $collectionHelper = new CollectionClass(); $xmlstr = $collectionHelper->getStream($this->pid, "ROMEO", 0); diff --git a/plugins/islandora_imageapi.info b/plugins/fedora_imageapi.info similarity index 82% rename from plugins/islandora_imageapi.info rename to plugins/fedora_imageapi.info index 5519ad85..6a465a04 100644 --- a/plugins/islandora_imageapi.info +++ b/plugins/fedora_imageapi.info @@ -1,7 +1,7 @@ name = Fedora ImageAPI description = Adds image manipulation support through a REST interface package = Islandora Dependencies -dependencies[] = islandora_repository +dependencies[] = fedora_repository dependencies[] = imageapi version = 11.2.beta2 core = 6.x diff --git a/plugins/islandora_imageapi.module b/plugins/fedora_imageapi.module similarity index 89% rename from plugins/islandora_imageapi.module rename to plugins/fedora_imageapi.module index cbe6225d..f3bd4481 100644 --- a/plugins/islandora_imageapi.module +++ b/plugins/fedora_imageapi.module @@ -6,7 +6,7 @@ function fedora_imageapi_menu() { $items = array(); $items['fedora/imageapi'] = array( 'title' => t('Image manipulation functions'), - 'page callback' => 'islandora_repository_image_manip', + 'page callback' => 'fedora_repository_image_manip', 'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'), ); @@ -21,7 +21,7 @@ function fedora_imageapi_menu() { * @param string $op * @param string $params */ -function islandora_repository_image_manip($pid = '', $dsid = '', $op = '', $params = '') { +function fedora_repository_image_manip($pid = '', $dsid = '', $op = '', $params = '') { module_load_include('inc', 'Fedora_Repository', 'ObjectHelper'); module_load_include('module', 'imageapi'); $obj = new ObjectHelper(); @@ -30,7 +30,7 @@ function islandora_repository_image_manip($pid = '', $dsid = '', $op = '', $para $op = (!empty($_GET['op']) ? $_GET['op'] : ''); $safe_pid = str_replace(':', '_', $pid); - $cache_key = 'islandora_repository_image_manip_' . md5($safe_pid . '_' . $dsid . '_' . $ext . '_' . $op . (isset($_GET['width']) ? '_' . $_GET['width'] : '') . (isset($_GET['height']) ? '_' . $_GET['height'] : '')); + $cache_key = 'fedora_repository_image_manip_' . md5($safe_pid . '_' . $dsid . '_' . $ext . '_' . $op . (isset($_GET['width']) ? '_' . $_GET['width'] : '') . (isset($_GET['height']) ? '_' . $_GET['height'] : '')); if (($file = cache_get($cache_key)) === 0) { //added the slash as sys_get_temp_dir in linux does not seem to include the slash $tmp_file_name = sys_get_temp_dir() . '/' . $safe_pid . '_' . $dsid . '.' . $ext; @@ -83,7 +83,7 @@ function islandora_repository_image_manip($pid = '', $dsid = '', $op = '', $para function fedora_imageapi_form_alter( &$form, $form_state, $form_id) { switch ( $form_id ) { - case 'islandora_repository_admin': + case 'fedora_repository_admin': $fedora_base_url = $form['fedora_base_url']['#default_value']; diff --git a/plugins/herbarium.inc b/plugins/herbarium.inc index f831bc59..f7a6d685 100644 --- a/plugins/herbarium.inc +++ b/plugins/herbarium.inc @@ -16,7 +16,7 @@ class Herbarium { function __construct($pid = '') { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); if (!empty($pid)) { $this->pid = $pid; $this->item = new Fedora_Item($pid); @@ -32,7 +32,7 @@ class Herbarium { public function buildDrupalForm($form = array(), $form_state = array()) { // We don't need to add anything beyond the standard Darwin Core form so just pass this through // If we wanted to we could add other fields. - module_load_include('inc', 'islandora_repository', 'plugins/DarwinCore'); + module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); $dwc = new DarwinCore($this->item); return $dwc->buildDrupalForm($form); @@ -73,9 +73,9 @@ class Herbarium { * Process the metadata form * Update the datastreams */ - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'plugins/DarwinCore'); - module_load_include('inc', 'islandora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); global $user; $mimetype = new MimeClass(); $dwc = new DarwinCore($this->item); @@ -97,9 +97,9 @@ class Herbarium { * Create fedora object * Add the datastreams */ - module_load_include('inc', 'islandora_repository', 'MimeClass'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'plugins/DarwinCore'); + module_load_include('inc', 'fedora_repository', 'MimeClass'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); global $user; $mimetype = new MimeClass(); $dwc = new DarwinCore(); @@ -141,8 +141,8 @@ class Herbarium { * @return string */ public function showFieldSets() { - module_load_include('inc', 'islandora_repository', 'plugins/tagging_form'); - module_load_include('inc', 'islandora_repository', 'plugins/DarwinCore'); + module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); + module_load_include('inc', 'fedora_repository', 'plugins/DarwinCore'); global $base_url; $tabset = array(); @@ -167,7 +167,7 @@ class Herbarium { '#title' => t('View'), // This will be the content of the tab. '#content' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/FULL_JPG/"><img src="' . $base_url . '/fedora/imageapi/' . - $this->pid . '/JPG/JPG.jpg' . '" /></a>' . '<p>' . drupal_get_form('islandora_repository_image_tagging_form', $this->pid) . '</p>', + $this->pid . '/JPG/JPG.jpg' . '" /></a>' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>', ); $dwc = new DarwinCore($this->item); @@ -184,10 +184,10 @@ class Herbarium { '#title' => t('Darwin Core'), '#content' => $dwc->asHTML(), ); - module_load_include('inc', 'islandora_repository', 'ObjectHelper'); + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $obj = new ObjectHelper(); - if (islandora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { - $editform = drupal_get_form('islandora_repository_edit_qdc_form', $this->pid, 'DARWIN_CORE'); + if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { + $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DARWIN_CORE'); $tabset['third_tab']['tabset']['edit'] = array( '#type' => 'tabpage', '#title' => t('Edit'), diff --git a/plugins/map_viewer.inc b/plugins/map_viewer.inc index 2ad56c0a..3e9bcfb6 100644 --- a/plugins/map_viewer.inc +++ b/plugins/map_viewer.inc @@ -29,9 +29,9 @@ class ShowMapStreamsInFieldSets { * @return type */ function showJPG() { - module_load_include('inc', 'islandora_repository', 'plugins/tagging_form'); - module_load_include('inc', 'islandora_repository', 'plugins/ShowStreamsInFieldSets'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); + module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); global $base_url; @@ -51,8 +51,8 @@ class ShowMapStreamsInFieldSets { $html = '<iframe src="' . $viewer_url . '" scrolling="no" frameborder="0" style="width: 100%; height: 800px;">Errors: unable to load viewer</iframe>'; drupal_add_css(path_to_theme() . '/header-viewer.css', 'theme'); - drupal_add_css(drupal_get_path('module', 'islandora_repository') . '/js/iiv/css/jquery-ui/smoothness/jquery-ui-1.7.2.custom.css'); - drupal_add_css(drupal_get_path('module', 'islandora_repository') . '/js/iiv/css/iiv.css'); + drupal_add_css(drupal_get_path('module', 'fedora_repository') . '/js/iiv/css/jquery-ui/smoothness/jquery-ui-1.7.2.custom.css'); + drupal_add_css(drupal_get_path('module', 'fedora_repository') . '/js/iiv/css/iiv.css'); $tabset['my_tabset']['second_tab'] = array( diff --git a/plugins/qt_viewer.inc b/plugins/qt_viewer.inc index 09d24cca..ec321ca1 100644 --- a/plugins/qt_viewer.inc +++ b/plugins/qt_viewer.inc @@ -112,9 +112,9 @@ class ShowQtStreamsInFieldSets { * @return type */ function showQt() { - module_load_include('inc', 'islandora_repository', 'plugins/tagging_form'); - module_load_include('inc', 'islandora_repository', 'plugins/ShowStreamsInFieldSets'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); + module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $info = $this->technicalMetadata(array('width' => 640, 'height' => 480)); $width = $info['width']; diff --git a/plugins/slide_viewer.inc b/plugins/slide_viewer.inc index ef569487..1d23b227 100644 --- a/plugins/slide_viewer.inc +++ b/plugins/slide_viewer.inc @@ -30,8 +30,8 @@ class ShowSlideStreamsInFieldSets { * @return type */ function showJPG() { - module_load_include('inc', 'islandora_repository', 'plugins/tagging_form'); - module_load_include('inc', 'islandora_repository', 'plugins/ShowStreamsInFieldSets'); + module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); + module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); global $base_url; global $user; @@ -58,7 +58,7 @@ class ShowSlideStreamsInFieldSets { '#title' => t('View'), // This will be the content of the tab. '#content' => '<img src="' . $base_url . - '/fedora/imageapi/' . $this->pid . '/JPG/JPG.jpg' . '" />' . '<p>' . drupal_get_form('islandora_repository_image_tagging_form', $this->pid) . '</p>', + '/fedora/imageapi/' . $this->pid . '/JPG/JPG.jpg' . '" />' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>', ); return $tabset; diff --git a/plugins/tagging_form.inc b/plugins/tagging_form.inc index ca32ecd5..0a421105 100644 --- a/plugins/tagging_form.inc +++ b/plugins/tagging_form.inc @@ -13,9 +13,9 @@ * @return string */ function _show_subject_tags($pid) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/dublin_core'); - module_load_include('inc', 'islandora_repository', 'api/tagging'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/dublin_core'); + module_load_include('inc', 'fedora_repository', 'api/tagging'); $obj = new Fedora_Item($pid); $tags = new TagSet($obj); if (!empty($tags->tags)) { @@ -35,10 +35,10 @@ function _show_subject_tags($pid) { * @param type $pid * @return type */ -function islandora_repository_image_tagging_form($form_state, $pid) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/dublin_core'); - module_load_include('inc', 'islandora_repository', 'api/tagging'); +function fedora_repository_image_tagging_form($form_state, $pid) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/dublin_core'); + module_load_include('inc', 'fedora_repository', 'api/tagging'); global $base_url; if (!empty($form_state['post']['pid'])) { @@ -71,7 +71,7 @@ function islandora_repository_image_tagging_form($form_state, $pid) { // Delete button for each existing tag. $form['tags-wrapper']['tags'][$tag['name']]['delete'] = array( '#type' => 'imagebutton', - '#image' => $base_url . '/' . drupal_get_path('module', 'islandora_repository') . '/images/remove_icon.png', + '#image' => $base_url . '/' . drupal_get_path('module', 'fedora_repository') . '/images/remove_icon.png', '#default_value' => $tag['name'], '#title' => t('Delete this tag'), ); @@ -122,9 +122,9 @@ function hook_imagebutton_process($form) { * @param type $form * @param type $form_state */ -function islandora_repository_image_tagging_form_submit($form, &$form_state) { - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); - module_load_include('inc', 'islandora_repository', 'api/tagging'); +function fedora_repository_image_tagging_form_submit($form, &$form_state) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/tagging'); global $user; $item = new Fedora_Item($form_state['values']['pid']); diff --git a/tests/README_TESTING.txt b/tests/README_TESTING.txt index f38af855..c9dde164 100644 --- a/tests/README_TESTING.txt +++ b/tests/README_TESTING.txt @@ -21,7 +21,7 @@ $FEDORA_HOME/server/config/fedora-users.xml: </attribute> </user> -If you look in the islandora_repository.test file we see that we are creating +If you look in the fedora_repository.test file we see that we are creating a user with a password set to 'simpletestpass'. Fedora requires the hashed version of this password to do a servlet filter-based authentication. diff --git a/tests/fedora_repository.test b/tests/fedora_repository.test index d5e59bc8..bbad2569 100644 --- a/tests/fedora_repository.test +++ b/tests/fedora_repository.test @@ -16,9 +16,9 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { } function setUp() { - parent::setUp('tabs', 'islandora_repository'); + parent::setUp('tabs', 'fedora_repository'); - module_load_include('inc', 'islandora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); // Create and login user. $repository_user = $this->drupalCreateFedoraUser(array('add fedora datastreams', @@ -57,11 +57,11 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $ingest_form_step_2['dc:title'] = $this->randomName(32); $ingest_form_step_2['dc:description'] = $this->randomName(256); - $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'islandora_repository') . '/tests/test_files/lorem_ipsum.pdf'); + $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_repository') . '/tests/test_files/lorem_ipsum.pdf'); $this->drupalPost(NULL, $ingest_form_step_2, 'Ingest'); $this->assertText('mimetype (application/pdf) is not associated with this Content Model', 'PDF mime type not accepted in collection content model.', 'message'); - $this->outputScreenContents('Initial ingest form submit step 2', 'islandora_repository'); + $this->outputScreenContents('Initial ingest form submit step 2', 'fedora_repository'); // Now try ingesting a proper collection policy. $ingest_form = array(); @@ -72,9 +72,9 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $ingest_form_step_2 = array(); $ingest_form_step_2['dc:title'] = $this->randomName(32); $ingest_form_step_2['dc:description'] = $this->randomName(256); - $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'islandora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml'); + $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml'); $this->drupalPost(NULL, $ingest_form_step_2, 'Ingest'); - //$this->outputScreenContents('Initial ingest form submit step 2 - PDF collection', 'islandora_repository'); + //$this->outputScreenContents('Initial ingest form submit step 2 - PDF collection', 'fedora_repository'); $this->assertPattern('/Item .* created successfully./', "Verified item created."); $pid = $this->getIngestedPid(); @@ -88,7 +88,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $ingest_form_step_2 = array(); $ingest_form_step_2['dc:title'] = "Lorem Ipsum"; $ingest_form_step_2['dc:description'] = $this->randomName(256); - $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'islandora_repository') . '/tests/test_files/lorem_ipsum.pdf'); + $ingest_form_step_2['files[ingest-file-location]'] = realpath(drupal_get_path('module', 'fedora_repository') . '/tests/test_files/lorem_ipsum.pdf'); $this->drupalPost(NULL, $ingest_form_step_2, 'Ingest'); $pid = $this->getIngestedPid(); $pid_list[] = $pid; @@ -104,7 +104,7 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $admin_tester = $this->drupalCreateUser(array('administer site configuration', 'view fedora collection')); $this->drupalLogin($admin_tester); - $pageContent = $this->drupalGet('admin/settings/islandora_repository'); + $pageContent = $this->drupalGet('admin/settings/fedora_repository'); $hasOption = preg_match('/Enforce namespace restrictions/', $pageContent); @@ -115,13 +115,13 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase { $this->pass('Removal of namespace restrictions is enabled'); $inVal['fedora_namespace_restriction_enforced'] = TRUE; $inVal['fedora_pids_allowed'] = 'simpletest:'; - $this->drupalPost('admin/settings/islandora_repository', $inVal, 'Save configuration'); + $this->drupalPost('admin/settings/fedora_repository', $inVal, 'Save configuration'); $this->assertPattern('/The configuration options have been saved./', 'The configuration options have been saved.'); $this->drupalGet('fedora/repository/islandora:largeimages/'); $this->assertPattern('/Access denied/', 'No access to Large image Collection Collection'); $inVal['fedora_namespace_restriction_enforced'] = 0; - $this->drupalPost('admin/settings/islandora_repository', $inVal, 'Save configuration'); + $this->drupalPost('admin/settings/fedora_repository', $inVal, 'Save configuration'); $this->assertPattern('/The configuration options have been saved./', 'The configuration options have been saved.'); $this->drupalLogin($this->repository_user); $this->drupalGet('fedora/repository/islandora:largeimages/'); From 632de8f9f0d627ee760fa8b57ad56e98f7aa2c54 Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Wed, 12 Oct 2011 14:31:06 -0300 Subject: [PATCH 12/46] Change the way we checked for ISLANDORACM datastream to take some strain off the logs --- api/fedora_utils.inc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index c8ce7d0e..98d83f3a 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -6,7 +6,6 @@ * @file * Base utilities used by the Islandora fedora module. */ - if (!function_exists('str_getcsv')) { /** @@ -96,9 +95,8 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post */ function do_curl_ext($url, $return_to_variable = 1, $number_of_post_vars = 0, $post = NULL) { global $user; - + // Check if we are inside Drupal and there is a valid user. - // If the user is not valid for a Fedora call curl will throw an exception. if ((!isset($user)) || $user->uid == 0) { $fedora_user = 'anonymous'; @@ -126,14 +124,13 @@ function do_curl_ext($url, $return_to_variable = 1, $number_of_post_vars = 0, $p curl_setopt($ch, CURLOPT_POST, $number_of_post_vars); curl_setopt($ch, CURLOPT_POSTFIELDS, "$post"); } - + $ret_val = curl_exec($ch); - + $error_code = curl_errno($ch); $error_string = curl_error($ch); - return array ($ret_val, $error_code, $error_string); + return array($ret_val, $error_code, $error_string); } - else { if (function_exists(drupal_set_message)) { drupal_set_message(t('No curl support.'), 'error'); @@ -159,10 +156,9 @@ function fedora_available() { function risearch_available() { $response = do_curl_ext(variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch')); - return ($response != NULL) ? ($response[1] == 0): FALSE; + return ($response != NULL) ? ($response[1] == 0) : FALSE; } - /** * Returns a UTF-8-encoded transcripiton of the string given in $in_str. * @param string $in_str @@ -264,7 +260,7 @@ function get_collections_as_option_array() { /** * Function: get_content_models_as_option_array * - * Description: Returns an associative array of all collection objects in Fedora instance + * Description: Returns an associative array of all available content models in Fedora instance * * @return array */ @@ -298,9 +294,10 @@ function get_content_models_as_option_array() { $item = new fedora_item($parts[0]); $nameparts = explode(':', $parts[0]); if (!$restricted || in_array($nameparts[0], $allowed)) - if ($item->get_datastream_dissemination('ISLANDORACM')) { - $options[$parts[0]] = $parts[1]. ' ~ ' . $parts[0] ; - } + $datastreams = array_keys($item->get_datastreams_list_as_array()); + if (in_array('ISLANDORACM', $datastreams)) { + $options[$parts[0]] = $parts[1] . ' ~ ' . $parts[0]; + } } } From 58ceada8758334816873cd07c13e2d2a5094eb94 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Wed, 12 Oct 2011 15:45:59 -0300 Subject: [PATCH 13/46] Coding standard cleanup --- BatchIngest.inc | 6 ++-- CollectionClass.inc | 8 +++--- CollectionManagement.inc | 6 ++-- CollectionPolicy.inc | 16 +++++------ ContentModel.inc | 54 +++++++++++++++++------------------ ObjectHelper.inc | 4 +-- XMLDatastream.inc | 4 +-- api/fedora_export.inc | 2 +- api/fedora_item.inc | 6 ++-- api/fedora_utils.inc | 6 ++-- fedora_repository.module | 2 +- formClass.inc | 8 +++--- plugins/ImageManipulation.inc | 2 +- plugins/qt_viewer.inc | 4 +-- 14 files changed, 64 insertions(+), 64 deletions(-) diff --git a/BatchIngest.inc b/BatchIngest.inc index ed768294..621a674a 100644 --- a/BatchIngest.inc +++ b/BatchIngest.inc @@ -38,7 +38,7 @@ function batch_creation_form(&$form_state, $collection_pid, $content_models) { '#title' => "Choose content model to be associated with objects ingested", '#type' => 'select', '#options' => $cm_options, - '#required' => true, + '#required' => TRUE, '#description' => t("Content models describe the behaviours of objects with which they are associated."), ); $form['indicator']['file-location'] = array( @@ -251,14 +251,14 @@ function batch_create_dc_from_mods($mods_xml) { */ function recursive_directory_delete($dir) { if (!file_exists($dir)) - return true; + return TRUE; if (!is_dir($dir)) return unlink($dir); foreach (scandir($dir) as $item) { if ($item == '.' || $item == '..') continue; if (!recursive_directory_delete($dir . DIRECTORY_SEPARATOR . $item)) - return false; + return FALSE; } return rmdir($dir); } \ No newline at end of file diff --git a/CollectionClass.inc b/CollectionClass.inc index 4216733d..ae68e2de 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -524,11 +524,11 @@ class CollectionClass { $show_batch_tab = FALSE; } if (!$show_ingest_tab) { - $view_selected = true; + $view_selected = TRUE; } if(!$collection_items){ - $view_selected = false; - $add_selected = true; + $view_selected = FALSE; + $add_selected = TRUE; } $view_selected = !$show_ingest_tab; @@ -554,7 +554,7 @@ class CollectionClass { '#title' => t('Manage This Collection'), // This will be the content of the tab. '#content' => drupal_get_form('collection_management_form', $this->pid, $content_models), - '#selected' => false, + '#selected' => FALSE, ); } if ($show_batch_tab && user_access('create batch process')) { diff --git a/CollectionManagement.inc b/CollectionManagement.inc index 83bb9952..39d33456 100644 --- a/CollectionManagement.inc +++ b/CollectionManagement.inc @@ -10,8 +10,8 @@ function collection_management_form(&$form_state, $this_collection_pid, $content_models) { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); $restricted = FALSE; - if (variable_get('fedora_namespace_restriction_enforced', true)) { - $restricted = true; + if (variable_get('fedora_namespace_restriction_enforced', TRUE)) { + $restricted = TRUE; $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); foreach ($namespaces as $namespace) { @@ -35,7 +35,7 @@ function collection_management_form(&$form_state, $this_collection_pid, $content } } if (!empty($cm_options)) { - $show_delete = true; + $show_delete = TRUE; } diff --git a/CollectionPolicy.inc b/CollectionPolicy.inc index b801eaff..be9e7a92 100644 --- a/CollectionPolicy.inc +++ b/CollectionPolicy.inc @@ -64,7 +64,7 @@ class CollectionPolicy extends XMLDatastream { /** * Ingests a new Collection Policy datastream to the specified * PID with the DSID specified. The file should be a valid collection - * policy XML. Returns false on failure. + * policy XML. Returns FALSE on failure. * * @param string $pid * @param string $name @@ -92,7 +92,7 @@ class CollectionPolicy extends XMLDatastream { /** * Ingests a new Collection Policy datastream to the specified * PID with the DSID specified. Clones the collection policy from the - * source collection pid. Returns false on failure. + * source collection pid. Returns FALSE on failure. * * @param string $pid * @param string $name @@ -122,7 +122,7 @@ class CollectionPolicy extends XMLDatastream { /** * Ingests a new minimum Collection Policy datastream to the specified * PID with the DSID specified. Initializes the policy with the specified values. - * Returns false on failure + * Returns FALSE on failure * * @param string $pid * @param string $name @@ -234,7 +234,7 @@ class CollectionPolicy extends XMLDatastream { $termEl = $newDom->createElement('term', $term->value); $termEl->setAttribute('field', $term->field); if (strval($sXml->search_terms->default) == $term->field) { - $termEl->setAttribute('default', 'true'); + $termEl->setAttribute('default', 'TRUE'); } $search_termsEl->appendChild($termEl); } @@ -321,7 +321,7 @@ class CollectionPolicy extends XMLDatastream { /** * Sets the path to the staging area to use for this - * collection. If specified path is blank (or false) it will + * collection. If specified path is blank (or FALSE) it will * remove the staging are path element from the collection policy. * * @param string $path @@ -435,7 +435,7 @@ class CollectionPolicy extends XMLDatastream { $terms = $this->xml->getElementsByTagName('search_terms')->item(0)->getElementsByTagName('term'); for ($i = 0; $i < $terms->length; $i++) { $default = $terms->item($i)->attributes->getNamedItem('default'); - $default = ($default !== NULL) ? (strtolower($default->nodeValue) == 'true') : FALSE; + $default = ($default !== NULL) ? (strtolower($default->nodeValue) == 'TRUE') : FALSE; $ret[] = ($asArray) ? array('value' => $terms->item($i)->nodeValue, 'field' => $terms->item($i)->getAttribute('field'), 'default' => $default) : $terms->item($i)->nodeValue; @@ -540,7 +540,7 @@ class CollectionPolicy extends XMLDatastream { if ($terms->item($i)->attributes->getNamedItem('default') !== NULL) { $terms->item($i)->removeAttribute('default'); } - $found->setAttribute('default', 'true'); + $found->setAttribute('default', 'TRUE'); $ret = TRUE; } } @@ -550,7 +550,7 @@ class CollectionPolicy extends XMLDatastream { /** * Removes the specified content model from the collection policy. This will only * prevent future ingests of the removed model to the collection. $cm should be - * a valid ContentModel object. Returns false on failure or when the CM was not found in + * a valid ContentModel object. Returns FALSE on failure or when the CM was not found in * the collection policy. * * @param ContentModel $cm diff --git a/ContentModel.inc b/ContentModel.inc index b1f28074..cbacd422 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -34,7 +34,7 @@ class ContentModel extends XMLDatastream { /** * Constructs a ContentModel object from a Fedora item * by getting the first content model from the hasModel relationship. - * Returns false on failure. + * Returns FALSE on failure. * @param string $pid * @return ContentModel $cm */ @@ -57,7 +57,7 @@ class ContentModel extends XMLDatastream { /** * Ingests a Content Model from a file to the specified pid/dsid . - * Returns false on failure. + * Returns FALSE on failure. * * @param string $pid * @param string $name @@ -84,7 +84,7 @@ class ContentModel extends XMLDatastream { /** * Ingests a Content Model from an existing model to the specified pid/dsid . - * Returns false on failure. + * Returns FALSE on failure. * * @param string $pid * @param string $name @@ -113,7 +113,7 @@ class ContentModel extends XMLDatastream { /** * Ingests a minimum Content Model to the specified pid/dsid. - * Returns false on failure. + * Returns FALSE on failure. * * @param string $pid * @param string $name @@ -153,8 +153,8 @@ class ContentModel extends XMLDatastream { $ingestFormEl = $newDom->createElement('ingest_form'); $ingestFormEl->setAttribute('dsid', $ingestFormDsid); $ingestFormEl->setAttribute('page', $ingestFormPage); - if ($ingestFormHideChooser == 'true') { - $ingestFormEl->setAttribute('hide_file_chooser', 'true'); + if ($ingestFormHideChooser == 'TRUE') { + $ingestFormEl->setAttribute('hide_file_chooser', 'TRUE'); } $builderEl = $newDom->createElement('form_builder_method'); @@ -186,7 +186,7 @@ class ContentModel extends XMLDatastream { * If DSID is specified it will use that datastream as the model, otherwise it will * use the default (usually ISLANDORACM). PID_NAMESPACE and name can also be initialized * from the collection policy. - * Returns false on failure. + * Returns FALSE on failure. * * NOTE: $name will be overwritten with the content model name found in the datastream * when the model is first validated.\ @@ -344,7 +344,7 @@ class ContentModel extends XMLDatastream { $ingest_formEl->setAttribute('dsid', $sXml->ingest_form['dsid']); $ingest_formEl->setAttribute('page', $sXml->ingest_form['page']); if (isset($sXml->ingest_form['hide_file_chooser'])) { - $ingest_formEl->setAttribute('hide_file_chooser', (strtolower($sXml->ingest_form['hide_file_chooser']) == 'true') ? 'true' : 'false'); + $ingest_formEl->setAttribute('hide_file_chooser', (strtolower($sXml->ingest_form['hide_file_chooser']) == 'TRUE') ? 'TRUE' : 'FALSE'); } $form_builderEl = $newDom->createElement('form_builder_method'); @@ -373,8 +373,8 @@ class ContentModel extends XMLDatastream { $elEl->setAttribute('label', $element->label); $elEl->setAttribute('name', $element->name); $elEl->setAttribute('type', $element->type); - if (strtolower($element->required) == 'true') { - $elEl->setAttribute('required', 'true'); + if (strtolower($element->required) == 'TRUE') { + $elEl->setAttribute('required', 'TRUE'); } if (isset($element->description) && trim($element->description) != '') { $descEl = $newDom->createElement('description', trim($element->description)); @@ -453,7 +453,7 @@ class ContentModel extends XMLDatastream { /** * Gets the name of the ContentModel - * Returns false on failure. + * Returns FALSE on failure. * * @return String $name */ @@ -539,7 +539,7 @@ class ContentModel extends XMLDatastream { $element = array('name' => $elements->item($i)->getAttribute('name'), 'label' => $label, 'type' => $elements->item($i)->getAttribute('type'), - 'required' => ($elements->item($i)->getAttribute('required') == 'true') ? TRUE : FALSE, + 'required' => ($elements->item($i)->getAttribute('required') == 'TRUE') ? TRUE : FALSE, 'description' => $desc ); @@ -561,7 +561,7 @@ class ContentModel extends XMLDatastream { $items = $params->item(0)->getElementsByTagName('parameter'); for ($j = 0; $j < $items->length; $j++) { $value = $items->item($j)->nodeValue; - $list[$items->item($j)->getAttribute('name')] = (strtolower($value) == 'true' ? TRUE : (strtolower($value) == 'false' ? FALSE : $value)); + $list[$items->item($j)->getAttribute('name')] = (strtolower($value) == 'TRUE' ? TRUE : (strtolower($value) == 'FALSE' ? FALSE : $value)); } } $element['parameters'] = $list; @@ -657,7 +657,7 @@ class ContentModel extends XMLDatastream { /** * Sets a parameter of an ingest form element. If the value of the element is FALSE the parameter - * will be removed entirely (if you want to store false as a value, then send the String "false"). + * will be removed entirely (if you want to store FALSE as a value, then send the String "FALSE"). * * @param String $elementName * @param String $paramName @@ -786,7 +786,7 @@ class ContentModel extends XMLDatastream { $found->setAttribute('name', $name); $found->setAttribute('type', $type); - $found->setAttribute('required', $required ? 'true' : 'false'); + $found->setAttribute('required', $required ? 'TRUE' : 'FALSE'); if (trim($label) != '' && trim($label) != trim($name)) { $found->setAttribute('label', $label); } @@ -838,7 +838,7 @@ class ContentModel extends XMLDatastream { $elementEl = $this->xml->createElement('element'); $elementEl->setAttribute('name', $name); $elementEl->setAttribute('type', $type); - $elementEl->setAttribute('required', $requiredi ? 'true' : 'false'); + $elementEl->setAttribute('required', $requiredi ? 'TRUE' : 'FALSE'); if (trim($label) != '' && trim($label) != trim($name)) { $elementEl->setAttribute('label', $label); } @@ -1062,7 +1062,7 @@ class ContentModel extends XMLDatastream { $ingest_form = $this->xml->getElementsByTagName('ingest_form')->item(0); if (!empty($ingest_form)) { - if (strtolower($ingest_form->getAttribute('hide_file_chooser')) == 'true') { + if (strtolower($ingest_form->getAttribute('hide_file_chooser')) == 'TRUE') { $form['indicator']['ingest-file-location']['#type'] = 'hidden'; } } @@ -1464,7 +1464,7 @@ class ContentModel extends XMLDatastream { $datastreams = $datastreams->item(0)->getElementsByTagName('datastream'); for ($i = 0; $i < $datastreams->length; $i++) { $ds = $datastreams->item($i); - if ($ds->attributes->getNamedItem('display_in_fieldset') == NULL || strtolower($ds->getAttribute('display_in_fieldset')) != 'false') { + if ($ds->attributes->getNamedItem('display_in_fieldset') == NULL || strtolower($ds->getAttribute('display_in_fieldset')) != 'FALSE') { $dispMethods = $ds->getElementsByTagName('display_method'); for ($j = 0; $j < $dispMethods->length; $j++) { $method = $dispMethods->item($j); @@ -1592,7 +1592,7 @@ class ContentModel extends XMLDatastream { 'file' => $dispMethods->item($i)->getAttribute('file'), 'class' => $dispMethods->item($i)->getAttribute('class'), 'method' => $dispMethods->item($i)->getAttribute('method'), - 'default' => ($dispMethods->item($i)->attributes->getNamedItem('default') !== NULL ? strtolower($dispMethods->item($i)->getAttribute('default')) == 'true' : FALSE)); + 'default' => ($dispMethods->item($i)->attributes->getNamedItem('default') !== NULL ? strtolower($dispMethods->item($i)->getAttribute('default')) == 'TRUE' : FALSE)); } } return $ret; @@ -1620,7 +1620,7 @@ class ContentModel extends XMLDatastream { $dsEl = $this->xml->createElement('datastream'); $dsEl->setAttribute('dsid', $dsid); if ($display_in_fieldset == TRUE) { - $dsEl->setAttribute('display_in_fieldset', 'true'); + $dsEl->setAttribute('display_in_fieldset', 'TRUE'); } $datastreamsEl->appendChild($dsEl); $ret = TRUE; @@ -1652,7 +1652,7 @@ class ContentModel extends XMLDatastream { public function displayInFieldset($dsid) { $ret = FALSE; if (self::valid_dsid($dsid) && ($ds = $this->getDSModel($dsid)) !== FALSE) { - $ret = strtolower($ds->getAttribute('display_in_fieldset')) == 'true'; + $ret = strtolower($ds->getAttribute('display_in_fieldset')) == 'TRUE'; } return $ret; } @@ -1671,7 +1671,7 @@ class ContentModel extends XMLDatastream { $ret = TRUE; } elseif ($value == TRUE) { - $ds->setAttribute('display_in_fieldset', 'true'); + $ds->setAttribute('display_in_fieldset', 'TRUE'); $ret = TRUE; } } @@ -1710,7 +1710,7 @@ class ContentModel extends XMLDatastream { } } - $found->setAttribute('default', 'true'); + $found->setAttribute('default', 'TRUE'); $ret = TRUE; } } @@ -2112,8 +2112,8 @@ class ContentModel extends XMLDatastream { $ingest_formEl = $this->xml->getElementsByTagName('ingest_form')->item(0); $ret = array('dsid' => $ingest_formEl->getAttribute('dsid'), 'page' => $ingest_formEl->getAttribute('page'), - 'hide_file_chooser' => strtolower($ingest_formEl->getAttribute('hide_file_chooser')) == 'true', - 'redirect' => strtolower($ingest_formEl->getAttribute('redirect')) == 'false' ? FALSE : TRUE); + 'hide_file_chooser' => strtolower($ingest_formEl->getAttribute('hide_file_chooser')) == 'TRUE', + 'redirect' => strtolower($ingest_formEl->getAttribute('redirect')) == 'FALSE' ? FALSE : TRUE); } return $ret; } @@ -2133,13 +2133,13 @@ class ContentModel extends XMLDatastream { $ingest_formEl->setAttribute('dsid', $dsid); $ingest_formEl->setAttribute('page', $page); if (!$redirect) { - $ingest_formEl->setAttribute('redirect', 'false'); + $ingest_formEl->setAttribute('redirect', 'FALSE'); } else { $ingest_formEl->removeAttribute('redirect'); } if ($hide_file_chooser) { - $ingest_formEl->setAttribute('hide_file_chooser', 'true'); + $ingest_formEl->setAttribute('hide_file_chooser', 'TRUE'); } else { $ingest_formEl->removeAttribute('hide_file_chooser'); diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 9e9995b7..4097a2d1 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -835,7 +835,7 @@ class ObjectHelper { and $o <mulgara:is> <info:fedora/' . $pid . '>'; $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); - $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; + $url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query_string))); $rows = explode("\n", $content); @@ -869,7 +869,7 @@ class ObjectHelper { $query_string = substr($query_string, 0, -3) . ' )'; $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); - $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; + $url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; $url .= htmlentities(urlencode($query_string)); $content = $this->doCurl($url); diff --git a/XMLDatastream.inc b/XMLDatastream.inc index d3afed09..ab8044f4 100644 --- a/XMLDatastream.inc +++ b/XMLDatastream.inc @@ -102,7 +102,7 @@ abstract class XMLDatastream { * @return XMLDatastream $cm */ public function __construct($xmlStr, $pid = NULL, $dsid = NULL) { - libxml_use_internal_errors(true); + libxml_use_internal_errors(TRUE); $this->pid = $pid; $this->dsid = $dsid; @@ -253,7 +253,7 @@ abstract class XMLDatastream { /** * Gets the history of the datastream from fedora. - * Returns false on failure. + * Returns FALSE on failure. * * @return string[] $ret */ diff --git a/api/fedora_export.inc b/api/fedora_export.inc index e1ed3cbd..30675783 100644 --- a/api/fedora_export.inc +++ b/api/fedora_export.inc @@ -170,7 +170,7 @@ function export_foxml_for_pid($pid, $dir, $paths, &$log, $format = FOXML_11, $re } foreach ($xpath->('METS:FLocat[@xlink:href]', $content_node) as $floc) { - $floc->setAttribute('xlink:href', url($paths[$ds_id], array('absolute' => true))); + $floc->setAttribute('xlink:href', url($paths[$ds_id], array('absolute' => TRUE))); } `} */ diff --git a/api/fedora_item.inc b/api/fedora_item.inc index 4dacca8c..a4ee923b 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -297,14 +297,14 @@ class Fedora_Item { $i++; $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora'); if ($cursor == 0) { - $url .= "/objects?query=$field~$pattern&pid=true&title=true&resultFormat=xml&maxResults=$max_results"; + $url .= "/objects?query=$field~$pattern&pid=TRUE&title=TRUE&resultFormat=xml&maxResults=$max_results"; } else { - $url .= "/objects?pid=true&title=truesessionToken=$session_token&resultFormat=xml&maxResults=$max_results"; + $url .= "/objects?pid=TRUE&title=TRUEsessionToken=$session_token&resultFormat=xml&maxResults=$max_results"; } if (count($resultFields) > 0) { - $url .= '&' . join('=true&', $resultFields) . '=true'; + $url .= '&' . join('=TRUE&', $resultFields) . '=TRUE'; } $resultxml = do_curl($url); diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index c8ce7d0e..36ae5918 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -245,7 +245,7 @@ function get_collections_as_option_array() { and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) order by $title'; $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); - $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; + $url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query))); $list = explode("\n", $content); array_shift($list); @@ -271,7 +271,7 @@ function get_collections_as_option_array() { function get_content_models_as_option_array() { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - $restricted = variable_get('fedora_namespace_restriction_enforced', true); + $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); $namespaces = explode(':', $allowed_string); foreach ($namespaces as $namespace) { @@ -287,7 +287,7 @@ function get_content_models_as_option_array() { order by $title'; $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); - $url .= "?type=tuples&flush=true&format=csv&limit=1000&lang=itql&stream=on&query="; + $url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; $content = do_curl($url . htmlentities(urlencode($query))); $list = explode("\n", $content); array_shift($list); diff --git a/fedora_repository.module b/fedora_repository.module index ea1c15c5..e2153355 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -990,7 +990,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU // Add a 'manage object' tab for all objects, where detailed list of content is shown. $obj = new FedoraObjectDetailedContent($pid); $object_details = $obj->showFieldSets(); - if ($object_details['fedora_object_details']['#selected'] == true){ + if ($object_details['fedora_object_details']['#selected'] == TRUE){ foreach($cmodels_tabs as $cmodel_tab){ if (is_array($cmodel_tab)){ $cmodel_tab['#selected'] = FALSE; diff --git a/formClass.inc b/formClass.inc index af0dc218..cfc240b6 100644 --- a/formClass.inc +++ b/formClass.inc @@ -306,8 +306,8 @@ class formClass { '#type' => 'fieldset', '#title' => t('Advanced configuration options'), '#description' => t('Advanced configuration. Under normal circumstances these will not be touched'), - '#collapsible' => true, - '#collapsed' => true, + '#collapsible' => TRUE, + '#collapsed' => TRUE, ); $form['advanced']['fedora_object_display_title'] = array( '#type' => 'select', @@ -587,7 +587,7 @@ class formClass { $form = new IngestObjectMetadataForm(); return $form->create($collection_pid, $collection_label, $form_state); } catch (Exception $e) { - $form_state['storage']['xml'] = false; // An error occured revert back to the QDC Form. + $form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form. } } return $this->createQDCIngestForm($collection_pid, $collection_label, $form_state); @@ -810,7 +810,7 @@ class formClass { $form = new EditObjectMetadataForm($form_state); return $form->create($pid, $client, $form_state); } catch (Exception $e) { - $form_state['storage']['xml'] = false; // An error occured revert back to the QDC Form. + $form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form. } } return $this->createQDCEditForm($pid, $dsid, $client, $form_state); diff --git a/plugins/ImageManipulation.inc b/plugins/ImageManipulation.inc index 8f97ab94..0351adbe 100644 --- a/plugins/ImageManipulation.inc +++ b/plugins/ImageManipulation.inc @@ -211,7 +211,7 @@ class ImageManipulation { } elseif (stristr($_SERVER['SERVER_SOFTWARE'], 'unix')) { // Use this for Mac OS X (MAMP) - $cmdline = "sips -s format jpeg \"$file\" -z $height $height --out \"$file$file_suffix\" >/dev/null"; + $cmdline = "sips -s format jpeg \"$file\" -z $height $height --out \"$file$file_suffix\" >/dev/NULL"; } else { $cmdline = "convert \"$file\"\[0\] -colorspace RGB -thumbnail " . $width . "x" . $height . " \"$file$file_suffix\""; diff --git a/plugins/qt_viewer.inc b/plugins/qt_viewer.inc index ec321ca1..e4717f14 100644 --- a/plugins/qt_viewer.inc +++ b/plugins/qt_viewer.inc @@ -99,7 +99,7 @@ class ShowQtStreamsInFieldSets { } /** - * Is download enabled. It always returns false. ??? + * Is download enabled. It always returns FALSE. ??? * @return FALSE */ function enableDownload() { @@ -147,7 +147,7 @@ class ShowQtStreamsInFieldSets { } $src = base_path() . 'fedora/repository/' . $this->pid . '/' . $media->ID . '/MOV.mov'; $qtparams = ''; - $qtparams .= "'autostart', '" . ($pframe !== FALSE ? 'true' : 'false') . "', "; + $qtparams .= "'autostart', '" . ($pframe !== FALSE ? 'TRUE' : 'FALSE') . "', "; $init = <<<EOD $(function() { src = "$src"; From c498a3f2b4a34baa2201314ed2084078e59d70a7 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Wed, 12 Oct 2011 15:51:46 -0300 Subject: [PATCH 14/46] fixed /dev/null --- api/fedora_collection.inc | 2 +- plugins/ImageManipulation.inc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/fedora_collection.inc b/api/fedora_collection.inc index b8afc5c4..a82bf39b 100644 --- a/api/fedora_collection.inc +++ b/api/fedora_collection.inc @@ -41,7 +41,7 @@ function export_collection($collection_pid, $relationship = 'isMemberOfCollectio fwrite($file, $item_foxml); fclose($file); } - if (system("cd $container;zip -r $collection_pid.zip $collection_pid/* >/dev/NULL") == 0) { + if (system("cd $container;zip -r $collection_pid.zip $collection_pid/* >/dev/null") == 0) { header("Content-type: application/zip"); header('Content-Disposition: attachment; filename="' . $collection_pid . '.zip' . '"'); $fh = fopen($container . '/' . $collection_pid . '.zip', 'r'); diff --git a/plugins/ImageManipulation.inc b/plugins/ImageManipulation.inc index 0351adbe..8f97ab94 100644 --- a/plugins/ImageManipulation.inc +++ b/plugins/ImageManipulation.inc @@ -211,7 +211,7 @@ class ImageManipulation { } elseif (stristr($_SERVER['SERVER_SOFTWARE'], 'unix')) { // Use this for Mac OS X (MAMP) - $cmdline = "sips -s format jpeg \"$file\" -z $height $height --out \"$file$file_suffix\" >/dev/NULL"; + $cmdline = "sips -s format jpeg \"$file\" -z $height $height --out \"$file$file_suffix\" >/dev/null"; } else { $cmdline = "convert \"$file\"\[0\] -colorspace RGB -thumbnail " . $width . "x" . $height . " \"$file$file_suffix\""; From d8728516b978875d6d8e87f6a062679d7d515833 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:11:35 -0300 Subject: [PATCH 15/46] checking to see if I need an array to sanitize text --- fedora_repository.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedora_repository.module b/fedora_repository.module index e2153355..90354d44 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -115,7 +115,7 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label $collection_pid = urldecode($collection_pid); } else { - drupal_set_message(t("This collection PID $collection_pid is not valid"), 'error'); + drupal_set_message(t("This collection PID @collection_pid is not valid", check_plain($collection_pid )), 'error'); return ' '; } } From bba29d761a032823098c61f8fc9e3a715e9d0483 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:16:41 -0300 Subject: [PATCH 16/46] Does this actually work --- fedora_repository.module | 56 ++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/fedora_repository.module b/fedora_repository.module index 90354d44..67dc0494 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -54,10 +54,9 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) { drupal_set_message(t('You must specify an object pid to purge an object.'), 'error'); return ''; } - $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', - array( - '%name' => $name, - '%pid' => $pid) + $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', array( + '%name' => $name, + '%pid' => $pid) ); $output .= drupal_get_form('fedora_repository_purge_object_form', $pid); @@ -115,7 +114,7 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label $collection_pid = urldecode($collection_pid); } else { - drupal_set_message(t("This collection PID @collection_pid is not valid", check_plain($collection_pid )), 'error'); + drupal_set_message(t("This collection PID @collection_pid is not valid", check_plain($collection_pid)), 'error'); return ' '; } } @@ -150,7 +149,7 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { $xml_form->submit($form, $form_state); } } - else if ($form_state['clicked_button']['#id'] == 'edit-submit') { + elseif ($form_state['clicked_button']['#id'] == 'edit-submit') { global $base_url; module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); @@ -240,14 +239,14 @@ function fedora_repository_ingest_form_validate($form, &$form_state) { if (!empty($file)) { if (!in_array($dformat, $allowedMimeTypes)) { form_set_error('ingest-file-location', t('The uploaded file\'s mimetype (' . $dformat . ') is not associated with this Content Model. The allowed types are ' . - implode(' ', $allowedMimeTypes))); + implode(' ', $allowedMimeTypes))); file_delete($file); return; } elseif (!$cm->execIngestRules($file, $dformat)) { drupal_set_message(t('Error following Content Model Rules'), 'error'); foreach (ContentModel::$errors as $err) { - drupal_set_message($err, 'error'); + drupal_set_message(check_plain($err), 'error'); } } } @@ -400,7 +399,7 @@ function add_stream_form_submit($form, &$form_state) { file_delete($file); } catch (exception $e) { - drupal_set_message(t($e->getMessage()), 'error'); + drupal_set_message(t(check_plain($e->getMessage())), 'error'); return; } $form_state['rebuild'] = TRUE; @@ -448,9 +447,9 @@ function add_stream_form_validate($form, &$form_state) { return FALSE; } $validators = array( - // 'file_validate_is_image' => array(), - // 'file_validate_image_resolution' => array('85x85'), - // 'file_validate_size' => array(30 * 1024), + // 'file_validate_is_image' => array(), + // 'file_validate_image_resolution' => array('85x85'), + // 'file_validate_size' => array(30 * 1024), ); $fileObject = file_save_upload('add-stream-file-location', $validators); @@ -482,9 +481,8 @@ function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) return ' '; } - $output = t('Are you sure you wish to purge this datastream %name<br />', - array( - '%name' => $name) + $output = t('Are you sure you wish to purge this datastream %name<br />', array( + '%name' => $name) ); $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); return $output; @@ -909,12 +907,12 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU drupal_set_message(t('The Fedora repository server is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); return ''; } - + if (!risearch_available()) { drupal_set_message(t('The Fedora resource index search is currently unavailable. Please contact the site administrator.'), 'warning', FALSE); return ''; } - + if ($pid == NULL) { $pid = variable_get('fedora_repository_pid', 'islandora:root'); } @@ -990,12 +988,11 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU // Add a 'manage object' tab for all objects, where detailed list of content is shown. $obj = new FedoraObjectDetailedContent($pid); $object_details = $obj->showFieldSets(); - if ($object_details['fedora_object_details']['#selected'] == TRUE){ - foreach($cmodels_tabs as $cmodel_tab){ - if (is_array($cmodel_tab)){ + if ($object_details['fedora_object_details']['#selected'] == TRUE) { + foreach ($cmodels_tabs as $cmodel_tab) { + if (is_array($cmodel_tab)) { $cmodel_tab['#selected'] = FALSE; } - } } $cmodels_tabs = array_merge($cmodels_tabs, $object_details); @@ -1468,10 +1465,10 @@ function fedora_repository_demo_objects_form() { ); foreach (array( - 'islandora:collectionCModel' => 'Islandora default content models', - 'islandora:root' => 'Islandora top-level collection', - 'islandora:demos' => 'Islandora demos collection', - 'islandora:largeimages' => 'Sample large image content model (requires <a href="http://sourceforge.net/projects/djatoka/">Djatoka</a> and <a href="http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=26&Itemid=22">Kakadu</a>.)', +'islandora:collectionCModel' => 'Islandora default content models', + 'islandora:root' => 'Islandora top-level collection', + 'islandora:demos' => 'Islandora demos collection', + 'islandora:largeimages' => 'Sample large image content model (requires <a href="http://sourceforge.net/projects/djatoka/">Djatoka</a> and <a href="http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=26&Itemid=22">Kakadu</a>.)', ) as $available_demo => $available_demo_desc) { try { @@ -1643,7 +1640,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) { if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) { $error = ''; foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml', - 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) { + 'islandora_slideCModel.xml', 'islandora_viewerSdep-slideCModel.xml', 'ilives_jp2Sdef.xml', 'ilives_viewerSdef.xml') as $foxml_file) { try { $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/' . $foxml_file); } catch (exception $e) { @@ -1685,7 +1682,6 @@ function fedora_repository_required_fedora_objects() { 'dsversion' => 2, 'cmodel' => 'fedora-system:ContentModel-3.0', ), - array( 'pid' => 'islandora:root', 'label' => 'Islandora Top-level Collection', @@ -1701,7 +1697,7 @@ function fedora_repository_required_fedora_objects() { 'mimetype' => 'image/png', ), ), - ), + ), ), ), ); @@ -2085,9 +2081,7 @@ function theme_add_to_basket_link($pid, $type = 'object') { */ if (!_is_added_to_basket($pid)) { return l( - theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), - "fedora/repository/addToBasket/" . $path, - array('html' => TRUE) + theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), "fedora/repository/addToBasket/" . $path, array('html' => TRUE) ); } From e542a6d4b52b9ca9d67e708334255064ce0ed768 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:19:28 -0300 Subject: [PATCH 17/46] Sanitizing text --- fedora_repository.module | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fedora_repository.module b/fedora_repository.module index 67dc0494..1d761d8f 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -399,7 +399,7 @@ function add_stream_form_submit($form, &$form_state) { file_delete($file); } catch (exception $e) { - drupal_set_message(t(check_plain($e->getMessage())), 'error'); + drupal_set_message(t('@message', check_plain($e->getMessage())), 'error'); return; } $form_state['rebuild'] = TRUE; @@ -518,7 +518,7 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) { drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error'); } else { - drupal_set_message(t($e->getMessage()), 'error'); + drupal_set_message(t('@message', check_plain($e->getMessage())), 'error'); } return; } @@ -576,7 +576,7 @@ function fedora_repository_purge_stream_form_submit($form, &$form_state) { try { $item->purge_datastream($dsid); } catch (exception $e) { - drupal_set_message(t($e->getMessage()), 'error'); + drupal_set_message(t('@message', check_plain($e->getMessage())), 'error'); } $form_state['redirect'] = $base_url . "/fedora/repository/$pid"; } @@ -934,7 +934,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU } if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed @here", array('@here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); } drupal_access_denied(); exit; From bc69572d6413d58c02d9b5d354a96b9bcb5062cf Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:29:21 -0300 Subject: [PATCH 18/46] Sanitized more text --- fedora_repository.module | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fedora_repository.module b/fedora_repository.module index 1d761d8f..2a7e5498 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -399,7 +399,7 @@ function add_stream_form_submit($form, &$form_state) { file_delete($file); } catch (exception $e) { - drupal_set_message(t('@message', check_plain($e->getMessage())), 'error'); + drupal_set_message(t('@message', array('@message' => check_plain($e->getMessage()))), 'error'); return; } $form_state['rebuild'] = TRUE; @@ -435,7 +435,7 @@ function add_stream_form_validate($form, &$form_state) { return FALSE; } if (!(preg_match("/^[a-zA-Z]/", $dsid))) { - form_set_error('', t("Data stream ID ($dsid) has to start with a letter.")); + form_set_error('', t("Data stream ID (@dsid) has to start with a letter.", array( '@dsid' => check_plain($dsid)))); return FALSE; } if (strlen($dsLabel) > 64) { @@ -518,7 +518,7 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) { drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error'); } else { - drupal_set_message(t('@message', check_plain($e->getMessage())), 'error'); + drupal_set_message(t('@message', array('@message' => check_plain($e->getMessage()))), 'error'); } return; } @@ -576,7 +576,7 @@ function fedora_repository_purge_stream_form_submit($form, &$form_state) { try { $item->purge_datastream($dsid); } catch (exception $e) { - drupal_set_message(t('@message', check_plain($e->getMessage())), 'error'); + drupal_set_message(t('@message', array('@message' => check_plain($e->getMessage()))), 'error'); } $form_state['redirect'] = $base_url . "/fedora/repository/$pid"; } @@ -1065,7 +1065,7 @@ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NU //drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error'); drupal_access_denied(); if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'error'); + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed @here", array('@here' => l('here', 'admin/settings/fedora_repository'))), 'error'); } return ' '; } @@ -1577,7 +1577,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) { $cmodel_collection->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_views/simple_list_view.xml', 'COLLECTION_VIEW', 'Collection View', 'text/xml', 'X'); $cmodel_collection->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/contentModel.jpg', 'TN', 'Thumbnail', 'image/jpg', 'M'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:ContentModelCollection\">islandora:ContentModelCollection</a>."), 'message'); + drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/islandora:ContentModelCollection\">islandora:ContentModelCollection</a>.", array('@base_url' => check_plain($base_url))), 'message'); } catch (exception $e) { } @@ -1589,7 +1589,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) { $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/COLLECTION-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); try { $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:root\">islandora:root</a>."), 'message'); + drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/islandora:root\">islandora:root</a>.", array('@base_url' => check_plain($base_url))), 'message'); } catch (exception $e) { } @@ -1609,7 +1609,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) { $new_item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); $cp = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PDF-COLLECTION POLICY.xml', 'COLLECTION_POLICY', 'Collection Policy', 'text/xml', 'X'); $tn = $new_item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_mimetype_pdf.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:demos\">islandora:demos</a>."), 'message'); + drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/islandora:demos\">islandora:demos</a>.", array('@base_url' => check_plain($base_url))), 'message'); } catch (exception $e) { } @@ -1631,7 +1631,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) { $dual_res_image_collection_cmodel = new Fedora_Item('demo:DualResImageCollection'); try { $cmstream = $dual_res_image_collection_cmodel->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/content_models/COLLECTIONCM.xml', 'ISLANDORACM', 'Islandora Content Model.xml', 'application/xml', 'X'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view."), 'message'); + drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/demo:SmileyStuff\">demo:SmileyStuff</a> collection view.", array('@base_url' => check_plain($base_url))), 'message'); } catch (exception $e) { } @@ -1650,7 +1650,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) { try { $item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_repository') . '/content_models/islandora_largeimages.xml'); $tn = $item->add_datastream_from_file(drupal_get_path('module', 'fedora_repository') . '/images/Gnome-emblem-photos.png', 'TN', 'Thumbnail.png', 'image/png', 'M'); - drupal_set_message(t("Successfully installed <a href=\"" . $base_url . "/fedora/repository/islandora:largeimages\">islandora:largeimages</a>."), 'message'); + drupal_set_message(t("Successfully installed <a href=\"@base_url/fedora/repository/islandora:largeimages\">islandora:largeimages</a>.", array('@base_url' => check_plain($base_url))), 'message'); } catch (exception $e) { $error .= " - Problem ingesting islandora:largeimages collection"; } @@ -1952,7 +1952,7 @@ function fedora_repository_basket_form_submit($form, &$form_state) { $foxml_dir = $export_dir . '/foxml'; if (!file_exists($foxml_dir) && !@mkdir($foxml_dir, 0775, TRUE)) { - drupal_set_message(t("Failed to create foxml dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $foxml_dir)), 'error'); + drupal_set_message(t("Failed to create foxml dir @dir. Check that export dir exsits and has correct permissions", array('@dir' => $foxml_dir)), 'error'); return FALSE; } @@ -1961,7 +1961,7 @@ function fedora_repository_basket_form_submit($form, &$form_state) { $objects_dir = $export_dir . '/objects/' . $pid; if (!file_exists($objects_dir) && !@mkdir($objects_dir, 0775, TRUE)) { - drupal_set_message(t("Failed to create objects dir %dir. Check that export dir exsits and has correct permissions", array('%dir' => $objects_dir)), 'error'); + drupal_set_message(t("Failed to create objects dir @dir. Check that export dir exsits and has correct permissions", array('@dir' => $objects_dir)), 'error'); return FALSE; } From cc4f8903635ea880b98f121b53fb3c92046497cd Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:30:27 -0300 Subject: [PATCH 19/46] Fixed last string error in fedora_repository.module --- fedora_repository.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedora_repository.module b/fedora_repository.module index 2a7e5498..56859edb 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -1657,7 +1657,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) { } if (!empty($error)) { - drupal_set_message(t('Some problems occurred: ' . $error)); + drupal_set_message(t('Some problems occurred: @error', array('@error' => $error))); } } } From d705d897cb2012a0aec39070ec179d91eccd1abc Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:32:04 -0300 Subject: [PATCH 20/46] Removed CVS id tags --- ConnectionHelper.inc | 2 +- MimeClass.inc | 2 +- ObjectHelper.inc | 2 +- SearchClass.inc | 2 +- SecurityClass.inc | 2 +- api/dublin_core.inc | 2 +- api/fedora_export.inc | 2 +- api/fedora_utils.inc | 2 +- api/rels-ext.inc | 2 +- api/tagging.inc | 2 +- formClass.inc | 2 +- plugins/CollectionFormBuilder.inc | 2 +- plugins/CreateCollection.inc | 2 +- plugins/DemoFormBuilder.inc | 2 +- plugins/Exiftool.inc | 2 +- plugins/FedoraObjectDetailedContent.inc | 2 +- plugins/Ffmpeg.inc | 2 +- plugins/Flv.inc | 2 +- plugins/FlvFormBuilder.inc | 2 +- plugins/FormBuilder.inc | 2 +- plugins/ImageManipulation.inc | 2 +- plugins/ModsFormBuilder.inc | 2 +- plugins/PersonalCollectionClass.inc | 2 +- plugins/Refworks.inc | 2 +- plugins/ShowDemoStreamsInFieldSets.inc | 2 +- plugins/ShowStreamsInFieldSets.inc | 2 +- plugins/map_viewer.inc | 2 +- plugins/qt_viewer.inc | 2 +- plugins/slide_viewer.inc | 2 +- plugins/tagging_form.inc | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/ConnectionHelper.inc b/ConnectionHelper.inc index 8225f0fc..255ebfac 100644 --- a/ConnectionHelper.inc +++ b/ConnectionHelper.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/MimeClass.inc b/MimeClass.inc index 119a8f97..42c11e37 100644 --- a/MimeClass.inc +++ b/MimeClass.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 4097a2d1..98160292 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file * Object Helper Class diff --git a/SearchClass.inc b/SearchClass.inc index 3f1c78d5..751dbbfa 100644 --- a/SearchClass.inc +++ b/SearchClass.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/SecurityClass.inc b/SecurityClass.inc index 0cdb2cbe..1e2b1835 100644 --- a/SecurityClass.inc +++ b/SecurityClass.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/api/dublin_core.inc b/api/dublin_core.inc index cb920c2a..ae8a3687 100644 --- a/api/dublin_core.inc +++ b/api/dublin_core.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/api/fedora_export.inc b/api/fedora_export.inc index 30675783..f3c82160 100644 --- a/api/fedora_export.inc +++ b/api/fedora_export.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index 917030ee..c154dbc4 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/api/rels-ext.inc b/api/rels-ext.inc index 4714b4ed..d89f9abd 100644 --- a/api/rels-ext.inc +++ b/api/rels-ext.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/api/tagging.inc b/api/tagging.inc index 5d58358b..bfe4b844 100644 --- a/api/tagging.inc +++ b/api/tagging.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/formClass.inc b/formClass.inc index cfc240b6..be5ef9d2 100644 --- a/formClass.inc +++ b/formClass.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/CollectionFormBuilder.inc b/plugins/CollectionFormBuilder.inc index a385aa26..93e11479 100644 --- a/plugins/CollectionFormBuilder.inc +++ b/plugins/CollectionFormBuilder.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/CreateCollection.inc b/plugins/CreateCollection.inc index 1ce9fad3..c02ac2b7 100644 --- a/plugins/CreateCollection.inc +++ b/plugins/CreateCollection.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/DemoFormBuilder.inc b/plugins/DemoFormBuilder.inc index ccc74ba2..05a9304f 100644 --- a/plugins/DemoFormBuilder.inc +++ b/plugins/DemoFormBuilder.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/Exiftool.inc b/plugins/Exiftool.inc index c0b98981..d8fd5e90 100644 --- a/plugins/Exiftool.inc +++ b/plugins/Exiftool.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc index 855d508c..4f3d9a74 100644 --- a/plugins/FedoraObjectDetailedContent.inc +++ b/plugins/FedoraObjectDetailedContent.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/Ffmpeg.inc b/plugins/Ffmpeg.inc index 81072ee3..46b4ae80 100644 --- a/plugins/Ffmpeg.inc +++ b/plugins/Ffmpeg.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/Flv.inc b/plugins/Flv.inc index d8f2b06b..f51e2194 100644 --- a/plugins/Flv.inc +++ b/plugins/Flv.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/FlvFormBuilder.inc b/plugins/FlvFormBuilder.inc index c259328c..8c2b5777 100644 --- a/plugins/FlvFormBuilder.inc +++ b/plugins/FlvFormBuilder.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index 382733b4..6da718fa 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/ImageManipulation.inc b/plugins/ImageManipulation.inc index 8f97ab94..4faabdd8 100644 --- a/plugins/ImageManipulation.inc +++ b/plugins/ImageManipulation.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index d49869e2..b9ace70b 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index 68ae5528..39dc68d0 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/plugins/PersonalCollectionClass.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/Refworks.inc b/plugins/Refworks.inc index 592a7e99..0f3e908c 100644 --- a/plugins/Refworks.inc +++ b/plugins/Refworks.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/ShowDemoStreamsInFieldSets.inc b/plugins/ShowDemoStreamsInFieldSets.inc index b648df53..80f8017c 100644 --- a/plugins/ShowDemoStreamsInFieldSets.inc +++ b/plugins/ShowDemoStreamsInFieldSets.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index 77eada60..e13dce33 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/map_viewer.inc b/plugins/map_viewer.inc index 3e9bcfb6..f3bfca80 100644 --- a/plugins/map_viewer.inc +++ b/plugins/map_viewer.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/qt_viewer.inc b/plugins/qt_viewer.inc index e4717f14..e52e4363 100644 --- a/plugins/qt_viewer.inc +++ b/plugins/qt_viewer.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/slide_viewer.inc b/plugins/slide_viewer.inc index 1d23b227..45ff3f9d 100644 --- a/plugins/slide_viewer.inc +++ b/plugins/slide_viewer.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file diff --git a/plugins/tagging_form.inc b/plugins/tagging_form.inc index 0a421105..390bf36c 100644 --- a/plugins/tagging_form.inc +++ b/plugins/tagging_form.inc @@ -1,6 +1,6 @@ <?php -// $Id$ + /** * @file From 6494fa13a3accdb8ce373a810483d458e81ea731 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:37:52 -0300 Subject: [PATCH 21/46] Added check_plain to the error handling --- BatchIngest.inc | 2 +- CollectionClass.inc | 18 +++++++++--------- ConnectionHelper.inc | 4 ++-- ObjectHelper.inc | 2 +- plugins/DarwinCore.inc | 2 +- plugins/Flv.inc | 4 ++-- plugins/FormBuilder.inc | 8 ++++---- plugins/ModsFormBuilder.inc | 4 ++-- plugins/PersonalCollectionClass.inc | 4 ++-- plugins/ShowStreamsInFieldSets.inc | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/BatchIngest.inc b/BatchIngest.inc index 621a674a..f4d987e0 100644 --- a/BatchIngest.inc +++ b/BatchIngest.inc @@ -229,7 +229,7 @@ function batch_create_dc_from_mods($mods_xml) { try { $proc = new XsltProcessor(); } catch (Exception $e) { - drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); return " "; } diff --git a/CollectionClass.inc b/CollectionClass.inc index ae68e2de..3d2c9f5b 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -131,7 +131,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting relationship element from policy stream !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error getting relationship element from policy stream !e', array('!e' => check_plain($e->getMessage()))), 'error'); return; } $relationship = $xml->relationship[0]; @@ -172,7 +172,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting PID namespace !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error getting PID namespace !e', array('!e' => check_plain($e->getMessage()))), 'error'); return; } foreach ($xml->contentmodels->contentmodel as $contentModel) { @@ -199,7 +199,7 @@ class CollectionClass { $xml = new SimpleXMLElement($collection_stream); } catch (Exception $e) { if ($showError) { - drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); } return NULL; } @@ -239,7 +239,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error Getting FormHandler: !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error Getting FormHandler: !e', array('!e' => check_plain($e->getMessage()))), 'error'); return NULL; } $formHandler = $xml->ingest_form; @@ -272,7 +272,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting content model stream for mime types !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error getting content model stream for mime types !e', array('!e' => check_plain($e->getMessage()))), 'error'); return; } foreach ($xml->mimetypes->type as $type) { @@ -302,7 +302,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting content model stream !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error getting content model stream !e', array('!e' => check_plain($e->getMessage()))), 'error'); return FALSE; } foreach ($xml->ingest_rules->rule as $rule) { @@ -365,7 +365,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting ingest form stream !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error getting ingest form stream !e', array('!e' => check_plain($e->getMessage()))), 'error'); return FALSE; } $docRoot = $_SERVER['DOCUMENT_ROOT']; @@ -451,7 +451,7 @@ class CollectionClass { $params )); } catch (exception $e) { - drupal_set_message(t('Error getting Next PID: !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error getting Next PID: !e', array('!e' => check_plain($e->getMessage()))), 'error'); return FALSE; } $pid = implode(get_object_vars($object)); @@ -663,7 +663,7 @@ class CollectionClass { throw new Exception("Invalid XML."); } } catch (Exception $e) { - drupal_set_message(t('!e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('!e', array('!e' => check_plain($e->getMessage()))), 'error'); return ''; } } diff --git a/ConnectionHelper.inc b/ConnectionHelper.inc index 255ebfac..71cca98d 100644 --- a/ConnectionHelper.inc +++ b/ConnectionHelper.inc @@ -71,7 +71,7 @@ class ConnectionHelper { 'exceptions' => $exceptions, )); } catch (SoapFault $e) { - drupal_set_message(t("!e", array('!e' => $e->getMessage()))); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage())))); return NULL; } } @@ -83,7 +83,7 @@ class ConnectionHelper { 'exceptions' => TRUE, )); } catch (SoapFault $e) { - drupal_set_message(t("!e", array('!e' => $e->getMessage()))); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage())))); return NULL; } } diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 98160292..ed3aec38 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -750,7 +750,7 @@ class ObjectHelper { try { $parent_collections = new SimpleXMLElement($parent_collections); } catch (exception $e) { - drupal_set_message(t('Error getting parent objects !e', array('!e' => $e->getMessage()))); + drupal_set_message(t('Error getting parent objects !e', array('!e' => check_plain($e->getMessage())))); return; } diff --git a/plugins/DarwinCore.inc b/plugins/DarwinCore.inc index 5ab525b6..1071c5e0 100644 --- a/plugins/DarwinCore.inc +++ b/plugins/DarwinCore.inc @@ -261,7 +261,7 @@ class DarwinCore { try { $proc = new XsltProcessor(); } catch (Exception $e) { - drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); return " "; } diff --git a/plugins/Flv.inc b/plugins/Flv.inc index f51e2194..0e248b71 100644 --- a/plugins/Flv.inc +++ b/plugins/Flv.inc @@ -69,7 +69,7 @@ class FormBuilder { $oai->appendChild($previousElement); } } catch (exception $e) { - drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); continue; } } @@ -126,7 +126,7 @@ class FormBuilder { unlink($form_values['fullpath']); } } catch (exception $e) { - drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error ingesting object: !e', array('!e' => check_plain($e->getMessage()))), 'error'); return; } } diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index 6da718fa..d44e1f9b 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -68,7 +68,7 @@ class FormBuilder { $oai->appendChild($previousElement); } } catch (exception $e) { - drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); continue; } } @@ -96,7 +96,7 @@ class FormBuilder { $xml = new SimpleXMLElement($policyStreamDoc); } catch (Exception $e) { watchdog(t("Fedora_Repository"), t("Problem getting security policy."), NULL, WATCHDOG_ERROR); - drupal_set_message(t('Problem getting security policy: !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Problem getting security policy: !e', array('!e' => check_plain($e->getMessage()))), 'error'); return FALSE; } $policyElement = $dom->createDocumentFragment(); @@ -182,8 +182,8 @@ class FormBuilder { } file_delete($form_values['ingest-file-location']); } catch (exception $e) { - drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error'); - watchdog(t("Fedora_Repository"), "Error ingesting object: !e", array('!e' => $e->getMessage()), NULL, WATCHDOG_ERROR); + drupal_set_message(t('Error ingesting object: !e', array('!e' => check_plain($e->getMessage()))), 'error'); + watchdog(t("Fedora_Repository"), "Error ingesting object: !e", array('!e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); return; } } diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index b9ace70b..05ae0a99 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -316,8 +316,8 @@ class ModsFormBuilder extends FormBuilder { } file_delete($form_values['ingest-file-location']); } catch (exception $e) { - drupal_set_message(t('Error ingesting object: !e', array('!e' => $e->getMessage())), 'error'); - watchdog(t("Fedora_Repository"), "Error ingesting object: !e", array('!e' => $e->getMessage()), NULL, WATCHDOG_ERROR); + drupal_set_message(t('Error ingesting object: !e', array('!e' => check_plain($e->getMessage()))), 'error'); + watchdog(t("Fedora_Repository"), "Error ingesting object: !e", array('!e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); return; } } diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index 39dc68d0..6d5b0946 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/plugins/PersonalCollectionClass.inc @@ -57,7 +57,7 @@ class PersonalCollectionClass { $params )); } catch (exception $e) { - drupal_set_message(t('Error ingesting personal collection object: !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Error ingesting personal collection object: !e', array('!e' => check_plain($e->getMessage()))), 'error'); return FALSE; } return TRUE; @@ -76,7 +76,7 @@ class PersonalCollectionClass { $xml = new SimpleXMLElement($collectionTemplate); } catch (Exception $e) { watchdog(t("Fedora_Repository"), t("Problem creating personal collection policy, could not parse collection policy stream."), NULL, WATCHDOG_ERROR); - drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: !e', array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: !e', array('!e' => check_plain($e->getMessage()))), 'error'); return FALSE; } $policyElement = $dom->createDocumentFragment(); diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index e13dce33..23d5a4dc 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -183,7 +183,7 @@ class ShowStreamsInFieldSets { try { $proc = new XsltProcessor(); } catch (Exception $e) { - drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); return " "; } $xsl = new DomDocument(); @@ -237,7 +237,7 @@ class ShowStreamsInFieldSets { try { $proc = new XsltProcessor(); } catch (Exception $e) { - drupal_set_message(t("!e", array('!e' => $e->getMessage())), 'error'); + drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); return; } $xsl = new DomDocument(); From 9c43f2dce7cdab33c9a590566c55b5f5c6529e64 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:52:10 -0300 Subject: [PATCH 22/46] Added a check_plain to getMessage and changed !e to @e --- BatchIngest.inc | 2 +- CollectionClass.inc | 18 +++++++++--------- ConnectionHelper.inc | 4 ++-- ObjectHelper.inc | 4 ++-- api/fedora_item.inc | 4 ++-- api/tagging.inc | 2 +- plugins/DarwinCore.inc | 2 +- plugins/Flv.inc | 4 ++-- plugins/FormBuilder.inc | 8 ++++---- plugins/ModsFormBuilder.inc | 4 ++-- plugins/PersonalCollectionClass.inc | 4 ++-- plugins/Refworks.inc | 4 ++-- plugins/ShowStreamsInFieldSets.inc | 4 ++-- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/BatchIngest.inc b/BatchIngest.inc index f4d987e0..efc235a6 100644 --- a/BatchIngest.inc +++ b/BatchIngest.inc @@ -229,7 +229,7 @@ function batch_create_dc_from_mods($mods_xml) { try { $proc = new XsltProcessor(); } catch (Exception $e) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); return " "; } diff --git a/CollectionClass.inc b/CollectionClass.inc index 3d2c9f5b..82e4739e 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -131,7 +131,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting relationship element from policy stream !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error getting relationship element from policy stream @e', array('@e' => check_plain($e->getMessage()))), 'error'); return; } $relationship = $xml->relationship[0]; @@ -172,7 +172,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting PID namespace !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error getting PID namespace @e', array('@e' => check_plain($e->getMessage()))), 'error'); return; } foreach ($xml->contentmodels->contentmodel as $contentModel) { @@ -199,7 +199,7 @@ class CollectionClass { $xml = new SimpleXMLElement($collection_stream); } catch (Exception $e) { if ($showError) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); } return NULL; } @@ -239,7 +239,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error Getting FormHandler: !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error Getting FormHandler: @e', array('@e' => check_plain($e->getMessage()))), 'error'); return NULL; } $formHandler = $xml->ingest_form; @@ -272,7 +272,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting content model stream for mime types !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error getting content model stream for mime types @e', array('@e' => check_plain($e->getMessage()))), 'error'); return; } foreach ($xml->mimetypes->type as $type) { @@ -302,7 +302,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting content model stream !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error getting content model stream @e', array('@e' => check_plain($e->getMessage()))), 'error'); return FALSE; } foreach ($xml->ingest_rules->rule as $rule) { @@ -365,7 +365,7 @@ class CollectionClass { try { $xml = new SimpleXMLElement($stream); } catch (Exception $e) { - drupal_set_message(t('Error getting ingest form stream !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error getting ingest form stream @e', array('@e' => check_plain($e->getMessage()))), 'error'); return FALSE; } $docRoot = $_SERVER['DOCUMENT_ROOT']; @@ -451,7 +451,7 @@ class CollectionClass { $params )); } catch (exception $e) { - drupal_set_message(t('Error getting Next PID: !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error getting Next PID: @e', array('@e' => check_plain($e->getMessage()))), 'error'); return FALSE; } $pid = implode(get_object_vars($object)); @@ -663,7 +663,7 @@ class CollectionClass { throw new Exception("Invalid XML."); } } catch (Exception $e) { - drupal_set_message(t('!e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); return ''; } } diff --git a/ConnectionHelper.inc b/ConnectionHelper.inc index 71cca98d..59f811e2 100644 --- a/ConnectionHelper.inc +++ b/ConnectionHelper.inc @@ -71,7 +71,7 @@ class ConnectionHelper { 'exceptions' => $exceptions, )); } catch (SoapFault $e) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage())))); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); return NULL; } } @@ -83,7 +83,7 @@ class ConnectionHelper { 'exceptions' => TRUE, )); } catch (SoapFault $e) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage())))); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); return NULL; } } diff --git a/ObjectHelper.inc b/ObjectHelper.inc index ed3aec38..70f73d4b 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -386,7 +386,7 @@ class ObjectHelper { $input = new DomDocument(); $input->loadXML(trim($xmlstr)); } catch (exception $e) { - watchdog(t("Fedora_Repository"), "Problem loading XSL file: !e", array('!e' => $e), NULL, WATCHDOG_ERROR); + watchdog(t("Fedora_Repository"), "Problem loading XSL file: @e", array('@e' => $e), NULL, WATCHDOG_ERROR); } $xsl = $proc->importStylesheet($xsl); $newdom = $proc->transformToDoc($input); @@ -750,7 +750,7 @@ class ObjectHelper { try { $parent_collections = new SimpleXMLElement($parent_collections); } catch (exception $e) { - drupal_set_message(t('Error getting parent objects !e', array('!e' => check_plain($e->getMessage())))); + drupal_set_message(t('Error getting parent objects @e', array('@e' => check_plain($e->getMessage())))); return; } diff --git a/api/fedora_item.inc b/api/fedora_item.inc index a4ee923b..54a9158b 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -885,7 +885,7 @@ class Fedora_Item { drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error'); } - watchdog(t("FEDORA_REPOSITORY"), "Error Trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e), NULL, WATCHDOG_ERROR); + watchdog(t("FEDORA_REPOSITORY"), "Error Trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR); } return NULL; } @@ -904,7 +904,7 @@ class Fedora_Item { } catch (exception $e) { if (!$quiet) { - watchdog(t("FEDORA_REPOSITORY"), "Error trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e), NULL, WATCHDOG_ERROR); + watchdog(t("FEDORA_REPOSITORY"), "Error trying to call SOAP function @fn: @e", array('@fn' => $function_name, '@e' => $e), NULL, WATCHDOG_ERROR); } return NULL; } diff --git a/api/tagging.inc b/api/tagging.inc index bfe4b844..418193fa 100644 --- a/api/tagging.inc +++ b/api/tagging.inc @@ -69,7 +69,7 @@ class TagSet { $this->item->modify_datastream_by_value($tagdoc->saveXML(), $this->tagsDSID, 'Tags', 'text/xml', 'X'); } } catch (exception $e) { - drupal_set_message(t('There was an error saving the tags datastream: !e'), array('!e' => $e), 'error'); + drupal_set_message(t('There was an error saving the tags datastream: @e'), array('@e' => $e), 'error'); return FALSE; } return TRUE; diff --git a/plugins/DarwinCore.inc b/plugins/DarwinCore.inc index 1071c5e0..2d66d60a 100644 --- a/plugins/DarwinCore.inc +++ b/plugins/DarwinCore.inc @@ -261,7 +261,7 @@ class DarwinCore { try { $proc = new XsltProcessor(); } catch (Exception $e) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); return " "; } diff --git a/plugins/Flv.inc b/plugins/Flv.inc index 0e248b71..b5f159b2 100644 --- a/plugins/Flv.inc +++ b/plugins/Flv.inc @@ -69,7 +69,7 @@ class FormBuilder { $oai->appendChild($previousElement); } } catch (exception $e) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); continue; } } @@ -126,7 +126,7 @@ class FormBuilder { unlink($form_values['fullpath']); } } catch (exception $e) { - drupal_set_message(t('Error ingesting object: !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error ingesting object: @e', array('@e' => check_plain($e->getMessage()))), 'error'); return; } } diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index d44e1f9b..cd9dc4a9 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -68,7 +68,7 @@ class FormBuilder { $oai->appendChild($previousElement); } } catch (exception $e) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); continue; } } @@ -96,7 +96,7 @@ class FormBuilder { $xml = new SimpleXMLElement($policyStreamDoc); } catch (Exception $e) { watchdog(t("Fedora_Repository"), t("Problem getting security policy."), NULL, WATCHDOG_ERROR); - drupal_set_message(t('Problem getting security policy: !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Problem getting security policy: @e', array('@e' => check_plain($e->getMessage()))), 'error'); return FALSE; } $policyElement = $dom->createDocumentFragment(); @@ -182,8 +182,8 @@ class FormBuilder { } file_delete($form_values['ingest-file-location']); } catch (exception $e) { - drupal_set_message(t('Error ingesting object: !e', array('!e' => check_plain($e->getMessage()))), 'error'); - watchdog(t("Fedora_Repository"), "Error ingesting object: !e", array('!e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); + drupal_set_message(t('Error ingesting object: @e', array('@e' => check_plain($e->getMessage()))), 'error'); + watchdog(t("Fedora_Repository"), "Error ingesting object: @e", array('@e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); return; } } diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index 05ae0a99..aa0f6f92 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -316,8 +316,8 @@ class ModsFormBuilder extends FormBuilder { } file_delete($form_values['ingest-file-location']); } catch (exception $e) { - drupal_set_message(t('Error ingesting object: !e', array('!e' => check_plain($e->getMessage()))), 'error'); - watchdog(t("Fedora_Repository"), "Error ingesting object: !e", array('!e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); + drupal_set_message(t('Error ingesting object: @e', array('@e' => check_plain($e->getMessage()))), 'error'); + watchdog(t("Fedora_Repository"), "Error ingesting object: @e", array('@e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); return; } } diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index 6d5b0946..29c76cfa 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/plugins/PersonalCollectionClass.inc @@ -57,7 +57,7 @@ class PersonalCollectionClass { $params )); } catch (exception $e) { - drupal_set_message(t('Error ingesting personal collection object: !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Error ingesting personal collection object: @e', array('@e' => check_plain($e->getMessage()))), 'error'); return FALSE; } return TRUE; @@ -76,7 +76,7 @@ class PersonalCollectionClass { $xml = new SimpleXMLElement($collectionTemplate); } catch (Exception $e) { watchdog(t("Fedora_Repository"), t("Problem creating personal collection policy, could not parse collection policy stream."), NULL, WATCHDOG_ERROR); - drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: !e', array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: @e', array('@e' => check_plain($e->getMessage()))), 'error'); return FALSE; } $policyElement = $dom->createDocumentFragment(); diff --git a/plugins/Refworks.inc b/plugins/Refworks.inc index 0f3e908c..5e39b3c2 100644 --- a/plugins/Refworks.inc +++ b/plugins/Refworks.inc @@ -290,7 +290,7 @@ class Refworks { if ($client == NULL) { drupal_set_message(t('Error getting SOAP client.'), 'error'); - watchdog(t("FEDORA_REPOSITORY"), "Error getting SOAP client: !e", array('!e' => $e), NULL, WATCHDOG_ERROR); + watchdog(t("FEDORA_REPOSITORY"), "Error getting SOAP client: @e", array('@e' => $e), NULL, WATCHDOG_ERROR); return; } $object = $client->__soapCall('ingest', array( @@ -305,7 +305,7 @@ class Refworks { } catch (exception $e) { $errors++; $errorMessage = 'yes'; - watchdog(t("FEDORA_REPOSITORY"), t("Error during ingest !it !e", array('!it' => $item_title, '!e' => $e)), NULL, WATCHDOG_ERROR); + watchdog(t("FEDORA_REPOSITORY"), t("Error during ingest !it @e", array('!it' => $item_title, '@e' => $e)), NULL, WATCHDOG_ERROR); } $success++; } diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index 23d5a4dc..a6e7eaad 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -183,7 +183,7 @@ class ShowStreamsInFieldSets { try { $proc = new XsltProcessor(); } catch (Exception $e) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); return " "; } $xsl = new DomDocument(); @@ -237,7 +237,7 @@ class ShowStreamsInFieldSets { try { $proc = new XsltProcessor(); } catch (Exception $e) { - drupal_set_message(t("!e", array('!e' => check_plain($e->getMessage()))), 'error'); + drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); return; } $xsl = new DomDocument(); From 759c5204497fb27e60a108f28fb85b070e1a9589 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 13 Oct 2011 14:56:38 -0300 Subject: [PATCH 23/46] Removed camel case --- BatchIngest.inc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/BatchIngest.inc b/BatchIngest.inc index efc235a6..c78be313 100644 --- a/BatchIngest.inc +++ b/BatchIngest.inc @@ -65,22 +65,22 @@ function batch_creation_form(&$form_state, $collection_pid, $content_models) { */ function batch_creation_form_validate($form, &$form_state) { - $fieldName = 'file-location'; - if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name'][$fieldName])) { - $file = file_save_upload($fieldName); + $field_name = 'file-location'; + if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name'][$field_name])) { + $file = file_save_upload($field_name); if ($file->filemime != 'application/zip') { - form_set_error($fieldName, 'Input file must be a .zip file'); + form_set_error($field_name, 'Input file must be a .zip file'); return; } if (!$file) { - form_set_error($fieldName, 'Error uploading file.'); + form_set_error($field_name, 'Error uploading file.'); return; } $form_state['values']['file'] = $file; } else { // set error - form_set_error($fieldName, 'Error uploading file.'); + form_set_error($field_name, 'Error uploading file.'); return; } } @@ -100,27 +100,27 @@ function batch_creation_form_submit($form, &$form_state) { } $namespace = $namespace_mappings[$content_model]; $namespace = preg_replace('/:.*/', '', $namespace); - $dirName = "temp" . $user->uid; - $tmpDir = file_directory_path() . '/' . $dirName . '/'; - mkdir($tmpDir); + $dir_name = "temp" . $user->uid; + $tmp_dir = file_directory_path() . '/' . $dir_name . '/'; + mkdir($tmp_dir); $file = $form_state['values']['file']; $fileName = $file->filepath; $file_list = array(); - $cmdString = "unzip -q -o -d $tmpDir \"$fileName\""; + $cmdString = "unzip -q -o -d $tmp_dir \"$fileName\""; system($cmdString, $retVal); $dirs = array(); - $doNotAdd = array('.', '..', '__MACOSX'); - array_push($dirs, $tmpDir); - $files = scandir($tmpDir); + $do_not_add = array('.', '..', '__MACOSX'); + array_push($dirs, $tmp_dir); + $files = scandir($tmp_dir); foreach ($files as $file) { - if (is_dir("$tmpDir/$file") & !in_array($file, $doNotAdd)) { - array_push($dirs, $tmpDir . $file); + if (is_dir("$tmp_dir/$file") & !in_array($file, $do_not_add)) { + array_push($dirs, $tmp_dir . $file); } } foreach ($dirs as $directory) { if ($inputs = opendir($directory)) { while (FALSE !== ($file_name = readdir($inputs))) { - if (!in_array($file_name, $doNotAdd) && is_dir($file_name) == FALSE) { + if (!in_array($file_name, $do_not_add) && is_dir($file_name) == FALSE) { $ext = strrchr($file_name, '.'); $base = preg_replace("/$ext$/", '', $file_name); $ext = substr($ext, 1); @@ -148,7 +148,7 @@ function batch_creation_form_submit($form, &$form_state) { foreach ($file_list as $label => $object_files) { $batch['operations'][] = array('create_batch_objects', array($label, $content_model, $object_files, $collection_pid, $namespace, $metadata)); } - $batch['operations'][] = array('recursive_directory_delete', array($tmpDir)); + $batch['operations'][] = array('recursive_directory_delete', array($tmp_dir)); batch_set($batch); batch_process(); } @@ -168,7 +168,7 @@ function create_batch_objects($label, $content_model, $object_files, $collection module_load_include('inc', 'fedora_reppository', 'api/fedora_item'); $cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM'); - $allowedMimeTypes = $cm->getMimetypes(); + $allowed_mime_types = $cm->getMimetypes(); $mime_helper = new MimeClass(); $pid = fedora_item::get_next_PID_in_namespace($namespace); @@ -193,7 +193,7 @@ function create_batch_objects($label, $content_model, $object_files, $collection $use_primary = TRUE; foreach ($object_files as $ext => $filename) { $file_mimetype = $mime_helper->get_mimetype($filename); - if (in_array($file_mimetype, $allowedMimeTypes)) { + if (in_array($file_mimetype, $allowed_mime_types)) { $added = $cm->execIngestRules($filename, $file_mimetype); } else { From 9eb6038eeafba16fb248bf88bc08ab20f014094b Mon Sep 17 00:00:00 2001 From: rwincewicz <richard.wincewicz@googlemail.com> Date: Fri, 14 Oct 2011 16:43:42 -0300 Subject: [PATCH 24/46] Fixed paging issue in sparql_to_html.xsl --- xsl/sparql_to_html.xsl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/xsl/sparql_to_html.xsl b/xsl/sparql_to_html.xsl index 71f94a30..c64af7d0 100644 --- a/xsl/sparql_to_html.xsl +++ b/xsl/sparql_to_html.xsl @@ -34,7 +34,7 @@ of <xsl:value-of select="$count"/> <br /> <li class="pager-previous"> <a> - <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/<xsl:value-of select="$thisTitle"/>/<xsl:value-of select="$page - 1"/> + <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> </xsl:attribute> <Prev </a></li> @@ -44,7 +44,7 @@ of <xsl:value-of select="$count"/> <br /> <li class="pager-next"> <a> - <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/<xsl:value-of select="$thisTitle"/>/<xsl:value-of select="$page + 1"/> + <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/> </xsl:attribute> Next> </a></li> @@ -54,13 +54,13 @@ of <xsl:value-of select="$count"/> <br /> <li class="pager-previous"> <a> - <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/<xsl:value-of select="$thisTitle"/>/<xsl:value-of select="$page - 1"/> + <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> </xsl:attribute> <Prev </a> </li> <li class="pager-next"> <a> - <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/<xsl:value-of select="$thisTitle"/>/<xsl:value-of select="$page + 1"/> + <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/> </xsl:attribute> Next> </a></li> @@ -106,7 +106,7 @@ of <xsl:value-of select="$count"/> <br /> <li class="pager-previous"> <a> - <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/<xsl:value-of select="$thisTitle"/>/<xsl:value-of select="$page - 1"/> + <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> </xsl:attribute> <Prev </a></li> @@ -116,7 +116,7 @@ of <xsl:value-of select="$count"/> <br /> <li class="pager-next"> <a> - <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/<xsl:value-of select="$thisTitle"/>/<xsl:value-of select="$page + 1"/> + <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/> </xsl:attribute> Next> </a></li> @@ -126,13 +126,13 @@ of <xsl:value-of select="$count"/> <br /> <li class="pager-previous"> <a> - <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/<xsl:value-of select="$thisTitle"/>/<xsl:value-of select="$page - 1"/> + <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> </xsl:attribute> <Prev </a> </li> <li class="pager-next"> <a> - <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/<xsl:value-of select="$thisTitle"/>/<xsl:value-of select="$page + 1"/> + <xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/> </xsl:attribute> Next> </a></li> @@ -245,4 +245,4 @@ </xsl:otherwise> </xsl:choose> </xsl:template> -</xsl:stylesheet> \ No newline at end of file +</xsl:stylesheet> From db7874c35eb96d20b964671ece1ccd701c36bf4f Mon Sep 17 00:00:00 2001 From: rwincewicz <richard.wincewicz@googlemail.com> Date: Fri, 14 Oct 2011 16:47:15 -0300 Subject: [PATCH 25/46] Fixed paging issue in sparql_to_html.xsl --- xsl/sparql_to_html.xsl | 1 - 1 file changed, 1 deletion(-) diff --git a/xsl/sparql_to_html.xsl b/xsl/sparql_to_html.xsl index c64af7d0..1b042273 100644 --- a/xsl/sparql_to_html.xsl +++ b/xsl/sparql_to_html.xsl @@ -8,7 +8,6 @@ <xsl:value-of select="$path"/> </xsl:variable> <xsl:variable name="thisPid" select="$collectionPid"/> - <xsl:variable name="thisTitle" select="Collection"/> <xsl:variable name="size" select="20"/> <xsl:variable name="page" select="$hitPage"/> <xsl:variable name="start" select="((number($page) - 1) * number($size)) + 1"/> From 9201ae2ef6d4e0df6420b8f41f561e85f542bff9 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Tue, 18 Oct 2011 15:43:21 -0300 Subject: [PATCH 26/46] Fixed version --- fedora_repository.info | 2 +- plugins/fedora_imageapi.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fedora_repository.info b/fedora_repository.info index 6fcf223f..99cb3d6f 100644 --- a/fedora_repository.info +++ b/fedora_repository.info @@ -5,5 +5,5 @@ dependencies[] = tabs dependencies[] = islandora_content_model_forms description = Shows a list of items in a fedora collection. package = Islandora -version = 11.2.beta2 +version = 11.2.0 core = 6.x diff --git a/plugins/fedora_imageapi.info b/plugins/fedora_imageapi.info index 6a465a04..af50a614 100644 --- a/plugins/fedora_imageapi.info +++ b/plugins/fedora_imageapi.info @@ -3,5 +3,5 @@ description = Adds image manipulation support through a REST interface package = Islandora Dependencies dependencies[] = fedora_repository dependencies[] = imageapi -version = 11.2.beta2 +version = 11.2.0 core = 6.x From ce0078d0eab8a0a4346e2086069093351d37a604 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Wed, 19 Oct 2011 09:33:17 -0300 Subject: [PATCH 27/46] Moved fixed a more appropriate place API should be low level fedora communications Core should be islandora specific code --- BatchIngest.inc => core/BatchIngest.inc | 0 CollectionClass.inc => core/CollectionClass.inc | 0 CollectionManagement.inc => core/CollectionManagement.inc | 0 CollectionPolicy.inc => core/CollectionPolicy.inc | 0 ConnectionHelper.inc => core/ConnectionHelper.inc | 0 ContentModel.inc => core/ContentModel.inc | 0 MimeClass.inc => core/MimeClass.inc | 0 ObjectHelper.inc => core/ObjectHelper.inc | 0 SearchClass.inc => core/SearchClass.inc | 0 SecurityClass.inc => core/SecurityClass.inc | 0 XMLDatastream.inc => core/XMLDatastream.inc | 0 .../fedora_repository.solutionpacks.inc | 0 formClass.inc => core/formClass.inc | 0 islandoracm.xsd => xsd/islandoracm.xsd | 0 searchTerms.xml => xsl/searchTerms.xml | 0 solrSearchTerms.xml => xsl/solrSearchTerms.xml | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename BatchIngest.inc => core/BatchIngest.inc (100%) rename CollectionClass.inc => core/CollectionClass.inc (100%) rename CollectionManagement.inc => core/CollectionManagement.inc (100%) rename CollectionPolicy.inc => core/CollectionPolicy.inc (100%) rename ConnectionHelper.inc => core/ConnectionHelper.inc (100%) rename ContentModel.inc => core/ContentModel.inc (100%) rename MimeClass.inc => core/MimeClass.inc (100%) rename ObjectHelper.inc => core/ObjectHelper.inc (100%) rename SearchClass.inc => core/SearchClass.inc (100%) rename SecurityClass.inc => core/SecurityClass.inc (100%) rename XMLDatastream.inc => core/XMLDatastream.inc (100%) rename fedora_repository.solutionpacks.inc => core/fedora_repository.solutionpacks.inc (100%) rename formClass.inc => core/formClass.inc (100%) rename islandoracm.xsd => xsd/islandoracm.xsd (100%) rename searchTerms.xml => xsl/searchTerms.xml (100%) rename solrSearchTerms.xml => xsl/solrSearchTerms.xml (100%) diff --git a/BatchIngest.inc b/core/BatchIngest.inc similarity index 100% rename from BatchIngest.inc rename to core/BatchIngest.inc diff --git a/CollectionClass.inc b/core/CollectionClass.inc similarity index 100% rename from CollectionClass.inc rename to core/CollectionClass.inc diff --git a/CollectionManagement.inc b/core/CollectionManagement.inc similarity index 100% rename from CollectionManagement.inc rename to core/CollectionManagement.inc diff --git a/CollectionPolicy.inc b/core/CollectionPolicy.inc similarity index 100% rename from CollectionPolicy.inc rename to core/CollectionPolicy.inc diff --git a/ConnectionHelper.inc b/core/ConnectionHelper.inc similarity index 100% rename from ConnectionHelper.inc rename to core/ConnectionHelper.inc diff --git a/ContentModel.inc b/core/ContentModel.inc similarity index 100% rename from ContentModel.inc rename to core/ContentModel.inc diff --git a/MimeClass.inc b/core/MimeClass.inc similarity index 100% rename from MimeClass.inc rename to core/MimeClass.inc diff --git a/ObjectHelper.inc b/core/ObjectHelper.inc similarity index 100% rename from ObjectHelper.inc rename to core/ObjectHelper.inc diff --git a/SearchClass.inc b/core/SearchClass.inc similarity index 100% rename from SearchClass.inc rename to core/SearchClass.inc diff --git a/SecurityClass.inc b/core/SecurityClass.inc similarity index 100% rename from SecurityClass.inc rename to core/SecurityClass.inc diff --git a/XMLDatastream.inc b/core/XMLDatastream.inc similarity index 100% rename from XMLDatastream.inc rename to core/XMLDatastream.inc diff --git a/fedora_repository.solutionpacks.inc b/core/fedora_repository.solutionpacks.inc similarity index 100% rename from fedora_repository.solutionpacks.inc rename to core/fedora_repository.solutionpacks.inc diff --git a/formClass.inc b/core/formClass.inc similarity index 100% rename from formClass.inc rename to core/formClass.inc diff --git a/islandoracm.xsd b/xsd/islandoracm.xsd similarity index 100% rename from islandoracm.xsd rename to xsd/islandoracm.xsd diff --git a/searchTerms.xml b/xsl/searchTerms.xml similarity index 100% rename from searchTerms.xml rename to xsl/searchTerms.xml diff --git a/solrSearchTerms.xml b/xsl/solrSearchTerms.xml similarity index 100% rename from solrSearchTerms.xml rename to xsl/solrSearchTerms.xml From bddfd81fc8c1082e0bf76b789727790a7dde92d8 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Wed, 19 Oct 2011 09:57:41 -0300 Subject: [PATCH 28/46] Marked everything in plugins as deprecated --- {plugins => api}/fedora_imageapi.info | 0 {plugins => api}/fedora_imageapi.module | 6 ++++-- plugins/CollectionFormBuilder.inc | 4 +--- plugins/CreateCollection.inc | 1 + plugins/DarwinCore.inc | 9 ++------- plugins/DemoFormBuilder.inc | 4 +--- plugins/DocumentConverter.inc | 2 +- plugins/Exiftool.inc | 3 +-- plugins/FedoraObjectDetailedContent.inc | 3 +-- plugins/Ffmpeg.inc | 3 +-- plugins/Flv.inc | 3 +-- plugins/FlvFormBuilder.inc | 4 +--- plugins/FormBuilder.inc | 3 +-- plugins/ImageManipulation.inc | 3 +-- plugins/ModsFormBuilder.inc | 5 ++--- plugins/PersonalCollectionClass.inc | 3 +-- plugins/QtFormBuilder.php | 3 +-- plugins/Refworks.inc | 3 ++- plugins/ShowDemoStreamsInFieldSets.inc | 3 ++- plugins/ShowStreamsInFieldSets.inc | 3 ++- plugins/herbarium.inc | 12 ++++++------ plugins/map_viewer.inc | 5 ++--- plugins/qt_viewer.inc | 3 +-- plugins/slide_viewer.inc | 5 ++--- plugins/tagging_form.inc | 6 ++++-- 25 files changed, 42 insertions(+), 57 deletions(-) rename {plugins => api}/fedora_imageapi.info (100%) rename {plugins => api}/fedora_imageapi.module (98%) diff --git a/plugins/fedora_imageapi.info b/api/fedora_imageapi.info similarity index 100% rename from plugins/fedora_imageapi.info rename to api/fedora_imageapi.info diff --git a/plugins/fedora_imageapi.module b/api/fedora_imageapi.module similarity index 98% rename from plugins/fedora_imageapi.module rename to api/fedora_imageapi.module index f3bd4481..99c2cfd2 100644 --- a/plugins/fedora_imageapi.module +++ b/api/fedora_imageapi.module @@ -1,7 +1,9 @@ <?php - - +/** + * fedora imageapi menu + * @return string + */ function fedora_imageapi_menu() { $items = array(); $items['fedora/imageapi'] = array( diff --git a/plugins/CollectionFormBuilder.inc b/plugins/CollectionFormBuilder.inc index 93e11479..83624d38 100644 --- a/plugins/CollectionFormBuilder.inc +++ b/plugins/CollectionFormBuilder.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * Collection Form Builder @@ -12,8 +10,8 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml * builds a dc metadata form + * @deprecated */ - class CollectionFormBuilder extends FormBuilder { /** diff --git a/plugins/CreateCollection.inc b/plugins/CreateCollection.inc index c02ac2b7..c29eb657 100644 --- a/plugins/CreateCollection.inc +++ b/plugins/CreateCollection.inc @@ -9,6 +9,7 @@ /** * This Class implements the methods defined in the STANDARD_IMAGE content model + * @deprecated */ class CreateCollection { diff --git a/plugins/DarwinCore.inc b/plugins/DarwinCore.inc index 2d66d60a..dc698521 100644 --- a/plugins/DarwinCore.inc +++ b/plugins/DarwinCore.inc @@ -1,18 +1,13 @@ <?php -/* @file - - - -*/ - /** * @file * Darwin Core class */ /** - * Darwin Core ??? + * Darwin Core + * @deprecated */ class DarwinCore { diff --git a/plugins/DemoFormBuilder.inc b/plugins/DemoFormBuilder.inc index 05a9304f..305c2029 100644 --- a/plugins/DemoFormBuilder.inc +++ b/plugins/DemoFormBuilder.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * @@ -11,8 +9,8 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml * builds a dc metadata form + * @deprecated */ - class DemoFormBuilder extends FormBuilder { /** diff --git a/plugins/DocumentConverter.inc b/plugins/DocumentConverter.inc index f258441a..ce782f08 100644 --- a/plugins/DocumentConverter.inc +++ b/plugins/DocumentConverter.inc @@ -1,6 +1,5 @@ <?php - /** * @file * Document Converter Class @@ -9,6 +8,7 @@ /** * This class implements document (doc, odt, pdf, etc.) conversion for a generic * multi-format document collection. + * @deprecated */ class DocumentConverter { diff --git a/plugins/Exiftool.inc b/plugins/Exiftool.inc index d8fd5e90..002c6b0c 100644 --- a/plugins/Exiftool.inc +++ b/plugins/Exiftool.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * Exiftool @@ -9,6 +7,7 @@ /** * This Class implements the methods defined in the STANDARD_IMAGE content model + * @deprecated */ class Exiftool { diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc index 4f3d9a74..ea70642b 100644 --- a/plugins/FedoraObjectDetailedContent.inc +++ b/plugins/FedoraObjectDetailedContent.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * FedoraObjectDetailedContent class @@ -11,6 +9,7 @@ * Fedora Object. This class is a plugin called from content models to display a detailed list of * content of the Fedora Item. This is hard coded into Islandora core, and it can also be called * from the IslandoraCM stream. + * @deprecated */ class FedoraObjectDetailedContent { diff --git a/plugins/Ffmpeg.inc b/plugins/Ffmpeg.inc index 46b4ae80..7c2159ed 100644 --- a/plugins/Ffmpeg.inc +++ b/plugins/Ffmpeg.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * Ffmpeg wrapper class @@ -11,6 +9,7 @@ * FFMpeg wrapper class for generating movie thumbnails * * This Class implements the methods defined in the STANDARD_QT content model + * @deprecated */ class Ffmpeg { diff --git a/plugins/Flv.inc b/plugins/Flv.inc index b5f159b2..76506ce3 100644 --- a/plugins/Flv.inc +++ b/plugins/Flv.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * Form Builder class @@ -9,6 +7,7 @@ /** * implements method from content model ingest form xml + * @deprecated */ class FormBuilder { diff --git a/plugins/FlvFormBuilder.inc b/plugins/FlvFormBuilder.inc index 8c2b5777..5e022b88 100644 --- a/plugins/FlvFormBuilder.inc +++ b/plugins/FlvFormBuilder.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * FLVFormBuilder @@ -11,8 +9,8 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml * builds a dc metadata form + * @deprecated */ - class FlvFormBuilder extends FormBuilder { /** diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index cd9dc4a9..02ca6ace 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * FormBuilder class @@ -10,6 +8,7 @@ /** * implements methods from content model ingest form xml * builds a dc metadata form + * @deprecated */ class FormBuilder { diff --git a/plugins/ImageManipulation.inc b/plugins/ImageManipulation.inc index 4faabdd8..bbbe84fd 100644 --- a/plugins/ImageManipulation.inc +++ b/plugins/ImageManipulation.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * Image Manipulation class @@ -9,6 +7,7 @@ /** * This Class implements the methods defined in the STANDARD_IMAGE content model + * @deprecated */ class ImageManipulation { diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index aa0f6f92..c7eefdb6 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * ModsFormBuilder class @@ -9,7 +7,8 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** - * ModsFormBuilder class ??? + * ModsFormBuilder class + * @deprecated */ class ModsFormBuilder extends FormBuilder { diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index 29c76cfa..b81d75df 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/plugins/PersonalCollectionClass.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * PersonalCollectionClass class @@ -9,6 +7,7 @@ /** * Personal Collection Class + * @deprecated */ class PersonalCollectionClass { diff --git a/plugins/QtFormBuilder.php b/plugins/QtFormBuilder.php index 28645d6b..95b7699c 100644 --- a/plugins/QtFormBuilder.php +++ b/plugins/QtFormBuilder.php @@ -1,7 +1,5 @@ <?php -// $Id$ - /** * @file * QTFormBuilder class @@ -11,6 +9,7 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * Implements methods from content model ingest form xml * builds a dc metadata form + * @deprecated */ class QtFormBuilder extends FormBuilder { diff --git a/plugins/Refworks.inc b/plugins/Refworks.inc index 5e39b3c2..e539520c 100644 --- a/plugins/Refworks.inc +++ b/plugins/Refworks.inc @@ -10,7 +10,8 @@ module_load_include('inc', 'fedora_repository', 'SecurityClass'); /** - * Refworks class ??? + * Refworks class + * @deprecated */ class Refworks { diff --git a/plugins/ShowDemoStreamsInFieldSets.inc b/plugins/ShowDemoStreamsInFieldSets.inc index 80f8017c..05c2dbd8 100644 --- a/plugins/ShowDemoStreamsInFieldSets.inc +++ b/plugins/ShowDemoStreamsInFieldSets.inc @@ -8,7 +8,8 @@ */ /** - * Show Demo Streams in Field Sets ??? + * Show Demo Streams in Field Sets + * @deprecated */ class ShowDemoStreamsInFieldSets { diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index a6e7eaad..3fc116d2 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -8,7 +8,8 @@ */ /** - * Show Streams In Field Sets ?? + * Show Streams In Field Sets + * @deprecated */ class ShowStreamsInFieldSets { diff --git a/plugins/herbarium.inc b/plugins/herbarium.inc index f7a6d685..fa2ac4a7 100644 --- a/plugins/herbarium.inc +++ b/plugins/herbarium.inc @@ -1,20 +1,20 @@ <?php -/** - * @file - * - */ - /** * @file * Herbarium class */ /** - * Herbarium ??? + * Herbarium Class + * @deprecated */ class Herbarium { + /** + * Constructor + * @param type $pid + */ function __construct($pid = '') { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); if (!empty($pid)) { diff --git a/plugins/map_viewer.inc b/plugins/map_viewer.inc index f3bfca80..7b9cdf1d 100644 --- a/plugins/map_viewer.inc +++ b/plugins/map_viewer.inc @@ -1,14 +1,13 @@ <?php - - /** * @file * ShowMapStreamsInFieldSets class */ /** - * Show Map Streams in Field Sets Class ?? + * Show Map Streams in Field Sets Class + * @deprecated */ class ShowMapStreamsInFieldSets { diff --git a/plugins/qt_viewer.inc b/plugins/qt_viewer.inc index e52e4363..46984cf2 100644 --- a/plugins/qt_viewer.inc +++ b/plugins/qt_viewer.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * ShowQTStreamsInFieldSets class @@ -9,6 +7,7 @@ /** * Show QT Stream in Field Sets + * @deprecated */ class ShowQtStreamsInFieldSets { diff --git a/plugins/slide_viewer.inc b/plugins/slide_viewer.inc index 45ff3f9d..b7c3cf41 100644 --- a/plugins/slide_viewer.inc +++ b/plugins/slide_viewer.inc @@ -1,14 +1,13 @@ <?php - - /** * @file * ShowSlideStreamsInFieldSets class */ /** - * ShowSlideStreamInFieldSets ?????? + * ShowSlideStreamInFieldSets + * @deprecated */ class ShowSlideStreamsInFieldSets { diff --git a/plugins/tagging_form.inc b/plugins/tagging_form.inc index 390bf36c..d3931957 100644 --- a/plugins/tagging_form.inc +++ b/plugins/tagging_form.inc @@ -1,7 +1,5 @@ <?php - - /** * @file * Tagging Form??? @@ -11,6 +9,7 @@ * Show subject tags ??? * @param type $pid * @return string + * @deprecated */ function _show_subject_tags($pid) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); @@ -34,6 +33,7 @@ function _show_subject_tags($pid) { * @param type $form_state * @param type $pid * @return type + * @deprecated */ function fedora_repository_image_tagging_form($form_state, $pid) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); @@ -105,6 +105,7 @@ function fedora_repository_image_tagging_form($form_state, $pid) { * Hook image button process ??? * @param type $form * @return string + * @deprecated */ function hook_imagebutton_process($form) { $form['op_x'] = array( @@ -121,6 +122,7 @@ function hook_imagebutton_process($form) { * @global type $user * @param type $form * @param type $form_state + * @deprecated */ function fedora_repository_image_tagging_form_submit($form, &$form_state) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); From 4bca2e80afa15eaec7805611218d968c72e6b307 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Wed, 19 Oct 2011 09:58:39 -0300 Subject: [PATCH 29/46] Moved the collection policy file --- collection_policy.xsd => xsd/collection_policy.xsd | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename collection_policy.xsd => xsd/collection_policy.xsd (100%) diff --git a/collection_policy.xsd b/xsd/collection_policy.xsd similarity index 100% rename from collection_policy.xsd rename to xsd/collection_policy.xsd From d037ce4edf5597951bfa7d5c6c14765b69de2c91 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Wed, 19 Oct 2011 10:07:47 -0300 Subject: [PATCH 30/46] Revert "Moved the collection policy file" This reverts commit 4bca2e80afa15eaec7805611218d968c72e6b307. --- xsd/collection_policy.xsd => collection_policy.xsd | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename xsd/collection_policy.xsd => collection_policy.xsd (100%) diff --git a/xsd/collection_policy.xsd b/collection_policy.xsd similarity index 100% rename from xsd/collection_policy.xsd rename to collection_policy.xsd From e1ebfb8f32a7389c2fab76d03b27fcb77cb3865e Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Wed, 19 Oct 2011 10:07:56 -0300 Subject: [PATCH 31/46] Revert "Marked everything in plugins as deprecated" This reverts commit bddfd81fc8c1082e0bf76b789727790a7dde92d8. --- plugins/CollectionFormBuilder.inc | 4 +++- plugins/CreateCollection.inc | 1 - plugins/DarwinCore.inc | 9 +++++++-- plugins/DemoFormBuilder.inc | 4 +++- plugins/DocumentConverter.inc | 2 +- plugins/Exiftool.inc | 3 ++- plugins/FedoraObjectDetailedContent.inc | 3 ++- plugins/Ffmpeg.inc | 3 ++- plugins/Flv.inc | 3 ++- plugins/FlvFormBuilder.inc | 4 +++- plugins/FormBuilder.inc | 3 ++- plugins/ImageManipulation.inc | 3 ++- plugins/ModsFormBuilder.inc | 5 +++-- plugins/PersonalCollectionClass.inc | 3 ++- plugins/QtFormBuilder.php | 3 ++- plugins/Refworks.inc | 3 +-- plugins/ShowDemoStreamsInFieldSets.inc | 3 +-- plugins/ShowStreamsInFieldSets.inc | 3 +-- {api => plugins}/fedora_imageapi.info | 0 {api => plugins}/fedora_imageapi.module | 6 ++---- plugins/herbarium.inc | 12 ++++++------ plugins/map_viewer.inc | 5 +++-- plugins/qt_viewer.inc | 3 ++- plugins/slide_viewer.inc | 5 +++-- plugins/tagging_form.inc | 6 ++---- 25 files changed, 57 insertions(+), 42 deletions(-) rename {api => plugins}/fedora_imageapi.info (100%) rename {api => plugins}/fedora_imageapi.module (98%) diff --git a/plugins/CollectionFormBuilder.inc b/plugins/CollectionFormBuilder.inc index 83624d38..93e11479 100644 --- a/plugins/CollectionFormBuilder.inc +++ b/plugins/CollectionFormBuilder.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * Collection Form Builder @@ -10,8 +12,8 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml * builds a dc metadata form - * @deprecated */ + class CollectionFormBuilder extends FormBuilder { /** diff --git a/plugins/CreateCollection.inc b/plugins/CreateCollection.inc index c29eb657..c02ac2b7 100644 --- a/plugins/CreateCollection.inc +++ b/plugins/CreateCollection.inc @@ -9,7 +9,6 @@ /** * This Class implements the methods defined in the STANDARD_IMAGE content model - * @deprecated */ class CreateCollection { diff --git a/plugins/DarwinCore.inc b/plugins/DarwinCore.inc index dc698521..2d66d60a 100644 --- a/plugins/DarwinCore.inc +++ b/plugins/DarwinCore.inc @@ -1,13 +1,18 @@ <?php +/* @file + + + +*/ + /** * @file * Darwin Core class */ /** - * Darwin Core - * @deprecated + * Darwin Core ??? */ class DarwinCore { diff --git a/plugins/DemoFormBuilder.inc b/plugins/DemoFormBuilder.inc index 305c2029..05a9304f 100644 --- a/plugins/DemoFormBuilder.inc +++ b/plugins/DemoFormBuilder.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * @@ -9,8 +11,8 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml * builds a dc metadata form - * @deprecated */ + class DemoFormBuilder extends FormBuilder { /** diff --git a/plugins/DocumentConverter.inc b/plugins/DocumentConverter.inc index ce782f08..f258441a 100644 --- a/plugins/DocumentConverter.inc +++ b/plugins/DocumentConverter.inc @@ -1,5 +1,6 @@ <?php + /** * @file * Document Converter Class @@ -8,7 +9,6 @@ /** * This class implements document (doc, odt, pdf, etc.) conversion for a generic * multi-format document collection. - * @deprecated */ class DocumentConverter { diff --git a/plugins/Exiftool.inc b/plugins/Exiftool.inc index 002c6b0c..d8fd5e90 100644 --- a/plugins/Exiftool.inc +++ b/plugins/Exiftool.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * Exiftool @@ -7,7 +9,6 @@ /** * This Class implements the methods defined in the STANDARD_IMAGE content model - * @deprecated */ class Exiftool { diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc index ea70642b..4f3d9a74 100644 --- a/plugins/FedoraObjectDetailedContent.inc +++ b/plugins/FedoraObjectDetailedContent.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * FedoraObjectDetailedContent class @@ -9,7 +11,6 @@ * Fedora Object. This class is a plugin called from content models to display a detailed list of * content of the Fedora Item. This is hard coded into Islandora core, and it can also be called * from the IslandoraCM stream. - * @deprecated */ class FedoraObjectDetailedContent { diff --git a/plugins/Ffmpeg.inc b/plugins/Ffmpeg.inc index 7c2159ed..46b4ae80 100644 --- a/plugins/Ffmpeg.inc +++ b/plugins/Ffmpeg.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * Ffmpeg wrapper class @@ -9,7 +11,6 @@ * FFMpeg wrapper class for generating movie thumbnails * * This Class implements the methods defined in the STANDARD_QT content model - * @deprecated */ class Ffmpeg { diff --git a/plugins/Flv.inc b/plugins/Flv.inc index 76506ce3..b5f159b2 100644 --- a/plugins/Flv.inc +++ b/plugins/Flv.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * Form Builder class @@ -7,7 +9,6 @@ /** * implements method from content model ingest form xml - * @deprecated */ class FormBuilder { diff --git a/plugins/FlvFormBuilder.inc b/plugins/FlvFormBuilder.inc index 5e022b88..8c2b5777 100644 --- a/plugins/FlvFormBuilder.inc +++ b/plugins/FlvFormBuilder.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * FLVFormBuilder @@ -9,8 +11,8 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * implements methods from content model ingest form xml * builds a dc metadata form - * @deprecated */ + class FlvFormBuilder extends FormBuilder { /** diff --git a/plugins/FormBuilder.inc b/plugins/FormBuilder.inc index 02ca6ace..cd9dc4a9 100644 --- a/plugins/FormBuilder.inc +++ b/plugins/FormBuilder.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * FormBuilder class @@ -8,7 +10,6 @@ /** * implements methods from content model ingest form xml * builds a dc metadata form - * @deprecated */ class FormBuilder { diff --git a/plugins/ImageManipulation.inc b/plugins/ImageManipulation.inc index bbbe84fd..4faabdd8 100644 --- a/plugins/ImageManipulation.inc +++ b/plugins/ImageManipulation.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * Image Manipulation class @@ -7,7 +9,6 @@ /** * This Class implements the methods defined in the STANDARD_IMAGE content model - * @deprecated */ class ImageManipulation { diff --git a/plugins/ModsFormBuilder.inc b/plugins/ModsFormBuilder.inc index c7eefdb6..aa0f6f92 100644 --- a/plugins/ModsFormBuilder.inc +++ b/plugins/ModsFormBuilder.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * ModsFormBuilder class @@ -7,8 +9,7 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** - * ModsFormBuilder class - * @deprecated + * ModsFormBuilder class ??? */ class ModsFormBuilder extends FormBuilder { diff --git a/plugins/PersonalCollectionClass.inc b/plugins/PersonalCollectionClass.inc index b81d75df..29c76cfa 100644 --- a/plugins/PersonalCollectionClass.inc +++ b/plugins/PersonalCollectionClass.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * PersonalCollectionClass class @@ -7,7 +9,6 @@ /** * Personal Collection Class - * @deprecated */ class PersonalCollectionClass { diff --git a/plugins/QtFormBuilder.php b/plugins/QtFormBuilder.php index 95b7699c..28645d6b 100644 --- a/plugins/QtFormBuilder.php +++ b/plugins/QtFormBuilder.php @@ -1,5 +1,7 @@ <?php +// $Id$ + /** * @file * QTFormBuilder class @@ -9,7 +11,6 @@ module_load_include('inc', 'fedora_repository', 'plugins/FormBuilder'); /** * Implements methods from content model ingest form xml * builds a dc metadata form - * @deprecated */ class QtFormBuilder extends FormBuilder { diff --git a/plugins/Refworks.inc b/plugins/Refworks.inc index e539520c..5e39b3c2 100644 --- a/plugins/Refworks.inc +++ b/plugins/Refworks.inc @@ -10,8 +10,7 @@ module_load_include('inc', 'fedora_repository', 'SecurityClass'); /** - * Refworks class - * @deprecated + * Refworks class ??? */ class Refworks { diff --git a/plugins/ShowDemoStreamsInFieldSets.inc b/plugins/ShowDemoStreamsInFieldSets.inc index 05c2dbd8..80f8017c 100644 --- a/plugins/ShowDemoStreamsInFieldSets.inc +++ b/plugins/ShowDemoStreamsInFieldSets.inc @@ -8,8 +8,7 @@ */ /** - * Show Demo Streams in Field Sets - * @deprecated + * Show Demo Streams in Field Sets ??? */ class ShowDemoStreamsInFieldSets { diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index 3fc116d2..a6e7eaad 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -8,8 +8,7 @@ */ /** - * Show Streams In Field Sets - * @deprecated + * Show Streams In Field Sets ?? */ class ShowStreamsInFieldSets { diff --git a/api/fedora_imageapi.info b/plugins/fedora_imageapi.info similarity index 100% rename from api/fedora_imageapi.info rename to plugins/fedora_imageapi.info diff --git a/api/fedora_imageapi.module b/plugins/fedora_imageapi.module similarity index 98% rename from api/fedora_imageapi.module rename to plugins/fedora_imageapi.module index 99c2cfd2..f3bd4481 100644 --- a/api/fedora_imageapi.module +++ b/plugins/fedora_imageapi.module @@ -1,9 +1,7 @@ <?php -/** - * fedora imageapi menu - * @return string - */ + + function fedora_imageapi_menu() { $items = array(); $items['fedora/imageapi'] = array( diff --git a/plugins/herbarium.inc b/plugins/herbarium.inc index fa2ac4a7..f7a6d685 100644 --- a/plugins/herbarium.inc +++ b/plugins/herbarium.inc @@ -1,20 +1,20 @@ <?php +/** + * @file + * + */ + /** * @file * Herbarium class */ /** - * Herbarium Class - * @deprecated + * Herbarium ??? */ class Herbarium { - /** - * Constructor - * @param type $pid - */ function __construct($pid = '') { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); if (!empty($pid)) { diff --git a/plugins/map_viewer.inc b/plugins/map_viewer.inc index 7b9cdf1d..f3bfca80 100644 --- a/plugins/map_viewer.inc +++ b/plugins/map_viewer.inc @@ -1,13 +1,14 @@ <?php + + /** * @file * ShowMapStreamsInFieldSets class */ /** - * Show Map Streams in Field Sets Class - * @deprecated + * Show Map Streams in Field Sets Class ?? */ class ShowMapStreamsInFieldSets { diff --git a/plugins/qt_viewer.inc b/plugins/qt_viewer.inc index 46984cf2..e52e4363 100644 --- a/plugins/qt_viewer.inc +++ b/plugins/qt_viewer.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * ShowQTStreamsInFieldSets class @@ -7,7 +9,6 @@ /** * Show QT Stream in Field Sets - * @deprecated */ class ShowQtStreamsInFieldSets { diff --git a/plugins/slide_viewer.inc b/plugins/slide_viewer.inc index b7c3cf41..45ff3f9d 100644 --- a/plugins/slide_viewer.inc +++ b/plugins/slide_viewer.inc @@ -1,13 +1,14 @@ <?php + + /** * @file * ShowSlideStreamsInFieldSets class */ /** - * ShowSlideStreamInFieldSets - * @deprecated + * ShowSlideStreamInFieldSets ?????? */ class ShowSlideStreamsInFieldSets { diff --git a/plugins/tagging_form.inc b/plugins/tagging_form.inc index d3931957..390bf36c 100644 --- a/plugins/tagging_form.inc +++ b/plugins/tagging_form.inc @@ -1,5 +1,7 @@ <?php + + /** * @file * Tagging Form??? @@ -9,7 +11,6 @@ * Show subject tags ??? * @param type $pid * @return string - * @deprecated */ function _show_subject_tags($pid) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); @@ -33,7 +34,6 @@ function _show_subject_tags($pid) { * @param type $form_state * @param type $pid * @return type - * @deprecated */ function fedora_repository_image_tagging_form($form_state, $pid) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); @@ -105,7 +105,6 @@ function fedora_repository_image_tagging_form($form_state, $pid) { * Hook image button process ??? * @param type $form * @return string - * @deprecated */ function hook_imagebutton_process($form) { $form['op_x'] = array( @@ -122,7 +121,6 @@ function hook_imagebutton_process($form) { * @global type $user * @param type $form * @param type $form_state - * @deprecated */ function fedora_repository_image_tagging_form_submit($form, &$form_state) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); From b79b82ab89097187dbc9b24bec4137e69dce9c9f Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Wed, 19 Oct 2011 10:08:02 -0300 Subject: [PATCH 32/46] Revert "Moved fixed a more appropriate place" This reverts commit ce0078d0eab8a0a4346e2086069093351d37a604. --- core/BatchIngest.inc => BatchIngest.inc | 0 core/CollectionClass.inc => CollectionClass.inc | 0 core/CollectionManagement.inc => CollectionManagement.inc | 0 core/CollectionPolicy.inc => CollectionPolicy.inc | 0 core/ConnectionHelper.inc => ConnectionHelper.inc | 0 core/ContentModel.inc => ContentModel.inc | 0 core/MimeClass.inc => MimeClass.inc | 0 core/ObjectHelper.inc => ObjectHelper.inc | 0 core/SearchClass.inc => SearchClass.inc | 0 core/SecurityClass.inc => SecurityClass.inc | 0 core/XMLDatastream.inc => XMLDatastream.inc | 0 ...itory.solutionpacks.inc => fedora_repository.solutionpacks.inc | 0 core/formClass.inc => formClass.inc | 0 xsd/islandoracm.xsd => islandoracm.xsd | 0 xsl/searchTerms.xml => searchTerms.xml | 0 xsl/solrSearchTerms.xml => solrSearchTerms.xml | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename core/BatchIngest.inc => BatchIngest.inc (100%) rename core/CollectionClass.inc => CollectionClass.inc (100%) rename core/CollectionManagement.inc => CollectionManagement.inc (100%) rename core/CollectionPolicy.inc => CollectionPolicy.inc (100%) rename core/ConnectionHelper.inc => ConnectionHelper.inc (100%) rename core/ContentModel.inc => ContentModel.inc (100%) rename core/MimeClass.inc => MimeClass.inc (100%) rename core/ObjectHelper.inc => ObjectHelper.inc (100%) rename core/SearchClass.inc => SearchClass.inc (100%) rename core/SecurityClass.inc => SecurityClass.inc (100%) rename core/XMLDatastream.inc => XMLDatastream.inc (100%) rename core/fedora_repository.solutionpacks.inc => fedora_repository.solutionpacks.inc (100%) rename core/formClass.inc => formClass.inc (100%) rename xsd/islandoracm.xsd => islandoracm.xsd (100%) rename xsl/searchTerms.xml => searchTerms.xml (100%) rename xsl/solrSearchTerms.xml => solrSearchTerms.xml (100%) diff --git a/core/BatchIngest.inc b/BatchIngest.inc similarity index 100% rename from core/BatchIngest.inc rename to BatchIngest.inc diff --git a/core/CollectionClass.inc b/CollectionClass.inc similarity index 100% rename from core/CollectionClass.inc rename to CollectionClass.inc diff --git a/core/CollectionManagement.inc b/CollectionManagement.inc similarity index 100% rename from core/CollectionManagement.inc rename to CollectionManagement.inc diff --git a/core/CollectionPolicy.inc b/CollectionPolicy.inc similarity index 100% rename from core/CollectionPolicy.inc rename to CollectionPolicy.inc diff --git a/core/ConnectionHelper.inc b/ConnectionHelper.inc similarity index 100% rename from core/ConnectionHelper.inc rename to ConnectionHelper.inc diff --git a/core/ContentModel.inc b/ContentModel.inc similarity index 100% rename from core/ContentModel.inc rename to ContentModel.inc diff --git a/core/MimeClass.inc b/MimeClass.inc similarity index 100% rename from core/MimeClass.inc rename to MimeClass.inc diff --git a/core/ObjectHelper.inc b/ObjectHelper.inc similarity index 100% rename from core/ObjectHelper.inc rename to ObjectHelper.inc diff --git a/core/SearchClass.inc b/SearchClass.inc similarity index 100% rename from core/SearchClass.inc rename to SearchClass.inc diff --git a/core/SecurityClass.inc b/SecurityClass.inc similarity index 100% rename from core/SecurityClass.inc rename to SecurityClass.inc diff --git a/core/XMLDatastream.inc b/XMLDatastream.inc similarity index 100% rename from core/XMLDatastream.inc rename to XMLDatastream.inc diff --git a/core/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc similarity index 100% rename from core/fedora_repository.solutionpacks.inc rename to fedora_repository.solutionpacks.inc diff --git a/core/formClass.inc b/formClass.inc similarity index 100% rename from core/formClass.inc rename to formClass.inc diff --git a/xsd/islandoracm.xsd b/islandoracm.xsd similarity index 100% rename from xsd/islandoracm.xsd rename to islandoracm.xsd diff --git a/xsl/searchTerms.xml b/searchTerms.xml similarity index 100% rename from xsl/searchTerms.xml rename to searchTerms.xml diff --git a/xsl/solrSearchTerms.xml b/solrSearchTerms.xml similarity index 100% rename from xsl/solrSearchTerms.xml rename to solrSearchTerms.xml From 5dbe901b7484dbbc09b1d0e7ebe8ffdc2b300aca Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Fri, 21 Oct 2011 12:25:12 -0300 Subject: [PATCH 33/46] Changed default file nameing --- BatchIngest.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BatchIngest.inc b/BatchIngest.inc index c78be313..77ab6bf7 100644 --- a/BatchIngest.inc +++ b/BatchIngest.inc @@ -125,7 +125,10 @@ function batch_creation_form_submit($form, &$form_state) { $base = preg_replace("/$ext$/", '', $file_name); $ext = substr($ext, 1); if ($ext) { - $file_list[$base][$ext] = "$directory/" . $file_name; + if ($directory[strlen($directory)-1] != '/'){ + $directory .= '/'; + } + $file_list[$base][$ext] = "$directory" . $file_name; } } } @@ -190,7 +193,6 @@ function create_batch_objects($label, $content_model, $object_files, $collection } unset($object_files['xml']); - $use_primary = TRUE; foreach ($object_files as $ext => $filename) { $file_mimetype = $mime_helper->get_mimetype($filename); if (in_array($file_mimetype, $allowed_mime_types)) { @@ -200,9 +202,7 @@ function create_batch_objects($label, $content_model, $object_files, $collection $item->purge("$pid $label not ingested. $file_mimetype not permitted in objects associated with $content_model"); continue; } - $ds_label = $use_primary ? $cm->getDatastreamNameDSID() : $ext; - $item->add_datastream_from_file($filename, $ds_label); - $use_primary = FALSE; + $item->add_datastream_from_file($filename, "Source_File"); if (!empty($_SESSION['fedora_ingest_files'])) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $datastream_file) { From 077223c985c1034f17c3179e1a74087d45d94df4 Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Tue, 25 Oct 2011 09:44:02 -0300 Subject: [PATCH 34/46] Moved Collection Manager to external module --- BatchIngest.inc | 264 -------------------------- CollectionClass.inc | 13 +- CollectionManagement.inc | 401 --------------------------------------- ObjectHelper.inc | 3 - fedora_repository.module | 11 +- xsl/convertQDC.xsl | 2 +- 6 files changed, 9 insertions(+), 685 deletions(-) delete mode 100644 BatchIngest.inc delete mode 100644 CollectionManagement.inc diff --git a/BatchIngest.inc b/BatchIngest.inc deleted file mode 100644 index 77ab6bf7..00000000 --- a/BatchIngest.inc +++ /dev/null @@ -1,264 +0,0 @@ -<?php - -/** - * batch creation form submit - * @global type $user - * @param array $form - * @param array $form_state - * @param array $content_models - */ -function batch_creation_form(&$form_state, $collection_pid, $content_models) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); - $cm_options = array(); - $name_mappings = array(); - foreach ($content_models as $content_model) { - if ($content_model->pid != "islandora:collectionCModel") { - $cm_options[$content_model->pid] = $content_model->name; - $name_mappings[] = $content_model->pid . '^' . $content_model->pid_namespace; - } - } - $mappings = implode('~~~', $name_mappings); - $form['#attributes']['enctype'] = 'multipart/form-data'; - - $form['titlebox'] = array( - '#type' => 'item', - '#value' => t("Batch ingest into $collection_pid"), - ); - - $form['collection_pid'] = array( - '#type' => 'hidden', - '#value' => $collection_pid, - ); - $form['namespace_mappings'] = array( - '#type' => 'hidden', - '#value' => $mappings, - ); - $form['content_model'] = array( - '#title' => "Choose content model to be associated with objects ingested", - '#type' => 'select', - '#options' => $cm_options, - '#required' => TRUE, - '#description' => t("Content models describe the behaviours of objects with which they are associated."), - ); - $form['indicator']['file-location'] = array( - '#type' => 'file', - '#title' => t('Upload zipped folder'), - '#size' => 48, - '#description' => t('The zipped folder should contain all files necessary to build objects.<br .> - Related files must have the same filename, but with differing extensions to indicate mimetypes.<br /> - ie. <em>myFile.xml</em> and <em>myFile.jpg</em>'), - ); - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Create Objects ') - ); - - - return($form); -} - -/** - * @param array $form - * @param array $form_state - */ -function batch_creation_form_validate($form, &$form_state) { - - $field_name = 'file-location'; - if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name'][$field_name])) { - $file = file_save_upload($field_name); - if ($file->filemime != 'application/zip') { - form_set_error($field_name, 'Input file must be a .zip file'); - return; - } - if (!$file) { - form_set_error($field_name, 'Error uploading file.'); - return; - } - $form_state['values']['file'] = $file; - } - else { - // set error - form_set_error($field_name, 'Error uploading file.'); - return; - } -} - -function batch_creation_form_submit($form, &$form_state) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - global $user; - $namespace_mappings = array(); - $content_model = $form_state['values']['content_model']; - $metadata = $form_state['values']['metadata_type']; - $collection_pid = $form_state['values']['collection_pid']; - $namespace_process = explode('~~~', $form_state['values']['namespace_mappings']); - foreach ($namespace_process as $line) { - $line_parts = explode('^', $line); - $namespace_mappings[$line_parts[0]] = $line_parts[1]; - } - $namespace = $namespace_mappings[$content_model]; - $namespace = preg_replace('/:.*/', '', $namespace); - $dir_name = "temp" . $user->uid; - $tmp_dir = file_directory_path() . '/' . $dir_name . '/'; - mkdir($tmp_dir); - $file = $form_state['values']['file']; - $fileName = $file->filepath; - $file_list = array(); - $cmdString = "unzip -q -o -d $tmp_dir \"$fileName\""; - system($cmdString, $retVal); - $dirs = array(); - $do_not_add = array('.', '..', '__MACOSX'); - array_push($dirs, $tmp_dir); - $files = scandir($tmp_dir); - foreach ($files as $file) { - if (is_dir("$tmp_dir/$file") & !in_array($file, $do_not_add)) { - array_push($dirs, $tmp_dir . $file); - } - } - foreach ($dirs as $directory) { - if ($inputs = opendir($directory)) { - while (FALSE !== ($file_name = readdir($inputs))) { - if (!in_array($file_name, $do_not_add) && is_dir($file_name) == FALSE) { - $ext = strrchr($file_name, '.'); - $base = preg_replace("/$ext$/", '', $file_name); - $ext = substr($ext, 1); - if ($ext) { - if ($directory[strlen($directory)-1] != '/'){ - $directory .= '/'; - } - $file_list[$base][$ext] = "$directory" . $file_name; - } - } - } - closedir($inputs); - } - } - - if (($cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM')) === FALSE) { - drupal_set_message("$content_model not found", "error"); - return; - } - - $batch = array( - 'title' => 'Ingesting Objects', - 'operations' => array(), - 'file' => drupal_get_path('module', 'fedora_repository') . '/BatchIngest.inc', - ); - - - foreach ($file_list as $label => $object_files) { - $batch['operations'][] = array('create_batch_objects', array($label, $content_model, $object_files, $collection_pid, $namespace, $metadata)); - } - $batch['operations'][] = array('recursive_directory_delete', array($tmp_dir)); - batch_set($batch); - batch_process(); -} - -/** - * - * @param <string> $label - * @param <string> $content_model - * @param <array> $object_files - * @param <string> $collection_pid - * @param <string> $namespace - * @param <string> $metadata - */ -function create_batch_objects($label, $content_model, $object_files, $collection_pid, $namespace, $metadata) { - module_load_include('inc', 'fedora_repository', 'ContentModel'); - module_load_include('inc', 'fedora_repository', 'MimeClass'); - module_load_include('inc', 'fedora_reppository', 'api/fedora_item'); - - $cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM'); - $allowed_mime_types = $cm->getMimetypes(); - $mime_helper = new MimeClass(); - $pid = fedora_item::get_next_PID_in_namespace($namespace); - - $item = Fedora_item::ingest_new_item($pid, 'A', $label, $owner); - $item->add_relationship('hasModel', $content_model, FEDORA_MODEL_URI); - $item->add_relationship('isMemberOfCollection', $collection_pid); - if ($object_files['xml']) { - $data = file_get_contents($object_files['xml']); - $xml = simplexml_load_string($data); - $identifier = $xml->getName(); - if ($identifier == 'dc') { - $item->modify_datastream_by_value($data, 'DC', "Dublin Core", 'text/xml'); - } - if ($identifier == 'mods') { - $item->add_datastream_from_string($mods_xml, 'MODS'); - $dc_xml = batch_create_dc_from_mods($mods_xml); - $item->modify_datastream_by_value($dc_xml, 'DC', "Dublin Core", 'text/xml'); - } - } - - unset($object_files['xml']); - foreach ($object_files as $ext => $filename) { - $file_mimetype = $mime_helper->get_mimetype($filename); - if (in_array($file_mimetype, $allowed_mime_types)) { - $added = $cm->execIngestRules($filename, $file_mimetype); - } - else { - $item->purge("$pid $label not ingested. $file_mimetype not permitted in objects associated with $content_model"); - continue; - } - $item->add_datastream_from_file($filename, "Source_File"); - - if (!empty($_SESSION['fedora_ingest_files'])) { - foreach ($_SESSION['fedora_ingest_files'] as $dsid => $datastream_file) { - $item->add_datastream_from_file($datastream_file, $dsid); - } - } - } -} - -/** - * transforms mods to dc - * @param <string> $mods_xml - * @return <string> - */ -function batch_create_dc_from_mods($mods_xml) { - $path = drupal_get_path('module', 'fedora_repository'); - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - - if ($xmlstr == NULL || strlen($xmlstr) < 5) { - return " "; - } - - try { - $proc = new XsltProcessor(); - } catch (Exception $e) { - drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); - return " "; - } - - $xsl = new DomDocument(); - $xsl->load($path . '/xsl/mods_to_dc.xsl'); - $input = new DomDocument(); - $input->loadXML(trim($xmlstr)); - $xsl = $proc->importStylesheet($xsl); - $newdom = $proc->transformToDoc($input); - $dc_xml = $newdom->saveXML(); - - return $dc_xml; -} - -/** - * - * @param <string> $dir - * @return <boolean> - */ -function recursive_directory_delete($dir) { - if (!file_exists($dir)) - return TRUE; - if (!is_dir($dir)) - return unlink($dir); - foreach (scandir($dir) as $item) { - if ($item == '.' || $item == '..') - continue; - if (!recursive_directory_delete($dir . DIRECTORY_SEPARATOR . $item)) - return FALSE; - } - return rmdir($dir); -} \ No newline at end of file diff --git a/CollectionClass.inc b/CollectionClass.inc index 82e4739e..2af37522 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -517,7 +517,7 @@ class CollectionClass { $show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form'); $add_to_collection = $this->getIngestInterface(); - $show_batch_tab = TRUE; + $show_batch_tab = FALSE; $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); $content_models = $policy->getContentModels(); if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { @@ -547,16 +547,7 @@ class CollectionClass { // This will be the content of the tab. '#content' => $add_to_collection, ); - if (user_access('manage collections')) { - $tabset['add_collection_tab'] = array( - // #type and #title are the minimum requirements. - '#type' => 'tabpage', - '#title' => t('Manage This Collection'), - // This will be the content of the tab. - '#content' => drupal_get_form('collection_management_form', $this->pid, $content_models), - '#selected' => FALSE, - ); - } + if ($show_batch_tab && user_access('create batch process')) { $tabset['batch_ingest_tab'] = array( // #type and #title are the minimum requirements. diff --git a/CollectionManagement.inc b/CollectionManagement.inc deleted file mode 100644 index 39d33456..00000000 --- a/CollectionManagement.inc +++ /dev/null @@ -1,401 +0,0 @@ -<?php - -/** - * collection creation form - * @param array $form_state - * @param string $parent_collection_pid - * @param string $content_models - * @return array - */ -function collection_management_form(&$form_state, $this_collection_pid, $content_models) { - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - $restricted = FALSE; - if (variable_get('fedora_namespace_restriction_enforced', TRUE)) { - $restricted = TRUE; - $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); - $namespaces = explode(':', $allowed_string); - foreach ($namespaces as $namespace) { - if ($namespace) { - $allowed[trim($namespace)] = trim($namespace); - } - } - } - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); - $item = new Fedora_Item($this_collection_pid); - $collection_name = $item->objectProfile->objLabel; - $new_content_models = get_content_models_as_option_array(); - $cm_options = array(); - $name_mappings = array(); - foreach ($content_models as $content_model) { - if ($content_model->pid != "islandora:collectionCModel") { - $item = new fedora_item($content_model->pid); - $cm_name = $item->objectProfile->objLabel; - $cm_options[$content_model->pid] = $cm_name; - } - } - if (!empty($cm_options)) { - $show_delete = TRUE; - } - - - $content_models = get_content_models_as_option_array(); - $form['child_creation'] = array( - '#title' => "Create Child Collection", - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - - $form['child_creation']['titlebox'] = array( - '#type' => 'item', - '#value' => t("Create New Child Collection within $this_collection_pid"), - ); - - $form['child_creation']['collection_name'] = array( - '#title' => "Collection Name", - '#type' => 'textfield', - '#description' => t("Human readable name for this collection"), - ); - - $form['child_creation']['new_collection_pid'] = array( - '#title' => "Collection PID", - '#type' => 'textfield', - '#size' => 15, - '#description' => t("Unique PID for this collection. <br />Pids take the general form of namespace:collection eg islandora:pamphlets"), - ); - if (!$restricted) { - $form['child_creation']['collection_namespace'] = array( - '#title' => "Collection Namespace", - '#type' => 'textfield', - '#size' => 15, - '#default_value' => 'default', - '#description' => t("Namespace for objects in this collection."), - ); - } - else { - $form['child_creation']['collection_namespace'] = array( - '#title' => "Collection Namespace", - '#type' => 'select', - '#options' => $allowed, - '#default_value' => 'default', - '#description' => t("Namespace for objects in this collection."), - ); - } - $form['parent_collection'] = array( - '#type' => 'hidden', - '#value' => $this_collection_pid, - ); - - $form['collection_pid'] = array( - '#type' => 'hidden', - '#value' => $this_collection_pid, - ); - $form['child_creation']['content_models'] = array( - '#title' => "Choose allowable content models for this collection", - '#type' => 'checkboxes', - '#options' => $content_models, - '#description' => t("Content models describe the behaviours of objects with which they are associated."), - ); - - - $form['child_creation']['submit'] = array( - '#type' => 'submit', - '#value' => t('Create Collection'), - '#id' => 'create_class' - ); - $form['manage_collection_policy'] = array( - '#title' => "Manage Collection Policies", - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - - $form['manage_collection_policy']['add'] = array( - '#title' => "Add Content Model", - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => $show_delete, - ); - - - $form ['manage_collection_policy']['add']['content_model_to_add'] = array( - '#title' => "Choose Content Model", - '#type' => 'select', - '#options' => array_diff_key($content_models, $cm_options), - '#description' => t("Choose content model to add to this collection policy."), - ); - - $form ['manage_collection_policy']['add']['new_cp_namespace'] = array( - '#title' => "Choose Namespace", - '#type' => 'textfield', - '#size' => 15, - '#description' => t("Choose namespace for objects in this collection associated with this content model"), - ); - $form['manage_collection_policy']['add']['submit'] = array( - '#type' => 'submit', - '#value' => t('Add Content Model to Collection Policy'), - '#id' => 'add_cm' - ); - - if ($show_delete) { - $form['manage_collection_policy']['remove'] = array( - '#title' => "Delete Content Model", - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - - $form ['manage_collection_policy']['remove']['content_models_to_remove'] = array( - '#title' => "Choose Content Model to Remove", - '#type' => 'checkboxes', - '#options' => $cm_options, - '#description' => t("Choose content models to remove from this collection policy."), - ); - - - $form['manage_collection_policy']['remove']['submit'] = array( - '#type' => 'submit', - '#value' => t('Remove Content Collection Policy'), - '#id' => 'remove_cm' - ); - } - $form['change_cmodel'] = array( - '#title' => "Change Content Models", - '#type' => 'fieldset', - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['change_cmodel']['titlebox'] = array( - '#type' => 'item', - '#value' => t("Change Content Models within $this_collection_pid"), - ); - - $form['change_cmodel']['current_content_model'] = array( - '#title' => "Choose content model to be changed", - '#type' => 'select', - '#options' => $cm_options, - '#description' => t("All objects in this collection with the selected content model will be changed."), - ); - $form['change_cmodel']['new_content_model'] = array( - '#title' => "Choose new content model", - '#type' => 'select', - '#options' => $new_content_models, - '#description' => t("The new content model to be assigned to selected objects."), - ); - $form['change_cmodel']['collection_pid'] = array( - '#type' => 'hidden', - '#value' => $this_collection_pid, - ); - $form['change_cmodel']['submit'] = array( - '#type' => 'submit', - '#value' => t('Change Content Model Associations'), - '#id' => 'change_model', - ); - if (user_access('delete entire collections')) { - $form['delete_collection'] = array( - '#title' => "Permanently Delete $collection_name", - '#type' => 'fieldset', - '#description' => t("Clicking this button will delete all objects within $collection_name. <br /> <strong>This action cannot be undone.</strong>"), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['delete_collection']['confirm'] = array( - '#title' => "Are you sure?", - '#type' => 'fieldset', - '#description' => t('<strong>Clicking the delete button will permanantly remove all objects from this collection. <br /> <strong>This action cannot be undone.</strong> '), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - - $form['delete_collection']['confirm']['submit'] = array( - '#type' => 'submit', - '#value' => t('Delete this collection'), - '#id' => 'delete_collection', - ); - } - return($form); -} - -/** - * collection creation form validate - * @param array $form - * @param array $form_state - */ -function collection_management_form_validate($form, &$form_state) { - if ($form_state['clicked_button']['#id'] == 'create_class') { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - $pid = $form_state['values']['new_collection_pid']; - $item = new fedora_item($pid); - if ($item->exists()) { - form_set_error('new_collection_pid', t("$pid already exists within your repository. the PID must be unique")); - return; - } - if (!valid_pid($pid)) { - form_set_error('new_collection_pid', t("$pid is not a valid identifier")); - return; - } - } - if ($form_state['clicked_button']['#id'] == 'add_cm') { - if (!valid_pid($form_state['values']['new_cp_namespace'])) { - form_set_error('new_cp_namespace', t("Namespace must be a valid PID")); - return; - } - } -} - -/** - * collection creation form submit - * @global type $user - * @param type $form - * @param type $form_state - */ -function collection_management_form_submit($form, &$form_state) { - module_load_include('inc', 'fedora_repository', 'api/fedora_collection'); - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/dublin_core'); - global $user; - $collection_pid = $form_state['values']['parent_collection']; - $policy = CollectionPolicy::loadFromCollection($collection_pid, TRUE); - if ($form_state['clicked_button']['#id'] == 'create_class') { - $module_path = drupal_get_path('module', 'fedora_repository'); - $thumbnail = drupal_get_path('module', 'Fedora_Repository') . '/images/Crystal_Clear_filesystem_folder_grey.png'; - $new_collection_pid = $form_state['values']['new_collection_pid']; - $new_collection_label = $form_state['values']['collection_name']; - $pid_namespace = $form_state['values']['collection_namespace']; - $all_cModels = get_content_models_as_option_array(); - $collection_policy = '<?xml version="1.0" encoding="UTF-8"?> -<collection_policy xmlns="http://www.islandora.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="" xsi:schemaLocation="http://www.islandora.ca http://syn.lib.umanitoba.ca/collection_policy.xsd"> - <content_models> - </content_models> - <search_terms> - </search_terms> - <staging_area></staging_area> - <relationship>isMemberOfCollection</relationship> -</collection_policy>'; - $content_models = $form_state['values']['content_models']; - $collection_policy_xml = simplexml_load_string($collection_policy); - foreach ($content_models as $content_model) { - if ($content_model) { - $node = $collection_policy_xml->content_models->addChild('content_model'); - $node->addAttribute('dsid', 'ISLANDORACM'); - $node->addAttribute('name', $all_cModels[$content_model]); - $node->addAttribute('namespace', $pid_namespace . ':1'); - $node->addAttribute('pid', $content_model); - } - } - $item = fedora_item::ingest_new_item($new_collection_pid, 'A', $new_collection_label, $user->name); - $item->add_relationship('isMemberOfCollection', $collection_pid, RELS_EXT_URI); - $item->add_relationship('hasModel', 'islandora:collectionCModel', FEDORA_MODEL_URI); - $item->add_datastream_from_string($collection_policy_xml->saveXML(), 'COLLECTION_POLICY'); - $item->add_datastream_from_file($thumbnail, 'TN'); - drupal_goto("/fedora/repository/$new_collection_pid"); - } - - if ($form_state['clicked_button']['#id'] == 'add_cm') { - - $cp_namespace = $form_state['values']['new_cp_namespace']; - $cp_content_model = $form_state['values']['content_model_to_add']; - $policy->addModel(ContentModel::loadFromModel($cp_content_model), $cp_namespace); - $policy->saveToFedora(); - drupal_set_message("Collection model successfully added"); - } - - if ($form_state['clicked_button']['#id'] == 'remove_cm') { - $candidates = $form_state['values']['content_models_to_remove']; - $count = 0; - foreach ($candidates as $candidate) { - if (is_string($candidate)) { - $policy->removeModel(ContentModel::loadFromModel($candidate)); - $count++; - } - } - if ($count > 0) { - $policy->saveToFedora(); - if ($count > 1) { - $s = 's'; - } - drupal_set_message("$count collection model$s removed"); - } - } - - if ($form_state['clicked_button']['#id'] == 'change_model') { - $current_content_model = $form_state['values']['current_content_model']; - $new_content_model = $form_state['values']['new_content_model']; - - $add_to_policy = TRUE; - $policy_cms = $policy->getContentModels(); - foreach ($policy_cms as $policy_cm) { - if ($policy_cm->pid == $current_content_model) { - $namespace = $policy_cm->pid_namespace; - } - if ($policy_cm->pid == $new_content_model) { - $add_to_policy = FALSE; - } - } - if ($add_to_policy) { - $policy->addModel(ContentModel::loadFromModel($new_content_model), $namespace); - $policy->saveToFedora(); - } - $query = "select \$object from <#ri> - where (\$object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/$current_content_model> - and \$object <info:fedora/fedora-system:def/relations-external#isMemberOfCollection> <info:fedora/$collection_pid> - and \$object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)"; - $query = htmlentities(urlencode($query)); - $content = ''; - - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); - $url .= "?type=tuples&flush=TRUE&format=csv&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query; - $content .= do_curl($url); - $results = explode("\n", $content); - $object_pids = preg_replace('/^info:fedora\/|"object"/', '', $results); - $count = 0; - foreach ($object_pids as $object_pid) { - if (!$object_pid) { - continue; - } - $item = new fedora_item($object_pid); - $item->purge_relationship('hasModel', $current_content_model); - $item->add_relationship('hasModel', $new_content_model, FEDORA_MODEL_URI); - $count++; - } - drupal_set_message("$current_content_model changed to $new_content_model on $count objects"); - } - - if ($form_state['clicked_button']['#id'] == 'delete_collection') { - $collection_name = $form_state['values']['collection_name']; - $pids = get_related_items_as_array($collection_pid, 'isMemberOfCollection'); - - $batch = array( - 'title' => "Deleting Objects from $name", - 'operations' => array(), - 'file' => drupal_get_path('module', 'fedora_repository') . '/CollectionManagement.inc', - ); - - - foreach ($pids as $pid) { - - $batch['operations'][] = array('delete_objects_as_batch', array($pid)); - } - - batch_set($batch); - batch_process('/fedora/repository'); - } -} - -/** - * deletes PID if pid is not collection - * @param <type> $pid - */ -function delete_objects_as_batch($pid) { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - $name = $user->name; - $item_to_delete = new Fedora_Item($pid); - $models = $item_to_delete->get_models(); - foreach ($models as $model) { - if ($model['object'] != 'islandora:collectionCModel') { - $item_to_delete->purge("$object purged by $name"); - } - } -} \ No newline at end of file diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 70f73d4b..8321c0ea 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -19,9 +19,6 @@ class ObjectHelper { public static $INGEST_FEDORA_OBJECTS = 'ingest new fedora objects'; public static $EDIT_TAGS_DATASTREAM = 'edit tags datastream'; public static $VIEW_DETAILED_CONTENT_LIST = 'view detailed list of content'; - public static $MANAGE_COLLECTIONS = 'manage collections'; - public static $DELETE_ENTIRE_COLLECTIONS = 'delete entire collections'; - public static $CREATE_BATCH_PROCESS = 'create batch process'; public static $DISPLAY_ALWAYS = 0; public static $DISPLAY_NEVER = 1; public static $DISPLAY_NO_MODEL_OUTPUT = 2; diff --git a/fedora_repository.module b/fedora_repository.module index 56859edb..f0ca2eaf 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -55,8 +55,8 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) { return ''; } $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', array( - '%name' => $name, - '%pid' => $pid) + '%name' => $name, + '%pid' => $pid) ); $output .= drupal_get_form('fedora_repository_purge_object_form', $pid); @@ -435,7 +435,7 @@ function add_stream_form_validate($form, &$form_state) { return FALSE; } if (!(preg_match("/^[a-zA-Z]/", $dsid))) { - form_set_error('', t("Data stream ID (@dsid) has to start with a letter.", array( '@dsid' => check_plain($dsid)))); + form_set_error('', t("Data stream ID (@dsid) has to start with a letter.", array('@dsid' => check_plain($dsid)))); return FALSE; } if (strlen($dsLabel) > 64) { @@ -482,7 +482,7 @@ function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL) } $output = t('Are you sure you wish to purge this datastream %name<br />', array( - '%name' => $name) + '%name' => $name) ); $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); return $output; @@ -995,8 +995,9 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU } } } - $cmodels_tabs = array_merge($cmodels_tabs, $object_details); + $hook_tabs = module_invoke_all('islandora_tabs', $content_models, $pid); + $cmodels_tabs = array_merge($cmodels_tabs, $object_details, $hook_tabs); return tabs_render($cmodels_tabs); } diff --git a/xsl/convertQDC.xsl b/xsl/convertQDC.xsl index e7e0d627..c2bb50f0 100644 --- a/xsl/convertQDC.xsl +++ b/xsl/convertQDC.xsl @@ -21,7 +21,7 @@ <xsl:value-of select="substring-after(name(),':')"/> = <xsl:value-of select="text()"/> </div> </xsl:for-each> - </td><td><a href="{$baseUrl}/search/fedora_repository/dc.{$FIELD}:{$DATA}"><img title="Find Similar by {$FIELD}" src="{$PATH}/images/view.gif" alt="Find Similar by {$FIELD}" /></a></td></tr> + </td></tr> </xsl:if> </xsl:for-each> From b4737ed80260ba98098c1a03eb0c1e144ca9c17e Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Fri, 28 Oct 2011 16:26:15 -0300 Subject: [PATCH 35/46] Fixed problem with page redirects on Edit --- ObjectHelper.inc | 1 + api/fedora_utils.inc | 1 + fedora_repository.module | 4 ++-- plugins/FedoraObjectDetailedContent.inc | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 8321c0ea..9567fd70 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -546,6 +546,7 @@ class ObjectHelper { */ function get_content_models_list($pid, $include_fedora_system_content_models = FALSE) { module_load_include('inc', 'fedora_repository', 'CollectionClass'); + module_load_include('inc', 'fedora_repository', 'ContentModel'); $collectionHelper = new CollectionClass(); $pids = array(); $query = 'select $object from <#ri> diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index c154dbc4..9399356d 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -235,6 +235,7 @@ function fix_dsid($dsid) { */ function get_collections_as_option_array() { module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $query = 'select $object $title from <#ri> where ($object <dc:title> $title and $object <info:fedora/fedora-system:def/model#hasModel> <info:fedora/islandora:collectionCModel> diff --git a/fedora_repository.module b/fedora_repository.module index f0ca2eaf..27060dda 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -317,7 +317,7 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NUL if (!empty($collectionPid)) { $collectionPid = $_SESSION['fedora_collection']; } -//$form['#redirect'] = $referrer; +//$form['#rebuild'] = $false; return $form; } @@ -989,7 +989,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU $obj = new FedoraObjectDetailedContent($pid); $object_details = $obj->showFieldSets(); if ($object_details['fedora_object_details']['#selected'] == TRUE) { - foreach ($cmodels_tabs as $cmodel_tab) { + foreach ($cmodels_tabs as &$cmodel_tab) { if (is_array($cmodel_tab)) { $cmodel_tab['#selected'] = FALSE; } diff --git a/plugins/FedoraObjectDetailedContent.inc b/plugins/FedoraObjectDetailedContent.inc index 4f3d9a74..0eef0f75 100644 --- a/plugins/FedoraObjectDetailedContent.inc +++ b/plugins/FedoraObjectDetailedContent.inc @@ -39,11 +39,11 @@ class FedoraObjectDetailedContent { $show_purge_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_purge_object_form'); $show_edit_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_edit_qdc_form'); $purge_form = drupal_get_form('fedora_repository_purge_object_form', $this->pid, check_plain(substr(request_uri(), strlen(base_path())))); - + $details_selected = ($show_purge_tab ||$show_edit_tab); $tabset['fedora_object_details'] = array( '#type' => 'tabpage', '#title' => t('Object Details'), - '#selected' => $show_purge_tab, + '#selected' => $details_selected, ); $tabset['fedora_object_details']['tabset'] = array( '#type' => 'tabset', From d7de3a51bfe150cdbb13e7606b5330f8de98f078 Mon Sep 17 00:00:00 2001 From: ppound <paul.pound@gmail.com> Date: Mon, 31 Oct 2011 15:43:13 -0300 Subject: [PATCH 36/46] partial fix for ISLANDORA-403 --- CollectionClass.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CollectionClass.inc b/CollectionClass.inc index 82e4739e..87ab1d63 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -519,7 +519,9 @@ class CollectionClass { $show_batch_tab = TRUE; $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); - $content_models = $policy->getContentModels(); + if(!empty($policy)){ + $content_models = $policy->getContentModels(); + } if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { $show_batch_tab = FALSE; } From b195d45b1e8517d747c04a19284c1c8f8f0b34f0 Mon Sep 17 00:00:00 2001 From: jonathangreen <jonathan@discoverygarden.ca> Date: Tue, 8 Nov 2011 21:28:00 -0400 Subject: [PATCH 37/46] Cleanup some TRUE that should be true When you do a repository search in Fedora_Item the URL it creates requires that the boolean be true. This got changed to TRUE in the code cleanup. Changed this back. --- api/fedora_item.inc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/api/fedora_item.inc b/api/fedora_item.inc index 54a9158b..a79749a7 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -43,7 +43,7 @@ class Fedora_Item { } $raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => "")); - + if (!empty($raw_objprofile)) { $this->objectProfile = $raw_objprofile->objectProfile; $this->datastreams = $this->get_datastreams_list_as_array(); @@ -297,18 +297,17 @@ class Fedora_Item { $i++; $url = variable_get('fedora_base_url', 'http://localhost:8080/fedora'); if ($cursor == 0) { - $url .= "/objects?query=$field~$pattern&pid=TRUE&title=TRUE&resultFormat=xml&maxResults=$max_results"; + $url .= "/objects?query=$field~$pattern&pid=true&title=TRUE&resultFormat=xml&maxResults=$max_results"; } else { - $url .= "/objects?pid=TRUE&title=TRUEsessionToken=$session_token&resultFormat=xml&maxResults=$max_results"; + $url .= "/objects?pid=true&title=true&sessionToken=$session_token&resultFormat=xml&maxResults=$max_results"; } if (count($resultFields) > 0) { - $url .= '&' . join('=TRUE&', $resultFields) . '=TRUE'; + $url .= '&' . join('=true&', $resultFields) . '=true'; } $resultxml = do_curl($url); - libxml_use_internal_errors(TRUE); $resultelements = simplexml_load_string($resultxml); if ($resultelements === FALSE) { From 32efbf8ae4b09a3c43f85c7c03be85db02a7a822 Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Thu, 10 Nov 2011 15:47:20 -0400 Subject: [PATCH 38/46] Externalized tabbing --- fedora_repository.module | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fedora_repository.module b/fedora_repository.module index 27060dda..600e3bcb 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -142,6 +142,10 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label */ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { //only validate the form if the submit button was pressed (other buttons may be used for AHAH + if ($form_state['ahah_submission']) { + $form_state['submitted'] = false; + return; + } if ($form_state['storage']['xml']) { if (module_exists('islandora_content_model_forms')) { module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); @@ -197,7 +201,11 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { */ function fedora_repository_ingest_form_validate($form, &$form_state) { //only validate the form if the submit button was pressed (other buttons may be used for AHAH - if ($form_state['clicked_button']['#id'] == 'edit-submit') { + if ($form_state['ahah_submission']) { + $form_state['submitted'] = false; + return; + } + if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) { switch ($form_state['storage']['step']) { case 1: $form_state['storage']['step']++; @@ -828,9 +836,6 @@ function fedora_repository_perm() { OBJECTHELPER::$INGEST_FEDORA_OBJECTS, OBJECTHELPER::$EDIT_TAGS_DATASTREAM, OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, - OBJECTHELPER::$MANAGE_COLLECTIONS, - OBJECTHELPER::$DELETE_ENTIRE_COLLECTIONS, - OBJECTHELPER::$CREATE_BATCH_PROCESS, ); } From e44be2a48c4ae483ed2a951baaada01f1a0a07ae Mon Sep 17 00:00:00 2001 From: ajstanley <alanjarlathstanley@gmail.com> Date: Mon, 14 Nov 2011 14:37:27 -0400 Subject: [PATCH 39/46] Replaced fedora calls with regex to improve performance. --- api/fedora_utils.inc | 58 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/api/fedora_utils.inc b/api/fedora_utils.inc index 9399356d..89545191 100644 --- a/api/fedora_utils.inc +++ b/api/fedora_utils.inc @@ -266,41 +266,41 @@ function get_collections_as_option_array() { * @return array */ function get_content_models_as_option_array() { - module_load_include('inc', 'fedora_repository', 'api/fedora_item'); - module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); - $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); - $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); - $namespaces = explode(':', $allowed_string); - foreach ($namespaces as $namespace) { - if ($namespace) { - $allowed[] = trim($namespace); + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); + module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + $restricted = variable_get('fedora_namespace_restriction_enforced', TRUE); + $allowed_string = variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora:'); + $namespaces = explode(':', $allowed_string); + foreach ($namespaces as $namespace) { + if ($namespace) { + $allowed[] = trim($namespace); + } } - } - $query = 'select $object $title from <#ri> + $query = 'select $object $title from <#ri> where ($object <dc:title> $title and ($object <fedora-model:hasModel> <info:fedora/fedora-system:ContentModel-3.0> or $object <fedora-rels-ext:isMemberOfCollection> <info:fedora/islandora:ContentModelsCollection>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) order by $title'; - $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); - $url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; - $content = do_curl($url . htmlentities(urlencode($query))); - $list = explode("\n", $content); - array_shift($list); - $list = preg_replace('/info:fedora\//', '', $list); - foreach ($list as $item) { //removes blanks - if ($item) { - $parts = explode(',', $item); - $item = new fedora_item($parts[0]); - $nameparts = explode(':', $parts[0]); - if (!$restricted || in_array($nameparts[0], $allowed)) - $datastreams = array_keys($item->get_datastreams_list_as_array()); - if (in_array('ISLANDORACM', $datastreams)) { - $options[$parts[0]] = $parts[1] . ' ~ ' . $parts[0]; - } + $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); + $url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query="; + $content = do_curl($url . htmlentities(urlencode($query))); + $list = explode("\n", $content); + array_shift($list); + $list = preg_replace('/info:fedora\//', '', $list); + foreach ($list as $item) { //removes blanks + if ($item) { + $parts = explode(',', $item); + $nameparts = explode(':', $parts[0]); + if (!$restricted || in_array($nameparts[0], $allowed)) { + + if (!preg_match('/fedora-system/', $nameparts[0])) { + $options[$parts[0]] = $parts[1] . ' ~ ' . $parts[0]; + } + } + } } - } - return $options; -} + return $options; +} \ No newline at end of file From 4ef6faa2fb5a774bb29ef8cb1dc2e648a73ca626 Mon Sep 17 00:00:00 2001 From: discoverygnoye <gordie@discoverygarden.ca> Date: Tue, 15 Nov 2011 11:41:49 -0400 Subject: [PATCH 40/46] COLORADO-1628 Fix the breadcrumb path calculation to remove blanks The current breadcrumb calculation takes the first <dc:title> tag in the DC datastream. The sorting order of the <dc:title> tags (in the case of more than one tag) has empty tags appearing as the first items to be selected by the query. This fix alters the query to change the sort order to make empty tags the last items to be selected and thus, if a non-empty tag exists it will be selected as the name of the breadcrumb. There is also a problem with the breadcrumb query processing that will attempt to process failed queries. The test for failure was incorrect and allowed some failed queries to be treated as successes. This resulted in recursively calling the breadcrumb processing an additional 10 times and failing each time. This resulted in 10 '>' symbols instead of an error message. This fix tests for falure and puts up an error message in the breadcrumb trail. The breadcrumb calculation should be rewritten to be more robust. --- ObjectHelper.inc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 70f73d4b..d1e73b8c 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -937,18 +937,22 @@ class ObjectHelper { or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject) and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> - order by $title'; + order by $title desc'; $query_string = htmlentities(urlencode($query_string)); $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $url .= "?type=tuples&flush=TRUE&format=CSV&limit=1&offset=0&lang=itql&stream=on&query=" . $query_string; - + $result = preg_split('/[\r\n]+/', do_curl($url)); array_shift($result); // throw away first line $matches = str_getcsv(join("\n", $result)); - if ($matches !== FALSE) { + if (count($matches) >= 2) { $parent = preg_replace('/^info:fedora\//', '', $matches[0]); + if (0 == strlen($matches[1])) { + $matches[1] = "Unlabeled Object"; + } + $breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) { $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); @@ -958,6 +962,10 @@ class ObjectHelper { $this->getBreadcrumbs($parent, $breadcrumbs, $level - 1); } } + + else { + $breadcrumbs[] = l("Path Calculation Error", 'fedora/repository/' . $pid); + } } } From 35a7d19f37006eef829c76ce6cea27e40464bd6e Mon Sep 17 00:00:00 2001 From: jonathangreen <jonathan@discoverygarden.ca> Date: Wed, 16 Nov 2011 11:14:21 -0400 Subject: [PATCH 41/46] Updated SecurityClass to properly search XACML The SecurityClass module does a naive search of an XACML policy to pull out the users and roles listed. Assuming that they are who can edit the object. With certain policies this was failing, and only returning the users, not the roles. This became a problem with the XACML editor in use because this class was used more often. I updated the XPATH expressions that it uses to find the users and roles, so it should find them in all cases now. We should update the security class to call the more precise XACML class first and only fall back on the security class if XACML fails to parse the file, however this would mean moving the XACML stuff into core. --- SecurityClass.inc | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/SecurityClass.inc b/SecurityClass.inc index 1e2b1835..1f3df0eb 100644 --- a/SecurityClass.inc +++ b/SecurityClass.inc @@ -34,7 +34,6 @@ class SecurityClass { $objectHelper = new ObjectHelper(); // get the childsecurity policy from the collection. $policyStream = $objectHelper->getStream($collection_pid, SECURITYCLASS :: $SECURITY_CLASS_SECURITY_STREAM, FALSE); - if ($policyStream == NULL) { // no child policy stream so collection is wide open to anyone to ingest, that has the permission ingest in Drupal. // maybe we should return FALSE here?? would be more secure. @@ -79,34 +78,20 @@ class SecurityClass { } $xml->registerXPathNamespace('default', 'urn:oasis:names:tc:xacml:1.0:policy'); - $conditions = $xml->xpath("//default:Condition"); - - foreach ($conditions as $condition) { - $designator = $condition->Apply->SubjectAttributeDesignator; - if (empty($designator)) {//$disignator may be wrapped by an or - $designator = $condition->Apply->Apply->SubjectAttributeDesignator; - } - $attributeId = strip_tags($designator['AttributeId']); + $roles = $xml->xpath('//default:SubjectAttributeDesignator[@AttributeId="fedoraRole"]/../default:Apply/default:AttributeValue'); + $users = $xml->xpath('//default:SubjectAttributeDesignator[@AttributeId="urn:fedora:names:fedora:2.1:subject:loginId"]/../default:Apply/default:AttributeValue'); - if ($attributeId == "fedoraRole") { - foreach ($condition->Apply->Apply->AttributeValue as $attributeValue) { - $allowedRoles[] = strip_tags($attributeValue->asXML()); - } - foreach ($condition->Apply->Apply->Apply->AttributeValue as $attributeValue) { - $allowedRoles[] = strip_tags($attributeValue->asXML()); - } - } - if ($attributeId == "urn:fedora:names:fedora:2.1:subject:loginId") { - foreach ($condition->Apply->Apply->AttributeValue as $attributeValue) { - $allowedUsers[] = strip_tags($attributeValue->asXML()); - } - foreach ($condition->Apply->Apply->Apply->AttributeValue as $attributeValue) { - $allowedUsers[] = strip_tags($attributeValue->asXML()); - } - } + foreach($roles as $role) { + $allowedRoles[] = (string)$role; } + foreach($users as $user) { + $allowedUsers[] = (string)$user; + } + $usersAndRoles['users'] = $allowedUsers; $usersAndRoles['roles'] = $allowedRoles; + + dd($usersAndRoles); return $usersAndRoles; } From 4d9c4cd00615b511ba70eb71d882f352d291e454 Mon Sep 17 00:00:00 2001 From: jonathangreen <jonathan@discoverygarden.ca> Date: Wed, 16 Nov 2011 15:08:50 -0400 Subject: [PATCH 42/46] Forgot to remove a debug statement before I committed. Woops. This fixes it all up. --- SecurityClass.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/SecurityClass.inc b/SecurityClass.inc index 1f3df0eb..67bc9c43 100644 --- a/SecurityClass.inc +++ b/SecurityClass.inc @@ -91,7 +91,6 @@ class SecurityClass { $usersAndRoles['users'] = $allowedUsers; $usersAndRoles['roles'] = $allowedRoles; - dd($usersAndRoles); return $usersAndRoles; } From 288125ea855d428b98541592f8e1e6717a566ef3 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Thu, 17 Nov 2011 14:45:46 -0400 Subject: [PATCH 43/46] Set the version to 11.3.beta1 --- fedora_repository.info | 2 +- plugins/fedora_imageapi.info | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fedora_repository.info b/fedora_repository.info index 99cb3d6f..45564e20 100644 --- a/fedora_repository.info +++ b/fedora_repository.info @@ -5,5 +5,5 @@ dependencies[] = tabs dependencies[] = islandora_content_model_forms description = Shows a list of items in a fedora collection. package = Islandora -version = 11.2.0 +version = 11.3beta1 core = 6.x diff --git a/plugins/fedora_imageapi.info b/plugins/fedora_imageapi.info index af50a614..ea14fb07 100644 --- a/plugins/fedora_imageapi.info +++ b/plugins/fedora_imageapi.info @@ -3,5 +3,5 @@ description = Adds image manipulation support through a REST interface package = Islandora Dependencies dependencies[] = fedora_repository dependencies[] = imageapi -version = 11.2.0 +version = 11.3beta1 core = 6.x From 9ca282d521e9c81af31e0dcced75c96b8f5ea4f0 Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Tue, 22 Nov 2011 12:01:49 -0400 Subject: [PATCH 44/46] Added validity check for Collection Policy class --- CollectionClass.inc | 9 +++++---- fedora_repository.module | 13 +++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CollectionClass.inc b/CollectionClass.inc index 2af37522..bee0c495 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -519,14 +519,16 @@ class CollectionClass { $show_batch_tab = FALSE; $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); - $content_models = $policy->getContentModels(); + if ($policy) { + $content_models = $policy->getContentModels(); + } if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { $show_batch_tab = FALSE; } if (!$show_ingest_tab) { $view_selected = TRUE; } - if(!$collection_items){ + if (!$collection_items) { $view_selected = FALSE; $add_selected = TRUE; } @@ -538,7 +540,6 @@ class CollectionClass { '#title' => 'View', '#selected' => $view_selected, '#content' => $collection_items, - ); $tabset['add_tab'] = array( '#type' => 'tabpage', @@ -614,7 +615,7 @@ class CollectionClass { $collectionName = $collection; - + if (!$pageNumber) { $pageNumber = 1; } diff --git a/fedora_repository.module b/fedora_repository.module index 27060dda..600e3bcb 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -142,6 +142,10 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label */ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { //only validate the form if the submit button was pressed (other buttons may be used for AHAH + if ($form_state['ahah_submission']) { + $form_state['submitted'] = false; + return; + } if ($form_state['storage']['xml']) { if (module_exists('islandora_content_model_forms')) { module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); @@ -197,7 +201,11 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) { */ function fedora_repository_ingest_form_validate($form, &$form_state) { //only validate the form if the submit button was pressed (other buttons may be used for AHAH - if ($form_state['clicked_button']['#id'] == 'edit-submit') { + if ($form_state['ahah_submission']) { + $form_state['submitted'] = false; + return; + } + if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) { switch ($form_state['storage']['step']) { case 1: $form_state['storage']['step']++; @@ -828,9 +836,6 @@ function fedora_repository_perm() { OBJECTHELPER::$INGEST_FEDORA_OBJECTS, OBJECTHELPER::$EDIT_TAGS_DATASTREAM, OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, - OBJECTHELPER::$MANAGE_COLLECTIONS, - OBJECTHELPER::$DELETE_ENTIRE_COLLECTIONS, - OBJECTHELPER::$CREATE_BATCH_PROCESS, ); } From 33bc8c922e1527633692b0b223c7a7e4afbd19ab Mon Sep 17 00:00:00 2001 From: Alan Stanley <astanley@upei.ca> Date: Thu, 24 Nov 2011 13:54:44 -0400 Subject: [PATCH 45/46] Added additional functionality to CollectionPolicy::getNextPid --- CollectionPolicy.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CollectionPolicy.inc b/CollectionPolicy.inc index be9e7a92..5a3daf21 100644 --- a/CollectionPolicy.inc +++ b/CollectionPolicy.inc @@ -360,13 +360,14 @@ class CollectionPolicy extends XMLDatastream { * @param string $dsid * @return string $nextPid */ - public function getNextPid($dsid) { + public function getNextPid($dsid, $content_model = null) { $ret = FALSE; + if (self::valid_dsid($dsid) && $this->validate()) { $content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); $namespace = FALSE; for ($i = 0; $namespace === FALSE && $i < $content_models->length; $i++) { - if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid)) { + if (strtolower($content_models->item($i)->getAttribute('dsid')) == strtolower($dsid) && (strtolower($content_models->item($i)->getAttribute('pid') == $content_model) || $content_model == null)) { $namespace = $content_models->item($i)->getAttribute('namespace'); } } From 59db4b5097e5994c3f4b7b633bf1983843a6a643 Mon Sep 17 00:00:00 2001 From: Ben Woodhead <bwoodhead@upei.ca> Date: Tue, 29 Nov 2011 09:51:46 -0400 Subject: [PATCH 46/46] New version and removed id tags --- fedora_repository.info | 3 +-- plugins/fedora_imageapi.info | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fedora_repository.info b/fedora_repository.info index 45564e20..944568fe 100644 --- a/fedora_repository.info +++ b/fedora_repository.info @@ -1,9 +1,8 @@ -; $Id$ name = Islandora Repository dependencies[] = imageapi dependencies[] = tabs dependencies[] = islandora_content_model_forms description = Shows a list of items in a fedora collection. package = Islandora -version = 11.3beta1 +version = 11.3beta2 core = 6.x diff --git a/plugins/fedora_imageapi.info b/plugins/fedora_imageapi.info index ea14fb07..d17d73a8 100644 --- a/plugins/fedora_imageapi.info +++ b/plugins/fedora_imageapi.info @@ -3,5 +3,5 @@ description = Adds image manipulation support through a REST interface package = Islandora Dependencies dependencies[] = fedora_repository dependencies[] = imageapi -version = 11.3beta1 +version = 11.3beta2 core = 6.x