Browse Source

Overhaul FedoraObjectDetailedContent and Object helper.

FODC tab now uses theme functions to generate the DC content, datastream info,
and list of parents.  Only thing not really being generated is the tiny
(but repeated) form for downloading.  Also, make the convertQDC XSLT a little
simpler, even though it really won't need to be used anymore...
Refactored to use the new RI search methods as well.
pull/99/head
Adam Vessey 13 years ago
parent
commit
f18ce11ba5
  1. 65
      CollectionClass.inc
  2. 326
      ObjectHelper.inc
  3. 2
      fedora_repository.module
  4. 5
      formClass.inc
  5. 24
      plugins/FedoraObjectDetailedContent.inc
  6. 6
      xsl/convertQDC.xsl

65
CollectionClass.inc

@ -40,6 +40,36 @@ class CollectionClass {
}
}
static function get_collection_query($pid) {
if ($query = self::_get_collection_query_from_stream($pid)) {
return $query;
}
else {
return self::_get_default_collection_query($pid);
}
}
static function _get_collection_query_from_stream($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;
}
}
static function _get_default_collection_query($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
* calls getRelatedItems but enforces limit and offset
@ -49,15 +79,11 @@ class CollectionClass {
* @param type $itqlquery
* @return type
*/
function getRelatedObjects($pid, $limit, $offset, $itqlquery=NULL) {
static 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');
}
$itqlquery = self::get_collection_query($pid);
}
return $this->getRelatedItems($pid, $itqlquery, $limit, $offset);
return self::getRelatedItems($pid, $itqlquery, $limit, $offset);
}
/**
@ -70,7 +96,7 @@ class CollectionClass {
* @param int $offset
* @return type
*/
function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) {
static function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
if (!isset($offset)) {
@ -84,27 +110,12 @@ class CollectionClass {
$objectHelper = new ObjectHelper();
$query_string = $itqlquery;
if (!isset($query_string)) {
$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
$query_string = preg_replace("/\%parent_collection\%/", "<info:fedora/$pid>", $query_string);
$query_string = self::get_collection_query($pid);
}
// Replace %parent_collection% with the actual collection PID
$query_string = preg_replace("/\%parent_collection\%/", "<info:fedora/$pid>", $query_string);
$query_string = htmlentities(urlencode($query_string));
$content = '';

326
ObjectHelper.inc

@ -313,36 +313,42 @@ class ObjectHelper {
function create_link_for_ds($pid, $dataStreamValue) {
global $base_url;
$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);
$purge_image = '&nbsp;';
if (user_access(ObjectHelper :: $PURGE_FEDORA_OBJECTSANDSTREAMS)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
$allow = fedora_fesl_check_roles($pid, 'write');
}
if ($allow) {
$purgeImage = '<a title="purge datastream ' . $dataStreamValue->label . '" href="' . $base_url . '/fedora/repository/purgeStream/' .
$pid . '/' . $dataStreamValue->ID . '/' . $dataStreamValue->label . '"><img src="' . $base_url . '/' . $path .
'/images/purge.gif" alt="purge datastream" /></a>';
$purge_text = t("purge datastream @label", array('@label' => $dataStreamValue->label));
$purge_path = "fedora/repository/purgeStream/$pid/{$dataStreamValue->ID}/{$dataStreamValue->label}";
$purge_image = l(theme('image', "$path/images/purge.gif", $purge_text, $purge_text, NULL, FALSE), $purge_path, array(
'html' => TRUE,
));
}
}
else {
$purgeImage = '&nbsp;';
$purge_image = '&nbsp;';
}
$fullPath = base_path() . $path;
// 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.
$replaceImage = '&nbsp;';
$replace_image = '&nbsp;';
if (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
$allow = fedora_fesl_check_roles($pid, 'write');
}
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,
));
}
}
@ -350,13 +356,17 @@ class ObjectHelper {
$id = $dataStreamValue->ID;
$label = $dataStreamValue->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;
$view = '<a href="' . $base_url . '/fedora/repository/' . drupal_urlencode($pid) . '/' . $id . '/' . drupal_urlencode($label) .
'" target="_blank" >' . t('View') . '</a>';
$action = "$base_url/fedora/repository/object_download/" . drupal_urlencode($pid) . '/' . $id . '/' . drupal_urlencode(preg_replace('/\//i', '${1}_', $label)); // Necessary to handle the case of Datastream labels that contain slashes. Ugh.
$view = l(t('View'), "'fedora/repository/$pid/$id/$label_deslashed", array(
'attributes' => array(
'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>';
if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) {
if (user_access(ObjectHelper::$EDIT_FEDORA_METADATA)) {
$versions = $item->get_datastream_history($id);
if (is_array($versions)) {
$downloadVersion = '<form method="GET" action="' . $action . '" onsubmit="this.action=\'' . $action . '\' + \'/\'+this.version.value;">';
@ -369,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 $content;
return array(
array(
'data' => $label,
),
array(
'data' => $view,
),
array(
'data' => $downloadVersion,
),
array(
'data' => $mimeType
),
array(
'data' => $replace_image . $purge_image,
),
);
}
/**
@ -387,33 +412,36 @@ class ObjectHelper {
$dsid = array_key_exists('QDC', $item->get_datastreams_list_as_array()) ? 'QDC' : 'DC';
$xmlstr = $item->get_datastream_dissemination($dsid);
if (empty($xmlstr)) {
return '';
}
try {
$proc = new XsltProcessor();
} catch (Exception $e) {
drupal_set_message($e->getMessage(), 'error');
return;
}
$simplexml = new SimpleXMLElement($xmlstr);
$proc->setParameter('', 'baseUrl', $base_url);
$proc->setParameter('', 'path', $base_url . '/' . $path);
$input = NULL;
$xsl = new DomDocument();
try {
$xsl->load($path . '/xsl/convertQDC.xsl');
$input = new DomDocument();
$input->loadXML(trim($xmlstr));
} catch (Exception $e) {
watchdog('fedora_repository', "Problem loading XSL file: @e", array('@e' => $e->getMessage()), NULL, WATCHDOG_ERROR);
$headers = array(
array(
'data' => t('Metadata'),
'colspan' => 2,
),
);
$rows = array();
dsm($xmlstr);
foreach ($simplexml->getNamespaces(TRUE) as $ns) {
foreach ($simplexml->children($ns) as $child) {
$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 $output;
return theme('table', $headers, $rows, array('class' => 'dc-table'));
}
/**
@ -432,16 +460,17 @@ class ObjectHelper {
$dsid = array_key_exists('QDC', $ds_list) ? 'QDC' : 'DC';
$path = drupal_get_path('module', 'fedora_repository');
//$baseUrl=substr($baseUrl, 0, (strpos($baseUrl, "/")-1));
if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
$allow = fedora_fesl_check_roles($pid, 'write');
}
if ($allow) {
$output .= '<br /><a title = "' . t('Edit Meta Data') . '" href="' . $base_url . '/fedora/repository/' . 'editmetadata/' . $pid . '/' .
$dsid . '"><img src="' . $base_url . '/' . $path . '/images/edit.gif" alt="' . t('Edit Meta Data') . '" /></a>';
$link_image = theme('image', "$path/images/edit.gif", t('Edit Metadata'));
$link = l($link_image, "fedora/repository/editmetadata/$pid", array(
'html' => TRUE,
));
$output .= '<br />' . $link;
}
}
return $output;
@ -461,7 +490,7 @@ class ObjectHelper {
*
*/
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', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
@ -473,58 +502,42 @@ class ObjectHelper {
if (user_access(ObjectHelper :: $VIEW_DETAILED_CONTENT_LIST)) {
$availableDataStreamsText = 'Detailed List of Content';
//$metaDataText='Description';
$mainStreamLabel = NULL;
$object = $fedoraItem->get_datastreams_list_as_SimpleXML();
if (!isset($object)) {
drupal_set_message(t("No datastreams available"));
return ' ';
}
$hasOBJStream = NULL;
$hasTNStream = FALSE;
$dataStreamBody = "<br /><table>\n";
$cmDatastreams = array();
if (variable_get('fedora_object_restrict_datastreams', FALSE) == TRUE && ($cm = ContentModel::loadFromObject($object_pid)) !== FALSE) {
$cmDatastreams = $cm->listDatastreams();
}
$dataStreamBody .= $this->get_parent_objects_asHTML($object_pid);
$dataStreamBody .= '<tr><th colspan="4"><h3>' . t("!text", array('!text' => $availableDataStreamsText)) . '</h3></th></tr>';
$headers = array(
array(
'data' => $availableDataStreamsText,
'colspan' => 4,
),
);
$DSs = array();
foreach ($object as $datastream) {
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 ($datastreamValue->ID == 'OBJ') {
$hasOBJStream = '1';
$mainStreamLabel = $datastreamValue->label;
$mainStreamLabel = str_replace("_", " ", $mainStreamLabel);
}
if ($datastreamValue->ID == 'TN') {
$hasTNStream = TRUE;
}
//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 (user_access(ObjectHelper :: $ADD_FEDORA_STREAMS)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
$allow = fedora_fesl_check_roles($object_pid, 'write');
}
if ($allow) {
$dataStreamBody .= drupal_get_form('add_stream_form', $object_pid);
}
if (user_access(ObjectHelper::$ADD_FEDORA_STREAMS) && //If allowed throw Drupal
((module_exists('fedora_fesl') && fedora_fesl_check_roles($object_pid, 'write')) || //And allowed throw FESL
!module_exists('fedora_fesl'))) { //Or not using FESL, draw the add datastream form.
$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;
}
@ -616,55 +629,44 @@ class ObjectHelper {
* @param type $pid
* @return type
*/
function fedora_repository_access($op, $pid) {
global $user;
function fedora_repository_access($op, $pid = NULL, $as_user = NULL) {
$returnValue = FALSE;
$isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
if (!$isRestricted) {
$namespaceAccess = TRUE;
}
if ($pid == NULL) {
$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;
foreach ($nameSpaceAllowed as $nameSpace) {
$pos = stripos($pid, $nameSpace);
if ($pos === 0) {
$namespaceAccess = TRUE;
}
}
if ($namespaceAccess) {
$user_access = user_access($op);
if ($user_access == NULL) {
return FALSE;
}
return $user_access;
$isRestricted = variable_get('fedora_namespace_restriction_enforced', TRUE);
$namespace_access = NULL;
if (!$isRestricted) {
$namespace_access = TRUE;
}
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
* 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
*/
function parseContent($content, $pid, $dsId, $collection, $pageNumber = NULL) {
$path = drupal_get_path('module', 'fedora_repository');
global $base_url;
$collection_pid = $pid; //we will be changing the pid later maybe
//module_load_include('php', ''Fedora_Repository'', 'ObjectHelper');
$objectHelper = $this;
$parsedContent = NULL;
$contentModels = $objectHelper->get_content_models_list($pid);
$contentModels = $this->get_content_models_list($pid);
$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;
$datastreams = $this->get_formatted_datastream_list($pid, $contentModels, $fedoraItem);
@ -672,6 +674,9 @@ class ObjectHelper {
if (!empty($contentModels)) {
foreach ($contentModels as $contentModel) {
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;
$isCollection = TRUE;
}
@ -689,8 +694,8 @@ class ObjectHelper {
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
module_load_include('inc', 'Fedora_Repository', 'CollectionPolicy');
$collectionPolicyExists = $objectHelper->getMimeType($pid, CollectionPolicy::getDefaultDSID());
if (user_access(ObjectHelper :: $INGEST_FEDORA_OBJECTS) && $collectionPolicyExists) {
$collectionPolicyExists = $this->getMimeType($pid, CollectionPolicy::getDefaultDSID());
if (user_access(ObjectHelper::$INGEST_FEDORA_OBJECTS) && $collectionPolicyExists) {
if (!empty($collectionPolicyExists)) {
$allow = TRUE;
if (module_exists('fedora_fesl')) {
@ -745,19 +750,34 @@ class ObjectHelper {
return $output;
}
/**
* Get the query to find parent objects.
*
* @param $pid string
* 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
*/
static function _parent_query($pid) {
return 'select $object $title from <#ri>
where ($object <fedora-model:label> $title
and <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title';
}
/**
* Gets the parent objects that this object is related to
*
* @param unknown_type $pid
* @return unknown
* @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::_parent_query())
*/
function get_parent_objects($pid) {
$query_string = 'select $object $title from <#ri>
where ($object <fedora-model:label> $title
and <info:fedora/' . $pid . '> <fedora-rels-ext:isMemberOfCollection> $object
and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
order by $title';
$objects = $this->getCollectionInfo($pid, $query_string);
$query_string = self::_parent_query();
module_load_include('inc', 'fedora_repository', 'CollectionClass');
$objects = CollectionClass::getRelatedItems($pid, $query_string);
return $objects;
}
@ -768,31 +788,24 @@ class ObjectHelper {
* @return string
*/
function get_parent_objects_asHTML($pid) {
global $base_url;
$parent_collections = $this->get_parent_objects($pid);
try {
$parent_collections = new SimpleXMLElement($parent_collections);
} catch (exception $e) {
drupal_set_message(t('Error getting parent objects @e', array('@e' => check_plain($e->getMessage()))));
return;
}
module_load_include('inc', 'fedora_repository', 'CollectionClass');
$results = self::perform_itql_query(self::_parent_query($pid));
$parent_collections = array();
foreach ($results as $result) {
$collection_title = $result['title'];
$collection_pid = $result['object'];
$path = "fedora/repository/$collection_pid/-/$collection_title";
$parent = array(
'data' => l($collection_title, $path),
);
$parent_collections_HTML = '';
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>';
$parent_collections[] = $parent;
}
return $parent_collections_HTML;
if (!empty($parent_collections)) {
return theme('item_list', $parent_collections, t('Belongs to these collections'), 'ul');
}
}
/**
@ -842,6 +855,8 @@ class ObjectHelper {
/**
* Get a tree of related pids - for the basket functionality
*
* FIXME: This doesn't actually get a tree...
*
* @param type $pid
* @return type
*/
@ -852,19 +867,18 @@ class ObjectHelper {
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
// 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
and $o <dc:description> $desc
and $o <mulgara:is> <info:fedora/' . $pid . '>';
$url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
$url .= "?type=tuples&flush=TRUE&format=csv&limit=1000&lang=itql&stream=on&query=";
$content = do_curl($url . htmlentities(urlencode($query_string)));
$rows = explode("\n", $content);
$fields = explode(',', $rows[1]);
$results = self::perform_itql_query($query_string);
$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));
@ -878,38 +892,24 @@ class ObjectHelper {
* @return type
*/
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
$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 ' .
'and $o <fedora-model:label> $title ' .
// 'and $o <dc:description> $desc '.
'and ( ';
'and ( ' . implode(' or ', $query_chunks) . ' )';
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);
// Knock of the first heading row
array_shift($rows);
$results = self::perform_itql_query($query_string);
$child_pids = array();
if (count($rows)) {
if ($results) {
// iterate through each row
foreach ($rows as $row) {
if ($row == "") {
continue;
}
$fields = explode(',', $row);
$child_pid = substr($fields[0], 12);
$child_pids[$child_pid] = array('title' => $fields[1], 'description' => $fields[2]);
foreach ($results as $result) {
$child_pids[$result['o']] = array('title' => $result['title']);
}
if (!empty($child_pids)) {
$child_pids += $this->get_child_pids(array_keys($child_pids));

2
fedora_repository.module

@ -869,7 +869,7 @@ function fedora_repository_perm() {
* @param type $account
* @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');
$objectHelper = new ObjectHelper();
return $objectHelper->fedora_repository_access($op, $node, $account);

5
formClass.inc

@ -13,8 +13,8 @@
class formClass {
function formClass() {
module_load_include('inc', 'formClass', '');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
}
/**
@ -128,7 +128,8 @@ class formClass {
'title' => t('Collection view'),
'page callback' => 'fedora_collection_view',
'type' => MENU_CALLBACK,
'access argruments' => array('view fedora collection')
'access callback' => 'fedora_repository_access',
'access argruments' => array(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA),
);
//new for mnpl******************************************

24
plugins/FedoraObjectDetailedContent.inc

@ -48,9 +48,8 @@ class FedoraObjectDetailedContent {
$tabset['fedora_object_details']['tabset'] = array(
'#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)) {
@ -63,9 +62,24 @@ class FedoraObjectDetailedContent {
'#weight' => $i++
),
'list' => array(
'#type' => 'markup',
'#value' => $ds_list, //XXX: The function called here could be cleaned up a fair bit as well...
'#weight' => $i++
'#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',

6
xsl/convertQDC.xsl

@ -12,13 +12,13 @@
<tr><th colspan="3"><h3>MetaData</h3></th></tr>
<xsl:for-each select="/*/*">
<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: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="*">
<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>
</xsl:for-each>
</td></tr>

Loading…
Cancel
Save