Documentation

O3PO_Journal
in package
implements O3PO_SettingsSpecifyer

The functionality related to individual journals.*

Tags
since
0.1.0
subpackage

O3PO/includes

author

Christian Gogolin o3po@quantum-journal.org

Table of Contents

Interfaces

O3PO_SettingsSpecifyer
Interface for classes specifying settings.

Properties

$doi_suffix_template  : O3PO_ShortcodeTemplate
The shortcode template used to construct DOIs.
$journal_config  : array<string|int, mixed>
Array holding the configuration of the journal.
$required_journal_config_properties  : array<string|int, mixed>
Required journal config properties

Methods

__construct()  : mixed
Initialize the journal.
add_fake_post_to_volume_overview_page()  : array<string|int, mixed>
Add a fake "empty" post to make 'loop_start' fire on the volume overview page
add_notice_to_search_form()  : string
Add a notice to the search form if there are no results.
add_notice_to_search_results_at_loop_start()  : mixed
Add a notice to the search results.
add_volumes_endpoint()  : mixed
Adds a rewrite endpoint for the /volumes/, /volumes/1, /volumes/2, ... pages.
compress_entries_in_volume_view()  : mixed
Inject java script to compress the entries in the volume listings
construct_doi_suffix()  : string
Construct the doi suffix for publications.
create_fake_post()  : stdClass
Create and return a fake empty post.
doi_suffix_still_free()  : mixed
Determines whether a given page number is still free.
get_count_of_volume()  : mixed
Get number of posts of the given type in the given volume.
get_journal_config_properties()  : mixed
Get an array of all options the journal expects in its journal config.
get_journal_property()  : mixed
Get a journal property.
get_post_type_highest_pages_info()  : mixed
Returns information about the post with the highest page number.
get_search_notice()  : mixed
Generate the notice for the search page.
handle_volumes_endpoint_request()  : Modified
Handle the requests to the /volume/ endpoint.
pages_still_free_info()  : mixed
Determines whether a given page number is still free.
render_doi_suffix_template_setting()  : mixed
Render the setting for the DOI suffix template.
specify_settings()  : mixed
Specifies class specific settings sections and fields.
validate_doi_suffix_template()  : string
Clean user input to the doi_suffix_template setting.
volume_endpoint_template()  : string
Force the usage of the page template on the volume overview page
volume_navigation_at_loop_start()  : mixed
Add navigation before the loop to the pages of the volume endpoint.

Properties

$doi_suffix_template

The shortcode template used to construct DOIs.

private static O3PO_ShortcodeTemplate $doi_suffix_template

The shortcode template used to construct DOIs.

Tags
since
0.4.0
access

private

$journal_config

Array holding the configuration of the journal.

private array<string|int, mixed> $journal_config = array()

Array of properties definig the journal.

Tags
since
0.1.0
access

private

$required_journal_config_properties

Required journal config properties

private static array<string|int, mixed> $required_journal_config_properties = array( 'arxiv_doi_feed_identifier', //from primary 'arxiv_url_abs_prefix', 'arxiv_url_pdf_prefix', //from primary 'arxiv_url_source_prefix', //from primary 'arxiv_url_trackback_prefix', //from secondary 'buffer_api_url', 'buffer_access_token', 'buffer_profile_ids', 'crossref_archive_locations', 'crossref_deposite_url', 'crossref_email', 'crossref_get_forward_links_url', 'crossref_id', 'crossref_pw', 'crossref_test_deposite_url', 'crossref_crossmark_policy_page_doi', 'ads_api_search_url', 'ads_api_token', 'developer_email', 'doaj_api_key', 'doaj_api_url', 'doaj_language_code', 'doi_prefix', 'journal_level_doi_suffix', 'doi_suffix_template', 'doi_url_prefix', 'eissn', 'fermats_library_email', //from primary 'fermats_library_url_prefix', //from primary 'first_volume_year', 'journal_title', 'license_explanation', 'license_name', //from primary 'license_type', 'license_url', 'license_version', 'orcid_url_prefix', 'publisher', 'publisher_country', 'publisher_email', 'scholastica_manuscripts_url', //from primary 'clockss_ftp_url', 'clockss_username', 'clockss_password', 'publication_type_name', //not in in settings 'publication_type_name_plural', //not in in settings 'volumes_endpoint', )

Array of all required journal config properties.

Tags
since
0.1.0
access

private

Methods

__construct()

Initialize the journal.

public __construct(array<string|int, mixed> $journal_config) : mixed
Parameters
$journal_config : array<string|int, mixed>

Array with values for the keys returned by get_journal_config_properties().

Tags
since
0.1.0
access

public

add_fake_post_to_volume_overview_page()

Add a fake "empty" post to make 'loop_start' fire on the volume overview page

public add_fake_post_to_volume_overview_page(array<string|int, mixed> $posts) : array<string|int, mixed>

For queries that do not return any posts, the loop is never run. As we initiate an empty query for the top level volume endpoint that is supposed to serve the volume overview page, we must add at least a fake "empty" post to the $posts in order to allow us to inject content into the standard page template of the current theme.

To be added to the 'the_posts' action.

Parameters
$posts : array<string|int, mixed>

Array of posts that would be returned if we do not intervene.

Tags
since
0.3.0
access

public

Return values
array<string|int, mixed> —

Array of posts that are returned if we do intervene.

add_notice_to_search_form()

Add a notice to the search form if there are no results.

public add_notice_to_search_form(string $form) : string

To be added to the 'get_search_form' filter.

Parameters
$form : string

The normal search form,

Tags
since
0.3.0
access

public

Return values
string —

Modified search form.

add_notice_to_search_results_at_loop_start()

Add a notice to the search results.

public add_notice_to_search_results_at_loop_start(WP_Query $wp_query) : mixed

To be added to the 'loop_start' filter.

Parameters
$wp_query : WP_Query

The current Wordpress query.

Tags
since
0.3.0
access

public

add_volumes_endpoint()

Adds a rewrite endpoint for the /volumes/, /volumes/1, /volumes/2, ... pages.

public add_volumes_endpoint() : mixed

To be added to the 'init' action.

Tags
since
0.1.0
access

public

compress_entries_in_volume_view()

Inject java script to compress the entries in the volume listings

public compress_entries_in_volume_view(WP_Query $wp_query) : mixed

Inject some java script to change how the entries of individual publications are displayed in the list of a volume.

To be added to the 'loop_end' filter.

Parameters
$wp_query : WP_Query

The current Wordpress query.

Tags
since
0.3.0
access

public

construct_doi_suffix()

Construct the doi suffix for publications.

public construct_doi_suffix(string $date_published, string|int $volume, string|int $pages) : string

Returns the doi suffix according to the template specified in settings.

Parameters
$date_published : string

A date in ISO_8601 format.

$volume : string|int

The volume for which to construct the DOI.

$pages : string|int

The page/article number for which to construct the DOI.

Tags
since
0.4.0
access

private

Return values
string —

The doi suffix constructed according to the template of this publication type.

create_fake_post()

Create and return a fake empty post.

public create_fake_post([string $post_content = '' ]) : stdClass
Parameters
$post_content : string = ''

The content of the post to create.

Tags
since
0.3.0
access

public

Return values
stdClass —

A WP_Post compatible object representing a fake post that is empty apart from the given cont.

doi_suffix_still_free()

Determines whether a given page number is still free.

public static doi_suffix_still_free(string $doi_suffix, array<string|int, mixed> $post_types) : mixed

This function can be used to check whether a given $doi_suffix is sitll free or already taken by a registered post type.

Parameters
$doi_suffix : string

Doi suffix to be checked.

$post_types : array<string|int, mixed>

Post types to take into accoun.

Tags
since
0.1.0
access

public

get_count_of_volume()

Get number of posts of the given type in the given volume.

public static get_count_of_volume(int $vol_num, string $publication_type) : mixed

If $vol_num is empty, the total number over all volumes is returned.

Parameters
$vol_num : int

Volume number to count or all volumes if empty.

$publication_type : string

Publication type to count.

Tags
since
0.1.0
access

public

get_journal_config_properties()

Get an array of all options the journal expects in its journal config.

public static get_journal_config_properties() : mixed
Tags
since
0.1.0
access

public

get_journal_property()

Get a journal property.

public get_journal_property(string $id) : mixed
Parameters
$id : string

Id of the property.

Tags
since
0.1.0
access

public

get_post_type_highest_pages_info()

Returns information about the post with the highest page number.

public static get_post_type_highest_pages_info(int $post_id_to_exclude, array<string|int, mixed> $post_types) : mixed

We have an aricle/fake page number that counts up 1,2,3,... This function determines the highes such number among all posts of the given publication types as well as the publication date of that post. Only published and future posts (i.e. such scheduled for publication) apart from the excluded post are taken into account.

Parameters
$post_id_to_exclude : int

Id of a post to exclude in the calculation

$post_types : array<string|int, mixed>

Array of post types to take into account.

Tags
since
0.1.0
access

public

get_search_notice()

Generate the notice for the search page.

public get_search_notice() : mixed
Tags
since
0.3.0
access

public

handle_volumes_endpoint_request()

Handle the requests to the /volume/ endpoint.

public handle_volumes_endpoint_request(WP_Query $wp_query) : Modified

We want to display an overview of the available volumes as well as sub-pages with lists for each volume. Here we set up appropriate queries to do that.

We then want that Wordpress and the theme take care of turning these queries into actual pages without the need for further intervention from ours side to the extent possible in order to (i) make this plugin as theme independent as possible and (ii) have the volume page rendered with the global theme the users have chosen for their website.

Unfortunately we run into several complications:

  • For the lists of publications in a given volume it is straight forward to generate the query and a navigation can be nicely added just above the list by hooking into 'loop_start' (see below).

  • For the overview page of all volumes we can add the navigation in the same way, but we don't want to display any entries. We thus set up an empty query and force the usage of the 'page' template (see the function volume_endpoint_template() below). Without any posts to show, however, even the 'page' template does not execute 'loop_start' and (depending on the theme) can fall back to the 'content-none' template. To prevent this we have to add a fake "empty" post. We do this during the 'the_posts' action in add_fake_empty_post_to_volume_overview_page() (see below).

  • Finally, we want the entries in the list to appear more "compressed" than in other archive pages. This again could be solved with a custom theme or template, but we want to stay largely theme independent. We thus instead insert some java script into the page to hide parts of the generated html and reduce the spacing between elements. This will not work with every theme, but at least is unlikely to cause serious unintended side-effects.

The true long-term solution to the problem we are solving here could be taxonomies.

To be added to the 'parse_request' action.

Parameters
$wp_query : WP_Query

Query to act on.

Tags
since
0.1.0
access

public

Return values
Modified —

WP_Query object.

pages_still_free_info()

Determines whether a given page number is still free.

public static pages_still_free_info(int $post_id_to_exclude, int $pages, array<string|int, mixed> $post_types) : mixed

We have an aricle/fake page number that counts up 1,2,3,... This function determines whether $pages is still free, in the sense that no post with a type in $post_types other than that with id $post_id already has page number $pages.

Parameters
$post_id_to_exclude : int

Id of a post to exclude.

$pages : int

Page number to be checked for whether it is still free or not.

$post_types : array<string|int, mixed>

Post types to take into account.

Tags
since
0.1.0
access

public

render_doi_suffix_template_setting()

Render the setting for the DOI suffix template.

public static render_doi_suffix_template_setting() : mixed
Tags
since
0.4.0
access

public

specify_settings()

Specifies class specific settings sections and fields.

public static specify_settings(O3PO_Settings $settings) : mixed

To be called during during O3PO_Settings::configure().

Parameters
$settings : O3PO_Settings

Settings object.

Tags
since
0.4.1+
access

public

validate_doi_suffix_template()

Clean user input to the doi_suffix_template setting.

public static validate_doi_suffix_template(string $field, string $input) : string
Parameters
$field : string

The field this was input to.

$input : string

User input.

Tags
since
0.4.0
access

private

Return values
string —

Validated doi suffix.

volume_endpoint_template()

Force the usage of the page template on the volume overview page

public volume_endpoint_template(string $template) : string

Checks for the presence of a query var ending in '_add_fake_post' to determine when to change the template.

To be added to the 'template_include' action.

Parameters
$template : string

The template that would be used.

Tags
since
0.3.0
access

public

Return values
string —

Template that should be used.

volume_navigation_at_loop_start()

Add navigation before the loop to the pages of the volume endpoint.

public volume_navigation_at_loop_start(WP_Query $wp_query) : mixed

To be added to 'loop_start'.

Parameters
$wp_query : WP_Query

The current Wordpress query.

Tags
since
0.3.0
access

public


        
On this page

Search results