Difference between revisions of "API:EPrints/DataObj/Document"
(6 intermediate revisions by the same user not shown) | |||
Line 19: | Line 19: | ||
Document represents a single format of an EPrint (eg. PDF) - the actual file(s) rather than the metadata. | Document represents a single format of an EPrint (eg. PDF) - the actual file(s) rather than the metadata. | ||
− | + | Inherits from [[API:EPrints/DataObj/SubObject|EPrints::DataObj::SubObject]], which in turn inherits from [[API:EPrints/DataObj|EPrints::DataObj]]. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<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 35: | Line 28: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=head_instance_variables --> |
− | === | + | ==INSTANCE VARIABLES== |
− | + | See [[API:EPrints/DataObj#INSTANCE_VARIABLES|EPrints::DataObj#INSTANCE_VARIABLES]]. | |
− | |||
<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%; '> | ||
Line 47: | Line 39: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=head_core_metadata_fields --> |
− | === | + | ==CORE METADATA FIELDS== |
− | |||
− | |||
− | |||
<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 59: | Line 48: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_docid --> |
− | === | + | ===docid (int)=== |
− | + | The unique ID of the document. | |
<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%; '> | ||
Line 71: | Line 60: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_rev_number --> |
− | === | + | ===rev_number (int)=== |
− | The | + | The revision number of this document record. |
<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%; '> | ||
Line 134: | Line 123: | ||
===language (namedset)=== | ===language (namedset)=== | ||
− | The ISO 639-1 | + | The ISO 639-1 code of the language of this document. The default configuration of EPrints does not set this. |
<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%; '> | ||
Line 205: | Line 194: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_media --> |
− | === | + | ===media (compound)=== |
+ | |||
+ | A compound field containing a description of the document media - dimensions, codec etc. | ||
+ | |||
+ | <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_references_and_related_objects --> | ||
+ | ==REFERENCES AND RELATED OBJECTS == | ||
<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 217: | Line 215: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_eprintid --> |
− | === | + | ===eprintid (itemref)=== |
− | + | The ID number of the eprint to which this document belongs. | |
<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%; '> | ||
Line 229: | Line 227: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_files --> |
− | == | + | ===files (subobject, multiple)=== |
+ | |||
+ | A virtual field which represents the list of files which are part of this record. | ||
+ | |||
<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 238: | Line 239: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_relation --> |
− | === | + | ===relation (relation, multiple)=== |
− | + | Predicated relationships between this document and other data objects within the archive. | |
− | |||
<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%; '> | ||
Line 251: | Line 251: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- 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 262: | Line 260: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=head_constructor_methods --> |
− | === | + | ===Constructor 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 273: | Line 269: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_create --> |
− | === | + | ====create==== |
− | EPrints::DataObj:: | + | $doc = EPrints::DataObj::Document::create( $session, $eprint ) |
− | + | Create and return a new document belonging to the given <tt>$eprint</tt> object. | |
− | + | N.B. This creates the document in the database, not just in memory. | |
<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%; '> | ||
Line 288: | Line 284: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_create_from_data --> |
− | === | + | ====create_from_data==== |
+ | |||
+ | $dataobj = EPrints::DataObj::Document::create_from_data( $session, $data, $dataset ) | ||
+ | Create document data object from <tt>$data</tt> provided. | ||
+ | |||
+ | Returns <tt>undef</tt> if a bad (or no) <tt>eprintid</tt> specified in <tt>$data</tt>. | ||
− | + | Otherwise calls the parent method in [[API:EPrints/DataObj|EPrints::DataObj]]. | |
− | |||
<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%; '> | ||
Line 301: | Line 301: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=head_class_methods --> |
− | === | + | ===Class 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 --> | ||
+ | |||
− | + | <!-- Pod2Wiki= --> | |
− | + | </div> | |
+ | <!-- Pod2Wiki=item_get_system_field_info --> | ||
+ | ====get_system_field_info==== | ||
− | + | $fields = EPrints::DataObj::Document->get_system_field_info | |
+ | Returns an array describing the system metadata of the document dataset. | ||
<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%; '> | ||
Line 316: | Line 323: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_get_defaults --> |
− | === | + | ====get_defaults==== |
+ | |||
+ | $defaults = EPrints::DataObj::Document->get_defaults( $session, $data, $dataset ) | ||
+ | Returns default values for this data object based on the starting <tt>$data</tt>. | ||
+ | |||
+ | <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_get_dataset_id --> | ||
+ | ====get_dataset_id==== | ||
− | + | $dataset = EPrints::DataObj::Document->get_dataset_id | |
+ | Returns the ID of the [[API:EPrints/DataSet|EPrints::DataSet]] object to which this record belongs. | ||
<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%; '> | ||
Line 333: | Line 349: | ||
<!-- Pod2Wiki= --> | <!-- Pod2Wiki= --> | ||
</div> | </div> | ||
− | <!-- Pod2Wiki= | + | <!-- Pod2Wiki=item_get_parent_dataset_id --> |
− | === | + | ====get_parent_dataset_id==== |
+ | |||
+ | $dataset_id = EPrints::DataObj::Document->get_parent_dataset_id | ||
+ | Returns the ID of the parent dataset for a document, (i.e. <tt>eprint</tt>). | ||
+ | |||
+ | <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_object_methods --> | ||
+ | ===Object 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 347: | Line 372: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_clone --> | <!-- Pod2Wiki=item_clone --> | ||
− | ===clone=== | + | ====clone==== |
$newdoc = $doc->clone( $eprint ) | $newdoc = $doc->clone( $eprint ) | ||
Line 362: | Line 387: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_remove --> | <!-- Pod2Wiki=item_remove --> | ||
− | ===remove=== | + | ====remove==== |
$success = $doc->remove | $success = $doc->remove | ||
Line 377: | Line 402: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_eprint --> | <!-- Pod2Wiki=item_get_eprint --> | ||
− | ===get_eprint=== | + | ====get_eprint==== |
$eprint = $doc->get_eprint | $eprint = $doc->get_eprint | ||
− | + | Returns the eprint this document is associated with. | |
Alias for: | Alias for: | ||
Line 394: | Line 419: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_baseurl --> | <!-- Pod2Wiki=item_get_baseurl --> | ||
− | ===get_baseurl=== | + | ====get_baseurl==== |
$url = $doc->get_baseurl | $url = $doc->get_baseurl | ||
Line 407: | Line 432: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_is_public --> | <!-- Pod2Wiki=item_is_public --> | ||
− | ===is_public=== | + | ====is_public==== |
$boolean = $doc->is_public | $boolean = $doc->is_public | ||
Line 420: | Line 445: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_path --> | <!-- Pod2Wiki=item_path --> | ||
− | ===path=== | + | ====path==== |
$path = $doc->path | $path = $doc->path | ||
Line 433: | Line 458: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_file_path --> | <!-- Pod2Wiki=item_file_path --> | ||
− | ===file_path=== | + | ====file_path==== |
$path = $doc->file_path( [ $file ] ) | $path = $doc->file_path( [ $file ] ) | ||
Line 451: | Line 476: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_url --> | <!-- Pod2Wiki=item_get_url --> | ||
− | ===get_url=== | + | ====get_url==== |
$url = $doc->get_url( [ $file ] ) | $url = $doc->get_url( [ $file ] ) | ||
Line 466: | Line 491: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_local_path --> | <!-- Pod2Wiki=item_local_path --> | ||
− | ===local_path=== | + | ====local_path==== |
$path = $doc->local_path | $path = $doc->local_path | ||
Line 481: | Line 506: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_files --> | <!-- Pod2Wiki=item_files --> | ||
− | ===files=== | + | ====files==== |
%files = $doc->files | %files = $doc->files | ||
− | + | Returns a hash, the keys of which are all the files belonging to this document (relative to [[API:EPrints/DataObj/Document#local_path|local_path]]). The values are the sizes of the files in bytes. | |
<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%; '> | ||
Line 494: | Line 519: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_remove_file --> | <!-- Pod2Wiki=item_remove_file --> | ||
− | ===remove_file=== | + | ====remove_file==== |
$success = $doc->remove_file( $filename ) | $success = $doc->remove_file( $filename ) | ||
Line 507: | Line 532: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_set_main --> | <!-- Pod2Wiki=item_set_main --> | ||
− | ===set_main=== | + | ====set_main==== |
$doc->set_main( $main_file ) | $doc->set_main( $main_file ) | ||
Line 522: | Line 547: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_main --> | <!-- Pod2Wiki=item_get_main --> | ||
− | ===get_main=== | + | ====get_main==== |
$filename = $doc->get_main | $filename = $doc->get_main | ||
− | + | Returns the filename of the file set as <tt>main</tt> in this document. | |
<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%; '> | ||
Line 535: | Line 560: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_set_format --> | <!-- Pod2Wiki=item_set_format --> | ||
− | ===set_format=== | + | ====set_format==== |
$doc->set_format( $format ) | $doc->set_format( $format ) | ||
Line 552: | Line 577: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_set_format_desc --> | <!-- Pod2Wiki=item_set_format_desc --> | ||
− | ===set_format_desc=== | + | ====set_format_desc==== |
$doc->set_format_desc( $format_desc ) | $doc->set_format_desc( $format_desc ) | ||
Line 569: | Line 594: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_upload --> | <!-- Pod2Wiki=item_upload --> | ||
− | ===upload=== | + | ====upload==== |
$success = $doc->upload( $filehandle, $filename, [ $preserve_path, $filesize ] ) | $success = $doc->upload( $filehandle, $filename, [ $preserve_path, $filesize ] ) | ||
Line 586: | Line 611: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_add_file --> | <!-- Pod2Wiki=item_add_file --> | ||
− | ===add_file=== | + | ====add_file==== |
$fileobj = $doc->add_file( $file, $filename, [ $preserve_path ] ) | $fileobj = $doc->add_file( $file, $filename, [ $preserve_path ] ) | ||
Line 594: | Line 619: | ||
Returns the file object if successfully created or <tt>undef</tt> on failure. | Returns the file object if successfully created or <tt>undef</tt> on failure. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<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%; '> | ||
Line 618: | Line 628: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_upload_archive --> | <!-- Pod2Wiki=item_upload_archive --> | ||
− | ===upload_archive=== | + | ====upload_archive==== |
$success = $doc->upload_archive( $filehandle, $filename, $archive_format ) | $success = $doc->upload_archive( $filehandle, $filename, $archive_format ) | ||
Line 633: | Line 643: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_add_archive --> | <!-- Pod2Wiki=item_add_archive --> | ||
− | ===add_archive=== | + | ====add_archive==== |
$success = $doc->add_archive( $file, $archive_format ) | $success = $doc->add_archive( $file, $archive_format ) | ||
Line 648: | Line 658: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_add_directory --> | <!-- Pod2Wiki=item_add_directory --> | ||
− | ===add_directory=== | + | ====add_directory==== |
$success = $doc->add_directory( $directory ) | $success = $doc->add_directory( $directory ) | ||
Line 665: | Line 675: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_upload_url --> | <!-- Pod2Wiki=item_upload_url --> | ||
− | ===upload_url=== | + | ====upload_url==== |
$success = $doc->upload_url( $url ) | $success = $doc->upload_url( $url ) | ||
Line 682: | Line 692: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_commit --> | <!-- Pod2Wiki=item_commit --> | ||
− | ===commit=== | + | ====commit==== |
$success = $doc->commit( [ $force ] ) | $success = $doc->commit( [ $force ] ) | ||
Line 701: | Line 711: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_derived_versions --> | <!-- Pod2Wiki=item_get_derived_versions --> | ||
− | ===get_derived_versions=== | + | ====get_derived_versions==== |
@derived_docs = $doc->get_derived_versions | @derived_docs = $doc->get_derived_versions | ||
− | + | Returns an array of documents that are derived from the current document through the <tt>isVersionOf</tt> relation. | |
<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%; '> | ||
Line 714: | Line 724: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_validate --> | <!-- Pod2Wiki=item_validate --> | ||
− | ===validate=== | + | ====validate==== |
$problems = $doc->validate( [ $for_archive ] ) | $problems = $doc->validate( [ $for_archive ] ) | ||
Line 731: | Line 741: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_user_can_view --> | <!-- Pod2Wiki=item_user_can_view --> | ||
− | ===user_can_view=== | + | ====user_can_view==== |
$boolean = $doc->user_can_view( $user ) | $boolean = $doc->user_can_view( $user ) | ||
− | + | Returns <tt>true</tt> if this document's security settings allow the given <tt>$user</tt> access to view it. | |
<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%; '> | ||
Line 744: | Line 754: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_type --> | <!-- Pod2Wiki=item_get_type --> | ||
− | ===get_type=== | + | ====get_type==== |
$type = $doc->get_type | $type = $doc->get_type | ||
Line 761: | Line 771: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_queue_files_modified --> | <!-- Pod2Wiki=item_queue_files_modified --> | ||
− | ===queue_files_modified=== | + | ====queue_files_modified==== |
$doc->queue_files_modified | $doc->queue_files_modified | ||
Line 774: | Line 784: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_files_modified --> | <!-- Pod2Wiki=item_files_modified --> | ||
− | ===files_modified=== | + | ====files_modified==== |
$doc->files_modified | $doc->files_modified | ||
Line 787: | Line 797: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_rehash --> | <!-- Pod2Wiki=item_rehash --> | ||
− | ===rehash=== | + | ====rehash==== |
$doc->rehash | $doc->rehash | ||
Line 800: | Line 810: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_make_indexcodes --> | <!-- Pod2Wiki=item_make_indexcodes --> | ||
− | ===make_indexcodes=== | + | ====make_indexcodes==== |
$indexcodes_doc = $doc->make_indexcodes | $indexcodes_doc = $doc->make_indexcodes | ||
Line 813: | Line 823: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_remove_indexcodes --> | <!-- Pod2Wiki=item_remove_indexcodes --> | ||
− | ===remove_indexcodes=== | + | ====remove_indexcodes==== |
$doc = $doc->remove_indexcodes | $doc = $doc->remove_indexcodes | ||
Line 826: | Line 836: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_cache_file --> | <!-- Pod2Wiki=item_cache_file --> | ||
− | ===cache_file=== | + | ====cache_file==== |
$filename = $doc->cache_file( $suffix ); | $filename = $doc->cache_file( $suffix ); | ||
Line 841: | Line 851: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_register_parent --> | <!-- Pod2Wiki=item_register_parent --> | ||
− | ===register_parent=== | + | ====register_parent==== |
$doc->register_parent( $parent ) | $doc->register_parent( $parent ) | ||
Line 856: | Line 866: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_thumbnail_url --> | <!-- Pod2Wiki=item_thumbnail_url --> | ||
− | ===thumbnail_url=== | + | ====thumbnail_url==== |
$doc->thumbnail_url( $size ) | $doc->thumbnail_url( $size ) | ||
Line 873: | Line 883: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_icon_url --> | <!-- Pod2Wiki=item_icon_url --> | ||
− | ===icon_url=== | + | ====icon_url==== |
$doc->icon_url( $size ) | $doc->icon_url( $size ) | ||
Line 886: | Line 896: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_icon_link --> | <!-- Pod2Wiki=item_render_icon_link --> | ||
− | ===render_icon_link=== | + | ====render_icon_link==== |
$frag = $doc->render_icon_link( %opts ) | $frag = $doc->render_icon_link( %opts ) | ||
Line 893: | Line 903: | ||
Options: | Options: | ||
− | + | new_window => 1 - Make link go to <tt>_blank</tt> not current window. | |
− | + | ||
− | + | preview => 1 - If possible, provide a preview pop-up. | |
− | + | ||
− | + | public => 0 - Show thumbnail/preview only on public documents. | |
− | + | ||
− | + | public => 1 - Show thumbnail/preview on all documents if possible. | |
− | + | ||
− | + | with_link => 0 - Do not link. | |
− | + | ||
− | new_window => 1 | ||
− | Make link go to <tt>_blank</tt> not current window. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | preview => 1 | ||
− | If possible, provide a preview pop-up. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | public => 0 | ||
− | Show thumbnail/preview only on public documents. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | public => 1 | ||
− | Show thumbnail/preview on all documents if possible. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | with_link => 0 | ||
− | Do not link. | ||
− | |||
<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 966: | Line 921: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_preview_link --> | <!-- Pod2Wiki=item_render_preview_link --> | ||
− | ===render_preview_link=== | + | ====render_preview_link==== |
$frag = $doc->render_preview_link( %opts ) | $frag = $doc->render_preview_link( %opts ) | ||
Line 981: | Line 936: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_caption_frag --> | <!-- Pod2Wiki=item_caption_frag --> | ||
− | ===caption_frag=== | + | ====caption_frag==== |
caption => $frag | caption => $frag | ||
Line 994: | Line 949: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_set_name --> | <!-- Pod2Wiki=item_set_name --> | ||
− | ===set_name=== | + | ====set_name==== |
set => "name" | set => "name" | ||
Line 1,007: | Line 962: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_thumbnail_plugin --> | <!-- Pod2Wiki=item_thumbnail_plugin --> | ||
− | ===thumbnail_plugin=== | + | ====thumbnail_plugin==== |
$plugin = $doc->thumbnail_plugin( $size ) | $plugin = $doc->thumbnail_plugin( $size ) | ||
− | + | Returns the plugin used to generatee thumbnails of the specified <tt>$size</tt>. | |
<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%; '> | ||
Line 1,020: | Line 975: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_thumbnail_path --> | <!-- Pod2Wiki=item_thumbnail_path --> | ||
− | ===thumbnail_path=== | + | ====thumbnail_path==== |
$path = $doc->thumbnail_path | $path = $doc->thumbnail_path | ||
Line 1,035: | Line 990: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_thumbnail_types --> | <!-- Pod2Wiki=item_thumbnail_types --> | ||
− | ===thumbnail_types=== | + | ====thumbnail_types==== |
$doc->thumbnail_types | $doc->thumbnail_types | ||
Line 1,048: | Line 1,003: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_remove_thumbnails --> | <!-- Pod2Wiki=item_remove_thumbnails --> | ||
− | ===remove_thumbnails=== | + | ====remove_thumbnails==== |
$doc->remove_thumbnails | $doc->remove_thumbnails | ||
Line 1,061: | Line 1,016: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_make_thumbnails --> | <!-- Pod2Wiki=item_make_thumbnails --> | ||
− | ===make_thumbnails=== | + | ====make_thumbnails==== |
$doc->make_thumbnails | $doc->make_thumbnails | ||
Line 1,074: | Line 1,029: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_mime_type --> | <!-- Pod2Wiki=item_mime_type --> | ||
− | ===mime_type=== | + | ====mime_type==== |
$mime_type = $doc->mime_type | $mime_type = $doc->mime_type | ||
Line 1,080: | Line 1,035: | ||
Returns the MIME type of this document. | Returns the MIME type of this document. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<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%; '> | ||
Line 1,102: | Line 1,044: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_get_parent_id --> | <!-- Pod2Wiki=item_get_parent_id --> | ||
− | ===get_parent_id=== | + | ====get_parent_id==== |
$eprintid = $doc->get_parent_id | $eprintid = $doc->get_parent_id | ||
Line 1,115: | Line 1,057: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_add_relation --> | <!-- Pod2Wiki=item_add_relation --> | ||
− | ===add_relation=== | + | ====add_relation==== |
$doc->add_relation( $tgt, @types ) | $doc->add_relation( $tgt, @types ) | ||
Line 1,130: | Line 1,072: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_remove_relation --> | <!-- Pod2Wiki=item_remove_relation --> | ||
− | ===remove_relation=== | + | ====remove_relation==== |
$doc->remove_relation( $tgt, [ @types ] ) | $doc->remove_relation( $tgt, [ @types ] ) | ||
Line 1,147: | Line 1,089: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_has_relation --> | <!-- Pod2Wiki=item_has_relation --> | ||
− | ===has_relation=== | + | ====has_relation==== |
$bool = $doc->has_relation( $tgt, [ @types ] ) | $bool = $doc->has_relation( $tgt, [ @types ] ) | ||
Line 1,160: | Line 1,102: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_search_related --> | <!-- Pod2Wiki=item_search_related --> | ||
− | ===search_related=== | + | ====search_related==== |
$list = $doc->search_related( [ $type ] ) | $list = $doc->search_related( [ $type ] ) | ||
Line 1,173: | Line 1,115: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_citation_link --> | <!-- Pod2Wiki=item_render_citation_link --> | ||
− | ===render_citation_link=== | + | ====render_citation_link==== |
$citation = $doc->render_citation_link( $style, %params ) | $citation = $doc->render_citation_link( $style, %params ) | ||
Line 1,186: | Line 1,128: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_render_video_preview --> | <!-- Pod2Wiki=item_render_video_preview --> | ||
− | ===render_video_preview=== | + | ====render_video_preview==== |
$frag = $doc->render_video_preview( $css_class ) | $frag = $doc->render_video_preview( $css_class ) | ||
Line 1,201: | Line 1,143: | ||
</div> | </div> | ||
<!-- Pod2Wiki=item_permit --> | <!-- Pod2Wiki=item_permit --> | ||
− | ===permit=== | + | ====permit==== |
$boolean = $doc->permit( $priv, $user ) | $boolean = $doc->permit( $priv, $user ) | ||
Line 1,207: | Line 1,149: | ||
See [[API:EPrints/DataObj#permit|EPrints::DataObj#permit]]. | See [[API:EPrints/DataObj#permit|EPrints::DataObj#permit]]. | ||
+ | |||
+ | <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_utility_methods --> | ||
+ | ===Utility 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 --> | ||
+ | |||
+ | |||
+ | <!-- Pod2Wiki= --> | ||
+ | </div> | ||
+ | <!-- Pod2Wiki=item_doc_with_eprintid_and_pos --> | ||
+ | ====doc_with_eprintid_and_pos==== | ||
+ | |||
+ | EPrints::DataObj::doc_with_eprintid_and_pos( $repository, $eprintid, $pos ) | ||
+ | Find the document for an eprint based on the <tt>$eprintid</tt> and <tt>$pos</tt> values supplied matching the document's corresponding fields. | ||
+ | |||
+ | Returns the document data object matching the criteria. Otherwise, checks <tt>dark_document</tt> dataset if it exists to find a corresponding match. | ||
+ | |||
+ | <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_main_input_tags --> | ||
+ | ====main_input_tags==== | ||
+ | |||
+ | EPrints::DataObj::Document::main_input_tags( $session, $object ) | ||
+ | <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_main_render_option --> | ||
+ | ====main_render_option==== | ||
+ | |||
+ | EPrints::DataObj::main_render_option( $session, $object ) | ||
+ | <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_sanitise --> | ||
+ | ====sanitise==== | ||
+ | |||
+ | $cleanfilename = EPrints::DataObj::Document::sanitise( $filename ) | ||
+ | Sanitises filename by replacing invalid characters. Mainly uses [[API:EPrints/System#sanitise|EPrints::System#sanitise]] but also replaces <tt>/</tt> with <tt>_</tt> to ensure these do not get confused as a separator between direectories. | ||
+ | |||
+ | <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_see_also --> | ||
+ | ==SEE ALSO== | ||
+ | [[API:EPrints/DataObj/SubObject|EPrints::DataObj::SubObject]], [[API:EPrints/DataObj|EPrints::DataObj]] and [[API:EPrints/DataSet|EPrints::DataSet]]. | ||
<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%; '> |
Latest revision as of 00:38, 3 January 2022
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 INSTANCE VARIABLES
- 4 CORE METADATA FIELDS
- 5 REFERENCES AND RELATED OBJECTS
- 6 METHODS
- 6.1 Constructor Methods
- 6.2 Class Methods
- 6.3 Object Methods
- 6.3.1 clone
- 6.3.2 remove
- 6.3.3 get_eprint
- 6.3.4 get_baseurl
- 6.3.5 is_public
- 6.3.6 path
- 6.3.7 file_path
- 6.3.8 get_url
- 6.3.9 local_path
- 6.3.10 files
- 6.3.11 remove_file
- 6.3.12 set_main
- 6.3.13 get_main
- 6.3.14 set_format
- 6.3.15 set_format_desc
- 6.3.16 upload
- 6.3.17 add_file
- 6.3.18 upload_archive
- 6.3.19 add_archive
- 6.3.20 add_directory
- 6.3.21 upload_url
- 6.3.22 commit
- 6.3.23 get_derived_versions
- 6.3.24 validate
- 6.3.25 user_can_view
- 6.3.26 get_type
- 6.3.27 queue_files_modified
- 6.3.28 files_modified
- 6.3.29 rehash
- 6.3.30 make_indexcodes
- 6.3.31 remove_indexcodes
- 6.3.32 cache_file
- 6.3.33 register_parent
- 6.3.34 thumbnail_url
- 6.3.35 icon_url
- 6.3.36 render_icon_link
- 6.3.37 render_preview_link
- 6.3.38 caption_frag
- 6.3.39 set_name
- 6.3.40 thumbnail_plugin
- 6.3.41 thumbnail_path
- 6.3.42 thumbnail_types
- 6.3.43 remove_thumbnails
- 6.3.44 make_thumbnails
- 6.3.45 mime_type
- 6.3.46 get_parent_id
- 6.3.47 add_relation
- 6.3.48 remove_relation
- 6.3.49 has_relation
- 6.3.50 search_related
- 6.3.51 render_citation_link
- 6.3.52 render_video_preview
- 6.3.53 permit
- 6.4 Utility Methods
- 7 SEE ALSO
- 8 COPYRIGHT
NAME
EPrints::DataObj::Document - A single format of a record.
DESCRIPTION
Document represents a single format of an EPrint (eg. PDF) - the actual file(s) rather than the metadata.
Inherits from EPrints::DataObj::SubObject, which in turn inherits from EPrints::DataObj.
INSTANCE VARIABLES
See EPrints::DataObj#INSTANCE_VARIABLES.
CORE METADATA FIELDS
docid (int)
The unique ID of the document.
rev_number (int)
The revision number of this document record.
pos (int)
The position of the document record within those associated with the eprint.
placement (int)
Placement of the document - the order documents in which should be shown. This may be different to pos, as the ultimate_doc_pos may lead to a different ordering.
format (namedset)
The format of this document. One of the types of the namedset c<document>.
formatdesc (text)
An additional description of this document. For example the specific version of a format.
language (namedset)
The ISO 639-1 code of the language of this document. The default configuration of EPrints does not set this.
security (namedset)
The security type of this document - who can view it. One of the types of the namedset security.
license (namedset)
The license applied of this document - who can view it. One of the types of the namedset license.
main (text)
The file which we should link to. For something like a PDF file this is the only file. For an HTML document with images it would be the name of the actual HTML file.
date_embargo (date)
The date until which the document has restricted access (set by security). At which point the embargo is lifted and security is set to public and this field set back to undef.
Requires bin/lift_embargos script to be deployed as a cron job.
date_embargo_retained (date)
The retained date of any embargo originally placed on this document. This is updated when a user modifies date_embargo but is not unset by the bin/lift_embargos script.
media (compound)
A compound field containing a description of the document media - dimensions, codec etc.
REFERENCES AND RELATED OBJECTS
eprintid (itemref)
The ID number of the eprint to which this document belongs.
files (subobject, multiple)
A virtual field which represents the list of files which are part of this record.
relation (relation, multiple)
Predicated relationships between this document and other data objects within the archive.
METHODS
Constructor Methods
create
$doc = EPrints::DataObj::Document::create( $session, $eprint )
Create and return a new document belonging to the given $eprint object.
N.B. This creates the document in the database, not just in memory.
create_from_data
$dataobj = EPrints::DataObj::Document::create_from_data( $session, $data, $dataset )
Create document data object from $data provided.
Returns undef if a bad (or no) eprintid specified in $data.
Otherwise calls the parent method in EPrints::DataObj.
Class Methods
get_system_field_info
$fields = EPrints::DataObj::Document->get_system_field_info
Returns an array describing the system metadata of the document dataset.
get_defaults
$defaults = EPrints::DataObj::Document->get_defaults( $session, $data, $dataset )
Returns default values for this data object based on the starting $data.
get_dataset_id
$dataset = EPrints::DataObj::Document->get_dataset_id
Returns the ID of the EPrints::DataSet object to which this record belongs.
get_parent_dataset_id
$dataset_id = EPrints::DataObj::Document->get_parent_dataset_id
Returns the ID of the parent dataset for a document, (i.e. eprint).
Object Methods
clone
$newdoc = $doc->clone( $eprint )
Attempt to clone this document. Both the document metadata and the actual files. The clone will be associated with the given $eprint.
Returns to the newly colument document.
remove
$success = $doc->remove
Attempt to completely delete this document. Including derived documents such as thumbnails.
Returns boolean dependent on success of deleting document.
get_eprint
$eprint = $doc->get_eprint
Returns the eprint this document is associated with.
Alias for:
$doc->get_parent
get_baseurl
$url = $doc->get_baseurl
Returns the base URL of the document.
is_public
$boolean = $doc->is_public
Returnes true if this document has no security set and is in the live archive. Otherwise, returns false.
path
$path = $doc->path
Returns the relative path to the document without specifying any file.
file_path
$path = $doc->file_path( [ $file ] )
Returns the relative path to $file stored in this document. If $file is undefined returns the path to the main file.
This is an efficient shortcut to this:
my $file = $doc->stored_file( $filename ); my $path = $file->path;
get_url
$url = $doc->get_url( [ $file ] )
Returns the full URL of the document.
If $file is not specified then the main file is used.
local_path
$path = $doc->local_path
DEPRECATED.
Returns the full path of the directory where this document is stored in the filesystem.
files
%files = $doc->files
Returns a hash, the keys of which are all the files belonging to this document (relative to local_path). The values are the sizes of the files in bytes.
remove_file
$success = $doc->remove_file( $filename )
Attempts to remove the file with $filename. $filename must be specified in the format that can be retrieved by get_stored_file.
set_main
$doc->set_main( $main_file )
Sets main for the document to the named $main_file and adjusts format and mime_type as necessary. Will not affect the database until the document is committed.
Unsets main if $main_file is undefined.
get_main
$filename = $doc->get_main
Returns the filename of the file set as main in this document.
set_format
$doc->set_format( $format )
Set format for document to $format. Will not affect the database until document is committed.
Alias for:
$doc->set_value( "format" , $format );
set_format_desc
$doc->set_format_desc( $format_desc )
Set format description for document to $format_desc. Will not affect the database until document is committed.
Alias for:
$doc->set_value( "format_desc" , $format_desc );
upload
$success = $doc->upload( $filehandle, $filename, [ $preserve_path, $filesize ] )
DEPRECATED - Use add_file, which will automatically identify the file type.
Upload the contents of the given $filehandle into this document as the given $filename.
If $preserve_path then make any subdirectories needed, otherwise place this in the top level directory.
add_file
$fileobj = $doc->add_file( $file, $filename, [ $preserve_path ] )
$file is the full path to a file to be added to the document, with name $filename. $filename is passed through EPrints::System#sanitise before being written.
If $preserve_path is true then include path components in $filename.
Returns the file object if successfully created or undef on failure.
upload_archive
$success = $doc->upload_archive( $filehandle, $filename, $archive_format )
DEPRECATED - use add_archive.
Upload the file contents provided through $filehandle using the filename from $filename. How to deal with the specified $archive_format (e.g. .zip, .tar.gz) is configured in EPrints::SystemSettings.
add_archive
$success = $doc->add_archive( $file, $archive_format )
Adds the contents of that archive $file to the document, where $archive_format is the format of the archive file (e.g. .zip, .tar.gz, etc.)
Returns a boolean dependent on whether the contents of the archive file is added to the document's subdirectory on the filesystem.
add_directory
$success = $doc->add_directory( $directory )
Upload the contents of $directory to this document. This will not set the document's main field.
This method expects $directory to have a trailing slash /.
Returns boolean depending on success of adding directory to document.
upload_url
$success = $doc->upload_url( $url )
Attempts to grab files from the given $url over HTTP. Grabbing files this way is always problematic. Therefore, by default, only relative links will be followed and only links to files in the same directory or subdirectory will be followed.
This method by default uses wget. However, you can modify this in EPrints::SystemSettings.
Returns a boolean dependent of whether file(s) were successfully uploaded.
commit
$success = $doc->commit( [ $force ] )
Commit any changes that have been made to this data object to the database.
Calls set_document_automatic_fields in the archive's configuration first to set any automatic fields that may be needed.
If $force is defined and true then still commit even if there are no non-volatile changes.
Returns boolean depending on whether commit of document data object is successful.
get_derived_versions
@derived_docs = $doc->get_derived_versions
Returns an array of documents that are derived from the current document through the isVersionOf relation.
validate
$problems = $doc->validate( [ $for_archive ] )
Validates the document data object. If $for_archive is defined this will be passed through to the archive configured validate_document method, in case it is required for bespoke changes to this method.
Returns a reference to an array of XHTML DOM objects describing validation problems with the entire document, including the metadata and repository config specific requirements.
A returned reference to an empty array indicates no problems.
user_can_view
$boolean = $doc->user_can_view( $user )
Returns true if this document's security settings allow the given $user access to view it.
get_type
$type = $doc->get_type
Returns the type of this document.
Alias for:
$doc->value( "format" );
queue_files_modified
$doc->queue_files_modified
Adds a files_modified task (e.g. for creating/updating thumbnails) to the event queue.
files_modified
$doc->files_modified
This method does all the things that need doing when a file has been modified.
rehash
$doc->rehash
Recalculate the hash value of the document. Uses MD5 of the files (in alphabetic order), but can use user-specified hashing function instead.
make_indexcodes
$indexcodes_doc = $doc->make_indexcodes
Make the index codes document for this document. Returns the generated index codes document on success or undef on failure.
remove_indexcodes
$doc = $doc->remove_indexcodes
Remove any documents containing index codes for this document. Returns the number of documents removed.
cache_file
$filename = $doc->cache_file( $suffix );
DEPRECATED
Returns a cache filename for this document with the given $suffix.
register_parent
$doc->register_parent( $parent )
Registers the $parent EPrints::DataObj::EPrint object for this document.
This may cause reference loops, but it does avoid two identical eprint data objects existing at once.
thumbnail_url
$doc->thumbnail_url( $size )
Returns the URL for the thumbnail of the document for a specified $size. If $size is unspecified defaults to small. Other values for $size include medium and preview.
Returns undef if file for particular type of thumbnail does not exist.
This method is called bt icon_url. It is best to use that method to reliably retrieve the required URL.
icon_url
$doc->icon_url( $size )
Returns the URL for the icon of the document for a specified $size. If $size is unspecified defaults to small. Other values for $size include medium and preview.
render_icon_link
$frag = $doc->render_icon_link( %opts )
Render a link to the icon for this document.
Options:
new_window => 1 - Make link go to _blank not current window. preview => 1 - If possible, provide a preview pop-up. public => 0 - Show thumbnail/preview only on public documents. public => 1 - Show thumbnail/preview on all documents if possible. with_link => 0 - Do not link.
render_preview_link
$frag = $doc->render_preview_link( %opts )
Render a link to the preview for this document (if available) using a lightbox.
Options:
caption => $frag
XHTML fragment to use as the caption, defaults to empty.
set_name
set => "name"
The name of the set this document belongs to, defaults to none (preview won't be shown as part of a set).
thumbnail_plugin
$plugin = $doc->thumbnail_plugin( $size )
Returns the plugin used to generatee thumbnails of the specified $size.
thumbnail_path
$path = $doc->thumbnail_path
DEPRECATED
Returns the filesystem path to location of thumbnails for the document.
thumbnail_types
$doc->thumbnail_types
Returns array containing names of all the thumbnail types available for this document.
remove_thumbnails
$doc->remove_thumbnails
Removes all thumbnail files associated with this document.
make_thumbnails
$doc->make_thumbnails
Make all the thumbnail files required for this document.
mime_type
$mime_type = $doc->mime_type
DEPRECATED - use $doc->value( "mime_type" )
Returns the MIME type of this document.
get_parent_id
$eprintid = $doc->get_parent_id
Returns the ID of the parent for this document, (i.e. the eprint ID).
add_relation
$doc->add_relation( $tgt, @types )
Add one or more relations with type(s) specified by @types to the document data object and pointing to the $tgt data object.
This will not update the $tgt data object even if reflexive relations exist.
remove_relation
$doc->remove_relation( $tgt, [ @types ] )
Removes the relations for the document data object to the $tgt data object. If @types is not defined, remove all relations to $tgt. If $tgt is also undefined removes all relations given in @types.
If both $tgt, and @types are both undefined no relations will be removed. If you want to remove all relations do:
$doc->set_value( "relation", [] );
has_relation
$bool = $doc->has_relation( $tgt, [ @types ] )
Returns true if document data object has relations to $tgt. If @types is also given, check these relations satisfy all of the given types. If $tgt is undefined, relations that satisfy the given types may be to any data object.
$list = $doc->search_related( [ $type ] )
Returns an EPrints::List that contains all document data objects related to this document data object. If $type is defined return only those document data object related by that type.
render_citation_link
$citation = $doc->render_citation_link( $style, %params )
Returns a XHTML DOM citation rendering of the document data object. Using citation $style and %params provided and setting class for DOM parent element to ep_document_link.
render_video_preview
$frag = $doc->render_video_preview( $css_class )
Returns a XHTML DOM fragment rendering of a HTML5 video preview with optional subtitles. Assigning the $css_class to the parent element if the XHTML DOM fragment, if provided.
Access / security concerns should be addressed at a higher level.
permit
$boolean = $doc->permit( $priv, $user )
Returns boolean depending on whether the $user has the privilege $priv to carry out a particular action on this document data object.
Utility Methods
doc_with_eprintid_and_pos
EPrints::DataObj::doc_with_eprintid_and_pos( $repository, $eprintid, $pos )
Find the document for an eprint based on the $eprintid and $pos values supplied matching the document's corresponding fields.
Returns the document data object matching the criteria. Otherwise, checks dark_document dataset if it exists to find a corresponding match.
main_input_tags
EPrints::DataObj::Document::main_input_tags( $session, $object )
main_render_option
EPrints::DataObj::main_render_option( $session, $object )
sanitise
$cleanfilename = EPrints::DataObj::Document::sanitise( $filename )
Sanitises filename by replacing invalid characters. Mainly uses EPrints::System#sanitise but also replaces / with _ to ensure these do not get confused as a separator between direectories.
SEE ALSO
EPrints::DataObj::SubObject, EPrints::DataObj and EPrints::DataSet.
COPYRIGHT
© Copyright 2000-2024 University of Southampton.
EPrints 3.4 is supplied by EPrints Services.
http://www.eprints.org/eprints-3.4/
LICENSE
This file is part of EPrints 3.4 http://www.eprints.org/.
EPrints 3.4 and this file are released under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation unless otherwise stated.
EPrints 3.4 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 3.4. If not, see http://www.gnu.org/licenses/.