$type = 'metarecord' if ($1 =~ /^m/o);
my $list = $supercat
- ->request("open-ils.supercat.$type.formats")
+ ->request("open-ils.supercat.$type.formats")
->gather(1);
print "\n";
$offset -= 1;
}
- my (undef,$version,$org,$type,$class,$terms) = split '/', $path;
+ my ($version,$org,$type,$class,$terms,$sort);
+ (undef,$version,$org,$type,$class,$terms,$sort,$lang) = split '/', $path;
- my $lang = $cgi->param('searchLang');
- my $sort = $cgi->param('searchSort');
- my $site = $cgi->param('searchSite');
-
+ $lang ||= $cgi->param('searchLang');
+ $sort ||= $cgi->param('searchSort');
$terms ||= $cgi->param('searchTerms');
$class ||= $cgi->param('searchClass') || '-';
$type ||= $cgi->param('responseType') || '-';
return $stuff;
}
+my %browse_types = (
+ call_number => {
+ xml => sub {
+ my $tree = shift;
+
+ my $year = (gmtime())[5] + 1900;
+ my $content = '';
+
+ $content .= "Content-type: application/xml\n\n";
+ $content .= "<hold:volumes xmlns:hold='http://open-ils.org/spec/holdings/v1'>";
+
+ for my $cn (@$tree) {
+ (my $cn_class = $cn->class_name) =~ s/::/-/gso;
+ $cn_class =~ s/Fieldmapper-//gso;
+
+ my $cn_tag = "tag:open-ils.org,$year:$cn_class/".$cn->id;
+ my $cn_lib = $cn->owning_lib->shortname;
+ my $cn_label = $cn->label;
+
+ (my $ou_class = $cn->owning_lib->class_name) =~ s/::/-/gso;
+ $ou_class =~ s/Fieldmapper-//gso;
+
+ my $ou_tag = "tag:open-ils.org,$year:$ou_class/".$cn->owning_lib->id;
+ my $ou_name = $cn->owning_lib->name;
+
+ $content .= "<hold:volume id='$cn_tag' lib='$cn_lib' label='$cn_label'>";
+ $content .= "<act:owning_lib xmlns:act='http://open-ils.org/spec/actors/v1' id='$ou_tag' name='$ou_name'/>";
+ $content .= $cn->record->marc;
+ $content .= "</hold:volume>";
+ }
+
+ $content .= '</hold:volumes>';
+ return $content;
+ }
+ }
+
+);
+sub string_browse {
+ my $apache = shift;
+ return Apache2::Const::DECLINED if (-e $apache->filename);
+
+ my $cgi = new CGI;
+ my $year = (gmtime())[5] + 1900;
+
+ my $host = $cgi->virtual_host || $cgi->server_name;
+
+ my $rel_name = quotemeta($cgi->url(-relative=>1));
+
+ my $add_path = 1;
+ $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
+
+ my $url = $cgi->url(-path_info=>$add_path);
+ my $root = (split 'browse', $url)[0];
+ my $base = (split 'browse', $url)[0] . 'browse';
+ my $unapi = (split 'browse', $url)[0] . 'unapi';
+
+
+ my $path = (split 'browse', $url)[1];
+
+ my (undef,$format,$axis,$site,$string,$page,$page_size) = split '/', $path;
+
+
+ $site ||= $cgi->param('searchOrg');
+ $page ||= $cgi->param('startPage') || 0;
+ $page_size ||= $cgi->param('count') || 9;
+
+ $page = 0 if ($page !~ /^\d+$/);
+
+ unless ($string and $axis and grep { $axis eq $_ } keys %browse_types) {
+ warn "something's wrong...";
+ return undef;
+ }
+
+ $string = decode_utf8($string);
+ $string =~ s/\+/ /go;
+ $string =~ s/'//go;
+
+ my $tree = $supercat->request(
+ "open-ils.supercat.$axis.browse",
+ $string,
+ $site,
+ $page_size,
+ $page
+ )->gather(1);
+
+ my $content = $browse_types{$axis}{$format}->($tree);
+ print $content;
+ return Apache2::Const::OK;
+}
+
1;