From 22ad318eb376accf24d27a38b17e27b215b01ab4 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 11 Sep 2008 01:55:58 +0000 Subject: [PATCH] bib and authority marchtml generator now use same code git-svn-id: svn://svn.open-ils.org/ILS/trunk@10577 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Search/Authority.pm | 35 ------------------ .../OpenILS/Application/Search/Biblio.pm | 36 +++++++++++-------- 2 files changed, 22 insertions(+), 49 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm index dfcbcf4371..e06599c3cd 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm @@ -260,39 +260,4 @@ sub crossref_authority_batch2 { - - -__PACKAGE__->register_method( - method => "authority_to_html", - api_name => "open-ils.search.authority.to_html" ); - -my $parser = XML::LibXML->new(); -my $xslt = XML::LibXSLT->new(); -my $stylesheet; - - -sub authority_to_html { - my( $self, $client, $id ) = @_; - - - if( !$stylesheet ) { - my $sclient = OpenSRF::Utils::SettingsClient->new(); - my $dir = $sclient->config_value( "dirs", "xsl" ); - my $xsl = $sclient->config_value( - "apps", "open-ils.search", "app_settings", "marc_html_xsl" ); - $xsl = $parser->parse_file("$dir/$xsl"); - $stylesheet = $xslt->parse_stylesheet( $xsl ); - } - - my $e = new_editor(); - my $rec = $e->retrieve_authority_record_entry($id) or return $e->event; - my $xmldoc = $parser->parse_string($rec->marc); - my $html = $stylesheet->transform($xmldoc); - - return $html->toString(); -} - - - - 1; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 1a5ea6dfb5..c6939b52c4 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -1205,17 +1205,21 @@ __PACKAGE__->register_method( method => "biblio_record_to_marc_html", api_name => "open-ils.search.biblio.record.html" ); -my $parser = XML::LibXML->new(); -my $xslt = XML::LibXSLT->new(); +__PACKAGE__->register_method( + method => "biblio_record_to_marc_html", + api_name => "open-ils.search.authority.to_html" ); + +my $parser = XML::LibXML->new(); +my $xslt = XML::LibXSLT->new(); my $marc_sheet; my $slim_marc_sheet; - my $settings_client = OpenSRF::Utils::SettingsClient->new(); + sub biblio_record_to_marc_html { - my( $self, $client, $recordid, $slim ) = @_; + my($self, $client, $recordid, $slim) = @_; my $sheet; - my $dir = $settings_client->config_value( "dirs", "xsl" ); + my $dir = $settings_client->config_value("dirs", "xsl"); if($slim) { unless($slim_marc_sheet) { @@ -1223,7 +1227,7 @@ sub biblio_record_to_marc_html { "apps", "open-ils.search", "app_settings", 'marc_html_xsl_slim'); if($xsl) { $xsl = $parser->parse_file("$dir/$xsl"); - $slim_marc_sheet = $xslt->parse_stylesheet( $xsl ); + $slim_marc_sheet = $xslt->parse_stylesheet($xsl); } } $sheet = $slim_marc_sheet; @@ -1233,22 +1237,26 @@ sub biblio_record_to_marc_html { unless($marc_sheet) { my $xsl_key = ($slim) ? 'marc_html_xsl_slim' : 'marc_html_xsl'; my $xsl = $settings_client->config_value( - "apps", "open-ils.search", "app_settings", 'marc_html_xsl' ); + "apps", "open-ils.search", "app_settings", 'marc_html_xsl'); $xsl = $parser->parse_file("$dir/$xsl"); - $marc_sheet = $xslt->parse_stylesheet( $xsl ); + $marc_sheet = $xslt->parse_stylesheet($xsl); } $sheet = $marc_sheet; } - my $record = $apputils->simple_scalar_request( - "open-ils.cstore", - "open-ils.cstore.direct.biblio.record_entry.retrieve", - $recordid ); + my $record; + my $e = new_editor(); + if($self->api_name =~ /authority/) { + $record = $e->retrieve_authority_record_entry($recordid) + or return $e->event; + } else { + $record = $e->retrieve_biblio_record_entry($recordid) + or return $e->event; + } my $xmldoc = $parser->parse_string($record->marc); my $html = $sheet->transform($xmldoc); - $html = $html->documentElement->toString(); - return $html; + return $html->documentElement->toString(); } -- 2.43.2