Documentation
Documentation
Graphic_Data_Transfer_Validator
in package
Class Graphic_Data_Transfer_Validator.
Tags
Table of Contents
Constants
- MAX_ENTRIES : mixed = 6
- Most entries a numbered set of fields (links, tabs, sections) can have.
Properties
- $errors : array<string|int, string>
- Problems that the edit screen would refuse to save.
- $find_file : callable
- Finds the file behind an address: receives the address and returns its path ('' if there is none) and, for a resized image, its width and height (otherwise 0).
- $form : Graphic_Data_Validation
- Edit screen validation, for its address checks.
- $meta : array<string|int, mixed>
- Fields of the post being checked.
- $read_linked : callable
- Reads a field of a linked post: receives the link's value, the linked post type and a meta key, and returns the value, or null if the linked post is not known.
- $urls : array<string, string>
- Valid web addresses found: label => address.
- $warnings : array<string|int, string>
- Problems that the edit screen only warns about.
Methods
- __construct() : mixed
- Constructor.
- check_urls() : array{next: int, failed: string[]}
- Check whether web addresses can be reached, until time runs out.
- reject_unsafe_urls() : array<string|int, mixed>
- Also refuse redirects to unsafe addresses. Filter callback for `http_request_args`.
-
validate()
: array{errors: string[], warnings: string[], urls: array
} - Check a post.
- check_about() : void
- Check the About content.
- check_figure() : void
- Check a Figure.
- check_instance() : void
- Check an Instance.
- check_links() : void
- Check a Scene's or Modal's info and photo links.
- check_modal() : void
- Check a Modal.
- check_parent() : void
- Warn if a linked post's own parent is not this post's: for example, a Modal whose Scene is in another Instance.
- check_scene() : void
- Check a Scene.
- check_tile() : void
- Check an Instance's tile image.
- check_url() : void
- Check a web address, and note it for check_urls().
- entries() : int
- A number of entries, limited to the most there can be.
- length() : int
- Number of characters in a text.
- linked() : string|null
- Read a field of a post that this one links to.
- value() : string
- A field's value, or an item of a fieldset.
Constants
MAX_ENTRIES
Most entries a numbered set of fields (links, tabs, sections) can have.
public
mixed
MAX_ENTRIES
= 6
Properties
$errors
Problems that the edit screen would refuse to save.
private
array<string|int, string>
$errors
= array()
$find_file
Finds the file behind an address: receives the address and returns its path ('' if there is none) and, for a resized image, its width and height (otherwise 0).
private
callable
$find_file
$form
Edit screen validation, for its address checks.
private
Graphic_Data_Validation
$form
$meta
Fields of the post being checked.
private
array<string|int, mixed>
$meta
= array()
$read_linked
Reads a field of a linked post: receives the link's value, the linked post type and a meta key, and returns the value, or null if the linked post is not known.
private
callable
$read_linked
$urls
Valid web addresses found: label => address.
private
array<string, string>
$urls
= array()
$warnings
Problems that the edit screen only warns about.
private
array<string|int, string>
$warnings
= array()
Methods
__construct()
Constructor.
public
__construct(callable $find_file, callable $read_linked) : mixed
Parameters
- $find_file : callable
-
See $find_file.
- $read_linked : callable
-
See $read_linked.
check_urls()
Check whether web addresses can be reached, until time runs out.
public
static check_urls(array<string|int, string> $urls, int $offset, int $budget) : array{next: int, failed: string[]}
Parameters
- $urls : array<string|int, string>
-
Addresses.
- $offset : int
-
First one to check.
- $budget : int
-
Seconds to spend.
Return values
array{next: int, failed: string[]} —Where to continue, and the addresses that could not be reached.
reject_unsafe_urls()
Also refuse redirects to unsafe addresses. Filter callback for `http_request_args`.
public
static reject_unsafe_urls(array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed>
-
Request arguments.
Return values
array<string|int, mixed>validate()
Check a post.
public
validate(string $type, string $title, array<string|int, mixed> $meta) : array{errors: string[], warnings: string[], urls: array}
Parameters
- $type : string
-
Post type.
- $title : string
-
Title.
- $meta : array<string|int, mixed>
-
Fields, as they will be after the import.
Return values
array{errors: string[], warnings: string[], urls: arraycheck_about()
Check the About content.
private
check_about() : void
check_figure()
Check a Figure.
private
check_figure() : void
check_instance()
Check an Instance.
private
check_instance() : void
check_links()
Check a Scene's or Modal's info and photo links.
private
check_links(string $type) : void
Parameters
- $type : string
-
'scene' or 'modal'.
check_modal()
Check a Modal.
private
check_modal(string $title) : void
Parameters
- $title : string
-
Title.
check_parent()
Warn if a linked post's own parent is not this post's: for example, a Modal whose Scene is in another Instance.
private
check_parent(string $key, string $type, string $parent_field, string $own_field, string $message) : void
Parameters
- $key : string
-
Meta key holding the link.
- $type : string
-
Post type linked to.
- $parent_field : string
-
Field of the linked post holding its parent.
- $own_field : string
-
Field of this post holding that parent.
- $message : string
-
Warning.
check_scene()
Check a Scene.
private
check_scene() : void
check_tile()
Check an Instance's tile image.
private
check_tile(string $url) : void
Parameters
- $url : string
-
Image address.
check_url()
Check a web address, and note it for check_urls().
private
check_url(string $url, string $label) : void
Parameters
- $url : string
-
Address.
- $label : string
-
Field, for messages.
entries()
A number of entries, limited to the most there can be.
private
entries(string $key[, int $max = self::MAX_ENTRIES ]) : int
Parameters
- $key : string
-
Meta key.
- $max : int = self::MAX_ENTRIES
-
Limit.
Return values
intlength()
Number of characters in a text.
private
static length(string $text) : int
Parameters
- $text : string
-
Text.
Return values
intlinked()
Read a field of a post that this one links to.
private
linked(string $key, string $type, string $field) : string|null
Parameters
- $key : string
-
Meta key holding the link.
- $type : string
-
Post type linked to.
- $field : string
-
Field of the linked post.
Return values
string|null —Null if the linked post is not known.
value()
A field's value, or an item of a fieldset.
private
value(string $key[, string $sub = '' ]) : string
Parameters
- $key : string
-
Meta key.
- $sub : string = ''
-
Item of the fieldset, if it is one.