Merge branch 'master' of git.evergreen-ils.org:Evergreen into social
[evergreen-equinox.git] / Open-ILS / src / perlmods / lib / OpenILS / WWW / SuperCat.pm
index 329935b..d3a6ae8 100644 (file)
@@ -273,7 +273,7 @@ with holdings information.
 The feed type could end with the string "-full", in which case we want
 to return call numbers, copies, and URIS.
 
-Or the feed type could be "-uris", in which case we want to return
+Or the feed type could end with "-uris", in which case we want to return
 call numbers and URIS.
 
 Otherwise, we won't return any holdings.
@@ -281,14 +281,14 @@ Otherwise, we won't return any holdings.
 =cut
 
 sub parse_feed_type {
-    my $type = shift;
+    my $type = shift || '';
 
      if ($type =~ /-full$/o) {
         return 1;
     }
 
      if ($type =~ /-uris$/o) {
-        return "uris";
+        return 2;
     }
 
     # Otherwise, we'll return just the facts, ma'am
@@ -412,21 +412,22 @@ sub unapi {
     # Enable localized results of copy status, etc
     $supercat->session_locale($locale);
 
-    my $format = $cgi->param('format');
+    my $format = $cgi->param('format') || '';
     my $flesh_feed = parse_feed_type($format);
     (my $base_format = $format) =~ s/(-full|-uris)$//o;
-    my ($id,$type,$command,$lib,$depth,$paging) = ('','','');
+    my ($id,$type,$command,$lib,$depth,$paging) = ('','record','');
+    my $body = "Content-type: application/xml; charset=utf-8\n\n";
+
+    if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^\/[]+)(?:\[([0-9,]+)\])?(?:/(.+))?}o) {
+        $id = $2;
+        $paging = $3;
+        ($lib,$depth) = split('/', $4);
+        $type = 'metarecord' if ($1 =~ /^m/o);
+        $type = 'authority' if ($1 =~ /^authority/o);
+    }
 
     if (!$format) {
-        my $body = "Content-type: application/xml; charset=utf-8\n\n";
-    
         if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^\/[]+)(?:\[([0-9,]+)\])?(?:/(.+))?}o) {
-            $id = $2;
-            $paging = $3;
-            ($lib,$depth) = split('/', $4);
-            $type = 'record';
-            $type = 'metarecord' if ($1 =~ /^m/o);
-            $type = 'authority' if ($1 =~ /^authority/o);
 
             my $list = $supercat
                 ->request("open-ils.supercat.$type.formats")
@@ -1480,7 +1481,7 @@ sub create_record_feed {
         next unless $node;
 
         $xml = '';
-        if ($lib && ($type eq 'marcxml' || $type eq 'atom') && ($flesh > 0 || $flesh eq 'uris')) {
+        if ($lib && ($type eq 'marcxml' || $type eq 'atom') && ($flesh > 0)) {
             my $r = $supercat->request( "open-ils.supercat.$search.holdings_xml.retrieve", $rec, $lib, $depth, $flesh_feed, $paging );
             while ( !$r->complete ) {
                 $xml .= join('', map {$_->content} $r->recv);
@@ -1491,8 +1492,8 @@ sub create_record_feed {
 
         $node->id($item_tag);
         #$node->update_ts(cleanse_ISO8601($record->edit_date));
-        $node->link(alternate => $feed->unapi . "?id=$item_tag&format=htmlholdings-full" => 'text/html') if ($flesh > 0 || $flesh eq 'uris');
-        $node->link(opac => $feed->unapi . "?id=$item_tag&format=opac") if ($flesh > 0 || $flesh eq 'uris');
+        $node->link(alternate => $feed->unapi . "?id=$item_tag&format=htmlholdings-full" => 'text/html') if ($flesh > 0);
+        $node->link(opac => $feed->unapi . "?id=$item_tag&format=opac") if ($flesh > 0);
         $node->link(unapi => $feed->unapi . "?id=$item_tag") if ($flesh);
         $node->link('unapi-id' => $item_tag) if ($flesh);
     }