API:EPrints/Repository
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
- 1 NAME
- 2 SYNOPSIS
- 3 DESCRIPTION
- 4 METHODS
- 4.1 new
- 4.2 new
- 4.3 query
- 4.4 param
- 4.5 xml
- 4.6 xhtml
- 4.7 eprint
- 4.8 current_user
- 4.9 user
- 4.10 user_by_username
- 4.11 user_by_email
- 4.12 dataset
- 4.13 config
- 4.14 log
- 4.15 call
- 4.16 can_call
- 4.17 try_call
- 4.18 template_dirs
- 4.19 id
- 4.20 exec
- 4.21 test_config
- 4.22 reload_config
- 4.23 noise
- 4.24 init_from_indexer
- 5 COPYRIGHT
NAME
EPrints::Repository - connection to a single Repository instance
SYNOPSIS
use EPrints;
$repo = EPrints->new->current_repository;
$repo = EPrints->new->repository( "myrepo" );
$xml = $repo->xml;
$cuser = $repo->current_user;
$repo->log( "Got user " . $cuser->id );
DESCRIPTION
EPrints::Repository represents a connection to the EPrints system. It connects to a single EPrints repository, and the database used by that repository.
Each Repository has a "current language". If you are running in a multilingual mode, this is used by the HTML rendering functions to choose what language to return text in.
The Repository object also knows about the current apache connection, if there is one, including the CGI parameters.
If the connection requires a username and password then it can also give access to the EPrints::DataObj::User object representing the user who is causing this request. See current_user.
The Repository object provides access to the EPrints::XML and EPrints::XHTML class which contain methods for creating XHTML results which can be returned via the web interface.
METHODS
new
$repository = EPrints::Repository->new( %opts )
Creates and returns a new repository object. This is a utility object only and will only have the basic system configuration available.
new
$repository = EPrints::Repository->new( $repository_id, %opts )
Create a connection to an EPrints repository $repository_id which provides access to the database and to the repository configuration.
Options:
db_connect - 1 check_db - 1 noise - 0
query
$query = $repository->query
Return the CGI object describing the current HTTP query, or undefined if this isn't a CGI script.
param
$value or @values = $repository->param( $name )
Passes through to CGI.pm param method.
$value = $repository->param( $name ): returns the value of CGI parameter $name.
@values = $repository->param: returns an array of the names of all the CGI parameters in the current request.
xml
$xml = $repo->xml
Return an EPrints::XML object for working with XML.
xhtml
$xhtml = $repo->xhtml
Return an EPrints::XHTML object for working with XHTML.
eprint
$eprint = $repository->eprint( $eprint_id );
A convience method to return the EPrints::DataObj::EPrint with the given ID, or undef.
Equivent to $repository->dataset("eprint")->dataobj( $eprint_id )
current_user
$user = $repository->current_user
Return the current logged in EPrints::DataObj::User for this session.
Return undef if there isn't one.
user
$user = $repository->user( $user_id );
A convience method to return the EPrints::DataObj::User with the given ID, or undef.
Equivent to $repository->dataset("user")->dataobj( $user_id )
user_by_username
$user = $repository->user_by_username( $username );
Return the user with the given username, or undef.
user_by_email
$user = $repository->user_by_email( $email );
Return the EPrints::DataObj::User with the given email, or undef.
dataset
$dataset = $repository->dataset( $setname )
Return a given EPrints::DataSet or undef if it doesn't exist.
config
$confitem = $repository->config( $key, [@subkeys] )
Returns a named configuration setting including those defined in archvies/<archive_id>/cfg/cfg.d/
$repository->config( "stuff", "en", "foo" )
is equivalent to
$repository->config( "stuff" )->{en}->{foo}
log
$repository->log( $msg [, $level ] )
Log a plain text message $msg. If $level is given only logs if $level is greater than or equal to noise.
To override where log messages are sent define the log
callback:
$c->{log} = sub { my( $repo, $msg, $level ) = @_; ... };
call
$result = $repository->call( $cmd, @params )
Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result.
can_call
$boolean = $repository->can_call( @cmd_conf_path )
Return true if the given subroutine exists in this repository's config package.
try_call
$result = $repository->try_call( $cmd, @params )
Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result.
If the subroutine does not exist then quietly returns undef.
This is used to call deprecated callback subroutines.
template_dirs
@dirs = $repository->template_dirs( $langid )
Returns a list of directories from which template files may be sourced, where the first matching template encountered is used.
The directories searched are:
archives/[archiveid]/cfg/lang/[langid]/templates/ archives/[archiveid]/cfg/templates/ archives/[archiveid]/cfg/themes/[themeid]/lang/[langid]/templates/ archives/[archiveid]/cfg/themes/[themeid]/templates/ lib/themes/[themeid]/templates/ lib/lang/[langid]/templates/ lib/templates/
id
$id = $repository->id
Returns the id string of this repository.
exec
$returncode = $repository->exec( $cmd_id, %map )
Executes a system command. $cmd_id is the id of the command as set in SystemSettings and %map contains a list of things to "fill in the blanks" in the invocation line in SystemSettings.
test_config
( $returncode, $output) = $repository->test_config
This runs "epadmin test" as an external script to test if the current configuraion on disk loads OK. This can be used by the web interface to test if changes to config. files may be saved, or not.
$returncode will be zero if everything seems OK.
If not, then $output will contain the output of epadmin test
reload_config
$ok = $repository->reload_config
Trigger a configuration reload on the next request/index.
To reload the configuration right now just call load_config.
noise
$noise_level = $repository->noise
Return the noise level for the current session. See the explaination under EPrints::Repository->new()
init_from_indexer
$repo->init_from_indexer( $daemon )
(Re)initialise the repository object for use by the indexer.
Calls check_last_changed.
COPYRIGHT
Copyright 2000-2011 University of Southampton.
This file is part of EPrints http://www.eprints.org/.
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.