Documentation

CRM_Afform_ArrayHtml
in package

Class CRM_Afform_ArrayHtml

FIXME This a quick-and-dirty array<=>html mapping. FIXME: Comment mapping.

Table of Contents

Constants

DEFAULT_TAG  = 'div'

Properties

$deepCoding  : bool
$formatWhitespace  : bool
$indent  : mixed
$protoSchema  : array<string|int, mixed>
This is a minimalist/temporary placeholder for a schema definition.

Methods

__construct()  : mixed
CRM_Afform_ArrayHtml constructor.
convertArraysToHtml()  : string
Converts a subset of items into html markup
convertArrayToHtml()  : string
convertHtmlToArray()  : array<string|int, mixed>
convertNodeToArray()  : array<string|int, mixed>|string
convertTreeToHtml()  : string
Converts a full array of items into html markup
isNodeEditable()  : bool
Determine if a node is recognized by the gui editor.
replaceUnicodeChars()  : string
Convert non-breaking space character to html notation.
convertNodesToArray()  : array<string|int, mixed>
decodeAttrValue()  : mixed
Given a string representation of an attribute value, determine the equivalent array (deep) representation.
encodeAttrValue()  : string
Given an array (deep) representation of an attribute, determine the attribute's content.
isSelfClosing()  : bool
pickAttrType()  : string
Determine the type of data that is stored in an attribute.

Constants

DEFAULT_TAG

public mixed DEFAULT_TAG = 'div'

Properties

$formatWhitespace

protected bool $formatWhitespace

$protoSchema

This is a minimalist/temporary placeholder for a schema definition.

private array<string|int, mixed> $protoSchema = ['*' => ['*' => 'text', 'af-fieldset' => 'text', 'data' => 'js'], 'af-entity' => ['#selfClose' => \TRUE, 'name' => 'text', 'type' => 'text', 'security' => 'text', 'actions' => 'js'], 'af-field' => ['#selfClose' => \TRUE, 'name' => 'text', 'defn' => 'js'], 'area' => ['#selfClose' => \TRUE], 'base' => ['#selfClose' => \TRUE], 'br' => ['#selfClose' => \TRUE], 'col' => ['#selfClose' => \TRUE], 'command' => ['#selfClose' => \TRUE], 'embed' => ['#selfClose' => \TRUE], 'hr' => ['#selfClose' => \TRUE], 'iframe' => ['#selfClose' => \TRUE], 'img' => ['#selfClose' => \TRUE], 'input' => ['#selfClose' => \TRUE], 'keygen' => ['#selfClose' => \TRUE], 'link' => ['#selfClose' => \TRUE], 'meta' => ['#selfClose' => \TRUE], 'param' => ['#selfClose' => \TRUE], 'source' => ['#selfClose' => \TRUE], 'track' => ['#selfClose' => \TRUE], 'wbr' => ['#selfClose' => \TRUE]]

FIXME: It shouldn't be here or look like this.

Ex: $protoSchema['my-tag']['my-attr'] = 'text';

Methods

__construct()

CRM_Afform_ArrayHtml constructor.

public __construct([bool $deepCoding = TRUE ][, bool $formatWhitespace = FALSE ]) : mixed
Parameters
$deepCoding : bool = TRUE
$formatWhitespace : bool = FALSE

convertArraysToHtml()

Converts a subset of items into html markup

public convertArraysToHtml(array<string|int, mixed> $children) : string
Parameters
$children : array<string|int, mixed>
Return values
string

html

convertArrayToHtml()

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

Ex: ['#tag' => 'div', 'class' => 'greeting', '#children' => ['Hello world']]

Return values
string

Ex: '

Hello world
'

convertHtmlToArray()

public convertHtmlToArray(string $html) : array<string|int, mixed>
Parameters
$html : string

Ex: '

Hello world
'

Return values
array<string|int, mixed>

Ex: ['#tag' => 'div', 'class' => 'greeting', '#children' => ['Hello world']]

convertNodeToArray()

public convertNodeToArray(DOMNode $node) : array<string|int, mixed>|string
Parameters
$node : DOMNode
Return values
array<string|int, mixed>|string

convertTreeToHtml()

Converts a full array of items into html markup

public convertTreeToHtml(array<string|int, mixed> $tree) : string
Parameters
$tree : array<string|int, mixed>
Return values
string

html

isNodeEditable()

Determine if a node is recognized by the gui editor.

public isNodeEditable(array<string|int, mixed> $item) : bool
Parameters
$item : array<string|int, mixed>
Return values
bool

replaceUnicodeChars()

Convert non-breaking space character to html notation.

public replaceUnicodeChars(string $markup) : string

Makes html files easier to read.

Note: This function does NOT convert all html entities (< to <, etc.) as the input string is assumed to already be valid markup.

Parameters
$markup : string
  • some html
Return values
string

convertNodesToArray()

protected convertNodesToArray(array<string|int, mixed>|DOMNodeList $nodes) : array<string|int, mixed>
Parameters
$nodes : array<string|int, mixed>|DOMNodeList

List of DOMNodes

Return values
array<string|int, mixed>

decodeAttrValue()

Given a string representation of an attribute value, determine the equivalent array (deep) representation.

protected decodeAttrValue(string $type, string $txtAttrValue) : mixed
Parameters
$type : string

Ex A: 'text' Ex B: 'js'

$txtAttrValue : string

The textual representation of the value from HTML notation. Ex A: 'hello' Ex B: '{hello: 123}'

Return values
mixed

The mixed (string/array/int) rerepresentation of the value in deep format Ex A: 'hello' Ex B: ['hello' => 123]

encodeAttrValue()

Given an array (deep) representation of an attribute, determine the attribute's content.

protected encodeAttrValue(string $type, mixed $mixedAttrValue) : string
Parameters
$type : string

Ex A: 'text' Ex B: 'js'

$mixedAttrValue : mixed

The mixed (string/array/int) representation of the value in deep format Ex A: 'hello' Ex B: ['hello' => 123]

Return values
string

An equivalent HTML attribute content (text). Ex A: 'hello' Ex B: '{hello: 123}'

isSelfClosing()

protected isSelfClosing(string $tag) : bool
Parameters
$tag : string

Ex: 'img', 'div'

Return values
bool

TRUE if the tag should look like ''. FALSE if the tag should look like '

'.

pickAttrType()

Determine the type of data that is stored in an attribute.

protected pickAttrType(string $tag, string $attrName) : string
Parameters
$tag : string

Ex: 'af-entity'

$attrName : string

Ex: 'label'

Return values
string

Ex: 'text' or 'js'


        
On this page

Search results