Browse Source

merged local changes

pull/147/head
Alan Stanley 13 years ago
parent
commit
846e6eda50
  1. 339
      CollectionClass.inc
  2. 8
      CollectionPolicy.inc
  3. 7
      ConnectionHelper.inc
  4. 563
      ObjectHelper.inc
  5. 10
      SearchClass.inc
  6. 6
      SecurityClass.inc
  7. 2
      XMLDatastream.inc
  8. 246
      api/fedora_item.inc
  9. 6
      api/fedora_utils.inc
  10. 43
      fedora_repository.install
  11. 100
      fedora_repository.module
  12. 7
      fedora_repository.solutionpacks.inc
  13. 42
      formClass.inc
  14. 2
      plugins/DarwinCore.inc
  15. 45
      plugins/FedoraObjectDetailedContent.inc
  16. 2
      plugins/FlvFormBuilder.inc
  17. 8
      plugins/FormBuilder.inc
  18. 2
      plugins/ModsFormBuilder.inc
  19. 8
      plugins/PersonalCollectionClass.inc
  20. 4
      plugins/QtFormBuilder.php
  21. 6
      plugins/Refworks.inc
  22. 5
      plugins/ShowDemoStreamsInFieldSets.inc
  23. 48
      plugins/ShowStreamsInFieldSets.inc
  24. 4
      plugins/fedora_imageapi.info
  25. 2
      plugins/fedora_imageapi.module
  26. 4
      plugins/herbarium.inc
  27. 67
      plugins/qt_viewer.inc
  28. 6
      plugins/slide_viewer.inc
  29. 30
      plugins/tagging_form.inc
  30. 6
      xsl/convertQDC.xsl
  31. 190
      xsl/sparql_to_html.xsl

339
CollectionClass.inc

@ -1,4 +1,4 @@
/<?php <?php
/** /**
* @file * @file
@ -35,78 +35,109 @@ class CollectionClass {
} }
} }
public static function getCollectionQuery($pid) {
if ($query = self::getCollectionQueryFromStream($pid)) {
return $query;
}
else {
return self::getDefaultCollectionQuery($pid);
}
}
protected static function getCollectionQueryFromStream($pid) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
return $item->get_datastream_dissemination('QUERY');
}
else {
return FALSE;
}
}
protected static function getDefaultCollectionQuery($pid) {
return 'select $object $title $content from <#ri>
where ($object <fedora-model:label> $title
and $object <fedora-model:hasModel> $content
and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '>
or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title';
}
/** /**
* gets objects related to this object. must include offset and limit * Gets objects related to this object. Must include offset and limit!
* calls getRelatedItems but enforces limit and offset *
* @param type $pid * Calls self::getRelatedItems() but requires limit and offset.
* @param type $limit *
* @param $pid string
* A string containing a Fedora PID.
* @param $limit
* An integer
* @param type $offset * @param type $offset
* @param type $itqlquery * @param type $itqlquery
* @return type * @return type
*/ */
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) { function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
if (!isset($itqlquery)) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$itqlquery = $item->get_datastream_dissemination('QUERY');
}
}
return $this->getRelatedItems($pid, $itqlquery, $limit, $offset); return $this->getRelatedItems($pid, $itqlquery, $limit, $offset);
} }
/** /**
* Gets objects related to this item. It will query the object for a Query stream and use that as a itql query * Gets objects related to this item.
* or if there is no query stream it will use the default. If you pass a query to this method it will use the passed in query no matter what *
* @global type $user * Query the resource index using the provided iTQL query. If no query is
* @param type $pid * provided, one should be obtained via self::getCollectionQuery() which
* @param type $itqlquery * grabs the child objects.
* @param int $limit *
* @param $pid string
* A string containing a PID which may be substituted into the query,
* in place of the %parent_collection% placeholder.
* @param $query_string string
* An optional iTQL query.
* @param $limit int
* An optional integer to limit the number of results returned.
* @param int $offset * @param int $offset
* @return type * An optional integer used to offset the results returned. (Query should
* involve a sort to maintain consistency.
* @return string
* Sparql XML results from the resource index.
*/ */
function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) { function getRelatedItems($pid, $query_string = NULL, $limit = NULL, $offset = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!isset($offset)) { module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$offset = 0; if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid)) {
}
global $user;
if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) {
drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error');
return ' '; return ' ';
} }
$objectHelper = new ObjectHelper();
$query_string = $itqlquery; if ($query_string === NULL) {
if (!isset($query_string)) { $query_string = self::getCollectionQuery($pid);
$query_string = NULL;
$item = new Fedora_Item($pid);
if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) {
$query_string = $item->get_datastream_dissemination('QUERY');
}
if ($query_string == NULL) {
$query_string = 'select $object $title $content from <#ri>
where ($object <fedora-model:label> $title
and $object <fedora-model:hasModel> $content
and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '>
or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>)
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title';
}
} }
else {
// Replace %parent_collection% with the actual collection PID // Replace %parent_collection% with the actual collection PID
$query_string = preg_replace("/\%parent_collection\%/", "<info:fedora/$pid>", $query_string); $query_string = preg_replace("/\%parent_collection\%/", "<info:fedora/$pid>", $query_string);
}
$query_string = htmlentities(urlencode($query_string));
$content = '';
$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=Sparql&limit=$limit&offset=$offset&lang=itql&stream=on&query=" . $query_string;
$content .= do_curl($url);
$settings = array(
'type' => 'tuples',
'flush' => TRUE,
'format' => 'Sparql',
'lang' => 'itql',
'stream' => 'on',
'query' => $query_string
);
if ($limit > 0) {
$settings['limit'] = $limit;
}
if ($offset > 0) {
$settings['offset'] = $offset;
}
$url .= '?' . http_build_query($settings, NULL, '&');
$content = do_curl($url);
return $content; return $content;
} }
@ -195,7 +226,7 @@ class CollectionClass {
* @return ContentModel * @return ContentModel
*/ */
function getContentModels($collection_pid, $showError = TRUE) { function getContentModels($collection_pid, $showError = TRUE) {
module_load_include('inc', 'Fedora_Repository', 'ContentModel'); module_load_include('inc', 'fedora_repository', 'ContentModel');
$collection_stream = $this->getCollectionPolicyStream($collection_pid); $collection_stream = $this->getCollectionPolicyStream($collection_pid);
try { try {
$xml = new SimpleXMLElement($collection_stream); $xml = new SimpleXMLElement($collection_stream);
@ -222,7 +253,7 @@ class CollectionClass {
* $dsid is the datastream id of the content model. * $dsid is the datastream id of the content model.
*/ */
function getNextPid($pid, $dsid) { function getNextPid($pid, $dsid) {
module_load_include('inc', 'Fedora_Repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
$pidNameSpace = $this->getPidNameSpace($pid, $dsid); $pidNameSpace = $this->getPidNameSpace($pid, $dsid);
$pname = substr($pidNameSpace, 0, strpos($pidNameSpace, ":")); $pname = substr($pidNameSpace, 0, strpos($pidNameSpace, ":"));
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -340,7 +371,7 @@ class CollectionClass {
$parametersArray["$name"] = $value; $parametersArray["$name"] = $value;
} }
} }
// module_load_include( $phpFile, 'Fedora_Repository', ' '); // module_load_include( $phpFile, 'fedora_repository', ' ');
require_once(drupal_get_path('module', 'fedora_repository') . '/' . $phpFile); require_once(drupal_get_path('module', 'fedora_repository') . '/' . $phpFile);
$thisClass = new $phpClass (); $thisClass = new $phpClass ();
$returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext); $returnValue = $thisClass->$phpMethod($parametersArray, $dsid, $file, $file_ext);
@ -417,7 +448,7 @@ class CollectionClass {
$phpClass = strip_tags($ingest_form->form_builder_method->class_name->asXML()); $phpClass = strip_tags($ingest_form->form_builder_method->class_name->asXML());
$phpMethod = strip_tags($ingest_form->form_builder_method->method_name->asXML()); $phpMethod = strip_tags($ingest_form->form_builder_method->method_name->asXML());
$dsid = strip_tags($ingest_form['dsid']); $dsid = strip_tags($ingest_form['dsid']);
// module_load_include('php', 'Fedora_Repository', $phpFile); // module_load_include('php', 'fedora_repository', $phpFile);
require_once(drupal_get_path('module', $drupal_module) . '/' . $phpFile); require_once(drupal_get_path('module', $drupal_module) . '/' . $phpFile);
$thisClass = new $phpClass (); $thisClass = new $phpClass ();
@ -485,9 +516,12 @@ class CollectionClass {
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
$collectionClass = new CollectionClass(); $collectionClass = new CollectionClass();
$xslContent = $collectionClass->getCollectionViewStream($pid); $xslContent = $collectionClass->getCollectionViewStream($pid);
if (!$xslContent && $canUseDefault) { //no xslt so we will use the default sent with the module
//If there's no XSLT from the object, then check if the one which used to exist, does...
if (!$xslContent && $canUseDefault && file_exists($path . '/xsl/sparql_to_html.xsl')) {
$xslContent = file_get_contents($path . '/xsl/sparql_to_html.xsl'); $xslContent = file_get_contents($path . '/xsl/sparql_to_html.xsl');
} }
return $xslContent; return $xslContent;
} }
@ -500,10 +534,11 @@ class CollectionClass {
*/ */
function showFieldSets($page_number) { function showFieldSets($page_number) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'CollectionManagement'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
module_load_include('inc', 'fedora_repository', 'BatchIngest'); //module_load_include('inc', 'fedora_repository', 'BatchIngest'); //Legacy code?
global $base_url; global $base_url;
global $user; global $user;
$tabset = array(); $tabset = array();
$query = NULL; $query = NULL;
$item = new Fedora_Item($this->pid); $item = new Fedora_Item($this->pid);
@ -513,10 +548,6 @@ class CollectionClass {
$results = $this->getRelatedItems($this->pid, $query); $results = $this->getRelatedItems($this->pid, $query);
$collection_items = $this->renderCollection($results, $this->pid, NULL, NULL, $page_number); $collection_items = $this->renderCollection($results, $this->pid, NULL, NULL, $page_number);
$collection_item = new Fedora_Item($this->pid);
// Check the form post to see if we are in the middle of an ingest operation.
$show_ingest_tab = (!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form');
$add_to_collection = $this->getIngestInterface();
$show_batch_tab = FALSE; $show_batch_tab = FALSE;
$policy = CollectionPolicy::loadFromCollection($this->pid, TRUE); $policy = CollectionPolicy::loadFromCollection($this->pid, TRUE);
@ -527,39 +558,31 @@ class CollectionClass {
if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") { if (count($content_models) == 1 && $content_models[0]->pid == "islandora:collectionCModel") {
$show_batch_tab = FALSE; $show_batch_tab = FALSE;
} }
if (!$show_ingest_tab) {
$view_selected = TRUE;
}
if (!$collection_items) {
$view_selected = FALSE;
$add_selected = TRUE;
}
$view_selected = !$show_ingest_tab;
// Check the form post to see if we are in the middle of an ingest operation.
$add_selected = ((!empty($_POST['form_id']) && $_POST['form_id'] == 'fedora_repository_ingest_form') || !$collection_items);
$view_selected = !$add_selected;
$tabset['view_tab'] = array( $tabset['view_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => 'View', '#title' => t('View'),
'#selected' => $view_selected, '#selected' => $view_selected,
'#content' => $collection_items, '#content' => $collection_items,
'#tab_name' => 'view-tab',
); );
$add_to_collection = $this->getIngestInterface();
if (!empty($add_to_collection)) {
$tabset['add_tab'] = array( $tabset['add_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Add'), '#title' => t('Add'),
'#selected' => $add_selected, '#selected' => $add_selected,
// This will be the content of the tab. // This will be the content of the tab.
'#content' => $add_to_collection, '#content' => $add_to_collection,
); '#tab_name' => 'add-tab',
if ($show_batch_tab && user_access('create batch process')) {
$tabset['batch_ingest_tab'] = array(
// #type and #title are the minimum requirements.
'#type' => 'tabpage',
'#title' => t('Batch Ingest'),
// This will be the content of the tab.
'#content' => drupal_get_form('batch_creation_form', $this->pid, $content_models),
); );
} }
return $tabset; return $tabset;
} }
@ -569,10 +592,8 @@ class CollectionClass {
* @return string * @return string
*/ */
function getIngestInterface() { function getIngestInterface() {
global $base_url; module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
$objectHelper = new ObjectHelper(); $collectionPolicyExists = $this->collectionObject->getMimeType($this->pid, CollectionPolicy::getDefaultDSID());
module_load_include('inc', 'Fedora_Repository', 'CollectionPolicy');
$collectionPolicyExists = $objectHelper->getMimeType($this->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;
@ -591,6 +612,66 @@ class CollectionClass {
return $ingestObject; return $ingestObject;
} }
/**
* Unfortunate function, I know...
*
* Does just what it says: Hacks the default Drupal pager such that it might
* be rendered, likely with: theme('pager', array(), $per_page, $pager_name)
* (I reccomend seeing the real documentation for more detail, but the first
* array can be a list of the tags to use for first, previous, next and last
* (text in the pager), I don't believe per_page is actually used in the theme
* function, and $pager_name is an integer used to identify the pager (such
* that there can be more than one--that is, tracking different lists of
* content on a single page. You can render the exact same pager multiple
* times, say if you want one at the top and bottom of a list, using the same
* ID/pager_name.
*
* @global $pager_total array
* Numerically indexed array, where keys are the $pager_names and values
* are the number of pages in the given set, based on: ceil($total_items/$per_page);
* @global $pager_page_array array
* Numerically indexed array, where keys are the $pager_names and values
* are the page selected in the relevant set.
* @param $pager_name int
* An integer to identify the pager to affect. Do note that paging in using
* this function will add the 'page' HTTP GET parameter to the URL, with
* the value containing a comma-separated list with max($pager_name + 1)
* values--that is, if you create a single pager named '10', the 'next'
* link will look something like: 0,0,0,0,0,0,0,0,0,0,1
* @param $per_page int
* An integer representing the number of items per page.
* @param $total_items int
* An integer representing the total number of items in the set.
* @return int
* An integer representing what the current page should be.
*/
protected static function hackPager($pager_name, $per_page = NULL, $total_items = NULL) {
global $pager_total, $pager_page_array;
if ($per_page !== NULL && $total_items !== NULL) {
$pager_total[$pager_name] = ceil($total_items / $per_page);
}
//XXX: Don't know that this is neccessary, to try to load all the time, or
// whether Drupal will load it automatically somewhere... Docs seems a
// a little sparse.
$page_info = explode(',', isset($_GET['page']) ? $_GET['page'] : '');
$page = $page_info[$pager_name];
if ($page < 0) {
$page = 0;
}
if (!isset($pager_page_array)) {
$pager_page_array = pager_load_array($page, $pager_name, $page_info);
}
else {
$pager_page_array = pager_load_array($page, $pager_name, $pager_page_array);
}
$page = $pager_page_array[$pager_name];
return $page;
}
/** /**
* render collection * render collection
* @global type $base_url * @global type $base_url
@ -601,46 +682,95 @@ class CollectionClass {
* @param int $pageNumber * @param int $pageNumber
* @return type * @return type
*/ */
function renderCollection($content, $pid, $dsId, $collection, $pageNumber = NULL) { function renderCollection($content, $pid, $dsId, $collectionName, $pageNumber = NULL) {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
global $base_url; global $base_url;
$collection_pid = $pid; //we will be changing the pid later maybe $collection_pid = $pid; //we will be changing the pid later maybe
$objectHelper = new ObjectHelper();
$parsedContent = NULL; $parsedContent = NULL;
$contentModels = $objectHelper->get_content_models_list($pid); if(!isset($this->collectionObject)){
$this->collectionObject = new ObjectHelper($pid);
}
$contentModels = $this->collectionObject->get_content_models_list($pid);
$isCollection = FALSE; $isCollection = FALSE;
//if this is a collection object store the $pid in the session as it will come in handy //if this is a collection object store the $pid in the session as it will come in handy
//after a purge or ingest to return to the correct collection. //after a purge or ingest to return to the correct collection.
$fedoraItem = NULL; $fedoraItem = NULL;
if (empty($collectionName)) {
$collectionName = menu_get_active_title();
}
$xslContent = $this->getXslContent($pid, $path);
$collectionName = $collection; $objectList = '';
if (isset($content) && $content != FALSE) {
if (!$xslContent) { //Didn't find an XSLT.
$intermediate_results = ObjectHelper::parse_sparql_results($content);
unset($content);
$per_page = 20; //XXX: Make this configurable.
$pager_name = 0;
$total = count($intermediate_results);
$pager_page = self::hackPager($pager_name, $per_page, $total);
$results = array();
foreach (array_slice($intermediate_results, $per_page * $pager_page, $per_page) as $result) {
$title = $result['title'];
$obj_path = "fedora/repository/{$result['object']}";
$thumbnail = theme('image', "$obj_path/TN", $title, $title, array(), FALSE);
$results[] = array(
'data' => l($thumbnail, $obj_path, array(
'html' => TRUE,
'attributes' => array(
'class' => 'results-image',
),
)) . l($title, $obj_path, array('attributes' => array('class' => 'results-text'))),
);
}
if (!$results) {
drupal_set_message(t("No objects in this collection (or bad query)."));
}
else {
$first = $per_page * $pager_page;
$last = (($total - $first) > $per_page)?
($first + $per_page):
$total;
$results_range_text = t('Results @first to @last of @total', array(
'@first' => $first + 1,
'@last' => $last,
'@total' => $total,
));
//$objectList = '<h3>' . $results_range_text . '</h3>';
$objectList .= theme('pager', array(), $per_page, $pager_name);
$objectList .= theme('item_list', $results, $result_range_text, 'ul', array(
'class' => 'islandora-collection-results-list',
));
$objectList .= theme('pager', array(), $per_page, $pager_name);
}
}
else {
if (!$pageNumber) { if (!$pageNumber) {
$pageNumber = 1; $pageNumber = 1;
} }
if (!isset($collectionName)) {
$collectionName = variable_get('fedora_repository_name', 'Collection');
}
$xslContent = $this->getXslContent($pid, $path);
//get collection list and display using xslt------------------------------------------- //get collection list and display using xslt-------------------------------------------
$objectList = '';
if (isset($content) && $content != FALSE) {
$input = new DomDocument(); $input = new DomDocument();
$input->loadXML(trim($content)); $input->loadXML(trim($content));
$results = $input->getElementsByTagName('result'); $results = $input->getElementsByTagName('result');
if ($results->length > 0) { if ($results->length > 0) {
try { try {
$proc = new XsltProcessor(); $proc = new XsltProcessor();
$proc->setParameter('', 'collectionPid', $collection_pid); $options = array( //Could make this the return of a hook?
$proc->setParameter('', 'collectionTitle', $collectionName); 'collectionPid' => $collection_pid,
$proc->setParameter('', 'baseUrl', $base_url); 'collectionTitle' => $collectionName,
$proc->setParameter('', 'path', $base_url . '/' . $path); 'baseUrl' => $base_url,
$proc->setParameter('', 'hitPage', $pageNumber); 'path' => "$base_url/$path",
'hitPage' => $pageNumber,
);
$proc->setParameter('', $options);
$proc->registerPHPFunctions(); $proc->registerPHPFunctions();
$xsl = new DomDocument(); $xsl = new DomDocument();
$xsl->loadXML($xslContent); $xsl->loadXML($xslContent);
@ -651,19 +781,20 @@ class CollectionClass {
$xsl = $proc->importStylesheet($xsl); $xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($input); $newdom = $proc->transformToDoc($input);
$objectList = $newdom->saveXML(); //is the xml transformed to html as defined in the xslt associated with the collection object $objectList = $newdom->saveHTML(); //is the xml transformed to html as defined in the xslt associated with the collection object
if (!$objectList) { if (!$objectList) {
throw new Exception("Invalid XML."); throw new Exception("Invalid XML.");
} }
} catch (Exception $e) { } catch (Exception $e) {
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(check_plain($e->getMessage()), 'error');
return ''; return '';
} }
} }
} }
}
else { else {
drupal_set_message(t("No Objects in this collection or bad query.")); drupal_set_message(t("No objects in this collection (or bad query)."));
} }
return $objectList; return $objectList;
} }

8
CollectionPolicy.inc

@ -44,8 +44,13 @@ class CollectionPolicy extends XMLDatastream {
if ($preFetch) { if ($preFetch) {
$fedoraItem = new Fedora_Item($pid); $fedoraItem = new Fedora_Item($pid);
if (array_key_exists($dsid, $fedoraItem->get_datastreams_list_as_array())) {
$ds = $fedoraItem->get_datastream_dissemination($dsid); $ds = $fedoraItem->get_datastream_dissemination($dsid);
} }
else { //No collection policy stream (of the default name, anyway)
return FALSE;
}
}
else { else {
$ds = NULL; $ds = NULL;
} }
@ -55,7 +60,6 @@ class CollectionPolicy extends XMLDatastream {
$ret = new CollectionPolicy($ds, $pid, $dsid); $ret = new CollectionPolicy($ds, $pid, $dsid);
} }
} catch (SOAPException $e) { } catch (SOAPException $e) {
$ret = FALSE; $ret = FALSE;
} }
return $ret; return $ret;
@ -388,7 +392,7 @@ class CollectionPolicy extends XMLDatastream {
function getContentModels() { function getContentModels() {
$ret = FALSE; $ret = FALSE;
if ($this->validate()) { if ($this->validate()) {
module_load_include('inc', 'Fedora_Repository', 'ContentModel'); module_load_include('inc', 'fedora_repository', 'ContentModel');
$ret = array(); $ret = array();
$content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model'); $content_models = $this->xml->getElementsByTagName('content_models')->item(0)->getElementsByTagName('content_model');
for ($i = 0; $i < $content_models->length; $i++) { for ($i = 0; $i < $content_models->length; $i++) {

7
ConnectionHelper.inc

@ -63,10 +63,11 @@ class ConnectionHelper {
//anonymous user. We will need an entry in the fedora users.xml file //anonymous user. We will need an entry in the fedora users.xml file
//with the appropriate entry for a username of anonymous password of anonymous //with the appropriate entry for a username of anonymous password of anonymous
try { try {
$client = new SoapClient($this->_fixURL($url, 'anonymous', 'anonymous'), array( $client = new SoapClient($url, array(
'login' => 'anonymous', 'login' => 'anonymous',
'password' => 'anonymous', 'password' => 'anonymous',
'exceptions' => $exceptions, 'exceptions' => $exceptions,
'authentication' => SOAP_AUTHENTICATION_BASIC
)); ));
} catch (SoapFault $e) { } catch (SoapFault $e) {
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))));
@ -75,10 +76,12 @@ class ConnectionHelper {
} }
else { else {
try { try {
$client = new SoapClient($this->_fixURL($url, $user->name, $user->pass), array( $client = new SoapClient($url, array(
'login' => $user->name, 'login' => $user->name,
'password' => $user->pass, 'password' => $user->pass,
'exceptions' => TRUE, 'exceptions' => TRUE,
'authentication' => SOAP_AUTHENTICATION_BASIC,
'cache_wsdl' => WSDL_CACHE_MEMORY
)); ));
} catch (SoapFault $e) { } catch (SoapFault $e) {
drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage())))); drupal_set_message(t('@e', array('@e' => check_plain($e->getMessage()))));

563
ObjectHelper.inc

@ -138,7 +138,7 @@ class ObjectHelper {
curl_setopt($ch, CURLOPT_USERPWD, "$fedoraUser:$fedoraPass"); curl_setopt($ch, CURLOPT_USERPWD, "$fedoraUser:$fedoraPass");
// There seems to be a bug in Fedora 3.1's REST authentication, removing this line fixes the authorization denied error. // There seems to be a bug in Fedora 3.1's REST authentication, removing this line fixes the authorization denied error.
// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); // return into a variable curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // return into a variable
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
@ -150,7 +150,6 @@ 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");
@ -181,13 +180,39 @@ class ObjectHelper {
header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"'); header('Content-Disposition: attachment; filename="' . $suggestedFileName . '"');
} }
if ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { curl_setopt($ch, CURLOPT_NOBODY, TRUE);
curl_exec($ch); $curl_out = curl_exec($ch);
if ($curl_out !== FALSE) {
$info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
//dd($info, 'effective URL');
if ($url !== $info) { //Handle redirect streams (the final URL is not the same as the Fedora URL)
//Add the parameters passed to Drupal, leaving out the 'q'
$query = array();
parse_str($_SERVER['QUERY_STRING'], $query);
if (isset($query['q'])) {
unset($query['q']);
}
header('HTTP/1.1 307 Moved Temporarily');
header('Location: ' . $info . '?' . http_build_query($query)); //Fedora seems to discard the query portion.
}
elseif ((isset($user) && $user->uid != 0) || $forceSoap || isset($_SERVER['HTTPS'])) { //If not anonymous, soap is force or we're using HTTPS
//Have the webserver mediate the transfer (download and restream)
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE); //CURLOPT_NOBODY sets it to 'HEAD'
$toReturn = curl_exec($ch);
echo $toReturn;
} }
else { else {
header('Location: ' . $url); header('Location: ' . $url);
} }
} }
else {
//Curl error...
}
}
curl_close($ch); curl_close($ch);
} }
else { else {
@ -288,36 +313,42 @@ class ObjectHelper {
function create_link_for_ds($pid, $dataStreamValue) { function create_link_for_ds($pid, $dataStreamValue) {
global $base_url; global $base_url;
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
require_once($path . '/api/fedora_item.inc');
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
$purge_image = '&nbsp;';
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/' . $purge_text = t('Purge datastream "@label"', array('@label' => $dataStreamValue->label));
$pid . '/' . $dataStreamValue->ID . '/' . $dataStreamValue->label . '"><img src="' . $base_url . '/' . $path . $purge_path = "fedora/repository/purgeStream/$pid/{$dataStreamValue->ID}/{$dataStreamValue->label}";
'/images/purge.gif" alt="purge datastream" /></a>'; $purge_image = l(theme('image', "$path/images/purge.gif", $purge_text, $purge_text, NULL, FALSE), $purge_path, array(
'html' => TRUE,
));
} }
} }
else { else {
$purgeImage = '&nbsp;'; $purge_image = '&nbsp;';
} }
$fullPath = base_path() . $path;
// 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;'; $replace_image = '&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>'; $replace_text = t('Replace datastream "@label"', array('@label' => $dataStreamValue->label));
$replace_path = "fedora/repository/replaceStream/$pid/{$dataStreamValue->ID}/{$dataStreamValue->label}";
$replace_image = l(theme('image', "$path/images/replace.png", $replace_text, $replace_text, NULL, FALSE), $replace_path, array(
'html' => TRUE,
));
} }
} }
@ -325,13 +356,17 @@ class ObjectHelper {
$id = $dataStreamValue->ID; $id = $dataStreamValue->ID;
$label = $dataStreamValue->label; $label = $dataStreamValue->label;
$label = str_replace("_", " ", $label); $label = str_replace("_", " ", $label);
$label_deslashed = preg_replace('/\//i', '${1}_', $label); // Necessary to handle the case of Datastream labels that contain slashes. Ugh.
$mimeType = $dataStreamValue->MIMEType; $mimeType = $dataStreamValue->MIMEType;
$view = '<a href="' . $base_url . '/fedora/repository/' . drupal_urlencode($pid) . '/' . $id . '/' . drupal_urlencode($label) . $view = l(t('View'), "fedora/repository/$pid/$id/$label_deslashed", array(
'" target="_blank" >' . t('View') . '</a>'; 'attributes' => array(
$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. 'target' => '_blank',
),
));
$action = url("fedora/repository/object_download/$pid/$id/$label_deslashed");
$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)) {
$versions = $item->get_datastream_history($id); $versions = $item->get_datastream_history($id);
if (is_array($versions)) { if (is_array($versions)) {
$downloadVersion = '<form method="GET" action="' . $action . '" onsubmit="this.action=\'' . $action . '\' + \'/\'+this.version.value;">'; $downloadVersion = '<form method="GET" action="' . $action . '" onsubmit="this.action=\'' . $action . '\' + \'/\'+this.version.value;">';
@ -344,8 +379,23 @@ class ObjectHelper {
} }
} }
$content .= "<tr><td>$label</td><td>&nbsp;$view</td><td>&nbsp;$downloadVersion</td><td>&nbsp;$mimeType</td><td>&nbsp;$replaceImage&nbsp;$purgeImage</td></tr>\n"; return array(
return $content; array(
'data' => $label,
),
array(
'data' => $view,
),
array(
'data' => $downloadVersion,
),
array(
'data' => $mimeType
),
array(
'data' => $replace_image . $purge_image,
),
);
} }
/** /**
@ -362,33 +412,35 @@ class ObjectHelper {
$dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC'; $dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC';
$xmlstr = $item->get_datastream_dissemination($dsid); $xmlstr = $item->get_datastream_dissemination($dsid);
if (empty($xmlstr)) { if (empty($xmlstr)) {
return ''; return '';
} }
try { $simplexml = new SimpleXMLElement($xmlstr);
$proc = new XsltProcessor();
} catch (Exception $e) {
drupal_set_message($e->getMessage(), 'error');
return;
}
$proc->setParameter('', 'baseUrl', $base_url); $headers = array(
$proc->setParameter('', 'path', $base_url . '/' . $path); array(
$input = NULL; 'data' => t('Metadata'),
$xsl = new DomDocument(); 'colspan' => 2,
try { ),
$xsl->load($path . '/xsl/convertQDC.xsl'); );
$input = new DomDocument(); $rows = array();
$input->loadXML(trim($xmlstr)); foreach ($simplexml->getNamespaces(TRUE) as $ns) {
} catch (Exception $e) { foreach ($simplexml->children($ns) as $child) {
watchdog('fedora_repository', "Problem loading XSL file: @e", array('@e' => $e->getMessage()), NULL, WATCHDOG_ERROR); $rows[] = array(
array(
'data' => $child->getName(),
'class' => 'dc-tag-name',
),
array(
'data' => (string)$child,
'class' => 'dc-content',
),
);
} }
$xsl = $proc->importStylesheet($xsl); }
$newdom = $proc->transformToDoc($input);
$output = $newdom->saveHTML(); return theme('table', $headers, $rows, array('class' => 'dc-table'));
return $output;
} }
/** /**
@ -407,16 +459,17 @@ class ObjectHelper {
$dsid = array_key_exists('QDC', $ds_list) ? 'QDC' : 'DC'; $dsid = array_key_exists('QDC', $ds_list) ? 'QDC' : 'DC';
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
//$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) {
$link_image = theme('image', "$path/images/edit.gif", t('Edit Metadata'));
$output .= '<br /><a title = "' . t('Edit Meta Data') . '" href="' . $base_url . '/fedora/repository/' . 'editmetadata/' . $pid . '/' . $link = l($link_image, "fedora/repository/editmetadata/$pid", array(
$dsid . '"><img src="' . $base_url . '/' . $path . '/images/edit.gif" alt="' . t('Edit Meta Data') . '" /></a>'; 'html' => TRUE,
));
$output .= '<br />' . $link;
} }
} }
return $output; return $output;
@ -436,7 +489,7 @@ class ObjectHelper {
* *
*/ */
function get_formatted_datastream_list($object_pid, $contentModels, &$fedoraItem) { function get_formatted_datastream_list($object_pid, $contentModels, &$fedoraItem) {
global $fedoraUser, $fedoraPass, $base_url, $user; global $base_url, $user;
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
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');
@ -448,58 +501,42 @@ class ObjectHelper {
if (user_access(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST)) { if (user_access(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST)) {
$availableDataStreamsText = 'Detailed List of Content'; $availableDataStreamsText = 'Detailed List of Content';
//$metaDataText='Description';
$mainStreamLabel = NULL; $mainStreamLabel = NULL;
$object = $fedoraItem->get_datastreams_list_as_SimpleXML(); $object = $fedoraItem->get_datastreams_list_as_SimpleXML();
if (!isset($object)) { if (!isset($object)) {
drupal_set_message(t("No datastreams available")); drupal_set_message(t("No datastreams available"));
return ' '; return ' ';
} }
$hasOBJStream = NULL;
$hasTNStream = FALSE;
$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); $headers = array(
$dataStreamBody .= '<tr><th colspan="4"><h3>' . t("!text", array('!text' => $availableDataStreamsText)) . '</h3></th></tr>'; array(
'data' => $availableDataStreamsText,
'colspan' => 4,
),
);
$DSs = array();
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') {
$hasOBJStream = '1';
$mainStreamLabel = $datastreamValue->label;
$mainStreamLabel = str_replace("_", " ", $mainStreamLabel);
}
if ($datastreamValue->ID == 'TN') {
$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"; $DSs []= $this->create_link_for_ds($object_pid, $datastreamValue);
} }
} }
} }
$dataStreamBody .= "</table>\n";
$dataStreamBody = theme('table', $headers, $DSs);
//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) && //If allowed throw Drupal
$allow = TRUE; ((module_exists('fedora_fesl') && fedora_fesl_check_roles($object_pid, 'write')) || //And allowed throw FESL
if (module_exists('fedora_fesl')) { !module_exists('fedora_fesl'))) { //Or not using FESL, draw the add datastream form.
$allow = fedora_fesl_check_roles($object_pid, 'write');
}
if ($allow) {
$dataStreamBody .= drupal_get_form('add_stream_form', $object_pid); $dataStreamBody .= drupal_get_form('add_stream_form', $object_pid);
} }
}
$fieldset = array(
'#title' => t("!text", array('!text' => $availableDataStreamsText)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#value' => $dataStreamBody
);
$dataStreamBody = '<div class = "fedora_detailed_list">' . theme('fieldset', $fieldset) . '</div>';
return $dataStreamBody; return $dataStreamBody;
} }
@ -561,7 +598,7 @@ class ObjectHelper {
try { try {
$sxml = new SimpleXMLElement($content_models); $sxml = new SimpleXMLElement($content_models);
} catch (exception $e) { } catch (exception $e) {
watchdog(t("Fedora_Repository"), "Could not find a parent object for %s", $pid, NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "Could not find a parent object for %s", $pid, NULL, WATCHDOG_ERROR);
return $pids; return $pids;
} }
@ -591,55 +628,44 @@ class ObjectHelper {
* @param type $pid * @param type $pid
* @return type * @return type
*/ */
function fedora_repository_access($op, $pid) { function fedora_repository_access($op, $pid = NULL, $as_user = NULL) {
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:root'); $pid = variable_get('fedora_repository_pid', 'islandora:root');
} }
$nameSpaceAllowed = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$pos = NULL; $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
foreach ($nameSpaceAllowed as $nameSpace) { $namespace_access = NULL;
$pos = stripos($pid, $nameSpace); if (!$isRestricted) {
if ($pos === 0) { $namespace_access = TRUE;
$namespaceAccess = TRUE;
}
}
if ($namespaceAccess) {
$user_access = user_access($op);
if ($user_access == NULL) {
return FALSE;
}
return $user_access;
} }
else { else {
return FALSE; $pid_namespace = substr($pid, 0, strpos($pid, ':') + 1); //Get the namespace (with colon)
$allowed_namespaces = explode(" ", variable_get('fedora_pids_allowed', 'default: demo: changeme: islandora: ilives: islandora-book: books: newspapers: '));
$namespace_access = in_array($pid_namespace, $allowed_namespaces);
} }
return ($namespace_access && user_access($op, $as_user));
} }
/** /**
* internal function * internal function
* uses an xsl to parse the sparql xml returned from the ITQL query * uses an xsl to parse the sparql xml returned from the ITQL query
* * @deprecated
* * This is only used in the fedora/repository/collection path,
* which should probably be nuked.
* @param $content String * @param $content String
*/ */
function parseContent($content, $pid, $dsId, $collection, $pageNumber = NULL) { function parseContent($content, $pid, $dsId, $collection, $pageNumber = NULL) {
$path = drupal_get_path('module', 'fedora_repository'); $path = drupal_get_path('module', 'fedora_repository');
global $base_url; global $base_url;
$collection_pid = $pid; //we will be changing the pid later maybe $collection_pid = $pid; //we will be changing the pid later maybe
//module_load_include('php', ''Fedora_Repository'', 'ObjectHelper');
$objectHelper = $this; $objectHelper = $this;
$parsedContent = NULL; $parsedContent = NULL;
$contentModels = $objectHelper->get_content_models_list($pid); $contentModels = $this->get_content_models_list($pid);
$isCollection = FALSE; $isCollection = FALSE;
//if this is a collection object store the $pid in the session as it will come in handy
//after a purge or ingest to return to the correct collection.
$fedoraItem = NULL; $fedoraItem = NULL;
$datastreams = $this->get_formatted_datastream_list($pid, $contentModels, $fedoraItem); $datastreams = $this->get_formatted_datastream_list($pid, $contentModels, $fedoraItem);
@ -647,6 +673,9 @@ class ObjectHelper {
if (!empty($contentModels)) { if (!empty($contentModels)) {
foreach ($contentModels as $contentModel) { foreach ($contentModels as $contentModel) {
if ($contentModel == variable_get('fedora_collection_model_pid', 'islandora:collectionCModel')) { if ($contentModel == variable_get('fedora_collection_model_pid', 'islandora:collectionCModel')) {
//if this is a collection object store the $pid in the session as it will come in handy
//after a purge or ingest to return to the correct collection.
$_SESSION['fedora_collection'] = $pid; $_SESSION['fedora_collection'] = $pid;
$isCollection = TRUE; $isCollection = TRUE;
} }
@ -663,9 +692,9 @@ class ObjectHelper {
//show the collections datastreams //show the collections datastreams
if ($results->length > 0 || $isCollection == TRUE) { if ($results->length > 0 || $isCollection == TRUE) {
// if(strlen($objectList)>22||$contentModel=='Collection'||$contentModel=='Community')//length of empty dom still equals 22 because of <table/> etc // if(strlen($objectList)>22||$contentModel=='Collection'||$contentModel=='Community')//length of empty dom still equals 22 because of <table/> etc
module_load_include('inc', 'Fedora_Repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
$collectionPolicyExists = $objectHelper->getMimeType($pid, CollectionPolicy::getDefaultDSID()); $collectionPolicyExists = $this->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')) {
@ -673,9 +702,11 @@ class ObjectHelper {
} }
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() . $ingest_text = t('Ingest a new object into @collection_name PID @collection_pid', array('@collection_name' => $collectionName, '@collection_pid' => $collection_pid));
'fedora/ingestObject/' . $collection_pid . '/' . $collectionName . '"><img src="' . $base_url . '/' . $path . $ingestObject = l(theme('image', "$path/images/ingest.png", $ingest_text), "fedora/ingestObject/$collection_pid/$collectionName", array('attributes' => array(
'/images/ingest.png" alt="' . t('Add a New Object') . '" class="icon"></a> ' . t('Add to this Collection'); 'class' => 'icon',
'title' => $ingest_text,
))) . t('Add to this Collection');
} }
} }
} }
@ -721,18 +752,34 @@ class ObjectHelper {
} }
/** /**
* Gets the parent objects that this object is related to * Get the query to find parent objects.
* *
* @param unknown_type $pid * @param $pid string
* @return unknown * A string containing a Fedora PID to find the parents for.
* @return string
* A string containing an iTQL query, selecting something into $object and $title
*/ */
function get_parent_objects($pid) { static function parentQuery($pid) {
$query_string = 'select $object $title from <#ri> return 'select $object $title from <#ri>
where ($object <fedora-model:label> $title where ($object <fedora-model:label> $title
and <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $object and <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title'; order by $title';
$objects = $this->getCollectionInfo($pid, $query_string); }
/**
* Gets the parent objects that this object is related to
*
* @param $pid string
* A string containing a Fedora PID to find the parents for.
* @return string
* A string containing Sparql XML (the results of the self::parentQuery())
*/
function get_parent_objects($pid) {
$query_string = self::parentQuery();
module_load_include('inc', 'fedora_repository', 'CollectionClass');
$collection_class = new CollectionClass($pid);
$objects = CollectionClass::getRelatedItems($pid, $query_string);
return $objects; return $objects;
} }
@ -743,31 +790,24 @@ class ObjectHelper {
* @return string * @return string
*/ */
function get_parent_objects_asHTML($pid) { function get_parent_objects_asHTML($pid) {
global $base_url; module_load_include('inc', 'fedora_repository', 'CollectionClass');
$parent_collections = $this->get_parent_objects($pid); $results = self::performItqlQuery(self::parentQuery($pid));
try {
$parent_collections = new SimpleXMLElement($parent_collections); $parent_collections = array();
} catch (exception $e) { foreach ($results as $result) {
drupal_set_message(t('Error getting parent objects @e', array('@e' => check_plain($e->getMessage())))); $collection_title = $result['title'];
return; $collection_pid = $result['object'];
} $path = "fedora/repository/$collection_pid/-/$collection_title";
$parent = array(
'data' => l($collection_title, $path),
);
$parent_collections_HTML = ''; $parent_collections[] = $parent;
foreach ($parent_collections->results->result as $result) {
$collection_label = $result->title;
foreach ($result->object->attributes() as $a => $b) {
if ($a == 'uri') {
$uri = (string) $b;
$uri = $base_url . '/fedora/repository' . substr($uri, strpos($uri, '/')) . '/-/' . $collection_label;
}
}
$parent_collections_HTML .= '<a href="' . $uri . '">' . $collection_label . '</a><br />';
}
if (!empty($parent_collections_HTML)) {
$parent_collections_HTML = '<tr><td><h3>' . t("Belongs to these collections:") . ' </h3></td><td colspan="4">' . $parent_collections_HTML . '</td></tr>';
} }
return $parent_collections_HTML; if (!empty($parent_collections)) {
return theme('item_list', $parent_collections, t('Belongs to these collections'), 'ul');
}
} }
/** /**
@ -817,6 +857,8 @@ class ObjectHelper {
/** /**
* Get a tree of related pids - for the basket functionality * Get a tree of related pids - for the basket functionality
* *
* FIXME: This doesn't actually get a tree...
*
* @param type $pid * @param type $pid
* @return type * @return type
*/ */
@ -827,19 +869,18 @@ class ObjectHelper {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
// Get title and descriptions for $pid // Get title and descriptions for $pid
$query_string = 'select $title $desc from <#ri> $query_string = 'select $title $description from <#ri>
where $o <fedora-model:label> $title where $o <fedora-model:label> $title
and $o <dc:description> $desc and $o <dc:description> $desc
and $o <mulgara:is> <info:fedora/' . $pid . '>'; and $o <mulgara:is> <info:fedora/' . $pid . '>';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); $results = self::performItqlQuery($query_string);
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query=";
$content = do_curl($url . htmlentities(urlencode($query_string)));
$rows = explode("\n", $content);
$fields = explode(',', $rows[1]);
$pids[$pid] = array('title' => $fields[0], 'description' => $fields[1]); $pids = array();
//There should only be one... Anyway.
foreach($results as $result) {
$pids[$pid] = $result;
}
// $pids += $this->get_child_pids(array($pid)); // $pids += $this->get_child_pids(array($pid));
@ -853,38 +894,24 @@ class ObjectHelper {
* @return type * @return type
*/ */
function get_child_pids($pids) { function get_child_pids($pids) {
//Build the parts which are used to filter to the list of input.
$query_chunks = array();
foreach ($pids as $pid) {
$query_chunks[] = '$s <mulgara:is> <info:fedora/' . $pid . '>';
}
// 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> '.
'where $s <info:fedora/fedora-system:def/relations-external#hasMember> $o ' . 'where $s <info:fedora/fedora-system:def/relations-external#hasMember> $o ' .
'and $o <fedora-model:label> $title ' . 'and $o <fedora-model:label> $title ' .
// 'and $o <dc:description> $desc '. 'and ( ' . implode(' or ', $query_chunks) . ' )';
'and ( ';
foreach ($pids as $pid) {
$query_string .= '$s <mulgara:is> <info:fedora/' . $pid . '> or ';
}
$query_string = substr($query_string, 0, -3) . ' )';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query=";
$url .= htmlentities(urlencode($query_string));
$content = $this->doCurl($url);
$rows = explode("\n", $content); $results = self::performItqlQuery($query_string);
// Knock of the first heading row
array_shift($rows);
$child_pids = array(); $child_pids = array();
if (count($rows)) { if ($results) {
// iterate through each row // iterate through each row
foreach ($rows as $row) { foreach ($results as $result) {
if ($row == "") { $child_pids[$result['o']] = array('title' => $result['title']);
continue;
}
$fields = explode(',', $row);
$child_pid = substr($fields[0], 12);
$child_pids[$child_pid] = array('title' => $fields[1], 'description' => $fields[2]);
} }
if (!empty($child_pids)) { if (!empty($child_pids)) {
$child_pids += $this->get_child_pids(array_keys($child_pids)); $child_pids += $this->get_child_pids(array_keys($child_pids));
@ -913,58 +940,62 @@ class ObjectHelper {
/** /**
* Builds an array of drupal links for use in breadcrumbs. * Builds an array of drupal links for use in breadcrumbs.
* *
* @todo Make fully recursive...
*
* @global type $base_url * @global type $base_url
* @param type $pid * @param type $pid
* @param type $breadcrumbs * @param type $breadcrumbs
* @param type $level * @param type $level
*/ */
function getBreadcrumbs($pid, &$breadcrumbs, $level=10) { function getBreadcrumbs($pid, &$breadcrumbs) {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
// Before executing the query, we hve a base case of accessing the top-level collection // Before executing the query, we hve a base case of accessing the top-level collection
global $base_url; global $base_url;
if ($pid == variable_get('fedora_repository_pid', 'islandora:root')) { static $max_level = 10;
//$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository'); static $level = -1;
$breadcrumbs[] = l(variable_get('fedora_repository_title', 'Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url); if (count($breadcrumbs) === 0) {
$level = $max_level;
}
$root = variable_get('fedora_repository_pid', 'islandora:root');
if ($pid == $root) {
$breadcrumbs[] = l(menu_get_active_title(), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), '<front>');
} }
else { else {
$query_string = 'select $parentObject $title $content from <#ri> $query_string = 'select $parentObject $title $content from <#ri>
where (<info:fedora/' . $pid . '> <fedora-model:label> $title where (
<info:fedora/' . $pid . '> <fedora-model:label> $title
and $parentObject <fedora-model:hasModel> $content and $parentObject <fedora-model:hasModel> $content
and (<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject and (
<info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject or <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOf> $parentObject
or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject) or <info:fedora/' . $pid . '> <fedora-rels-ext:isPartOf> $parentObject
and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>) )
and $parentObject <fedora-model:state> <info:fedora/fedora-system:def/model#Active>
)
minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0> minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
order by $title desc'; order by $title desc';
$query_string = htmlentities(urlencode($query_string));
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'); if (count($results = self::performItqlQuery($query_string)) > 0 && $level > 0) {
$url .= "?type=tuples&flush=TRUE&format=CSV&limit=1&offset=0&lang=itql&stream=on&query=" . $query_string; $parent = $results[0]['parentObject'];
$this_title = $results[0]['title'];
$result = preg_split('/[\r\n]+/', do_curl($url)); if (empty($this_title)) {
array_shift($result); // throw away first line $this_title = t('Unlabeled Object');
$matches = str_getcsv(join("\n", $result));
if (count($matches) >= 2) {
$parent = preg_replace('/^info:fedora\//', '', $matches[0]);
if (0 == strlen($matches[1])) {
$matches[1] = "Unlabeled Object";
} }
$breadcrumbs[] = l($matches[1], 'fedora/repository/' . $pid); $breadcrumbs[] = l($this_title, "fedora/repository/$pid");
if ($parent == variable_get('fedora_repository_pid', 'islandora:root')) {
//$breadcrumbs[] = l(t('Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(variable_get('fedora_repository_title', 'Digital repository'), 'fedora/repository');
$breadcrumbs[] = l(t('Home'), $base_url);
}
elseif ($level > 0) {
$this->getBreadcrumbs($parent, $breadcrumbs, $level - 1);
}
}
$level--;
$this->getBreadcrumbs($parent, $breadcrumbs);
}
else { else {
$breadcrumbs[] = l(t("Path Calculation Error"), 'fedora/repository/' . $pid); watchdog('fedora_repository', 'Error generating breadcrumbs for %pid. Verify there exists relationships back up to %root. (May also be due to a hierarchy deeper than %max_depth).', array('%pid' => $pid, '%root' => $root, '%max_depth' => $max_depth), WATCHDOG_WARNING);
$breadcrumbs[] = '...'; //Add an non-link, as we don't know how to get back to the root.
$this->getBreadcrumbs($root, $breadcrumbs); //And render the last two links and break (on the next pass).
} }
} }
} }
@ -987,5 +1018,137 @@ class ObjectHelper {
drupal_set_message(t($configMess . "<br />" . $messMap[$app] . "<hr width='40%' align = 'left'/>", array('%app' => $app)), 'warning', FALSE); drupal_set_message(t($configMess . "<br />" . $messMap[$app] . "<hr width='40%' align = 'left'/>", array('%app' => $app)), 'warning', FALSE);
} }
/**
* Parse the passed in Sparql XML string into a more easily usable format.
*
* @param $sparql string
* A string containing Sparql result XML.
* @return array
* Indexed (numerical) array, containing a number of associative arrays,
* with keys being the same as the variable names in the query.
* URIs beginning with 'info:fedora/' will have this beginning stripped
* off, to facilitate their use as PIDs.
*/
public static function parseSparqlResults($sparql) {
//Load the results into a SimpleXMLElement
$doc = new SimpleXMLElement($sparql, 0, FALSE, 'http://www.w3.org/2001/sw/DataAccess/rf1/result');
$results = array(); //Storage.
//Build the results.
foreach ($doc->results->children() as $result) {
//Built a single result.
$r = array();
foreach ($result->children() as $element) {
$val = NULL;
$attrs = $element->attributes();
if (!empty($attrs['uri'])) {
$val = self::pidUriToBarePid((string)$attrs['uri']);
}
else {
$val = (string)$element;
}
//Map the name to the value in the array.
$r[$element->getName()] = $val;
}
//Add the single result to the set to return.
$results[] = $r;
}
return $results;
}
/**
* Performs the given Resource Index query and return the results.
*
* @param $query string
* A string containing the RI query to perform.
* @param $type string
* The type of query to perform, as used by the risearch interface.
* @param $limit int
* An integer, used to limit the number of results to return.
* @param $offset int
* An integer, used to offset the results (results should be ordered, to
* maintain consistency.
*
* @return array
* Indexed (numerical) array, containing a number of associative arrays,
* with keys being the same as the variable names in the query.
* URIs beginning with 'info:fedora/' will have this beginning stripped
* off, to facilitate their use as PIDs.
*/
static function performRiQuery($query, $type = 'itql', $limit = -1, $offset = 0) {
//Setup the query options...
$options = array(
'type' => 'tuples',
'flush' => TRUE,
'format' => 'Sparql', //Sparql XML is processed into the array below.
'lang' => $type,
'query' => $query
);
//Add limit if provided.
if ($limit > 0) {
$options['limit'] = $limit;
}
//Add offset if provided.
if ($offset > 0) {
$options['offset'] = $offset;
}
//Construct the query URL.
$queryUrl = url(variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch'), array('query' => $options));
//Perform the query.
$curl_result = do_curl_ext($queryUrl);
//If the query failed, write message to the logs and return.
if (!$curl_result[0]) {
watchdog('fedora_repository', 'Failed to perform %type resource index query: %query', array('%type' => $type, '%query' => $query), WATCHDOG_ERROR);
return FALSE;
}
//Pass the query's results off to a decent parser.
return self::parseSparqlResults($curl_result[0]);
}
/**
* Thin wrapper for self::_performRiQuery().
*
* @see self::performRiQuery()
*/
public static function performItqlQuery($query, $limit = -1, $offset = 0) {
return self::performRiQuery($query, 'itql', $limit, $offset);
}
/**
* Thin wrapper for self::performRiQuery().
*
* @see self::_performRiQuery()
*/
public static function performSparqlQuery($query, $limit = -1, $offset = 0) {
return self::performRiQuery($query, 'sparql', $limit, $offset);
}
/**
* Utility function used in self::performRiQuery().
*
* Strips off the 'info:fedora/' prefix from the passed in string.
*
* @param $uri string
* A string containing a URI.
*
* @return string
* The input string less the 'info:fedora/' prefix (if it has it).
* The original string otherwise.
*/
protected static function pidUriToBarePid($uri) {
$chunk = 'info:fedora/';
$pos = strpos($uri, $chunk);
if ($pos === 0) { //Remove info:fedora/ chunk
return substr($uri, strlen($chunk));
}
else { //Doesn't start with info:fedora/ chunk...
return $uri;
}
}
} }

10
SearchClass.inc

@ -36,7 +36,7 @@ class SearchClass {
try { try {
$implementation = new $solrClass(); $implementation = new $solrClass();
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), "Error getting solr search results class: !message", array('!message' => $e->getMessage()), NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "Error getting solr search results class: !message", array('!message' => $e->getMessage()), NULL, WATCHDOG_ERROR);
return 'Error getting solr search results class. Check watchdog for more info.'; return 'Error getting solr search results class. Check watchdog for more info.';
} }
return $implementation->$solrFunction($query, $startPage, $fq, $dismax); return $implementation->$solrFunction($query, $startPage, $fq, $dismax);
@ -253,7 +253,7 @@ class SearchClass {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$resultData = do_curl($searchString, 1); $resultData = do_curl($searchString, 1);
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'fedora_repository');
$output .= $this->applySpecifiedXSLT($resultData, $path . '/xsl/browseIndexToResultPage.xslt', $displayName); $output .= $this->applySpecifiedXSLT($resultData, $path . '/xsl/browseIndexToResultPage.xslt', $displayName);
//$output .= '<br />'.$alpha_out; //$output .= '<br />'.$alpha_out;
@ -367,7 +367,7 @@ class SearchClass {
* @param <type> $query the query that was executed. May want to pass this on. * @param <type> $query the query that was executed. May want to pass this on.
*/ */
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; $test = $xslt_file;
$isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE); $isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
if (!isRestricted && $xslt_file == NULL) { if (!isRestricted && $xslt_file == NULL) {
@ -425,7 +425,7 @@ class SearchClass {
* @return type * @return type
*/ */
function applyXSLT($resultData, $orderBy = 0) { function applyXSLT($resultData, $orderBy = 0) {
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'fedora_repository');
$proc = NULL; $proc = NULL;
if (!$resultData) { if (!$resultData) {
//drupal_set_message(t('No Results!')); //drupal_set_message(t('No Results!'));
@ -590,7 +590,7 @@ class SearchClass {
*/ */
function get_search_terms_array($path = NULL, $file = NULL) { function get_search_terms_array($path = NULL, $file = NULL) {
if (!isset($path)) { if (!isset($path)) {
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'fedora_repository');
} }
$xmlDoc = new DomDocument(); $xmlDoc = new DomDocument();
if (!isset($file)) { if (!isset($file)) {

6
SecurityClass.inc

@ -71,7 +71,7 @@ class SecurityClass {
try { try {
$xml = new SimpleXMLElement($policyStream); $xml = new SimpleXMLElement($policyStream);
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), "No roles found in security policy, could not parse policy stream.", NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "No roles found in security policy, could not parse policy stream.", NULL, WATCHDOG_ERROR);
//we may not want to send this to the screen. //we may not want to send this to the screen.
drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('No roles found in security policy, could not parse policy stream: !message', array('!message' => check_plain($e->getMessage()))), 'error');
return NULL; return NULL;
@ -108,9 +108,9 @@ class SecurityClass {
function createPersonalPolicy($user) { function createPersonalPolicy($user) {
$doc = new DOMDocument(); $doc = new DOMDocument();
try { try {
$doc->load(drupal_get_path('module', 'Fedora_Repository') . '/policies/noObjectEditPolicy.xml'); $doc->load(drupal_get_path('module', 'fedora_repository') . '/policies/noObjectEditPolicy.xml');
} catch (exception $e) { } catch (exception $e) {
watchdog(t("Fedora_Repository"), "Problem loading policy file.", NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "Problem loading policy file.", NULL, WATCHDOG_ERROR);
} }
$conditions = $doc->getElementsByTagName('Condition'); $conditions = $doc->getElementsByTagName('Condition');
foreach ($conditions as $condition) { foreach ($conditions as $condition) {

2
XMLDatastream.inc

@ -227,7 +227,7 @@ abstract class XMLDatastream {
* @return boolean $success * @return boolean $success
*/ */
public function saveToFedora() { public function saveToFedora() {
module_load_include('inc', 'Fedora_Repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
if ($this->validate()) { if ($this->validate()) {
$item = new Fedora_Item($this->pid); $item = new Fedora_Item($this->pid);
$item->modify_datastream_by_value($this->dumpXml(), $this->dsid, $this->name, 'application/xml'); $item->modify_datastream_by_value($this->dumpXml(), $this->dsid, $this->name, 'application/xml');

246
api/fedora_item.inc

@ -7,6 +7,8 @@
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#');
define("ISLANDORA_PAGE_URI", 'info:islandora/islandora-system:def/pageinfo#'); define("ISLANDORA_PAGE_URI", 'info:islandora/islandora-system:def/pageinfo#');
define("ISLANDORA_RELS_EXT_URI", 'http://islandora.ca/ontology/relsext#');
define("ISLANDORA_RELS_INT_URI", "http://islandora.ca/ontology/relsint#");
/** /**
* Fedora Item Class * Fedora Item Class
@ -103,9 +105,14 @@ class Fedora_Item {
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 (!is_file($datastream_file)) { if (!is_file($datastream_file)) {
drupal_set_message("$datastream_file not found<br />", 'warning'); drupal_set_message(t('The datastream file %datastream_file could not found! (or is not a regular file...)', array('%datastream_file' => $datastream_file)), 'warning');
return; return;
} }
elseif (!is_readable($datastream_file)) {
drupal_set_message(t('The datastream file %datastream_file could not be read! (likely due to permissions...)', array('%datastream_file' => $datastream_file)), 'warning');
return;
}
if (empty($datastream_mimetype)) { if (empty($datastream_mimetype)) {
// Get mime type from the file extension. // Get mime type from the file extension.
$mimetype_helper = new MimeClass(); $mimetype_helper = new MimeClass();
@ -214,43 +221,64 @@ class Fedora_Item {
/** /**
* Add a relationship string to this object's RELS-EXT. * Add a relationship string to this object's RELS-EXT.
*
* does not support rels-int yet. * does not support rels-int yet.
* @param type $relationship *
* @param type $object * @param string $relationship
* @param type $namespaceURI * The predicate/relationship tag to add
* @param string $object
* The object to be related to.
* @param string $namespaceURI
* The predicate namespace.
* @param boolean $literal_value
* Whether or not the object should be added as a URI (FALSE) or a literal (TRUE).
*/ */
function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI) { function add_relationship($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = FALSE) {
//dd($this, 'The Fedora_Item');
$ds_list = $this->get_datastreams_list_as_array(); $ds_list = $this->get_datastreams_list_as_array();
$f_prefix = 'info:fedora/';
if (empty($ds_list['RELS-EXT'])) { if (!array_key_exists('RELS-EXT', $ds_list)) {
$this->add_datastream_from_string(' <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> $rdf_string = <<<RDF
<rdf:Description rdf:about="info:fedora/' . $this->pid . '"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="$f_prefix{$this->pid}">
</rdf:Description> </rdf:Description>
</rdf:RDF>', 'RELS-EXT', 'Fedora object-to-object relationship metadata', 'text/xml', 'X'); </rdf:RDF>
RDF;
$this->add_datastream_from_string($rdf_string, 'RELS-EXT', 'Fedora object-to-object relationship metadata', 'application/rdf+xml', 'X');
} }
$relsext = $this->get_datastream_dissemination('RELS-EXT'); $relsext = $this->get_datastream_dissemination('RELS-EXT');
if (substr($object, 0, 12) != 'info:fedora/') { if (!$literal_value && strpos($object, $f_prefix) !== 0) {
$object = "info:fedora/$object"; $object = $f_prefix . $object;
} }
$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) {
//XXX: This really shouldn't be done; lower case d doesn't fit the schema. Warn users to fix the data and generators, pending deprecation.
$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) {
drupal_set_message(t('RDF with lower case "d" in "description" encountered. Should be uppercase! PID: %pid', array('%pid' => $this->pid)), 'warning');
}
} }
$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);
if ($literal_value) {
$newrel->appendChild($relsextxml->createTextNode($object));
}
else {
$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');
return $this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'application/rdf+xml');
//print ($description->dump_node()); //print ($description->dump_node());
/* /*
$params = array( 'pid' => $this->pid, $params = array( 'pid' => $this->pid,
@ -264,8 +292,55 @@ class Fedora_Item {
*/ */
} }
/**
* Purge/delete relationships string from this object's RELS-EXT.
*
* does not support rels-int yet.
*
* @param string $relationship
* The predicate/relationship tag to delete
* @param string $object
* The object to be related to. (NULL/value for which empty() evaluates to true will remove all relations of the given type, ignoring $literal_value)
* @param string $namespaceURI
* The predicate namespace.
* @param boolean $literal_value
* Whether or not the object should be looked for as a URI (FALSE) or a literal (TRUE).
* @return boolean
* Whether or not this operation has produced any changes in the RELS-EXT
*/
function purge_relationships($relationship, $object, $namespaceURI = RELS_EXT_URI, $literal_value = FALSE) {
$relsext = $this->get_datastream_dissemination('RELS-EXT');
$relsextxml = new DomDocument();
$relsextxml->loadXML($relsext);
$modified = FALSE;
$rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) {
foreach ($rels as $rel) {
if ( //If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed.
empty($object) ||
(!$literal_value && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||
($literal_value && $rel->textContent == $object)) {
$rel->parentNode->removeChild($rel);
$modified = TRUE;
}
}
}
//Save changes.
if ($modified) {
$this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
}
//Return whether or not we've introduced any changes.
return $modified;
}
/** /**
* Removes the given relationship from the item's RELS-EXT and re-saves it. * Removes the given relationship from the item's RELS-EXT and re-saves it.
*
* @deprecated
* Dropped in favour of purge_relationships, which follows the same paradigm as add_relationship. This function tries to figure out the predicate URI based on the prefix/predicate given, which requires specific naming...
* @param string $relationship * @param string $relationship
* @param string $object * @param string $object
*/ */
@ -300,7 +375,7 @@ class Fedora_Item {
break; break;
} }
if (substr($object, 0, 12) != 'info:fedora/') { if (!empty($object) && substr($object, 0, 12) != 'info:fedora/') {
$object = "info:fedora/$object"; $object = "info:fedora/$object";
} }
@ -310,17 +385,16 @@ class Fedora_Item {
$rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship);
if (!empty($rels)) { if (!empty($rels)) {
foreach ($rels as $rel) { foreach ($rels as $rel) {
if ($rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) { if (empty($object) || $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) {
$rel->parentNode->removeChild($rel); $rel->parentNode->removeChild($rel);
$modified = TRUE; $modified = TRUE;
} }
} }
} }
if ($modified) { if ($modified) {
$this->modify_datastream_by_value($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml'); $this->modify_datastream($relsextxml->saveXML(), 'RELS-EXT', "Fedora Object-to-Object Relationship Metadata", 'text/xml');
} }
return $modified; return $modified;
//print ($description->dump_node());
} }
/** /**
@ -434,7 +508,7 @@ class Fedora_Item {
* @param type $as_of_date_time * @param type $as_of_date_time
* @return type * @return type
*/ */
function get_datastream($dsid, $as_of_date_time = "") { function get_datastream($dsid, $as_of_date_time = '') {
$params = array( $params = array(
'pid' => $this->pid, 'pid' => $this->pid,
'dsID' => $dsid, 'dsID' => $dsid,
@ -530,7 +604,7 @@ class Fedora_Item {
* @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,
@ -563,7 +637,7 @@ class Fedora_Item {
// datastream, instead of returning it as an array, only // datastream, instead of returning it as an array, only
// the single item will be returned directly. We have to // the single item will be returned directly. We have to
// check for this. // check for this.
if (count($this->datastreams_list->datastreamDef) >= 2) { if (count($this->datastreams_list->datastreamDef) > 1) {
foreach ($this->datastreams_list->datastreamDef as $ds) { foreach ($this->datastreams_list->datastreamDef as $ds) {
if (!is_object($ds)) { if (!is_object($ds)) {
print_r($ds); print_r($ds);
@ -644,7 +718,7 @@ class Fedora_Item {
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(t("Error retrieving RELS-EXT of object $pid"), 'error'); drupal_set_message(t('Error retrieving RELS-EXT of object %pid.', array('%pid' => $pid)), 'error');
return $relationships; return $relationships;
} }
@ -668,30 +742,8 @@ class Fedora_Item {
} }
function get_models() { function get_models() {
$relationships = array(); //This is/was formerly just a copy/paste jobbie, without the parameter being passable...
try { return $this->get_relationships();
$relsext = $this->get_datastream_dissemination('RELS-EXT');
} catch (exception $e) {
drupal_set_message(t("Error retrieving RELS-EXT of object $pid"), 'error');
return $relationships;
}
// Parse the RELS-EXT into an associative array.
$relsextxml = new DOMDocument();
$relsextxml->loadXML($relsext);
$relsextxml->normalizeDocument();
$mods = $relsextxml->getElementsByTagNameNS(FEDORA_MODEL_URI, '*');
foreach ($mods as $child) {
if (empty($relationship) || preg_match("/$relationship/", $child->tagName)) {
$relationships[] = array(
'subject' => $this->pid,
'predicate' => $child->tagName,
'object' => substr($child->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource'), 12),
);
}
}
return $relationships;
} }
/** /**
@ -790,8 +842,9 @@ class Fedora_Item {
* @return type * @return type
*/ */
function url() { function url() {
global $base_url; return url('fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : ''), array(
return $base_url . '/fedora/repository/' . $this->pid . (!empty($this->objectProfile) ? '/-/' . drupal_urlencode($this->objectProfile->objLabel) : ''); 'absolute' => TRUE
));
} }
/** /**
@ -827,9 +880,14 @@ class Fedora_Item {
* @param type $foxml * @param type $foxml
* @return Fedora_Item * @return Fedora_Item
*/ */
static function ingest_from_FOXML($foxml) { static function ingest_from_FOXML(DOMDocument $foxml) {
$params = array('objectXML' => $foxml->saveXML(), 'format' => "info:fedora/fedora-system:FOXML-1.1", 'logMessage' => "Fedora Object Ingested"); $params = array(
'objectXML' => $foxml->saveXML(),
'format' => 'info:fedora/fedora-system:FOXML-1.1',
'logMessage' => 'Fedora Object Ingested'
);
$object = self::soap_call('ingest', $params); $object = self::soap_call('ingest', $params);
//dd($object, 'Soap return');
return new Fedora_Item($object->objectPID); return new Fedora_Item($object->objectPID);
} }
@ -889,6 +947,73 @@ class Fedora_Item {
return self::soap_call('modifyObject', $params, $quiet); return self::soap_call('modifyObject', $params, $quiet);
} }
/**
* Wrap modify by value and reference
*
* Wrap modify by value and reference, so that the proper one gets called in the correct instance. (value if inline XML, reference otherwise)
*
* First tries to treat the passed in value as a filename, tries using as contents second.
* Coerces the data into what is required, and passes it on to the relevant function.
*
* @param string $filename_or_content
* Either a filename to add, or an string of content.
* @param string $dsid
* The DSID to update
* @param string $label
* A label to withwhich to update the datastream
* @param string $mime_type
* Mimetype for the data being pushed into the datastream
* @param boolean $force
* Dunno, refer to underlying functions/SOAP interface. We just pass it like a chump.
* @param string $logMessage
* A message for the audit log.
* @param boolean $quiet
* Error suppression? Refer to soap_call for usage (just passed along here).
*/
function modify_datastream($filename_or_content, $dsid, $label, $mime_type, $force = FALSE, $logMessage='Modified by Islandora API', $quiet=FALSE) {
$toReturn = NULL;
//Determine if it's inline xml; if it is, modify by value
if ($this->get_datastream($dsid)->controlGroup === 'X') {
$content = '<null/>';
if (is_file($filename_or_content) && is_readable($filename_or_content)) {
$content = file_get_contents($filename_or_content);
}
else {
$content = $filename_or_content;
}
$toReturn = $this->modify_datastream_by_value($content, $dsid, $label, $mime_type, $force, $logMessage);
}
//Otherwise, write to web-accessible temp file and modify by reference.
else {
$file = '';
$created_temp = FALSE;
if (is_file($filename_or_content) && is_readable($filename_or_content)) {
$file = $filename_or_content;
$original_path = $file;
// Temporarily move file to a web-accessible location.
file_copy($file, file_directory_path());
$created_temp = ($original_path != $file);
}
else {
//Push contents to a web-accessible file
$file = file_save_data($filename_or_content, file_directory_path());
$created_temp = TRUE;
}
$file_url = file_create_url($file);
$toReturn = $this->modify_datastream_by_reference($file_url, $dsid, $label, $mime_type, $force, $logMessage);
if ($created_temp && is_file($file) && is_writable($file)) {
file_delete($file);
}
}
return $toReturn;
}
/** /**
* Modify datastream by reference * Modify datastream by reference
* @param type $external_url * @param type $external_url
@ -976,9 +1101,11 @@ class Fedora_Item {
module_load_include('inc', 'fedora_repository', 'ConnectionHelper'); module_load_include('inc', 'fedora_repository', 'ConnectionHelper');
self::$connection_helper = new ConnectionHelper(); self::$connection_helper = new ConnectionHelper();
} }
$url = (array_search($function, self::$SoapManagedFunctions) !== FALSE) ? $url = (
in_array($function, self::$SoapManagedFunctions)?
variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M') : variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/wsdl?api=API-M') :
variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl'); variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')
);
try { try {
$soap_client = self::$connection_helper->getSoapClient($url); $soap_client = self::$connection_helper->getSoapClient($url);
if (isset($soap_client)) { if (isset($soap_client)) {
@ -1029,25 +1156,23 @@ class Fedora_Item {
} }
} }
$root_element = $foxml->createElement("foxml:digitalObject"); $root_element = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:digitalObject");
$root_element->setAttribute("VERSION", "1.1"); $root_element->setAttribute("VERSION", "1.1");
$root_element->setAttribute("PID", $pid); $root_element->setAttribute("PID", $pid);
$root_element->setAttribute("xmlns:foxml", "info:fedora/fedora-system:def/foxml#"); $root_element->setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd");
$root_element->setAttribute("xmlns:xsl", "http://www.w3.org/2001/XMLSchema-instance");
$root_element->setAttribute("xsl:schemaLocation", "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd");
$foxml->appendChild($root_element); $foxml->appendChild($root_element);
// FOXML object properties section // FOXML object properties section
$object_properties = $foxml->createElement("foxml:objectProperties"); $object_properties = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:objectProperties");
$state_property = $foxml->createElement("foxml:property"); $state_property = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:property");
$state_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#state"); $state_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#state");
$state_property->setAttribute("VALUE", $state); $state_property->setAttribute("VALUE", $state);
$label_property = $foxml->createElement("foxml:property"); $label_property = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "foxml:property");
$label_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#label"); $label_property->setAttribute("NAME", "info:fedora/fedora-system:def/model#label");
$label_property->setAttribute("VALUE", $label); $label_property->setAttribute("VALUE", $label);
$owner_property = $foxml->createElement("foxml:property"); $owner_property = $foxml->createElementNS("info:fedora/fedora-system:def/foxml#", "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);
@ -1056,7 +1181,6 @@ class Fedora_Item {
$object_properties->appendChild($owner_property); $object_properties->appendChild($owner_property);
$root_element->appendChild($object_properties); $root_element->appendChild($object_properties);
$foxml->appendChild($root_element); $foxml->appendChild($root_element);
return $foxml; return $foxml;
} }

6
api/fedora_utils.inc

@ -85,7 +85,7 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post
* an array that consists of three value or NULL if curl is not suported: * an array that consists of three value or NULL if curl is not suported:
* - element 0: * - element 0:
* The value returned from the curl_exec function call. * The value returned from the curl_exec function call.
* This is either a TRUE or FALSE value or the actual data returned from * This is either a boolean value or the actual data returned from
* accessing the URL. * accessing the URL.
* - element 1: * - element 1:
* The error code reslting from attempting to access the URL with curl_exec * The error code reslting from attempting to access the URL with curl_exec
@ -93,7 +93,7 @@ function do_curl($url, $return_to_variable = 1, $number_of_post_vars = 0, $post
* A string representing a textual representation of the error code that * A string representing a textual representation of the error code that
* resulted from attempting to access the URL with curl_exec * resulted from attempting to access the URL with curl_exec
*/ */
function do_curl_ext($url, $return_to_variable = 1, $number_of_post_vars = 0, $post = NULL) { function do_curl_ext($url, $return_to_variable = TRUE, $number_of_post_vars = 0, $post = NULL) {
global $user; global $user;
// Check if we are inside Drupal and there is a valid user. // Check if we are inside Drupal and there is a valid user.
@ -113,7 +113,7 @@ function do_curl_ext($url, $return_to_variable = 1, $number_of_post_vars = 0, $p
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); // Fail on errors curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); // Fail on errors
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // allow redirects
curl_setopt($ch, CURLOPT_TIMEOUT, 90); // times out after 90s curl_setopt($ch, CURLOPT_TIMEOUT, 90); // times out after 90s
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, $return_to_variable); // return into a variable curl_setopt($ch, CURLOPT_RETURNTRANSFER, $return_to_variable); // return into a variable

43
fedora_repository.install

@ -34,71 +34,70 @@ function fedora_collections_enable() {
* @see _update_cron_notify() * @see _update_cron_notify()
*/ */
function fedora_repository_requirements($phase) { function fedora_repository_requirements($phase) {
global $base_url;
$requirements = array(); $requirements = array();
$t = get_t(); //May not have access to the regular t() function; and so Drupal provides...
if ($phase == 'install') { if ($phase == 'install') {
// Test for SOAP // Test for SOAP
$requirements['fedora-soap']['title'] = t("PHP SOAP extension library"); $requirements['fedora-soap']['title'] = $t("PHP SOAP extension library");
if (!class_exists('SoapClient')) { if (!class_exists('SoapClient')) {
$requirements['fedora-soap']['value'] = t("Not installed"); $requirements['fedora-soap']['value'] = $t("Not installed");
$requirements['fedora-soap']['severity'] = REQUIREMENT_ERROR; $requirements['fedora-soap']['severity'] = REQUIREMENT_ERROR;
$requirements['fedora-soap']['description'] = t('Ensure that the PHP SOAP extension is installed.'); $requirements['fedora-soap']['description'] = $t('Ensure that the PHP SOAP extension is installed.');
} }
else { else {
$requirements['fedora-soap']['value'] = t("Installed"); $requirements['fedora-soap']['value'] = $t("Installed");
$requirements['fedora-soap']['severity'] = REQUIREMENT_OK; $requirements['fedora-soap']['severity'] = REQUIREMENT_OK;
} }
// Test for Curl // Test for Curl
$requirements['curl']['title'] = "PHP Curl extension library"; $requirements['curl']['title'] = $t('PHP Curl extension library');
if (!function_exists('curl_init')) { if (!function_exists('curl_init')) {
$requirements['curl']['value'] = t("Not installed"); $requirements['curl']['value'] = $t("Not installed");
$requirements['curl']['severity'] = REQUIREMENT_ERROR; $requirements['curl']['severity'] = REQUIREMENT_ERROR;
$requirements['curl']['description'] = t("Ensure that the PHP Curl extension is installed."); $requirements['curl']['description'] = $t("Ensure that the PHP Curl extension is installed.");
} }
else { else {
$requirements['curl']['value'] = t("Installed"); $requirements['curl']['value'] = $t("Installed");
$requirements['curl']['severity'] = REQUIREMENT_OK; $requirements['curl']['severity'] = REQUIREMENT_OK;
} }
// Test for DOM // Test for DOM
$requirements['dom']['title'] = "PHP DOM XML extension library"; $requirements['dom']['title'] = $t("PHP DOM XML extension library");
if (!method_exists('DOMDocument', 'loadHTML')) { if (!method_exists('DOMDocument', 'loadHTML')) {
$requirements['dom']['value'] = t("Not installed"); $requirements['dom']['value'] = $t("Not installed");
$requirements['dom']['severity'] = REQUIREMENT_ERROR; $requirements['dom']['severity'] = REQUIREMENT_ERROR;
$requirements['dom']['description'] = t("Ensure that the PHP DOM XML extension is installed."); $requirements['dom']['description'] = $t("Ensure that the PHP DOM XML extension is installed.");
} }
else { else {
$requirements['dom']['value'] = t("Installed"); $requirements['dom']['value'] = $t("Installed");
$requirements['dom']['severity'] = REQUIREMENT_OK; $requirements['dom']['severity'] = REQUIREMENT_OK;
} }
// Test for XSLT // Test for XSLT
$requirements['xsl']['title'] = "PHP XSL extension library"; $requirements['xsl']['title'] = $t("PHP XSL extension library");
if (!class_exists('XSLTProcessor')) { if (!class_exists('XSLTProcessor')) {
$requirements['xslt']['value'] = t("Not installed"); $requirements['xslt']['value'] = $t("Not installed");
$requirements['xslt']['severity'] = REQUIREMENT_ERROR; $requirements['xslt']['severity'] = REQUIREMENT_ERROR;
$requirements['xslt']['description'] = t("Ensure that the PHP XSL extension is installed."); $requirements['xslt']['description'] = $t("Ensure that the PHP XSL extension is installed.");
} }
else { else {
$requirements['xslt']['value'] = t("Installed"); $requirements['xslt']['value'] = $t("Installed");
$requirements['xslt']['severity'] = REQUIREMENT_OK; $requirements['xslt']['severity'] = REQUIREMENT_OK;
} }
} }
elseif ($phase == 'runtime') { elseif ($phase == 'runtime') {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$requirements['fedora-repository']['title'] = t("Fedora server"); $requirements['fedora-repository']['title'] = $t("Fedora server");
if (!fedora_available()) { if (!fedora_available()) {
$requirements['fedora-repository']['value'] = t("Not available"); $requirements['fedora-repository']['value'] = $t("Not available");
$requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR; $requirements['fedora-repository']['severity'] = REQUIREMENT_ERROR;
$requirements['fedora-repository']['description'] = t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => $base_url . '/admin/settings/fedora_repository')); $requirements['fedora-repository']['description'] = $t('Ensure that Fedora is running and that the <a href="@collection-settings">collection settings</a> are correct.', array('@collection-settings' => url('admin/settings/fedora_repository')));
} }
else { else {
$requirements['fedora-repository']['value'] = t("Available"); $requirements['fedora-repository']['value'] = $t("Available");
$requirements['fedora-repository']['severity'] = REQUIREMENT_OK; $requirements['fedora-repository']['severity'] = REQUIREMENT_OK;
} }
} }

100
fedora_repository.module

@ -2,8 +2,7 @@
/** /**
* Drupal hook for admin form * Drupal hook for admin form
* fedora_repository_name is the name of the top level collection this module will query *
* fedora_repository_pid is the name of the top level pid.
* Stores this info in the drupal variables table. * Stores this info in the drupal variables table.
* the name and pid can also be passed as url parameters * the name and pid can also be passed as url parameters
*/ */
@ -146,14 +145,13 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
$form_state['submitted'] = FALSE; $form_state['submitted'] = FALSE;
return; return;
} }
if ($form_state['storage']['xml']) { //ddebug_backtrace();
if (module_exists('islandora_content_model_forms')) { if ($form_state['storage']['xml'] && module_exists('islandora_content_model_forms')) {
module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm'); module_load_include('inc', 'islandora_content_model_forms', 'IngestObjectMetadataForm');
$xml_form = new IngestObjectMetadataForm(); $xml_form = new IngestObjectMetadataForm();
$xml_form->submit($form, $form_state); $xml_form->submit($form, $form_state);
} }
} elseif (strpos($form_state['clicked_button']['#id'], 'edit-submit') === 0) {
elseif ($form_state['clicked_button']['#id'] == 'edit-submit') {
global $base_url; global $base_url;
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy');
@ -188,7 +186,7 @@ function fedora_repository_ingest_form_submit(array $form, array &$form_state) {
} }
if ($redirect) { if ($redirect) {
$form_state['redirect'] = ($err) ? ' ' : $base_url . "/fedora/repository/{$form_state['values']['collection_pid']}"; $form_state['redirect'] = ($err) ? ' ' : url("fedora/repository/{$form_state['values']['collection_pid']}");
} }
} }
} }
@ -205,7 +203,7 @@ function fedora_repository_ingest_form_validate($form, &$form_state) {
$form_state['submitted'] = FALSE; $form_state['submitted'] = FALSE;
return; return;
} }
if ($form_state['clicked_button']['#id'] == 'edit-submit' && $form_state['ahah_submission'] != 1) { if (strpos($form_state['clicked_button']['#id'], 'edit-submit') === 0 && $form_state['ahah_submission'] != 1) {
switch ($form_state['storage']['step']) { switch ($form_state['storage']['step']) {
case 1: case 1:
$form_state['storage']['step']++; $form_state['storage']['step']++;
@ -286,7 +284,8 @@ function fedora_repository_ingest_form(&$form_state, $collection_pid, $collectio
$ingestForm = new formClass(); $ingestForm = new formClass();
$form_state['storage']['content_model'] = $content_model; $form_state['storage']['content_model'] = $content_model;
$form_state['storage']['collection_pid'] = $collection_pid; $form_state['storage']['collection_pid'] = $collection_pid;
return $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state); $form = $ingestForm->createIngestForm($collection_pid, $collection_label, $form_state);
return $form;
} }
/** /**
@ -635,7 +634,7 @@ function fedora_repository_replace_stream($pid, $dsId, $dsLabel = '', $collectio
* @return type * @return type
*/ */
function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) { function fedora_repository_replace_stream_form(&$form_state, $pid, $dsId, $dsLabel) {
module_load_include('inc', 'Fedora_Repository', 'formClass'); module_load_include('inc', 'fedora_repository', 'formClass');
$replaceDataStreamForm = new formClass(); $replaceDataStreamForm = new formClass();
return $replaceDataStreamForm->createReplaceDataStreamForm($pid, $dsId, $dsLabel, $form_state); return $replaceDataStreamForm->createReplaceDataStreamForm($pid, $dsId, $dsLabel, $form_state);
} }
@ -660,7 +659,7 @@ function fedora_repository_replace_stream_form_validate($form, &$form_state) {
} }
$doc = new DOMDocument(); $doc = new DOMDocument();
module_load_include('inc', 'Fedora_Repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
$mime = new MimeClass(); $mime = new MimeClass();
if ($mime->getType($file->filepath) == 'text/xml' && !$doc->load($file->filepath)) { if ($mime->getType($file->filepath) == 'text/xml' && !$doc->load($file->filepath)) {
form_set_error('file', 'Invalid XML format.'); form_set_error('file', 'Invalid XML format.');
@ -690,7 +689,7 @@ function fedora_repository_replace_stream_form_submit($form, &$form_state) {
$dsLabel = substr($dsLabel, 0, $indexOfDot); $dsLabel = substr($dsLabel, 0, $indexOfDot);
$dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.; $dsLabel .= substr($file->filename, strrpos($file->filename, '.')); // Add the file extention to the end of the label.;
} }
module_load_include('inc', 'Fedora_Repository', 'MimeClass'); module_load_include('inc', 'fedora_repository', 'MimeClass');
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$file_basename = basename($file->filepath); $file_basename = basename($file->filepath);
@ -771,13 +770,6 @@ function fedora_repository_edit_qdc_form(&$form_state, $pid, $dsId = NULL) {
$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'));
// Check if there is a custom edit metadata function defined in the content model. // Check if there is a custom edit metadata function defined in the content model.
$breadcrumbs = array();
$objectHelper = new ObjectHelper();
$objectHelper->getBreadcrumbs($pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($breadcrumbs));
$output = ''; $output = '';
if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) { if (($cm = ContentModel::loadFromObject($pid)) !== FALSE) {
$output = $cm->buildEditMetadataForm($pid, $dsId); $output = $cm->buildEditMetadataForm($pid, $dsId);
@ -821,7 +813,7 @@ function fedora_repository_edit_qdc_form_validate($form, &$form_state) {
function fedora_repository_edit_qdc_form_submit($form, &$form_state) { function fedora_repository_edit_qdc_form_submit($form, &$form_state) {
if ($form_state['storage']['xml']) { if ($form_state['storage']['xml']) {
module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm'); module_load_include('inc', 'islandora_content_model_forms', 'EditObjectMetadataForm');
$xml_form = new EditObjectMetadataForm($form_state); $xml_form = new EditObjectMetadataForm();
$xml_form->submit($form, $form_state); $xml_form->submit($form, $form_state);
} }
else { else {
@ -877,7 +869,7 @@ function fedora_repository_perm() {
* @param type $account * @param type $account
* @return type * @return type
*/ */
function fedora_repository_access($op, $node, $account) { function fedora_repository_access($op, $node = NULL, $account = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
return $objectHelper->fedora_repository_access($op, $node, $account); return $objectHelper->fedora_repository_access($op, $node, $account);
@ -1047,6 +1039,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
/** /**
* fedora repository urlencode string * fedora repository urlencode string
* FIXME: URL-encoding is not the same as HTML/XML encoding...
* @param type $str * @param type $str
* @return type * @return type
*/ */
@ -1722,7 +1715,7 @@ function fedora_repository_required_fedora_objects() {
'pid' => 'islandora:collectionCModel', 'pid' => 'islandora:collectionCModel',
'label' => 'Islandora Collection Content Model', 'label' => 'Islandora Collection Content Model',
'dsid' => 'ISLANDORACM', 'dsid' => 'ISLANDORACM',
'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml", 'datastream_file' => "./$module_path/content_models/COLLECTIONCM.xml",
'dsversion' => 2, 'dsversion' => 2,
'cmodel' => 'fedora-system:ContentModel-3.0', 'cmodel' => 'fedora-system:ContentModel-3.0',
), ),
@ -1733,11 +1726,11 @@ function fedora_repository_required_fedora_objects() {
'datastreams' => array( 'datastreams' => array(
array( array(
'dsid' => 'COLLECTION_POLICY', 'dsid' => 'COLLECTION_POLICY',
'datastream_file' => "$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml", 'datastream_file' => "./$module_path/collection_policies/COLLECTION-COLLECTION POLICY.xml",
), ),
array( array(
'dsid' => 'TN', 'dsid' => 'TN',
'datastream_file' => "$module_path/images/Gnome-emblem-photos.png", 'datastream_file' => "./$module_path/images/Gnome-emblem-photos.png",
'mimetype' => 'image/png', 'mimetype' => 'image/png',
), ),
), ),
@ -2117,19 +2110,19 @@ function theme_add_to_basket_link($pid, $type = 'object') {
$save = "export_big.png"; $save = "export_big.png";
$saved = "exported_big.png"; $saved = "exported_big.png";
// $path = drupal_get_path('module', 'Fedora_Repository').'/images/'.$save ; // $path = drupal_get_path('module', 'fedora_repository').'/images/'.$save ;
/* /*
var_dump($path); var_dump($path);
var_dump(theme('image',drupal_get_path('module', 'Fedora_Repository').'/images/'.$save)); var_dump(theme('image',drupal_get_path('module', 'fedora_repository').'/images/'.$save));
die(); die();
*/ */
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))), "fedora/repository/addToBasket/" . $path, array('html' => TRUE) theme('image', drupal_get_path('module', 'fedora_repository') . '/images/' . $save, t("Add to basket"), t("Add this @object to my basket", array('@object' => $object))), "fedora/repository/addToBasket/" . $path, array('html' => TRUE)
); );
} }
return theme('image', drupal_get_path('module', 'Fedora_Repository') . '/images/' . $saved, t("In basket"), t("This @object is already in your basket", array('@object' => $object))); return theme('image', drupal_get_path('module', 'fedora_repository') . '/images/' . $saved, t("In basket"), t("This @object is already in your basket", array('@object' => $object)));
} }
/** /**
@ -2176,49 +2169,61 @@ function fedora_repository_batch_reingest_object($object, &$context) {
return NULL; return NULL;
} }
// Does the object exist? If so, purge it. // Does the object exist? If so, purge it.
//dd("About to test existence of PID: $pid");
$item = new Fedora_Item($pid); $item = new Fedora_Item($pid);
if ($item->exists()) { if ($item->exists()) {
//dd(' Found');
$item->purge(t('Remove during re-install batch job')); $item->purge(t('Remove during re-install batch job'));
//dd(' Purged');
} }
$new_item = NULL; //Need to have this a couple places... (After trying from FOXML and later for individual DSs)
$datastreams = array(); //Seems like this might be getting messed up due to scope?
// Ingest the object from the source file. // Ingest the object from the source file.
if (!empty($object['foxml_file'])) { if (!empty($object['foxml_file'])) {
$foxml_file = $object['foxml_file']; $foxml_file = $object['foxml_file'];
$new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file); $new_item = Fedora_Item::ingest_from_FOXML_file($foxml_file);
if ($new_item->exists()) { if ($new_item->exists()) {
// Batch operation was successful. // Batch operation was successful; can still add additional DSs, though
$context['message'][] = "$new_item->pid installed."; $context['message'][] = t('%pid installed.', array('%pid' => $new_item->pid));
} }
} }
if (!empty($object['dsid']) && !empty($object['datastream_file'])) { if (!empty($object['dsid']) && !empty($object['datastream_file'])) {
$datastreams = array( $datastreams[] = array(
array(
'dsid' => $object['dsid'], 'dsid' => $object['dsid'],
'datastream_file' => $object['datastream_file'], 'datastream_file' => $object['datastream_file'],
)
); );
} }
elseif (!empty($object['datastreams'])) { elseif (!empty($object['datastreams'])) {
$datastreams = $object['datastreams']; $datastreams = $object['datastreams'];
} }
if (!empty($datastreams) && is_array($datastreams)) {
$label = !empty($object['label']) ? $object['label'] : ''; $label = !empty($object['label']) ? $object['label'] : '';
if (!isset($new_item)) {
if (empty($object['foxml_file']) && !isset($new_item)) { //dd(' Not found, creating');
$new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); $new_item = Fedora_Item::ingest_new_item($pid, 'A', $label);
//dd(' Created');
}
elseif (!empty($label)) {
$new_item->modify_object($label);
} }
if (isset($new_item)) {
if (!empty($object['cmodel'])) { if (!empty($object['cmodel'])) {
//dd(' relating to cmodel');
$new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI);
//dd(' related to cmodel');
} }
if (!empty($object['parent'])) { if (!empty($object['parent'])) {
//dd(' adding parent');
$new_item->add_relationship('isMemberOfCollection', $object['parent']); $new_item->add_relationship('isMemberOfCollection', $object['parent']);
//dd(' parent added');
} }
foreach ($datastreams as $ds) { foreach ((array)$datastreams as $ds) {
//dd("trying to add ds: {$ds['dsid']}");
if ($ds['dsid'] == 'DC') { if ($ds['dsid'] == 'DC') {
$new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml'); $new_item->modify_datastream_by_value(file_get_contents($ds['datastream_file']), $ds['dsid'], $ds['label'], 'text/xml');
} }
@ -2242,22 +2247,17 @@ function fedora_repository_batch_reingest_object($object, &$context) {
*/ */
function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) { function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid = NULL, $datastream_file = NULL) {
$return = NULL; $return = NULL;
if (isset($item)) { if (!empty($item) && !empty($dsid)) {
$doc = simplexml_load_string($item->get_datastream_dissemination($dsid)); $doc = simplexml_load_string($item->get_datastream_dissemination($dsid));
} }
elseif (isset($datastream_file)) { elseif (!empty($datastream_file)) {
$doc = simplexml_load_file($datastream_file); $doc = simplexml_load_file($datastream_file);
} }
if (!empty($doc)) { if (!empty($doc) && $version = (int)$doc->attributes()->version) {
$attrs = $doc->attributes(); $return = $version;
foreach ($attrs as $name => $value) {
if ($name == 'version') {
$return = (int) $value;
break;
}
}
} }
return $return; return $return;
} }

7
fedora_repository.solutionpacks.inc

@ -110,10 +110,11 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
$object_status = 'Missing datastream'; $object_status = 'Missing datastream';
break; break;
} }
if (isset($ds['dsversion'])) { elseif (isset($ds['dsversion'])) {
// Check if the datastream is versioned and needs updating. // Check if the datastream is versioned and needs updating.
$installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']); $installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']);
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']); $available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']);
if ($available_version > $installed_version) { if ($available_version > $installed_version) {
$needs_update = TRUE; $needs_update = TRUE;
$object_status = 'Out of date'; $object_status = 'Out of date';
@ -165,8 +166,8 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
$module_name = $form_state['values']['solution_pack_module']; $module_name = $form_state['values']['solution_pack_module'];
// This should be replaced with module_invoke // This should be replaced with module_invoke
$solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); //$solution_pack_info = call_user_func($module_name . '_required_fedora_objects');
//$solution_pack_info = module_invoke($module_name, 'required_fedora_objects'); $solution_pack_info = module_invoke($module_name, 'required_fedora_objects');
$batch = array( $batch = array(
'title' => t('Installing / updating solution pack objects'), 'title' => t('Installing / updating solution pack objects'),

42
formClass.inc

@ -13,7 +13,6 @@
class formClass { class formClass {
function formClass() { function formClass() {
module_load_include('inc', 'formClass', '');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
@ -69,19 +68,11 @@ class formClass {
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
); );
$repository_title = variable_get('fedora_repository_title', 'Digital repository');
if (trim($repository_title) != '') {
$respository_title = t($repository_title);
}
else {
$repository_title = NULL;
}
$items['fedora/repository'] = array( $items['fedora/repository'] = array(
'title' => $repository_title, 'title' => 'Digital Repository',
'page callback' => 'repository_page', 'page callback' => 'repository_page',
'type' => MENU_NORMAL_ITEM, 'type' => MENU_NORMAL_ITEM,
'access arguments' => array('view fedora collection'), 'access arguments' => array('view fedora collection'),
// 'access' => TRUE
); );
$items['fedora/repository/service'] = array( $items['fedora/repository/service'] = array(
@ -100,8 +91,6 @@ class formClass {
$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),
//'type' => MENU_LOCAL_TASK,
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('edit fedora meta data') 'access arguments' => array('edit fedora meta data')
); );
@ -123,7 +112,6 @@ class formClass {
$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_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('purge objects and datastreams') 'access arguments' => array('purge objects and datastreams')
); );
@ -131,7 +119,6 @@ class formClass {
$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_CALLBACK, 'type' => MENU_CALLBACK,
'access arguments' => array('add fedora datastreams') 'access arguments' => array('add fedora datastreams')
); );
@ -140,7 +127,7 @@ class formClass {
'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******************************************
@ -197,24 +184,16 @@ class formClass {
/** /**
* Create admin form * Create admin form
* @return type * @return array
*/ */
function createAdminForm() { function createAdminForm() {
if (!user_access('administer site configuration')) { if (!user_access('administer site configuration')) {
drupal_set_message(t('You must be a site administrator to edit the Fedora collecitons list.'), 'error'); drupal_set_message(t('You must be a site administrator to edit the Fedora collections list.'), 'error');
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(
'#type' => 'textfield',
'#title' => t('Root Collection Name'),
'#default_value' => variable_get('fedora_repository_name', 'Islandora demos collection'),
'#description' => t('The Name of the Root Collection Object'),
'#required' => TRUE,
'#weight' => -20
);
$form['fedora_repository_pid'] = array( $form['fedora_repository_pid'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Root Collection PID'), '#title' => t('Root Collection PID'),
@ -249,7 +228,10 @@ class formClass {
'#description' => t('The URL to use for SOAP connections'), '#description' => t('The URL to use for SOAP connections'),
'#required' => TRUE, '#required' => TRUE,
'#weight' => -12, '#weight' => -12,
'#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() ?
theme('image', 'misc/watchdog-ok.png') . t('Successfully connected to Fedora server at @fedora_soap_url', array('@fedora_soap_url' => variable_get('fedora_soap_url', ''))) :
theme('image', 'misc/watchdog-error.png') . t('Unable to connect to Fedora server at @fedora_soap_url', array('@fedora_soap_url' => variable_get('fedora_soap_url', '')))) . '</p>',
); );
$form['fedora_soap_manage_url'] = array( $form['fedora_soap_manage_url'] = array(
@ -295,12 +277,7 @@ class formClass {
'#weight' => 0 '#weight' => 0
); );
} }
$form['fedora_repository_title'] = array(
'#type' => 'textfield',
'#title' => t('Digital Repository Title'),
'#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.'),
);
//have tabs options (like disable) //have tabs options (like disable)
$form['tabs'] = array( $form['tabs'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
@ -617,6 +594,7 @@ class formClass {
$form = new IngestObjectMetadataForm(); $form = new IngestObjectMetadataForm();
return $form->create($collection_pid, $collection_label, $form_state); return $form->create($collection_pid, $collection_label, $form_state);
} catch (Exception $e) { } catch (Exception $e) {
//dd('An error occured; reverting to QDC form...');
$form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form. $form_state['storage']['xml'] = FALSE; // An error occured revert back to the QDC Form.
} }
} }

2
plugins/DarwinCore.inc

@ -247,7 +247,7 @@ class DarwinCore {
* @return type * @return type
*/ */
public function asHTML() { public function asHTML() {
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'fedora_repository');
module_load_include('inc', 'fedora_repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');

45
plugins/FedoraObjectDetailedContent.inc

@ -43,20 +43,51 @@ class FedoraObjectDetailedContent {
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Object Details'), '#title' => t('Object Details'),
'#selected' => $details_selected, '#selected' => $details_selected,
'#weight' => 100, //XXX: Make the weight configurable?
); );
$tabset['fedora_object_details']['tabset'] = array( $tabset['fedora_object_details']['tabset'] = array(
'#type' => 'tabset', '#type' => 'tabset',
); );
$dc_html = $objectHelper->getFormattedDC($this->item);
$ds_list = $objectHelper->get_formatted_datastream_list($this->pid, NULL, $this->item);
$dc_html = $objectHelper->getFormattedDC($this->item);
$i = 0;
if (fedora_repository_access(OBJECTHELPER :: $VIEW_DETAILED_CONTENT_LIST, $this->pid, $user)) {
$tabset['fedora_object_details']['tabset']['view'] = array( $tabset['fedora_object_details']['tabset']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('View'), '#title' => t('View'),
'#content' => $dc_html . $ds_list . $purge_form, 'dc' => array(
'#type' => 'markup',
'#value' => $dc_html, //XXX: This could easily be done in Drupal, instead of using an XSL
'#weight' => $i++
),
'list' => array(
'#type' => 'fieldset',
'#title' => t('Detailed List of Content'),
'#attributes' => array(
'class' => 'fedora_detailed_list',
),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => $i++,
'parents' => array(
'#type' => 'markup',
'#value' => $objectHelper->get_parent_objects_asHTML($this->pid),
'#weight' => $i++,
),
'datastreams' => array(
'#type' => 'markup',
'#value' => $objectHelper->get_formatted_datastream_list($this->pid, NULL, $this->item), //XXX: The function called here could be cleaned up a fair bit as well...
'#weight' => $i++,
),
),
'purge' => array(
'#type' => 'markup',
'#value' => $purge_form,
'#weight' => $i++
)
); );
}
if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) {
$editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); $editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC');
@ -68,7 +99,13 @@ class FedoraObjectDetailedContent {
); );
} }
$ts = $tabset['fedora_object_details']['tabset'];
if (array_key_exists('view', $ts) || array_key_exists('edit', $ts)) {
return $tabset; return $tabset;
} }
else {
return array();
}
}
} }

2
plugins/FlvFormBuilder.inc

@ -58,7 +58,7 @@ class FlvFormBuilder extends FormBuilder {
$ds1v->appendChild($ds1content); $ds1v->appendChild($ds1content);
$rootElement->appendChild($ds1); $rootElement->appendChild($ds1);
$createdFile = drupal_get_path('module', 'Fedora_Repository') . '/images/flashThumb.jpg'; $createdFile = drupal_get_path('module', 'fedora_repository') . '/images/flashThumb.jpg';
$fileUrl = $base_url . '/' . drupal_urlencode($createdFile); //'http://'.$_SERVER['HTTP_HOST'].'/'.$createdFile; $fileUrl = $base_url . '/' . drupal_urlencode($createdFile); //'http://'.$_SERVER['HTTP_HOST'].'/'.$createdFile;
$ds1 = $dom->createElement("foxml:datastream"); $ds1 = $dom->createElement("foxml:datastream");
$ds1->setAttribute("ID", "TN"); $ds1->setAttribute("ID", "TN");

8
plugins/FormBuilder.inc

@ -95,21 +95,21 @@ class FormBuilder {
try { try {
$xml = new SimpleXMLElement($policyStreamDoc); $xml = new SimpleXMLElement($policyStreamDoc);
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), "Problem getting security policy.", NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "Problem getting security policy.", NULL, WATCHDOG_ERROR);
drupal_set_message(t('Problem getting security policy: @e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('Problem getting security policy: @e', array('@e' => check_plain($e->getMessage()))), 'error');
return FALSE; return FALSE;
} }
$policyElement = $dom->createDocumentFragment(); $policyElement = $dom->createDocumentFragment();
if (!$policyElement) { if (!$policyElement) {
drupal_set_message(t('Error parsing security policy stream.')); drupal_set_message(t('Error parsing security policy stream.'));
watchdog(t("Fedora_Repository"), "Error parsing security policy stream, could not parse policy stream.", NULL, WATCHDOG_NOTICE); watchdog(t("fedora_repository"), "Error parsing security policy stream, could not parse policy stream.", NULL, WATCHDOG_NOTICE);
return FALSE; return FALSE;
} }
$dom->importNode($policyElement, TRUE); $dom->importNode($policyElement, TRUE);
$value = $policyElement->appendXML($policyStreamDoc); $value = $policyElement->appendXML($policyStreamDoc);
if (!$value) { if (!$value) {
drupal_set_message(t('Error creating security policy stream.')); drupal_set_message(t('Error creating security policy stream.'));
watchdog(t("Fedora_Repository"), "Error creating security policy stream, could not parse collection policy template file.", NULL, WATCHDOG_NOTICE); watchdog(t("fedora_repository"), "Error creating security policy stream, could not parse collection policy template file.", NULL, WATCHDOG_NOTICE);
return FALSE; return FALSE;
} }
@ -183,7 +183,7 @@ class FormBuilder {
file_delete($form_values['ingest-file-location']); file_delete($form_values['ingest-file-location']);
} catch (exception $e) { } catch (exception $e) {
drupal_set_message(t('Error ingesting object: @e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('Error ingesting object: @e', array('@e' => check_plain($e->getMessage()))), 'error');
watchdog(t("Fedora_Repository"), "Error ingesting object: @e", array('@e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "Error ingesting object: @e", array('@e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR);
return; return;
} }
} }

2
plugins/ModsFormBuilder.inc

@ -317,7 +317,7 @@ class ModsFormBuilder extends FormBuilder {
file_delete($form_values['ingest-file-location']); file_delete($form_values['ingest-file-location']);
} catch (exception $e) { } catch (exception $e) {
drupal_set_message(t('Error ingesting object: @e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('Error ingesting object: @e', array('@e' => check_plain($e->getMessage()))), 'error');
watchdog(t("Fedora_Repository"), "Error ingesting object: @e", array('@e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "Error ingesting object: @e", array('@e' => check_plain($e->getMessage())), NULL, WATCHDOG_ERROR);
return; return;
} }
} }

8
plugins/PersonalCollectionClass.inc

@ -71,11 +71,11 @@ class PersonalCollectionClass {
* @return type * @return type
*/ */
function createCollectionPolicyStream($user, $dom, $rootElement) { function createCollectionPolicyStream($user, $dom, $rootElement) {
$collectionTemplate = file_get_contents(drupal_get_path('module', 'Fedora_Repository') . '/collection_policies/PERSONAL-COLLECTION-POLICY.xml'); $collectionTemplate = file_get_contents(drupal_get_path('module', 'fedora_repository') . '/collection_policies/PERSONAL-COLLECTION-POLICY.xml');
try { try {
$xml = new SimpleXMLElement($collectionTemplate); $xml = new SimpleXMLElement($collectionTemplate);
} catch (Exception $e) { } catch (Exception $e) {
watchdog(t("Fedora_Repository"), "Problem creating personal collection policy, could not parse collection policy stream.", NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "Problem creating personal collection policy, could not parse collection policy stream.", NULL, WATCHDOG_ERROR);
drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: @e', array('@e' => check_plain($e->getMessage()))), 'error'); drupal_set_message(t('Problem creating personal collection policy, could not parse collection policy stream: @e', array('@e' => check_plain($e->getMessage()))), 'error');
return FALSE; return FALSE;
} }
@ -83,7 +83,7 @@ class PersonalCollectionClass {
if (!$policyElement) { if (!$policyElement) {
drupal_set_message(t('Error parsing policy stream.')); drupal_set_message(t('Error parsing policy stream.'));
watchdog(t("Fedora_Repository"), "Error parsing policy stream, could not parse policy stream.", NULL, WATCHDOG_NOTICE); watchdog(t("fedora_repository"), "Error parsing policy stream, could not parse policy stream.", NULL, WATCHDOG_NOTICE);
return FALSE; return FALSE;
} }
$dom->importNode($policyElement, TRUE); $dom->importNode($policyElement, TRUE);
@ -91,7 +91,7 @@ class PersonalCollectionClass {
$value = $policyElement->appendXML($collectionTemplate); $value = $policyElement->appendXML($collectionTemplate);
if (!$value) { if (!$value) {
drupal_set_message(t('Error creating collection policy stream.')); drupal_set_message(t('Error creating collection policy stream.'));
watchdog(t("Fedora_Repository"), "Error creating collection policy stream, could not parse collection policy template file.", NULL, WATCHDOG_NOTICE); watchdog(t("fedora_repository"), "Error creating collection policy stream, could not parse collection policy template file.", NULL, WATCHDOG_NOTICE);
return FALSE; return FALSE;
} }

4
plugins/QtFormBuilder.php

@ -18,7 +18,7 @@ class QtFormBuilder extends FormBuilder {
* Constructor * Constructor
*/ */
function QtFormBuilder() { function QtFormBuilder() {
module_load_include('php', 'Fedora_Repository', 'plugins/FormBuilder'); module_load_include('php', 'fedora_repository', 'plugins/FormBuilder');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
} }
@ -57,7 +57,7 @@ class QtFormBuilder extends FormBuilder {
$rootElement->appendChild($ds1); $rootElement->appendChild($ds1);
if (empty($_SESSION['fedora_ingest_files']) || !isset($_SESSION['fedora_ingest_files']['TN'])) { if (empty($_SESSION['fedora_ingest_files']) || !isset($_SESSION['fedora_ingest_files']['TN'])) {
$createdFile = drupal_get_path('module', 'Fedora_Repository') . '/images/qtThumb.jpg'; $createdFile = drupal_get_path('module', 'fedora_repository') . '/images/qtThumb.jpg';
$fileUrl = $base_url . '/' . drupal_urlencode($createdFile); //'http://'.$_SERVER['HTTP_HOST'].'/'.$createdFile; $fileUrl = $base_url . '/' . drupal_urlencode($createdFile); //'http://'.$_SERVER['HTTP_HOST'].'/'.$createdFile;
$ds1 = $dom->createElement("foxml:datastream"); $ds1 = $dom->createElement("foxml:datastream");
$ds1->setAttribute("ID", "TN"); $ds1->setAttribute("ID", "TN");

6
plugins/Refworks.inc

@ -290,13 +290,13 @@ class Refworks {
if ($client == NULL) { if ($client == NULL) {
drupal_set_message(t('Error getting SOAP client.'), 'error'); drupal_set_message(t('Error getting SOAP client.'), 'error');
watchdog(t("FEDORA_REPOSITORY"), "Error getting SOAP client: @e", array('@e' => $e), NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), "Error getting SOAP client: @e", array('@e' => $e), NULL, WATCHDOG_ERROR);
return; return;
} }
$object = $client->__soapCall('ingest', array( $object = $client->__soapCall('ingest', array(
$params $params
)); ));
watchdog(t("FEDORA_REPOSITORY"), "Successfully added repository item " . $pid . " - ". $item_title, NULL, WATCHDOG_INFO); watchdog(t("fedora_repository"), "Successfully added repository item " . $pid . " - ". $item_title, NULL, WATCHDOG_INFO);
$deleteFiles = $form_values['delete_file']; //remove files from drupal file system $deleteFiles = $form_values['delete_file']; //remove files from drupal file system
if ($deleteFiles > 0) { if ($deleteFiles > 0) {
@ -305,7 +305,7 @@ class Refworks {
} catch (exception $e) { } catch (exception $e) {
$errors++; $errors++;
$errorMessage = 'yes'; $errorMessage = 'yes';
watchdog(t("FEDORA_REPOSITORY"), t("Error during ingest !it @e", array('!it' => $item_title, '@e' => $e)), NULL, WATCHDOG_ERROR); watchdog(t("fedora_repository"), t("Error during ingest !it @e", array('!it' => $item_title, '@e' => $e)), NULL, WATCHDOG_ERROR);
} }
$success++; $success++;
} }

5
plugins/ShowDemoStreamsInFieldSets.inc

@ -29,11 +29,10 @@ class ShowDemoStreamsInFieldSets {
* @return type * @return type
*/ */
function showMediumSize() { function showMediumSize() {
global $base_url; $path = "fedora/repository/{$this->pid}/MEDIUM_SIZE";
$collection_fieldset = array( $collection_fieldset = array(
'#collapsible' => FALSE, '#collapsible' => FALSE,
'#value' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/MEDIUM_SIZE/"><img src="' . '#value' => l(theme('image', $path), $path, array('html' => TRUE)),
$base_url . '/fedora/repository/' . $this->pid . '/MEDIUM_SIZE/MEDIUM_SIZE' . '" /></a>',
); );
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }

48
plugins/ShowStreamsInFieldSets.inc

@ -28,16 +28,22 @@ class ShowStreamsInFieldSets {
*/ */
function showFlv() { function showFlv() {
//FLV is the datastream id //FLV is the datastream id
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'fedora_repository');
$fullPath = base_path() . $path; $fullPath = url($path);
$content = ""; $content = "";
$pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/swfobject.js'; $pathTojs = drupal_get_path('module', 'fedora_repository') . '/js/swfobject.js';
drupal_add_js("$pathTojs"); drupal_add_js("$pathTojs");
$content .= '<div id="player' . $this->pid . 'FLV"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>'; $div_id = "player' . $this->pid . 'FLV";
drupal_add_js('var s1 = new SWFObject("' . $fullPath . '/flash/flvplayer.swf","single","320","240","7"); $content .= <<<EOH
s1.addParam("allowfullscreen","TRUE"); <div id="$div_id"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
s1.addVariable("file","' . base_path() . 'fedora/repository/' . $this->pid . '/FLV/FLV.flv"); EOH;
s1.write("player' . $this->pid . 'FLV");', 'inline', 'footer'); drupal_add_js(<<<EOJS
var s1 = new SWFObject("$fullPath/flash/flvplayer.swf","single","320","240","7");
s1.addParam("allowfullscreen","TRUE");
s1.addVariable("file", "$fullPath/fedora/repository/{$this->pid}/FLV/FLV.flv");
s1.write("$div_id");
EOJS
, 'inline', 'footer');
$collection_fieldset = array( $collection_fieldset = array(
'#title' => t('Flash Video'), '#title' => t('Flash Video'),
'#collapsible' => TRUE, '#collapsible' => TRUE,
@ -48,30 +54,26 @@ class ShowStreamsInFieldSets {
/** /**
* Show the TN ?? * Show the TN ??
* @global type $base_url
* @return type * @return type
*/ */
function showTN() { function showTN() {
global $base_url;
$collection_fieldset = array( $collection_fieldset = array(
'#title' => '', '#title' => '',
'#attributes' => array(), '#attributes' => array(),
'#collapsible' => FALSE, '#collapsible' => FALSE,
'#value' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/OBJ/"><img src="' . $base_url . '/fedora/repository/' . $this->pid . '/TN/TN' . '" /></a>', '#value' => l(theme('image', "fedora/repository/{$this->pid}/TN/TN", '', '', NULL, FALSE), "fedora/repository/{$this->pid}/OBJ", array('html' => TRUE)),
); );
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
/** /**
* Same as showTN but artinventory stores the image in a dsid of IMAGE instead of OBJ * Same as showTN but artinventory stores the image in a dsid of IMAGE instead of OBJ
* @global type $base_url
* @return type * @return type
*/ */
function showArtInventoryTN() { function showArtInventoryTN() {
global $base_url;
$collection_fieldset = array( $collection_fieldset = array(
'#collapsible' => FALSE, '#collapsible' => FALSE,
'#value' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/IMAGE/image.jpg"><img src="' . $base_url . '/fedora/repository/' . $this->pid . '/TN/TN' . '" /></a>', '#value' => l(theme('image', "fedora/repository/{$this->pid}/TN/TN", '', '', NULL, FALSE), "fedora/repository/{$this->pid}/IMAGE/image.jpg", array('html' => TRUE)),
); );
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }
@ -102,14 +104,16 @@ class ShowStreamsInFieldSets {
$objectHelper = new ObjectHelper(); $objectHelper = new ObjectHelper();
$item = new Fedora_Item($this->pid); $item = new Fedora_Item($this->pid);
if (key_exists('TN', $item->datastreams)) { if (key_exists('TN', $item->datastreams)) {
$tn_url = $base_url . '/fedora/repository/' . $item->pid . '/TN'; $tn_url = "fedora/repository/{$item->pid}/TN";
} }
else { else {
$tn_url = $base_path . drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_app_download_manager.png'; $tn_url = drupal_get_path('module', 'fedora_repository') . '/images/Crystal_Clear_app_download_manager.png';
} }
$tn_url = url($tn_url);
$dc_html = $objectHelper->getFormattedDC($item); $dc_html = $objectHelper->getFormattedDC($item);
$dl_link = l('<div style="float:left; padding: 10px"><img src="' . $tn_url . '"><br />' . t('View Document') .'</div>', 'fedora/repository/' . $this->pid . '/OBJ', array('html' => TRUE)); $dl_link = l('<div style="float:left; padding: 10px">' . theme('image', $tn_url, '', '', NULL, FALSE) . '<br />' . t('View Document') .'</div>', "fedora/repository/{$this->pid}/OBJ", array('html' => TRUE));
$tabset['first_tab']['tabs']['view'] = array( $tabset['first_tab']['tabs']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
@ -126,11 +130,13 @@ class ShowStreamsInFieldSets {
); );
} }
$viewer_url = 'http://docs.google.com/viewer?url=' . url("fedora/repository/{$this->pid}/OBJ/preview.pdf", array('absolute' => TRUE)) . '&embedded=TRUE';
$tabset['second_tab'] = array( $tabset['second_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Read Online'), '#title' => t('Read Online'),
'#content' => "<iframe src=\"http://docs.google.com/viewer?url=" . $base_url . '/fedora/repository/' . '#content' => <<<EOM
$this->pid . '/OBJ/preview.pdf' . "&embedded=TRUE\" style=\"width:600px; height:500px;\" frameborder=\"0\"></iframe>" <iframe src="$viewer_url" style="width:600px; height:500px;" frameborder="0"></iframe>"
EOM
); );
// Render the tabset. // Render the tabset.
@ -164,7 +170,7 @@ class ShowStreamsInFieldSets {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$item = new Fedora_Item($this->pid); $item = new Fedora_Item($this->pid);
$streams = $item->get_datastreams_list_as_array(); $streams = $item->get_datastreams_list_as_array();
return "<a href='" . $base_url . "/fedora/repository/" . $this->pid . "/OBJ/" . $streams['OBJ']['label'] . "'>" . $streams['OBJ']['label'] . "</a>"; return l($streams['OBJ']['label'], "fedora/repository/{$this->pid}/OBJ");
} }
/** /**
@ -225,7 +231,7 @@ class ShowStreamsInFieldSets {
* @return type * @return type
*/ */
function showRomeo($collapsed = FALSE) { function showRomeo($collapsed = FALSE) {
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'fedora_repository');
module_load_include('inc', 'fedora_repository', 'CollectionClass'); module_load_include('inc', 'fedora_repository', 'CollectionClass');
$collectionHelper = new CollectionClass(); $collectionHelper = new CollectionClass();
$xmlstr = $collectionHelper->getStream($this->pid, "ROMEO", 0); $xmlstr = $collectionHelper->getStream($this->pid, "ROMEO", 0);

4
plugins/fedora_imageapi.info

@ -3,5 +3,7 @@ description = Adds image manipulation support through a REST interface
package = Islandora Dependencies package = Islandora Dependencies
dependencies[] = fedora_repository dependencies[] = fedora_repository
dependencies[] = imageapi dependencies[] = imageapi
version = 6.x-12.1-RC1
version = 6.x-dev
core = 6.x core = 6.x

2
plugins/fedora_imageapi.module

@ -22,7 +22,7 @@ function fedora_imageapi_menu() {
* @param string $params * @param string $params
*/ */
function fedora_repository_image_manip($pid = '', $dsid = '', $op = '', $params = '') { function fedora_repository_image_manip($pid = '', $dsid = '', $op = '', $params = '') {
module_load_include('inc', 'Fedora_Repository', 'ObjectHelper'); module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('module', 'imageapi'); module_load_include('module', 'imageapi');
$obj = new ObjectHelper(); $obj = new ObjectHelper();
$mimetype = $obj->getMimeType($pid, $dsid); $mimetype = $obj->getMimeType($pid, $dsid);

4
plugins/herbarium.inc

@ -161,13 +161,13 @@ class Herbarium {
'#title' => t('Full-size'), '#title' => t('Full-size'),
'#content' => $html '#content' => $html
); );
$image = theme('image', "fedora/imageapi/{$this->pid}/JPG/JPG.jpg", '', '', NULL, FALSE);
$tabset['first_tab'] = array( $tabset['first_tab'] = array(
// #type and #title are the minimum requirements. // #type and #title are the minimum requirements.
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('View'), '#title' => t('View'),
// This will be the content of the tab. // This will be the content of the tab.
'#content' => '<a href="' . $base_url . '/fedora/repository/' . $this->pid . '/FULL_JPG/"><img src="' . $base_url . '/fedora/imageapi/' . '#content' => l($image, "fedora/repository/{$this->pid}/FULL_JPG", array('html' => TRUE)), '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
$this->pid . '/JPG/JPG.jpg' . '" /></a>' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
); );
$dwc = new DarwinCore($this->item); $dwc = new DarwinCore($this->item);

67
plugins/qt_viewer.inc

@ -125,31 +125,53 @@ class ShowQtStreamsInFieldSets {
if ($media === FALSE) { if ($media === FALSE) {
return ''; return '';
} }
global $base_url;
$path = drupal_get_path('module', 'Fedora_Repository'); $path = drupal_get_path('module', 'fedora_repository');
$fullPath = base_path() . $path;
$content = ''; drupal_add_js("$path/js/AC_Quicktime.js");
$pathTojs = drupal_get_path('module', 'Fedora_Repository') . '/js/AC_Quicktime.js';
drupal_add_js($pathTojs);
$divid = 'player' . md5($this->pid) . 'MOV'; $divid = 'player' . md5($this->pid) . 'MOV';
$content .= '<div class="player" id="' . $divid . '">';
$collection_fieldset = array(
'#title' => t('Quicktime'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'player' => array(
'#type' => 'markup',
'#prefix' => '<div class="player" id="' . $divid . '">',
'#suffix' => '</div>',
),
);
if ($pframe !== FALSE) { if ($pframe !== FALSE) {
$content .= '<div class="poster" style="cursor: pointer; position: relative; width: ' . $width . 'px; min-height: ' . ($height) . 'px;">'; $collection_fieldset['player']['poster_container'] = array(
$content .= '<img src="' . base_path() . 'fedora/repository/' . $this->pid . '/' . $pframe->ID . '/poster.jpg' . '" />'; '#type' => 'markup',
$content .= '<div class="play" style="font-size: 128px; color: white; position: absolute; top: 50%; left: 50%; margin-top: -0.085em; margin-left: -0.33em; opacity: 0.9; "></div>'; '#prefix' => '<div class="poster" style="cursor: pointer; position: relative; width: ' . $width . 'px; min-height: ' . ($height) . 'px;">',
$content .= '</div>'; '#suffix' => '</div>',
'poster' => array(
'#type' => 'markup',
'#value' => theme('image', "fedora/repository/{$this->pid}/{$pframe->ID}/poster.jpg", '', '', NULL, FALSE)
),
'play' => array(
'#type' => 'markup',
'#prefix' => '<div class="play" style="font-size: 128px; color: white; position: absolute; top: 50%; left: 50%; margin-top: -0.085em; margin-left: -0.33em; opacity: 0.9;">',
'#suffix' => '</div>',
'#value' => '&nbsp;',
),
);
} }
$content .= '</div>';
if ($this->enableDownload()) { if ($this->enableDownload()) {
$url = base_path() . 'fedora/repository/' . $this->pid . '/OBJ/MOV.mov'; //$url = url();
$content .= '<a class="download" href="' . $url . '">Download Media File</a>'; $collection_fieldset['download_link'] = array(
'#type' => 'markup',
'#value' => l(t('Download Media File'), "fedora/repository/{$this->pid}/OBJ/MOV.mov", array('attributes' => array('class' => 'download'))),
);
} }
$src = base_path() . 'fedora/repository/' . $this->pid . '/' . $media->ID . '/MOV.mov'; $src = url("fedora/repository/{$this->pid}/{$media->ID}/MOV.mov");
$qtparams = '';
$qtparams .= "'autostart', '" . ($pframe !== FALSE ? 'TRUE' : 'FALSE') . "', "; $qtparams = "'autostart', '" . ($pframe !== FALSE ? 'TRUE' : 'FALSE') . "', ";
$init = <<<EOD $init = <<<EOD
$(function() { $(function() {
src = "$src"; src = "$src";
if(src.substring(0,4) != 'http') { if(src.substring(0,4) != 'http') {
src = 'http://' + location.host + src; src = 'http://' + location.host + src;
@ -163,21 +185,16 @@ class ShowQtStreamsInFieldSets {
'SCALE', 'aspect', 'SCALE', 'aspect',
'LOOP', 'FALSE' 'LOOP', 'FALSE'
); );
if($('.poster', '#$divid').length ==0) { if($('.poster', '#$divid').length == 0) {
$('#$divid').append(str); $('#$divid').append(str);
} else { } else {
$('#$divid .poster').one('click', function() { $(this).hide(); $('#$divid').append(str); }); $('#$divid .poster').one('click', function() { $(this).hide(); $('#$divid').append(str); });
} }
}); });
EOD; EOD;
drupal_add_js($init, 'inline', 'footer'); drupal_add_js($init, 'inline', 'footer');
$collection_fieldset = array(
'#title' => t('Quicktime'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#value' => $content);
return theme('fieldset', $collection_fieldset); return theme('fieldset', $collection_fieldset);
} }

6
plugins/slide_viewer.inc

@ -30,14 +30,13 @@ class ShowSlideStreamsInFieldSets {
function showJPG() { function showJPG() {
module_load_include('inc', 'fedora_repository', 'plugins/tagging_form'); module_load_include('inc', 'fedora_repository', 'plugins/tagging_form');
module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets'); module_load_include('inc', 'fedora_repository', 'plugins/ShowStreamsInFieldSets');
global $base_url;
global $user; global $user;
$tabset = array(); $tabset = array();
$qs = ''; $qs = '';
if ($user->uid != 0) { if ($user->uid != 0) {
$qs = '?uid=' . base64_encode($user->name . ':' . $user->pass); $qs = '?uid=' . base64_encode($user->name . ':' . $user->pass); //XXX: Base64 encoding is not encryption; SSL would be nice...
} }
$viewer_url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer' . $qs; $viewer_url = variable_get('fedora_base_url', 'http://localhost:8080/fedora') . '/get/' . $this->pid . '/ilives:viewerSdef/getViewer' . $qs;
@ -55,8 +54,7 @@ class ShowSlideStreamsInFieldSets {
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('View'), '#title' => t('View'),
// This will be the content of the tab. // This will be the content of the tab.
'#content' => '<img src="' . $base_url . '#content' => theme('image', "fedora/imageapi/{$this->pid}/JPG/JPG.jpg", '', '', NULL, FALSE) . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
'/fedora/imageapi/' . $this->pid . '/JPG/JPG.jpg' . '" />' . '<p>' . drupal_get_form('fedora_repository_image_tagging_form', $this->pid) . '</p>',
); );
return $tabset; return $tabset;

30
plugins/tagging_form.inc

@ -19,13 +19,15 @@ function _show_subject_tags($pid) {
$obj = new Fedora_Item($pid); $obj = new Fedora_Item($pid);
$tags = new TagSet($obj); $tags = new TagSet($obj);
if (!empty($tags->tags)) { if (!empty($tags->tags)) {
$output = "<ul>"; $items = array();
foreach ($tags->tags as $tag) { foreach ($tags->tags as $tag) {
$output .= "<li title=" . $tag['creator'] . '>' . $tag['name'] . '</li> '; $items[] = array(
'data' => $tag['name'],
'title' => $tag['creator'],
);
} }
$output .= "</ul>"; return theme('item_list', $items);
} }
return $output;
} }
/** /**
@ -57,21 +59,27 @@ function fedora_repository_image_tagging_form($form_state, $pid) {
// Add the current tags to the form. // Add the current tags to the form.
$tagset = new TagSet($obj); $tagset = new TagSet($obj);
$tags = array();
foreach ($tagset->tags as $tag) { foreach ($tagset->tags as $tag) {
$form['tags-wrapper']['tags'][$tag['name']] = array( $form_tag = $form['tags-wrapper']['tags'][$tag['name']] = array(
'#prefix' => '<li>', '#prefix' => '<li>',
'#suffix' => '</li>', '#suffix' => '</li>',
); );
$form['tags-wrapper']['tags'][$tag['name']]['tag'] = array(
'#prefix' => '<a title="Added by ' . $tag['creator'] . '" href="' . $base_url . '/fedora/repository/mnpl_advanced_search/tag:' . $tag['name'] . '">', $tag_title_text = t('Added by @creator.', array(
'#value' => $tag['name'], '@creator' => $tag['creator'],
'#suffix' => '</a>', ));
$tag_mnpl_search_path = "fedora/repository/mnpl_advanced_search/tag:{$tag['name']}";
$form_tag['tag'] = array(
'#value' => l($tag['name'], $tag_mnpl_search_path, array('attributes' => array(
'title' => $tag_title_text
))),
); );
if (user_access('modify fedora datastreams') || user_access('add fedora tags')) { if (user_access('modify fedora datastreams') || user_access('add fedora tags')) {
// Delete button for each existing tag. // Delete button for each existing tag.
$form['tags-wrapper']['tags'][$tag['name']]['delete'] = array( $form_tag['delete'] = array(
'#type' => 'imagebutton', '#type' => 'imagebutton',
'#image' => $base_url . '/' . drupal_get_path('module', 'fedora_repository') . '/images/remove_icon.png', '#image' => drupal_get_path('module', 'fedora_repository') . '/images/remove_icon.png',
'#default_value' => $tag['name'], '#default_value' => $tag['name'],
'#title' => t('Delete this tag'), '#title' => t('Delete this tag'),
); );

6
xsl/convertQDC.xsl

@ -12,13 +12,13 @@
<tr><th colspan="3"><h3>MetaData</h3></th></tr> <tr><th colspan="3"><h3>MetaData</h3></th></tr>
<xsl:for-each select="/*/*"> <xsl:for-each select="/*/*">
<xsl:variable name="FULLFIELD" select="name()"/> <xsl:variable name="FULLFIELD" select="name()"/>
<xsl:variable name="FIELD" select="substring-after(name(),':')"/> <xsl:variable name="FIELD" select="local-name()"/>
<xsl:variable name="DATA" select="text()"/> <xsl:variable name="DATA" select="text()"/>
<xsl:if test="$DATA != ' '"> <xsl:if test="$DATA != ' '">
<tr><td><strong><xsl:value-of select="substring-after(name(),':')"/></strong></td><td><xsl:value-of select="text()"/> <tr><td><strong><xsl:value-of select="local-name()"/></strong></td><td><xsl:value-of select="text()"/>
<xsl:for-each select="*"> <xsl:for-each select="*">
<div> <div>
<xsl:value-of select="substring-after(name(),':')"/> = <xsl:value-of select="text()"/> <xsl:value-of select="local-name()"/> = <xsl:value-of select="text()"/>
</div> </div>
</xsl:for-each> </xsl:for-each>
</td></tr> </td></tr>

190
xsl/sparql_to_html.xsl

@ -1,12 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php"> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<!-- Red and White XSLT --> <!-- Red and White XSLT -->
<xsl:variable name="BASEURL"> <xsl:variable name="BASEURL" select="$baseUrl"/>
<xsl:value-of select="$baseUrl"/> <xsl:variable name="PATH" select="$path"/>
</xsl:variable>
<xsl:variable name="PATH">
<xsl:value-of select="$path"/>
</xsl:variable>
<xsl:variable name="thisPid" select="$collectionPid"/> <xsl:variable name="thisPid" select="$collectionPid"/>
<xsl:variable name="size" select="20"/> <xsl:variable name="size" select="20"/>
<xsl:variable name="page" select="$hitPage"/> <xsl:variable name="page" select="$hitPage"/>
@ -14,141 +10,80 @@
<xsl:variable name="end" select="($start - 1) + number($size)"/> <xsl:variable name="end" select="($start - 1) + number($size)"/>
<xsl:variable name="cellsPerRow" select="4"/> <xsl:variable name="cellsPerRow" select="4"/>
<xsl:variable name="count" select="count(s:sparql/s:results/s:result)"/> <xsl:variable name="count" select="count(s:sparql/s:results/s:result)"/>
<xsl:template match="/">
<xsl:template match="/">
<xsl:if test="$count>0"> <xsl:if test="$count>0">
<table cellpadding="3" cellspacing="3" width="90%"> <xsl:call-template name="render_pager"/>
<tr><td colspan="{$cellsPerRow}"> <table cellpadding="3" cellspacing="3" width="90%">
<!-- <div STYLE="text-align: center;">--> <xsl:apply-templates select="s:sparql/s:results"/>
<!-- start previous next --> </table><br clear="all" />
<div class="item-list"> <xsl:call-template name="render_pager"/>
<ul class="pager"> </xsl:if>
<xsl:choose> </xsl:template>
<xsl:when test="$end >= $count and $start = 1">
<xsl:value-of select="$start"/>-<xsl:value-of select="$count"/>
of <xsl:value-of select="$count"/>&#160;<br />
</xsl:when>
<xsl:when test="$end >= $count">
<xsl:value-of select="$start"/>-<xsl:value-of select="$count"/> <xsl:template match="s:sparql/s:results">
of <xsl:value-of select="$count"/>&#160;<br /> <xsl:for-each select="s:result[position() mod $cellsPerRow = 1 and position()>=$start and position() &lt;=$end]">
<li class="pager-previous"> <tr>
<a> <xsl:apply-templates select=". | following-sibling::s:result[position() &lt; $cellsPerRow]"/>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> </tr>
</xsl:attribute> </xsl:for-each>
&lt;Prev </xsl:template>
</a></li>
</xsl:when>
<xsl:when test="$start = 1">
<xsl:value-of select="$start"/>-<xsl:value-of select="$end"/>
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-next">
<a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/>
</xsl:attribute>
Next>
</a></li>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$start"/>-<xsl:value-of select="$end"/>
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-previous">
<a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/>
</xsl:attribute>
&lt;Prev
</a>&#160;</li>
<li class="pager-next">
<a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/>
</xsl:attribute>
Next>
</a></li>
</xsl:otherwise>
</xsl:choose>
</ul>
</div>
<!-- end previous next-->
<br clear="all" />
</td></tr>
<!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() &lt;=$end]"> <xsl:template name="render_pager">
<xsl:variable name='OBJECTURI' select="object/@uri"/> <!-- start previous next -->
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/>
<tr>
<td>
<img>
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN
</xsl:attribute>
</img>
<a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</td>
</tr>
</xsl:for-each>-
-->
<xsl:apply-templates select="s:sparql/s:results"/>
</table><br clear="all" />
<!-- start previous next -->
<div class="item-list"> <div class="item-list">
<ul class="pager"> <ul class="pager">
<xsl:choose> <xsl:choose>
<xsl:when test="$end >= $count and $start = 1"> <xsl:when test="$end >= $count and $start = 1">
<xsl:value-of select="$start"/>-<xsl:value-of select="$count"/> <xsl:value-of select="concat($start, '-', $count, ' of ', $count, '&#160;')"/><br />
of <xsl:value-of select="$count"/>&#160;<br />
</xsl:when> </xsl:when>
<xsl:when test="$end >= $count"> <xsl:when test="$end >= $count">
<xsl:value-of select="concat($start, '-', $count, ' of ', $count, '&#160;')"/><br />
<xsl:value-of select="$start"/>-<xsl:value-of select="$count"/>
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-previous"> <li class="pager-previous">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page - 1)"/>
</xsl:attribute> </xsl:attribute>
&lt;Prev &lt;Prev
</a></li> </a>
</li>
</xsl:when> </xsl:when>
<xsl:when test="$start = 1"> <xsl:when test="$start = 1">
<xsl:value-of select="$start"/>-<xsl:value-of select="$end"/> <xsl:value-of select="concat($start, '-', $end, ' of ', $count, '&#160;')"/><br />
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-next"> <li class="pager-next">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page + 1)"/>
</xsl:attribute> </xsl:attribute>
Next> Next>
</a></li> </a>
</li>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="$start"/>-<xsl:value-of select="$end"/> <xsl:value-of select="concat($start, '-', $end, ' of ', $count, '&#160;')"/><br />
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-previous"> <li class="pager-previous">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page - 1)"/>
</xsl:attribute> </xsl:attribute>
&lt;Prev &lt;Prev
</a>&#160;</li> </a>&#160;
</li>
<li class="pager-next"> <li class="pager-next">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page + 1)"/>
</xsl:attribute> </xsl:attribute>
Next> Next>
</a></li> </a>
</li>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</ul> </ul>
</div> </div>
<!-- end previous next--> <!-- end previous next-->
</xsl:if>
</xsl:template>
<xsl:template match="s:sparql/s:results">
<xsl:for-each select="s:result[position() mod $cellsPerRow = 1 and position()>=$start and position() &lt;=$end]">
<tr>
<xsl:apply-templates select=". | following-sibling::s:result[position() &lt; $cellsPerRow]"/>
</tr>
</xsl:for-each>
</xsl:template> </xsl:template>
<xsl:template match="s:result"> <xsl:template match="s:result">
<xsl:variable name='OBJECTURI' select="s:object/@uri"/> <xsl:variable name='OBJECTURI' select="s:object/@uri"/>
<xsl:variable name='CONTENTURI' select="s:content/@uri"/> <xsl:variable name='CONTENTURI' select="s:content/@uri"/>
@ -160,48 +95,46 @@
<xsl:with-param name="from" select="'_'"/> <xsl:with-param name="from" select="'_'"/>
<xsl:with-param name="to" select="' '"/> <xsl:with-param name="to" select="' '"/>
</xsl:call-template> </xsl:call-template>
</xsl:variable>
<xsl:variable name="cleanTitle">
<xsl:value-of select="php:functionString('fedora_repository_urlencode_string', $newTitle)"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="cleanTitle" select="php:functionString('fedora_repository_urlencode_string', $newTitle)"/>
<xsl:variable name="linkUrl"> <xsl:variable name="linkUrl">
<xsl:choose> <xsl:choose>
<xsl:when test="($CONTENTMODEL='islandora:collectionCModel')"> <xsl:when test="($CONTENTMODEL='islandora:collectionCModel')">
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="'collection'"/> <xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID, '/-/collection')"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<!--the below is an example of going straight to a datastream instead of the details page. <!--the below is an example of going straight to a datastream instead of the details page.
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>--> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>-->
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/> <xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID)"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:value-of select="s:content"/> <xsl:value-of select="s:content"/>
</xsl:variable> </xsl:variable>
<td valign="top" width="25%"> <td valign="top" width="25%">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$linkUrl"/> <xsl:attribute name="href">
<xsl:value-of select="$linkUrl"/>
</xsl:attribute> </xsl:attribute>
<img> <img>
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN <xsl:attribute name="src"><xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID, '/TN')"/></xsl:attribute>
</xsl:attribute> <xsl:attribute name="alt"><xsl:value-of select="$newTitle" disable-output-escaping="yes"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="$newTitle" disable-output-escaping="yes"/> </img>
</xsl:attribute> </a><br clear="all" />
</img> </a> <br clear="all" />
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$linkUrl"/> <xsl:attribute name="href"><xsl:value-of select="$linkUrl"/>
</xsl:attribute> </xsl:attribute>
<xsl:value-of select="$newTitle" disable-output-escaping="yes" /> <xsl:value-of select="$newTitle" disable-output-escaping="yes" />
</a> </a>
<!-- example of a url that would drill down to the details page if the url above went directly to a datastream <!-- example of a url that would drill down to the details page if the url above went directly to a datastream
<xsl:if test="($CONTENTMODEL!='islandora:collectionCModel')"> <xsl:if test="($CONTENTMODEL!='islandora:collectionCModel')">
<br />[[ <a> <br />[[ <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/>
</xsl:attribute> </xsl:attribute>
DETAILS DETAILS
</a> ]] </a> ]]
</xsl:if>--> </xsl:if>-->
</td> </td>
<xsl:if test="(position() = last()) and (position() &lt; $cellsPerRow)"> <xsl:if test="(position() = last()) and (position() &lt; $cellsPerRow)">
@ -210,6 +143,7 @@ DETAILS
</xsl:call-template> </xsl:call-template>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template name="FillerCells"> <xsl:template name="FillerCells">
<xsl:param name="cellCount"/> <xsl:param name="cellCount"/>
<td>&#160;</td> <td>&#160;</td>
@ -219,6 +153,7 @@ DETAILS
</xsl:call-template> </xsl:call-template>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template name="replace-string"> <xsl:template name="replace-string">
<xsl:param name="text"/> <xsl:param name="text"/>
<xsl:param name="from"/> <xsl:param name="from"/>
@ -245,4 +180,3 @@ DETAILS
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

Loading…
Cancel
Save