O3PO_Arxiv
in package
Encapsulates the interface with the external service arXiv.
Provides methods to interface with arXiv.
Tags
Table of Contents
Methods
- download_pdf() : mixed
- Download the source of an eprint from the arXiv.
- download_source() : mixed
- Download the source of an eprint from the arXiv.
- fetch_meta_data_from_abstract_page() : array<string|int, mixed>
- Fetch meta-data from the abstract page of an eprint on the arXiv.
- get_abstract_page_html() : string
- Get the html of the abstract page
- get_arxiv_upload_date() : int|WP_Error
- Get the date at which a eprint was uploaded to the arXiv.
- get_submission_history_from_abstract_page() : array<string|int, mixed>|WP_Error
- Get the submission history from the abstract page of an eprint on the arXiv.
- is_cc_by_license_url() : bool
- Check whether a url is a CC-BY license url
Methods
download_pdf()
Download the source of an eprint from the arXiv.
public
static download_pdf(O3PO_Environment $environment, string $arxiv_url_pdf_prefix, string $eprint, string $file_name_without_extension, int $post_id) : mixed
Uses the provided $evironment to download the pdf of an eprint from the arXiv.
Parameters
- $environment : O3PO_Environment
-
The environment to use for downloading
- $arxiv_url_pdf_prefix : string
-
The url prefix under which arXiv pdfs can be found.
- $eprint : string
-
The eprint whose source is to be downloaded
- $file_name_without_extension : string
-
The desired filename without extension of the local file after the download.
- $post_id : int
-
Id of the post to which to attach the download.
Tags
Return values
mixed —Returns a map with information on the downloaded file. See O3PO_Environment for more details.
download_source()
Download the source of an eprint from the arXiv.
public
static download_source(O3PO_Environment $environment, string $arxiv_url_source_prefix, string $eprint, string $file_name_without_extension, int $post_id) : mixed
The arXiv returns either a tar.gz file in case the authors' submission consisted of multiple files, or a single uncompressed tex file. The returned mime type is accessible via the 'mime_type' key in the returned results.
Parameters
- $environment : O3PO_Environment
-
The environment to use for downloading
- $arxiv_url_source_prefix : string
-
The url prefix under which arXiv source can be found.
- $eprint : string
-
The eprint whose source is to be downloaded
- $file_name_without_extension : string
-
The desired filename without extension of the local file after the download.
- $post_id : int
-
Id of the post to which to attach the download.
Tags
Return values
mixed —Returns a map with information on the downloaded file. See O3PO_Environment for more details.
fetch_meta_data_from_abstract_page()
Fetch meta-data from the abstract page of an eprint on the arXiv.
public
static fetch_meta_data_from_abstract_page(string $arxiv_url_abs_prefix, string $eprint[, int $timeout = 10 ][, bool $check_license = true ]) : array<string|int, mixed>
Extracts the abstract, number_authors, author_first_names, author_last_names and title. As there is no way to tell, whether the first name is the given or surname we cannot deduce the given names and surnames and instead return first and last names.
Parameters
- $arxiv_url_abs_prefix : string
-
The url prefix under which arXiv abstracts can be found.
- $eprint : string
-
The eprint for which to fetch the meta-data.
- $timeout : int = 10
-
An optional timeout.
- $check_license : bool = true
-
Whether to fetch and check the license.
Tags
Return values
array<string|int, mixed> —An array containing the extracted meta-data.
get_abstract_page_html()
Get the html of the abstract page
public
static get_abstract_page_html(string $arxiv_url_abs_prefix, string $eprint[, int $timeout = 10 ]) : string
Parameters
- $arxiv_url_abs_prefix : string
-
The url prefix under which arXiv abstracts can be found.
- $eprint : string
-
The eprint for which to fetch the meta-data.
- $timeout : int = 10
-
An optional timeout.
Tags
Return values
string —The html
get_arxiv_upload_date()
Get the date at which a eprint was uploaded to the arXiv.
public
static get_arxiv_upload_date(string $arxiv_url_abs_prefix, string $eprint[, int $timeout = 10 ]) : int|WP_Error
Parameters
- $arxiv_url_abs_prefix : string
-
The url prefix under which arXiv abstracts can be found.
- $eprint : string
-
The eprint for which to get the upload date.
- $timeout : int = 10
-
An optional timeout.
Tags
Return values
int|WP_Error —The upload date
get_submission_history_from_abstract_page()
Get the submission history from the abstract page of an eprint on the arXiv.
public
static get_submission_history_from_abstract_page(string $arxiv_url_abs_prefix, string $eprint[, int $timeout = 10 ]) : array<string|int, mixed>|WP_Error
Extracts the submission history.
Parameters
- $arxiv_url_abs_prefix : string
-
The url prefix under which arXiv abstracts can be found.
- $eprint : string
-
The eprint for which to fetch the meta-data.
- $timeout : int = 10
-
An optional timeout.
Tags
Return values
array<string|int, mixed>|WP_Error —An array describing the submission history with the versions being the keys and each element an array containing the submission time stamp and size.
is_cc_by_license_url()
Check whether a url is a CC-BY license url
public
static is_cc_by_license_url(string $url) : bool
Parameters
- $url : string
-
Url to check
Tags
Return values
bool —True if it is a CC-BY license