[open-ils-commits] r10577 -
trunk/Open-ILS/src/perlmods/OpenILS/Application/Search
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 10 21:55:59 EDT 2008
Author: erickson
Date: 2008-09-10 21:55:58 -0400 (Wed, 10 Sep 2008)
New Revision: 10577
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Log:
bib and authority marchtml generator now use same code
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm 2008-09-11 01:53:29 UTC (rev 10576)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm 2008-09-11 01:55:58 UTC (rev 10577)
@@ -260,39 +260,4 @@
-
-
-__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;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm 2008-09-11 01:53:29 UTC (rev 10576)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm 2008-09-11 01:55:58 UTC (rev 10577)
@@ -1205,17 +1205,21 @@
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();
-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 @@
"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 @@
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();
}
More information about the open-ils-commits
mailing list