$environment
$environment : \O3PO_Environment
The envrironment in which this publication type exists.
Class representing the primary publication type.
Abstract base class for representing different publication types as custom WordPress post types.
$environment : \O3PO_Environment
The envrironment in which this publication type exists.
$journal : \O3PO_Journal
The array holding the properties of the journal this post type is associated with.
__construct(object $journal, \O3PO_Environment $environment)
Construct this publication type.
Constructs and registers this publication type in the array static::$active_publication_types. Throws an error in case a publication type with the same $publication_type_name is alreay registered.
object | $journal | The journal this publication type is associated with. |
\O3PO_Environment | $environment | The evironment in which this post type is to be created. |
init_metabox()
Init the meta box for all publication types and add hooks for its save action.
Normally all hooks should be added in class-o3po.php. This method is special in that it adds two extra hooks. We do this, because we need to unhook one of them during save_metabox() (see below), so that it is better to keep this all contained in the same file
save_metabox(integer $post_id, \WP_Post $post)
Callback function for handling the data enterd into the meta-box when a correspnding post is saved.
Calls save_meta_data() and validate_and_process_data() as well as a bunch of other methods such as on_post_actually_published() when appropriate to actually do the processing. Also ensures that the post is forced to private as long as there are still validation ERRORs or REVIEW requests.
Warning: This is already called when a New Post is created and not only when the "Publish" or "Update" button is pressed!
integer | $post_id | The id of the post for which to save the metabox. |
\WP_Post | $post | The post for which to save the metabox. |
on_transition_post_status(string $new, string $old, integer $post)
Handle post status transitions
To be added to the 'transition_post_status' hook.
string | $new | The new post status after this transition. |
string | $old | The old post status before this transition. |
integer | $post | The post that is undergoing the transitions. |
generate_crossref_xml_doi_batch_id(integer $post_id, string $timestamp)
Generate a doi batch id for coressref
Cossref requires us to generate a unique id for each doi batch submission. Here we do this by adding a timestamp to the doi of the post we want to register.
integer | $post_id | Id of the post for which to generate the doi batch id. |
string | $timestamp | Timestamp of the submission for which the requested batch id is to be used. |
generate_crossref_xml(integer $post_id, string $doi_batch_id, $timestamp)
Generate an xml representation of the meta-data of that post suitable for crossref.
This function return a string containing xml formated meta-data about the given $post_id that can be uploaded to and then processed by Crossref.
See https://www.crossref.org/education/content-registration/crossrefs-metadata-deposit-schema/crossref-xsd-schema-quick-reference/ for the documentation of the Corssref XML scheme.
integer | $post_id | Id of the post for which the crossref xml is to be generated. |
string | $doi_batch_id | Batch id of the submission for which the crossref xml is to be generated. |
$timestamp |
generate_clockss_xml(integer $post_id)
Generate xml suitable for the submission to CLOCKSS
This function returns a string containing xml formated according to the JATS scheme suitable for CLOCKSS.
integer | $post_id | Id of the post for which to generate the clockss xml. |
generate_doaj_json(integer $post_id)
Generate json suitable for the submission to DOAJ
This function returns a json encoded string containing the meta-data in a format suitable for DOAJ.
TODO: Clean this up once we got some feedback from DOAJ
integer | $post_id | Id of the post for which to generate the the json encoded meta-data. |
get_formated_bibliography_entry_html(array $entry)
Get a formated bibliography entry.
Expects a entry of a bibliography such as those that can be obtained via O3PO_Latex::parse_bbl() from bbl code.
array | $entry | Array describing the bibliography entry. |
get_cited_by_data(integer $post_id, boolean $fetch_if_outdated = true) : array
Get cited-by data.
integer | $post_id | Id of the post. |
boolean | $fetch_if_outdated | Whether to fetch new data from remote services if the cached data is considered outdated (default true). |
Array containing cited-by data in various formats.
admin_page_extra_css(integer $post_id = null)
Adds css to the amin area to hide the WordPress title field for the associated post type to avoid confusion.
To be added to the 'admin_head' action.
integer | $post_id | The Id of the post that is views (defaults to null). If left empty global $post is used. |
get_post_meta_field_containing_array(integer $post_id, string $key)
Get a post meta field that is expected to contain an array.
Contrary to get_post_meta($post_id, $key, true ) this returns an emty array() if the key is unset. This allows to directly add to the array with the [] notation even on php >= 7.1, wich no longer allows this notation on strings.
integer | $post_id | The Id of the post whose meta field is to be retreived. |
string | $key | The key that is to be retreived. |
get_pdf_pretty_permalink(integer $post_id)
Get the pretty permalink of the pdf associated with a post.
For Google Scholar the full text must be available in a
subdirectory of the abstract page and anyway it is nice to have a
consistent api for downloading the fulltext pdf. The following
functions are added to the 'init' and 'parse_request' hooks and
thereby make any url of the form [post-type-name]/
integer | $post_id | Id of the post. |
get_all_citation_counts(boolean $fetch_if_outdated = false) : array
Get the citation counts for all publications of the given type.
boolean | $fetch_if_outdated | Whether to fetch new data if the currently cached one is considered outdated. |
Array with information about citation counts.
html_latex_excerpt(string $str, integer $count, string $more = null) : string
Excerpt from a string with html and LaTeX
Safely extracts not more than the first $count characters from a string containing html and LaTeX code (including mathematical formulas).
string | $str | String to get the excerpt from. |
integer | $count | Maximum number of characters to take. |
string | $more | (Optional) What to append if $str needs to be trimmed. Defaults to empty string. Default value: null |
The excerpt.
handle_pdf_endpoint_request(\WP_Query $wp_query, boolean $do_not_exit = false)
Handle request to the /pdf endpoint for serving the full text pdf.
For PHPUnit testing this function needs a way to suppress the calls to exit(), which are otherwise necessary to prevent other parts of WordPress from adding additional output to the PDF we want to deliver. This can be done with the optional parameter $do_not_exit which defaults to false.
To be added to the 'parse_request' action.
\WP_Query | $wp_query | The WP_Query to be handled. |
boolean | $do_not_exit | Prevent this function from calling exit() and return instead. |
handle_web_statement_endpoint_request(\WP_Query $wp_query, boolean $do_not_exit = false)
Handle requests to the /web-statement end point for serving a web statement of the licence.
For PHPUnit testing this function needs a way to suppress the calls to exit(), which are otherwise necessary to prevent other parts of WordPress from adding additional output to the web statement we want to deliver. This can be done with the optional parameter $do_not_exit which defaults to false. To be added to the 'parse_request' action.
\WP_Query | $wp_query | The WP_Query to be handled. |
boolean | $do_not_exit | Prevent this function from calling exit() and return instead. |
handle_arxiv_paper_doi_feed_endpoint_request(\WP_Query $wp_query, boolean $do_not_exit = false)
Handle requests to the arxiv_paper_doi_feed endpoint for serving a feed of recent papers for the arXiv.
To be added to the 'parse_request' action.
\WP_Query | $wp_query | The WP_Query to be handled. |
boolean | $do_not_exit | Prevent this function from calling exit() and return instead. |
save_meta_data(integer $post_id)
Callback function for handling the data enterd into the meta-box when a correspnding post is saved.
Calls save_meta_data() and validate_and_process_data() as well as a bunch of other methods such as on_post_actually_published() when appropriate to actually do the processing. Also ensures that the post is forced to private as long as there are still validation ERRORs or REVIEW requests.
Warning: This is already called when a New Post is created and not only when the "Publish" or "Update" button is pressed!
integer | $post_id | Id of the post whose meta data is to be saved. |
validate_and_process_data(integer $post_id)
Validate and process the meta-data that was saved in save_meta_data().
We also trigger interactions with external services (Crossref, DOAJ, CLOCKSS) here.
integer | $post_id | The id of the post whose meta-data is to be validated and processed. |
upload_meta_data_to_crossref(string $doi_batch_id, string $crossref_xml, string $crossref_id, string $crossref_pw, string $crossref_url)
Submit meta-data to Crossref.
This function must be private since we do no longer check internally whether we are running on the test system.
string | $doi_batch_id | Batch id of this upload. |
string | $crossref_xml | The xml to upload. |
string | $crossref_id | The id for which to submit this upload. |
string | $crossref_pw | The password corresponding to the crossref_id. |
string | $crossref_url | The url of the crossref server to upload to. |
upload_meta_data_to_doaj(string $doaj_json, string $doaj_api_url, string $doaj_api_key)
Submit meta-data to DOAJ.
From the command line you could do rouhgly the smame via:
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "[json goes here]" "https://doaj.org/api/v1/articles?api_key=XXX" see https://doaj.org/api/v1/docs#/ for more infomation.
DOAJ has no test system, so that we can only get a response from the real system once we publish the final and actual record.
This function must be private since we do no longer check internally whether we are running on the test system.
string | $doaj_json | The JSON encoded meta-data to upload. |
string | $doaj_api_url | The url of the DOAJ api to upload to. |
string | $doaj_api_key | The API key with DOAJ |
upload_meta_data_and_pdf_to_clockss(string $clockss_xml, string $pdf_path, string $remote_filename_without_extension, string $clockss_ftp_url, string $clockss_username, string $clockss_password)
Submit meta-data and full text to CLOCKSS.
Upload an xml file with the meta-data and the full text pdf to CLOCKSS.
CLOCKSS has no test system, so that we can only get a response from the real system once we publish the final and actual record.
This function must be private since we do no longer check internally whether we are running on the test system.
string | $clockss_xml | The xml encoded meta-data to upload. |
string | $pdf_path | Path to the local fulltext pdf |
string | $remote_filename_without_extension | Filename without extension under which the files are to be deposited on the remore server |
string | $clockss_ftp_url | The url of the CLOCKSS ftp server. |
string | $clockss_username | The CLOCKSS username |
string | $clockss_password | The CLOCKSS password |
parse_publication_source(string $path_source, string $mime_type)
Parse the source files.
Depending on the manuscript we either got a single uncompressed .tex file or a tar.gz archive from the arXiv which we have to extract and then analyse.
string | $path_source | Path to the source file. |
string | $mime_type | Mime type of the source file. |