use strict; use EPrints; # This extension works only with Stats::View::SetDesc my $session = new EPrints::Session; return unless( defined $session ); unless( $session->can_call( 'irstats2', 'allow' ) && $session->call( ['irstats2', 'allow'], $session, 'irstats2/view' ) ) { $session->get_request->status( 401 ); $session->terminate; exit; } my $handler = $session->plugin( "Stats::Handler" ); unless(defined $handler) { print STDOUT "
IRStats2: internal error (handler not available)
"; $session->terminate(); return; } my $set_name = $session->param( 'set_name' ); unless( defined $set_name ) { $session->terminate; return; } my $sets = $session->config( 'irstats2', 'sets' ); my $minimum_filter_length = 0; foreach my $set ( @$sets ) { if( ( defined( $set->{name}) && $set->{name} eq $set_name ) || ( defined( $set->{field} ) && $set->{field} eq $set_name ) ) { $minimum_filter_length = $set->{minimum_filter_length}; } } my $base_url = $session->param( 'base_url' ) || '/cgi/stats/report'; $base_url =~ s/\/$//g; my $report = ''; if( $base_url =~ /report\/(.*)$/ ) { $report = $1; $base_url =~ s/\/?([^\/]*)$//g; } my $q = $session->param( 'q' ); my $values; if( $set_name eq 'eprintid' ) { # special case - there should only be only one match my $eprint = $session->dataset( 'archive' )->dataobj( $q ); if( defined $eprint ) { print STDOUT "".$eprint->value( 'title' ).""; $session->terminate; return; } } elsif( length($q) < $minimum_filter_length ) { print STDOUT $session->phrase( "cgi/stats/set_finder:minimum_filter_length", characters => $minimum_filter_length ); $session->terminate; return; } else { $values = $handler->get_all_rendered_set_values( $set_name, $q ); } my $html = "