metadata_functions.php
Metadata related functions
Functions related to resource metadata in general
Table of Contents
Enums
Functions
- runFitsForFile() : bool|SimpleXMLElement
- Run FITS on a file and get the output back
- getFitsMetadataFieldValue() : string
- Get metadata value for a FITS field
- extractFitsMetadata() : bool
- Extract FITS metadata from a file for a specific resource.
- check_date_format() : string
- Check date conforms to "yyyy-mm-dd hh:mm" format or any valid partital of that e.g. yyyy-mm.
- check_date_parts() : string
- Check datepart conforms to its formatting and error out each section accordingly
- update_fieldx() : void
- updates the value of fieldx field further to a metadata field value update
- exiftool_resolution_calc() : void
- Extract and store dimensions, resolution, and unit (if available) from exif data Exiftool output format (tab delimited): widthxheight resolution unit (e.g., 1440x1080 300 inches)
- get_required_fields() : array<string|int, mixed>
- Return array containing data for all required fields that apply to the given resource type.
- missing_fields_check() : array<string|int, mixed>
- For a given resource, return an array of data for required metadata field references which have not been completed.
- update_archive_required_fields_check() : array<string|int, mixed>
- Considers if checking of missed required fields is required when a resource changes archive state. We'll always allow moving to the $resource_deletion_state and Pending Submission state (-2). Exceptions made to archive states in rse_workflow will be applied.
- update_geolocation_fields() : void
- Update the geo location fields (if set) for the given resource(s).
Functions
runFitsForFile()
Run FITS on a file and get the output back
runFitsForFile(string $file_path) : bool|SimpleXMLElement
Parameters
- $file_path : string
-
Physical path to the file
Tags
Return values
bool|SimpleXMLElementgetFitsMetadataFieldValue()
Get metadata value for a FITS field
getFitsMetadataFieldValue(SimpleXMLElement $xml, string $fits_field) : string
Parameters
- $xml : SimpleXMLElement
-
FITS metadata XML
- $fits_field : string
-
A ResourceSpace specific FITS field mapping which allows ResourceSpace to know exactly where to look for that value in XML by converting it to an XPath query string. Example: video.mimeType would point to
Tags
Return values
stringextractFitsMetadata()
Extract FITS metadata from a file for a specific resource.
extractFitsMetadata(string $file_path, int|array<string|int, mixed> $resource) : bool
Parameters
- $file_path : string
-
Path to the file from which you will extract FITS metadata
- $resource : int|array<string|int, mixed>
-
Resource ID or resource array (as returned by get_resource_data())
Tags
Return values
boolcheck_date_format()
Check date conforms to "yyyy-mm-dd hh:mm" format or any valid partital of that e.g. yyyy-mm.
check_date_format(mixed $date) : string
Parameters
- $date : mixed
Tags
Return values
stringcheck_date_parts()
Check datepart conforms to its formatting and error out each section accordingly
check_date_parts(mixed $parts) : string
Parameters
- $parts : mixed
Tags
Return values
stringupdate_fieldx()
updates the value of fieldx field further to a metadata field value update
update_fieldx(int $metadata_field_ref) : void
Parameters
- $metadata_field_ref : int
-
- metadata field ref
exiftool_resolution_calc()
Extract and store dimensions, resolution, and unit (if available) from exif data Exiftool output format (tab delimited): widthxheight resolution unit (e.g., 1440x1080 300 inches)
exiftool_resolution_calc(string $file_path, int $ref[, bool $remove_original = false ]) : void
Parameters
- $file_path : string
-
Path to the original file.
- $ref : int
-
Reference of the resource.
- $remove_original : bool = false
-
Option to remove the original record. Used by update_resource_dimensions.php
get_required_fields()
Return array containing data for all required fields that apply to the given resource type.
get_required_fields(int $resource_type) : array<string|int, mixed>
Parameters
- $resource_type : int
-
Resource type reference.
Return values
array<string|int, mixed>missing_fields_check()
For a given resource, return an array of data for required metadata field references which have not been completed.
missing_fields_check(int|array<string|int, mixed> $resource) : array<string|int, mixed>
Required fields shown by a display condition will only be considered required if the display condition is met.
Parameters
- $resource : int|array<string|int, mixed>
-
Integer representing the resource reference or array of resource data from get_resource_data().
Return values
array<string|int, mixed>update_archive_required_fields_check()
Considers if checking of missed required fields is required when a resource changes archive state. We'll always allow moving to the $resource_deletion_state and Pending Submission state (-2). Exceptions made to archive states in rse_workflow will be applied.
update_archive_required_fields_check(int|array<string|int, mixed> $resource, int $archive_state) : array<string|int, mixed>
Return will consist of an empty array where no checking is needed or an array of metadata field data where the field is required but was not completed.
Parameters
- $resource : int|array<string|int, mixed>
-
Resource ref or array of resource data, likely from get_resource_data().
- $archive_state : int
-
Destination archive state.
Return values
array<string|int, mixed>update_geolocation_fields()
Update the geo location fields (if set) for the given resource(s).
update_geolocation_fields(int|array<string|int, mixed> $resources, string|array<string|int, mixed> $location) : void
User permissions are not checked as this should be used in cases where the user has already edited the location.
Parameters
- $resources : int|array<string|int, mixed>
-
The resource ref(s) as a single integer or an array of integers.
- $location : string|array<string|int, mixed>
-
The new location to use, a blank string to clear the location from the resource(s). Otherwise an array with two integer values being the latitude and longitude.