Screen Plugins: Difference between revisions
⧼vector-appearance-label⧽
No edit summary |
No edit summary |
||
| Line 6: | Line 6: | ||
* Actions - things which modify the system in some way. | * Actions - things which modify the system in some way. | ||
* Rights testing - the entire plugin, and individual actions, can be restricted in various ways. | * Rights testing - the entire plugin, and individual actions, can be restricted in various ways. | ||
For EPrints 3.2+ | |||
===To make a Screen for the Admin section=== | |||
To make an Admin Screen plugin, you create a Perl Module in <code>[eprints]/perl_bin/EPrints/Plugin/Screen/</code> with the following basic structure | |||
<pre> | |||
package EPrints::Plugin::Screen::Mypackage; | |||
use EPrints::Plugin::Screen; | |||
@ISA = ( 'EPrints::Plugin::Screen' ); | |||
use strict; | |||
sub new | |||
{ | |||
my( $class, %params ) = @_; | |||
my $self = $class->SUPER::new(%params); | |||
$self->{priv} = undef; | |||
$self->{appears} = [ | |||
{ | |||
place => "admin_actions_editorial", # see notes below | |||
position => 1450, | |||
}, | |||
]; | |||
return $self; | |||
} | |||
sub can_be_viewed | |||
{ | |||
my( $self ) = @_; | |||
return $self->allow( "my/conf/value" ); | |||
} | |||
sub render | |||
{ | |||
my( $self ) = @_; | |||
my $session = $self->{session}; | |||
my $user = $session->current_user; | |||
my $p = $session->make_doc_fragment; | |||
# create page contents: | |||
my $h = $session->make_element( "h3" ); | |||
$h->appendChild($session->make_text( "Look up organisations known to OA-RJ" )); | |||
$p->appendChild($h); | |||
return $p | |||
} | |||
</pre> | |||
====The locations==== | |||
There are 4 tabs defined: | |||
* admin_actions_editorial | |||
* admin_actions_system | |||
* admin_actions_config | |||
* admin_actions_misc | |||
===Making the page appear=== | |||
There are three steps to making a page appear: | |||
# The Perl Package should test for ''view-ability'' | |||
<pre> | |||
sub can_be_viewed | |||
{ | |||
my( $self ) = @_; | |||
return $self->allow( "my/conf/value" ); | |||
} | |||
</pre> | |||
# The ''User'' DataObject needs to list the privilege under a role: | |||
<pre> | |||
# EPrints::DataObj::User | |||
foo_bar => [ | |||
"my/view/value", | |||
], | |||
foo_baz => [ | |||
"my/view/value", | |||
"my/conf/value", | |||
], | |||
</pre> | |||
# The user_roles.pl file needs to make the role available to the user-type: | |||
<pre> | |||
$c->{user_roles}->{user} = [qw{ | |||
// snip | |||
foo_bar | |||
}], | |||
$c->{user_roles}->{admin} = [qw{ | |||
// | |||
foo_baz | |||
}], | |||
</pre> | |||
See Also: [[List of Core Screen Plugins]] | See Also: [[List of Core Screen Plugins]] | ||
Revision as of 14:09, 13 April 2010
Screen Plugins are used to handle the User Interface. Screen plugins provide the UI to the user-interaction parts of EPrints. A screen plugin can include:
- A render (a screen plugin can actually have several pages (like a search) or none (like the eprint move plugin). Most have a single page of output.
- Actions - things which modify the system in some way.
- Rights testing - the entire plugin, and individual actions, can be restricted in various ways.
For EPrints 3.2+
To make a Screen for the Admin section
To make an Admin Screen plugin, you create a Perl Module in [eprints]/perl_bin/EPrints/Plugin/Screen/ with the following basic structure
package EPrints::Plugin::Screen::Mypackage;
use EPrints::Plugin::Screen;
@ISA = ( 'EPrints::Plugin::Screen' );
use strict;
sub new
{
my( $class, %params ) = @_;
my $self = $class->SUPER::new(%params);
$self->{priv} = undef;
$self->{appears} = [
{
place => "admin_actions_editorial", # see notes below
position => 1450,
},
];
return $self;
}
sub can_be_viewed
{
my( $self ) = @_;
return $self->allow( "my/conf/value" );
}
sub render
{
my( $self ) = @_;
my $session = $self->{session};
my $user = $session->current_user;
my $p = $session->make_doc_fragment;
# create page contents:
my $h = $session->make_element( "h3" );
$h->appendChild($session->make_text( "Look up organisations known to OA-RJ" ));
$p->appendChild($h);
return $p
}
The locations
There are 4 tabs defined:
- admin_actions_editorial
- admin_actions_system
- admin_actions_config
- admin_actions_misc
Making the page appear
There are three steps to making a page appear:
- The Perl Package should test for view-ability
sub can_be_viewed
{
my( $self ) = @_;
return $self->allow( "my/conf/value" );
}
- The User DataObject needs to list the privilege under a role:
# EPrints::DataObj::User
foo_bar => [
"my/view/value",
],
foo_baz => [
"my/view/value",
"my/conf/value",
],
- The user_roles.pl file needs to make the role available to the user-type:
$c->{user_roles}->{user} = [qw{
// snip
foo_bar
}],
$c->{user_roles}->{admin} = [qw{
//
foo_baz
}],
See Also: List of Core Screen Plugins