Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
Triggers
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Example ==== Send the coversheeted version of the document rather than the original. $c->add_trigger( EP_TRIGGER_DOC_URL_REWRITE, sub { my( %args ) = @_; my( $request, $doc, $relations, $filename ) = @args{qw( request document relations filename )}; return EP_TRIGGER_OK unless defined $doc && ref $doc eq "EPrints::DataObj::Document"; # To avoid missing field error with dark documents that do not get coversheeted. # check document is a pdf my $format = $doc->value( "format" ); # back compatibility my $mime_type = defined $doc->value( "mime_type" ) ? $doc->value( "mime_type" ) : ""; return EP_TRIGGER_OK unless( $format eq "application/pdf" || $mime_type eq "application/pdf" || $filename =~ /\.pdf$/i ); # ignore thumbnails e.g. http://.../8381/1.haspreviewThumbnailVersion/jacqueline-lane.pdf foreach my $rel ( @{$relations || []} ) { return EP_TRIGGER_OK if( $rel =~ /^is\w+ThumbnailVersionOf$/ ); } # ignore volatile documents return EP_TRIGGER_OK if $doc->has_relation( undef, "isVolatileVersionOf" ); my $session = $doc->get_session; my $eprint = $doc->get_eprint; # search for a coversheet that can be applied to this document my $coversheet = EPrints::DataObj::Coversheet->search_by_eprint( $session, $eprint ); return EP_TRIGGER_OK unless( defined $coversheet ); # check whether there is an existing covered version and whether it needs to be regenerated my $current_cs_id = $doc->get_value( 'coversheetid' ) || -1; # coversheet used to cover document my $coverdoc; # existing covered version if( $coversheet->get_id == $current_cs_id ) { # get the covered version of the document $coverdoc = $coversheet->get_coversheet_doc( $doc ); } if( defined $coverdoc ) { # return the covered version $coverdoc->set_value( "security", $doc->get_value( "security" ) ); $request->pnotes( document => $coverdoc ); $request->pnotes( dataobj => $coverdoc ); # Only update request filename to coverdoc's filename if it is defined and the document filename matches that used in the request. # If the document filename does not match that used in the request, then not updating the filename will mean requests with a # spurious filename will get a 404 error rather than returning the document under a spurious filename. $request->pnotes( filename => $coverdoc->get_main ) if defined $coverdoc->get_main && defined $doc->get_main && $filename eq $doc->get_main; } # return the uncovered document return EP_TRIGGER_DONE; }, priority => 100 );
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)