Difference between revisions of "API:EPrints/Repository"
Line 29: | Line 29: | ||
The session object also provides many methods for creating XHTML results which can be returned via the web interface. | The session object also provides 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 --> | ||
+ | |||
+ | |||
+ | <!-- Pod2Wiki= --> | ||
+ | </div> | ||
+ | <!-- Pod2Wiki=head_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%; '> | <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> | <span style='display:none'>User Comments</span> | ||
Line 37: | Line 46: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_new --> | <!-- Pod2Wiki=item_new --> | ||
− | === | + | ===new=== |
+ | $repository = EPrints::Repository->new( $mode, [$repository_id], [$noise], [$nocheckdb] ) | ||
Create a connection to an EPrints repository which provides access to the database and to the repository configuration. | Create a connection to an EPrints repository which provides access to the database and to the repository configuration. | ||
Line 62: | Line 72: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_request --> | <!-- Pod2Wiki=item_get_request --> | ||
− | === | + | ===get_request=== |
+ | $request = $repository->get_request; | ||
Return the Apache request object (from mod_perl) or undefined if this isn't a CGI script. | Return the Apache request object (from mod_perl) or undefined if this isn't a CGI script. | ||
Line 74: | Line 85: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_query --> | <!-- Pod2Wiki=item_query --> | ||
− | === | + | ===query=== |
+ | $query = $repository->query | ||
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. | ||
Line 86: | Line 98: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_terminate --> | <!-- Pod2Wiki=item_terminate --> | ||
− | === | + | ===terminate=== |
+ | $repository->terminate | ||
Perform any cleaning up necessary, for example SQL cache tables which are no longer needed. | Perform any cleaning up necessary, for example SQL cache tables which are no longer needed. | ||
Line 98: | Line 111: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_xml --> | <!-- Pod2Wiki=item_xml --> | ||
− | === | + | ===xml=== |
+ | $xml = $repo->xml | ||
Return an XML object for working with XML. | Return an XML object for working with XML. | ||
Line 110: | Line 124: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_xhtml --> | <!-- Pod2Wiki=item_xhtml --> | ||
− | === | + | ===xhtml=== |
+ | $xhtml = $repo->xhtml | ||
Return an XHTML object for working with XHTML. | Return an XHTML object for working with XHTML. | ||
Line 122: | Line 137: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_eprint --> | <!-- Pod2Wiki=item_eprint --> | ||
− | === | + | ===eprint=== |
+ | $eprint = $repository->eprint( $eprint_id ); | ||
Return the eprint with the given ID, or undef. | Return the eprint with the given ID, or undef. | ||
Line 134: | Line 150: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_user --> | <!-- Pod2Wiki=item_user --> | ||
− | === | + | ===user=== |
+ | $user = $repository->user( $user_id ); | ||
Return the user with the given ID, or undef. | Return the user with the given ID, or undef. | ||
Line 146: | Line 163: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_user_by_username --> | <!-- Pod2Wiki=item_user_by_username --> | ||
− | === | + | ===user_by_username=== |
+ | $user = $repository->user_by_username( $username ); | ||
Return the user with the given username, or undef. | Return the user with the given username, or undef. | ||
Line 158: | Line 176: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_user_by_email --> | <!-- Pod2Wiki=item_user_by_email --> | ||
− | === | + | ===user_by_email=== |
+ | $user = $repository->user_by_email( $email ); | ||
Return the user with the given email, or undef. | Return the user with the given email, or undef. | ||
Line 170: | Line 189: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_new_from_request --> | <!-- Pod2Wiki=item_new_from_request --> | ||
− | === | + | ===new_from_request=== |
+ | $repository = EPrints::RepositoryConfig->new_from_request( $request ) | ||
This creates a new repository object. It looks at the given Apache request object and decides which repository to load based on the value of the PerlVar "EPrints_ArchiveID". | This creates a new repository object. It looks at the given Apache request object and decides which repository to load based on the value of the PerlVar "EPrints_ArchiveID". | ||
Line 184: | Line 204: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_language --> | <!-- Pod2Wiki=item_get_language --> | ||
− | === | + | ===get_language=== |
+ | $language = $repository->get_language( [$langid] ) | ||
Returns the EPrints::Language for the requested language id (or the default for this repository if $langid is not specified). | Returns the EPrints::Language for the requested language id (or the default for this repository if $langid is not specified). | ||
Line 196: | Line 217: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_template_parts --> | <!-- Pod2Wiki=item_get_template_parts --> | ||
− | === | + | ===get_template_parts=== |
+ | $template = $repository->get_template_parts( $langid, [$template_id] ) | ||
Returns an array of utf-8 strings alternating between XML and the id of a pin to replace. This is used for the faster template construction. | Returns an array of utf-8 strings alternating between XML and the id of a pin to replace. This is used for the faster template construction. | ||
Line 208: | Line 230: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_template --> | <!-- Pod2Wiki=item_get_template --> | ||
− | === | + | ===get_template=== |
+ | $template = $repository->get_template( $langid, [$template_id] ) | ||
Returns the DOM document which is the webpage template for the given language. Do not modify the template without cloning it first. | Returns the DOM document which is the webpage template for the given language. Do not modify the template without cloning it first. | ||
Line 220: | Line 243: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_types --> | <!-- Pod2Wiki=item_get_types --> | ||
− | === | + | ===get_types=== |
+ | @type_ids = $repository->get_types( $type_set ) | ||
Return an array of keys for the named set. Comes from /cfg/types/foo.xml | Return an array of keys for the named set. Comes from /cfg/types/foo.xml | ||
Line 232: | Line 256: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_dataset_ids --> | <!-- Pod2Wiki=item_get_dataset_ids --> | ||
− | === | + | ===get_dataset_ids=== |
+ | @dataset_ids = $repository->get_dataset_ids() | ||
Returns a list of dataset ids in this repository. | Returns a list of dataset ids in this repository. | ||
Line 244: | Line 269: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_sql_dataset_ids --> | <!-- Pod2Wiki=item_get_sql_dataset_ids --> | ||
− | === | + | ===get_sql_dataset_ids=== |
+ | @dataset_ids = $repository->get_sql_dataset_ids() | ||
Returns a list of dataset ids that have database tables. | Returns a list of dataset ids that have database tables. | ||
Line 256: | Line 282: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_sql_counter_ids --> | <!-- Pod2Wiki=item_get_sql_counter_ids --> | ||
− | === | + | ===get_sql_counter_ids=== |
+ | @counter_ids = $repository->get_sql_counter_ids() | ||
Returns a list of counter ids generated by the database. | Returns a list of counter ids generated by the database. | ||
Line 268: | Line 295: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_dataset --> | <!-- Pod2Wiki=item_dataset --> | ||
− | === | + | ===dataset=== |
+ | $dataset = $repository->dataset( $setname ) | ||
Return a given dataset or undef if it doesn't exist. | Return a given dataset or undef if it doesn't exist. | ||
Line 280: | Line 308: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_plugin_factory --> | <!-- Pod2Wiki=item_get_plugin_factory --> | ||
− | === | + | ===get_plugin_factory=== |
+ | $plugins = $repository->get_plugin_factory() | ||
Return the plugins factory object. | Return the plugins factory object. | ||
Line 292: | Line 321: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_config --> | <!-- Pod2Wiki=item_config --> | ||
− | === | + | ===config=== |
+ | $confitem = $repository->config( $key, [@subkeys] ) | ||
Returns a named configuration setting. Probably set in ArchiveConfig.pm | Returns a named configuration setting. Probably set in ArchiveConfig.pm | ||
Line 310: | Line 340: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_log --> | <!-- Pod2Wiki=item_log --> | ||
− | === | + | ===log=== |
+ | $repository->log( $msg ) | ||
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. | 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. | ||
Line 322: | Line 353: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_call --> | <!-- Pod2Wiki=item_call --> | ||
− | === | + | ===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. | Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result. | ||
Line 334: | Line 366: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_can_call --> | <!-- Pod2Wiki=item_can_call --> | ||
− | === | + | ===can_call=== |
+ | $boolean = $repository->can_call( @cmd_conf_path ) | ||
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. | ||
Line 346: | Line 379: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_try_call --> | <!-- Pod2Wiki=item_try_call --> | ||
− | === | + | ===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. | Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result. | ||
Line 362: | Line 396: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_store_dirs --> | <!-- Pod2Wiki=item_get_store_dirs --> | ||
− | === | + | ===get_store_dirs=== |
+ | @dirs = $repository->get_store_dirs | ||
Returns a list of directories available for storing documents. These may well be symlinks to other hard drives. | Returns a list of directories available for storing documents. These may well be symlinks to other hard drives. | ||
Line 374: | Line 409: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_static_dirs --> | <!-- Pod2Wiki=item_get_static_dirs --> | ||
− | === | + | ===get_static_dirs=== |
+ | @dirs = $repository->get_static_dirs( $langid ) | ||
Returns a list of directories from which static files may be sourced. | Returns a list of directories from which static files may be sourced. | ||
Line 386: | Line 422: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_store_dir_size --> | <!-- Pod2Wiki=item_get_store_dir_size --> | ||
− | === | + | ===get_store_dir_size=== |
+ | $size = $repository->get_store_dir_size( $dir ) | ||
Returns the current storage (in bytes) used by a given documents dir. $dir should be one of the values returned by $repository->get_store_dirs. | Returns the current storage (in bytes) used by a given documents dir. $dir should be one of the values returned by $repository->get_store_dirs. | ||
Line 400: | Line 437: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_parse_xml --> | <!-- Pod2Wiki=item_parse_xml --> | ||
− | === | + | ===parse_xml=== |
+ | $domdocument = $repository->parse_xml( $file, $no_expand ); | ||
Turns the given $file into a XML DOM document. If $no_expand is true then load &entities; but do not expand them to the values in the DTD. | Turns the given $file into a XML DOM document. If $no_expand is true then load &entities; but do not expand them to the values in the DTD. | ||
Line 416: | Line 454: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_id --> | <!-- Pod2Wiki=item_get_id --> | ||
− | === | + | ===get_id=== |
+ | $id = $repository->get_id | ||
Returns the id string of this repository. | Returns the id string of this repository. | ||
Line 428: | Line 467: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_exec --> | <!-- Pod2Wiki=item_exec --> | ||
− | === | + | ===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. | 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. | ||
Line 440: | Line 480: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_invocation --> | <!-- Pod2Wiki=item_invocation --> | ||
− | === | + | ===invocation=== |
+ | $commandstring = $repository->invocation( $cmd_id, %map ) | ||
Finds the invocation for the specified command from SystemSetting and fills in the blanks using %map. Returns a string which may be executed as a system call. | Finds the invocation for the specified command from SystemSetting and fills in the blanks using %map. Returns a string which may be executed as a system call. | ||
Line 454: | Line 495: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_field_defaults --> | <!-- Pod2Wiki=item_get_field_defaults --> | ||
− | === | + | ===get_field_defaults=== |
+ | $defaults = $repository->get_field_defaults( $fieldtype ) | ||
Return the cached default properties for this metadata field type. or undef. | Return the cached default properties for this metadata field type. or undef. | ||
Line 466: | Line 508: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_set_field_defaults --> | <!-- Pod2Wiki=item_set_field_defaults --> | ||
− | === | + | ===set_field_defaults=== |
+ | $repository->set_field_defaults( $fieldtype, $defaults ) | ||
Cache the default properties for this metadata field type. | Cache the default properties for this metadata field type. | ||
Line 478: | Line 521: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_generate_dtd --> | <!-- Pod2Wiki=item_generate_dtd --> | ||
− | === | + | ===generate_dtd=== |
+ | $success = $repository->generate_dtd | ||
DEPRECATED | DEPRECATED | ||
Line 490: | Line 534: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_test_config --> | <!-- Pod2Wiki=item_test_config --> | ||
− | === | + | ===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. | 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 515: | Line 560: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_session_language --> | <!-- Pod2Wiki=item_get_session_language --> | ||
− | ==== | + | ====get_session_language==== |
+ | $langid = EPrints::Repository::get_session_language( $repository, $request ) | ||
Given an repository object and a Apache (mod_perl) request object, this method decides what language the session should be. | Given an repository object and a Apache (mod_perl) request object, this method decides what language the session should be. | ||
Line 531: | Line 577: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_change_lang --> | <!-- Pod2Wiki=item_change_lang --> | ||
− | ==== | + | ====change_lang==== |
+ | $repository->change_lang( $newlangid ) | ||
Change the current language of the session. $newlangid should be a valid country code for the current repository. | Change the current language of the session. $newlangid should be a valid country code for the current repository. | ||
Line 545: | Line 592: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_html_phrase --> | <!-- Pod2Wiki=item_html_phrase --> | ||
− | ==== | + | ====html_phrase==== |
+ | $xhtml_phrase = $repository->html_phrase( $phraseid, %inserts ) | ||
Return an XHTML DOM object describing a phrase from the phrase files. | Return an XHTML DOM object describing a phrase from the phrase files. | ||
Line 561: | Line 609: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_phrase --> | <!-- Pod2Wiki=item_phrase --> | ||
− | ==== | + | ====phrase==== |
+ | $utf8_text = $repository->phrase( $phraseid, %inserts ) | ||
Performs the same function as html_phrase, but returns plain text. | Performs the same function as html_phrase, but returns plain text. | ||
Line 575: | Line 624: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_lang --> | <!-- Pod2Wiki=item_get_lang --> | ||
− | ==== | + | ====get_lang==== |
+ | $language = $repository->get_lang | ||
Return the EPrints::Language object for this sessions current language. | Return the EPrints::Language object for this sessions current language. | ||
Line 587: | Line 637: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_langid --> | <!-- Pod2Wiki=item_get_langid --> | ||
− | ==== | + | ====get_langid==== |
+ | $langid = $repository->get_langid | ||
Return the ID code of the current language of this session. | Return the ID code of the current language of this session. | ||
Line 599: | Line 650: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_best_language --> | <!-- Pod2Wiki=item_best_language --> | ||
− | ==== | + | ====best_language==== |
+ | $value = EPrints::Repository::best_language( $repository, $lang, %values ) | ||
$repository is the current repository. $lang is the prefered language. | $repository is the current repository. $lang is the prefered language. | ||
Line 625: | Line 677: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_view_name --> | <!-- Pod2Wiki=item_get_view_name --> | ||
− | ==== | + | ====get_view_name==== |
+ | $viewname = $repository->get_view_name( $dataset, $viewid ) | ||
Return a UTF8 encoded string containing the human readable name of the /view/ section with the ID $viewid. | Return a UTF8 encoded string containing the human readable name of the /view/ section with the ID $viewid. | ||
Line 646: | Line 699: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_database --> | <!-- Pod2Wiki=item_get_database --> | ||
− | ==== | + | ====get_database==== |
+ | $db = $repository->get_database | ||
Return the current EPrints::Database connection object. | Return the current EPrints::Database connection object. | ||
Line 658: | Line 712: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_storage --> | <!-- Pod2Wiki=item_get_storage --> | ||
− | ==== | + | ====get_storage==== |
+ | $store = $repository->get_storage | ||
Return the storage control object. | Return the storage control object. | ||
Line 670: | Line 725: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_repository --> | <!-- Pod2Wiki=item_get_repository --> | ||
− | ==== | + | ====get_repository==== |
+ | $repository = $repository->get_repository | ||
Return the EPrints::Repository object associated with the Repository. | Return the EPrints::Repository object associated with the Repository. | ||
Line 682: | Line 738: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_current_url --> | <!-- Pod2Wiki=item_current_url --> | ||
− | ==== | + | ====current_url==== |
+ | $url = $repository->current_url( [ @OPTS ] [, $page] ) | ||
Utility method to get various URLs. See [[API:EPrints/URL|EPrints::URL]]. | Utility method to get various URLs. See [[API:EPrints/URL|EPrints::URL]]. | ||
Line 711: | Line 768: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_uri --> | <!-- Pod2Wiki=item_get_uri --> | ||
− | ==== | + | ====get_uri==== |
+ | $uri = $repository->get_uri | ||
Returns the URL of the current script. Or "undef". | Returns the URL of the current script. Or "undef". | ||
Line 723: | Line 781: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_full_url --> | <!-- Pod2Wiki=item_get_full_url --> | ||
− | ==== | + | ====get_full_url==== |
+ | $uri = $repository->get_full_url | ||
Returns the URL of the current script plus the CGI params. | Returns the URL of the current script plus the CGI params. | ||
Line 735: | Line 794: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_noise --> | <!-- Pod2Wiki=item_get_noise --> | ||
− | ==== | + | ====get_noise==== |
+ | $noise_level = $repository->get_noise | ||
Return the noise level for the current session. See the explaination under EPrints::Repository->new() | Return the noise level for the current session. See the explaination under EPrints::Repository->new() | ||
Line 747: | Line 807: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_online --> | <!-- Pod2Wiki=item_get_online --> | ||
− | ==== | + | ====get_online==== |
+ | $boolean = $repository->get_online | ||
Return true if this script is running via CGI, return false if we're on the command line. | Return true if this script is running via CGI, return false if we're on the command line. | ||
Line 759: | Line 820: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_secure --> | <!-- Pod2Wiki=item_get_secure --> | ||
− | ==== | + | ====get_secure==== |
+ | $secure = $repository->get_secure | ||
Returns true if we're using HTTPS/SSL (checks get_online first). | Returns true if we're using HTTPS/SSL (checks get_online first). | ||
Line 782: | Line 844: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_make_element --> | <!-- Pod2Wiki=item_make_element --> | ||
− | ==== | + | ====make_element==== |
+ | $dom = $repository->make_element( $element_name, %attribs ) | ||
Return a DOM element with name ename and the specified attributes. | Return a DOM element with name ename and the specified attributes. | ||
Line 802: | Line 865: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_make_indent --> | <!-- Pod2Wiki=item_make_indent --> | ||
− | ==== | + | ====make_indent==== |
+ | $dom = $repository->make_indent( $width ) | ||
Return a DOM object describing a C.R. and then $width spaces. This is used to make nice looking XML for things like the OAI interface. | Return a DOM object describing a C.R. and then $width spaces. This is used to make nice looking XML for things like the OAI interface. | ||
Line 814: | Line 878: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_make_comment --> | <!-- Pod2Wiki=item_make_comment --> | ||
− | ==== | + | ====make_comment==== |
+ | $dom = $repository->make_comment( $text ) | ||
Return a DOM object describing a comment containing $text. | Return a DOM object describing a comment containing $text. | ||
Line 830: | Line 895: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_make_text --> | <!-- Pod2Wiki=item_make_text --> | ||
− | ==== | + | ====make_text==== |
+ | $DOM = $repository->make_text( $text ) | ||
Return a DOM object containing the given text. $text should be UTF-8 encoded. | Return a DOM object containing the given text. $text should be UTF-8 encoded. | ||
Line 852: | Line 918: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_make_javascript --> | <!-- Pod2Wiki=item_make_javascript --> | ||
− | ==== | + | ====make_javascript==== |
+ | $DOM = $repository->make_javascript( $code, %attribs ) | ||
Return a new DOM "script" element containing $code in javascript. %attribs will be added to the script element, similar to make_element(). | Return a new DOM "script" element containing $code in javascript. %attribs will be added to the script element, similar to make_element(). | ||
Line 872: | Line 939: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_make_doc_fragment --> | <!-- Pod2Wiki=item_make_doc_fragment --> | ||
− | ==== | + | ====make_doc_fragment==== |
+ | $fragment = $repository->make_doc_fragment | ||
Return a new XML document fragment. This is an item which can have XML elements added to it, but does not actually get rendered itself. | Return a new XML document fragment. This is an item which can have XML elements added to it, but does not actually get rendered itself. | ||
Line 897: | Line 965: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_ruler --> | <!-- Pod2Wiki=item_render_ruler --> | ||
− | ==== | + | ====render_ruler==== |
+ | $ruler = $repository->render_ruler | ||
Return an HR. in ruler.xml | Return an HR. in ruler.xml | ||
Line 909: | Line 978: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_nbsp --> | <!-- Pod2Wiki=item_render_nbsp --> | ||
− | ==== | + | ====render_nbsp==== |
+ | $nbsp = $repository->render_nbsp | ||
Return an XHTML &nbsp; character. | Return an XHTML &nbsp; character. | ||
Line 921: | Line 991: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_data_element --> | <!-- Pod2Wiki=item_render_data_element --> | ||
− | ==== | + | ====render_data_element==== |
+ | $xhtml = $repository->render_data_element( $indent, $elementname, $value, [%opts] ) | ||
This is used to help render neat XML data. It returns a fragment containing an element of name $elementname containing the value $value, the element is indented by $indent spaces. | This is used to help render neat XML data. It returns a fragment containing an element of name $elementname containing the value $value, the element is indented by $indent spaces. | ||
Line 940: | Line 1,011: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_link --> | <!-- Pod2Wiki=item_render_link --> | ||
− | ==== | + | ====render_link==== |
+ | $xhtml = $repository->render_link( $uri, [$target] ) | ||
Returns an HTML link to the given uri, with the optional $target if it needs to point to a different frame or window. | Returns an HTML link to the given uri, with the optional $target if it needs to point to a different frame or window. | ||
Line 952: | Line 1,024: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_row --> | <!-- Pod2Wiki=item_render_row --> | ||
− | ==== | + | ====render_row==== |
+ | $table_row = $repository->render_row( $key, @values ); | ||
Return the key and values in a DOM encoded HTML table row. eg. | Return the key and values in a DOM encoded HTML table row. eg. | ||
Line 966: | Line 1,039: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_language_name --> | <!-- Pod2Wiki=item_render_language_name --> | ||
− | ==== | + | ====render_language_name==== |
+ | $xhtml = $repository->render_language_name( $langid ) Return a DOM object containing the description of the specified languagein the current default language, or failing that from languages.xml | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <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> | <span style='display:none'>User Comments</span> | ||
Line 976: | Line 1,050: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_type_name --> | <!-- Pod2Wiki=item_render_type_name --> | ||
− | ==== | + | ====render_type_name==== |
+ | $xhtml = $repository->render_type_name( $type_set, $type ) | ||
Return a DOM object containing the description of the specified type in the type set. eg. "eprint", "article" | Return a DOM object containing the description of the specified type in the type set. eg. "eprint", "article" | ||
Line 988: | Line 1,063: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_type_name --> | <!-- Pod2Wiki=item_get_type_name --> | ||
− | ==== | + | ====get_type_name==== |
+ | $string = $repository->get_type_name( $type_set, $type ) | ||
As above, but return a utf-8 string. Used in <option> elements, for example. | As above, but return a utf-8 string. Used in <option> elements, for example. | ||
Line 1,000: | Line 1,076: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_name --> | <!-- Pod2Wiki=item_render_name --> | ||
− | ==== | + | ====render_name==== |
+ | $xhtml_name = $repository->render_name( $name, [$familylast] ) | ||
$name is a ref. to a hash containing family, given etc. | $name is a ref. to a hash containing family, given etc. | ||
Line 1,016: | Line 1,093: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_option_list --> | <!-- Pod2Wiki=item_render_option_list --> | ||
− | ==== | + | ====render_option_list==== |
+ | $xhtml_select = $repository->render_option_list( %params ) | ||
This method renders an XHTML <select>. The options are complicated and may change, so it's better not to use it. | This method renders an XHTML <select>. The options are complicated and may change, so it's better not to use it. | ||
Line 1,028: | Line 1,106: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_single_option --> | <!-- Pod2Wiki=item_render_single_option --> | ||
− | ==== | + | ====render_single_option==== |
+ | $option = $repository->render_single_option( $key, $desc, $selected ) | ||
Used by render_option_list. | Used by render_option_list. | ||
Line 1,040: | Line 1,119: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_hidden_field --> | <!-- Pod2Wiki=item_render_hidden_field --> | ||
− | ==== | + | ====render_hidden_field==== |
+ | $xhtml_hidden = $repository->render_hidden_field( $name, $value ) | ||
Return the XHTML DOM describing an <input> element of type "hidden" and name and value as specified. eg. | Return the XHTML DOM describing an <input> element of type "hidden" and name and value as specified. eg. | ||
Line 1,054: | Line 1,134: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_upload_field --> | <!-- Pod2Wiki=item_render_upload_field --> | ||
− | ==== | + | ====render_upload_field==== |
+ | $xhtml_uploda = $repository->render_upload_field( $name ) | ||
Render into XHTML DOM a file upload form button with the given name. | Render into XHTML DOM a file upload form button with the given name. | ||
Line 1,068: | Line 1,149: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_action_buttons --> | <!-- Pod2Wiki=item_render_action_buttons --> | ||
− | ==== | + | ====render_action_buttons==== |
+ | $dom = $repository->render_action_buttons( %buttons ) | ||
Returns a DOM object describing the set of buttons. | Returns a DOM object describing the set of buttons. | ||
Line 1,092: | Line 1,174: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_internal_buttons --> | <!-- Pod2Wiki=item_render_internal_buttons --> | ||
− | ==== | + | ====render_internal_buttons==== |
+ | $dom = $repository->render_internal_buttons( %buttons ) | ||
As for render_action_buttons, but creates buttons for actions which will modify the state of the current form, not continue with whatever process the form is part of. | As for render_action_buttons, but creates buttons for actions which will modify the state of the current form, not continue with whatever process the form is part of. | ||
Line 1,106: | Line 1,189: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_form --> | <!-- Pod2Wiki=item_render_form --> | ||
− | ==== | + | ====render_form==== |
+ | $dom = $repository->render_form( $method, $dest ) | ||
Return a DOM object describing an HTML form element. | Return a DOM object describing an HTML form element. | ||
Line 1,134: | Line 1,218: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_subjects --> | <!-- Pod2Wiki=item_render_subjects --> | ||
− | ==== | + | ====render_subjects==== |
+ | $ul = $repository->render_subjects( $subject_list, [$baseid], [$currentid], [$linkmode], [$sizes] ) | ||
Return as XHTML DOM a nested set of <ul> and <li> tags describing part of a subject tree. | Return as XHTML DOM a nested set of <ul> and <li> tags describing part of a subject tree. | ||
Line 1,166: | Line 1,251: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_error --> | <!-- Pod2Wiki=item_render_error --> | ||
− | ==== | + | ====render_error==== |
+ | $repository->render_error( $error_text, $back_to, $back_to_text ) | ||
Renders an error page with the given error text. A link, with the text $back_to_text, is offered, the destination of this is $back_to, which should take the user somewhere sensible. | Renders an error page with the given error text. A link, with the text $back_to_text, is offered, the destination of this is $back_to, which should take the user somewhere sensible. | ||
Line 1,178: | Line 1,264: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_input_form --> | <!-- Pod2Wiki=item_render_input_form --> | ||
− | ==== | + | ====render_input_form==== |
+ | $dom = $repository->render_input_form( %params ) | ||
Return a DOM object representing an entire input form. | Return a DOM object representing an entire input form. | ||
Line 1,229: | Line 1,316: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_write_static_page --> | <!-- Pod2Wiki=item_write_static_page --> | ||
− | ==== | + | ====write_static_page==== |
+ | $repository->write_static_page( $filebase, $parts, [$page_id], [$wrote_files] ) | ||
Write an .html file plus a set of files describing the parts of the page for use with the dynamic template option. | Write an .html file plus a set of files describing the parts of the page for use with the dynamic template option. | ||
Line 1,247: | Line 1,335: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_prepare_page --> | <!-- Pod2Wiki=item_prepare_page --> | ||
− | ==== | + | ====prepare_page==== |
+ | $repository->prepare_page( $parts, %options ) | ||
Create an XHTML page for this session. | Create an XHTML page for this session. | ||
Line 1,269: | Line 1,358: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_send_page --> | <!-- Pod2Wiki=item_send_page --> | ||
− | ==== | + | ====send_page==== |
+ | $repository->send_page( %httpopts ) | ||
Send a web page out by HTTP. Only relevant if this is a CGI script. build_page must have been called first. | Send a web page out by HTTP. Only relevant if this is a CGI script. build_page must have been called first. | ||
Line 1,285: | Line 1,375: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_page_to_file --> | <!-- Pod2Wiki=item_page_to_file --> | ||
− | ==== | + | ====page_to_file==== |
+ | $repository->page_to_file( $filename, [$wrote_files] ) | ||
Write out the current webpage to the given filename. | Write out the current webpage to the given filename. | ||
Line 1,303: | Line 1,394: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_set_page --> | <!-- Pod2Wiki=item_set_page --> | ||
− | ==== | + | ====set_page==== |
+ | $repository->set_page( $newhtml ) | ||
Erase the current page for this session, if any, and replace it with the XML DOM structure described by $newhtml. | Erase the current page for this session, if any, and replace it with the XML DOM structure described by $newhtml. | ||
Line 1,319: | Line 1,411: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_clone_for_me --> | <!-- Pod2Wiki=item_clone_for_me --> | ||
− | ==== | + | ====clone_for_me==== |
+ | $copy_of_node = $repository->clone_for_me( $node, [$deep] ) | ||
XML DOM items can only be added to the document which they belong to. | XML DOM items can only be added to the document which they belong to. | ||
Line 1,337: | Line 1,430: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_redirect --> | <!-- Pod2Wiki=item_redirect --> | ||
− | ==== | + | ====redirect==== |
+ | $repository->redirect( $url, [%opts] ) | ||
Redirects the browser to $url. | Redirects the browser to $url. | ||
Line 1,349: | Line 1,443: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_not_found --> | <!-- Pod2Wiki=item_not_found --> | ||
− | ==== | + | ====not_found==== |
+ | $repository->not_found( [ $message ] ) | ||
Send a 404 Not Found header. If $message is undef sets message to 'Not Found' but does '''NOT''' print an error message, otherwise defaults to the normal 404 Not Found type response. | Send a 404 Not Found header. If $message is undef sets message to 'Not Found' but does '''NOT''' print an error message, otherwise defaults to the normal 404 Not Found type response. | ||
Line 1,361: | Line 1,456: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_send_http_header --> | <!-- Pod2Wiki=item_send_http_header --> | ||
− | ==== | + | ====send_http_header==== |
+ | $repository->send_http_header( %opts ) | ||
Send the HTTP header. Only makes sense if this is running as a CGI script. | Send the HTTP header. Only makes sense if this is running as a CGI script. | ||
Line 1,390: | Line 1,486: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_param --> | <!-- Pod2Wiki=item_param --> | ||
− | ==== | + | ====param==== |
+ | $value or @values = $repository->param( $name ) | ||
Passes through to CGI.pm param method. | Passes through to CGI.pm param method. | ||
Line 1,408: | Line 1,505: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_have_parameters --> | <!-- Pod2Wiki=item_have_parameters --> | ||
− | ==== | + | ====have_parameters==== |
+ | $bool = $repository->have_parameters | ||
Return true if the current script had any parameters (post or get) | Return true if the current script had any parameters (post or get) | ||
Line 1,420: | Line 1,518: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_current_user --> | <!-- Pod2Wiki=item_current_user --> | ||
− | ==== | + | ====current_user==== |
+ | $user = $repository->current_user | ||
Return the current EPrints::DataObj::User for this session. | Return the current EPrints::DataObj::User for this session. | ||
Line 1,434: | Line 1,533: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_seen_form --> | <!-- Pod2Wiki=item_seen_form --> | ||
− | ==== | + | ====seen_form==== |
+ | $boolean = $repository->seen_form | ||
Return true if the current request contains the values from a form generated by EPrints. | Return true if the current request contains the values from a form generated by EPrints. | ||
Line 1,448: | Line 1,548: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_internal_button_pressed --> | <!-- Pod2Wiki=item_internal_button_pressed --> | ||
− | ==== | + | ====internal_button_pressed==== |
+ | $boolean = $repository->internal_button_pressed( $buttonid ) | ||
Return true if a button has been pressed in a form which is intended to reload the current page with some change. | Return true if a button has been pressed in a form which is intended to reload the current page with some change. | ||
Line 1,462: | Line 1,563: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_action_button --> | <!-- Pod2Wiki=item_get_action_button --> | ||
− | ==== | + | ====get_action_button==== |
+ | $action_id = $repository->get_action_button | ||
Return the ID of the eprint action button which has been pressed in a form, if there was one. The name of the button is "_action_" followed by the id. | Return the ID of the eprint action button which has been pressed in a form, if there was one. The name of the button is "_action_" followed by the id. | ||
Line 1,478: | Line 1,580: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_internal_button --> | <!-- Pod2Wiki=item_get_internal_button --> | ||
− | ==== | + | ====get_internal_button==== |
+ | $button_id = $repository->get_internal_button | ||
Return the id of the internal button which has been pushed, or undef if one wasn't. | Return the id of the internal button which has been pushed, or undef if one wasn't. | ||
Line 1,490: | Line 1,593: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_client --> | <!-- Pod2Wiki=item_client --> | ||
− | ==== | + | ====client==== |
+ | $client = $repository->client | ||
Return a string representing the kind of browser that made the current request. | Return a string representing the kind of browser that made the current request. | ||
Line 1,510: | Line 1,614: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_http_status --> | <!-- Pod2Wiki=item_get_http_status --> | ||
− | ==== | + | ====get_http_status==== |
+ | $status = $repository->get_http_status | ||
Return the status of the current HTTP request. | Return the status of the current HTTP request. | ||
Line 1,531: | Line 1,636: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_plugin --> | <!-- Pod2Wiki=item_plugin --> | ||
− | ==== | + | ====plugin==== |
+ | $plugin = $repository->plugin( $pluginid ) | ||
Return the plugin with the given pluginid, in this repository or, failing that, from the system level plugins. | Return the plugin with the given pluginid, in this repository or, failing that, from the system level plugins. | ||
Line 1,543: | Line 1,649: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_plugin_list --> | <!-- Pod2Wiki=item_plugin_list --> | ||
− | ==== | + | ====plugin_list==== |
+ | @plugin_ids = $repository->plugin_list( %restrictions ) | ||
Return either a list of all the plugins available to this repository or return a list of available plugins which can accept the given restrictions. | Return either a list of all the plugins available to this repository or return a list of available plugins which can accept the given restrictions. | ||
Line 1,558: | Line 1,665: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_plugins --> | <!-- Pod2Wiki=item_get_plugins --> | ||
− | ==== | + | ====get_plugins==== |
+ | @plugins = $repository->get_plugins( [ $params, ] %restrictions ) | ||
Returns a list of plugin objects that conform to %restrictions (may be empty). | Returns a list of plugin objects that conform to %restrictions (may be empty). | ||
Line 1,581: | Line 1,689: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_microtime --> | <!-- Pod2Wiki=item_microtime --> | ||
− | ==== | + | ====microtime==== |
+ | $time = EPrints::Repository::microtime(); | ||
This function is currently buggy so just returns the time in seconds. | This function is currently buggy so just returns the time in seconds. | ||
Line 1,597: | Line 1,706: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_mail_administrator --> | <!-- Pod2Wiki=item_mail_administrator --> | ||
− | ==== | + | ====mail_administrator==== |
+ | $foo = $repository->mail_administrator( $subjectid, $messageid, %inserts ) | ||
Sends a mail to the repository administrator with the given subject and message body. | Sends a mail to the repository administrator with the given subject and message body. | ||
Line 1,615: | Line 1,725: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_destroy --> | <!-- Pod2Wiki=item_destroy --> | ||
− | ==== | + | ====destroy==== |
+ | $repository->DESTROY | ||
Destructor. Don't call directly. | Destructor. Don't call directly. | ||
Revision as of 13:22, 25 February 2010
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 DESCRIPTION
- 3 METHODS
- 3.1 new
- 3.2 get_request
- 3.3 query
- 3.4 terminate
- 3.5 xml
- 3.6 xhtml
- 3.7 eprint
- 3.8 user
- 3.9 user_by_username
- 3.10 user_by_email
- 3.11 new_from_request
- 3.12 get_language
- 3.13 get_template_parts
- 3.14 get_template
- 3.15 get_types
- 3.16 get_dataset_ids
- 3.17 get_sql_dataset_ids
- 3.18 get_sql_counter_ids
- 3.19 dataset
- 3.20 get_plugin_factory
- 3.21 config
- 3.22 log
- 3.23 call
- 3.24 can_call
- 3.25 try_call
- 3.26 get_store_dirs
- 3.27 get_static_dirs
- 3.28 get_store_dir_size
- 3.29 parse_xml
- 3.30 get_id
- 3.31 exec
- 3.32 invocation
- 3.33 get_field_defaults
- 3.34 set_field_defaults
- 3.35 generate_dtd
- 3.36 test_config
- 3.37 Language Related Methods
- 3.38 Accessor Methods
- 3.39 DOM Related Methods
- 3.40 XHTML Related Methods
- 3.40.1 render_ruler
- 3.40.2 render_nbsp
- 3.40.3 render_data_element
- 3.40.4 render_link
- 3.40.5 render_row
- 3.40.6 render_language_name
- 3.40.7 render_type_name
- 3.40.8 get_type_name
- 3.40.9 render_name
- 3.40.10 render_option_list
- 3.40.11 render_single_option
- 3.40.12 render_hidden_field
- 3.40.13 render_upload_field
- 3.40.14 render_action_buttons
- 3.40.15 render_internal_buttons
- 3.40.16 render_form
- 3.40.17 render_subjects
- 3.40.18 render_error
- 3.40.19 render_input_form
- 3.41 Methods relating to the current XHTML page
- 3.42 Input Methods
- 3.43 Methods related to Plugins
- 3.44 Other Methods
NAME
EPrints::Repository - Single connection to the EPrints system
DESCRIPTION
This module is not really a session. The name is out of date, but hard to change.
EPrints::Repository represents a connection to the EPrints system. It connects to a single EPrints repository, and the database used by that repository. Thus it has an associated EPrints::Database and EPrints::Repository object.
Each "session" 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 "session" 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.
The session object also provides many methods for creating XHTML results which can be returned via the web interface.
METHODS
new
$repository = EPrints::Repository->new( $mode, [$repository_id], [$noise], [$nocheckdb] )
Create a connection to an EPrints repository which provides access to the database and to the repository configuration.
This method can be called in two modes. Setting $mode to 0 means this is a connection via a CGI web page. $repository_id is ignored, instead the value is taken from the "PerlSetVar EPrints_ArchiveID" option in the apache configuration for the current directory.
If this is being called from a command line script, then $mode should be 1, and $repository_id should be the ID of the repository we want to connect to.
$mode : mode = 0 - We are online (CGI script) mode = 1 - We are offline (bin script) $repository_id is repository_id mode = 2 - We are online, but don't create a CGI query (so we
don't consume the data).
$noise is the level of debugging output. 0 - silent 1 - quietish 2 - noisy 3 - debug all SQL statements 4 - debug database connection
Under normal conditions use "0" for online and "1" for offline.
$nocheckdb - if this is set to 1 then a connection is made to the database without checking that the tables exist.
get_request
$request = $repository->get_request;
Return the Apache request object (from mod_perl) or undefined if this isn't a CGI script.
query
$query = $repository->query
Return the CGI object describing the current HTTP query, or undefined if this isn't a CGI script.
terminate
$repository->terminate
Perform any cleaning up necessary, for example SQL cache tables which are no longer needed.
xml
$xml = $repo->xml
Return an XML object for working with XML.
xhtml
$xhtml = $repo->xhtml
Return an XHTML object for working with XHTML.
eprint
$eprint = $repository->eprint( $eprint_id );
Return the eprint with the given ID, or undef.
user
$user = $repository->user( $user_id );
Return the user with the given ID, or undef.
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 user with the given email, or undef.
new_from_request
$repository = EPrints::RepositoryConfig->new_from_request( $request )
This creates a new repository object. It looks at the given Apache request object and decides which repository to load based on the value of the PerlVar "EPrints_ArchiveID".
Aborts with an error if this is not possible.
get_language
$language = $repository->get_language( [$langid] )
Returns the EPrints::Language for the requested language id (or the default for this repository if $langid is not specified).
get_template_parts
$template = $repository->get_template_parts( $langid, [$template_id] )
Returns an array of utf-8 strings alternating between XML and the id of a pin to replace. This is used for the faster template construction.
get_template
$template = $repository->get_template( $langid, [$template_id] )
Returns the DOM document which is the webpage template for the given language. Do not modify the template without cloning it first.
get_types
@type_ids = $repository->get_types( $type_set )
Return an array of keys for the named set. Comes from /cfg/types/foo.xml
get_dataset_ids
@dataset_ids = $repository->get_dataset_ids()
Returns a list of dataset ids in this repository.
get_sql_dataset_ids
@dataset_ids = $repository->get_sql_dataset_ids()
Returns a list of dataset ids that have database tables.
get_sql_counter_ids
@counter_ids = $repository->get_sql_counter_ids()
Returns a list of counter ids generated by the database.
dataset
$dataset = $repository->dataset( $setname )
Return a given dataset or undef if it doesn't exist.
get_plugin_factory
$plugins = $repository->get_plugin_factory()
Return the plugins factory object.
config
$confitem = $repository->config( $key, [@subkeys] )
Returns a named configuration setting. Probably set in ArchiveConfig.pm
$repository->config( "stuff", "en", "foo" )
is equivalent to
$repository->config( "stuff" )->{en}->{foo}
log
$repository->log( $msg )
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.
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.
get_store_dirs
@dirs = $repository->get_store_dirs
Returns a list of directories available for storing documents. These may well be symlinks to other hard drives.
get_static_dirs
@dirs = $repository->get_static_dirs( $langid )
Returns a list of directories from which static files may be sourced.
get_store_dir_size
$size = $repository->get_store_dir_size( $dir )
Returns the current storage (in bytes) used by a given documents dir. $dir should be one of the values returned by $repository->get_store_dirs.
This should not be called if disable_df is set in SystemSettings.
parse_xml
$domdocument = $repository->parse_xml( $file, $no_expand );
Turns the given $file into a XML DOM document. If $no_expand is true then load &entities; but do not expand them to the values in the DTD.
This function also sets the path in which the Parser will look for DTD files to the repository's config directory.
Returns undef if an error occurs during parsing.
get_id
$id = $repository->get_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.
invocation
$commandstring = $repository->invocation( $cmd_id, %map )
Finds the invocation for the specified command from SystemSetting and fills in the blanks using %map. Returns a string which may be executed as a system call.
All arguments are ESCAPED using quotemeta() before being used (i.e. don't pre-escape arguments in %map).
get_field_defaults
$defaults = $repository->get_field_defaults( $fieldtype )
Return the cached default properties for this metadata field type. or undef.
set_field_defaults
$repository->set_field_defaults( $fieldtype, $defaults )
Cache the default properties for this metadata field type.
generate_dtd
$success = $repository->generate_dtd
DEPRECATED
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
Language Related Methods
get_session_language
$langid = EPrints::Repository::get_session_language( $repository, $request )
Given an repository object and a Apache (mod_perl) request object, this method decides what language the session should be.
First it looks at the HTTP cookie "eprints_lang", failing that it looks at the prefered language of the request from the HTTP header, failing that it looks at the default language for the repository.
The language ID it returns is the highest on the list that the given eprint repository actually supports.
change_lang
$repository->change_lang( $newlangid )
Change the current language of the session. $newlangid should be a valid country code for the current repository.
An invalid code will cause eprints to terminate with an error.
html_phrase
$xhtml_phrase = $repository->html_phrase( $phraseid, %inserts )
Return an XHTML DOM object describing a phrase from the phrase files.
$phraseid is the id of the phrase to return. If the same ID appears in both the repository-specific phrases file and the system phrases file then the repository-specific one is used.
If the phrase contains <ep:pin> elements, then each one should have an entry in %inserts where the key is the "ref" of the pin and the value is an XHTML DOM object describing what the pin should be replaced with.
phrase
$utf8_text = $repository->phrase( $phraseid, %inserts )
Performs the same function as html_phrase, but returns plain text.
All HTML elements will be removed, <br> and <p> will be converted into breaks in the text. <img> tags will be replaced with their "alt" values.
get_lang
$language = $repository->get_lang
Return the EPrints::Language object for this sessions current language.
get_langid
$langid = $repository->get_langid
Return the ID code of the current language of this session.
best_language
$value = EPrints::Repository::best_language( $repository, $lang, %values )
$repository is the current repository. $lang is the prefered language.
%values contains keys which are language ids, and values which is text or phrases in those languages, all translations of the same thing.
This function returns one of the values from %values based on the following logic:
If possible, return the value for $lang.
Otherwise, if possible return the value for the default language of this repository.
Otherwise, if possible return the value for "en" (English).
Otherwise just return any one value.
This means that the view sees the best possible phrase.
get_view_name
$viewname = $repository->get_view_name( $dataset, $viewid )
Return a UTF8 encoded string containing the human readable name of the /view/ section with the ID $viewid.
Accessor Methods
get_database
$db = $repository->get_database
Return the current EPrints::Database connection object.
get_storage
$store = $repository->get_storage
Return the storage control object.
get_repository
$repository = $repository->get_repository
Return the EPrints::Repository object associated with the Repository.
current_url
$url = $repository->current_url( [ @OPTS ] [, $page] )
Utility method to get various URLs. See EPrints::URL.
With no arguments returns the current full URL without any query part.
# Return the current static path $repository->current_url( path => "static" ); # Return the current cgi path $repository->current_url( path => "cgi" ); # Return a full URL to the current cgi path $repository->current_url( host => 1, path => "cgi" ); # Return a full URL to the static path under HTTP $repository->current_url( scheme => "http", host => 1, path => "static" ); # Return a full URL to the image 'foo.png' $repository->current_url( host => 1, path => "images", "foo.png" );
get_uri
$uri = $repository->get_uri
Returns the URL of the current script. Or "undef".
get_full_url
$uri = $repository->get_full_url
Returns the URL of the current script plus the CGI params.
get_noise
$noise_level = $repository->get_noise
Return the noise level for the current session. See the explaination under EPrints::Repository->new()
get_online
$boolean = $repository->get_online
Return true if this script is running via CGI, return false if we're on the command line.
get_secure
$secure = $repository->get_secure
Returns true if we're using HTTPS/SSL (checks get_online first).
DOM Related Methods
These methods help build XML. Usually, but not always XHTML.
make_element
$dom = $repository->make_element( $element_name, %attribs )
Return a DOM element with name ename and the specified attributes.
eg. $repository->make_element( "img", src => "/foo.gif", alt => "my pic" )
Will return the DOM object describing:
<img src="/foo.gif" alt="my pic" />
Note that in the call we use "=>" not "=".
make_indent
$dom = $repository->make_indent( $width )
Return a DOM object describing a C.R. and then $width spaces. This is used to make nice looking XML for things like the OAI interface.
make_comment
$dom = $repository->make_comment( $text )
Return a DOM object describing a comment containing $text.
eg.
<!-- this is a comment -->
make_text
$DOM = $repository->make_text( $text )
Return a DOM object containing the given text. $text should be UTF-8 encoded.
Characters will be treated as _text_ including < > etc.
eg.
$repository->make_text( "This is <b> an example" );
Would return a DOM object representing the XML:
"This is <b> an example"
make_javascript
$DOM = $repository->make_javascript( $code, %attribs )
Return a new DOM "script" element containing $code in javascript. %attribs will be added to the script element, similar to make_element().
E.g.
<script type="text/javascript"> // <![CDATA[ alert("Hello, World!"); // ]]> </script>
make_doc_fragment
$fragment = $repository->make_doc_fragment
Return a new XML document fragment. This is an item which can have XML elements added to it, but does not actually get rendered itself.
If appended to an element then it disappears and its children join the element at that point.
XHTML Related Methods
These methods help build XHTML.
render_ruler
$ruler = $repository->render_ruler
Return an HR. in ruler.xml
render_nbsp
$nbsp = $repository->render_nbsp
Return an XHTML character.
render_data_element
$xhtml = $repository->render_data_element( $indent, $elementname, $value, [%opts] )
This is used to help render neat XML data. It returns a fragment containing an element of name $elementname containing the value $value, the element is indented by $indent spaces.
The %opts describe any extra attributes for the element
eg. $repository->render_data_element( 4, "foo", "bar", class=>"fred" )
would return a XML DOM object describing:
<foo class="fred">bar</foo>
render_link
$xhtml = $repository->render_link( $uri, [$target] )
Returns an HTML link to the given uri, with the optional $target if it needs to point to a different frame or window.
render_row
$table_row = $repository->render_row( $key, @values );
Return the key and values in a DOM encoded HTML table row. eg.
<tr><th>$key:</th><td>$value[0]</td><td>...</td></tr>
render_language_name
$xhtml = $repository->render_language_name( $langid ) Return a DOM object containing the description of the specified languagein the current default language, or failing that from languages.xml
render_type_name
$xhtml = $repository->render_type_name( $type_set, $type )
Return a DOM object containing the description of the specified type in the type set. eg. "eprint", "article"
get_type_name
$string = $repository->get_type_name( $type_set, $type )
As above, but return a utf-8 string. Used in <option> elements, for example.
render_name
$xhtml_name = $repository->render_name( $name, [$familylast] )
$name is a ref. to a hash containing family, given etc.
Returns an XML DOM fragment with the name rendered in the manner of the repository. Usually "John Smith".
If $familylast is set then the family and given parts are reversed, eg. "Smith, John"
render_option_list
$xhtml_select = $repository->render_option_list( %params )
This method renders an XHTML <select>. The options are complicated and may change, so it's better not to use it.
render_single_option
$option = $repository->render_single_option( $key, $desc, $selected )
Used by render_option_list.
$xhtml_hidden = $repository->render_hidden_field( $name, $value )
Return the XHTML DOM describing an <input> element of type "hidden" and name and value as specified. eg.
<input type="hidden" name="foo" value="bar" />
render_upload_field
$xhtml_uploda = $repository->render_upload_field( $name )
Render into XHTML DOM a file upload form button with the given name.
eg. <input type="file" name="foo" />
render_action_buttons
$dom = $repository->render_action_buttons( %buttons )
Returns a DOM object describing the set of buttons.
The keys of %buttons are the ids of the action that button will cause, the values are UTF-8 text that should appear on the button.
Two optional additional keys may be used:
_order => [ "action1", "action2" ]
will force the buttons to appear in a set order.
_class => "my_css_class"
will add a class attribute to the <div> containing the buttons to allow additional styling.
render_internal_buttons
$dom = $repository->render_internal_buttons( %buttons )
As for render_action_buttons, but creates buttons for actions which will modify the state of the current form, not continue with whatever process the form is part of.
eg. the "More Spaces" button and the up and down arrows on multiple type fields.
render_form
$dom = $repository->render_form( $method, $dest )
Return a DOM object describing an HTML form element.
$method should be "get" or "post"
$dest is the target of the form. By default the current page.
eg.
$repository->render_form( "GET", "http://example.com/cgi/foo" );
returns a DOM object representing:
<form method="get" action="http://example.com/cgi/foo" accept-charset="utf-8" />
If $method is "post" then an addition attribute is set: enctype="multipart/form-data"
This just controls how the data is passed from the browser to the CGI library. You don't need to worry about it.
render_subjects
$ul = $repository->render_subjects( $subject_list, [$baseid], [$currentid], [$linkmode], [$sizes] )
Return as XHTML DOM a nested set of <ul> and <li> tags describing part of a subject tree.
$subject_list is a array ref of subject ids to render.
$baseid is top top level node to render the tree from. If only a single subject is in subject_list, all subjects up to $baseid will still be rendered. Default is the ROOT element.
If $currentid is set then the subject with that ID is rendered in <strong>
$linkmode can 0, 1, 2 or 3.
0. Don't link the subjects.
1. Links subjects to the URL which edits them in edit_subjects.
2. Links subjects to "subjectid.html" (where subjectid is the id of the subject)
3. Links the subjects to "subjectid/". $sizes must be set. Only subjects with a size of more than one are linked.
4. Links the subjects to "../subjectid/". $sizes must be set. Only subjects with a size of more than one are linked.
$sizes may be a ref. to hash mapping the subjectid's to the number of items in that subject which will be rendered in brackets next to each subject.
render_error
$repository->render_error( $error_text, $back_to, $back_to_text )
Renders an error page with the given error text. A link, with the text $back_to_text, is offered, the destination of this is $back_to, which should take the user somewhere sensible.
render_input_form
$dom = $repository->render_input_form( %params )
Return a DOM object representing an entire input form.
%params contains the following options:
dataset: The EPrints::Dataset to which the form relates, if any.
fields: a reference to an array of EPrint::MetaField objects, which describe the fields to be added to the form.
values: a set of default values. A reference to a hash where the keys are ID's of fields, and the values are the default values for those fields.
show_help: if true, show the fieldhelp phrase for each input field.
show_name: if true, show the fieldname phrase for each input field.
buttons: a description of the buttons to appear at the bottom of the form. See render_action_buttons for details.
top_buttons: a description of the buttons to appear at the top of the form (optional).
default_action: the id of the action to be performed by default, ie. if the user pushes "return" in a text field.
dest: The URL of the target for this form. If not defined then the current URI is used.
type: if this form relates to a user or an eprint, the type of eprint/user can effect what fields are flagged as required. This param contains the ID of the eprint/user if any, and if relevant.
staff: if true, this form is being presented to repository staff (admin, or editor). This may change which fields are required.
hidden_fields: reference to a hash. The keys of which are CGI keys and the values are the values they are set to. This causes hidden form elements to be set, so additional information can be passed.
object: The DataObj which this form is editing, if any.
comment: not yet used.
Methods relating to the current XHTML page
write_static_page
$repository->write_static_page( $filebase, $parts, [$page_id], [$wrote_files] )
Write an .html file plus a set of files describing the parts of the page for use with the dynamic template option.
File base is the name of the page without the .html suffix.
parts is a reference to a hash containing DOM trees.
If $wrote_files is defined then any filenames written are logged in it as keys.
prepare_page
$repository->prepare_page( $parts, %options )
Create an XHTML page for this session.
$parts is a hash of XHTML elements to insert into the pins in the template. Usually: title, page. Maybe pagetop and head.
If template is set then an alternate template file is used.
This function only builds the page it does not output it any way, see the methods below for that.
Options include:
page_id=>"id to put in body tag" template=>"The template to use instead of default."
send_page
$repository->send_page( %httpopts )
Send a web page out by HTTP. Only relevant if this is a CGI script. build_page must have been called first.
See send_http_header for an explanation of %httpopts
Dispose of the XML once it's sent out.
page_to_file
$repository->page_to_file( $filename, [$wrote_files] )
Write out the current webpage to the given filename.
build_page must have been called first.
Dispose of the XML once it's sent out.
If $wrote_files is set then keys are created in it for each file created.
set_page
$repository->set_page( $newhtml )
Erase the current page for this session, if any, and replace it with the XML DOM structure described by $newhtml.
This page is what is output by page_to_file or send_page.
$newhtml is a normal DOM Element, not a document object.
clone_for_me
$copy_of_node = $repository->clone_for_me( $node, [$deep] )
XML DOM items can only be added to the document which they belong to.
A EPrints::Repository has it's own XML DOM DOcument.
This method copies an XML node from _any_ document. The copy belongs to this sessions document.
If $deep is set then the children, (and their children etc.), are copied too.
redirect
$repository->redirect( $url, [%opts] )
Redirects the browser to $url.
not_found
$repository->not_found( [ $message ] )
Send a 404 Not Found header. If $message is undef sets message to 'Not Found' but does NOT print an error message, otherwise defaults to the normal 404 Not Found type response.
send_http_header
$repository->send_http_header( %opts )
Send the HTTP header. Only makes sense if this is running as a CGI script.
Opts supported are:
content_type. Default value is "text/html; charset=UTF-8". This sets the http content type header.
lang. If this is set then a cookie setting the language preference is set in the http header.
Input Methods
These handle input from the user, browser and apache.
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.
have_parameters
$bool = $repository->have_parameters
Return true if the current script had any parameters (post or get)
current_user
$user = $repository->current_user
Return the current EPrints::DataObj::User for this session.
Return undef if there isn't one.
seen_form
$boolean = $repository->seen_form
Return true if the current request contains the values from a form generated by EPrints.
This is identified by a hidden field placed into forms named _seen with value "true".
internal_button_pressed
$boolean = $repository->internal_button_pressed( $buttonid )
Return true if a button has been pressed in a form which is intended to reload the current page with some change.
Examples include the "more spaces" button on multiple fields, the "lookup" button on succeeds, etc.
get_action_button
$action_id = $repository->get_action_button
Return the ID of the eprint action button which has been pressed in a form, if there was one. The name of the button is "_action_" followed by the id.
This also handles the .x and .y inserted in image submit.
This is designed to get back the name of an action button created by render_action_buttons.
get_internal_button
$button_id = $repository->get_internal_button
Return the id of the internal button which has been pushed, or undef if one wasn't.
client
$client = $repository->client
Return a string representing the kind of browser that made the current request.
Options are GECKO, LYNX, MSIE4, MSIE5, MSIE6, ?.
GECKO covers mozilla and firefox.
? is what's returned if none of the others were matched.
These divisions are intended for modifying the way pages are rendered not logging what browser was used. Hence merging mozilla and firefox.
get_http_status
$status = $repository->get_http_status
Return the status of the current HTTP request.
plugin
$plugin = $repository->plugin( $pluginid )
Return the plugin with the given pluginid, in this repository or, failing that, from the system level plugins.
plugin_list
@plugin_ids = $repository->plugin_list( %restrictions )
Return either a list of all the plugins available to this repository or return a list of available plugins which can accept the given restrictions.
Restictions:
vary depending on the type of the plugin.
get_plugins
@plugins = $repository->get_plugins( [ $params, ] %restrictions )
Returns a list of plugin objects that conform to %restrictions (may be empty).
If $params is given uses that hash reference to initialise the plugins. Always passes this session to the plugin constructor method.
Other Methods
microtime
$time = EPrints::Repository::microtime();
This function is currently buggy so just returns the time in seconds.
Return the time of day in seconds, but to a precision of microseconds.
Accuracy depends on the operating system etc.
mail_administrator
$foo = $repository->mail_administrator( $subjectid, $messageid, %inserts )
Sends a mail to the repository administrator with the given subject and message body.
$subjectid is the name of a phrase in the phrase file to use for the subject.
$messageid is the name of a phrase in the phrase file to use as the basis for the mail body.
%inserts is a hash. The keys are the pins in the messageid phrase and the values the utf8 strings to replace the pins with.
destroy
$repository->DESTROY
Destructor. Don't call directly.