Difference between revisions of "EPScript/Introduction"

From EPrints Documentation
Jump to: navigation, search
(Added language synopsis and global vars to intro)
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{formats}}
 +
 
{{EPScript}}
 
{{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:
 
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:
 +
# [[Citation Format|Citations]]
 
# [[Workflow Format|Workflows]]
 
# [[Workflow Format|Workflows]]
# [[Citation Format|Citations]]
 
# [[Template Format|Webpage Templates]]
 
# [[XPAGE Format|Static Webpages]]
 
 
# [[Phrase Format|Phrases]]
 
# [[Phrase Format|Phrases]]
 +
# [[Template Format|Templates (of web pages)]]
 +
# [[XPAGE Format|Static (web) pages]]
 +
 
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.
 
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 ==
 
== Language Synopsis ==
  
$var{xxx} - get the value of 'xxx' in $var
+
* '''<code>$var{xxx}</code>''' - get the value of <tt>xxx</tt> in <tt>$var</tt>.
 
+
* '''<code>$var{xxx}{yyy}</code>''' - get the value of <tt>yyy</tt> in <tt>xxx</tt> in <tt>$var</tt>.
$var{xxx}{yyy} - get the value of 'yyy' in 'xxx' in $var
+
* '''<code>$var.xxx(yyy)</code>''' - call method <tt>xxx</tt> on <tt>$var</tt> with argument <tt>yyy</tt>.
 
+
* '''<code>xxx(yyy)</code>''' - call method <tt>xxx</tt> with argument <tt>yyy</tt>.
$var.xxx(yyy) - call method 'xxx' on $var with argument 'yyy'
+
* '''<code>xxx</code>''' - get the value of field <tt>xxx</tt>.
 
+
* '''<code>xxx OP yyy</code>''' - test whether <tt>xxx</tt> is OP <tt>yyy</tt> (=, !=, etc.)
xxx(yyy) - call method 'xxx' with argument 'yyy'
+
* '''<code>xxx LOGIC yyy</code>''' - test whether <tt>xxx</tt> LOGIC <tt>yyy</tt> (and, or, not etc.)
 
 
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 ===
 
=== Examples ===
 
+
* '''<code>$config{oai}{v2}{archive_id}</code>''' - gets the current OAI repository identifier.
$config{oai}{v2}{archive_id} - gets the current OAI repository identifier
+
* '''<code>$current_user{department}.is_set()</code>''' - returns true if the user's department field is set.
 
+
* '''<code>published.one_of('submitted','published')</code>''' - returns true if published is 'unpub' or 'published'.
$current_user{department}.is_set() - returns true if the user's department field is set
+
* '''<code>$item{type} = 'patent'</code>''' - returns true if type from item is 'patent'.
 
+
* '''<code>join($item{userid}.as_item(){collection},',')</code>''' - 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]].
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 ==  
 
== Global Variables ==  
  
$config{xxx} - a value from the configuration.
+
*'''<code>$config{xxx}</code>''' - a value from the configuration.
 
+
*'''<code>$current_user</code>''' - the current user, e.g., $current_user{username}
$current_user - the current user, e.g., $current_user{username}
+
*'''<code>$current_lang</code>''' - the id of the current language (such as 'en')
 
+
*'''<code>$item</code>''' - 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}'''
$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}'''
 

Latest revision as of 02:53, 21 February 2022

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. Citations
  2. Workflows
  3. Phrases
  4. Templates (of web pages)
  5. Static (web) pages

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}