Browse Source

Conflicts resolved

pull/105/head
Alan Stanley 14 years ago
parent
commit
e32cf74fe2
  1. 261
      ObjectHelper.inc
  2. 94
      SearchClass.inc
  3. 275
      api/fedora_item.inc
  4. 32
      api/fedora_utils.inc
  5. 367
      fedora_repository.module
  6. 714
      formClass.inc
  7. 1
      ilives/fedora_ilives.module
  8. 6
      plugins/fedora_attach/fedora_attach.admin.inc
  9. 205
      tests/fedora_repository.test
  10. 269
      xsl/unfilteredresults.xsl

261
ObjectHelper.inc

@ -32,7 +32,7 @@ class ObjectHelper {
//$this->fedoraPass = $connectionHelper->getPassword(); //$this->fedoraPass = $connectionHelper->getPassword();
} }
/** /**
* Grabs a stream from fedora sets the mimetype and returns it. $dsID is the * Grabs a stream from fedora sets the mimetype and returns it. $dsID is the
* datastream id. If $forceSoap is set, the function will always buffer the datastream from fedora. Otherwise, it will * datastream id. If $forceSoap is set, the function will always buffer the datastream from fedora. Otherwise, it will
* try and use a redirect if possible. * try and use a redirect if possible.
@ -41,7 +41,7 @@ class ObjectHelper {
*/ */
function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = TRUE) { function makeObject($pid, $dsID, $asAttachment = FALSE, $label = NULL, $filePath=FALSE, $version=NULL, $forceSoap = TRUE) {
global $user; global $user;
module_load_include('inc','fedora_repository','ContentModel'); module_load_include('inc', 'fedora_repository', 'ContentModel');
if ($pid == NULL || $dsID == NULL) { if ($pid == NULL || $dsID == NULL) {
drupal_set_message(t("no pid or dsid given to create an object with"), 'error'); drupal_set_message(t("no pid or dsid given to create an object with"), 'error');
return ' '; return ' ';
@ -58,21 +58,21 @@ class ObjectHelper {
drupal_set_message(t("You do not have access Fedora objects within the attempted namespace."), 'error'); drupal_set_message(t("You do not have access Fedora objects within the attempted namespace."), 'error');
drupal_access_denied(); drupal_access_denied();
return ' '; return ' ';
} }
if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE ) { if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE) {
if (($cm = ContentModel::loadFromObject($pid)) == FALSE) { if (($cm = ContentModel::loadFromObject($pid)) == FALSE) {
drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error'); drupal_set_message(t("You do not have access to objects without an Islandora Content Model."), 'error');
drupal_access_denied(); drupal_access_denied();
return ' '; return ' ';
} }
$cmDatastreams = $cm->listDatastreams(); $cmDatastreams = $cm->listDatastreams();
if ( !((isset($user) && in_array('administrator',$user->roles)) || in_array($dsID,$cmDatastreams))) { if (!((isset($user) && in_array('administrator', $user->roles)) || in_array($dsID, $cmDatastreams))) {
drupal_set_message(t("You do not have access to the specified datastream."), 'error'); drupal_set_message(t("You do not have access to the specified datastream."), 'error');
drupal_access_denied(); drupal_access_denied();
return ' '; return ' ';
} }
} }
@ -81,9 +81,9 @@ class ObjectHelper {
if (isset($item->datastreams[$dsID])) { if (isset($item->datastreams[$dsID])) {
$mimeType=$item->datastreams[$dsID]['MIMEType']; $mimeType = $item->datastreams[$dsID]['MIMEType'];
if ($label == NULL) { if ($label == NULL) {
$label = $item->datastreams[$dsID]['label']; $label = $item->datastreams[$dsID]['label'];
} }
} else { } else {
drupal_not_found(); drupal_not_found();
@ -94,7 +94,7 @@ class ObjectHelper {
if ((!isset($user)) || $user->uid == 0) { if ((!isset($user)) || $user->uid == 0) {
$fedoraUser = 'anonymous'; $fedoraUser = 'anonymous';
$fedoraPass = 'anonymous'; $fedoraPass = 'anonymous';
$contentSize= 0; $contentSize = 0;
} else { } else {
$fedoraUser = $user->name; $fedoraUser = $user->name;
$fedoraPass = $user->pass; $fedoraPass = $user->pass;
@ -102,7 +102,7 @@ class ObjectHelper {
$contentSize = $dataStreamInfo->datastream->size; $contentSize = $dataStreamInfo->datastream->size;
} }
if (function_exists("curl_init")) { if (function_exists("curl_init")) {
if (!isset($mimeType)) { if (!isset($mimeType)) {
$pid = variable_get('fedora_default_display_pid', 'demo:10'); $pid = variable_get('fedora_default_display_pid', 'demo:10');
$dsID = variable_get('fedora_default_display_dsid', 'TN'); $dsID = variable_get('fedora_default_display_dsid', 'TN');
@ -137,10 +137,10 @@ class ObjectHelper {
fclose($fp); fclose($fp);
} else { } else {
header("Content-type: $mimeType"); header("Content-type: $mimeType");
if ($contentSize > 0) { if ($contentSize > 0) {
header("Content-length: $contentSize"); header("Content-length: $contentSize");
} }
if ($asAttachment) { if ($asAttachment) {
$suggestedFileName = "$label"; $suggestedFileName = "$label";
@ -165,18 +165,18 @@ class ObjectHelper {
header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"');
} }
if ( (isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { if ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) {
curl_exec($ch); curl_exec($ch);
} else { } else {
header('Location: '.$url); header('Location: ' . $url);
} }
} }
curl_close($ch); curl_close($ch);
} else { } else {
drupal_set_message(t('No curl support.'), 'error'); drupal_set_message(t('No curl support.'), 'error');
} }
} }
//Gets collection objects t //Gets collection objects t
function getCollectionInfo($pid, $query = NULL) { function getCollectionInfo($pid, $query = NULL) {
@ -258,14 +258,14 @@ class ObjectHelper {
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if (user_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS)) { if (user_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS)) {
$allow=TRUE; $allow = TRUE;
if (module_exists('fedora_fesl')) { if (module_exists('fedora_fesl')) {
$allow= fedora_fesl_check_roles($pid,'write'); $allow = fedora_fesl_check_roles($pid, 'write');
} }
if ($allow) { if ($allow) {
$purgeImage = '<a title="purge datastream ' . $dataStreamValue->label . '" href="' . $base_url . '/fedora/repository/purgeStream/' . $purgeImage = '<a title="purge datastream ' . $dataStreamValue->label . '" href="' . $base_url . '/fedora/repository/purgeStream/' .
$pid . '/' . $dataStreamValue->ID . '/' . $dataStreamValue->label . '"><img src="' . $base_url . '/' . $path . $pid . '/' . $dataStreamValue->ID . '/' . $dataStreamValue->label . '"><img src="' . $base_url . '/' . $path .
'/images/purge.gif" alt="purge datastream" /></a>'; '/images/purge.gif" alt="purge datastream" /></a>';
} }
} else { } else {
$purgeImage = '&nbsp;'; $purgeImage = '&nbsp;';
@ -274,16 +274,16 @@ class ObjectHelper {
// Add an icon to replace a datastream // Add an icon to replace a datastream
// @TODO Note: using l(theme_image(..), ...); for these image links (and other links) may remove the need to have clean urls enabled. // @TODO Note: using l(theme_image(..), ...); for these image links (and other links) may remove the need to have clean urls enabled.
$replaceImage= '&nbsp;'; $replaceImage = '&nbsp;';
if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) { if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) {
$allow=TRUE; $allow = TRUE;
if (module_exists('fedora_fesl')) { if (module_exists('fedora_fesl')) {
$allow= fedora_fesl_check_roles($pid,'write'); $allow = fedora_fesl_check_roles($pid, 'write');
} }
if ($allow) { if ($allow) {
$replaceImage = '<a title="' . t("Replace datastream") . " " . $dataStreamValue->label . '" href="' . $base_url . '/fedora/repository/replaceStream/' . $pid . '/' . $dataStreamValue->ID . '/' . $dataStreamValue->label . '"><img src="' . $base_url . '/' . $path . '/images/replace.png" alt="replace datastream" /></a>'; $replaceImage = '<a title="' . t("Replace datastream") . " " . $dataStreamValue->label . '" href="' . $base_url . '/fedora/repository/replaceStream/' . $pid . '/' . $dataStreamValue->ID . '/' . $dataStreamValue->label . '"><img src="' . $base_url . '/' . $path . '/images/replace.png" alt="replace datastream" /></a>';
} }
} }
$content = ''; $content = '';
$id = $dataStreamValue->ID; $id = $dataStreamValue->ID;
@ -292,7 +292,7 @@ class ObjectHelper {
$mimeType = $dataStreamValue->MIMEType; $mimeType = $dataStreamValue->MIMEType;
$view = '<a href="' . $base_url . '/fedora/repository/' . drupal_urlencode($pid) . '/' . $id . '/' . drupal_urlencode($label) . $view = '<a href="' . $base_url . '/fedora/repository/' . drupal_urlencode($pid) . '/' . $id . '/' . drupal_urlencode($label) .
'" target="_blank" >' . t('View') . '</a>'; '" target="_blank" >' . t('View') . '</a>';
$action = "$base_url/fedora/repository/object_download/" . drupal_urlencode($pid) . '/' . $id . '/' . drupal_urlencode(preg_replace('/\//i', '${1}_', $label)); // Necessary to handle the case of Datastream labels that contain slashes. Ugh. $action = "$base_url/fedora/repository/object_download/" . drupal_urlencode($pid) . '/' . $id . '/' . drupal_urlencode(preg_replace('/\//i', '${1}_', $label)); // Necessary to handle the case of Datastream labels that contain slashes. Ugh.
$downloadVersion = '<form method="GET" action="' . $action . '"><input type="submit" value="' . t('Download') . '"></form>'; $downloadVersion = '<form method="GET" action="' . $action . '"><input type="submit" value="' . t('Download') . '"></form>';
if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) { if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) {
@ -331,25 +331,27 @@ class ObjectHelper {
$dsId = 'QDC'; $dsId = 'QDC';
$params = array( $params = array(
'pid' => "$pid", 'pid' => "$pid",
'dsID' => "$dsId", 'dsID' => "$dsId",
'asOfDateTime' => "" 'asOfDateTime' => ""
); );
try { try {
$object = $client->__soapCall('getDatastreamDissemination', array( $object = $client->__soapCall('getDatastreamDissemination', array(
'parameters' => $params 'parameters' => $params
)); ));
} catch (Exception $e) { } catch (Exception $e) {
try { //probably no QDC so we will try for the DC stream. try { //probably no QDC so we will try for the DC stream.
$dsId = 'DC'; $dsId = 'DC';
$params = array( $params = array(
'pid' => "$pid", 'pid' => "$pid",
'dsID' => "$dsId", 'dsID' => "$dsId",
'asOfDateTime' => "" 'asOfDateTime' => ""
); );
$object = $client->__soapCAll('getDatastreamDissemination', array( $object = $client->__soapCAll('getDatastreamDissemination', array(
'parameters' => $params 'parameters' => $params
)); ));
} catch (exception $e2) { } catch (exception $e2) {
drupal_set_message($e2->getMessage(), 'error'); drupal_set_message($e2->getMessage(), 'error');
return; return;
@ -380,13 +382,13 @@ class ObjectHelper {
$baseUrl = base_path(); $baseUrl = base_path();
//$baseUrl=substr($baseUrl, 0, (strpos($baseUrl, "/")-1)); //$baseUrl=substr($baseUrl, 0, (strpos($baseUrl, "/")-1));
if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) { if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) {
$allow=TRUE; $allow = TRUE;
if (module_exists('fedora_fesl')) { if (module_exists('fedora_fesl')) {
$allow= fedora_fesl_check_roles($pid,'write'); $allow = fedora_fesl_check_roles($pid, 'write');
} }
if ($allow) { if ($allow) {
$output .= '<br /><a title = "' . t('Edit Meta Data') . '" href="' . $base_url . '/fedora/repository/' . 'editmetadata/' . $pid . '/' . $output .= '<br /><a title = "' . t('Edit Meta Data') . '" href="' . $base_url . '/fedora/repository/' . 'editmetadata/' . $pid . '/' .
$dsId . '"><img src="' . $base_url . '/' . $path . '/images/edit.gif" alt="' . t('Edit Meta Data') . '" /></a>'; $dsId . '"><img src="' . $base_url . '/' . $path . '/images/edit.gif" alt="' . t('Edit Meta Data') . '" /></a>';
} }
} }
return $output; return $output;
@ -411,7 +413,7 @@ class ObjectHelper {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'ContentModel'); module_load_include('inc', 'fedora_repository', 'ContentModel');
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
$dataStreamBody = ''; $dataStreamBody = '';
$fedoraItem = new Fedora_Item($object_pid); $fedoraItem = new Fedora_Item($object_pid);
@ -428,47 +430,47 @@ class ObjectHelper {
$hasOBJStream = NULL; $hasOBJStream = NULL;
$hasTNStream = FALSE; $hasTNStream = FALSE;
$dataStreamBody = "<br /><table>\n"; $dataStreamBody = "<br /><table>\n";
$cmDatastreams = array(); $cmDatastreams = array();
if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE && ($cm = ContentModel::loadFromObject($object_pid)) !== FALSE) { if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE && ($cm = ContentModel::loadFromObject($object_pid)) !== FALSE) {
$cmDatastreams = $cm->listDatastreams(); $cmDatastreams = $cm->listDatastreams();
} }
$dataStreamBody .= $this->get_parent_objects_asHTML($object_pid); $dataStreamBody .= $this->get_parent_objects_asHTML($object_pid);
$dataStreamBody .= '<tr><th colspan="4"><h3>' . t("!text", array('!text' => $availableDataStreamsText)) . '</h3></th></tr>'; $dataStreamBody .= '<tr><th colspan="4"><h3>' . t("!text", array('!text' => $availableDataStreamsText)) . '</h3></th></tr>';
foreach ($object as $datastream) { foreach ($object as $datastream) {
foreach ($datastream as $datastreamValue) { foreach ($datastream as $datastreamValue) {
if (variable_get('fedora_object_restrict_datastreams', FALSE) == FALSE || ((isset($user) && in_array('administrator',$user->roles)) || in_array($datastreamValue->ID,$cmDatastreams))) { if (variable_get('fedora_object_restrict_datastreams', FALSE) == FALSE || ((isset($user) && in_array('administrator', $user->roles)) || in_array($datastreamValue->ID, $cmDatastreams))) {
if ($datastreamValue->ID == 'OBJ') { if ($datastreamValue->ID == 'OBJ') {
$hasOBJStream = '1'; $hasOBJStream = '1';
$mainStreamLabel = $datastreamValue->label; $mainStreamLabel = $datastreamValue->label;
$mainStreamLabel = str_replace("_", " ", $mainStreamLabel); $mainStreamLabel = str_replace("_", " ", $mainStreamLabel);
} }
if ($datastreamValue->ID == 'TN') { if ($datastreamValue->ID == 'TN') {
$hasTNStream = TRUE; $hasTNStream = TRUE;
} }
//create the links to each datastream //create the links to each datastream
$dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"<tr><td><b>$key :</b></td><td>$value</td></tr>\n"; $dataStreamBody .= $this->create_link_for_ds($object_pid, $datastreamValue); //"<tr><td><b>$key :</b></td><td>$value</td></tr>\n";
} }
} }
} }
$dataStreamBody .= "</table>\n"; $dataStreamBody .= "</table>\n";
//if they have access let them add a datastream //if they have access let them add a datastream
if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) { if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) {
$allow=TRUE; $allow = TRUE;
if (module_exists('fedora_fesl')) { if (module_exists('fedora_fesl')) {
$allow= fedora_fesl_check_roles($object_pid,'write'); $allow = fedora_fesl_check_roles($object_pid, 'write');
} }
if ($allow) { if ($allow) {
$dataStreamBody .= drupal_get_form('add_stream_form', $object_pid); $dataStreamBody .= drupal_get_form('add_stream_form', $object_pid);
} }
} }
$fieldset = array( $fieldset = array(
'#title' => t("!text", array('!text' => $availableDataStreamsText)), '#title' => t("!text", array('!text' => $availableDataStreamsText)),
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => TRUE, '#collapsed' => TRUE,
'#value' => $dataStreamBody '#value' => $dataStreamBody
); );
$dataStreamBody = '<div class = "fedora_detailed_list">' . theme('fieldset', $fieldset) . '</div>'; $dataStreamBody = '<div class = "fedora_detailed_list">' . theme('fieldset', $fieldset) . '</div>';
} }
@ -493,15 +495,15 @@ class ObjectHelper {
$content .= $dataStreamBody; $content .= $dataStreamBody;
if (user_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS)) { if (user_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS)) {
$allow=TRUE; $allow = TRUE;
if (module_exists('fedora_fesl')) { if (module_exists('fedora_fesl')) {
$allow= fedora_fesl_check_roles($object_pid,'write'); $allow = fedora_fesl_check_roles($object_pid, 'write');
} }
if ($allow) { if ($allow) {
//$purgeObject = '<a title="' . t('Purge Object ') . $object_pid . '" href="' . base_path() . 'fedora/repository/purgeObject/' . //$purgeObject = '<a title="' . t('Purge Object ') . $object_pid . '" href="' . base_path() . 'fedora/repository/purgeObject/' .
//$object_pid . '"><img src="' . $base_url . '/' . $path . '/images/purge_big.png" alt="' . t('Purge Object') . '" class="icon">' . t('Purge Object') . '</a>'; //$object_pid . '"><img src="' . $base_url . '/' . $path . '/images/purge_big.png" alt="' . t('Purge Object') . '" class="icon">' . t('Purge Object') . '</a>';
$purgeObject = drupal_get_form('fedora_repository_purge_object_form', $object_pid, check_plain(substr(request_uri(), strlen(base_path())))); $purgeObject = drupal_get_form('fedora_repository_purge_object_form', $object_pid, check_plain(substr(request_uri(), strlen(base_path()))));
} }
} else { } else {
$purgeObject = '&nbsp;'; $purgeObject = '&nbsp;';
} }
@ -540,9 +542,9 @@ class ObjectHelper {
try { try {
$client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
$params = array( $params = array(
'pid' => "$pid", 'pid' => "$pid",
'dsID' => "$dsid", 'dsID' => "$dsid",
'asOfDateTime' => "" 'asOfDateTime' => ""
); );
if (!isset($client)) { if (!isset($client)) {
@ -602,23 +604,29 @@ class ObjectHelper {
/* /*
* determines whether we can see the object or not * determines whether we can see the object or not
* checks PID namespace permissions, and user permissions
*/ */
function fedora_repository_access($op, $pid) { function fedora_repository_access($op, $pid) {
global $user; global $user;
$returnValue = FALSE; $returnValue = FALSE;
$isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
if (!$isRestricted) {
$namespaceAccess = TRUE;
}
if ($pid == NULL) { if ($pid == NULL) {
$pid = variable_get('fedora_repository_pid', 'islandora:top'); $pid = variable_get('fedora_repository_pid', 'islandora:top');
} }
$nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); $nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '));
$pos = NULL; $pos = NULL;
foreach ($nameSpaceAllowed as $nameSpace) { foreach ($nameSpaceAllowed as $nameSpace) {
$pos = stripos($pid, $nameSpace); $pos = stripos($pid, $nameSpace);
if ($pos === 0) { if ($pos === 0) {
$returnValue = TRUE; $namespaceAccess = TRUE;
} }
} }
if ($returnValue) { if ($namespaceAccess) {
$user_access = user_access($op); $user_access = user_access($op);
if ($user_access == NULL) { if ($user_access == NULL) {
return FALSE; return FALSE;
@ -724,19 +732,18 @@ class ObjectHelper {
$collectionPolicyExists = $objectHelper->getMimeType($pid, CollectionPolicy::getDefaultDSID()); $collectionPolicyExists = $objectHelper->getMimeType($pid, CollectionPolicy::getDefaultDSID());
if (user_access(ObjectHelper :: $INGEST_FEDORA_OBJECTS) && $collectionPolicyExists) { if (user_access(ObjectHelper :: $INGEST_FEDORA_OBJECTS) && $collectionPolicyExists) {
if (!empty($collectionPolicyExists)) { if (!empty($collectionPolicyExists)) {
$allow=TRUE; $allow = TRUE;
if (module_exists('fedora_fesl')) { if (module_exists('fedora_fesl')) {
$allow= fedora_fesl_check_roles($pid,'write'); $allow = fedora_fesl_check_roles($pid, 'write');
} }
if ($allow) { if ($allow) {
// $ingestObject = '<a title="'. t('Ingest a New object into ') . $collectionName . ' '. $collection_pid . '" href="'. base_path() . // $ingestObject = '<a title="'. t('Ingest a New object into ') . $collectionName . ' '. $collection_pid . '" href="'. base_path() .
$ingestObject = '<a title="' . t('Ingest a New object into !collection_name PID !collection_pid', array('!collection_name' => $collectionName, '!collection_pid' => $collection_pid)) . '" href="' . base_path() . $ingestObject = '<a title="' . t('Ingest a New object into !collection_name PID !collection_pid', array('!collection_name' => $collectionName, '!collection_pid' => $collection_pid)) . '" href="' . base_path() .
'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '"><img src="' . $base_url . '/' . $path . 'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '"><img src="' . $base_url . '/' . $path .
'/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon"></a>' . t(' Add to this Collection'); '/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon"></a>' . t(' Add to this Collection');
} }
} }
} } else {
else {
$ingestObject = '&nbsp;'; $ingestObject = '&nbsp;';
} }
@ -746,20 +753,20 @@ class ObjectHelper {
$objectListOut = ''; $objectListOut = '';
if (isset($objectList)) { if (isset($objectList)) {
$object_list_fieldset = array( $object_list_fieldset = array(
'#title' => t('Items in this collection'), '#title' => t('Items in this collection'),
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => FALSE, '#collapsed' => FALSE,
'#value' => (isset($objectList) ? $objectList : ''), //collection list '#value' => (isset($objectList) ? $objectList : ''), //collection list
); );
$objectListOut = theme('fieldset', $object_list_fieldset); $objectListOut = theme('fieldset', $object_list_fieldset);
} }
} else { } else {
//$collectionName=''; //$collectionName='';
$collection_fieldset = array( $collection_fieldset = array(
'#title' => "", '#title' => "",
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => FALSE, '#collapsed' => FALSE,
'#value' => $datastreams, '#value' => $datastreams,
); );
$objectListOut = ''; //no collection objects to show so don't show field set $objectListOut = ''; //no collection objects to show so don't show field set
} }
@ -800,10 +807,10 @@ class ObjectHelper {
$metaDataText = t('Description'); $metaDataText = t('Description');
$body = $this->getQDC($pid); $body = $this->getQDC($pid);
$fieldset = array( $fieldset = array(
'#title' => t("!metaDataText", array('!metaDataText' => $metaDataText)), '#title' => t("!metaDataText", array('!metaDataText' => $metaDataText)),
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => TRUE, '#collapsed' => TRUE,
'#value' => $body '#value' => $body
); );
$output .= theme('fieldset', $fieldset); $output .= theme('fieldset', $fieldset);
} }
@ -944,10 +951,10 @@ class ObjectHelper {
// Get pid, title and description for children of object $pid // Get pid, title and description for children of object $pid
$query_string = 'select $o $title from <#ri> ' . $query_string = 'select $o $title from <#ri> ' .
// $query_string = 'select $o $title $desc from <#ri> '. // $query_string = 'select $o $title $desc from <#ri> '.
'where $s <info:fedora/fedora-system:def/relations-external#hasMember> $o ' . 'where $s <info:fedora/fedora-system:def/relations-external#hasMember> $o ' .
'and $o <dc:title> $title ' . 'and $o <dc:title> $title ' .
// 'and $o <dc:description> $desc '. // 'and $o <dc:description> $desc '.
'and ( '; 'and ( ';
foreach ($pids as $pid) { foreach ($pids as $pid) {
$query_string .= '$s <mulgara:is> <info:fedora/' . $pid . '> or '; $query_string .= '$s <mulgara:is> <info:fedora/' . $pid . '> or ';
@ -1013,11 +1020,13 @@ class ObjectHelper {
$url = variable_get('fedora_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; $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)); $result = preg_split('/[\r\n]+/',do_curl($url));
array_shift($result); // throw away first line array_shift($result); // throw away first line
$matches =str_getcsv(join("\n",$result)); $matches =str_getcsv(join("\n",$result));
if ($matches !== FALSE) { if ($matches !== FALSE) {
$parent = preg_replace('/^info:fedora\//','',$matches[0]); $parent = preg_replace('/^info:fedora\//','',$matches[0]);
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); $breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid);
if ($parent == variable_get('fedora_repository_pid', 'islandora:top')) { if ($parent == variable_get('fedora_repository_pid', 'islandora:top')) {
$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); $breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
@ -1032,9 +1041,9 @@ class ObjectHelper {
public static function warnIfMisconfigured($app) { public static function warnIfMisconfigured($app) {
$messMap = array( $messMap = array(
'Kakadu' => 'Full installation instructions for Kakadu can be found 'Kakadu' => 'Full installation instructions for Kakadu can be found
<a href=http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=27&Itemid=23>Here</a>', <a href=http://www.kakadusoftware.com/index.php?option=com_content&task=view&id=27&Itemid=23>Here</a>',
'ImageMagick' => 'Check the path settings in the configuration of your <b>imageapi</b> module.<br/> 'ImageMagick' => 'Check the path settings in the configuration of your <b>imageapi</b> module.<br/>
Further details can be found <a href=http://www.imagemagick.org/script/install-source.php>Here</a>', Further details can be found <a href=http://www.imagemagick.org/script/install-source.php>Here</a>',
); );

94
SearchClass.inc

@ -208,42 +208,7 @@ class SearchClass {
} }
/*
function custom_search($query,$pathToXslt=NULL){
module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
module_load_include('inc', 'Fedora_Repository', 'api/fedora_utils');
if (user_access('view fedora collection')) {
$numberOfHistPerPage = '1000';//hack for IR they do not want next button
$luceneQuery = NULL;
//demo search string ?operation=gfindObjects&indexName=DemoOnLucene&query=fgs.DS.first.text%3Achristmas&hitPageStart=11&hitPageSize=10
$indexName = variable_get('fedora_index_name', 'DemoOnLucene');
$query=htmlentities(urlencode($query));
$searchUrl = variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest');
$searchString = '?operation=gfindObjects&indexName=' . $indexName . '&restXslt=copyXml&query=' . $query;
$searchString .= '&hitPageSize='.$numberOfHistPerPage.'&hitPageStart=1';
//$searchString = htmlentities($searchString);
$searchUrl .= $searchString;
$objectHelper = new ObjectHelper();
$resultData = do_curl($searchUrl,1);
//var_dump($resultData);exit(0);
// $doc = new DOMDocument();
// $doc->loadXML($resultData);
if($pathToXslt==NULL) {
$output.=$this->applyLuceneXSLT($resultData,$query);
}else{
$output.=$this->applySpecifiedXSLT($resultData,$pathToXslt);
}
return $output;
}
}
*/
function custom_search($query, $startPage=1, $xslt= '/xsl/advanced_search_results.xsl', $numberOfHistPerPage = 50) { 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', 'ObjectHelper');
@ -327,53 +292,7 @@ class SearchClass {
} }
} }
//default function for lucene results //default function for lucene results
/*
function applyLuceneXSLT($resultData, $query = NULL){
$path = drupal_get_path('module', 'Fedora_Repository');
$proc = NULL;
if (!$resultData) {
drupal_set_message(t('No Results!'));
return ' '; //no results
}
try {
$proc = new XsltProcessor();
}
catch (Exception $e) {
drupal_set_message(t('Error loading results xslt! ') . $e->getMessage()) ;
return ' ';
}
//inject into xsl stylesheet
if(isset($query)){
$proc->setParameter('', 'fullQuery', $query);
}
$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', 'demo: changeme:'));
$proc->registerPHPFunctions();
$xsl = new DomDocument();
$test= $xsl->load($path . '/xsl/results.xsl');
if (!isset($test)) {
drupal_set_message(t('Error loading search results XSLT!'));
return t('Error loading search results XSLT.');
}
$input = new DomDocument();
$didLoadOk = $input->loadXML($resultData);
if (!isset($didLoadOk)) {
drupal_set_message(t('Error loading search results!'));
return t('Error loading search results.');
}
else {
$proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input);
return $newdom->saveXML();
}
}
*/
/** /**
* apply an xslt to lucene gsearch search results * apply an xslt to lucene gsearch search results
@ -385,6 +304,11 @@ class SearchClass {
*/ */
function applyLuceneXSLT($resultData, $startPage = 1, $xslt_file = '/xsl/results.xsl', $query=NULL) { function applyLuceneXSLT($resultData, $startPage = 1, $xslt_file = '/xsl/results.xsl', $query=NULL) {
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'Fedora_Repository');
$test = $xslt_file;
$isRestricted = variable_get('fedora_namespace_restriction_enforced',TRUE);
if(!isRestricted && $xslt_file == null){
$xslt_file = '/xsl/unfilteredresults.xsl';
}
$proc = NULL; $proc = NULL;
if (!$resultData) { if (!$resultData) {
//drupal_set_message(t('No Results!')); //drupal_set_message(t('No Results!'));
@ -405,7 +329,7 @@ class SearchClass {
$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('', '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('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
$proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'objectsPage', base_path());
$proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '));
$proc->setParameter('', 'hitPageStart', $startPage); $proc->setParameter('', 'hitPageStart', $startPage);
$proc->registerPHPFunctions(); $proc->registerPHPFunctions();
$xsl = new DomDocument(); $xsl = new DomDocument();
@ -450,7 +374,7 @@ class SearchClass {
$proc->setParameter('', 'userID', $user->uid); $proc->setParameter('', 'userID', $user->uid);
$proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl $proc->setParameter('', 'searchUrl', url('search') . '/fedora_repository'); //needed in our xsl
$proc->setParameter('', 'objectsPage', base_path()); $proc->setParameter('', 'objectsPage', base_path());
$proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '));
$proc->setParameter('', 'orderBy', $orderBy); $proc->setParameter('', 'orderBy', $orderBy);
$xsl = new DomDocument(); $xsl = new DomDocument();

275
api/fedora_item.inc

@ -2,19 +2,18 @@
// $Id$ // $Id$
define ('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#'); define('RELS_EXT_URI', 'info:fedora/fedora-system:def/relations-external#');
define ("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#'); define("FEDORA_MODEL_URI", 'info:fedora/fedora-system:def/model#');
class Fedora_Item { class Fedora_Item {
public $pid = NULL; // The $pid of the fedora object represented by an instance of this class. public $pid = NULL; // The $pid of the fedora object represented by an instance of this class.
public $objectProfile = NULL; public $objectProfile = NULL;
private $datastreams_list = NULL; // A SimpleXML object to store a list of this item's datastreams private $datastreams_list = NULL; // A SimpleXML object to store a list of this item's datastreams
public $datastreams = NULL; public $datastreams = NULL;
private static $connection_helper = NULL; private static $connection_helper = NULL;
private static $instantiated_pids = array(); private static $instantiated_pids = array();
/** /**
* Create an object to represent an item in the Fedora repository. * Create an object to represent an item in the Fedora repository.
* Throws a SOAPException if the PID is not in the repository. * Throws a SOAPException if the PID is not in the repository.
@ -29,32 +28,34 @@ class Fedora_Item {
$this->pid = $pid; $this->pid = $pid;
if (isset(Fedora_Item::$instantiated_pids[$pid])) { if (isset(Fedora_Item::$instantiated_pids[$pid])) {
$this->objectProfile =& Fedora_Item::$instantiated_pids[$pid]->objectProfile; $this->objectProfile = & Fedora_Item::$instantiated_pids[$pid]->objectProfile;
$this->datastreams =& Fedora_Item::$instantiated_pids[$pid]->datastreams; $this->datastreams = & Fedora_Item::$instantiated_pids[$pid]->datastreams;
$this->datastreams_list =& Fedora_Item::$instantiated_pids[$pid]->datastreams_list; $this->datastreams_list = & Fedora_Item::$instantiated_pids[$pid]->datastreams_list;
} else { }
else {
if (empty(self::$connection_helper)) { if (empty(self::$connection_helper)) {
self::$connection_helper = new ConnectionHelper(); self::$connection_helper = new ConnectionHelper();
} }
$raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => "")); $raw_objprofile = $this->soap_call('getObjectProfile', array('pid' => $this->pid, 'asOfDateTime' => ""));
if (!empty($raw_objprofile)) { if (!empty($raw_objprofile)) {
$this->objectProfile = $raw_objprofile->objectProfile; $this->objectProfile = $raw_objprofile->objectProfile;
$this->datastreams = $this->get_datastreams_list_as_array(); $this->datastreams = $this->get_datastreams_list_as_array();
} else {
$this->objectProfile = '';
$this->datastreams = array();
} }
Fedora_Item::$instantiated_pids[$pid]=&$this; else {
$this->objectProfile = '';
$this->datastreams = array();
}
Fedora_Item::$instantiated_pids[$pid] = &$this;
} }
} }
function exists() { function exists() {
return (!empty($this->objectProfile)); return (!empty($this->objectProfile));
} }
function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M',$logMessage = null) { 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', 'fedora_repository', 'MimeClass');
if (empty($datastream_mimetype)) { if (empty($datastream_mimetype)) {
// Get mime type from the file extension. // Get mime type from the file extension.
@ -67,7 +68,7 @@ class Fedora_Item {
$datastream_url = drupal_urlencode($datastream_file); $datastream_url = drupal_urlencode($datastream_file);
$url = file_create_url($datastream_url); $url = file_create_url($datastream_url);
$return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup,$logMessage); $return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
if ($original_path != $datastream_file) { if ($original_path != $datastream_file) {
file_delete($datastream_file); file_delete($datastream_file);
@ -75,12 +76,12 @@ class Fedora_Item {
return $return_value; return $return_value;
} }
function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M',$logMessage = null) { function add_datastream_from_url($datastream_url, $datastream_id, $datastream_label = NULL, $datastream_mimetype = '', $controlGroup = 'M', $logMessage = null) {
if (empty( $datastream_label)) { if (empty($datastream_label)) {
$datastream_label = $datastream_id; $datastream_label = $datastream_id;
} }
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $datastream_id, 'dsID' => $datastream_id,
'altIDs' => NULL, 'altIDs' => NULL,
@ -93,19 +94,23 @@ class Fedora_Item {
'dsState' => 'A', 'dsState' => 'A',
'checksumType' => 'DISABLED', 'checksumType' => 'DISABLED',
'checksum' => 'none', 'checksum' => 'none',
'logMessage' => ($logMessage != null)?$logMessage: 'Ingested object '. $datastream_id 'logMessage' => ($logMessage != null) ? $logMessage : 'Ingested object ' . $datastream_id
); );
<<<<<<< HEAD
return $this->soap_call( 'addDataStream', $params ); return $this->soap_call( 'addDataStream', $params );
=======
return $this->soap_call('addDataStream', $params)->datastreamID;
>>>>>>> ISLANDORA-125
} }
function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M',$logMessage = null) { function add_datastream_from_string($str, $datastream_id, $datastream_label = NULL, $datastream_mimetype = 'text/xml', $controlGroup = 'M', $logMessage = null) {
$dir = sys_get_temp_dir(); $dir = sys_get_temp_dir();
$tmpfilename = tempnam($dir, 'fedoratmp'); $tmpfilename = tempnam($dir, 'fedoratmp');
$tmpfile = fopen($tmpfilename, 'w'); $tmpfile = fopen($tmpfilename, 'w');
fwrite($tmpfile, $str, strlen($str)); fwrite($tmpfile, $str, strlen($str));
fclose($tmpfile); fclose($tmpfile);
$returnvalue = $this->add_datastream_from_file($tmpfilename, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup,$logMessage); $returnvalue = $this->add_datastream_from_file($tmpfilename, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup, $logMessage);
unlink($tmpfilename); unlink($tmpfilename);
return $returnvalue; return $returnvalue;
} }
@ -118,10 +123,10 @@ class Fedora_Item {
*/ */
function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) { function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) {
$ds_list = $this->get_datastreams_list_as_array(); $ds_list = $this->get_datastreams_list_as_array();
if (empty($ds_list['RELS-EXT'])) { if (empty($ds_list['RELS-EXT'])) {
$this->add_datastream_from_string(' <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> $this->add_datastream_from_string(' <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="info:fedora/'. $this->pid . '"> <rdf:Description rdf:about="info:fedora/' . $this->pid . '">
</rdf:Description> </rdf:Description>
</rdf:RDF>', 'RELS-EXT', 'Fedora object-to-object relationship metadata', 'text/xml', 'X'); </rdf:RDF>', 'RELS-EXT', 'Fedora object-to-object relationship metadata', 'text/xml', 'X');
} }
@ -133,32 +138,32 @@ class Fedora_Item {
} }
$relsextxml = new DomDocument(); $relsextxml = new DomDocument();
$relsextxml->loadXML($relsext); $relsextxml->loadXML($relsext);
$description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description'); $description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description');
if ($description->length == 0) { if ($description->length == 0) {
$description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'description'); $description = $relsextxml->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'description');
} }
$description=$description->item(0); $description = $description->item(0);
// Create the new relationship node. // Create the new relationship node.
$newrel = $relsextxml->createElementNS($namespaceURI, $relationship); $newrel = $relsextxml->createElementNS($namespaceURI, $relationship);
$newrel->setAttribute('rdf:resource', $object); $newrel->setAttribute('rdf:resource', $object);
$description->appendChild($newrel); $description->appendChild($newrel);
$this->modify_datastream_by_value( $relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml'); $this->modify_datastream_by_value($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
//print ($description->dump_node()); //print ($description->dump_node());
/* /*
$params = array( 'pid' => $this->pid, $params = array( 'pid' => $this->pid,
'relationship' => $relationship, 'relationship' => $relationship,
'object' => $object, 'object' => $object,
'isLiteral' => FALSE, 'isLiteral' => FALSE,
'datatype' => '', 'datatype' => '',
); );
return $this->soap_call( 'addRelationship', $params ); return $this->soap_call( 'addRelationship', $params );
*/ */
} }
/** /**
@ -205,7 +210,7 @@ class Fedora_Item {
} }
} }
if ($modified) { if ($modified) {
$this->modify_datastream_by_value( $relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml'); $this->modify_datastream_by_value($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
} }
return $modified; return $modified;
//print ($description->dump_node()); //print ($description->dump_node());
@ -231,7 +236,7 @@ class Fedora_Item {
*/ */
static function find_objects_by_pattern($pattern = '*', $field = 'pid', $max_results = 100, $resultFields = array()) { 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', 'fedora_repository', 'api/fedora_utils');
$pattern = drupal_urlencode($pattern); $pattern = drupal_urlencode($pattern);
$done = FALSE; $done = FALSE;
$cursor = 0; $cursor = 0;
@ -248,8 +253,8 @@ class Fedora_Item {
$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) { if (count($resultFields) > 0) {
$url .= '&'.join('=true&',$resultFields).'=true'; $url .= '&' . join('=true&', $resultFields) . '=true';
} }
$resultxml = do_curl($url); $resultxml = do_curl($url);
@ -266,15 +271,15 @@ class Fedora_Item {
$done = TRUE; $done = TRUE;
} }
foreach ($resultelements->resultList->objectFields as $obj) { foreach ($resultelements->resultList->objectFields as $obj) {
$ret = (string)$obj->title; $ret = (string) $obj->title;
if (count($resultFields) > 0) { if (count($resultFields) > 0) {
$ret = array('title' => $ret); $ret = array('title' => $ret);
foreach ($resultFields as $field) { foreach ($resultFields as $field) {
$ret[$field]=(string)$obj->$field; $ret[$field] = (string) $obj->$field;
} }
} }
$results[(string)$obj->pid] = $ret; $results[(string) $obj->pid] = $ret;
$cursor++; $cursor++;
if ($cursor >= $max_results) { if ($cursor >= $max_results) {
$done = TRUE; $done = TRUE;
@ -311,24 +316,24 @@ class Fedora_Item {
'asOfDateTime' => $as_of_date_time, 'asOfDateTime' => $as_of_date_time,
); );
$object = self::soap_call('getDatastream', $params); $object = self::soap_call('getDatastream', $params);
return $object->datastream; return $object->datastream;
} }
function get_datastream_history($dsid) { function get_datastream_history($dsid) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid 'dsID' => $dsid
); );
$object = self::soap_call('getDatastreamHistory', $params); $object = self::soap_call('getDatastreamHistory', $params);
$ret = FALSE; $ret = FALSE;
if (!empty($object)) { if (!empty($object)) {
$ret = $object->datastream; $ret = $object->datastream;
} }
return $ret; return $ret;
} }
function get_dissemination($service_definition_pid, $method_name, $parameters = array(), $as_of_date_time = null) { function get_dissemination($service_definition_pid, $method_name, $parameters = array(), $as_of_date_time = null) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
@ -365,36 +370,36 @@ class Fedora_Item {
//} //}
return $this->datastreams_list; return $this->datastreams_list;
} }
/** /**
* * DatastreamControlGroup controlGroup - String restricted to the values of "X", "M", "R", or "E" (InlineXML,Managed Content,Redirect, or External Referenced). * * DatastreamControlGroup controlGroup - String restricted to the values of "X", "M", "R", or "E" (InlineXML,Managed Content,Redirect, or External Referenced).
* String ID - The datastream ID (64 characters max). * String ID - The datastream ID (64 characters max).
* String versionID - The ID of the most recent datastream version * String versionID - The ID of the most recent datastream version
* String[] altIDs - Alternative IDs for the datastream, if any. * String[] altIDs - Alternative IDs for the datastream, if any.
* String label - The Label of the datastream. * String label - The Label of the datastream.
* boolean versionable - Whether the datastream is versionable. * boolean versionable - Whether the datastream is versionable.
* String MIMEType - The mime-type for the datastream, if set. * String MIMEType - The mime-type for the datastream, if set.
* String formatURI - The format uri for the datastream, if set. * String formatURI - The format uri for the datastream, if set.
* String createDate - The date the first version of the datastream was created. * String createDate - The date the first version of the datastream was created.
* long size - The size of the datastream in Fedora. Only valid for inline XML metadata and managed content datastreams. * long size - The size of the datastream in Fedora. Only valid for inline XML metadata and managed content datastreams.
* String state - The state of the datastream. Will be "A" (active), "I" (inactive) or "D" (deleted). * String state - The state of the datastream. Will be "A" (active), "I" (inactive) or "D" (deleted).
* String location - If the datastream is an external reference or redirect, the url to the contents. TODO: Managed? * String location - If the datastream is an external reference or redirect, the url to the contents. TODO: Managed?
* String checksumType - The algorithm used to compute the checksum. One of "DEFAULT", "DISABLED", "MD5", "SHA-1", "SHA-256", "SHA-385", "SHA-512". * String checksumType - The algorithm used to compute the checksum. One of "DEFAULT", "DISABLED", "MD5", "SHA-1", "SHA-256", "SHA-385", "SHA-512".
* String checksum - The value of the checksum represented as a hexadecimal string. * String checksum - The value of the checksum represented as a hexadecimal string.
* *
* @param string $dsid * @param string $dsid
* @return datastream object * @return datastream object
* get the mimetype size etc. in one shot. instead of iterating throught the datastream list for what we need * get the mimetype size etc. in one shot. instead of iterating throught the datastream list for what we need
*/ */
function get_datastream_info($dsid,$as_of_date_time = ""){ function get_datastream_info($dsid, $as_of_date_time = "") {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
'asOfDateTime' => $as_of_date_time 'asOfDateTime' => $as_of_date_time
); );
return $this->soap_call('getDatastream', $params); return $this->soap_call('getDatastream', $params);
} }
/** /**
@ -427,14 +432,14 @@ class Fedora_Item {
} }
$ds_list[$ds->ID]['label'] = $ds->label; $ds_list[$ds->ID]['label'] = $ds->label;
$ds_list[$ds->ID]['MIMEType'] = $ds->MIMEType; $ds_list[$ds->ID]['MIMEType'] = $ds->MIMEType;
$ds_list[$ds->ID]['URL'] = $this->url() . '/'. $ds->ID . '/'. drupal_urlencode($ds->label); $ds_list[$ds->ID]['URL'] = $this->url() . '/' . $ds->ID . '/' . drupal_urlencode($ds->label);
} }
} }
else { else {
$ds = $this->datastreams_list->datastreamDef; $ds = $this->datastreams_list->datastreamDef;
$ds_list[$ds->ID]['label'] = $ds->label; $ds_list[$ds->ID]['label'] = $ds->label;
$ds_list[$ds->ID]['MIMEType'] = $ds->MIMEType; $ds_list[$ds->ID]['MIMEType'] = $ds->MIMEType;
$ds_list[$ds->ID]['URL'] = $this->url().'/'.$ds->ID.'/'.drupal_urlencode($ds->label); $ds_list[$ds->ID]['URL'] = $this->url() . '/' . $ds->ID . '/' . drupal_urlencode($ds->label);
} }
} }
@ -454,7 +459,7 @@ class Fedora_Item {
foreach ($datastream_list as $datastream) { foreach ($datastream_list as $datastream) {
foreach ($datastream as $datastreamValue) { foreach ($datastream as $datastreamValue) {
if ($datastreamValue->ID == $dsid) { if ($datastreamValue->ID == $dsid) {
return $datastreamValue->MIMEType; return $datastreamValue->MIMEType;
} }
} }
} }
@ -472,8 +477,7 @@ class Fedora_Item {
$relationships = array(); $relationships = array();
try { try {
$relsext = $this->get_datastream_dissemination('RELS-EXT'); $relsext = $this->get_datastream_dissemination('RELS-EXT');
} } catch (exception $e) {
catch (exception $e) {
drupal_set_message("Error retrieving RELS-EXT of object $pid", 'error'); drupal_set_message("Error retrieving RELS-EXT of object $pid", 'error');
return $relationships; return $relationships;
} }
@ -510,12 +514,12 @@ class Fedora_Item {
// Verify the array format and that it isn't empty. // Verify the array format and that it isn't empty.
if (!empty($relationships)) { if (!empty($relationships)) {
$relsextxml = '<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:fedora="info:fedora/fedora-system:def/relations-external#" xmlns:fedora-model="info:fedora/fedora-system:def/model#" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">' $relsextxml = '<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:fedora="info:fedora/fedora-system:def/relations-external#" xmlns:fedora-model="info:fedora/fedora-system:def/model#" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">'
. '<rdf:description rdf:about="'. $this->pid . '">'; . '<rdf:description rdf:about="' . $this->pid . '">';
foreach ($relationships as $rel) { foreach ($relationships as $rel) {
if (empty($rel['subject']) || empty($rel['predicate']) || empty($rel['object']) || $rel['subject'] != 'info:fedora/'. $this->pid) { if (empty($rel['subject']) || empty($rel['predicate']) || empty($rel['object']) || $rel['subject'] != 'info:fedora/' . $this->pid) {
// drupal_set_message should use parameterized variables, not interpolated. // drupal_set_message should use parameterized variables, not interpolated.
drupal_set_message("Error with relationship format: ". $rel['subject'] . " - ". $rel['predicate'] . ' - '. $rel['object'], "error"); drupal_set_message("Error with relationship format: " . $rel['subject'] . " - " . $rel['predicate'] . ' - ' . $rel['object'], "error");
return FALSE; return FALSE;
} }
} }
@ -539,27 +543,28 @@ class Fedora_Item {
return $this->soap_call('purgeObject', $params); return $this->soap_call('purgeObject', $params);
} }
function purge_datastream( $dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) { function purge_datastream($dsID, $start_date = NULL, $end_date = NULL, $log_message = 'Purged datastream using Islandora API', $force = FALSE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsID, 'dsID' => $dsID,
'startDT' => $start_date, 'startDT' => $start_date,
'endDT' => $end_date, 'endDT' => $end_date,
'logMessage' => $log_message, 'logMessage' => $log_message,
'force' => $force, 'force' => $force,
); );
return $this->soap_call('purgeDatastream', $params); return $this->soap_call('purgeDatastream', $params);
} }
function url() { function url() {
global $base_url; global $base_url;
return $base_url . '/fedora/repository/'. $this->pid . (!empty($this->objectProfile) ? '/-/'. drupal_urlencode($this->objectProfile->objLabel) : ''); return $base_url . '/fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : '');
} }
static function get_next_PID_in_namespace( $pid_namespace = '') { static function get_next_PID_in_namespace($pid_namespace = '') {
if (empty($pid_namespace)) { if (empty($pid_namespace)) {
// Just get the first one in the config settings. // Just get the first one in the config settings.
$allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); $allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '));
$pid_namespace = $allowed_namespaces[0]; $pid_namespace = $allowed_namespaces[0];
if (!empty($pid_namespace)) { if (!empty($pid_namespace)) {
$pid_namespace = substr($pid_namespace, 0, strpos($pid_namespace, ":")); $pid_namespace = substr($pid_namespace, 0, strpos($pid_namespace, ":"));
@ -568,7 +573,7 @@ class Fedora_Item {
$pid_namespace = 'default'; $pid_namespace = 'default';
} }
} }
$params = array( $params = array(
'numPIDs' => '', 'numPIDs' => '',
'pidNamespace' => $pid_namespace, 'pidNamespace' => $pid_namespace,
@ -586,7 +591,7 @@ class Fedora_Item {
static function ingest_from_FOXML_file($foxml_file) { static function ingest_from_FOXML_file($foxml_file) {
$foxml = new DOMDocument(); $foxml = new DOMDocument();
$foxml->load( $foxml_file ); $foxml->load($foxml_file);
return self::ingest_from_FOXML($foxml); return self::ingest_from_FOXML($foxml);
} }
@ -600,9 +605,9 @@ class Fedora_Item {
} }
try { try {
self::ingest_from_FOXML_file( $path . '/'. $file ); self::ingest_from_FOXML_file($path . '/' . $file);
} } catch (exception $e) {
catch (exception $e) {
} }
} }
// Close // Close
@ -610,20 +615,20 @@ class Fedora_Item {
} }
function modify_object($label = '', $state = null, $ownerId = null, $logMessage = 'Modified by Islandora API', $quiet=TRUE) { function modify_object($label = '', $state = null, $ownerId = null, $logMessage = 'Modified by Islandora API', $quiet=TRUE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'ownerId' => $ownerId, 'ownerId' => $ownerId,
'state' => $state, 'state' => $state,
'label' => $label, 'label' => $label,
'logMessage' => $logMessage 'logMessage' => $logMessage
); );
return self::soap_call('modifyObject', $params, $quiet); return self::soap_call('modifyObject', $params, $quiet);
} }
function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API',$quiet=FALSE) { function modify_datastream_by_reference($external_url, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
'altIDs' => NULL, 'altIDs' => NULL,
@ -636,11 +641,11 @@ class Fedora_Item {
'logMessage' => $logMessage, 'logMessage' => $logMessage,
'force' => $force 'force' => $force
); );
return self::soap_call('modifyDatastreamByReference', $params, $quiet); return self::soap_call('modifyDatastreamByReference', $params, $quiet);
} }
function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API',$quiet=FALSE) { function modify_datastream_by_value($content, $dsid, $label, $mime_type, $force = FALSE, $logMessage = 'Modified by Islandora API', $quiet=FALSE) {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
'altIDs' => NULL, 'altIDs' => NULL,
@ -653,10 +658,10 @@ class Fedora_Item {
'logMessage' => $logMessage, 'logMessage' => $logMessage,
'force' => $force 'force' => $force
); );
return self::soap_call('modifyDatastreamByValue', $params,$quiet); return self::soap_call('modifyDatastreamByValue', $params, $quiet);
} }
static function soap_call( $function_name, $params_array, $quiet = FALSE ) { static function soap_call($function_name, $params_array, $quiet = FALSE) {
if (!self::$connection_helper) { if (!self::$connection_helper) {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper(); self::$connection_helper = new ConnectionHelper();
@ -684,25 +689,25 @@ class Fedora_Item {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection.")); watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection."));
return NULL; return NULL;
} }
} } catch (exception $e) {
catch (exception $e) { if (!$quiet) {
if (!$quiet) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/',$e->getMessage())) { drupal_set_message(t('Error: Insufficient permissions to call SOAP function !fn.', array('!fn' => $function_name)), 'error');
drupal_set_message(t('Error: Insufficient permissions to call SOAP function !fn.', array('!fn' => $function_name) ), 'error'); }
} else { else {
drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error'); drupal_set_message(t("Error trying to call SOAP function $function_name. Check watchdog logs for more information."), 'error');
} }
watchdog(t("FEDORA_REPOSITORY"), t("Error Trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e)), NULL, WATCHDOG_ERROR); watchdog(t("FEDORA_REPOSITORY"), t("Error Trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e)), NULL, WATCHDOG_ERROR);
} }
return NULL; return NULL;
} }
break; break;
default: default:
try { try {
$soap_client = self::$connection_helper->getSoapClient( variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); $soap_client = self::$connection_helper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) { if (!empty($soap_client)) {
$result = $soap_client->__soapCall($function_name, array('parameters' => $params_array)); $result = $soap_client->__soapCall($function_name, array('parameters' => $params_array));
} }
@ -710,19 +715,17 @@ class Fedora_Item {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection.")); watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection."));
return NULL; return NULL;
} }
} } catch (exception $e) {
catch (exception $e) {
if (!$quiet) {
if (!$quiet) { watchdog(t("FEDORA_REPOSITORY"), t("Error trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e)), NULL, WATCHDOG_ERROR);
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to call SOAP function !fn: !e", array('!fn' => $function_name, '!e' => $e)), NULL, WATCHDOG_ERROR); }
} return NULL;
return NULL;
} }
} }
return $result; return $result;
} }
/** /**
* Creates the minimal FOXML for a new Fedora object, which is then passed to * Creates the minimal FOXML for a new Fedora object, which is then passed to
* ingest_from_FOXML to be added to the repository. * ingest_from_FOXML to be added to the repository.
@ -766,7 +769,7 @@ class Fedora_Item {
$owner_property = $foxml->createElement("foxml:property"); $owner_property = $foxml->createElement("foxml:property");
$owner_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#ownerId"); $owner_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#ownerId");
$owner_property->setAttribute("VALUE", $owner ); $owner_property->setAttribute("VALUE", $owner);
$object_properties->appendChild($state_property); $object_properties->appendChild($state_property);
$object_properties->appendChild($label_property); $object_properties->appendChild($label_property);
@ -778,7 +781,7 @@ class Fedora_Item {
} }
static function ingest_new_item($pid = '', $state = 'A', $label = '', $owner = '') { static function ingest_new_item($pid = '', $state = 'A', $label = '', $owner = '') {
return self::ingest_from_FOXML(self::create_object_FOXML( $pid, $state, $label, $owner)); return self::ingest_from_FOXML(self::create_object_FOXML($pid, $state, $label, $owner));
} }
static function fedora_item_exists($pid) { static function fedora_item_exists($pid) {
@ -786,9 +789,9 @@ class Fedora_Item {
return $item->exists(); return $item->exists();
} }
/******************************************************** /* * ******************************************************
* Relationship Functions * Relationship Functions
********************************************************/ * ****************************************************** */
/** /**
* Returns an associative array of relationships that this item has * Returns an associative array of relationships that this item has

32
api/fedora_utils.inc

@ -66,8 +66,40 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post
} }
function fedora_available() { function fedora_available() {
<<<<<<< HEAD
$response = drupal_http_request(variable_get('fedora_base_url', 'http://localhost:8080/fedora').'/describe'); $response = drupal_http_request(variable_get('fedora_base_url', 'http://localhost:8080/fedora').'/describe');
return ($response->code == 200); return ($response->code == 200);
=======
$ret = do_curl(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/management?wsdl'), 1);
// A bit of a hack but the SOAP parser will cause a fatal error if you give it the wrong URL.
//return (strpos($ret, 'wsdl:definitions') != FALSE);
module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
return true;
try {
$connection_helper = new ConnectionHelper();
$soap_client = $connection_helper->getSoapClient( variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'));
if (!empty($soap_client)) {
$result = $soap_client->__soapCall('describeRepository', array());
}
return TRUE;
}
catch (SoapFault $e) {
watchdog(t("FEDORA_REPOSITORY"), t("Error trying to get SOAP client connection."));
return FALSE;
}
>>>>>>> ISLANDORA-125
} }
/** /**

367
fedora_repository.module

@ -58,9 +58,9 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) {
return ''; return '';
} }
$output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />', $output = t('Are you sure you wish to purge object %name %pid!<br /><b>This cannot be undone</b><br />',
array( array(
'%name' => $name, '%name' => $name,
'%pid' => $pid) '%pid' => $pid)
); );
$output .= drupal_get_form('fedora_repository_purge_object_form', $pid); $output .= drupal_get_form('fedora_repository_purge_object_form', $pid);
@ -101,11 +101,11 @@ function fedora_repository_ingest_object($collection_pid=NULL, $collection_label
if (!validPid($collection_pid)) { if (!validPid($collection_pid)) {
if (validPid(urldecode($collection_pid))) { if (validPid(urldecode($collection_pid))) {
$collection_pid = urldecode($collection_pid); $collection_pid = urldecode($collection_pid);
} else { }
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"), 'error');
return ' '; return ' ';
} }
} }
if ($collection_pid == NULL) { if ($collection_pid == NULL) {
@ -145,7 +145,7 @@ function fedora_repository_ingest_form_submit($form, &$form_state) {
$form_state['values']['content_model_pid'] = $contentModelPid; $form_state['values']['content_model_pid'] = $contentModelPid;
$form_state['values']['relationship'] = $relationship; $form_state['values']['relationship'] = $relationship;
$err = (!$cm->execFormHandler($form_state['values'],$form_state)); $err = (!$cm->execFormHandler($form_state['values'], $form_state));
$_SESSION['fedora_ingest_files'] = ''; //empty this variable $_SESSION['fedora_ingest_files'] = ''; //empty this variable
@ -203,10 +203,11 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
if (!empty($file)) { if (!empty($file)) {
if (!in_array($dformat, $allowedMimeTypes)) { 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 ' . 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); file_delete($file);
return; return;
} elseif (!$cm->execIngestRules($file, $dformat)) { }
elseif (!$cm->execIngestRules($file, $dformat)) {
drupal_set_message(t('Error following Content Model Rules'), 'error'); drupal_set_message(t('Error following Content Model Rules'), 'error');
foreach (ContentModel::$errors as $err) { foreach (ContentModel::$errors as $err) {
drupal_set_message($err, 'error'); drupal_set_message($err, 'error');
@ -243,32 +244,32 @@ function fedora_repository_purge_object_form(&$form_state, $pid, $referrer = NUL
return NULL; return NULL;
} }
$form['pid'] = array( $form['pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$pid" '#value' => "$pid"
); );
if (!strstr( drupal_get_destination(), urlencode('fedora/repository'))) { if (!strstr(drupal_get_destination(), urlencode('fedora/repository'))) {
$form['referrer'] = array( $form['referrer'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $referrer, '#value' => $referrer,
); );
} }
if(!isset($form_state['storage']['confirm'])) { if (!isset($form_state['storage']['confirm'])) {
// do your normal $form definition here // do your normal $form definition here
$form['submit'] = array( $form['submit'] = array(
'#type' => 'image_button', '#type' => 'image_button',
'#src' => drupal_get_path('module', 'fedora_repository').'/images/purge_big.png', '#src' => drupal_get_path('module', 'fedora_repository') . '/images/purge_big.png',
'#value' => t('Purge'), '#value' => t('Purge'),
'#suffix' => 'Purge this object', '#suffix' => 'Purge this object',
); );
if (!empty($collectionPid)) { if (!empty($collectionPid)) {
$collectionPid = $_SESSION['fedora_collection']; $collectionPid = $_SESSION['fedora_collection'];
} }
//$form['#redirect'] = $referrer; //$form['#redirect'] = $referrer;
return $form; return $form;
} }
else { 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 // 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
@ -370,9 +371,9 @@ function add_stream_form_validate($form, &$form_state) {
return FALSE; return FALSE;
} }
$validators = array( $validators = array(
// 'file_validate_is_image' => array(), // 'file_validate_is_image' => array(),
// 'file_validate_image_resolution' => array('85x85'), // 'file_validate_image_resolution' => array('85x85'),
// 'file_validate_size' => array(30 * 1024), // 'file_validate_size' => array(30 * 1024),
); );
$fileObject = file_save_upload('add-stream-file-location', $validators); $fileObject = file_save_upload('add-stream-file-location', $validators);
@ -397,8 +398,8 @@ function fedora_repository_purge_stream($pid = NULL, $dsId = NULL, $name = NULL)
} }
$output = t('Are you sure you wish to purge this datastream %name<br />', $output = t('Are you sure you wish to purge this datastream %name<br />',
array( array(
'%name' => $name) '%name' => $name)
); );
$output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId); $output .= drupal_get_form('fedora_repository_purge_stream_form', $pid, $dsId);
return $output; return $output;
@ -410,13 +411,13 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
if (!isset($form_state['storage']['confirm'])) { 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['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 $form_state['rebuild'] = TRUE; // along with this
} }
else { else {
// this is where you do your processing after they have pressed the confirm button // this is where you do your processing after they have pressed the confirm button
$params = array( $params = array(
"pid" => $pid, "pid" => $pid,
"logMessage" => "Purged", "logMessage" => "Purged",
"force" => "" "force" => ""
); );
try { try {
$soapHelper = new ConnectionHelper(); $soapHelper = new ConnectionHelper();
@ -426,7 +427,8 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
} catch (exception $e) { } catch (exception $e) {
if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) { if (preg_match('/org\.fcrepo\.server\.security\.xacml\.pep\.AuthzDeniedException/', $e->getMessage())) {
drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error'); drupal_set_message(t('Error: Insufficient permissions to purge object.'), 'error');
} else { }
else {
drupal_set_message(t($e->getMessage()), 'error'); drupal_set_message(t($e->getMessage()), 'error');
} }
return; return;
@ -444,16 +446,16 @@ function fedora_repository_purge_object_form_submit($form, &$form_state) {
function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) { function fedora_repository_purge_stream_form(&$form_state, $pid, $dsId) {
$form['pid'] = array( $form['pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$pid" '#value' => "$pid"
); );
$form['dsid'] = array( $form['dsid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$dsId" '#value' => "$dsId"
); );
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Purge') '#value' => t('Purge')
); );
return $form; return $form;
@ -542,11 +544,13 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
*/ */
$mimetype = new MimeClass(); $mimetype = new MimeClass();
$dformat = $mimetype->getType($file->filepath); $dformat = $mimetype->getType($file->filepath);
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
$item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat); $item->modify_datastream_by_reference($streamUrl, $dsid, $dsLabel, $dformat);
$form_state['redirect'] = 'fedora/repository/' . $pid; $form_state['redirect'] = 'fedora/repository/' . $pid;
} }
function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) { function fedora_repository_edit_qdc_page($pid = NULL, $dsId = NULL) {
@ -649,13 +653,13 @@ function fedora_repository_edit_qdc_form_submit($form, &$form_state) {
function fedora_repository_perm() { function fedora_repository_perm() {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
return array( return array(
OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA,
OBJECTHELPER::$EDIT_FEDORA_METADATA, OBJECTHELPER::$EDIT_FEDORA_METADATA,
OBJECTHELPER::$PURGE_FEDORA_OBJECTSANDSTREAMS, OBJECTHELPER::$PURGE_FEDORA_OBJECTSANDSTREAMS,
OBJECTHELPER::$ADD_FEDORA_STREAMS, OBJECTHELPER::$ADD_FEDORA_STREAMS,
OBJECTHELPER::$INGEST_FEDORA_OBJECTS, OBJECTHELPER::$INGEST_FEDORA_OBJECTS,
OBJECTHELPER::$EDIT_TAGS_DATASTREAM, OBJECTHELPER::$EDIT_TAGS_DATASTREAM,
OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST, OBJECTHELPER::$VIEW_DETAILED_CONTENT_LIST,
); );
} }
@ -717,22 +721,30 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
global $user; global $user;
if (!fedora_available()) { if (!fedora_available()) {
drupal_set_message('The Fedora repository server is currently unavailable. Please contact the site administrator.', 'warning', FALSE); drupal_set_message('The Fedora repository server is currently unavailable. Please contact the site administrator.', 'warning', FALSE);
return ''; return '';
} }
if ($pid &!validPid($pid)) { if ($pid &!validPid($pid)) {
drupal_set_message(t("Invalid PID!"), 'error'); drupal_set_message(t("Invalid PID!"), 'error');
return ' '; return ' ';
} }
if ($dsId &!validDsid($dsId)) { if ($dsId & !validDsid($dsId)) {
drupal_set_message(t("Invalid dsID!"), 'error'); drupal_set_message(t("Invalid dsID!"), 'error');
return ' '; return ' ';
} }
if (!fedora_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_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied"), 'error');
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 ' '; return ' ';
} }
@ -806,11 +818,16 @@ function repository_page($pid = NULL, $dsId = NULL, $collection = NULL, $pageNum
} }
function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) { function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NULL) {
module_load_include('inc','fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc','fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
global $user; global $user;
if (!fedora_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_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 ' '; return ' ';
} }
if ($pid == NULL) { if ($pid == NULL) {
@ -823,15 +840,13 @@ function repository_service($pid = NULL, $servicePid = NULL, $serviceMethod = NU
return ' '; return ' ';
} }
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if ($item !== false) if ($item !== false) {
{ echo $item->get_dissemination($servicePid, $serviceMethod);
echo $item->get_dissemination($servicePid,$serviceMethod);
} }
exit(); exit();
} }
//Search Stuff ******************************************************************** //Search Stuff ********************************************************************
@ -896,7 +911,8 @@ function fedora_repository_search($op = 'search', $keys = NULL) {
$searchQuery = NULL; $searchQuery = NULL;
if (isset($type) && strcmp($type, ':')) { if (isset($type) && strcmp($type, ':')) {
$searchQuery = $type . ':' . $keys; $searchQuery = $type . ':' . $keys;
} else { }
else {
$searchQuery = $keys; $searchQuery = $keys;
} }
//$searchQuery.=" AND (PID:vre OR PID:vre:ref OR PID:demo OR PID:changeme)"; //$searchQuery.=" AND (PID:vre OR PID:vre:ref OR PID:demo OR PID:changeme)";
@ -910,10 +926,10 @@ function fedora_repository_search($op = 'search', $keys = NULL) {
$resultData = do_curl($searchUrl); $resultData = do_curl($searchUrl);
$results[] = array( $results[] = array(
array( array(
'data' => $resultData, 'data' => $resultData,
'colspan' => 2 'colspan' => 2
) )
); );
return $results; return $results;
} }
@ -926,6 +942,7 @@ function fedora_repository_search($op = 'search', $keys = NULL) {
*/ */
function fedora_repository_search_page($resultData) { function fedora_repository_search_page($resultData) {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
$isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
$proc = NULL; $proc = NULL;
if (!$resultData[0][0]['data']) { if (!$resultData[0][0]['data']) {
return ''; //no results return ''; //no results
@ -936,10 +953,10 @@ function fedora_repository_search_page($resultData) {
$proc = new XsltProcessor(); $proc = new XsltProcessor();
} catch (Exception $e) { } catch (Exception $e) {
$out[] = array( $out[] = array(
array( array(
'data' => $e->getMessage(), 'data' => $e->getMessage(),
'colspan' => 2 'colspan' => 2
) )
); );
return $out; return $out;
} }
@ -951,36 +968,42 @@ function fedora_repository_search_page($resultData) {
$proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ')); $proc->setParameter('', 'allowedPidNameSpaces', variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: '));
$proc->registerPHPFunctions(); $proc->registerPHPFunctions();
$xsl = new DomDocument(); $xsl = new DomDocument();
$xsl->load($path . '/xsl/results.xsl'); if ($isRestricted) {
$quimby = $xsl; $xsl->load($path . '/xsl/results.xsl');
}
else {
$xsl->load($path . '/xsl/unfilteredresults.xsl');
}
$input = new DomDocument(); $input = new DomDocument();
$didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data'])); $didLoadOk = $input->loadXML(utf8_encode($resultData[0][0]['data']));
if (!$didLoadOk) { if (!$didLoadOk) {
$results[] = array( $results[] = array(
array( array(
'data' => 'Error parsing results', 'data' => 'Error parsing results',
'colspan' => 2 'colspan' => 2
) )
); );
} else { }
else {
$xsl = $proc->importStylesheet($xsl); $xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input); $newdom = $proc->transformToDoc($input);
$results[] = array( $results[] = array(
array( array(
'data' => $newdom->saveHTML(), 'data' => $newdom->saveHTML(),
'colspan' => 2 'colspan' => 2
) )
); );
} }
$header = array( $header = array(
array( array(
'data' => t('Collection results'), 'data' => t('Collection results'),
NULL, NULL,
), ),
(NULL) (NULL)
); );
$output .= theme('table', $header, $results); $output .= theme('table', $header, $results);
@ -1008,17 +1031,17 @@ function fedora_repository_form_alter(&$form, &$form_state, $form_id) {
$form['basic']['inline']['keys']['#default_value'] = $default_value; $form['basic']['inline']['keys']['#default_value'] = $default_value;
// Keyword boxes: // Keyword boxes:
$form['advanced'] = array( $form['advanced'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Advanced search'), '#title' => t('Advanced search'),
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => TRUE, '#collapsed' => TRUE,
'#attributes' => array( '#attributes' => array(
'class' => 'search-advanced' 'class' => 'search-advanced'
), ),
); );
$form['advanced']['keywords'] = array( $form['advanced']['keywords'] = array(
'#prefix' => '<div class="criterion">', '#prefix' => '<div class="criterion">',
'#suffix' => '</div>', '#suffix' => '</div>',
); );
$xmlDoc = new DomDocument(); $xmlDoc = new DomDocument();
$xmlDoc->load($path . '/searchTerms.xml'); $xmlDoc->load($path . '/searchTerms.xml');
@ -1027,15 +1050,15 @@ function fedora_repository_form_alter(&$form, &$form_state, $form_id) {
$types = $searchClass->get_search_terms_array(); $types = $searchClass->get_search_terms_array();
$form['advanced']['type'] = array( $form['advanced']['type'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Choose a field to search'), '#title' => t('Choose a field to search'),
'#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $types, '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $types,
'#default_value' => $type, '#default_value' => $type,
); );
$form['advanced']['submit'] = array( $form['advanced']['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Advanced search'), '#value' => t('Advanced search'),
'#prefix' => '<div class="action clear-block">', '#suffix' => '</div>', '#prefix' => '<div class="action clear-block">', '#suffix' => '</div>',
); );
$form['#validate'][] = 'fedora_repository_search_validate'; $form['#validate'][] = 'fedora_repository_search_validate';
} }
@ -1069,7 +1092,7 @@ function fedora_repository_block($op = 'list', $delta = 0, $edit = array()) {
// This is used to provide a list of possible blocks to the administrator, // This is used to provide a list of possible blocks to the administrator,
// end users will not see these descriptions. // end users will not see these descriptions.
$blocks[0] = array( $blocks[0] = array(
'info' => t('Repository advanced search block'), 'info' => t('Repository advanced search block'),
); );
return $blocks; return $blocks;
case 'configure': case 'configure':
@ -1083,11 +1106,11 @@ function fedora_repository_block($op = 'list', $delta = 0, $edit = array()) {
// All we need to provide is a text field, Drupal will take care of // All we need to provide is a text field, Drupal will take care of
// the other block configuration options and the save button. // the other block configuration options and the save button.
$form['fedora_repository_advanced_block_repeat'] = array( $form['fedora_repository_advanced_block_repeat'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Number of times to repeat search fields'), '#title' => t('Number of times to repeat search fields'),
'#size' => 5, '#size' => 5,
'#description' => t('The number of times you would like the search blocks to be repeated'), '#description' => t('The number of times you would like the search blocks to be repeated'),
'#default_value' => variable_get('fedora_repository_advanced_block_repeat', t('3')), '#default_value' => variable_get('fedora_repository_advanced_block_repeat', t('3')),
); );
break; break;
} }
@ -1121,16 +1144,16 @@ function fedora_repository_block($op = 'list', $delta = 0, $edit = array()) {
function fedora_repository_theme() { function fedora_repository_theme() {
return array( return array(
'fedora_repository_mnpl_advanced_search_form' => array( 'fedora_repository_mnpl_advanced_search_form' => array(
'arguments' => array( 'arguments' => array(
'form' => NULL, 'form' => NULL,
),
), ),
'fedora_repository_time' => array( ),
'arguments' => array( 'fedora_repository_time' => array(
'element' => NULL 'arguments' => array(
), 'element' => NULL
), ),
),
); );
} }
@ -1158,6 +1181,7 @@ function theme_fedora_repository_mnpl_advanced_search_form($form) {
function fedora_repository_mnpl_advanced_search($query, $startPage = 1) { function fedora_repository_mnpl_advanced_search($query, $startPage = 1) {
module_load_include('inc', 'fedora_repository', 'SearchClass'); module_load_include('inc', 'fedora_repository', 'SearchClass');
$searchClass = new SearchClass(); $searchClass = new SearchClass();
$retVal = $searchClass->custom_search($query, $startPage);
return $searchClass->custom_search($query, $startPage); return $searchClass->custom_search($query, $startPage);
} }
@ -1191,18 +1215,18 @@ function fedora_repository_demo_objects_form() {
$existing_demos = array(); $existing_demos = array();
$form['install_demos'] = array( $form['install_demos'] = array(
'#title' => t('Islandora Demo Collections'), '#title' => t('Islandora Demo Collections'),
'#type' => 'fieldset', '#type' => 'fieldset',
'#description' => t('Install demo image and document collections and content models.'), '#description' => t('Install demo image and document collections and content models.'),
); );
$demo_objects = array(); $demo_objects = array();
// Check if the top-level islandora collection exists. If not, display a button to ingest. // Check if the top-level islandora collection exists. If not, display a button to ingest.
$form['install_demos']['demo_collections'] = array( $form['install_demos']['demo_collections'] = array(
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#title' => t('Collections to ingest'), '#title' => t('Collections to ingest'),
'#options' => array(), '#options' => array(),
'#description' => t('Choose which demo collections you would like ingested into the repository.'), '#description' => t('Choose which demo collections you would like ingested into the repository.'),
); );
foreach (array( foreach (array(
@ -1221,7 +1245,8 @@ function fedora_repository_demo_objects_form() {
if (empty($demo_objects[$available_demo]->objectProfile)) { if (empty($demo_objects[$available_demo]->objectProfile)) {
//The demo objects collection does not exist in the repository, display a button to ingest them. //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; $form['install_demos']['demo_collections']['#options'][$available_demo] = $available_demo_desc;
} else { }
else {
array_push($existing_demos, $demo_objects[$available_demo]); array_push($existing_demos, $demo_objects[$available_demo]);
} }
} }
@ -1233,34 +1258,36 @@ function fedora_repository_demo_objects_form() {
$datastreams_list = $smiley_stuff->get_datastreams_list_as_array(); $datastreams_list = $smiley_stuff->get_datastreams_list_as_array();
if (empty($datastreams_list['COLLECTION_VIEW'])) { if (empty($datastreams_list['COLLECTION_VIEW'])) {
$form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection'; $form['install_demos']['demo_collections']['#options']['demo:SmileyStuff'] = 'Add Islandora Collection View to Fedora Smiley Stuff Collection';
} else { }
else {
$demo_objects['demo:SmileyStuff'] = $smiley_stuff; $demo_objects['demo:SmileyStuff'] = $smiley_stuff;
} }
} else { }
else {
$form['install_demos']['smileynote'] = array( $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>' '#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( $form['install_demos']['ingest'] = array(
'#type' => 'submit', '#type' => 'submit',
'#name' => 'install_demos', '#name' => 'install_demos',
'#value' => 'Install Selected Demos', '#value' => 'Install Selected Demos',
'#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE, '#disabled' => (empty($form['install_demos']['demo_collections']['#options'])) ? TRUE : FALSE,
); );
$form['existing_demos'] = array( $form['existing_demos'] = array(
'#prefix' => '<p>Demo collections already installed in this repository:</p><ul>', '#prefix' => '<p>Demo collections already installed in this repository:</p><ul>',
'#suffix' => '</ul>', '#suffix' => '</ul>',
); );
if (!empty($existing_demos)) { if (!empty($existing_demos)) {
foreach ($existing_demos as $pid => $demo_object) { foreach ($existing_demos as $pid => $demo_object) {
$form['existing_demos'][$demo_object->pid] = array ( $form['existing_demos'][$demo_object->pid] = array(
'#prefix' => '<li>', '#prefix' => '<li>',
'#value' => l($demo_object->pid, $demo_object->url()), '#value' => l($demo_object->pid, $demo_object->url()),
'#suffix' => '</li>', '#suffix' => '</li>',
); );
} }
} }
@ -1365,7 +1392,7 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) { if (!empty($form_state['values']['demo_collections']['islandora:largeimages'])) {
$error = ''; $error = '';
foreach (array('islandora_jp2Sdep-slideCModel.xml', 'islandora_mods2htmlSdef.xml', 'islandora_mods2htmlSdep.xml', 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 { try {
$item = Fedora_Item::ingest_from_FOXML_file(drupal_get_path('module', 'fedora_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) { } catch (exception $e) {
@ -1393,8 +1420,8 @@ function fedora_repository_demo_objects_form_submit($form, &$form_state) {
function fedora_repository_elements() { function fedora_repository_elements() {
$type['fedora_repository_time'] = array( $type['fedora_repository_time'] = array(
"#input" => TRUE, "#input" => TRUE,
"#process" => array("fedora_repository_expand_time"), "#process" => array("fedora_repository_expand_time"),
); );
return $type; return $type;
@ -1405,8 +1432,8 @@ function fedora_repository_expand_time($element) {
// default value is present it will override value // default value is present it will override value
if (empty($element['#default_value'])) { if (empty($element['#default_value'])) {
$element['#value'] = array( $element['#value'] = array(
'hour' => intval(format_date(time(), 'custom', 'h')), 'hour' => intval(format_date(time(), 'custom', 'h')),
'minute' => intval(format_date(time(), 'custom', 'i')), 'minute' => intval(format_date(time(), 'custom', 'i')),
); );
} }
@ -1429,9 +1456,9 @@ function fedora_repository_expand_time($element) {
} }
$element[$type] = array( $element[$type] = array(
'#type' => 'select', '#type' => 'select',
'#default_value' => $element['#value'][$type], '#default_value' => $element['#value'][$type],
'#options' => $options, '#options' => $options,
); );
} }
@ -1485,7 +1512,8 @@ function fedora_repository_basket_form($form_state, $pids) {
$form['pid'] = array(); $form['pid'] = array();
$form['title'] = array(); $form['title'] = array();
$form['desc'] = array(); $form['desc'] = array();
} else { }
else {
return; return;
} }
@ -1499,28 +1527,28 @@ function fedora_repository_basket_form($form_state, $pids) {
} }
$form['remove'] = array( $form['remove'] = array(
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#options' => $cbs, '#options' => $cbs,
); );
$form['remove_submit'] = array( $form['remove_submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Remove selected'), '#value' => t('Remove selected'),
); );
$form['remove_all'] = array( $form['remove_all'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Empty basket'), '#value' => t('Empty basket'),
); );
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Export selected'), '#value' => t('Export selected'),
); );
$form['submit_all'] = array( $form['submit_all'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Export all'), '#value' => t('Export all'),
); );
return $form; return $form;
@ -1528,22 +1556,23 @@ function fedora_repository_basket_form($form_state, $pids) {
function theme_fedora_repository_basket_form($form) { function theme_fedora_repository_basket_form($form) {
$header = array( $header = array(
theme('table_select_header_cell'), theme('table_select_header_cell'),
t('PID'), t('PID'),
t('Title'), t('Title'),
t('Description'), t('Description'),
); );
if (isset($form['pid']) && is_array($form['pid'])) { if (isset($form['pid']) && is_array($form['pid'])) {
foreach (element_children($form['pid']) as $key) { foreach (element_children($form['pid']) as $key) {
$rows[] = array( $rows[] = array(
drupal_render($form['remove'][$key]), drupal_render($form['remove'][$key]),
drupal_render($form['pid'][$key]), drupal_render($form['pid'][$key]),
drupal_render($form['title'][$key]), drupal_render($form['title'][$key]),
drupal_render($form['desc'][$key]), drupal_render($form['desc'][$key]),
); );
} }
} else { }
else {
$rows[] = array(array('data' => t('Your basket is empty.'), 'colspan' => '4')); $rows[] = array(array('data' => t('Your basket is empty.'), 'colspan' => '4'));
} }
@ -1581,7 +1610,8 @@ function fedora_repository_basket_form_submit($form, &$form_state) {
if ($form_state['values']['op'] == $form_state['values']['submit_all']) { if ($form_state['values']['op'] == $form_state['values']['submit_all']) {
$msg = t("All objects exported to staging area"); $msg = t("All objects exported to staging area");
$pids = _fedora_repository_get_basket_pids(); $pids = _fedora_repository_get_basket_pids();
} elseif ($form_state['values']['op'] == $form_state['values']['submit']) { }
elseif ($form_state['values']['op'] == $form_state['values']['submit']) {
$msg = t("Selected objects exported to staging area"); $msg = t("Selected objects exported to staging area");
$pids = array_filter($form_state['values']['remove']); $pids = array_filter($form_state['values']['remove']);
} }
@ -1616,7 +1646,8 @@ function fedora_repository_basket_form_submit($form, &$form_state) {
drupal_set_message($msg, $success ? 'info' : 'error'); drupal_set_message($msg, $success ? 'info' : 'error');
//_fedora_repository_empty_basket(); //_fedora_repository_empty_basket();
} else { }
else {
drupal_set_message(t("No objects selected or basket empty"), 'error'); drupal_set_message(t("No objects selected or basket empty"), 'error');
} }
@ -1666,7 +1697,8 @@ function fedora_repository_add_to_basket($pid, $warn = TRUE, $searchResultsFlag
if (!isset($_SESSION['basket'])) { if (!isset($_SESSION['basket'])) {
$_SESSION['basket'] = array(); $_SESSION['basket'] = array();
$_SESSION['basket']['unprocessed'] = array($pid => $pid); $_SESSION['basket']['unprocessed'] = array($pid => $pid);
} else { }
else {
$_SESSION['basket']['unprocessed'][$pid] = $pid; $_SESSION['basket']['unprocessed'][$pid] = $pid;
} }
@ -1700,9 +1732,9 @@ function theme_add_to_basket_link($pid, $type = 'object') {
*/ */
if (!_is_added_to_basket($pid)) { if (!_is_added_to_basket($pid)) {
return l( 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))), 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, "fedora/repository/addToBasket/" . $path,
array('html' => TRUE) array('html' => TRUE)
); );
} }
@ -1718,7 +1750,8 @@ function fedora_repository_display_schema($file) {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) { if (strtolower(substr($file, -3)) == 'xsd' && file_exists($path . '/' . $file)) {
drupal_goto($path . '/' . $file); drupal_goto($path . '/' . $file);
} else { }
else {
drupal_goto(); drupal_goto();
} }
return; return;

714
formClass.inc

@ -4,9 +4,6 @@
/* /*
* Created on Jan 22, 2008 * Created on Jan 22, 2008
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/ */
class formClass { class formClass {
@ -24,201 +21,175 @@ class formClass {
$items = array(); $items = array();
$items['admin/settings/fedora_repository'] = array( $items['admin/settings/fedora_repository'] = array(
'title' => t('Fedora collection list'), 'title' => t('Fedora collection list'),
'description' => t('Enter the Fedora Collection information here'), 'description' => t('Enter the Fedora Collection information here'),
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('fedora_repository_admin'), 'page arguments' => array('fedora_repository_admin'),
//'access' => user_access('access administration pages'), 'access arguments' => array('administer site configuration'),
'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM,
'type' => MENU_NORMAL_ITEM,
// 'type' => MENU_DEFAULT_LOCAL_TASK,
); );
$items['admin/settings/fedora_repository/collection'] = array( $items['admin/settings/fedora_repository/collection'] = array(
'title' => t('Collection list'), 'title' => t('Collection list'),
'description' => t('Enter the Fedora collection information here.'), 'description' => t('Enter the Fedora collection information here.'),
'access arguments' => array('administer site configuration'), 'access arguments' => array('administer site configuration'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0, 'weight' => 0,
); );
$items['admin/settings/fedora_repository/demoobjects'] = array( $items['admin/settings/fedora_repository/demoobjects'] = array(
'title' => t('Install demos'), 'title' => t('Install demos'),
'description' => t('Install example content models and collections to get started using Islandora and Fedora.'), 'description' => t('Install example content models and collections to get started using Islandora and Fedora.'),
'page callback' => 'fedora_repository_install_demos_page', 'page callback' => 'fedora_repository_install_demos_page',
'access arguments' => array('add fedora datastreams'), 'access arguments' => array('add fedora datastreams'),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
); );
$items['islandoracm.xsd'] = array( $items['islandoracm.xsd'] = array(
'title' => t('Islandoracm XML Schema Definition'), 'title' => t('Islandoracm XML Schema Definition'),
'page callback' => 'fedora_repository_display_schema', 'page callback' => 'fedora_repository_display_schema',
'page arguments' => array('islandoracm.xsd'), 'page arguments' => array('islandoracm.xsd'),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
// 'page arguments'=>array(1), 'access arguments' => array('view fedora collection'),
'access arguments' => array('view fedora collection'), );
// 'access' => TRUE
);
$items['collection_policy.xsd'] = array( $items['collection_policy.xsd'] = array(
'title' => t('Islandoracm XML Schema Definition'), 'title' => t('Islandoracm XML Schema Definition'),
'page callback' => 'fedora_repository_display_schema', 'page callback' => 'fedora_repository_display_schema',
'page arguments' => array('collection_policy.xsd'), 'page arguments' => array('collection_policy.xsd'),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
// 'page arguments'=>array(1), 'access arguments' => array('view fedora collection'),
'access arguments' => array('view fedora collection'), );
// 'access' => TRUE
);
$items['fedora'] = array( $items['fedora'] = array(
// 'title' => t('Digital repository'), 'page callback' => 'repository_page',
'page callback' => 'repository_page', 'type' => MENU_CALLBACK,
'type' => MENU_CALLBACK, 'access arguments' => array('view fedora collection'),
// 'page arguments'=>array(1), );
'access arguments' => array('view fedora collection'), $repository_title = variable_get('fedora_repository_title', 'Digital repository');
// 'access' => TRUE if (trim($repository_title) != '') {
); $respository_title = t($repository_title);
$repository_title = variable_get('fedora_repository_title','Digital repository'); }
if (trim($repository_title)!= '') { else {
$respository_title=t($repository_title); $repository_title = NULL;
} else {
$repository_title= NULL;
} }
$items['fedora/repository'] = array( $items['fedora/repository'] = array(
'title' => $repository_title, 'title' => $repository_title,
'page callback' => 'repository_page', 'page callback' => 'repository_page',
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
// 'page arguments'=>array(1), 'access arguments' => array('view fedora collection'),
'access arguments' => array('view fedora collection'), // 'access' => TRUE
// 'access' => TRUE
); );
$items['fedora/repository/service'] = array( $items['fedora/repository/service'] = array(
'page callback' => 'repository_service', 'page callback' => 'repository_service',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
); );
$items['fedora/repository/object_download'] = array( $items['fedora/repository/object_download'] = array(
'title' => t('Download object'), 'title' => t('Download object'),
'page callback' => 'fedora_object_as_attachment', 'page callback' => 'fedora_object_as_attachment',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection') 'access arguments' => array('view fedora collection')
); );
$items['fedora/repository/editmetadata'] = array( $items['fedora/repository/editmetadata'] = array(
'title' => t('Edit metadata'), 'title' => t('Edit metadata'),
'page callback' => 'fedora_repository_edit_qdc_page', 'page callback' => 'fedora_repository_edit_qdc_page',
// 'page arguments' => array(1), // 'page arguments' => array(1),
//'type' => MENU_LOCAL_TASK, //'type' => MENU_LOCAL_TASK,
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('edit fedora meta data') 'access arguments' => array('edit fedora meta data')
); );
$items['fedora/repository/purgeStream'] = array( $items['fedora/repository/purgeStream'] = array(
'title' => t('Purge data stream'), 'title' => t('Purge data stream'),
'page callback' => 'fedora_repository_purge_stream', 'page callback' => 'fedora_repository_purge_stream',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('purge objects and datastreams') 'access arguments' => array('purge objects and datastreams')
); );
$items['fedora/repository/replaceStream'] = array( $items['fedora/repository/replaceStream'] = array(
'title' => t('Replace Stream'), 'title' => t('Replace Stream'),
'page callback' => 'fedora_repository_replace_stream', 'page callback' => 'fedora_repository_replace_stream',
// 'callback arguments' => array(3, 4), // 'callback arguments' => array(3, 4),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
// 'access callback' => 'fedora_repository_user_access', // 'access callback' => 'fedora_repository_user_access',
'access arguments' => array('add fedora datastreams'), 'access arguments' => array('add fedora datastreams'),
); );
$items['fedora/repository/purgeObject'] = array( $items['fedora/repository/purgeObject'] = array(
'title' => t('Purge object'), 'title' => t('Purge object'),
'page callback' => 'fedora_repository_purge_object', 'page callback' => 'fedora_repository_purge_object',
// 'type' => MENU_LOCAL_TASK, // 'type' => MENU_LOCAL_TASK,
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('purge objects and datastreams') 'access arguments' => array('purge objects and datastreams')
); );
$items['fedora/repository/addStream'] = array( $items['fedora/repository/addStream'] = array(
'title' => t('Add stream'), 'title' => t('Add stream'),
'page callback' => 'add_stream', 'page callback' => 'add_stream',
// 'type' => MENU_LOCAL_TASK, // 'type' => MENU_LOCAL_TASK,
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('add fedora datastreams') 'access arguments' => array('add fedora datastreams')
); );
$items['fedora/repository/collection'] = array( $items['fedora/repository/collection'] = array(
'title' => t('Collection view'), 'title' => t('Collection view'),
'page callback' => 'fedora_collection_view', 'page callback' => 'fedora_collection_view',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access argruments' => array('view fedora collection') 'access argruments' => array('view fedora collection')
); );
//new for mnpl****************************************** //new for mnpl******************************************
$items['fedora/repository/mnpl_advanced_search'] = array( $items['fedora/repository/mnpl_advanced_search'] = array(
'title' => t('Repository advanced search'), 'title' => t('Repository advanced search'),
'page callback' => 'fedora_repository_mnpl_advanced_search', 'page callback' => 'fedora_repository_mnpl_advanced_search',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection') 'access arguments' => array('view fedora collection')
); );
$items['fedora/ingestObject'] = array( $items['fedora/ingestObject'] = array(
'title' => t('Ingest object'), 'title' => t('Ingest object'),
'page callback' => 'fedora_repository_ingest_object', 'page callback' => 'fedora_repository_ingest_object',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('add fedora datastreams') 'access arguments' => array('add fedora datastreams')
); );
$items['fedora/repository/list_terms'] = array( $items['fedora/repository/list_terms'] = array(
'title' => t('List terms'), 'title' => t('List terms'),
'page callback' => 'fedora_repository_list_terms', 'page callback' => 'fedora_repository_list_terms',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection') 'access arguments' => array('view fedora collection')
); );
$items['fedora/tagging/add_tag/js'] = array( $items['fedora/tagging/add_tag/js'] = array(
'page callback' => 'fedora_tagging_add_tag_js', 'page callback' => 'fedora_tagging_add_tag_js',
'access arguments' => array('edit tags datastream'), 'access arguments' => array('edit tags datastream'),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
); );
/* Export functionality */ /* Export functionality */
$items['fedora/basket'] = array( $items['fedora/basket'] = array(
'title' => t('Fedora Basket'), 'title' => t('Fedora Basket'),
'description' => t('View and download objects added to your basket'), 'description' => t('View and download objects added to your basket'),
'page callback' => 'fedora_repository_basket', 'page callback' => 'fedora_repository_basket',
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
); );
$items['fedora/repository/addToBasket'] = array( $items['fedora/repository/addToBasket'] = array(
'page callback' => 'fedora_repository_add_to_basket', 'page callback' => 'fedora_repository_add_to_basket',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
); );
$items['fedora/repository/removeFromBasket'] = array( $items['fedora/repository/removeFromBasket'] = array(
'page callback' => 'fedora_repository_remove_from_basket', 'page callback' => 'fedora_repository_remove_from_basket',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
); );
$items['fedora/repository/add_search_results_to_basket'] = array( $items['fedora/repository/add_search_results_to_basket'] = array(
'page callback' => 'fedora_repository_add_search_results_to_basket', 'page callback' => 'fedora_repository_add_search_results_to_basket',
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection'),
);
/*
$items['fedora/item'] = array (
'title' => t('Repository Item'),
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
'page callback' => 'fedora_repository_item', );
'type' => MENU_NORMAL_ITEM,
);
$item['feodra/item/view'] = array (
'title' => t('View Repository Item'),
'access arguments' => array('view fedora collection'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
*/
// $items = array_merge($items,$irItems);
return $items; return $items;
} }
@ -228,194 +199,182 @@ class formClass {
return; return;
} }
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$form = array(); $form = array();
$form['fedora_repository_name'] = array( $form['fedora_repository_name'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Default collection name'), '#title' => t('Default collection name'),
'#default_value' => variable_get('fedora_repository_name', 'Islandora demos collection'), '#default_value' => variable_get('fedora_repository_name', 'Islandora demos collection'),
'#description' => t('The Name of the collection to grab the list of items from'), '#description' => t('The Name of the collection to grab the list of items from'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => -2 '#weight' => -2
); );
$form['fedora_repository_pid'] = array( $form['fedora_repository_pid'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Default collection PID'), '#title' => t('Default collection PID'),
'#default_value' => variable_get('fedora_repository_pid', 'islandora:top'), '#default_value' => variable_get('fedora_repository_pid', 'islandora:top'),
'#description' => t('The PID of the collection object to grab the list of items from'), '#description' => t('The PID of the collection object to grab the list of items from'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => -2 '#weight' => -2
); );
$form['fedora_collection_model_pid'] = array( $form['fedora_collection_model_pid'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Default Collection Model PID'), '#title' => t('Default Collection Model PID'),
'#default_value' => variable_get('fedora_collection_model_pid', 'islandora:collectionCModel'), '#default_value' => variable_get('fedora_collection_model_pid', 'islandora:collectionCModel'),
'#description' => t('The PID of the default Collection Model Object'), '#description' => t('The PID of the default Collection Model Object'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => -2 '#weight' => -2
); );
$form['fedora_content_model_collection_pid'] = array( $form['fedora_content_model_collection_pid'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Default Content Model Collection PID'), '#title' => t('Default Content Model Collection PID'),
'#default_value' => variable_get('fedora_content_model_collection_pid', 'islandora:ContentModelCollection'), '#default_value' => variable_get('fedora_content_model_collection_pid', 'islandora:ContentModelCollection'),
'#description' => t('The PID of the Content Model Collection Object'), '#description' => t('The PID of the Content Model Collection Object'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => -2 '#weight' => -2
); );
$form['fedora_repository_url'] = array( $form['fedora_repository_url'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora RISearch URL'), '#title' => t('Fedora RISearch URL'),
'#default_value' => variable_get('fedora_repository_url', '#default_value' => variable_get('fedora_repository_url',
'http://localhost:8080/fedora/risearch'), 'http://localhost:8080/fedora/risearch'),
'#description' => t('The url of the Fedora server'), '#required' => TRUE, '#description' => t('The url of the Fedora server'), '#required' => TRUE,
'#weight' => 0 '#weight' => 0
); );
$form['fedora_fgsearch_url'] = array( $form['fedora_fgsearch_url'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora Lucene search URL'), '#title' => t('Fedora Lucene search URL'),
'#default_value' => variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest'), '#default_value' => variable_get('fedora_fgsearch_url', 'http://localhost:8080/fedoragsearch/rest'),
'#description' => t('The url of the Lucene Fedora server'), '#description' => t('The url of the Lucene Fedora server'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => 0 '#weight' => 0
); );
$form['fedora_index_name'] = array( $form['fedora_index_name'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora Lucene index name'), '#title' => t('Fedora Lucene index name'),
'#default_value' => variable_get('fedora_index_name', 'BasicIndex'), '#default_value' => variable_get('fedora_index_name', 'BasicIndex'),
'#description' => t('The name of the Lucene index to search'), '#description' => t('The name of the Lucene index to search'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => 0 '#weight' => 0
); );
$form['fedora_soap_url'] = array( $form['fedora_soap_url'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora SOAP Url'), '#title' => t('Fedora SOAP Url'),
'#default_value' => variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'), '#default_value' => variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'),
'#description' => t('The URL to use for SOAP connections'), '#description' => t('The URL to use for SOAP connections'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => 0, '#weight' => 0,
// '#suffix' => '<p>'. (fedora_available() ? '<img src="'. url('misc/watchdog-ok.png') . '"/>'. t('Successfully connected to Fedora server at ') : '<img src="'. url('misc/watchdog-error.png') . '"/> '. t('Unable to connect to Fedora server at ')) . variable_get('fedora_soap_url', '') . '</p>', '#suffix' => '<p>' . (fedora_available() ? '<img src="' . url('misc/watchdog-ok.png') . '"/>' . t('Successfully connected to Fedora server at !fedora_soap_url', array('!fedora_soap_url' => variable_get('fedora_soap_url', ''))) : '<img src="' . url('misc/watchdog-error.png') . '"/> ' . t('Unable to connect to Fedora server at !fedora_soap_url</p>', array('!fedora_soap_url' => variable_get('fedora_soap_url', '')))),
'#suffix' => '<p>' . (fedora_available() ? '<img src="' . url('misc/watchdog-ok.png') . '"/>' . t('Successfully connected to Fedora server at !fedora_soap_url', array('!fedora_soap_url' => variable_get('fedora_soap_url', ''))) : '<img src="' . url('misc/watchdog-error.png') . '"/> ' . t('Unable to connect to Fedora server at !fedora_soap_url</p>', array('!fedora_soap_url' => variable_get('fedora_soap_url', '')))),
); );
$form['fedora_base_url'] = array( $form['fedora_base_url'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora base URL'), '#title' => t('Fedora base URL'),
'#default_value' => variable_get('fedora_base_url', 'http://localhost:8080/fedora'), '#default_value' => variable_get('fedora_base_url', 'http://localhost:8080/fedora'),
'#description' => t('The URL to use for REST-type connections'), '#description' => t('The URL to use for REST-type connections'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => 0, '#weight' => 0,
); );
$form['fedora_soap_manage_url'] = array( $form['fedora_soap_manage_url'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora SOAP management URL'), '#title' => t('Fedora SOAP management URL'),
'#default_value' => variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'), '#description' => t('The URL to use for SOAP API-M connections'), '#default_value' => variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'), '#description' => t('The URL to use for SOAP API-M connections'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => 0 '#weight' => 0
); );
$form['fedora_solr_search_url'] = array( $form['fedora_solr_search_url'] = array(
'#type' => 'textfield',
'#title' => t('Fedora Solr search URL'),
'#default_value' => variable_get('fedora_solr_search_url', 'http://localhost:8080/solr'), '#description' => t('The URL to use for Solr searching'),
'#required' => TRUE,
'#weight' => 0
);
/*
$form['fedora_default_display_pid'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora Default Display Object Pid' ), '#title' => t('Fedora Solr search URL'),
'#default_value' => variable_get('fedora_default_display_pid', 'demo:10'), '#default_value' => variable_get('fedora_solr_search_url', 'http://localhost:8080/solr'), '#description' => t('The URL to use for Solr searching'),
'#description' => t('Object Pid of an Image to show if the requested pid/datastream cannot be found'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => 0 '#weight' => 0
);
// will allow admin user to remove namepsace restrictions if not explicitly disallowed in settings.php
if (variable_get('allow_open_namespace', TRUE)) {
$form['fedora_namespace'] = array(
'#type' => 'fieldset',
); );
$form['fedora_default_display_dsid'] = array(
'#type' => 'textfield', $form['fedora_namespace']['fedora_namespace_restriction_enforced'] = array(
'#title' => t('Fedora Default Display Datastream ID' ), '#weight' => -1,
'#default_value' => variable_get('fedora_default_display_dsid', 'TN'), '#type' => 'radios',
'#description' => t('Object Datastream id of an Image to show if the requested pid/datastream cannot be found'), '#title' => t('Enforce namespace restrictions'),
'#required' => TRUE, '#options' => array(
'#weight' => 0 TRUE => t('Enabled'),
FALSE => t('Disabled')
),
'#description' => t('Allow administrator to restrict user\'s access to the PID namepaces listed below'),
'#default_value' => variable_get('fedora_namespace_restriction_enforced', TRUE)
); );
*/
$form['fedora_pids_allowed'] = array( $form['fedora_namespace']['fedora_pids_allowed'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('PID namespaces allowed in this Drupal install'), '#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: '), '#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '),
'#description' => t('The PID namespaces that you are allowed to see from this Drupal install. In reality this can be more than a namespace as it could include demo:mydemos etc. Can be a space seperated list to include more than one PID namespace.'), '#description' => t('A space separated list PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'),
'#required' => TRUE,
'#weight' => 0 '#weight' => 0
);
/*
$form['fedora_admin_user'] = array(
'#type' => 'textfield',
'#title' => t('A user with the Drupal role administrator'),
'#default_value' => variable_get('fedora_admin_user', 'admin'),
'#description' => t('A user with the administrator role. This is the user the Islandora module will use when admin access is needed for a task, such as creating a collection object for a new user.'),
'#required' => TRUE, '#weight' => 0
); );
}
$form['fedora_searchterms_location'] = array( else {
'#type' => 'file', $form['fedora_pids_allowed'] = array(
'#title' => 'SearchTerms.xml file location', '#type' => 'textfield',
'#title' => t('PID namespaces allowed in this Drupal install'),
'#default_value' => variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: '),
'#description' => t('A space separated list PID namespaces that users are permitted to access from this Drupal installation. <br /> This could be more than a simple namespace ie demo:mydemos.'),
'#weight' => 0
); );
*/ }
$form['fedora_repository_title'] = array( $form['fedora_repository_title'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Fedora Repository Title'), '#title' => t('Fedora Repository Title'),
'#default_value'=> variable_get('fedora_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.'), '#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['fedora_object_display_title'] = array( $form['fedora_object_display_title'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Display Object Title Behaviour'), '#title' => t('Display Object Title Behaviour'),
'#default_value'=> variable_get('fedora_object_display_title', ObjectHelper::$DISPLAY_ALWAYS), '#default_value' => variable_get('fedora_object_display_title', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')), '#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')),
'#description' => t('Determines when to display the object (or collection) title when viewing an object/collection page.'), '#description' => t('Determines when to display the object (or collection) title when viewing an object/collection page.'),
); );
$form['fedora_object_display_description'] = array( $form['fedora_object_display_description'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Display Object Description Behaviour'), '#title' => t('Display Object Description Behaviour'),
'#default_value'=> variable_get('fedora_object_display_description', ObjectHelper::$DISPLAY_ALWAYS), '#default_value' => variable_get('fedora_object_display_description', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')), '#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')),
'#description' => t('Determines when to display the default object (or collection) description fieldset when viewing an object/collection page.'), '#description' => t('Determines when to display the default object (or collection) description fieldset when viewing an object/collection page.'),
); );
$form['fedora_object_restrict_datastreams'] = array( $form['fedora_object_restrict_datastreams'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Restrict Access to Fedora Object Datastreams'), '#title' => t('Restrict Access to Fedora Object Datastreams'),
'#default_value'=> variable_get('fedora_object_restrict_datastreams', FALSE), '#default_value' => variable_get('fedora_object_restrict_datastreams', FALSE),
'#description' => t('When enabled, restricts access to fedora object datastreams that are not listed in the Islandora Content Model for the object (unless the user is an administrator).'), '#description' => t('When enabled, restricts access to fedora object datastreams that are not listed in the Islandora Content Model for the object (unless the user is an administrator).'),
); );
$form['fedora_collection_display_list'] = array( $form['fedora_collection_display_list'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Display Collection List Behaviour'), '#title' => t('Display Collection List Behaviour'),
'#default_value'=> variable_get('fedora_collection_display_list', ObjectHelper::$DISPLAY_ALWAYS), '#default_value' => variable_get('fedora_collection_display_list', ObjectHelper::$DISPLAY_ALWAYS),
'#options' => array(ObjectHelper::$DISPLAY_ALWAYS=>t('Always'),ObjectHelper::$DISPLAY_NEVER=>t('Never'),ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT=>t('Only if no Content Model display output.')), '#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')),
'#description' => t('Determines when to display the list of objects when viewing a collection page.'), '#description' => t('Determines when to display the list of objects when viewing a collection page.'),
); );
//Export functionality //Export functionality
$form['module']['export_area'] = array( $form['module']['export_area'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Export area'), '#title' => t('Export area'),
'#default_value' => variable_get('export_area', file_directory_path() . '/fedora_export_area'), '#default_value' => variable_get('export_area', file_directory_path() . '/fedora_export_area'),
'#description' => t("Path to the export area. It must be accessible by druapl (i.e. apache user)."), '#description' => t("Path to the export area. It must be accessible by druapl (i.e. apache user)."),
'#required' => TRUE, '#required' => TRUE,
); );
$form['#attributes'] = array('enctype' => "multipart/form-data"); $form['#attributes'] = array('enctype' => "multipart/form-data");
@ -451,7 +410,7 @@ class formClass {
if (!strcmp(substr($key, 0, 4), 'app_')) { if (!strcmp(substr($key, 0, 4), 'app_')) {
$key = substr($key, 4); $key = substr($key, 4);
$previousElement->appendChild($dom->createElement($key, $value)); $previousElement->appendChild($dom->createElement($key, $value));
} }
else { else {
$previousElement = $dom->createElement($key, $value); $previousElement = $dom->createElement($key, $value);
$oai->appendChild($previousElement); $oai->appendChild($previousElement);
@ -472,14 +431,14 @@ class formClass {
$pid = $form_values['pid']; $pid = $form_values['pid'];
$dsId = $form_values['dsid']; $dsId = $form_values['dsid'];
$params = array( $params = array(
"pid" => $pid, "pid" => $pid,
"dsID" => $dsId, "dsID" => $dsId,
"altIDs" => "", "altIDs" => "",
"dsLabel" => "Qualified Dublin Core", "dsLabel" => "Qualified Dublin Core",
"MIMEType" => "text/xml", "MIMEType" => "text/xml",
"formatURI" => "URL", "formatURI" => "URL",
"dsContent" => $dom->saveXML(), "checksumType" => "DISABLED", "checksum" => "none", "dsContent" => $dom->saveXML(), "checksumType" => "DISABLED", "checksum" => "none",
"logMessage" => "datastream_modified", "force" => "TRUE"); "logMessage" => "datastream_modified", "force" => "TRUE");
try { try {
$object = $client->__soapCall('ModifyDatastreamByValue', array($params)); $object = $client->__soapCall('ModifyDatastreamByValue', array($params));
} catch (exception $e) { } catch (exception $e) {
@ -544,17 +503,16 @@ class formClass {
switch ($form_state['storage']['step']) { switch ($form_state['storage']['step']) {
case 1: case 1:
$form['indicator'] = array( $form['indicator'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Ingest digital object into collection_pid !collection_label Step #1', array('collection_pid' => $collection_pid, '!collection_label' => $collection_label)) '#title' => t('Ingest digital object into collection_pid !collection_label Step #1', array('collection_pid' => $collection_pid, '!collection_label' => $collection_label))
); );
$form['indicator']['models'] = array(// content models available $form['indicator']['models'] = array(// content models available
'#type' => 'select', '#type' => 'select',
'#title' => t('Content models available'), '#title' => t('Content models available'),
'#options' => $modelsForForm, '#options' => $modelsForForm,
//'#description' => t('Content models available in this collection. A content model defines what is allowed in a collection and what to do with a file when it is uploaded (An example may creating a thumbnail from an image.).') //'#description' => t('Content models available in this collection. A content model defines what is allowed in a collection and what to do with a file when it is uploaded (An example may creating a thumbnail from an image.).')
'#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a> ') '#description' => t('Content models define datastream composition, relationships between this and other content models, and the mandatory behaviors associated with each digital object.<br /> Additional information may be found <a href="https://wiki.duraspace.org/display/FEDORACREATE/Content+Models+Overview">here.</a> ')
); );
break; break;
@ -578,22 +536,22 @@ class formClass {
} }
$form['collection_pid'] = array( $form['collection_pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => $collection_pid '#value' => $collection_pid
); );
if ($form_state['storage']['step'] < 2) { if ($form_state['storage']['step'] < 2) {
$button_name = t('Next'); $button_name = t('Next');
} }
else { else {
$prefix = t('Please be patient. Once you click next there may be a number of files created. Depending on your content model this could take a few minutes to process.<br />'); $prefix = t('Please be patient. Once you click next there may be a number of files created. Depending on your content model this could take a few minutes to process.<br />');
$button_name = t('Ingest'); $button_name = t('Ingest');
} }
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#submit' => array('fedora_repository_ingest_form_submit'), '#submit' => array('fedora_repository_ingest_form_submit'),
'#value' => $button_name '#value' => $button_name
); );
return $form; return $form;
@ -633,13 +591,13 @@ class formClass {
if ($form_state['submitted'] && $form_state['clicked_button']['#value'] != 'OK') { if ($form_state['submitted'] && $form_state['clicked_button']['#value'] != 'OK') {
$form['add_datastream_label'] = array( $form['add_datastream_label'] = array(
'#value' => t('<br /><h3>The datastream has been uploaded.</h3>'), '#value' => t('<br /><h3>The datastream has been uploaded.</h3>'),
'#weight' => -10, '#weight' => -10,
); );
$form['#redirect'] = "fedora/repository/$pid/"; $form['#redirect'] = "fedora/repository/$pid/";
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('OK') '#value' => t('OK')
); );
return $form; return $form;
} }
@ -651,49 +609,34 @@ class formClass {
} }
$form['add_datastream_label'] = array( $form['add_datastream_label'] = array(
'#value' => t('<br /><h3>Add Datastream:</h3>'), '#value' => t('<br /><h3>Add Datastream:</h3>'),
'#weight' => -10, '#weight' => -10,
); );
$form['pid'] = array( $form['pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$pid" '#value' => "$pid"
); );
/*
$form['stream_location'] = array (
'#title' => 'File Location',
'#required' => 'TRUE',
'#description' => 'The path to the file for the new datastream',
//'#prefix' => '<a onclick="window.open(\'?q=imce/browse\', \'_imce_fedora_\', \'width=640, height=600, resizable=1\')" href="#">Upload File</a>',
'#type' => 'hidden'
);
*/
$form['stream_label'] = array( $form['stream_label'] = array(
'#title' => 'Datastream Label', '#title' => 'Datastream Label',
'#required' => 'TRUE', '#required' => 'TRUE',
'#description' => t('A Human readable label'), '#description' => t('A Human readable label'),
'#type' => 'textfield' '#type' => 'textfield'
); );
// $form['delete_file'] = array (
// '#title' => 'Remove File After Ingest',
// '#description' => 'Remove the file from the drupal file system after ingest into the Digital Repository.',
// '#type' => 'hidden',
// '#default_value' => 'remove_file',
// '#options' => $options
// );
$form['#attributes']['enctype'] = 'multipart/form-data'; $form['#attributes']['enctype'] = 'multipart/form-data';
$form['add-stream-file-location'] = array( $form['add-stream-file-location'] = array(
'#type' => 'file', '#type' => 'file',
'#title' => t('Upload Document'), '#title' => t('Upload Document'),
'#size' => 48, '#size' => 48,
// '#required'=>'TRUE', // '#required'=>'TRUE',
'#description' => t('The file to upload.') '#description' => t('The file to upload.')
); );
$form['#redirect'] = "fedora/repository/$pid/"; $form['#redirect'] = "fedora/repository/$pid/";
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Add Datastream') '#value' => t('Add Datastream')
); );
if (!empty($unused_dsids)) { if (!empty($unused_dsids)) {
@ -702,21 +645,23 @@ class formClass {
$dsidsForForm[$dsid]=$dsid; $dsidsForForm[$dsid]=$dsid;
} }
$form['stream_id'] = array( $form['stream_id'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Datastream ID'), '#title' => t('Datastream ID'),
'#default_value' => variable_get('feed_item_length', 'teaser'), '#default_value' => variable_get('feed_item_length', 'teaser'),
'#weight' => '-1', '#weight' => '-1',
'#description' => t('Datastream IDs defined by the content model.'), '#description' => t('Datastream IDs defined by the content model.'),
); );
$form['stream_id']['#options'] = $dsidsForForm; $form['stream_id']['#options'] = $dsidsForForm;
} }
else { else {
$form['stream_id'] = array( $form['stream_id'] = array(
'#title' => 'Datastream ID', '#title' => 'Datastream ID',
'#required' => 'TRUE', '#required' => 'TRUE',
'#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores.'), '#description' => t('An ID for this stream that is unique to this object. Must start with a letter and contain only alphanumeric characters and dashes and underscores.'),
'#type' => 'textfield', '#type' => 'textfield',
'#weight' => -1, '#weight' => -1,
); );
} }
return $form; return $form;
@ -753,31 +698,31 @@ class formClass {
$name = $dcItems->item($i)->nodeName; $name = $dcItems->item($i)->nodeName;
if ($name == 'dc:description') { if ($name == 'dc:description') {
$form["$name" . '-' . "$i"] = array( $form["$name" . '-' . "$i"] = array(
'#title' => $name, '#title' => $name,
'#type' => 'textarea', '#type' => 'textarea',
'#default_value' => $dcItems->item($i)->nodeValue, '#default_value' => $dcItems->item($i)->nodeValue,
'#description' => 'Dublin Core ' . substr($dcItems->item($i)->nodeName, 3) '#description' => 'Dublin Core ' . substr($dcItems->item($i)->nodeName, 3)
); );
} }
elseif ($name == 'dc:title') { elseif ($name == 'dc:title') {
$form["$name" . '-' . "$i"] = array( $form["$name" . '-' . "$i"] = array(
'#title' => $name, '#title' => $name,
'#type' => 'textfield', '#type' => 'textfield',
'#required' => 'TRUE', '#required' => 'TRUE',
'#default_value' => $dcItems->item($i)->nodeValue, '#default_value' => $dcItems->item($i)->nodeValue,
'#description' => 'Dublin Core ' . substr($dcItems->item($i)->nodeName, 3) '#description' => 'Dublin Core ' . substr($dcItems->item($i)->nodeName, 3)
); );
} }
else { else {
if ($oai_dc->item(0)->nodeName != $dcItems->item($i)->parentNode->nodeName) { if ($oai_dc->item(0)->nodeName != $dcItems->item($i)->parentNode->nodeName) {
$description = strstr($name, ':'); $description = strstr($name, ':');
$form['app_' . "$name" . '-' . "$i"] = array( $form['app_' . "$name" . '-' . "$i"] = array(
'#title' => $name, '#title' => $name,
'#type' => 'textfield', '#type' => 'textfield',
'#default_value' => $dcItems->item($i)->nodeValue, '#default_value' => $dcItems->item($i)->nodeValue,
'#description' => 'Dublin Core ' . substr($description, 1) '#description' => 'Dublin Core ' . substr($description, 1)
); );
} }
else { else {
$field_type = 'textfield'; $field_type = 'textfield';
$value = $dcItems->item($i)->nodeValue; $value = $dcItems->item($i)->nodeValue;
@ -789,26 +734,26 @@ class formClass {
} }
$description = strstr($name, ':'); $description = strstr($name, ':');
$form["$name" . '-' . "$i"] = array( $form["$name" . '-' . "$i"] = array(
'#title' => $name, '#title' => $name,
'#type' => $field_type, '#type' => $field_type,
'#default_value' => $value, '#default_value' => $value,
'#description' => 'Dublin Core ' . substr($description, 1) '#description' => 'Dublin Core ' . substr($description, 1)
); );
} }
} }
} }
// $form['#redirect'] = "fedora/repository/$pid/";
$form['pid'] = array( $form['pid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$pid" '#value' => "$pid"
); );
$form['dsid'] = array( $form['dsid'] = array(
'#type' => 'hidden', '#type' => 'hidden',
'#value' => "$dsId" '#value' => "$dsId"
); );
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Update Metadata'), '#value' => t('Update Metadata'),
); );
return $form; return $form;
@ -822,62 +767,33 @@ class formClass {
$form['#attributes']['enctype'] = 'multipart/form-data'; $form['#attributes']['enctype'] = 'multipart/form-data';
$form['file'] = array( $form['file'] = array(
'#type' => 'file', '#type' => 'file',
'#title' => t('Upload Document'), '#title' => t('Upload Document'),
'#description' => t('The file to upload.') '#description' => t('The file to upload.')
); );
$form['pid'] = array( $form['pid'] = array(
'#type' => 'value', '#type' => 'value',
'#value' => $pid, '#value' => $pid,
); );
$form['dsId'] = array( $form['dsId'] = array(
'#type' => 'value', '#type' => 'value',
'#value' => $dsId, '#value' => $dsId,
); );
$form['dsLabel'] = array( $form['dsLabel'] = array(
'#type' => 'value', '#type' => 'value',
'#value' => $dsLabel, '#value' => $dsLabel,
); );
$form['submit'] = array( $form['submit'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Replace Datastream') '#value' => t('Replace Datastream')
); );
return $form; return $form;
} }
/*
function createReplaceDataStreamForm($pid, $dsId, &$form_state) {
$form = array();
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['file'] = array(
'#type' => 'file',
'#title' => t('Upload Document'),
'#description' => t('The file to upload.')
);
$form['pid'] = array(
'#type' => 'value',
'#value' => $pid,
);
$form['dsId'] = array(
'#type' => 'value',
'#value' => $dsId,
);
$form['submit']=array(
'#type' => 'submit',
'#value'=>t('Replace Datastream')
);
return $form;
}
*/
} }

1
ilives/fedora_ilives.module

@ -548,6 +548,7 @@ function install_book_content_model_objects() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$allowed_pids_str = variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: '); $allowed_pids_str = variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: ');
$allowed_pids = explode(' ', $allowed_pids_str); $allowed_pids = explode(' ', $allowed_pids_str);
if (!in_array('ilives:', $allowed_pids)) { if (!in_array('ilives:', $allowed_pids)) {
variable_set('fedora_pids_allowed', $allowed_pids_str . ' ilives:'); variable_set('fedora_pids_allowed', $allowed_pids_str . ' ilives:');

6
plugins/fedora_attach/fedora_attach.admin.inc

@ -14,10 +14,12 @@
* @see system_settings_form(). * @see system_settings_form().
*/ */
function fedora_attach_admin() { function fedora_attach_admin() {
$options = drupal_map_assoc(explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: Islandora: ilives: '))); $options = drupal_map_assoc(explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: ')));
$default_value = variable_get('fedora_attach_pid_namespace', 'default:'); $default_value = variable_get('fedora_attach_pid_namespace', 'default:');
$isRestricted = variable_get('fedora_namespace_restriction_enforced',TRUE);
if (!in_array($default_value, $options)) {
if (!in_array($default_value, $options) && $isRestricted) {
drupal_set_message( "The value last set here ($default_value) is not in the list of available PID namespaces (perhaps it has changed?). Please choose a valid option from the list.", 'warning' ); drupal_set_message( "The value last set here ($default_value) is not in the list of available PID namespaces (perhaps it has changed?). Please choose a valid option from the list.", 'warning' );
} }

205
tests/fedora_repository.test

@ -1,39 +1,15 @@
<?php <?php
// $Id$ // $Id$
/* /*
* Tests the functions of the Fedora Repository module. * Tests the functions of the Fedora Repository module.
*/ */
class FedoraRepositoryTestCase extends DrupalWebTestCase { class FedoraRepositoryTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Fedora Repository',
'description' => t('The Fedora repository content models.'),
'group' => t('fedora repository'),
);
}
function setUp() {
parent::setUp('fedora_repository', 'tabs');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
// Create and login user.
$repository_user = $this->drupalCreateFedoraUser(array('add fedora datastreams',
'edit fedora meta data',
'edit tags datastream',
'ingest new fedora objects',
'purge objects and datastreams',
'view fedora collection',
'view detailed list of content'));
$this->drupalLogin($repository_user);
}
public function testDatastreams() { public function testDatastreams() {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$pid_list = array(); $pid_list = array();
@ -195,4 +171,179 @@ class FedoraRepositoryTestCase extends DrupalWebTestCase {
$account->pass_raw = $edit['pass']; $account->pass_raw = $edit['pass'];
return $account; return $account;
} }
public static function getInfo() {
return array(
'name' => 'Fedora Repository',
'description' => t('The Fedora repository content models.'),
'group' => t('fedora repository'),
);
}
function setUp() {
parent::setUp('fedora_repository');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
// Create and login user.
$repository_user = $this->drupalCreateFedoraUser(array('add fedora datastreams',
'edit fedora meta data',
'edit tags datastream',
'ingest new fedora objects',
'purge objects and datastreams',
'view fedora collection'));
$this->repository_user = $repository_user;
$this->drupalLogin($repository_user);
}
/**
* Add an item based on a content model. Initially we will assume that the repository
* will be populated with the default content models and collections that are
* created from the admin settings -> Install Demos page.
*
*/
public function testIngest() {
// Check that the 'Strict PDF' content model exists in the repository.
//$pdf_cm = new Fedora_Item('islandora:strict_pdf');
$pid_list = array();
// Create a collection for ingesting PDF content model objects.
//$this->drupalGet('fedora/ingestObject/islandora:top/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');
// Add a sample PDF object via the web ingest form.
// Required fields are file location, dc:title and dc:description
$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') . '/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');
// Now try ingesting a proper collection policy.
$ingest_form = array();
$ingest_form['models'] = 'islandora:collectionCModel/ISLANDORACM';
$this->drupalPost('fedora/ingestObject/islandora:top/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);
$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');
$this->drupalPost(NULL, $ingest_form_step_2, 'Ingest');
//$this->outputScreenContents('Initial ingest form submit step 2 - PDF collection', 'fedora_repository');
$this->assertPattern('/Item .* created successfully./', "Verified item created.");
$pid = $this->getIngestedPid();
$pid_list[] = $pid;
$this->pass('Now attempting to ingest a PDF into the new collection.');
// Now try ingesting a PDF
$ingest_form = array();
$ingest_form['models'] = 'islandora:strict_pdf/ISLANDORACM';
$this->drupalPost("fedora/ingestObject/$pid/", $ingest_form, 'Next');
// Required fields are file location, dc:title and dc:description
$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');
$this->drupalPost(NULL, $ingest_form_step_2, 'Ingest');
$pid = $this->getIngestedPid();
$pid_list[] = $pid;
if (!empty($pid)) {
$this->pass("Successfully ingested PDF object $pid.");
}
$this->cleanUpRepository($pid_list);
}
public function testPidSpaceRestriction() {
// give user full permissions
$admin_tester = $this->drupalCreateUser(array('administer site configuration', 'view fedora collection'));
$this->drupalLogin($admin_tester);
$pageContent = $this->drupalGet('admin/settings/fedora_repository');
$hasOption = preg_match('/Enforce namespace restrictions/', $pageContent);
if (!$hasOption) {
$this->pass('Removal of namespace restrictions is disabled');
}
else {
$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->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->assertPattern('/The configuration options have been saved./', 'The configuration options have been saved.');
$this->drupalLogin($this->repository_user);
$this->drupalGet('fedora/repository/islandora:largeimages/');
$this->assertPattern('/Large Images Collection/', 'Access to Large Images Collection');
}
}
private function cleanUpRepository($pid_list = array()) {
$this->pass("This is the PID list to purge: " . implode(", ", $pid_list));
foreach ($pid_list as $pid) {
$this->drupalPost("fedora/repository/purgeObject/$pid", array(), 'Purge');
}
}
private function getIngestedPid() {
$subject = $this->drupalGetContent();
$pattern = '/">(.*)<\/a> created successfully./';
$matches = array();
$res = preg_match($pattern, $subject, $matches);
return $matches[1];
}
private function outputScreenContents($description, $basename) {
// This is a hack to get a directory that won't be cleaned up by SimpleTest.
$file_dir = file_directory_path() . '../simpletest_output_pages';
if (!is_dir($file_dir)) {
mkdir($file_dir, 0777, TRUE);
}
$output_path = "$file_dir/$basename." . $this->randomName(10) . '.html';
$rv = file_put_contents($output_path, $this->drupalGetContent());
$this->pass("$description: Contents of result page are " . l('here', $output_path));
}
protected function drupalCreateFedoraUser($permissions = array('access comments', 'access content', 'post comments', 'post comments without approval')) {
// Create a role with the given permission set.
if (!($rid = $this->drupalCreateRole($permissions))) {
return FALSE;
}
// Create a user assigned to that role.
$edit = array();
$edit['name'] = 'simpletestuser';
$edit['mail'] = $edit['name'] . '@example.com';
$edit['roles'] = array($rid => $rid);
$edit['pass'] = 'simpletestpass';
$edit['status'] = 1;
$account = user_save('', $edit);
$this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), t('User login'));
if (empty($account->uid)) {
return FALSE;
}
// Add the raw password so that we can log in as this user.
$account->pass_raw = $edit['pass'];
return $account;
}
} }

269
xsl/unfilteredresults.xsl

@ -0,0 +1,269 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<xsl:variable name="OBJECTSPAGE">
<xsl:value-of select="$objectsPage"/>
</xsl:variable>
<xsl:template match="gfindObjects">
<xsl:variable name="INDEXNAME" select="@indexName"/>
<xsl:variable name="PREQUERY" select="substring-before(@query,':')"/>
<xsl:variable name="QUERY" select="substring-after(@query,':')"/>
<xsl:variable name="HITPAGESTART" select="@hitPageStart"/>
<xsl:variable name="HITPAGESIZE" select="@hitPageSize"/>
<xsl:variable name="HITTOTAL" select="@hitTotal"/>
<xsl:variable name="SEARCHURL">
<xsl:value-of select="$searchUrl"/>
</xsl:variable>
<xsl:variable name="TOKEN">
<xsl:value-of select="$searchToken"/>
</xsl:variable>
<xsl:variable name="HITPAGEEND">
<xsl:choose>
<xsl:when test="$HITPAGESTART + $HITPAGESIZE - 1 > $HITTOTAL">
<xsl:value-of select="$HITTOTAL"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$HITPAGESTART + $HITPAGESIZE - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="HITPAGENO" select="ceiling($HITPAGESTART div $HITPAGESIZE)"/>
<xsl:variable name="HITPAGENOLAST" select="ceiling($HITTOTAL div $HITPAGESIZE)"/>
<xsl:variable name="HITPAGESTARTT" select="(($HITPAGENO - 1) * $HITPAGESIZE + 1)"/>
<xsl:choose>
<xsl:when test="$HITTOTAL > 0">
Total Hits =
<strong>
<xsl:value-of select="@hitTotal"/>,
</strong>
Number of Hits/page =
<xsl:value-of select="@hitPageSize"/>
<!-- Current page = <xsl:value-of select="@hitPageStart"/>-->
<br/>
<!--<form action="/drupal-5.1/?q=search/fedora_collections" method="post" id="search-form" class="search-form">-->
<form action="{$SEARCHURL}" method="post" id="search-form" class="search-form">
<input type="hidden" maxlength="255" name="keys" id="edit-keys" size="40" value="{$HITPAGESTARTT+$HITPAGESIZE}:{$QUERY}" class="form-text" />
<!--<xsl:if test="$PREQUERY = fgs.DS.first.text" >-->
<input type="hidden" name="type" id="edit-type" value="{$PREQUERY}" />
<!--</xsl:if>-->
<xsl:if test="$HITPAGENO > 1">
<input type="button" name="back" onClick="javascript:history.go(-1)" id="back-button" value="Previous" class="form-submit" />
</xsl:if>
<xsl:if test="$HITPAGENO &lt; $HITPAGENOLAST">
<input type="submit" name="op" id="edit-submit" value="Next" class="form-submit" />
</xsl:if>
<input type="hidden" name="form_token" id="edit-search-form-form-token" value="{$TOKEN}" />
<input type="hidden" name="form_id" id="edit-search-form" value="search_form" />
</form>
<style type="text/css">
span.highlight
{
background-color:yellow
}
span.searchtitle
{
font-weight: bold
}
</style>
<xsl:apply-templates select="objects"/>
</xsl:when>
<xsl:otherwise>
<div class="box">
<h2>Your search yielded no results</h2>
<div class="content">
<ul>
<li>Check if your spelling is correct.</li>
<li>Remove quotes around phrases to match each word individually:
<em>"blue smurf"</em> will match less than
<em>blue smurf</em>.
</li>
<li>Consider loosening your query with
<em>OR</em>:
<em>blue smurf</em> will match less than
<em>blue OR smurf</em>.
</li>
</ul>
</div>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="objects">
<table>
<div class="search-results">
<xsl:for-each select="object">
<xsl:variable name="PIDVALUE">
<xsl:choose>
<xsl:when test="@PID">
<xsl:value-of select="@PID"/>
</xsl:when>
<xsl:when test="field[@name='PID' and @snippet='yes']">
<xsl:value-of select="field[@name='PID']/span/text()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="field[@name='PID']/text()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="showResult">
<xsl:with-param name="PIDVALUE" select="$PIDVALUE"/>
</xsl:call-template>
</xsl:for-each>
</div>
</table>
</xsl:template>
<xsl:template name="showResult">
<xsl:param name="PIDVALUE"/>
<xsl:variable name="DCTITLE">
<xsl:value-of select="field[@name='dc.title']/node()"/>
</xsl:variable>
<xsl:variable name="CLEANTITLE">
<xsl:value-of select="php:functionString('fedora_repository_urlencode_string', $DCTITLE)"/>
</xsl:variable>
<tr>
<td valign="top">
<a>
<xsl:attribute name="href">
<xsl:copy-of select="$OBJECTSPAGE"/>fedora/repository/
<xsl:copy-of select="$PIDVALUE"/>/-/
<xsl:value-of select="$CLEANTITLE"/>
</xsl:attribute>
<!--<xsl:attribute name="href"><xsl:copy-of select="$OBJECTSPAGE"/><![CDATA[&pid=]]><xsl:value-of select="$PIDVALUE"/><![CDATA[&collection=object]]>
</xsl:attribute>-->
<img>
<xsl:attribute name="src">
<xsl:copy-of select="$OBJECTSPAGE"/>fedora/repository/
<xsl:copy-of select="$PIDVALUE"/>/TN
</xsl:attribute>
</img>
</a>
</td >
<td width="80%" valign="top">
<table valign="top">
<tr valign="top">
<td valign="top" class="search-results" colspan="2">
<xsl:value-of select="@no"/>
<xsl:value-of select="'. '"/>
<a>
<!--<xsl:attribute name="href"><![CDATA[http://localhost/drupal-5.1/?q=node/7&pid=]]><xsl:value-of select="$PIDVALUE"/><![CDATA[&collection=object]]>-->
<!--<xsl:attribute name="href"><xsl:copy-of select="$OBJECTSPAGE"/><![CDATA[&pid=]]><xsl:value-of select="$PIDVALUE"/><![CDATA[&collection=object]]>-->
<xsl:attribute name="href">
<xsl:copy-of select="$OBJECTSPAGE"/>fedora/repository/
<xsl:value-of select="$PIDVALUE"/>/-/
<xsl:value-of select="$CLEANTITLE"/>
</xsl:attribute>
<xsl:value-of select="$PIDVALUE"/>
<br />
</a>
<span class="searchtitle">
<span >
Score:(
<xsl:value-of select="@score"/>)
</span>
<br />
<a>
<!--<xsl:attribute name="href"><xsl:copy-of select="$OBJECTSPAGE"/><![CDATA[&pid=]]><xsl:value-of select="$PIDVALUE"/><![CDATA[&collection=object]]>-->
<xsl:attribute name="href">
<xsl:copy-of select="$OBJECTSPAGE"/>fedora/repository/
<xsl:value-of select="$PIDVALUE"/>/-/
<xsl:value-of select="$CLEANTITLE"/>
</xsl:attribute>
<xsl:value-of select="field[@name='dc.title']/node()" disable-output-escaping="yes"/>
</a>
</span>
</td>
</tr>
<xsl:for-each select="field[@snippet='yes']">
<xsl:choose>
<xsl:when test="(@name='fgs.DS.first.text')">
<tr>
<td valign="top">
<span class="searchtitle">
Text Stream<!--<xsl:value-of select="@name"/>-->
</span>
</td>
<td>
<span class="text">
<xsl:copy-of select="node()"/>
</span>
</td>
</tr>
</xsl:when>
<xsl:when test="(@name='dc.title')">
</xsl:when>
<xsl:otherwise>
<tr>
<td valign="top">
<span class="searchtitle">
<xsl:value-of select="@name"/>
</span>
</td>
<td>
<span class="text">
<xsl:copy-of select="node()"/>
</span>
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</table>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Loading…
Cancel
Save