EPScript/Introduction

From EPrints Documentation
Revision as of 02:51, 21 February 2022 by Drn@ecs.soton.ac.uk (talk | contribs) (Added formatting to global variables.)
Jump to: navigation, search

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


XML Configuration: EPScript - Control Format (EPC) - Citation - Workflow - Phrase - Template - XPAGE (static pages)


EPScript

EPScript is a bespoke EPrints mini-scripting language. It is integrated in the XML markup for the definition of the following elements of an EPrints repository:

  1. Workflows
  2. Citations
  3. Webpage Templates
  4. Static Webpages
  5. Phrases

EPScript works with EPrints Control Format to allow the above elements to be dynamically generated. It allows for markup in the XML formats for these elements to call Perl function to perform complex processes, typically for a control or a rendering purpose.

Language Synopsis

  • $var{xxx} - get the value of xxx in $var.
  • $var{xxx}{yyy} - get the value of yyy in xxx in $var.
  • $var.xxx(yyy) - call method xxx on $var with argument yyy.
  • xxx(yyy) - call method xxx with argument yyy.
  • xxx - get the value of field xxx.
  • xxx OP yyy - test whether xxx is OP yyy (=, !=, etc.)
  • xxx LOGIC yyy - test whether xxx LOGIC yyy (and, or, not etc.)

Examples

  • $config{oai}{v2}{archive_id} - gets the current OAI repository identifier.
  • $current_user{department}.is_set() - returns true if the user's department field is set.
  • published.one_of('submitted','published') - returns true if published is 'unpub' or 'published'.
  • $item{type} = 'patent' - returns true if type from item is 'patent'.
  • join($item{userid}.as_item(){collection},',') - useful for extracting data in 'multiple' fields. For the owner of the eprint, return all 'collection's as a comma-separated string. See How to control eprint workflow based on a user field.

Global Variables

  • $config{xxx} - a value from the configuration.
  • $current_user - the current user, e.g., $current_user{username}
  • $current_lang - the id of the current language (such as 'en')
  • $item - the current item (usually an eprint, but not always, e.g., in citations or workflows for user objects), e.g., $item{eprintid}. If you just use eprintid it is a shortcut for $item{eprintid}