c.className = "record_misc_cell";
var resources = record.types_of_resource();
- for( var i in resources )
- this.buildResourcePic( c, resources[i]);
+ for( var i in resources ) {
+ var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath;
+ var res = modsFormatToMARC(resources[i]);
+ var a = elem("a",
+ {href: prefix + "?target=record_result&mrid=" +
+ record.doc_id() + "&format=" + res +
+ "&page=0&location=" + this.location +
+ "&depth=" + this.depth} );
+ this.buildResourcePic( c, resources[i], a);
+ }
author_row.id = "record_result_author_row_" + id;
title_row.id = "record_result_title_row_" + id;
}
-AbstractRecordResultPage.prototype.buildResourcePic = function(c, resource) {
- return buildResourcePic(c, resource);
+AbstractRecordResultPage.prototype.buildResourcePic = function(c, resource, parent) {
+ return buildResourcePic(c, resource, parent);
}
-function buildResourcePic(c, resource) {
+function buildResourcePic(c, resource, parent) {
var pic = createAppElement("img");
-
if(resource.indexOf("sound recording") != -1)
resource = "sound recording";
pic.setAttribute("src", "/images/" + resource + ".jpg");
+ pic.setAttribute("border", "0");
pic.className = "record_resource_pic";
pic.setAttribute("width", "20");
pic.setAttribute("height", "20");
}
c.childNodes[index].innerHTML = "";
- c.childNodes[index].appendChild(pic);
+
+ if(parent) {
+ parent.appendChild(pic);
+ c.childNodes[index].appendChild(parent);
+ } else {
+ c.childNodes[index].appendChild(pic);
+ }
}
AbstractRecordResultPage.prototype.buildRecordImage = function(pic_cell, record, page_id, title) {
"mr_search_query", this.string,
"mr_search_location", location,
"mr_search_depth", this.searchDepth,
+ "format", this.format,
"page", this.page + 1
] );
}
"mr_search_query", this.string,
"mr_search_location", location,
"mr_search_depth", this.searchDepth,
+ "format", this.format,
"page", this.page - 1
] );
}
"mr_search_query", this.string,
"mr_search_location", this.searchLocation,
"mr_search_depth", this.searchDepth,
+ "format", this.format,
"page", 0
];
}
"&hits_per_page=" + this.hitsPerPage +
"&location=" + this.searchLocation +
"&depth=" + this.searchDepth );
+
href.appendChild(createAppTextNode(value));
href.title = "View titles for " + t + "";
break;
"&hits_per_page=" + this.hitsPerPage +
"&location=" + this.searchLocation +
"&depth=" + this.searchDepth );
+
href.title = "View titles for " + t + "";
break;
var location = paramObj.__mr_search_location;
var depth = paramObj.__mr_search_depth;
var hitsper = paramObj.__hits_per_page;
+ var format = paramObj.__format;
lastSearchString = string;
lastSearchType = stype;
this.hitsPerPage = parseInt(hitsper);
debug("mr search params string " + string + " stype " + stype +
- " location " + location + " depth " + depth );
+ " location " + location + " depth " + depth + " format " + format);
if(depth == null || depth == "undefined")
depth = globalSearchDepth;
string != this.string ||
stype != this.stype ||
this.searchLocation != location ||
+ this.format != format ||
this.searchDepth != depth ) {
debug("Resetting MRSearch for search " + string);
this.resetSearch();
this.stype = stype;
this.string = string;
this.page = parseInt(paramObj.__page);
+ this.format = format;
+
if(this.page == null) this.page = 0;
this.searchOffset = this.page * this.hitsPerPage;
if(isNaN(this.searchDepth)) this.searchDepth = 0;
if(isNaN(this.searchLocation)) this.searchLocation = 1;
+ var form = this.format;
+ if(this.format == "all") form = null;
var creq = new RemoteRequest(
"open-ils.search", method,
- this.stype, this.string, this.searchLocation, this.searchDepth );
+ this.stype, this.string, this.searchLocation, this.searchDepth, form );
/* this request grabs the search count. When the counts come back
the metarecord ids are collected */
debug("Search method is " + method);
+ var form = this.format;
+ if(this.format == "all") form = null;
+
var request = new RemoteRequest(
- "open-ils.search", method,
- obj.stype, obj.string,
- obj.searchLocation,
- obj.searchDepth, "50", obj.searchOffset );
+ "open-ils.search", method, obj.stype, obj.string, obj.searchLocation,
+ obj.searchDepth, "50", obj.searchOffset, form );
request.setCompleteCallback(
function(req) {
*/
var title_href = createAppElement("a");
- title_href.setAttribute("href","?sub_frame=1&target=record_detail&record=" + record.doc_id() );
+ var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath;
+ title_href.setAttribute("href", prefix + "?sub_frame=1&target=record_detail&record=" + record.doc_id() );
title_href.setAttribute("target","_top"); /* escape to the outermost frame */
title_href.appendChild(mktext(record.title()));
due = due.replace(/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/,"");
var title_href = createAppElement("a");
- title_href.setAttribute("href","?sub_frame=1&target=record_detail&record=" + record.doc_id() );
+ var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath;
+ title_href.setAttribute("href",prefix + "?sub_frame=1&target=record_detail&record=" + record.doc_id() );
title_href.setAttribute("target","_top"); /* escape to the outermost frame */
title_href.appendChild(mktext(record.title()));
this.page = parseInt(paramObj.__page);
var hitsper = paramObj.__hits_per_page;
+ this.format = paramObj.__format;
if(hitsper)
this.hitsPerPage = parseInt(hitsper);
RecordResultPage.prototype.mrSearch = function(mrid) {
+ var form = this.format;
+ if(form == "all") form = null;
var request = new RemoteRequest("open-ils.search",
- "open-ils.search.biblio.metarecord_to_records", mrid );
+ "open-ils.search.biblio.metarecord_to_records", mrid, form );
+
debug("Gathering doc ids for metarecord " + mrid );
var obj = this;
SearchBarFormChunk.prototype.init = function() {
+
debug("Initing searchBarFormchunk");
this.search_query = getById("mr_search_query");
this.search_type = getById("mr_search_type");
this.search_button = getById("mr_search_button");
this.searchRange = getById("search_range_select");
+ this.setFormat();
+}
+
+
+SearchBarFormChunk.prototype.setFormat = function() {
+ var fsel = getById("mr_search_format");
+ var format = paramObj.__format;
+ for( var idx = 0; idx != fsel.options.length; idx++ ) {
+ var obj = fsel.options[idx];
+ if(obj && obj.value == format) {
+ fsel.selectedIndex = idx;
+ obj.selected = true;
+ }
+ }
+
}
SearchBarFormChunk.prototype.resetPage = function() {
this.init();
this.search_button.onclick = mrSearchSubmitForm;
+
this.search_query.onkeydown = mrSearchSubmitOnEnter;
this.search_type.onkeydown = mrSearchSubmitOnEnter;
-
var s = paramObj.__mr_search_query;
if(!s) s = lastSearchString;
var t = paramObj.__mr_search_type;
function mrSearchSubmitForm() {
+
var search_query = getById("mr_search_query").value;
var search_type = getById("mr_search_type").value;
+ var form = getById("mr_search_format").value
+
+ /*
+ var fsel = getById("mr_search_format");
+ var form = fsel.options[fsel.selectedIndex].value
+ */
var depth = globalSearchDepth;
"mr_search_query", search_query,
"mr_search_location", location,
"mr_search_depth", depth,
+ "format", form,
"page", 0
] );
}
/* forces the submission of the search */
function mrSearchSubmitOnEnter(evt) {
- evt = (evt) ? evt : ((window.event) ? event : null); /* for mozilla and IE */
+ var win = getWindow();
+ evt = (evt) ? evt : ((win.event) ? globalAppFrame.event : null); /* for mozilla and IE */
var obj = globalSearchBarFormChunk;
var code = grabCharCode(evt);
- if(code==13||code==3) {
+ if(code==13 || code==3) {
mrSearchSubmitForm();
+ return false;
}
}
return "g";
case "sound recording":
return "ij";
+ case "sound recording-nonmusical":
+ return "ij";
+ case "sound recording-musical":
+ return "ij";
case "software, multimedia":
return "m";
case "still images":
-=head comment
-__PACKAGE__->register_method(
- method => "cat_biblio_search_class_id",
- api_name => "open-ils.search.cat.biblio.class.id",
- argc => 3,
- note => "Searches biblio information by search class and returns the IDs",
-);
-
-sub cat_biblio_search_class_id {
-
- my( $self, $client, $org_id, $class, $string, $limit, $offset ) = @_;
-
- $offset ||= 0;
- $limit ||= 100;
- $limit -= 1;
-
-
- my $bool = ($class eq "subject" || $class eq "keyword");
- $string = OpenILS::Application::Search->filter_search($string, $bool);
-
- if(!$string) {
- return OpenILS::EX->new("SEARCH_TOO_LARGE")->ex();
- }
-
- warn "Searching cat.biblio.class.id string: $string offset: $offset limit: $limit\n";
-
- throw OpenSRF::EX::InvalidArg
- ("Not enough args to open-ils.search.cat.biblio.class")
- unless( defined($org_id) and $class and $string );
-
-
- my $search_hash;
-
- my $cache_key = md5_hex( $org_id . $class . $string );
- my $id_array = OpenILS::Application::SearchCache->get_cache($cache_key);
-
- if(ref($id_array)) {
- warn "Returning class search from cache\n";
- my $size = @$id_array;
- my @ids = @$id_array[ $offset..($offset+$limit) ];
- return { count => $size, ids => \@ids };
- }
-
- my $method = $self->method_lookup("open-ils.search.biblio.marc");
- if(!$method) {
- throw OpenSRF::EX::PANIC
- ("Can't lookup method 'open-ils.search.biblio.marc'");
- }
-
- my ($records) = $method->run( $cat_search_hash->{$class}, $string );
-
- my @cache_ids;
-
- for my $i (@$records) {
- if(defined($i->[0])) {
- push @cache_ids, $i->[0];
- }
- }
-
- my @ids = @cache_ids[ $offset..($offset+$limit) ];
- my $size = @$records;
-
- OpenILS::Application::SearchCache->put_cache(
- $cache_key, \@cache_ids, $size );
-
- return { count =>$size, ids => \@ids };
-
-}
-=cut
__PACKAGE__->register_method(
method => "biblio_search_class_count",
sub biblio_search_class_count {
- my( $self, $client, $class, $string, $org_id, $org_type ) = @_;
+ my( $self, $client, $class, $string, $org_id, $org_type, $format ) = @_;
warn "org: $org_id : depth: $org_type\n";
warn "Searching biblio.class.id\n" .
"string: $string " .
"org_id: $org_id\n" .
- "depth: $org_type\n" ;
+ "depth: $org_type\n" .
+ "format: $format\n";
# my $bool = ($class eq "subject" || $class eq "keyword");
# $string = OpenILS::Application::Search->filter_search($string, $bool);
term => $string,
org_unit => $org_id,
cache_page_size => 1,
- depth =>$org_type );
+ depth =>$org_type,
+ format => $format );
my $count = $request->gather(1);
warn "Received count $count\n";
sub biblio_search_class {
my( $self, $client, $class, $string,
- $org_id, $org_type, $limit, $offset ) = @_;
+ $org_id, $org_type, $limit, $offset, $format ) = @_;
warn "org: $org_id : depth: $org_type : limit: $limit : offset: $offset\n";
"\noffset: $offset\n" .
"limit: $limit\n" .
"org_id: $org_id\n" .
- "depth: $org_type\n" ;
+ "depth: $org_type\n" .
+ "format: $format\n";
warn "Search filtering string " . time() . "\n";
$string = OpenILS::Application::Search->filter_search($string);
depth => $org_type,
limit => $limit,
offset => $offset,
+ format => $format,
cache_page_size => 200,
);
);
sub biblio_mrid_to_record_ids {
- my( $self, $client, $mrid ) = @_;
+ my( $self, $client, $mrid, $format ) = @_;
throw OpenSRF::EX::InvalidArg
("search.biblio.metarecord_to_record_ids requires mr id")
"open-ils.storage",
#"open-ils.storage.direct.metabib.metarecord_source_map.search.metarecord", $mrid );
"open-ils.storage.ordered.metabib.metarecord.records.atomic",
- $mrid );
+ $mrid, $format );
#my @ids;
WRAPPER html/select name='format' id='mr_search_format';
option(value='all', selected='selected', content="All Formats");
- option(value='audiobooks', content="Audiobooks");
- option(value='', content="...");
+ option(value='at', content="Books");
+ option(value='at-d', content="Large Print Books");
+ option(value='ij', content="Audiobooks");
+ option(value='g', content="Video Recording");
+ option(value='cd', content="Music");
+ option(value='m', content="Electronic Resources");
END;
input( type='hidden', name='page', value='0');
input(id='mr_search_query', name='mr_search_query',
- type='textarea', size='54');
+ type='textarea', size='54' );
+#onkeydown='logicNode.mrSearchSubmitOnEnter(event); event.preventDefault = true; event.cancelBubble=true;'); # overwite this onkeydown if !IE XXX
#space(1);
lines(2);
space(2);
WRAPPER html/select name='format' id='mr_search_format';
option(value='all', selected='selected', content="All Formats");
- option(value='audiobooks', content="Audiobooks");
- option(value='', content="...");
+ option(value='at', content="Books");
+ option(value='at-d', content="Large Print Books");
+ option(value='ij', content="Audiobooks");
+ option(value='g', content="Video Recording");
+ option(value='cd', content="Music");
+ option(value='m', content="Electronic Resources");
END;
END;