Difference between revisions of "API:EPrints/Repository"

From EPrints Documentation
Jump to: navigation, search
Line 8: Line 8:
 
'''EPrints::Repository''' - Single connection to a specific EPrints Repository
 
'''EPrints::Repository''' - Single connection to a specific EPrints Repository
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_description -->
 
<!-- Pod2Wiki=head_description -->
 
==DESCRIPTION==
 
==DESCRIPTION==
Line 29: Line 26:
 
The Repository object also provides access to the [[API:EPrints/XHTML|EPrints::XHTML]] class which contains many methods for creating XHTML results which can be returned via the web  interface.  
 
The Repository object also provides access to the [[API:EPrints/XHTML|EPrints::XHTML]] class which contains many methods for creating XHTML results which can be returned via the web  interface.  
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
 
<!-- Pod2Wiki=head_methods -->
 
<!-- Pod2Wiki=head_methods -->
 
==METHODS==
 
==METHODS==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
 
<!-- Pod2Wiki=item_new -->
 
===new===
 
 
 
  $repository = EPrints::Repository-&gt;new( %opts )
 
  $repository = EPrints::Repository-&gt;new( %opts )
 
Creates and returns a new repository object. This is a utility object only and will only have the basic system configuration available.
 
Creates and returns a new repository object. This is a utility object only and will only have the basic system configuration available.
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
 
 
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=item_new -->
 
===new===
 
  
 
  $repository = EPrints::Repository-&gt;new( $repository_id, %opts )
 
  $repository = EPrints::Repository-&gt;new( $repository_id, %opts )
Line 66: Line 44:
 
Options:
 
Options:
  
  db_connect - 1
+
<pre>  db_connect - 1
 
   check_db - 1
 
   check_db - 1
   noise - 0
+
   noise - 0</pre>
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
<!-- Pod2Wiki=head_query -->
 +
===query===
  
<!-- Pod2Wiki= -->
+
<source lang="perl">$query = $repository->query
</div>
 
<!-- Pod2Wiki=item_query -->
 
===query===
 
  
$query = $repository-&gt;query
+
</source>
 
Return the {{API:PodLink|file=CGI|package_name=CGI|section=|text=CGI}} object describing the current HTTP query, or  undefined if this isn't a CGI script.
 
Return the {{API:PodLink|file=CGI|package_name=CGI|section=|text=CGI}} object describing the current HTTP query, or  undefined if this isn't a CGI script.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_param -->
<!-- Pod2Wiki=item_param -->
 
 
===param===
 
===param===
  
$value or @values = $repository-&gt;param( $name )
+
<source lang="perl">$value or @values = $repository->param( $name )
 +
 
 +
</source>
 
Passes through to CGI.pm param method.
 
Passes through to CGI.pm param method.
  
Line 102: Line 74:
 
@values = $repository-&gt;param: returns an array of the names of all the CGI parameters in the current request.
 
@values = $repository-&gt;param: returns an array of the names of all the CGI parameters in the current request.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_xml -->
<!-- Pod2Wiki=item_xml -->
 
 
===xml===
 
===xml===
  
$xml = $repo-&gt;xml
+
<source lang="perl">$xml = $repo->xml
 +
 
 +
</source>
 
Return an [[API:EPrints/XML|EPrints::XML]] object for working with XML.
 
Return an [[API:EPrints/XML|EPrints::XML]] object for working with XML.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_xhtml -->
<!-- Pod2Wiki=item_xhtml -->
 
 
===xhtml===
 
===xhtml===
  
$xhtml = $repo-&gt;xhtml
+
<source lang="perl">$xhtml = $repo->xhtml
 +
 
 +
</source>
 
Return an [[API:EPrints/XHTML|EPrints::XHTML]] object for working with XHTML.
 
Return an [[API:EPrints/XHTML|EPrints::XHTML]] object for working with XHTML.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_eprint -->
<!-- Pod2Wiki=item_eprint -->
 
 
===eprint===
 
===eprint===
  
$eprint = $repository-&gt;eprint( $eprint_id );
+
<source lang="perl">$eprint = $repository->eprint( $eprint_id );
 +
 
 +
</source>
 
A convience method to return the [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]] with  the given ID, or undef.
 
A convience method to return the [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]] with  the given ID, or undef.
  
 
Equivent to $repository-&gt;dataset("eprint")-&gt;dataobj( $eprint_id )
 
Equivent to $repository-&gt;dataset("eprint")-&gt;dataobj( $eprint_id )
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_current_user -->
<!-- Pod2Wiki=item_current_user -->
 
 
===current_user===
 
===current_user===
  
$user = $repository-&gt;current_user
+
<source lang="perl">$user = $repository->current_user
 +
 
 +
</source>
 
Return the current logged in [[API:EPrints/DataObj/User|EPrints::DataObj::User]] for this session.
 
Return the current logged in [[API:EPrints/DataObj/User|EPrints::DataObj::User]] for this session.
  
 
Return undef if there isn't one.
 
Return undef if there isn't one.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_user -->
<!-- Pod2Wiki=item_user -->
 
 
===user===
 
===user===
  
$user = $repository-&gt;user( $user_id );
+
<source lang="perl">$user = $repository->user( $user_id );
 +
 
 +
</source>
 
A convience method to return the [[API:EPrints/DataObj/User|EPrints::DataObj::User]] with  the given ID, or undef.
 
A convience method to return the [[API:EPrints/DataObj/User|EPrints::DataObj::User]] with  the given ID, or undef.
  
 
Equivent to $repository-&gt;dataset("user")-&gt;dataobj( $user_id )
 
Equivent to $repository-&gt;dataset("user")-&gt;dataobj( $user_id )
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_user_by_username -->
<!-- Pod2Wiki=item_user_by_username -->
 
 
===user_by_username===
 
===user_by_username===
  
$user = $repository-&gt;user_by_username( $username );
+
<source lang="perl">$user = $repository->user_by_username( $username );
 +
 
 +
</source>
 
Return the user with the given username, or undef.
 
Return the user with the given username, or undef.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_user_by_email -->
<!-- Pod2Wiki=item_user_by_email -->
 
 
===user_by_email===
 
===user_by_email===
  
$user = $repository-&gt;user_by_email( $email );
+
<source lang="perl">$user = $repository->user_by_email( $email );
 +
 
 +
</source>
 
Return the [[API:EPrints/DataObj/User|EPrints::DataObj::User]] with the given email, or undef.
 
Return the [[API:EPrints/DataObj/User|EPrints::DataObj::User]] with the given email, or undef.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_dataset -->
<!-- Pod2Wiki=item_dataset -->
 
 
===dataset===
 
===dataset===
  
$dataset = $repository-&gt;dataset( $setname )
+
<source lang="perl">$dataset = $repository->dataset( $setname )
 +
 
 +
</source>
 
Return a given [[API:EPrints/DataSet|EPrints::DataSet]] or undef if it doesn't exist.
 
Return a given [[API:EPrints/DataSet|EPrints::DataSet]] or undef if it doesn't exist.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_config -->
<!-- Pod2Wiki=item_config -->
 
 
===config===
 
===config===
  
$confitem = $repository-&gt;config( $key, [@subkeys] )
+
<source lang="perl">$confitem = $repository->config( $key, [@subkeys] )
 +
 
 +
</source>
 
Returns a named configuration setting including those defined in archvies/&lt;archive_id&gt;/cfg/cfg.d/  
 
Returns a named configuration setting including those defined in archvies/&lt;archive_id&gt;/cfg/cfg.d/  
  
Line 231: Line 194:
 
$repository-&gt;config( "stuff" )-&gt;{en}-&gt;{foo}  
 
$repository-&gt;config( "stuff" )-&gt;{en}-&gt;{foo}  
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_log -->
<!-- Pod2Wiki=item_log -->
 
 
===log===
 
===log===
  
  $repository-&gt;log( $msg )
+
<source lang="perl">$repository->log( $msg [, $level ] )
Calls the log method from ArchiveConfig.pm for this repository with the  given parameters. Basically logs the comments wherever the site admin wants them to go. Printed to STDERR by default.
+
 
 +
</source>
 +
Log a plain text message $msg. If $level is given only logs if $level is greater than or equal to [[API:EPrints/Repository#noise|noise]].
 +
 
 +
To override where log messages are sent define the <code>log</code> callback:
 +
 
 +
<pre> $c-&gt;{log} = sub {
 +
    my( $repo, $msg, $level ) = @_;
 +
 
 +
    ...
 +
  };</pre>
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_call -->
<!-- Pod2Wiki=item_call -->
 
 
===call===
 
===call===
  
$result = $repository-&gt;call( $cmd, @params )
+
<source lang="perl">$result = $repository->call( $cmd, @params )
 +
 
 +
</source>
 
Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result.
 
Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_can_call -->
<!-- Pod2Wiki=item_can_call -->
 
 
===can_call===
 
===can_call===
  
$boolean = $repository-&gt;can_call( @cmd_conf_path )
+
<source lang="perl">$boolean = $repository->can_call( @cmd_conf_path )
 +
 
 +
</source>
 
Return true if the given subroutine exists in this repository's config package.
 
Return true if the given subroutine exists in this repository's config package.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_try_call -->
<!-- Pod2Wiki=item_try_call -->
 
 
===try_call===
 
===try_call===
  
$result = $repository-&gt;try_call( $cmd, @params )
+
<source lang="perl">$result = $repository->try_call( $cmd, @params )
 +
 
 +
</source>
 
Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result.
 
Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result.
  
Line 287: Line 254:
 
This is used to call deprecated callback subroutines.
 
This is used to call deprecated callback subroutines.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_template_dirs -->
<!-- Pod2Wiki=item_template_dirs -->
 
 
===template_dirs===
 
===template_dirs===
  
@dirs = $repository-&gt;template_dirs( $langid )
+
<source lang="perl">@dirs = $repository->template_dirs( $langid )
 +
 
 +
</source>
 
Returns a list of directories from which template files may be sourced, where the first matching template encountered is used.
 
Returns a list of directories from which template files may be sourced, where the first matching template encountered is used.
  
 
The directories searched are:
 
The directories searched are:
  
  archives/[archiveid]/cfg/lang/[langid]/templates/
+
<pre>  archives/[archiveid]/cfg/lang/[langid]/templates/
 
   archives/[archiveid]/cfg/templates/
 
   archives/[archiveid]/cfg/templates/
 
   archives/[archiveid]/cfg/themes/[themeid]/lang/[langid]/templates/
 
   archives/[archiveid]/cfg/themes/[themeid]/lang/[langid]/templates/
Line 308: Line 274:
 
   lib/themes/[themeid]/templates/
 
   lib/themes/[themeid]/templates/
 
   lib/lang/[langid]/templates/
 
   lib/lang/[langid]/templates/
   lib/templates/
+
   lib/templates/</pre>
 
+
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_id -->
<!-- Pod2Wiki=item_id -->
 
 
===id===
 
===id===
  
$id = $repository-&gt;id  
+
<source lang="perl">$id = $repository->id  
 +
 
 +
</source>
 
Returns the id string of this repository.
 
Returns the id string of this repository.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_exec -->
<!-- Pod2Wiki=item_exec -->
 
 
===exec===
 
===exec===
  
$returncode = $repository-&gt;exec( $cmd_id, %map )
+
<source lang="perl">$returncode = $repository->exec( $cmd_id, %map )
 +
 
 +
</source>
 
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.  
 
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.  
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_test_config -->
<!-- Pod2Wiki=item_test_config -->
 
 
===test_config===
 
===test_config===
  
( $returncode, $output) = $repository-&gt;test_config
+
<source lang="perl">( $returncode, $output) = $repository->test_config
 +
 
 +
</source>
 
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.
 
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.
  
Line 353: Line 316:
 
If not, then $output will contain the output of epadmin test  
 
If not, then $output will contain the output of epadmin test  
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_reload_config -->
<!-- Pod2Wiki=item_reload_config -->
 
 
===reload_config===
 
===reload_config===
  
$ok = $repository-&gt;reload_config
+
<source lang="perl">$ok = $repository->reload_config
 +
 
 +
</source>
 
Trigger a configuration reload on the next request/index.
 
Trigger a configuration reload on the next request/index.
  
 
To reload the configuration right now just call [[API:EPrints/Repository#load_config|load_config]].
 
To reload the configuration right now just call [[API:EPrints/Repository#load_config|load_config]].
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_noise -->
<!-- Pod2Wiki=item_init_from_indexer -->
+
===noise===
===init_from_indexer===
 
  
$repo-&gt;init_from_indexer( $daemon )
+
<source lang="perl">$noise_level = $repository->noise
(Re)initialise the repository object for use by the indexer.
 
  
Calls [[API:EPrints/Repository#check_last_changed|check_last_changed]].
+
</source>
 +
Return the noise level for the current session. See the explaination under EPrints::Repository-&gt;new()
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=head_dom_related_methods -->
 +
===DOM Related Methods===
 +
These methods help build XML. Usually, but not always XHTML.
 +
 
 +
<!-- Pod2Wiki=end -->
 +
InternalDoc<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_xhtml_related_methods -->
 +
===XHTML Related Methods===
 +
These methods help build XHTML.
 +
 
 +
<!-- Pod2Wiki=end -->
 +
InternalDoc<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_methods_relating_to_the_current_xhtml_page -->
 +
===Methods relating to the current XHTML page===
 +
<!-- Pod2Wiki=end -->
 +
InternalDoc<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
<!-- Pod2Wiki=head_methods_related_to_plugins -->
 +
===Methods related to Plugins===
 +
<!-- Pod2Wiki=end -->
 +
InternalDoc<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
$repo-&gt;init_from_indexer( $daemon )
 +
(Re)initialise the repository object for use by the indexer.
 +
 
 +
Calls [[API:EPrints/Repository#check_last_changed|check_last_changed]].
 +
 
 
<!-- Pod2Wiki=head_copyright -->
 
<!-- Pod2Wiki=head_copyright -->
 
==COPYRIGHT==
 
==COPYRIGHT==
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #ccepadding: 0em 1em 0em 1em; font-size: 80%; '>
+
Copyright 2000-2011 University of Southampton.
<span style='display:none'>User Comments</span>
+
 
 +
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/.
 +
 
 
<!-- Edit below this comment -->
 
<!-- Edit below this comment -->
  
  
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
</div>
+
<!-- Pod2Wiki=_postamble_ -->
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->
+
<!-- Edit below this comment -->

Revision as of 08:28, 20 April 2012

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Repository - Single connection to a specific EPrints Repository


DESCRIPTION

This module is really a Repository, REALLY. The name is up to date and everything :-)

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 also provides access to the EPrints::XHTML class which contains many methods for creating XHTML results which can be returned via the web interface.


METHODS

$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.

$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.

$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()


DOM Related Methods

These methods help build XML. Usually, but not always XHTML.

InternalDoc


XHTML Related Methods

These methods help build XHTML.

InternalDoc


Methods relating to the current XHTML page

InternalDoc


Methods related to Plugins

InternalDoc


$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/.