#################################################################################### # This Widget is based upon the widget developed for UCA. # The UCA version relies upon a customised EPrint workflow with specific types # This is a generic version that relies upon the default workflow. # The UCA code is left in place but is commented out. # ################################################################################## package EPrints::Plugin::MePrints::Widget::AllOutputs; use EPrints::Plugin::MePrints::Widget; @ISA = ( 'EPrints::Plugin::MePrints::Widget' ); use strict; sub new { my( $class, %params ) = @_; my $self = $class->SUPER::new( %params ); if ( !$self->{session} ) { $self->{session} = $self->{processor}->{session}; } $self->{name} = "EPrints Profile System: Published List Widget"; $self->{visible} = "all"; $self->{advertise} = 1; $self->{surround} = 'Simple'; $self->{render_title} = 0; $self->{max_display} = 30; return $self; } sub render_content { my( $self ) = @_; my $session = $self->{session}; my $user = $self->{user}; my $frag = $session->make_doc_fragment; my $ds = $session->get_repository->get_dataset( "archive" ); my $searchexp = new EPrints::Search( session=>$session, satisfy_all => 0, dataset=>$ds ); my $users_name = $user->get_value("name"); my $creators_name = $users_name->{family}.", ".$users_name->{given}; $searchexp->add_field( $ds->field( "creators_name" ), $creators_name, "EQ" ) if $ds->has_field( "creators_name" ); $searchexp->add_field( $ds->field( "contributors_name" ), $creators_name, "EQ" ) if $ds->has_field( "contributors_name" ); $searchexp->add_field( $ds->field( "editors_name" ), $creators_name, "EQ" ) if $ds->has_field( "editors_name" ); $searchexp->add_field( $ds->field( "exhibitors_name" ), $creators_name, "EQ" ) if $ds->has_field( "exhibitors_name" ); $searchexp->add_field( $ds->field( "curators_name" ), $creators_name, "EQ" ) if $ds->has_field( "curators_name" ); $searchexp->add_field( $ds->field( "publication_creators_name" ), $creators_name, "EQ" ) if $ds->has_field( "publication_creators_name" ); $searchexp->add_field( $ds->field( "publication_editors_name" ), $creators_name, "EQ" ) if $ds->has_field( "publication_editors_name" ); my $list = $searchexp->perform_search; $list = $list->reorder("-date"); if ( $list->count ) { my $art_design = []; my $publications = []; my $exhibitions = []; my $conferences = []; $list->map(sub { my ($session, $dataset, $eprint, $info ) = @_; my $id = $eprint->get_value("eprintid"); my $type = $eprint->get_value("type"); # my $categories = $eprint->get_value("category"); # my $is_artwork = $eprint->get_value("is_artwork"); #art and design: # if ($is_artwork eq 'TRUE') # { # my $exhibition_found = 0; # #check for Exhibition/show # CAT: foreach my $category (@$categories) # { # if (defined $category && $category =~ m/^.*[E|e]xhibition.*|^.*[S|s]how.*/) # { # $exhibition_found = 1; # last CAT; # } # } # if ($exhibition_found) # { # push @$exhibitions, $eprint; # } # else # { # push @$art_design, $eprint; # } # # } # else # { # if ($type =~ m/artwork/) # { # push @$art_design, $eprint; # } # elsif ($type =~ m/^.*[C|c]onference.*|^.*[W|w]orkshop.*/ ) # { # push @$conferences, $eprint; # } # else # { # push @$publications, $eprint; # } # } # if ( $type =~ m/exhibition/i) { push @$exhibitions, $eprint; } elsif ( $type =~ m/conference_item/i) { push @$conferences, $eprint; } else { push @$publications, $eprint; } }); if ( scalar (@$art_design) ) { $frag->appendChild( $self->html_phrase( "Art" ) ); my $itemlist = $session->make_element( "ol" ); foreach my $eprint (@$art_design) { my $eprintitem = form_eprint_list_item($session, $eprint->get_id, $eprint->get_value( "title" ), $eprint->get_value( "date") ); $itemlist->appendChild( $eprintitem ); } $frag->appendChild( $itemlist ); } if ( scalar (@$publications) ) { $frag->appendChild( $self->html_phrase( "Publications" ) ); my $itemlist = $session->make_element( "ol" ); foreach my $eprint (@$publications) { my $eprintitem = form_eprint_list_item($session, $eprint->get_id, $eprint->get_value( "title" ), $eprint->get_value( "date") ); $itemlist->appendChild( $eprintitem ); } $frag->appendChild( $itemlist ); } if ( scalar (@$exhibitions) ) { $frag->appendChild( $self->html_phrase( "Exhibitions" ) ); my $itemlist = $session->make_element( "ol" ); foreach my $eprint (@$exhibitions) { my $eprintitem = form_eprint_list_item($session, $eprint->get_id, $eprint->get_value( "title" ), $eprint->get_value( "date") ); $itemlist->appendChild( $eprintitem ); } $frag->appendChild( $itemlist ); } if ( scalar (@$conferences) ) { $frag->appendChild( $self->html_phrase( "Conferences" ) ); my $itemlist = $session->make_element( "ol" ); foreach my $eprint (@$conferences) { my $eprintitem = form_eprint_list_item($session, $eprint->get_id, $eprint->get_value( "title" ), $eprint->get_value( "date") ); $itemlist->appendChild( $eprintitem ); } $frag->appendChild( $itemlist ); } } else { $frag->appendChild( $self->html_phrase( "noitems" ) ); } return $frag; } sub form_eprint_list_item { my ($session, $id, $title, $year ) = @_; my $eprintlink = $session->render_link( $session->get_repository->get_conf( "base_url" )."/".$id ); $year = "n.d." if ( ! EPrints::Utils::is_set($year) ); $eprintlink->appendChild( $session->make_text( "($year) $title" ) ); my $eprintitem = $session->make_element( "li" ); $eprintitem->appendChild( $eprintlink ); return $eprintitem; } 1;