\O3PO_Ready2PublishForm

Class for the ready to publish form.

Summary

Methods
Properties
Constants
__construct()
read_and_validate_field_values()
handle_form_data_and_produce_content()
submitted_message()
render_navigation()
init()
do_parse_request()
get_field_value()
sanitize_user_input()
generate_session_id()
validate_session_id()
render_image_upload_field()
validate_array_of_at_most_1000_names()
validate_array_of_at_most_1000_name_styles()
render_summary()
checked_if_on_or_past_containing_page_unless_back_or_upload()
on_submit()
specify_page()
specify_section()
specify_field()
render_single_line_field()
render_multi_line_field()
render_password_field()
render_checkbox_field()
render_select_field()
render_array_as_comma_separated_list_field()
get_field_default()
get_field_defaults()
get_field_title()
specify_fake_field()
validate_doi_prefix()
validate_doi_suffix()
validate_four_digit_year()
validate_eprint()
validate_issn_or_empty()
validate_issn()
validate_email()
validate_url()
validate_array_as_comma_separated_list()
validate_two_letter_country_code()
validate_positive_integer()
validate_non_negative_euros()
checked_or_unchecked()
checked()
trim()
trim_strip_tags()
leave_unchanged()
specify_settings()
render_eprint_field()
render_agree_to_publish()
render_acceptance_code()
render_popular_summary()
render_featured_image_caption()
render_fermats_library()
render_copyright_confirmation()
render_featured_image_upload()
validate_featured_image_upload()
validate_acceptance_code()
validate_eprint_fetch_meta_data_check_license_and_store_in_session()
render_title()
render_abstract()
render_author_data()
render_funder_information()
render_payment_amount()
render_ready2publish_settings()
render_acceptance_codes_setting()
render_corresponding_author_email()
render_basic_manuscript_data_section()
render_manuscript_data_section()
render_dissemination_material_section()
render_invoice_recipient()
render_invoice_address()
render_invoice_vat_number()
render_comments()
render_dissemination_multimedia()
render_payment_method()
render_funder_information_summary()
render_author_data_summary()
one_of_invoice_noinvoice_waiver()
non_empty_if_payment_method_is_invoice_and_on_or_past_containing_page()
No public properties found
No constants found
specify_pages_sections_and_fields()
add_error()
put_session_data()
get_session_data()
append_session_data()
add_sideloaded_files_to_media_library()
$coming_from_page
$plugin_name
$slug
$pages
$sections
$fields
N/A
make_post()
setup_query()
discard_session()
renew_session_id()
get_session_ids()
get_class_option()
update_class_option()
delete_sideloaded_files()
$errors
$field_values
$title
$page_to_display
$navigation
$submitted_successfully
$environment
$storage
N/A

Properties

$coming_from_page

$coming_from_page : integer

The page id of the page the user is coming from

Type

integer — Page id.

$plugin_name

$plugin_name : string

The unique identifier of this plugin.

Type

string — The string used to uniquely identify this plugin.

$slug

$slug : string

Slug of this form.

Used for css classes when rendering the sections and fields. Used then storing/retreiving data from the database.

Type

string — Slug of the form.

$pages

$pages : array

Array of all pages of the form.

Type

array — Dictionary of all pages and their properties.

$sections

$sections : array

Array of all sections of the form.

Type

array — Dictionary of all sections and their properties.

$fields

$fields : array

Array of all field of the form.

Type

array — Dictionary of all fields and their properties.

$errors

$errors : array

Errors identified in the form

Type

array — Array of errors.

$field_values

$field_values : array

Field values of the form.

Type

array — Array of field values.

$title

$title : string

Title

Type

string — Title of the form.

$page_to_display

$page_to_display : integer

Page to display

Type

integer — Id of page to display.

$navigation

$navigation : string

Value of the navigation

Type

string — One of 'Next', 'Back', 'Submit', or 'Upload'

$submitted_successfully

$submitted_successfully : boolean

Whether the form was submitted successfully

Type

boolean — Whether the form was submitted successfully.

$environment

$environment : \O3PO_Environment

Environment

Type

\O3PO_Environment — Environment in which this form operates.

$storage

$storage : array

Storage used by this form.

Type

array — Storage of the form.

Methods

__construct()

__construct(string  $plugin_name, string  $slug, \O3PO_Environment  $environment, \O3PO_Ready2PublishStorage  $storage) 

Construct this form

Parameters

string $plugin_name

Name of the plugin

string $slug

Slug of this form

\O3PO_Environment $environment

Environment in which the form operates

\O3PO_Ready2PublishStorage $storage

Storage used by the form

read_and_validate_field_values()

read_and_validate_field_values() 

Read all form values from $_POST and process.

handle_form_data_and_produce_content()

handle_form_data_and_produce_content() 

Handle the form data and render the form

submitted_message()

submitted_message(boolean  $submitted_successfully) : string

Render the final message after form submission

Parameters

boolean $submitted_successfully

Whether the form submission was successful.

Returns

string —

The message

render_navigation()

render_navigation(integer  $previous_page_id, integer  $page_id, integer  $next_page_id) 

Render the form navigation

Parameters

integer $previous_page_id

Id of the previous page

integer $page_id

Id of this page

integer $next_page_id

Id of the next page

init()

init() 

Adds a rewrite endpoint for the form.

To be added to the 'init' action.

do_parse_request()

do_parse_request(boolean  $bool, \WP  $wp, boolean  $do_not_exit = False) 

Parse form requests

Processes form input and displays the form.

Parameters

boolean $bool

Whether or not to parse the request.

\WP $wp

Current WordPress environment instance.

boolean $do_not_exit

Whether to exit after parsing the request. Can be set to false for testing only.

get_field_value()

get_field_value(integer  $id) 

Get the value of a field by id.

Parameters

integer $id

Id of the field.

sanitize_user_input()

sanitize_user_input(string  $input) : string

Sanitize user input

Parameters

string $input

The input to sanitize.

Returns

string —

Sanitized input

generate_session_id()

generate_session_id() : string

Generate a unique session id

Returns

string —

Random hex string

validate_session_id()

validate_session_id(integer  $id) : mixed

Check whether an id is a valid session id

Parameters

integer $id

Id to validate

Returns

mixed —

Session id or False if invalid.

render_image_upload_field()

render_image_upload_field(string  $id, string  $label = '', boolean  $esc_label = true) 

Render an image upload field

Parameters

string $id

Id of the field

string $label

Label of the field. May contain html and is not escaped!

boolean $esc_label

Whether to escape the label

validate_array_of_at_most_1000_names()

validate_array_of_at_most_1000_names(string  $id, array  $input) 

Validate that an array of at most 1000 names

Parameters

string $id

The id of the field whose input is validated.

array $input

The input.

validate_array_of_at_most_1000_name_styles()

validate_array_of_at_most_1000_name_styles(string  $id, array  $input) 

Validate that an array of at most 1000 name styles

Parameters

string $id

The id of the field whose input is validated.

array $input

The input.

render_summary()

render_summary() 

Render the form summary

checked_if_on_or_past_containing_page_unless_back_or_upload()

checked_if_on_or_past_containing_page_unless_back_or_upload(string  $id, string  $input) 

Ensure that a check box field is checked

Parameters

string $id

The field this was input to.

string $input

User input.

on_submit()

on_submit(array  $attach_ids) : boolean

On submit

Executed on form submission. Stores the information in the storage and sends various emails.

Parameters

array $attach_ids

Id of attachments created during form submission.

Returns

boolean —

Whether this step of form submission was successful.

specify_page()

specify_page(string  $id, string  $title, callable  $callback = null) 

Specify a section of the form.

Keeps a record of all sections in $this->sections.

Parameters

string $id

Slug-name to identify the page.

string $title

Formatted title of the section. Shown as the heading for the section.

callable $callback

Function that echos out the any content at the top of the page (before the first section).

specify_section()

specify_section(string  $id, string  $title, callable  $callback, string  $page, callable  $summary_callback = null) 

Specify a section of the form.

Keeps a record of all sections in $this->sections.

Parameters

string $id

Slug-name to identify the section. Used in the 'id' attribute of tags.

string $title

Formatted title of the section. Shown as the heading for the section.

callable $callback

Function that echos out any content at the top of the section (between heading and fields).

string $page

The slug-name of the page on which to show the section.

callable $summary_callback

Callback to call when composing the summary of this form.

specify_field()

specify_field(string  $id, string  $title, callable  $callback, string  $page, string  $section, array  $args, callable  $validation_callable, string  $default, integer  $max_length = false) 

Specify a field of the form.

Keeps a record of all fields in $this->fields.

Parameters

string $id

Slug-name to identify the field. Used in the 'id' attribute of tags.

string $title

Formatted title of the field. Shown as the heading for the field.

callable $callback

Function that echos out any content at the top of the field (between heading and fields).

string $page

The slug-name of the page on which to show the field.

string $section

The slug-name of the section in which to show the field.

array $args

{ Extra arguments used when outputting the field. May be an empty array().

@type string $label_for When supplied, the label will be wrapped
                        in a `<label>` element, its `for` attribute populated
                        with this value.
@type string $class     CSS Class to be added to the `<tr>` element when the
                        field is output.

}

callable $validation_callable

Callable to use during validation of inputs. Must take a field ID and input as parameters and return a valid value for the field. Should call $this->add_error() to indicate problems.

string $default

Default value for the field.

integer $max_length

Maximum length of the value of the field.

render_single_line_field()

render_single_line_field(string  $id, string|null  $placeholder = null, string  $autocomplete = 'on', string  $style = false, string  $label = false, boolean  $esc_label = true, string  $label_style = false) 

Render a standard text box type field.

Parameters

string $id

Id of the field.

string|null $placeholder

Placeholder text (default is null).

string $autocomplete

Whether to auto complete 'or' (default) or 'off.

string $style

CSS style.

string $label

HTML label.

boolean $esc_label

Whether to escape the content of label.

string $label_style

CSS style for the label.

render_multi_line_field()

render_multi_line_field(string  $id, integer  $rows = false, string  $style = false, boolean  $preview = false, string  $placeholder = false) 

Render a multi line text box type field.

Parameters

string $id

Id of the field.

integer $rows

Number of rows

string $style

CSS style

boolean $preview

Whether to show a LaTeX preview below the field.

string $placeholder

Placeholder

render_password_field()

render_password_field(string  $id) 

Render a password field.

Parameters

string $id

Id of the field.

render_checkbox_field()

render_checkbox_field(string  $id, string  $label = '', boolean  $esc_label = true) 

Render a checkbox type field.

Parameters

string $id

Id of the field.

string $label

Label of the field.

boolean $esc_label

Whether to escape the content of $label, disable in case you want $label to contains htmls

render_select_field()

render_select_field(string  $id, array  $options, string  $onchange = false) 

Render a select type field.

Parameters

string $id

Id of the field.

array $options

The options between which to select

string $onchange

The HTML onchange parameter

render_array_as_comma_separated_list_field()

render_array_as_comma_separated_list_field(string  $id, string  $placeholder = null) 

Render an array as comma separated list type field.

Does not escape or otherwise handle individual fields that contain commas.

Parameters

string $id

Id of the field.

string $placeholder

Placeholder text.

get_field_default()

get_field_default(integer  $id) : string

Get the default value of a field by id.

Parameters

integer $id

Id of the field.

Returns

string —

Default value of the field

get_field_defaults()

get_field_defaults(boolean  $include_fake_fields = false) 

Get the default value of all fields.

Parameters

boolean $include_fake_fields

Whether to also include fake fields in the list.

get_field_title()

get_field_title(integer  $id) 

Get the title of a field by id.

Parameters

integer $id

Id of the field.

specify_fake_field()

specify_fake_field(string  $id, string  $default) 

Add a fake field

Fake fields cannot be modified, but have default values that can be used to avoid hard coding values.

Parameters

string $id

Slug-name to identify the section. Used in the 'id' attribute of tags.

string $default

Default value for the field.

validate_doi_prefix()

validate_doi_prefix(string  $id, string  $input) 

Clean user input to doi_prefix fields

Parameters

string $id

The field this was input to.

string $input

User input.

validate_doi_suffix()

validate_doi_suffix(string  $id, string  $input) 

Clean user input to doi_suffix fields

Parameters

string $id

The field this was input to.

string $input

User input.

validate_four_digit_year()

validate_four_digit_year(string  $id, string  $input) 

Clean user input to fields expecting a year.

Parameters

string $id

The field this was input to.

string $input

User input.

validate_eprint()

validate_eprint(string  $id, string  $input) : string

Clean user input to eprint fields

Parameters

string $id

The field this was input to.

string $input

User input.

Returns

string —

Valid issn or empty string.

validate_issn_or_empty()

validate_issn_or_empty(string  $id, string  $input) : string

Clean user input to issn fields

Parameters

string $id

The field this was input to.

string $input

User input.

Returns

string —

Valid issn or empty string.

validate_issn()

validate_issn(string  $id, string  $input) 

Clean user input to issn fields

Parameters

string $id

The field this was input to.

string $input

User input.

validate_email()

validate_email(string  $id, string  $input) 

Clean user input to email fields

Parameters

string $id

The field this was input to.

string $input

User input.

validate_url()

validate_url(string  $id, string  $input) 

Clean user input to url fields

Parameters

string $id

The field this was input to.

string $input

User input.

validate_array_as_comma_separated_list()

validate_array_as_comma_separated_list(string  $id, string  $input) 

Validate input to comma separated list fields.

Break a comma separated list into an array of fields.

Parameters

string $id

The field this was input to.

string $input

User input.

validate_two_letter_country_code()

validate_two_letter_country_code(string  $id, string  $input) 

Validate two letter country code fields

Parameters

string $id

The field this was input to.

string $input

User input.

validate_positive_integer()

validate_positive_integer(string  $id, string  $input) 

Validate positive integer fields

Parameters

string $id

The field this was input to.

string $input

User input.

validate_non_negative_euros()

validate_non_negative_euros(string  $id, string  $input) 

Validate non-negative euro fields

Parameters

string $id

The field this was input to.

string $input

User input.

checked_or_unchecked()

checked_or_unchecked(string  $id, string  $input) 

Restrict input to checked or unchecked fields

Parameters

string $id

The field this was input to.

string $input

User input.

checked()

checked(string  $id, string  $input) 

Ensure that a check box field is checked

Parameters

string $id

The field this was input to.

string $input

User input.

trim()

trim(string  $id, string  $input) 

Trim user input to field

Parameters

string $id

The field this was input to.

string $input

User input.

trim_strip_tags()

trim_strip_tags(string  $id, string  $input) 

Trim user input to field

Parameters

string $id

The field this was input to.

string $input

User input.

leave_unchanged()

leave_unchanged(string  $id, string  $input) 

Leave user input to field unchanged.

Parameters

string $id

The field this was input to.

string $input

User input.

specify_settings()

specify_settings(\O3PO_Settings  $settings) 

Specify the settings of this form

Should be overwritten by classes implementing this interface. In this function classes can specify their settings fields by calling $settings->specify_field().

Parameters

\O3PO_Settings $settings

Settings instance

render_eprint_field()

render_eprint_field() 

Render the eprint field

render_agree_to_publish()

render_agree_to_publish() 

Render the agreement ot publish checkbox

render_acceptance_code()

render_acceptance_code() 

Render the acceptance code field

render_popular_summary()

render_popular_summary() 

Render the popular summary text box

render_featured_image_caption()

render_featured_image_caption() 

Render the feature image caption text box

render_fermats_library()

render_fermats_library() 

Render the Fermat's library checkbox

render_copyright_confirmation()

render_copyright_confirmation() 

Render the check box to confirm the copyright

render_featured_image_upload()

render_featured_image_upload() 

Render the featured image upload

validate_featured_image_upload()

validate_featured_image_upload(string  $id, array  $file_of_this_id) : array

Validate the feature image upload

Parameters

string $id

Id of the image upload field

array $file_of_this_id

Array with fields such as those of a single element of the $_FILE variable

Returns

array —

Various image upload information

validate_acceptance_code()

validate_acceptance_code(string  $id, string  $input) : string

Validate the provided acceptance code

Parameters

string $id

Id of the field

string $input

The input

Returns

string —

The acceptance code if valid otherwise the field default value

validate_eprint_fetch_meta_data_check_license_and_store_in_session()

validate_eprint_fetch_meta_data_check_license_and_store_in_session(string  $id, string  $input) : string

Validate the license and fetch and store meta-data from the arXiv

Parameters

string $id

Id of the field

string $input

The input

Returns

string —

The eprint

render_title()

render_title() 

Render the title field

render_abstract()

render_abstract() 

Render the abstract field

render_author_data()

render_author_data() 

Render the author data field(s)

render_funder_information()

render_funder_information() 

Render the funder information field(s)

render_payment_amount()

render_payment_amount() 

Render the payment amount select box

render_ready2publish_settings()

render_ready2publish_settings() 

Render the lead in text of the settings of this form

render_acceptance_codes_setting()

render_acceptance_codes_setting() 

Render the setting for valid acceptance codes

render_corresponding_author_email()

render_corresponding_author_email() 

Render the corresponding author email field

render_basic_manuscript_data_section()

render_basic_manuscript_data_section() 

Render the help text of the basic manuscript data section

render_manuscript_data_section()

render_manuscript_data_section() 

Render the help text of the manuscript meta-data section

render_dissemination_material_section()

render_dissemination_material_section() 

Render the help text of the dissemination material section

render_invoice_recipient()

render_invoice_recipient() 

Render the invoice recipient field

render_invoice_address()

render_invoice_address() 

Render the invoice address field

render_invoice_vat_number()

render_invoice_vat_number() 

Render the invoice recipient vat number field

render_comments()

render_comments() 

Render the comments text box.

render_dissemination_multimedia()

render_dissemination_multimedia() 

Render the multi media text box

render_payment_method()

render_payment_method() 

Render the payment method section.

render_funder_information_summary()

render_funder_information_summary() 

Render the summary of the funder information

render_author_data_summary()

render_author_data_summary() 

Render the summary of the author data

one_of_invoice_noinvoice_waiver()

one_of_invoice_noinvoice_waiver(string  $id, string  $input) 

Validate the payment method input

Parameters

string $id

Id of the field

string $input

Input

non_empty_if_payment_method_is_invoice_and_on_or_past_containing_page()

non_empty_if_payment_method_is_invoice_and_on_or_past_containing_page(string  $id, string  $input) 

Validate that field is non empty under certain conditions

Parameters

string $id

Id of the field

string $input

Input

specify_pages_sections_and_fields()

specify_pages_sections_and_fields() 

Specifies form sections and fields.

add_error()

add_error(string  $setting, string  $code, string  $message,   $type = 'error') 

Record errors during input verification.

The O3PO_Settings class for example implements this as just a wrappter around add_settings_error().

Implementations must adhere to the following parameter specification:

Parameters

string $setting

Slug title of the setting to which this error applies.

string $code

Slug-name to identify the error. Used as part of 'id' attribute in HTML output.

string $message

The formatted message text to display to the user (will be shown inside styled

and

tags).

$type

Message type, controls HTML class. Possible values include 'error', 'success', 'warning', 'info'. Default value: 'error'

put_session_data()

put_session_data(string  $field, mixed  $value, string  $session_id = Null) 

Set field in the data of a session

Parameters

string $field

The field to set.

mixed $value

The value to set.

string $session_id

The session id for which to set the field.

get_session_data()

get_session_data(string  $field, mixed  $default = Null, string  $session_id = Null) 

Get field from the data of a session

Parameters

string $field

The field to get.

mixed $default

The default value in case the field is not set.

string $session_id

The session id for which to get the field.

append_session_data()

append_session_data(string  $field, mixed  $value) 

Append a field value pair to the current session data

Parameters

string $field

The field to set.

mixed $value

The value to set.

add_sideloaded_files_to_media_library()

add_sideloaded_files_to_media_library() 

Add the files uploaded by the user to the media library.

make_post()

make_post(string  $title, string  $content) 

Make a fake post to show the form

Parameters

string $title

Title of the post

string $content

Content of the post

setup_query()

setup_query(\WP_Post  $wp_post) 

Setup the query to show a post

Parameters

\WP_Post $wp_post

Post to show.

discard_session()

discard_session(integer  $session_id) 

Discard a session and all its data

Parameters

integer $session_id

Id to discard

renew_session_id()

renew_session_id(integer  $session_id) 

Renew a session and all its data

Parameters

integer $session_id

Id to renew

get_session_ids()

get_session_ids(integer  $dicard_older_than = 24 * 60 * 60) : array

Get all recent session ids

Parameters

integer $dicard_older_than

Discard all session ids older than this many seconds

Returns

array —

Recent session ids

get_class_option()

get_class_option() : array

Get the option element used by this class

Returns

array —

Class option

update_class_option()

update_class_option(  $class_options) 

Set the option element used by this class

Parameters

$class_options

delete_sideloaded_files()

delete_sideloaded_files(string  $session_id) 

Delete the sideloaded files of a session

Parameters

string $session_id

Session id.