package EPrints::Plugin::Screen::Hello_EPrint; @ISA = ( 'EPrints::Plugin::Screen' ); use strict; # Make the plug-in #our $eprint = undef; our $eprints = undef; sub new { my( $class, %params ) = @_; my $self = $class->SUPER::new(%params); # Where the button to access the screen appears if anywhere, and what priority $self->{appears} = [ { place => "admin_actions", position => 1248, }, ]; $self->{actions} = [qw/ process_input /]; return $self; } # Anyone can see this screen sub can_be_viewed { 1 } sub allow_process_input { my ( $self ) = @_; return 1; } # Process input to the screen sub action_process_input { my ( $self ) = @_; my $repository = $self->{repository}; # my $eprint_id = $repository->param( "input_field" ); my $input_value = $repository->param( "input_field" ); my $eprint_dataset = $repository->dataset( "eprint" ); my @filters = ( { meta_fields => [qw( title )], value => $input_value }, ); $eprints = $eprint_dataset->search( filters => \@filters, custom_order=>"-datestamp", limit => 10, ); if (!defined $eprints or $eprints->count < 1) { $self->{processor}->add_message( "error", $self->{repository}->make_text("No EPrints found to match search: $input_value") ); } ## DO SOME VALIDATION HERE MAYBE??? # $eprint = $repository->eprint( $eprint_id ); # # if (!defined $eprint) # { # $self->{processor}->add_message( # "error", # $self->{repository}->make_text("No EPrint found with ID: $eprint_id") # ); # } } # What to display sub render { my( $self ) = @_; my $repository = $self->{repository}; my $screen_id = "Screen::".$self->{processor}->{screenid}; my $screen = $repository->plugin( $screen_id, processor => $self->{processor} ); my $frag = $repository->xml->create_document_fragment(); my $br = $repository->xml->create_element("br"); $frag->appendChild($repository->xml->create_text_node( "Hello, World!" )); $frag->appendChild($br); $frag->appendChild($br); $frag->appendChild($self->html_phrase("text")); $frag->appendChild($br); $frag->appendChild($br); my $form = $repository->render_form("POST"); my $input_field = $repository->make_element( "input", name=> "input_field", type=> "text" ); $form->appendChild($input_field); my $submit_button = $screen->render_action_button( { action => "process_input", screen => $screen, screen_id => $screen_id, } ); $form->appendChild($submit_button); $frag->appendChild( $form ); my $input_value = $repository->param( "input_field" ); if ((!defined $eprints) and (defined $input_value)) { $self->action_process_input(); } if (defined $eprints and $eprints->count > 0) { $frag->appendChild($br); $frag->appendChild($br); $frag->appendChild($br); $eprints->map( sub { my( undef, undef, $eprint ) = @_; $frag->appendChild($eprint->render_citation("default")); $frag->appendChild($repository->make_element("br")); }); # my $title = $eprint->get_value("title"); # # my $h1 = $repository->make_element("h1"); # $h1->appendChild($repository->make_text($title)); # # $frag->appendChild($h1); } return $frag; } 1