Permalink
Browse files

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.
  • Loading branch information...
adam-vessey committed Apr 20, 2012
1 parent 5ae0e46 commit f18ce11ba5076c3338af3b235de217c7a6dbe18f
Showing with 234 additions and 208 deletions.
  1. +38 −27 CollectionClass.inc
  2. +170 −170 ObjectHelper.inc
  3. +1 −1 fedora_repository.module
  4. +3 −2 formClass.inc
  5. +19 −5 plugins/FedoraObjectDetailedContent.inc
  6. +3 −3 xsl/convertQDC.xsl
View
@@ -39,6 +39,36 @@ class CollectionClass {
$this->pid = $pid;
}
}
+
+ 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
@@ -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,26 +110,11 @@ 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));
Oops, something went wrong.

0 comments on commit f18ce11

Please sign in to comment.