Difference between revisions of "Core API"

From EPrints Documentation
Jump to: navigation, search
Line 3: Line 3:
 
{{api}}
 
{{api}}
  
This is the bits which you will need to get started...
+
Core API modules.
 +
* EPrint.pm
 +
* DataObj.pm
 +
* DataSet
 +
* EPrint/EPrint
 +
* EPrint/User
 +
* EPrint/Subject
 +
* EPrint/Document
 +
* EPrint/File
 +
* Handle
 +
* Handle/Language.pm
 +
* Handle/Render.pm
 +
* Handle/CGI.pm
 +
* Handle/Page.pm
 +
* Handle/XML.pm
 +
* Repository
 +
* MetaField.pm
 +
* List.pm
 +
* Search.pm
 +
* Database.pm
 +
* Time.pm
 +
* URL.pm
 +
* Utils.pm
 +
* XML.pm
  
A connection to the EPrints system is represented by an instance of [[API:EPrints/Session|EPrints::Session]]. The session object links to
+
Todo later.
* the [[API:EPrints/Repository#get_conf|configuration]] of the [[API:EPrints/Session#get_repository|repository]] (only one per session object, even if the system itself has multiple repositories).
+
* Paginate.pm
* the [[API:EPrints/Session#get_database|database]] for the repository.
+
* Paginate/Columns.pm
* the [[API:EPrints/Session#get_lang|language]] to output in.
+
* Box.pm
And if a CGI script then also
+
* Email.pm
* the [[API:EPrints/Session#current_user|current user]], if any.
+
* Platform.pm
* the [[API:EPrints/Session#get_request|apache request]].
+
* Storage.pm
 
+
* TempDir.pm
If you're writing your own script then you'll need to start by asking for a Session object.
 
 
 
== Command-line Script ==
 
 
 
#!/usr/bin/perl -w -I/opt/eprints3/perl-lib/
 
 
use EPrints;
 
 
use strict;
 
 
my $archive_id = $ARGV[0];
 
my $session = new EPrints::Session( 1, $archive_id );
 
exit( 1 ) unless( defined $session );
 
 
 
# do your stuff
 
 
 
$session->terminate;
 
 
 
The "1" passed to Session tells it that we're a normal script and not a CGI script.
 
 
 
The $archive_id value is taken from $ARGV[0] which is the first parameter on the commandline. You could hard-wire the value if you wanted.
 
 
 
The use of "-w" to produce warnings and "use strict" to prevent sloppy code is just good Perl-practice.
 
 
 
== CGI Script ==
 
 
 
This is similar to a command line script but you don't need the path to perl and the archive_id is not needed as it will work that out from the web-request.
 
 
 
use EPrints;
 
 
 
use strict;
 
 
 
my $session = new EPrints::Session;
 
exit( 0 ) unless( defined $session );
 
 
 
# do some stuff
 
 
 
# Return a result to browser (usually an HTML page)
 
 
$session->terminate();
 
 
 
== Code in the EPrints Configuration Files ==
 
 
 
Such as eprint_render.pl or creating a new subroutine for render_single_value on a field.
 
 
 
These are always passed a $session so you don't need to create your own.
 
 
 
== Plugins ==
 
 
 
These are described in the section about plugins.
 

Revision as of 11:20, 18 August 2009


Template:Api

Core API modules.

  • EPrint.pm
  • DataObj.pm
  • DataSet
  • EPrint/EPrint
  • EPrint/User
  • EPrint/Subject
  • EPrint/Document
  • EPrint/File
  • Handle
  • Handle/Language.pm
  • Handle/Render.pm
  • Handle/CGI.pm
  • Handle/Page.pm
  • Handle/XML.pm
  • Repository
  • MetaField.pm
  • List.pm
  • Search.pm
  • Database.pm
  • Time.pm
  • URL.pm
  • Utils.pm
  • XML.pm

Todo later.

  • Paginate.pm
  • Paginate/Columns.pm
  • Box.pm
  • Email.pm
  • Platform.pm
  • Storage.pm
  • TempDir.pm