Difference between revisions of "Export bar on abstract page"
(Created page with '{{Template:version_3_2}} This page demonstrates how to add an "Export" bar to the abstract page. ===cgi/export_redirect=== <pre> #!/usr/bin/perl use strict; use warnings; us…') |
(No difference)
|
Revision as of 12:42, 27 January 2010
This page demonstrates how to add an "Export" bar to the abstract page.
cgi/export_redirect
#!/usr/bin/perl use strict; use warnings; use EPrints; my $eprints = EPrints->new; my $repo = $eprints->current_repository; exit( 0 ) if !defined $repo; my $id = $repo->param( "dataobj" ); my $format = $repo->param( "format" ); exit( 0 ) if !EPrints::Utils::is_set( $id ); exit( 0 ) if !EPrints::Utils::is_set( $format ); my $dataobj = $repo->dataset( "archive" )->dataobj( $id ); if( !defined $dataobj ) { $repo->not_found( "eprint $id doesn't exist" ); exit( 0 ); } my $plugin = $repo->plugin( "Export::".$format ); if( !defined $plugin ) { $repo->not_found( "export format $format doesn't exist" ); exit( 0 ); } $repo->redirect( $plugin->dataobj_export_url( $dataobj ) ); exit( 0 );
archives/[repoid]/cfg/cfg.d/eprint_render.pl
Somewhere in eprint_render.pl, below my $fragments add this:
my $export_bar = $session->make_element( "div", style => "ep_block" ); $fragments{export_bar} = [ $export_bar, "XHTML" ]; { my @plugins = $session->get_plugins( type => "Export", can_accept => "dataobj/eprint", is_advertised => 1, is_visible => "all" ); my $uri = $session->get_url( path => "cgi" ) . "/roar/export_redirect"; my $form = $session->render_form( "GET", $uri ); $export_bar->appendChild( $form ); $form->appendChild( $session->render_hidden_field( dataobj => $eprint->id ) ); my $select = $session->make_element( "select", name => "format" ); $form->appendChild( $select ); foreach my $plugin (@plugins) { my $plugin_id = $plugin->get_id; $plugin_id =~ s/^Export:://; my $option = $session->make_element( "option", value => $plugin_id ); $select->appendChild( $option ); $option->appendChild( $plugin->render_name ); } my $button = $session->make_element( "input", type => "submit", value => $session->phrase( "lib/searchexpression:export_button" ), class => "ep_form_action_button" ); $form->appendChild( $button ); }
archives/[repoid]/cfg/citations/eprint/summary_page.xml
<epc:print expr="$export_bar" />