Documentation

BrandGuidelines

Table of Contents

Functions

acl_can_view_brand_guidelines()  : bool
Helper function for access control purposes to check if user can view the Brand Guidelines
acl_can_edit_brand_guidelines()  : bool
Helper function for access control purposes to check if user can edit the Brand Guidelines
is_section()  : bool
Check if a page item is a section
filter_only_pages()  : bool
Check if a page item is just a page (i.e. NOT a section)
cast_reorder_direction_to_int()  : -1|1
Helper function to cast a re-order direction to an integer.
compute_item_order()  : T
Compute moving (for re-ordering purposes) an item based on the requested direction (up/down). Example:
reorder_input_validator()  : bool
Input validation for the re-order capability
richtext_input_parser()  : string
Rich text editor input parser (removes invalid HTML tags/attributes)
colour_hex_input_validator()  : bool
Input validation for HEX colour syntax, including short form notations (e.g. 03A === 0033AA)
colour_rgb_input_validator()  : bool
Input validation for RGB colour syntax (e.g. 0,0,0)
colour_cmyk_input_validator()  : bool
Input validation for CMYK colour syntax (e.g. 0,0,0,100)
create_page_content()  : bool
Create a new page content item (use case).
save_page_content()  : mixed
Save a page content item change (use case).
reorder_page_content()  : bool
Re-order page content. Use cases: - move up/down items (no group logic); - move up/down items over an entire group; - move up/down a group over another group; - move up/down an entire group of items (including over another group); - move left/right within the group boundaries; - move up/down outside group boundaries to take an item out of a group;
convert_to_db_content()  : array<string|int, mixed>
Data transfer utility to help translate custom fields' data structures to a minimum required data structure that we can store in the database.
convert_from_db_content()  : array<string|int, mixed>
Data transfer utility to help reconstruct custom fields' data structure
group_content_items()  : array<string|int, mixed>
Helper function to group similar sequential page (colour & resource) content items for rendering purposes. A group is made of at least one item (to allow users to add to it). Full width resources do not get grouped.
is_group_member()  : callable
Helper filter function to determine if a page content item is part of group
reorder_items_in_memory()  : T
Re-order table records in memory in ascending order based on their order_by
decode_page_content_item()  : array<string|int, mixed>
Page content item (JSON) decoder
is_brand_guidelines_callback()  : bool
Helper validator to check if a callback URL is for Brand Guidelines
get_all_pages()  : array<string|int, mixed>
Get all Brand Guidelines pages
get_page_contents()  : array<string|int, mixed>
Get a Brand Guidelines page (entire) content
get_page_content_item()  : array<string|int, mixed>
Get a specific page content item
create_page()  : int
Create new Brand Guidelines page/section.
save_page()  : void
Edit Brand Guidelines page/section.
delete_pages()  : bool
Delete Brand Guidelines pages
reorder_items()  : void
Re-order databse records (where order_by exists)
create_content_item()  : int
Create new database record for a content item
save_content_item()  : bool
Save a content item database record
delete_page_content()  : bool
Delete a Brand Guideline page content
render_individual_menu()  : void
render_content_menu()  : void
render_new_content_button()  : void
Render the new content button
render_new_block_element_button()  : void
Render the button for new content item within a group.
render_block_colour_item()  : void
Render a colour page content item. Example: ```php render_block_colour_item([ 'ref' => 9, 'name' => 'Black', 'hex' => '000000', 'rgb' => '0, 0, 0', 'cmyk' => '0, 0, 0, 100', ]); ```
render_navigation_item()  : void
Render the table of contents (TOC) items.
render_item_top_right_menu()  : void
Render the contextual right menu.
render_resource_item()  : void
Render resource content item.
render_video_player()  : string
Render video player for resource content items

Functions

acl_can_view_brand_guidelines()

Helper function for access control purposes to check if user can view the Brand Guidelines

acl_can_view_brand_guidelines() : bool
Return values
bool

acl_can_edit_brand_guidelines()

Helper function for access control purposes to check if user can edit the Brand Guidelines

acl_can_edit_brand_guidelines() : bool
Return values
bool

is_section()

Check if a page item is a section

is_section(array{parent: int|numeric-string} $I) : bool
Parameters
$I : array{parent: int|numeric-string}

Generic page data structure

Return values
bool

filter_only_pages()

Check if a page item is just a page (i.e. NOT a section)

filter_only_pages(array{parent: int|numeric-string} $I) : bool
Parameters
$I : array{parent: int|numeric-string}

Generic page data structure

Return values
bool

cast_reorder_direction_to_int()

Helper function to cast a re-order direction to an integer.

cast_reorder_direction_to_int(string $direction) : -1|1
Parameters
$direction : string
Return values
-1|1

compute_item_order()

Compute moving (for re-ordering purposes) an item based on the requested direction (up/down). Example:

compute_item_order(T $item, string $direction[, int $jump_over = 1 ]) : T
$changed_list = array_replace(
    $all_pages_index,
    [$ref => compute_item_order($all_pages_index[$ref], $reorder)]
);
Parameters
$item : T

Generic item record with at least the 'order_by' key

$direction : string

The direction of the re-order - up/down

$jump_over : int = 1

Specify how many elements to jump over

Tags
phpstan-template

T of array

Return values
T

reorder_input_validator()

Input validation for the re-order capability

reorder_input_validator(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

richtext_input_parser()

Rich text editor input parser (removes invalid HTML tags/attributes)

richtext_input_parser(string $value) : string
Parameters
$value : string
Return values
string

colour_hex_input_validator()

Input validation for HEX colour syntax, including short form notations (e.g. 03A === 0033AA)

colour_hex_input_validator(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

colour_rgb_input_validator()

Input validation for RGB colour syntax (e.g. 0,0,0)

colour_rgb_input_validator(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

colour_cmyk_input_validator()

Input validation for CMYK colour syntax (e.g. 0,0,0,100)

colour_cmyk_input_validator(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

create_page_content()

Create a new page content item (use case).

create_page_content(int $page, BRAND_GUIDELINES_CONTENT_TYPES, fields: array, position_after: int} $item) : bool
Parameters
$page : int

Page ID

$item : BRAND_GUIDELINES_CONTENT_TYPES, fields: array, position_after: int}

An item data structure

Return values
bool

save_page_content()

Save a page content item change (use case).

save_page_content(int $ref, array<string|int, mixed> $item) : mixed
Parameters
$ref : int

Page content item ID

$item : array<string|int, mixed>

reorder_page_content()

Re-order page content. Use cases: - move up/down items (no group logic); - move up/down items over an entire group; - move up/down a group over another group; - move up/down an entire group of items (including over another group); - move left/right within the group boundaries; - move up/down outside group boundaries to take an item out of a group;

reorder_page_content(string $reorder, array<string|int, mixed> $init_page_content, array<string|int, mixed> $refs) : bool
Parameters
$reorder : string

The move direction (up/down only). Note that moving left/right <=> up/down.

$init_page_content : array<string|int, mixed>

The page content get_page_contents() with the keys being each items' ref.

$refs : array<string|int, mixed>

List of IDs to move. Multiple IDs means we move an entire group.

Return values
bool

convert_to_db_content()

Data transfer utility to help translate custom fields' data structures to a minimum required data structure that we can store in the database.

convert_to_db_content(array<string|int, mixed> $input) : array<string|int, mixed>
Parameters
$input : array<string|int, mixed>

Submitted custom fields' data structure process_custom_fields_submission()

Return values
array<string|int, mixed>

convert_from_db_content()

Data transfer utility to help reconstruct custom fields' data structure

convert_from_db_content(string $json, array<string|int, mixed> $def) : array<string|int, mixed>
Parameters
$json : string

Database record value (JSON type)

$def : array<string|int, mixed>

Custom fields' data structure as input to process_custom_fields_submission()

Return values
array<string|int, mixed>

Same custom fields' data structure with, where applicable, an extra "value" key representing the current field value

group_content_items()

Helper function to group similar sequential page (colour & resource) content items for rendering purposes. A group is made of at least one item (to allow users to add to it). Full width resources do not get grouped.

group_content_items(array<string|int, mixed> $items) : array<string|int, mixed>
Parameters
$items : array<string|int, mixed>

Page content item records

Return values
array<string|int, mixed>

Returns the item as is or makes it a group member otherwise

is_group_member()

Helper filter function to determine if a page content item is part of group

is_group_member(int $ref, array<string|int, mixed> $table) : callable
Parameters
$ref : int

Page content item ID

$table : array<string|int, mixed>

Lookup table (e.g.: array_column(get_page_contents($page), null, 'ref'))

Return values
callable

reorder_items_in_memory()

Re-order table records in memory in ascending order based on their order_by

reorder_items_in_memory(T $table) : T
Parameters
$table : T
Tags
template

T of array<postive-int, array{ref: postive-int, order_by: int}>

Return values
T

decode_page_content_item()

Page content item (JSON) decoder

decode_page_content_item(array<string|int, mixed> $item) : array<string|int, mixed>
Parameters
$item : array<string|int, mixed>

A (database record) page content item data structure BRAND_GUIDELINES_DB_COLS_CONTENT

Return values
array<string|int, mixed>

is_brand_guidelines_callback()

Helper validator to check if a callback URL is for Brand Guidelines

is_brand_guidelines_callback(mixed $url) : bool
Parameters
$url : mixed
Return values
bool

get_all_pages()

Get all Brand Guidelines pages

get_all_pages() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_page_contents()

Get a Brand Guidelines page (entire) content

get_page_contents(int $id) : array<string|int, mixed>
Parameters
$id : int
Return values
array<string|int, mixed>

get_page_content_item()

Get a specific page content item

get_page_content_item(int $id) : array<string|int, mixed>
Parameters
$id : int
Return values
array<string|int, mixed>

create_page()

Create new Brand Guidelines page/section.

create_page(string $name, int $parent) : int
Parameters
$name : string

Page/Section name

$parent : int

The sections' ID a page belongs to. Use zero for sections (i.e. root pages)

Return values
int

save_page()

Edit Brand Guidelines page/section.

save_page(int $ref, string $name, int $parent) : void
Parameters
$ref : int

Page ID

$name : string

Page name

$parent : int

The sections' ID a page belongs to. Use zero for sections (i.e. root pages)

delete_pages()

Delete Brand Guidelines pages

delete_pages(array<int, int> $refs) : bool
Parameters
$refs : array<int, int>

List of page IDs

Return values
bool

True if it executed the query, false otherwise

reorder_items()

Re-order databse records (where order_by exists)

reorder_items(string $table, array<string|int, mixed> $list, null|callable $filter) : void
Parameters
$table : string

Database table (where the operation takes place)

$list : array<string|int, mixed>
$filter : null|callable

Optional filter, if the $list has unnecessary elements

create_content_item()

Create new database record for a content item

create_content_item(int $page, BRAND_GUIDELINES_CONTENT_TYPES, fields: array, position_after: int} $item) : int
Parameters
$page : int

The page ID the content item belongs to

$item : BRAND_GUIDELINES_CONTENT_TYPES, fields: array, position_after: int}

A content item data structure

Return values
int

Returns the ID of the new database record or zero otherwise.

save_content_item()

Save a content item database record

save_content_item(int $ref, array<string|int, mixed> $item) : bool
Parameters
$ref : int

The content item ID

$item : array<string|int, mixed>
Return values
bool

delete_page_content()

Delete a Brand Guideline page content

delete_page_content(array<int, int> $refs) : bool
Parameters
$refs : array<int, int>

List of page content IDs

Return values
bool

True if it executed the query, false otherwise

render_new_content_button()

Render the new content button

render_new_content_button(string $id, array{class: list$ctx) : void
Parameters
$id : string

The HTML id of the button

$ctx : array{class: list}

render_new_block_element_button()

Render the button for new content item within a group.

render_new_block_element_button(string $class, BRAND_GUIDELINES_CONTENT_TYPES> $type) : void
Parameters
$class : string

CSS class to use

$type : BRAND_GUIDELINES_CONTENT_TYPES>

Content item type to create

render_block_colour_item()

Render a colour page content item. Example: ```php render_block_colour_item([ 'ref' => 9, 'name' => 'Black', 'hex' => '000000', 'rgb' => '0, 0, 0', 'cmyk' => '0, 0, 0, 100', ]); ```

render_block_colour_item(array{ref: int, name: string, hex: string, rgb: string, cmyk: string} $value, array{top_right_menu_class: list$ctx) : void
Parameters
$value : array{ref: int, name: string, hex: string, rgb: string, cmyk: string}

Colour value to render

$ctx : array{top_right_menu_class: list}

render_navigation_item()

Render the table of contents (TOC) items.

render_navigation_item(array<string|int, mixed> $item[, bool $is_current = false ][, array{class: list, top_right_menu_class: list$ctx = [] ]) : void
Parameters
$item : array<string|int, mixed>

A section/page record get_all_pages()

$is_current : bool = false

Specify if the input item is the currently selected page

$ctx : array{class: list, top_right_menu_class: list} = []

render_item_top_right_menu()

Render the contextual right menu.

render_item_top_right_menu(int $ref[, array<int, string> $class = [] ]) : void
Parameters
$ref : int

Items' ID. Note: item is generic here, it refers to both section/page as well as page content items.

$class : array<int, string> = []

List of HTML classes to add to the wrapping div.

render_resource_item()

Render resource content item.

render_resource_item(array<string|int, mixed> $item, array{top_right_menu_class: list$ctx) : void
Parameters
$item : array<string|int, mixed>

A decoded page content item. guidelines.php

$ctx : array{top_right_menu_class: list}

render_video_player()

Render video player for resource content items

render_video_player(array<string|int, mixed> $resource[, array{context: string, max_width: int, max_height: int} $ctx = [] ]) : string
Parameters
$resource : array<string|int, mixed>

Resource data get_resource_data()

$ctx : array{context: string, max_width: int, max_height: int} = []

Set optional context for the rendered video player

Return values
string

Either nothing or the video player HTML to render

On this page

Search results