HelPHP

H extends Html
in package

Tags
class

H

That's our UI componant class... It generate Html5 componants/widgets and common elements depending main config and properties given As it extends Html class, it use also its magic methods and offer an intuitive usage.

Table of Contents

Constants

_CHECKMARK_BOLD  = '✔'
_CHECKMARK_NORMAL  = '✓'
_DOWN_ARROW  = '↓'
_DOWN_DASHED_ARROW  = '⇣'
_LEFT_ARROW  = '←'
_LEFT_DASHED_ARROW  = '⇠'
_RIGHT_ARROW  = '→'
_RIGHT_ARROW_HEAD  = '➤'
_RIGHT_DASHED_ARROW  = '⇢'
_STAR_EMPTY  = '☆'
_STAR_FULL  = '★'
_UP_ARROW  = '↑'
_UP_DASHED_ARROW  = '⇡'
_X_BOLD  = '✖'
_X_NORMAL  = '✕'
A  = 'a'
AUDIO  = 'audio'
BODY  = 'body'
BR  = 'br'
BUTTON  = 'button'
CANVAS  = 'canvas'
DATALIST  = 'datalist'
DETAILS  = 'details'
DIV  = 'div'
FIELDSET  = 'fieldset'
FORM  = 'form'
HEAD  = 'head'
HR  = 'hr'
HTML  = 'html'
IMAGE  = 'IMAGE'
IMG  = 'img'
INPUT  = 'input'
LABEL  = 'label'
LEGEND  = 'legend'
LI  = 'li'
LINK  = 'link'
META  = 'meta'
OPTGROUP  = 'optgroup'
OPTION  = 'option'
PARAM  = 'param'
QUICK_EDIT_DATA  = 'qe_d'
QUICK_EDIT_FIELD  = 'qe_f'
QUICK_EDIT_ID  = 'qe_i'
QUICK_EDIT_TYPE  = 'qe_t'
QUICK_EDIT_TYPE_INDEX  = 'qe_ti'
SCRIPT  = 'script'
SELECT  = 'select'
simple_tags  = [\helPHP\libs\Html::IMG, \helPHP\libs\Html::IMAGE, \helPHP\libs\Html::BR, \helPHP\libs\Html::HR, \helPHP\libs\Html::INPUT, \helPHP\libs\Html::LINK, \helPHP\libs\Html::META, \helPHP\libs\Html::PARAM, \helPHP\libs\Html::USE]
SOURCE  = 'source'
SPAN  = 'span'
STYLE  = 'style'
SUMMARY  = 'summary'
SVG  = 'svg'
svg_sprite  = \Config::SVG_SPRITE_ICONS_FILE
used by H::icons, it define the main svg sheet used.
TABLE  = 'table'
TBODY  = 'tbody'
TD  = 'td'
TEXTAREA  = 'textarea'
TFOOT  = 'tfoot'
TH  = 'th'
THEAD  = 'thead'
TITLE  = 'title'
TR  = 'tr'
UL  = 'ul'
USE  = 'use'
VIDEO  = 'video'

Properties

$_debug  : mixed
$children  : mixed
$current_value  : mixed
$current_value_label  : mixed
$debug  : mixed
$extra  : mixed
$items_after  : mixed
$label  : mixed
$label_for  : mixed

Methods

__callStatic()  : object
Magic method to handle the call to a static function that does not exist and will create corresponding html/object element
__construct()  : mixed
Constructor for the H class.
__get()  : mixed
will execute its parent from Html class
__set()  : mixed
will execute its parent from Html class
__toString()  : string
Magic method called when a string operation is done with the current object.
__unset()  : mixed
will execute its parent from Html class
_input_translation()  : array<string|int, mixed>|object
this is the base function for input_short_translation and input_long_translation that can be found in HelPHP_module.php. themselves are used in translate_block.
add_after()  : int|bool
Adds an item or a list of items to be rendered after the current HTML element.
add_child()  : int|bool
Adds a child element or a list of child elements to the current HTML element.
add_class()  : void
Adds a CSS class to the HTML element's class attribute.
add_debug()  : mixed
advanced_data_grid()  : Objet
As its name indicate it, it do more than the simple grid, there is an additionnal $value_filter used to replace the value to display by textual values.
after_html()  : string
Generates the HTML for items that should be rendered after the current element.
ajax_call()  : Html
Description for ajax_call This function generates a script that will execute an AJAX call to the specified URL with the provided data.
button_icon()  : object
display a button with and icon inside
button_icon_with_text()  : object
same as button_icon() but with a text label that can be place on the left or right side of the button
button_info()  : Objet
Create a informative button
close_document()  : object
Its name says all !
close_html()  : string
Generates the closing HTML tag for the current element.
close_tag()  : string
Create a closing tag
content_html()  : string
Generates the HTML content of the element's children.
copy_attributes_to()  : void
Copies attributes, data, and extra properties from the current HTML element to another.
create_instance()  : object
$H is a global used everywhere in HelPHP to call this class methods and create_instance will create it.
css_loader()  : object
Create a link tag to load a css after the first load of document is done, then move it to document head.
debug_structure()  : Html
exepose the current object structure as an object tree.
del_attribute()  : void
Delete an HTML attribute for the element.
detail()  : mixed
create HTML detail element for accordion effect.
fieldset()  : Fieldset
Creates a fieldset object/HTML element with the given legend.
find_child()  : Html|null
Recursively searches for a child element within the current HTML element's children.
form()  : mixed
The Form ! One of the more important tag ! In this class the form created come with multiple automatic features : Fields validation (depending each input) the choice of the div targeted to display the result after a submit (dom_target attributes) or its immediate parent (dom_target='.parent') some custom javascript function to call on submit etc.
full_html()  : string
Generates the complete HTML for the current object/element, including its opening tag, content, and closing tag.
get_children()  : array<string|int, mixed>
All is in the name
get_items_after()  : array<string|int, mixed>
Retrieves the items that should be rendered after the current HTML element.
get_unique_id()  : string
create the unique_id for html tag
group()  : object
group of html object.
icon()  : object
Generates an icon SVG element based on the provided name and attributes.
image()  : object
Generate an image object/HTML tag based on provided attributes.
input_autocomplete()  : object
The input autocomplete, will search in DB depending the typing or the user to propose a list of available value containing the string.
input_checkbox()  : object
The classic checkbox set $attributes['checked'] to check it.
input_colorpicker()  : Objet
Create a colorpicker with the external js alwan colorpicker.
input_confirmation()  : object
The input confirmation is a classic field used in general to confirm the content of a previous one, like a password or email you need to confirm.
input_date()  : object
A date selector! Perfect for booking... You can set a minimal and maximal value for an accepted value in a range.
input_datetime()  : object
A datetime selector! Note that some navigator still got some issue with this kind of input, and sometimes it's better to use an input_date and a separated input_time to cover all needs and possible issue.
input_email()  : object
Generates an HTML input field for the email type of data.
input_field()  : object
Generates an input field of the specified type.
input_file()  : object
The input file can support multiple upload.
input_float()  : object
You liked the input integer ? here is the same for float... With min max limit for accepted range as well.
input_hidden()  : object
The hidden input ! you don't see it, but still the best solution to keep some temporary values between two post!
input_integer()  : object
Another input field dedicated to integers.
input_login()  : object
Generates an HTML input field for the login type of data.
input_multiple_radios()  : mixed
create multiple radio
input_order()  : mixed
the purpose of the input order is to permet to ordonnate a list by a numeric value, and to manipulate it thru drag & drop or manual edition in case you want to manipulate lines of data, you can enclose each line with a DIV with the attribute 'data-order_parent'=>'sort_order['.$post['key'].']' sort order will be the name of the input_order.
input_password()  : object
Generates an HTML input field for the password type of data.
input_precomplete()  : object
the input_precomplete is different from input_autocomplete, as it do not ask for data in db at each new char, because it already got the db table inside ansdrequested only one time.
input_radio()  : object
The classic radio set $attributes['checked'] to indicate which one is checked.
input_range()  : object
The input range take care of all possibilities of the html5 range tag.
input_submit_attributes()  : array<string|int, mixed>
Used to add some submit attributes to other input like select
input_text()  : object
A simple input text
input_textarea()  : object
A textarea ! But not so simple, because if $attributes['tinymce'] is set, the textarea will be transformed in a tinyMCE instance.
input_time()  : object
A time selector!
is_simple()  : bool
check if the tag is a simple one like <br> with no closing tag
label_tag()  : Html
Create an Html::Label tag from $label and $attributes or from $this->label and $this->attributes of the current object.
load_js()  : Objects
Load_js is used by new_document() only in dev mode.
multi_state_button()  : object
The fantastic multistate button ! with tooglable menu ! Will create a div containing a list of buttons with only one active and visible.
new_document()  : object
Major method that will create all the head elements of a new html output.
open_html_tag()  : string
Generates the opening HTML tag for the current element.
open_tag()  : string
Create an opening tag with its attributes
output()  : string
Will return the current HTML content as string.
parse_event()  : mixed
Retrieve event that need to pass by event.js it automaticaly removed onclick or onchange and over attributes related to events, to pass them thru the event.js class.
preview_button()  : mixed
button preview for admin to call preview module.
quick_edit()  : object
Create a "quick edit" item.
quick_edit_generate_input()  : Objet
Quick edit input generated depending the preparation done with quick_edit().
reset_key()  : mixed
Reset key_name
script()  : object
Create script tag with some special features... if an "autoremove" attribute is specified the script tag will be automatically removed from the html page after 50 milliseconds (default value) or a specified delay in milliseconds.
script_loader()  : object
Create a script tag to load a script after the first load of document is done.
select()  : object
To get an input select.
set_attribute()  : void
Sets an HTML attribute for the element.
set_extra()  : void
Sets an extra property for the element.
simple_data_grid()  : Objet
Create quickly a datagrid (with a simple table tag) from a simple key=>value array.
submit_button()  : object
Doing more than a simple submit button.
submit_button_single()  : object
seems to work just like a submit button only this field will be posted (in addition to all those with the 'alwaysposted' flag)
table_header_row()  : mixed
shortcut for _table_row
table_row()  : mixed
shortcut for _table_row
tabs()  : Html
Create tabs inside a page or modal, useful to avoid to rely on navigator tabs.
tag()  : Instance
Create a new Html instance for a tag

Constants

_CHECKMARK_BOLD

public mixed _CHECKMARK_BOLD = '&#10004;'

_CHECKMARK_NORMAL

public mixed _CHECKMARK_NORMAL = '&#10003;'

_DOWN_ARROW

public mixed _DOWN_ARROW = '&darr;'

_DOWN_DASHED_ARROW

public mixed _DOWN_DASHED_ARROW = '&#8675;'

_LEFT_ARROW

public mixed _LEFT_ARROW = '&larr;'

_LEFT_DASHED_ARROW

public mixed _LEFT_DASHED_ARROW = '&#8672;'

_RIGHT_ARROW

public mixed _RIGHT_ARROW = '&rarr;'

_RIGHT_ARROW_HEAD

public mixed _RIGHT_ARROW_HEAD = '&#10148;'

_RIGHT_DASHED_ARROW

public mixed _RIGHT_DASHED_ARROW = '&#8674;'

_STAR_EMPTY

public mixed _STAR_EMPTY = '&#9734;'

_STAR_FULL

public mixed _STAR_FULL = '&#9733;'

_UP_ARROW

public mixed _UP_ARROW = '&uarr;'

_UP_DASHED_ARROW

public mixed _UP_DASHED_ARROW = '&#8673;'

_X_BOLD

public mixed _X_BOLD = '&#10006;'

_X_NORMAL

public mixed _X_NORMAL = '&#10005;'

AUDIO

public mixed AUDIO = 'audio'

BODY

public mixed BODY = 'body'

BR

public mixed BR = 'br'

BUTTON

public mixed BUTTON = 'button'

CANVAS

public mixed CANVAS = 'canvas'

DATALIST

public mixed DATALIST = 'datalist'

DETAILS

public mixed DETAILS = 'details'

DIV

public mixed DIV = 'div'

FIELDSET

public mixed FIELDSET = 'fieldset'

FORM

public mixed FORM = 'form'

HEAD

public mixed HEAD = 'head'

HR

public mixed HR = 'hr'

HTML

public mixed HTML = 'html'

IMAGE

public mixed IMAGE = 'IMAGE'

IMG

public mixed IMG = 'img'

INPUT

public mixed INPUT = 'input'

LABEL

public mixed LABEL = 'label'

LEGEND

public mixed LEGEND = 'legend'

LI

public mixed LI = 'li'
public mixed LINK = 'link'

META

public mixed META = 'meta'

OPTGROUP

public mixed OPTGROUP = 'optgroup'

OPTION

public mixed OPTION = 'option'

PARAM

public mixed PARAM = 'param'

QUICK_EDIT_DATA

public mixed QUICK_EDIT_DATA = 'qe_d'

QUICK_EDIT_FIELD

public mixed QUICK_EDIT_FIELD = 'qe_f'

QUICK_EDIT_ID

public mixed QUICK_EDIT_ID = 'qe_i'

QUICK_EDIT_TYPE

public mixed QUICK_EDIT_TYPE = 'qe_t'

QUICK_EDIT_TYPE_INDEX

public mixed QUICK_EDIT_TYPE_INDEX = 'qe_ti'

SCRIPT

public mixed SCRIPT = 'script'

SELECT

public mixed SELECT = 'select'

simple_tags

public mixed simple_tags = [\helPHP\libs\Html::IMG, \helPHP\libs\Html::IMAGE, \helPHP\libs\Html::BR, \helPHP\libs\Html::HR, \helPHP\libs\Html::INPUT, \helPHP\libs\Html::LINK, \helPHP\libs\Html::META, \helPHP\libs\Html::PARAM, \helPHP\libs\Html::USE]

SOURCE

public mixed SOURCE = 'source'

SPAN

public mixed SPAN = 'span'

STYLE

public mixed STYLE = 'style'

SUMMARY

public mixed SUMMARY = 'summary'

SVG

public mixed SVG = 'svg'

svg_sprite

used by H::icons, it define the main svg sheet used.

public string svg_sprite = \Config::SVG_SPRITE_ICONS_FILE

the original sheet comes from https://feathericons.com/

TABLE

public mixed TABLE = 'table'

TBODY

public mixed TBODY = 'tbody'

TD

public mixed TD = 'td'

TEXTAREA

public mixed TEXTAREA = 'textarea'

TFOOT

public mixed TFOOT = 'tfoot'

TH

public mixed TH = 'th'

THEAD

public mixed THEAD = 'thead'

TITLE

public mixed TITLE = 'title'

TR

public mixed TR = 'tr'

UL

public mixed UL = 'ul'

USE

public mixed USE = 'use'

VIDEO

public mixed VIDEO = 'video'

Properties

$_debug

public static mixed $_debug = false

$children

public mixed $children = array()

$current_value

public mixed $current_value = null

$current_value_label

public mixed $current_value_label = null

$debug

public mixed $debug = false

$extra

public mixed $extra = []

$items_after

public mixed $items_after = array()

$label

public mixed $label = ''

$label_for

public mixed $label_for = false

Methods

__callStatic()

Magic method to handle the call to a static function that does not exist and will create corresponding html/object element

public static __callStatic(string $name, array<string|int, mixed> $args) : object
Parameters
$name : string

the function/html element name

$args : array<string|int, mixed>

[0] : the html attributes as a key pairs array, [1] : the content of the tag

Return values
object

Html element

__construct()

Constructor for the H class.

public __construct([string $tag_name = '' ][, array<string|int, mixed>|null $attributes = null ][, mixed|null $data = null ]) : mixed

This method initializes a new instance of the H class with the specified tag name, attributes, and data. will simply execute the construct of Html class.

Parameters
$tag_name : string = ''

The name of the HTML tag to use for this element (e.g., 'div', 'p', etc.).

$attributes : array<string|int, mixed>|null = null

An array of key-value pairs representing the attributes for this element.

$data : mixed|null = null

Additional data to be used when creating this element. in general its content/innerhtml

Tags
see
construct

__get()

will execute its parent from Html class

public __get(mixed $property) : mixed
Parameters
$property : mixed
Tags
see
__get

__set()

will execute its parent from Html class

public __set(mixed $property, mixed $value) : mixed
Parameters
$property : mixed
$value : mixed

The value to set for the property.

Tags
see
__set

__toString()

Magic method called when a string operation is done with the current object.

public __toString() : string

it will act as a shortcut to full_html().

Return values
string

A string representation of the current HTML element.

__unset()

will execute its parent from Html class

public __unset(mixed $property) : mixed
Parameters
$property : mixed
Tags
see
__unset

_input_translation()

this is the base function for input_short_translation and input_long_translation that can be found in HelPHP_module.php. themselves are used in translate_block.

public static _input_translation(array<string|int, mixed> $attributes[, int $id = 0 ][, bool $short = true ]) : array<string|int, mixed>|object
Parameters
$attributes : array<string|int, mixed>
$id : int = 0
$short : bool = true

if true return an input text, false a textarea

Tags
see
input_short_translation
see
input_long_translation
see
translate_block
Return values
array<string|int, mixed>|object

of multiple input text or textarea depending the number of languages ans short type true/false

add_after()

Adds an item or a list of items to be rendered after the current HTML element.

public add_after(mixed $itemList[, string $key_name = '' ]) : int|bool
Parameters
$itemList : mixed

The item(s) to add. Can be a single Html object, a string, or an array of Html objects or strings.

$key_name : string = ''

Optional key name for the item if it's a single item and needs a specific key.

Return values
int|bool

Returns the index of the last added item if successful, or false if the item list is invalid.

add_child()

Adds a child element or a list of child elements to the current HTML element.

public add_child(mixed $child_list[, string $key_name = '' ]) : int|bool
Parameters
$child_list : mixed

The child element(s) to add. Can be a single Html object, a string, or an array of Html objects or strings.

$key_name : string = ''

Optional key name for the child element if it's a single element and needs a specific key.

Return values
int|bool

Returns the index of the last added child if successful, or false if the element is simple or the child list is invalid. If a key is provided the child is added by the given key and the function return the index of the added element.

add_class()

Adds a CSS class to the HTML element's class attribute.

public add_class(string $value) : void
Parameters
$value : string

The CSS class to add.

add_debug()

public add_debug(mixed $item) : mixed
Parameters
$item : mixed

advanced_data_grid()

As its name indicate it, it do more than the simple grid, there is an additionnal $value_filter used to replace the value to display by textual values.

public static advanced_data_grid(array<string|int, mixed> $liste[, array<string|int, mixed> $columns_filter = null ][, null $values_filter = null ][, string $id = false ]) : Objet

exemple : the returned data contains a size field with possible values 0,1,2 $values_filter = array('size'=> array( 0=>'undefined' , 1=>'small' , 2=>'tall' ) ); instead of displaying 0,1,2 in the cells , it will display 'small' or 'tall' etc...

Parameters
$liste : array<string|int, mixed>
$columns_filter : array<string|int, mixed> = null
$values_filter : null = null
$id : string = false

for the grid

Return values
Objet

Html table

after_html()

Generates the HTML for items that should be rendered after the current element.

public after_html([int $l = 0 ]) : string

This method iterates through the items in the items_after array. If an item is an Html object, it recursively calls its full_html method. Otherwise, it treats the item as a string.

Parameters
$l : int = 0

The current indentation level (for pretty printing).

Return values
string

The HTML content of the items to be rendered after.

ajax_call()

Description for ajax_call This function generates a script that will execute an AJAX call to the specified URL with the provided data.

public static ajax_call(string $url, array<string|int, mixed> $data[, null|string $target = null ][, int $delay = 0 ]) : Html

Useful in rare case when you can't initialize de JS module.

Parameters
$url : string
$data : array<string|int, mixed>

of values to send

$target : null|string = null

to receive result

$delay : int = 0

before launching the script

Return values
Html

script tag to execute the ajax call

button_icon()

display a button with and icon inside

public static button_icon(mixed $name[, mixed $attributes = [] ]) : object
Parameters
$name : mixed

icon name to display

$attributes : mixed = []
Tags
see
icon

you can also use the admin module Icon to pick the icon needed and just add "button_" like this : H:button_icon('picked icon name') to get it quickly.

Return values
object

H::BUTTON with the generated SVG Object element containing the icon.

button_icon_with_text()

same as button_icon() but with a text label that can be place on the left or right side of the button

public static button_icon_with_text(mixed $name[, string $side = 'right' ][, string $label = '' ][, array<string|int, mixed> $attributes = [] ]) : object
Parameters
$name : mixed

of the icpn

$side : string = 'right'

'left' or 'right' default

$label : string = ''
$attributes : array<string|int, mixed> = []
Tags
see
icon

you can also use the admin module Icon to pick the icon needed and just call the function like this : H:button_icon_with_text('picked icon name','left','text label') to get it quickly.

Return values
object

H::BUTTON with the generated SVG Object element containing the icon and a SPAN with the text label

button_info()

Create a informative button

public static button_info(array<string|int, mixed> $attributes, string|object $content[, string $type = 'text' ]) : Objet

When clicked display a modal aside with content given to the method, used to display information to the user

Parameters
$attributes : array<string|int, mixed>
$content : string|object

, either string or HTML object

$type : string = 'text'

Optional, determine the type of string given (text, link)

Return values
Objet

Html div container

close_document()

Its name says all !

public static close_document() : object
Return values
object

Html body and html closing tags

close_html()

Generates the closing HTML tag for the current element.

public close_html() : string
Return values
string

The closing HTML tag.

close_tag()

Create a closing tag

public static close_tag(mixed $tag_name) : string
Parameters
$tag_name : mixed
Return values
string

content_html()

Generates the HTML content of the element's children.

public content_html([int $l = 0 ]) : string

This method iterates through the children of the current HTML element. If a child is an Html object, it recursively calls its full_html method. Otherwise, it treats the child as a string.

Parameters
$l : int = 0

The current indentation level (for pretty printing).

Return values
string

The HTML content of the children.

copy_attributes_to()

Copies attributes, data, and extra properties from the current HTML element to another.

public copy_attributes_to(Html $destination_tag) : void
Parameters
$destination_tag : Html

The target HTML element to copy attributes to.

create_instance()

$H is a global used everywhere in HelPHP to call this class methods and create_instance will create it.

public static create_instance([bool $forceNewInstance = false ]) : object

..

Parameters
$forceNewInstance : bool = false
Return values
object

global $H

css_loader()

Create a link tag to load a css after the first load of document is done, then move it to document head.

public static css_loader(string $url) : object
Parameters
$url : string
Return values
object

html link

debug_structure()

exepose the current object structure as an object tree.

public debug_structure([string $key_name = '' ][, string $parent = '' ][, int $l = 0 ][, bool $is_next = false ]) : Html

Helpfull to debug very complexe object tree.

Parameters
$key_name : string = ''

the key to use to identify the current object in the tree

$parent : string = ''

the parent object to use as a reference

$l : int = 0

the level of the current object in the tree and to force usage of $key_name and $parent

$is_next : bool = false

to start with next item or first child.

Return values
Html

structure of the objet as an Html tree.

del_attribute()

Delete an HTML attribute for the element.

public del_attribute(string $name) : void

can be useful for boolean attributes, like "controls" for video

Parameters
$name : string

The name of the attribute.

detail()

create HTML detail element for accordion effect.

public static detail(mixed $params[, mixed $label = null ]) : mixed
Parameters
$params : mixed
$label : mixed = null

fieldset()

Creates a fieldset object/HTML element with the given legend.

public static fieldset([array<string|int, mixed>|null $attributes = null ][, string $legend = '' ]) : Fieldset
Parameters
$attributes : array<string|int, mixed>|null = null

Additional attributes to apply to the fieldset tag.

$legend : string = ''

The text content of the legend tag. Defaults to an empty string.

Return values
Fieldset

The created Fieldset object with the added legend child.

find_child()

Recursively searches for a child element within the current HTML element's children.

public find_child(string $key_name[, int $maxRecursion = 0 ][, Html|null $parent = null ][, int $level = 0 ]) : Html|null
Parameters
$key_name : string

The key name of the child element to find.

$maxRecursion : int = 0

The maximum recursion depth for the search. Default is 0 (only direct children are searched).

$parent : Html|null = null

The parent element to start the search from. Defaults to the current element.

$level : int = 0

The current recursion level.

Return values
Html|null

Returns the found child element as an Html object, or null if not found. If the key name is found in the direct children, it returns that child.

form()

The Form ! One of the more important tag ! In this class the form created come with multiple automatic features : Fields validation (depending each input) the choice of the div targeted to display the result after a submit (dom_target attributes) or its immediate parent (dom_target='.parent') some custom javascript function to call on submit etc.

public static form([array<string|int, mixed>|null $attributes = null ][, array<string|int, mixed>|string|null $content = '' ][, string $custom_submit_function = '' ]) : mixed

classic form ex : $form = H::form(['action'=>$this->get_index_relative_path(), 'dom_target'=>$this->dom_target, 'class'=>'my_form']); the value coming with $this are coming from helPHP_module in this example...

Parameters
$attributes : array<string|int, mixed>|null = null

list of html attributes

$content : array<string|int, mixed>|string|null = ''

content of the form

$custom_submit_function : string = ''

javascript function to call when submitting the form

full_html()

Generates the complete HTML for the current object/element, including its opening tag, content, and closing tag.

public full_html([int $l = 0 ]) : string

This method orchestrates the generation of the full HTML representation of the element. It handles both standard HTML tags and tag-less groups of children. For standard tags, it calls open_html_tag, content_html, and close_html. For simple tags (like
), it omits the content and closing tag. It also appends any HTML content specified to be rendered after the element.

Parameters
$l : int = 0

The current indentation level for pretty-printing the HTML.

Return values
string

The complete HTML string for the element.

get_children()

All is in the name

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

Returns an array containing the child elements of the current HTML element.

get_items_after()

Retrieves the items that should be rendered after the current HTML element.

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

Returns an array containing the item to be rendered after.

get_unique_id()

create the unique_id for html tag

public static get_unique_id() : string
Return values
string

group()

group of html object.

public static group([mixed $key_name = '' ]) : object

This little and useful function create a new empty Html instance object. So it can receive childs etc and permit various operation on groups of html objet to merge them etc. Very often used for display_output : $output = new H::group('my_display'); $output->add_child([...,...]); return $output;

Parameters
$key_name : mixed = ''

=''

Return values
object

Html group

icon()

Generates an icon SVG element based on the provided name and attributes.

public static icon(string $name[, array<string|int, mixed> $attributes = [] ]) : object

The SVG spreadsheet is a collection of def/symboles. To easily pick one you'll find a very useful admin module named "Icons" that will present to you all the icons in the speadsheet and will permit to search and pick one by clicking on it (it will copy an H:icon('picked icon name') in your clipboard ) and you'll just need to paste the icon at the right place in your code.

Note : it's creating an SVG, so if you want to add an event on it, you should embed it in a div and put the event on it.

Parameters
$name : string

The name of the icon to be used in the #id attribute of the tag.

$attributes : array<string|int, mixed> = []

Optional attributes for the icon, including class and style. Defaults to an empty array.

Return values
object

H::SVG The generated SVG Object element containing the icon.

image()

Generate an image object/HTML tag based on provided attributes.

public static image(mixed $attributes) : object
Parameters
$attributes : mixed

The attributes for the image tag. Can be passed as associative array, or 'src' value.

Return values
object

The generated image object/HTML tag.

input_autocomplete()

The input autocomplete, will search in DB depending the typing or the user to propose a list of available value containing the string.

public static input_autocomplete([array<string|int, mixed> $params = [] ][, null $table_name = null ][, null $field_name = null ][, bool $submit_on_change = false ][, bool $callback = false ]) : object

Other element in the parent form with 'data-autocomp' in parameters will be sent with this input

It's working by sending ajax requests from H_ui_autocomplete to the default autocomplete function in HelPHP_module. Of course it can be extended in a HelPHP module.

Parameters
$params : array<string|int, mixed> = []

with key pairs : name -> the name for the posted input value -> the current id for the hidden field value_label -> the label for the id, in the text field label -> is the label to put before the visible field in the form. class -> css class to add

$table_name : null = null

the name of the table in db

$field_name : null = null

the name of the field in db

$submit_on_change : bool = false

does it send the form when selecting in the list

$callback : bool = false

a js callback

Tags
see
take

a look in the admin users module to find some input autocomplete at work with extended exemple.

Return values
object

Html div / autocomplete widget

input_checkbox()

The classic checkbox set $attributes['checked'] to check it.

public static input_checkbox(array<string|int, mixed> $attributes[, mixed $post = null ]) : object
Parameters
$attributes : array<string|int, mixed>
$post : mixed = null

the current post

Return values
object

html input checkbox

input_colorpicker()

Create a colorpicker with the external js alwan colorpicker.

public static input_colorpicker(mixed $attributes) : Objet

the value is in class html hexa value (e.g:#FFFFFF)

Parameters
$attributes : mixed
Return values
Objet

Html div

input_confirmation()

The input confirmation is a classic field used in general to confirm the content of a previous one, like a password or email you need to confirm.

public static input_confirmation(object $original_input[, string $label = '[confirm]' ]) : object
Parameters
$original_input : object

the original field that needed to be confimed

$label : string = '[confirm]'
Return values
object

html input confirm with similar aspect of the orginal input

input_date()

A date selector! Perfect for booking... You can set a minimal and maximal value for an accepted value in a range.

public static input_date([array<string|int, mixed>|null $attributes = null ]) : object
Parameters
$attributes : array<string|int, mixed>|null = null
Tags
see
input_datetime()

if hours matters

Return values
object

html input

input_datetime()

A datetime selector! Note that some navigator still got some issue with this kind of input, and sometimes it's better to use an input_date and a separated input_time to cover all needs and possible issue.

public static input_datetime([array<string|int, mixed>|null $attributes = null ]) : object
Parameters
$attributes : array<string|int, mixed>|null = null
Return values
object

html input

input_email()

Generates an HTML input field for the email type of data.

public static input_email([array<string|int, mixed>|null $attributes = null ]) : object
Parameters
$attributes : array<string|int, mixed>|null = null

of the input element. If null, default attributes will be used.

Return values
object

The generated HTML input email field.

input_field()

Generates an input field of the specified type.

public static input_field(string $type[, array<string|int, mixed> $attributes = null ]) : object

validation process is automaticaly made depending the type This function is a global shortcut to all input_xxx ones you can find bellow.

Parameters
$type : string

The type of input field to generate. One of:

  • 'login'
  • 'password'
  • 'email'
  • 'integer'
  • 'float'
  • 'date'
  • 'textarea'
  • 'hidden'
  • 'file'
  • 'bool' / 'checkbox'
  • 'radio'
  • 'varchar'
  • 'char'
  • 'text'
$attributes : array<string|int, mixed> = null

Optional. Additional attributes to pass to the input field.

Return values
object

/ Html input

input_file()

The input file can support multiple upload.

public static input_file(array<string|int, mixed> $attributes) : object

Those are chunked uploads automaticaly managed by our Ajax JS and PHP class Nothing special to do, you'll reveice your file(s) in $_FILE as usual, but the Ajax\process_file() method will help you move/process them. But if you want to upload image or video you should take a look on the Media module that offer a lot more.

Parameters
$attributes : array<string|int, mixed>
Return values
object

html input

input_float()

You liked the input integer ? here is the same for float... With min max limit for accepted range as well.

public static input_float([array<string|int, mixed>|null $attributes = null ][, int|null $min = null ][, int|null $max = null ]) : object
Parameters
$attributes : array<string|int, mixed>|null = null
$min : int|null = null
$max : int|null = null
Return values
object

html input

input_hidden()

The hidden input ! you don't see it, but still the best solution to keep some temporary values between two post!

public static input_hidden(array<string|int, mixed> $attributes) : object
Parameters
$attributes : array<string|int, mixed>
Return values
object

html input

input_integer()

Another input field dedicated to integers.

public static input_integer([array<string|int, mixed>|null $attributes = null ][, int|null $min = null ][, int|null $max = null ]) : object

You can set a minimal and maximal value for an accepted value in a range. accept only integers (of course )

Parameters
$attributes : array<string|int, mixed>|null = null
$min : int|null = null
$max : int|null = null
Return values
object

html input

input_login()

Generates an HTML input field for the login type of data.

public static input_login([array<string|int, mixed>|null $attributes = null ]) : object
Parameters
$attributes : array<string|int, mixed>|null = null

of the input element. If null, default attributes will be used.

Return values
object

The generated HTML input login field.

input_multiple_radios()

create multiple radio

public static input_multiple_radios(array<string|int, mixed> $attributes) : mixed

add a values key to attributes with the list of values.

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

Associative array. Some value are required to work properly:

  • values : array of array with label and value inside, each one display a choice
  • name : name's in form

input_order()

the purpose of the input order is to permet to ordonnate a list by a numeric value, and to manipulate it thru drag & drop or manual edition in case you want to manipulate lines of data, you can enclose each line with a DIV with the attribute 'data-order_parent'=>'sort_order['.$post['key'].']' sort order will be the name of the input_order.

public static input_order(array<string|int, mixed> $params[, bool $editable = false ][, mixed $callback = '' ]) : mixed

there can multiple inpu_order series, do it's the name of it that identifie and seperated the various input_order group. exemple: in this exemple we list a DB prepared_query_list and create a div for each line of value and an input order each one, so for each line :

//we create a div for the line $linediv = H::DIV(['class'=>$this->css.'field', 'data-order_parent'=>'sort_order['.$post['key'].']'],$line['value']); //first we check if an order is already given... $val_order = (isset($post['sort_order'])) ? $post['sort_order'] : ($post['key']+1); $order = H::input_order(['name'=>'sort_order['.$post['key'].']', 'value'=>$val_order, 'class'=>$this->css.'order']); we add the order input to the parent div of the line... $linediv->add_child($order);

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

, general parameter for the input like. Need to have name and value to work.

$editable : bool = false

, true if the order can be change with an input integer

$callback : mixed = ''

input_password()

Generates an HTML input field for the password type of data.

public static input_password([array<string|int, mixed>|null $attributes = null ]) : object
Parameters
$attributes : array<string|int, mixed>|null = null

of the input element. If null, default attributes will be used.

Return values
object

The generated HTML input password field.

input_precomplete()

the input_precomplete is different from input_autocomplete, as it do not ask for data in db at each new char, because it already got the db table inside ansdrequested only one time.

public static input_precomplete(array<string|int, mixed> $params[, array<string|int, mixed> $list_data = [] ][, bool $submit_on_change = false ][, false|string $callback = false ]) : object

It's perfect for a small batch of data like to choose a country or search... you'll find exemple in the admin category module.

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

with key pairs : name -> the name for the posted input value -> the current id for the hidden field value_label -> the label for the id, in the text field label -> is the label to put before the visible field in the form. class -> css class to add

$list_data : array<string|int, mixed> = []

is an array like the opt_data in select, with label_key, value_key, data, (optionnal) first_empty

$submit_on_change : bool = false

can be false | true, submit form on change

$callback : false|string = false

a javascript callback to call when change

Return values
object

Html div / precomplete widget

input_radio()

The classic radio set $attributes['checked'] to indicate which one is checked.

public static input_radio(array<string|int, mixed> $attributes) : object
Parameters
$attributes : array<string|int, mixed>
Tags
see
input_multiple_radios()

to create all radios in one go

Return values
object

html input radio

input_range()

The input range take care of all possibilities of the html5 range tag.

public static input_range(array<string|int, mixed> $attributes[, float $min = null ][, float $max = null ][, float $step = null ][, string $value = null ][, string $orient = null ]) : object

With step and limits it can also be used to represent a playing track.

Parameters
$attributes : array<string|int, mixed>
$min : float = null

minimal limitation

$max : float = null

maximal limitation

$step : float = null

the precision of the step will define also the precision of the range

$value : string = null

=null

$orient : string = null

=null (vertical or horizontal for firefox) you can also add "writing-mode" or "direction" in $attributes array.

Return values
object

html input range

input_submit_attributes()

Used to add some submit attributes to other input like select

public static input_submit_attributes(string $submit_varname, string $submit_varvalue) : array<string|int, mixed>
Parameters
$submit_varname : string
$submit_varvalue : string
Return values
array<string|int, mixed>

attributes

input_text()

A simple input text

public static input_text(array<string|int, mixed> $attributes) : object
Parameters
$attributes : array<string|int, mixed>
Return values
object

html input

input_textarea()

A textarea ! But not so simple, because if $attributes['tinymce'] is set, the textarea will be transformed in a tinyMCE instance.

public static input_textarea(array<string|int, mixed> $attributes) : object
Parameters
$attributes : array<string|int, mixed>
Return values
object

html input

input_time()

A time selector!

public static input_time([array<string|int, mixed>|null $attributes = null ]) : object
Parameters
$attributes : array<string|int, mixed>|null = null
Return values
object

html input

is_simple()

check if the tag is a simple one like <br> with no closing tag

public static is_simple(mixed $tag_name) : bool
Parameters
$tag_name : mixed
Return values
bool

true false

label_tag()

Create an Html::Label tag from $label and $attributes or from $this->label and $this->attributes of the current object.

public label_tag([string $label = null ][, array<string|int, mixed> $attributes = null ]) : Html
Parameters
$label : string = null
$attributes : array<string|int, mixed> = null
Return values
Html

object Html::label

load_js()

Load_js is used by new_document() only in dev mode.

public static load_js([bool $public = true ][, string $pre = '' ][, string $refresher = '' ]) : Objects

It's used to cp the available js of module in tmp folder on the instance to permit debug .

Parameters
$public : bool = true
$pre : string = ''

the base usl pre tmp

$refresher : string = ''

a timestamp or any changing value to force reload.

Return values
Objects

Html bunch of scripts tag

multi_state_button()

The fantastic multistate button ! with tooglable menu ! Will create a div containing a list of buttons with only one active and visible.

public static multi_state_button(array<string|int, mixed> $params, mixed $btns, int $index_active[, string $side = '' ][, mixed $toggle_mode = false ]) : object

clicking on the current button will execute its events then display the next one.

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

parameters array for container (id, class, dataset...)

$btns : mixed
$index_active : int

the index in btns array of the current active button, the one that is selected by default if -1, no buttons active by default but the fist one will be used as avatar

$side : string = ''

add "side"css class to the element to indicate on which side should toogle the button menu

$toggle_mode : mixed = false

=false

Return values
object

Html sort of button

new_document()

Major method that will create all the head elements of a new html output.

public static new_document(string $title, mixed $keywords, mixed $description[, mixed $meta_data = false ][, mixed $public = false ][, mixed $canonical = false ][, mixed $theme = false ]) : object

it will manage the embeding of the javascripts and css files depending if we are in dev or production mode. But also the indexations and socials tags for indexable documents.

Parameters
$title : string

The title of the page. @param String $keywords : all the keywords for meta keywords @param Array $meta_data : meta tags as key pairs (name => value). @param Bool $public indicate if this head is for the front or backoffice / admin side @param String|Bool $canonical is used for sitemap indexation to indicate the original document in case of double URL @param Int $theme ID of the theme to load.

$keywords : mixed
$description : mixed
$meta_data : mixed = false
$public : mixed = false
$canonical : mixed = false
$theme : mixed = false
Return values
object

The complete head of the HTML document.

open_html_tag()

Generates the opening HTML tag for the current element.

public open_html_tag() : string

This includes the tag name and all its attributes (standard and data-*). It also handles special cases like the DOCTYPE for the tag and event parsing for JavaScript integration. For quick edit fields/forms, it encrypt the field infos to avoid XSS or SQL injection.

Return values
string

The opening HTML tag as a string.

open_tag()

Create an opening tag with its attributes

public static open_tag(mixed $tag_name[, null $attributes = null ]) : string
Parameters
$tag_name : mixed
$attributes : null = null
Return values
string

output()

Will return the current HTML content as string.

public static output(mixed $htmlContent) : string

Echo force the call to magic method __toString that will convert everything with full_html()

Parameters
$htmlContent : mixed
Return values
string

html

parse_event()

Retrieve event that need to pass by event.js it automaticaly removed onclick or onchange and over attributes related to events, to pass them thru the event.js class.

public parse_event() : mixed

This will avoid conflict and permit multiple similar events on the same tag Except for A tag because they need to stop the original event to not trig the page reload This function is called automaticaly

preview_button()

button preview for admin to call preview module.

public static preview_button(mixed $module, mixed $id[, mixed $label = '' ][, mixed $admin = false ][, mixed $extra_params = false ]) : mixed
Parameters
$module : mixed
$id : mixed
$label : mixed = ''
$admin : mixed = false
$extra_params : mixed = false

quick_edit()

Create a "quick edit" item.

public static quick_edit(Objet $form, string $id, string $field_identifier[, array<string|int, mixed> $attributes = [] ][, string $text = '' ][, string $type = 'text' ][, int $id_lang_data = null ]) : object

a "quick edit" a start seems to be a simple text, but after a double click/tap on it, it transform as a input field that permit to edit the value of the text. After validation, the value is updated in the DB. useful when there is only one thing to edit in a page or with complexe pagination or when you need to enlight the UI. you can have one form object for multiple quick edit item.

exemple : $my_quick_edit = H::quick_edit($form, $line['id'], ['class'=>'myqe'], $this->ifld_data_value, $line['value'], 'float');

Parameters
$form : Objet

the H::form() that will integrate the field

$id : string

integer id of the field in database

$field_identifier : string

the name to send, with format module_table-field

$attributes : array<string|int, mixed> = []

to add the html element (like other elements)

$text : string = ''

text to display

$type : string = 'text'

of the field to enable validation

$id_lang_data : int = null

if translatable field, the id of the language

Tags
see
quick_edit_generate_input()
Return values
object

Html item that will transform as a typed input

quick_edit_generate_input()

Quick edit input generated depending the preparation done with quick_edit().

public static quick_edit_generate_input(int $id, mixed $value, mixed $type_index, mixed $field_data[, null $id_lang_data = null ][, array<string|int, mixed> $attributes = [] ]) : Objet

this function is automaticaly called by HelPHP_module and create the mini form with current value

Parameters
$id : int
$value : mixed
$type_index : mixed
$field_data : mixed
$id_lang_data : null = null
$attributes : array<string|int, mixed> = []
Return values
Objet

Html block

reset_key()

Reset key_name

public reset_key([mixed $newValue = '' ]) : mixed
Parameters
$newValue : mixed = ''

script()

Create script tag with some special features... if an "autoremove" attribute is specified the script tag will be automatically removed from the html page after 50 milliseconds (default value) or a specified delay in milliseconds.

public static script(mixed $content[, null $attributes = null ]) : object

So if the user inspect the page source to find this js, there will be nothing (useful for security). this allows you to run a punctual piece of javascript, without polluting the page afterwards If async="async": The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing) If async is not present and defer="defer": The script is executed when the page has finished parsing If neither async or defer is present: The script is fetched and executed immediately, before the browser continues parsing the page

Parameters
$content : mixed
$attributes : null = null
Return values
object

html script

script_loader()

Create a script tag to load a script after the first load of document is done.

public static script_loader(string $url) : object
Parameters
$url : string
Return values
object

html script

select()

To get an input select.

public static select(array<string|int, mixed> $attributes, array<string|int, mixed> $options_data[, null $default_value = null ][, string $submit_varname = '' ][, string $submit_varvalue = '' ]) : object

the form can be posted automatically when changing the value of this select two other parameters must be specified : $submit_varname : action variable name $submit_varvalue : action variable value

Parameters
$attributes : array<string|int, mixed>
$options_data : array<string|int, mixed>

an array containing the list of options to display (usually a result of sql query) value_key : the name of the field containing the value of each option of the select label_key : the name of the field containing the text to display in each option of the select

first_empty (optional) : true if it is necessary to display an empty value at the beginning of the list or an array representing the element to display at the start of the list, formatted as the options are: [value_key => "value", label_key => "label"]

groups (optional) : an array used to create groups from a field in the options table

exemple : 'groups'=>['model'=> [0=>'Thing' , 1=>'Another Thing'] ]); the 'model' field will be used to define the groups, the items with model = 0 will go in the group labeled 'Thing', those with the value 1 will go in the group with the label 'Another Thing'

IMPORTANT: two special keys are predefined: 'null' and '?' the group with 'null' will receive all the elements whose specified field contains the value NULL the group with '?' will receive all items that do not have an identified value in another group

full exemple usage with a list coming from db for: // we get the data $q = 'SELECT id, name FROM '. $DB->table('xxxx_data').' ORDER BY name'; $list = $DB->prepared_query_list($q); //check if there is already a posted id $selected_id = isset($post[$this->build_module_field_name('xxxx','data','id')]) ? $post[$this->build_module_field_name('xxxx','data','id')] : 0; //setting up all options data $opts_data = array('first_empty'=>true, 'value_key'=>'id', 'label_key'=>'name', 'options'=>$list); //getting the select $select = H::select(['name'=>$this->build_module_field_name('xxxx','data','id'), 'label'=>$this->get_tl('my_select')], $opts_data, $selected_id, $this->input_action_identifier, $this->ACTION); //when there will be an onchange event, it will submit the current form.

$default_value : null = null

(optional) : the value of the option to be selected by default on the first display

$submit_varname : string = ''
$submit_varvalue : string = ''
Return values
object

Html input select

set_attribute()

Sets an HTML attribute for the element.

public set_attribute(string $name, mixed $value) : void
Parameters
$name : string

The name of the attribute.

$value : mixed

The value of the attribute.

set_extra()

Sets an extra property for the element.

public set_extra(string $name, mixed $value) : void
Parameters
$name : string

The name of the extra property.

$value : mixed

The value of the extra property.

simple_data_grid()

Create quickly a datagrid (with a simple table tag) from a simple key=>value array.

public static simple_data_grid(array<string|int, mixed> $liste[, array<string|int, mixed> $columns_filter = null ][, string $id = false ]) : Objet

it can come from DB\prepared_query_list or DB\query_list to display directy the result of a mysql Query. $columns_filter contains an array used to specify fields to display and to give them a display label. it can also change their order : exemple : $columns =  ['id'=>'DB ID' , 'email'=>'mail adress ' , etc ... ] $liste = 0 => ['email'=>'xxx@yyyyy.com','id'=>125, ...], 1 => ['email'=>'zzzz@yyyyy.com','id'=>126, ...]

Parameters
$liste : array<string|int, mixed>
$columns_filter : array<string|int, mixed> = null
$id : string = false

for the grid

Return values
Objet

Html table

submit_button()

Doing more than a simple submit button.

public static submit_button(mixed $attributes[, string $label = 'SUBMIT' ][, string $custom_submit_function = '' ]) : object

it use a token system to avoid flooding and limit ddos it will call validator to check the vallue of all input again. if we give an action identifier as name for all submit button, its value can be used to call different process (you'll see that during module construction). Exemple : $btn_delete = H::submit_button(['class'=>$this->css.'btn_del', 'name'=>$this->input_action_identifier, 'value'=>$this->ACTION_DELETE_document_data, 'title'=>$this->get_tl('tlc_del'), 'data-confirm'=>$this->get_tl('ask_delete')], $this->get_tl('tlc_del'));

Parameters
$attributes : mixed
$label : string = 'SUBMIT'
$custom_submit_function : string = ''

a javascript call back called

Return values
object

Html submit button

submit_button_single()

seems to work just like a submit button only this field will be posted (in addition to all those with the 'alwaysposted' flag)

public static submit_button_single(mixed $attributes[, string $label = 'SUBMIT' ][, string $custom_submit_function = '' ]) : object
Parameters
$attributes : mixed
$label : string = 'SUBMIT'
$custom_submit_function : string = ''
Return values
object

Html submit button

table_header_row()

shortcut for _table_row

public static table_header_row(mixed $data_line[, mixed $columns_filter = null ][, mixed $values_filter = null ]) : mixed
Parameters
$data_line : mixed
$columns_filter : mixed = null
$values_filter : mixed = null
Tags
see
_table_row()

table_row()

shortcut for _table_row

public static table_row(mixed $data_line[, mixed $columns_filter = null ][, mixed $values_filter = null ]) : mixed
Parameters
$data_line : mixed
$columns_filter : mixed = null
$values_filter : mixed = null
Tags
see
_table_row()

tabs()

Create tabs inside a page or modal, useful to avoid to rely on navigator tabs.

public static tabs(array<string|int, mixed> $params, array<string|int, mixed> $labels, array<string|int, mixed> $contents) : Html

Take a look in admin blockeditor or document editor to see exemple of usage

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

usual attributes

$labels : array<string|int, mixed>

the tab labels

$contents : array<string|int, mixed>

the tabl contents

Return values
Html

object tabs

tag()

Create a new Html instance for a tag

public static tag([string $tag_name = '' ][, null $attributes = null ][, null $content = null ]) : Instance
Parameters
$tag_name : string = ''
$attributes : null = null
$content : null = null
Return values
Instance

object


        
On this page

Search results