# this package relies on MePrints so this config file must be read after the z_meprints.pl config # # Bazaar Configuration $c->{plugins}{"ENovaMePrints"}{params}{disable} = 0; $c->{plugins}{"MePrints::ENovaLayout"}{params}{disable} = 0; $c->{plugins}{"MePrints::ENovaMePrintsHandler"}{params}{disable} = 0; $c->{plugins}{"MePrints::Layout::ENovaTwoColumn"}{params}{disable} = 0; $c->{plugins}{"MePrints::Layout::Tabbed"}{params}{disable} = 0; $c->{plugins}{"MePrints::Widget::AllOutputs"}{params}{disable} = 0; $c->{plugins}{"MePrints::Widget::ENovaDetails"}{params}{disable} = 0; $c->{plugins}{"MePrints::Widget::ENovaTopTen"}{params}{disable} = 0; $c->{plugins}{"MePrints::Widget::UserGallery"}{params}{disable} = 0; $c->{plugins}{"MePrints::Widget::Video"}{params}{disable} = 0; $c->{plugins}{"Screen::User::ENovaHomepage"}{params}{disable} = 0; $c->{plugins}{"Screen::User::Download_cv"}{params}{disable} = 0; $c->{plugins}{"Screen::User::Upload"}{params}{disable} = 0; $c->{plugins}{"Screen::EPMC::ENovaMePrints"}{params}{disable} = 0; #override some of the standard MePrints Plugins $c->{plugin_alias_map}->{"MePrints"} = "ENovaMePrints"; $c->{plugin_alias_map}->{"ENovaMePrints"} = undef; $c->{plugin_alias_map}->{"MePrints::Layout"} = "MePrints::ENovaLayout"; $c->{plugin_alias_map}->{"MePrints::ENovaLayout"} = undef; $c->{plugin_alias_map}->{"MePrints::Layout::TwoColumn"} = "MePrints::Layout::ENovaTwoColumn"; $c->{plugin_alias_map}->{"MePrints::Layout::ENovaTwoColumn"} = undef; $c->{plugin_alias_map}->{"MePrints::MePrintsHandler"} = "MePrints::ENovaMePrintsHandler"; $c->{plugin_alias_map}->{"MePrints::ENovaMePrintsHandler"} = undef; $c->{plugin_alias_map}->{"MePrints::Widget::Details"} = "MePrints::Widget::ENovaDetails"; $c->{plugin_alias_map}->{"MePrints::Widget::ENovaDetails"} = undef; $c->{plugin_alias_map}->{"MePrints::Widget::TopTen"} = "MePrints::Widget::ENovaTopTen"; $c->{plugin_alias_map}->{"MePrints::Widget::ENovaTopTen"} = undef; $c->{plugin_alias_map}->{"Screen::User::Homepage"} = "Screen::User::ENovaHomepage"; $c->{plugin_alias_map}->{"Screen::User::ENovaHomepage"} = undef; #disable the saved search Plugin and the edit plugin $c->{plugins}{"Screen::User::SavedSearches"}{params}{disable} = 1; $c->{plugins}{"Screen::User::Edit"}{params}{disable} = 1; ###################################################################### # # MePrints configuration # # All About MEPrints is a JISC rapid innovations project to build a # user profile system for EPrints. The extension we have developed is # called MePrints. This configuration file lets you control how the # MePrints extension works in your repository. # # For an overview of MePrints, see: # http://wiki.eprints.org/w/MePrintsOverview # # For technical instructions, including troubleshooting, see: # http://wiki.eprints.org/w/MePrintsInstall # ###################################################################### #disable controls on the profile $c->{plugins}->{"Screen::User::History"}->{params}->{disable} = 1; #move controls on the profile $c->{plugins}->{"Screen::User::SavedSearches"}->{appears}->{user_actions} = 100; $c->{plugins}->{"Screen::User::Staff::Edit"}->{appears}->{user_actions} = 200; $c->{plugins}->{"Screen::User::Remove"}->{appears}->{user_actions} = 300; $c->{plugins}->{"Screen::User::Edit"}->{appears}->{user_actions} = 400; $c->{plugins}->{"Screen::User::UploadPicture"}->{appears}->{user_actions} = 500; #$c->{plugins}->{"Screen::User::Upload"}->{appears}->{user_actions} = 600; #$c->{plugins}->{"Screen::User::Upload"}->{appears}->{user_actions} = 600; # Allow repo.ac.uk/profile/XYZ urls #$c->{rewrite_exceptions} = [] unless( defined $c->{rewrite_exceptions} ); #push( @{$c->{rewrite_exceptions}}, "/profile/" ); # Add extra metadata fields for user profiles @{ $c->{fields}->{user} } = ( @{ $c->{fields}->{user} }, ( { 'name' => 'supervision', 'type' => 'longtext', 'input_rows' => 5, 'render_value' => 'EPrints::MePrints::enova_render_first_n_chars_with_paras', }, { 'name' => 'ext_examinations', 'type' => 'longtext', 'input_rows' => 5, 'render_value' => 'EPrints::MePrints::enova_render_first_n_chars_with_paras', }, { 'name' => 'profile_video', 'type' => 'url', }, { 'name' => 'rights_to_video', 'input_style' => 'radio', 'type' => 'boolean', }, { name => 'statement', 'type' => 'longtext', 'render_value' => 'EPrints::MePrints::enova_render_first_n_chars_with_paras'}, { name => "esteem", type => "longtext", 'render_value' => 'EPrints::MePrints::enova_render_first_n_chars_with_paras' }, { name => "interests", type => "text", multiple => 1, 'render_value' => 'EPrints::MePrints::enova_render_strings_as_list' }, { name => "grants", type => "longtext", input_rows=>5, 'render_value' => 'EPrints::MePrints::enova_render_first_n_chars_with_paras' }, { name => "memberships", type => "longtext", input_rows=>5, 'render_value' => 'EPrints::MePrints::enova_render_first_n_chars_with_paras' }, { name => "links", type => "url", multiple => 1, 'render_value' => 'EPrints::MePrints::enova_render_strings_as_list' }, { name => "named_links", type => "compound", multiple => 1, render_value => "EPrints::MePrints::enova_render_named_url", toform => "enova_toform", fromform => "enova_fromform", fields => [ { sub_name => 'url', type => 'url', input_cols => 40 }, { sub_name => 'desc', type => 'text', input_cols => 15, } ], }, )); foreach my $field (@{ $c->{fields}->{user} }) { #if the fields qualifications or expertise are defined then modify the renderer if ( $field->{name} eq 'expertise' ) { $field->{render_value} = 'EPrints::MePrints::enova_render_strings_as_list'; } if ( $field->{name} eq 'qualifications' ) { $field->{render_value} = 'EPrints::MePrints::enova_render_first_n_chars_with_paras'; } } $c->{meprints_control_position} = "above"; $c->{help_link_on_left} = "true"; $c->{meprints_download_cv} = 1; $c->{meprints_stats_tab} = 0; $c->{enova_toform} = sub { my( $value, $session ) = @_; if (scalar @$value) { my $last_url; foreach my $entry (@$value) { my $url_val = $entry->{url}; $entry->{url} = "http://" unless EPrints::Utils::is_set( $url_val ); $last_url = $entry->{url}; } if ($last_url ne "http://") { push @$value, { url => "http://" }; } } else { push @$value, { url => "http://" }; } return $value; }; $c->{enova_fromform} = sub { my( $value, $session ) = @_; foreach my $entry (@$value) { my $url_val = $entry->{url}; $entry->{url} = undef if (EPrints::Utils::is_set( $url_val ) && $url_val eq "http://"); } return $value; }; { package EPrints::MePrints; my $DEFAULT_N_CHARS = 800; sub enova_render_first_n_chars_with_paras { my( $session , $field , $value, $alllangs, $nolink, $object ) = @_; my $chunk = $session->make_doc_fragment; return $chunk unless( EPrints::Utils::is_set( $value ) ); my $id = "meprints_render_".$field->get_name; my $div = $session->make_element( "div", id => $id, class => "meprints_short_rendering" ); $chunk->appendChild( $div ); if( length( $value ) <= $DEFAULT_N_CHARS ) { my $para_text = enova_render_paras($session, $field, $value, $object); } else { my $first_n = substr( $value, 0, $DEFAULT_N_CHARS ); my $para_first_n = enova_render_paras($session, $field, $first_n, $object); $div->appendChild( $para_first_n ); my $link = $session->make_element( "a", href => "#", onclick => "\$('$id').style.display = 'none';\$('$id"."_all"."').style.display = 'block';return false;", class => "meprints_link_more" ); $link->appendChild( $session->html_phrase( "meprints:link:more" ) ); $div->appendChild( $link ); my $long_div = $session->make_element( "div", id => $id."_all", style => "display:none;" ); $chunk->appendChild( $long_div ); my $para_text = enova_render_paras($session, $field, $value, $object); $long_div->appendChild( $para_text ); } return $chunk; } sub enova_render_paras { my( $session, $field, $value, $object ) = @_; my $frag = $session->make_doc_fragment; # normalise newlines $value =~ s/(\r\n|\n|\r)/\n/gs; my @paras = split( /\n\n/, $value ); foreach my $para( @paras ) { $para =~ s/^\s*\n?//; $para =~ s/\n?\s*$//; next if $para eq ""; my $p = $session->make_element( "p", style=>"text-align: left; margin: 1em auto 0em auto" ); my @lines = split( /\n/, $para ); for( my $i=0; $iappendChild( $session->make_text( $lines[$i] ) ); $p->appendChild( $session->make_element( "br" ) ) unless $i == $#lines; } $frag->appendChild( $p ); } return $frag; } sub enova_render_strings_as_list { my( $session , $field , $value, $alllangs, $nolink, $object ) = @_; my $chunk = $session->make_doc_fragment; return $chunk unless( EPrints::Utils::is_set( $value ) ); my $id = "meprints_render_".$field->get_name; my $div = $session->make_element( "div", id => $id, class => "meprints_short_rendering" ); $chunk->appendChild( $div ); my $ul = $session->make_element( "ul" ); $div->appendChild( $ul ); foreach my $entry (@{$value}) { my $li = $session->make_element( "li" ); $ul->appendChild($li); $li->appendChild( $field->render_value_no_multiple( $session, $entry, $alllangs, $nolink, $object ) ); #$li->appendChild( $session->make_text( $entry ) ); } return $chunk; } sub enova_render_named_url { my( $session, $field, $value ) = @_; my $f = $field->get_property( "fields_cache" ); my $fmap = {}; foreach my $field_conf ( @{$f} ) { my $fieldname = $field_conf->{name}; my $this_field = $field->{dataset}->get_field( $fieldname ); $fmap->{$field_conf->{sub_name}} = $this_field; } my $ul = $session->make_element( "ul" ); foreach my $row ( @{$value} ) { my $li = $session->make_element( "li" ); my $link = $session->render_link( $row->{url} ); if( defined $row->{desc} ) { $link->appendChild( $fmap->{desc}->render_single_value( $session, $row->{desc} ) ); } else { my $text = $row->{url}; if( length( $text ) > 40 ) { $text = substr( $text, 0, 40 )."..."; } $link->appendChild( $session->make_text( $text ) ); } $li->appendChild( $link ); $ul->appendChild( $li ); } return $ul; } }