HelPHP_module
in package
Tags
Table of Contents
Constants
- hierarchy_suffix = '_parentage'
- indentation_key = '_level_'
- module_name = 'helphpmodule'
- posted_container_name = 'posted_from_container_name'
- posted_varname = 'posted_from_container'
- reload_no_params = 'reloadnoparams'
- reload_page = true
Properties
- $debug : mixed
- $disable_output : mixed
- $display : mixed
- $error_list : mixed
- $force_reload_delay : mixed
- $json_output : mixed
- $lang : mixed
- $message_list : mixed
- $module_path : mixed
- $options : mixed
- $reload_after_message : mixed
- $tl : mixed
Methods
- __construct() : mixed
- Initializes the module, sets up display container, checks user access, loads translations and options, and prepares settings if available.
- __get() : mixed
- Magic getter for dynamic property access (table names, field names, JS instance, etc.).
- add_error() : void
- Adds an error message to be displayed as a popup.
- add_message() : void
- Adds a standard message to be displayed as a popup.
- add_parenting() : bool
- Adds a parenting relationship in the hierarchy table.
- apply_bdd_data() : void
- This function modifies $post by incorporating the values from the bdd and prepare them to be displayed in form fields if $fields is false then we take all fields of the table by default. . .
- autocomplete() : mixed
- Handles autocomplete requests for form fields.
- build_field_name() : string
- construction of the field name that will be used for the inputs in the forms it is formed by the 'name module'.'_'.'table name'.'-'.'field name' ex : module "message" table "data" field "id" : message_data-id ------------------------------ IMPORTANT : the dash (-) is used as a separator, so it should not be found in module, table or field names ------------------------------ this function is a shortcut to build_module_field_name (using current module_name)
- build_module_field_name() : string
- Returns the field name for form inputs for a specified module.
- build_module_table_name() : string
- Returns the full table name for a specified module.
- build_table_name() : string
- Returns the full table name for the current module.
- check_module_access() : void
- Checks module access rights for the current user and sets user_allowed and user_can_edit.
- check_posted_data() : void
- This function checks the validity of fields sent from the form and an alignment is made according to the type of each field.
- check_token() : bool
- Checks the validity of a token sent by a form with token protection against DDOS
- data_tree() : array<string|int, mixed>
- Generates a data tree for the specified table.
- data_tree_for_select() : array<string|int, mixed>
- Generates a data tree for use in a select input, separating out-of-tree items at the end of the list.
- delete_associations() : void
- Removes associations related to a specified item.
- delete_parenting() : void
- Deletes all parenting entries for a specified item.
- echo_output() : void
- Echoes the HTML code to be output for this module.
- explode_field_name() : array<string|int, mixed>
- Splits a composed field name into module, table, and field.
- extract_field_name() : string
- Extracts the field name from a composed field name.
- get_association_tables() : array<string|int, mixed>
- Returns the list of all association tables related to this module.
- get_bdd_data() : array<string|int, mixed>
- Retrieves data from the database for a table and optional fields/ID.
- get_display_tree() : mixed
- Generates the display tree structure for the module container.
- get_dom_id() : void
- Generates or retrieves the DOM ID for the module instance.
- get_elapsed_time() : float
- Returns the time elapsed (in seconds) since the class was instantiated.
- get_error_count() : int|bool
- Checks if there are any error message.
- get_error_list() : array<string|int, mixed>
- Returns the current error list.
- get_form_fields_name() : string
- Generates a name for the group that will contain form fields.
- get_index_relative_path() : string
- Returns the relative path to the module's index page (public or admin).
- get_message_list() : array<string|int, mixed>
- Returns the current message list.
- get_multiple_tl() : array<string|int, mixed>|string
- returns an array with all identified texts, or the identifier in brackets if no text exists for this identifier $list is an array that contains another array like this: ['key'=>'string identifier' , 'replace'=>[...] ] replace can contain a word or an array of words each word will replace in order the numbered markers preceded by $ present in the text= if $join is specified, the result will be a string concatenated with this text instead of an array
- get_order_parenting() : int
- Gets the next sort order value for a parent in the hierarchy table.
- get_output() : string
- Returns the HTML code to be displayed as output for this module.
- get_parent_data() : array<string|int, mixed>|null
- Gets parent data for a specified item in the hierarchy table.
- get_parent_id() : int|null
- Gets the parent ID for a specified item in the hierarchy table.
- get_raw_format() : string
- Returns the raw format type for a given field type or name.
- get_tl() : string|array<string|int, mixed>
- Returns the translated text for a given key, with optional replacements and pluralization.
- get_translated_table_fields() : array<string|int, mixed>
- Returns translated field names for a table.
- get_translated_text_from_other_module() : string
- Gets a translated text from another module.
- group_has_access() : bool
- check if user has right to access depending group restriction
- has_any_message() : bool
- Checks if there are any error or message popups to display.
- has_data_tree() : bool
- Checks if the specified table has a data tree structure.
- init_form_fields() : mixed
- kept for compatibility.
- input_long_translation() : mixed
- Creates translation textarea for a long text field.
- input_short_translation() : mixed
- Creates translation inputs for a short text field.
- integrate_module() : string
- Integrates another module's HTML output into the current module when no Hcode possible be careful, this function use the HTLM 4 Parser, but have been improved to support most of html5 https://www.php.net/manual/en/domdocument.loadhtml.php
- load_options() : void
- Loads options for this module from the main config file.
- load_settings_data() : void
- Loads settings data for the current module from settings module DB if it's installed.
- load_translation_files() : void
- Loads translation files for the module.
- module_data_tree() : mixed
- module_data_tree_for_select() : array<string|int, mixed>
- Generates a data tree for a module's table for use in a select input.
- module_has_data_tree() : bool
- Checks if a module's table has a data tree structure.
- module_load_options() : array<string|int, mixed>|false
- Loads options for a given module from the configuration.
- parse_hcode() : string
- Parses Hcode tags in HTML and replaces them with module outputs.
- prepare_fields() : void
- Prepares fields for editing forms by checking posted data and applying database values if there is an posted ID.
- prepare_group_query_part() : string
- Prepares the SQL query part for group-based access restrictions.
- prepare_module() : void
- Prepares the module with its name and admin status.
- process_data() : bool
- Main method for processing input data and handling module actions.
- publish_output() : void
- Publishes the output, either integrating into core content or echoing directly.
- quick_edit_update() : mixed
- Validates and saves a quick edit update for a field.
- receive_tinymce_file() : void
- Handles TinyMCE file uploads for the module.
- recurse_tree() : array<string|int, mixed>
- Recursively builds a tree structure for a module's table.
- reset_fields() : void
- Resets all fields in $post according to their type in the database.
- sync_messages_with() : void
- Synchronizes error and message lists with another module instance.
- sync_with_user() : void
- Synchronizes error and message lists with the global user object to check connection etc.
- translate_block() : mixed
- Generates a translation block with inputs for multiple languages.
- user_query_part() : string
- Returns the SQL query part to limit results to the current user.
Constants
hierarchy_suffix
public
mixed
hierarchy_suffix
= '_parentage'
indentation_key
public
mixed
indentation_key
= '_level_'
module_name
public
mixed
module_name
= 'helphpmodule'
posted_container_name
public
mixed
posted_container_name
= 'posted_from_container_name'
posted_varname
public
mixed
posted_varname
= 'posted_from_container'
reload_no_params
public
mixed
reload_no_params
= 'reloadnoparams'
reload_page
public
mixed
reload_page
= true
Properties
$debug
public
mixed
$debug
= false
$disable_output
public
static mixed
$disable_output
= false
$display
public
mixed
$display
$error_list
public
mixed
$error_list
= []
$force_reload_delay
public
mixed
$force_reload_delay
= 0
$json_output
public
mixed
$json_output
= null
$lang
public
mixed
$lang
= ''
$message_list
public
mixed
$message_list
= []
$module_path
public
mixed
$module_path
= ''
$options
public
mixed
$options
$reload_after_message
public
mixed
$reload_after_message
= false
$tl
public
mixed
$tl
= array()
Methods
__construct()
Initializes the module, sets up display container, checks user access, loads translations and options, and prepares settings if available.
public
__construct([string|null $dom_container = null ][, string|false $module_path = false ]) : mixed
Parameters
- $dom_container : string|null = null
-
Optional. The DOM container name.
- $module_path : string|false = false
-
Optional. Path to the module.
__get()
Magic getter for dynamic property access (table names, field names, JS instance, etc.).
public
__get(string $property) : mixed
Parameters
- $property : string
-
The property name.
Return values
mixed —The computed property value or null.
add_error()
Adds an error message to be displayed as a popup.
public
add_error(string $error_message_key[, mixed|null $replace = null ]) : void
Parameters
- $error_message_key : string
-
Translation key for the error message.
- $replace : mixed|null = null
-
Optional. Replacement values for the message.
add_message()
Adds a standard message to be displayed as a popup.
public
add_message(string $message_key[, mixed|null $replace = null ]) : void
Parameters
- $message_key : string
-
Translation key for the message.
- $replace : mixed|null = null
-
Optional. Replacement values for the message.
add_parenting()
Adds a parenting relationship in the hierarchy table.
public
add_parenting(string $table, int $id_item[, int $id_parent = 0 ]) : bool
Parameters
- $table : string
-
Table name.
- $id_item : int
-
Item ID.
- $id_parent : int = 0
-
Parent ID.
Return values
bool —True on success, false otherwise.
apply_bdd_data()
This function modifies $post by incorporating the values from the bdd and prepare them to be displayed in form fields if $fields is false then we take all fields of the table by default. . .
public
apply_bdd_data(array<string|int, mixed> &$post, string $table[, array<string|int, mixed>|false $fields = false ][, int|null $id = null ]) : void
this avoids making an useless array of type protected_$fields .
Parameters
- $post : array<string|int, mixed>
-
Reference to the POST data array.
- $table : string
-
Table name.
- $fields : array<string|int, mixed>|false = false
-
Optional. List of fields.
- $id : int|null = null
-
Optional. ID to filter.
autocomplete()
Handles autocomplete requests for form fields.
public
autocomplete(array<string|int, mixed> &$post) : mixed
Parameters
- $post : array<string|int, mixed>
-
Reference to the POST data array.
Return values
mixed —Autocomplete result object.
build_field_name()
construction of the field name that will be used for the inputs in the forms it is formed by the 'name module'.'_'.'table name'.'-'.'field name' ex : module "message" table "data" field "id" : message_data-id ------------------------------ IMPORTANT : the dash (-) is used as a separator, so it should not be found in module, table or field names ------------------------------ this function is a shortcut to build_module_field_name (using current module_name)
public
build_field_name(string $table, string $field) : string
Parameters
- $table : string
-
Table name.
- $field : string
-
Field name.
Return values
string —Field name for forms.
build_module_field_name()
Returns the field name for form inputs for a specified module.
public
static build_module_field_name(string $module, string $table, string $field) : string
Parameters
- $module : string
-
Module name.
- $table : string
-
Table name.
- $field : string
-
Field name.
Return values
string —Field name for forms.
build_module_table_name()
Returns the full table name for a specified module.
public
static build_module_table_name(string $module, string $table) : string
Parameters
- $module : string
-
Module name.
- $table : string
-
Table name.
Return values
string —Full table name.
build_table_name()
Returns the full table name for the current module.
public
build_table_name(string $table) : string
shortcut for build_module_table_name() using only table name
Parameters
- $table : string
-
Table name.
Return values
string —Full table name.
check_module_access()
Checks module access rights for the current user and sets user_allowed and user_can_edit.
public
check_module_access() : void
check_posted_data()
This function checks the validity of fields sent from the form and an alignment is made according to the type of each field.
public
check_posted_data(array<string|int, mixed> &$post, string $table[, array<string|int, mixed>|false $fields = false ]) : void
If we don’t send an array “fields” then we will check all the fields of the table, which should be the base... this avoids making an array of type protected_$fields. IMPORTANT: the & before $post makes it a pointer to the original variable which is then updated directly
Parameters
- $post : array<string|int, mixed>
-
Reference to the POST data array.
- $table : string
-
Table name.
- $fields : array<string|int, mixed>|false = false
-
Optional. List of fields.
check_token()
Checks the validity of a token sent by a form with token protection against DDOS
public
static check_token(mixed $post, int $delay) : bool
Parameters
- $post : mixed
-
The POST data containing the token to validate in $post['js_token']
- $delay : int
-
The timestamp to validate against in microseconds
Return values
bool —Returns true if token is valid, false otherwise
data_tree()
Generates a data tree for the specified table.
public
data_tree([string $table = 'data' ][, string $display_field = 'name' ][, int $id_parent = 0 ][, bool $linear = false ][, array<string|int, mixed>|false $ignore = false ]) : array<string|int, mixed>
shortcut of module_data_tree with current module_name
Parameters
- $table : string = 'data'
-
Table name.
- $display_field : string = 'name'
-
Field name to display,to identify the element.
- $id_parent : int = 0
-
Root parent ID. If this parameter is set to null, only the out of tree structure elements will be returned
- $linear : bool = false
-
false -> the function returns a recursive tree, with the children contained in the key “children” true -> the function returns a tree in the form of a linear list, the recursion level is given by the key $this->indentation_key
- $ignore : array<string|int, mixed>|false = false
-
list of id to ignore in the request, will ignore corresponding elements and their children
Return values
array<string|int, mixed> —Data tree structure.
data_tree_for_select()
Generates a data tree for use in a select input, separating out-of-tree items at the end of the list.
public
data_tree_for_select([string $table = 'data' ][, string $display_field = 'name' ][, int $id_parent = 0 ][, array<string|int, mixed>|null $options = null ]) : array<string|int, mixed>
shortcut to module_data_tree_for_select with current module_name
Parameters
- $table : string = 'data'
-
Table name.
- $display_field : string = 'name'
-
Field name to display.
- $id_parent : int = 0
-
Root parent ID.
- $options : array<string|int, mixed>|null = null
-
Optional. Additional options.
Return values
array<string|int, mixed> —Data tree for select.
delete_associations()
Removes associations related to a specified item.
public
delete_associations(int $id[, string $otherModule = '' ]) : void
Parameters
- $id : int
-
Item ID.
- $otherModule : string = ''
-
Optional. Other module name.
delete_parenting()
Deletes all parenting entries for a specified item.
public
delete_parenting(string $table, int $id) : void
Parameters
- $table : string
-
Table name.
- $id : int
-
Item ID.
echo_output()
Echoes the HTML code to be output for this module.
public
echo_output() : void
explode_field_name()
Splits a composed field name into module, table, and field.
public
static explode_field_name(string $composed_field_name) : array<string|int, mixed>
Parameters
- $composed_field_name : string
-
The composed field name.
Return values
array<string|int, mixed> —Array with keys 'module', 'table', 'field'.
extract_field_name()
Extracts the field name from a composed field name.
public
extract_field_name(string $composed_field_name) : string
(a formatted string "module_table-field")
Parameters
- $composed_field_name : string
-
The composed field name.
Return values
string —The field name.
get_association_tables()
Returns the list of all association tables related to this module.
public
get_association_tables([string $otherModule = '' ]) : array<string|int, mixed>
Parameters
- $otherModule : string = ''
-
Optional. Other module name.
Return values
array<string|int, mixed> —List of association tables.
get_bdd_data()
Retrieves data from the database for a table and optional fields/ID.
public
get_bdd_data(string $table[, string|array<string|int, mixed> $fields = '*' ][, int|array<string|int, mixed>|null $id = null ]) : array<string|int, mixed>
Parameters
- $table : string
-
Table name.
- $fields : string|array<string|int, mixed> = '*'
-
Fields to retrieve.
- $id : int|array<string|int, mixed>|null = null
-
Optional. ID(s) to filter.
Return values
array<string|int, mixed> —Retrieved data.
get_display_tree()
Generates the display tree structure for the module container.
public
get_display_tree(string $name, mixed &$data) : mixed
Parameters
- $name : string
-
Name of the display tree.
- $data : mixed
-
Data for the tree.
Return values
mixed —Display tree object.
get_dom_id()
Generates or retrieves the DOM ID for the module instance.
public
get_dom_id([array<string|int, mixed> $post = [] ]) : void
Parameters
- $post : array<string|int, mixed> = []
-
Optional. POST data array.
Return values
void —set $this->dom_id
get_elapsed_time()
Returns the time elapsed (in seconds) since the class was instantiated.
public
get_elapsed_time() : float
it doesn't use Datetime class chrono function,
Return values
float —Elapsed time in seconds.
get_error_count()
Checks if there are any error message.
public
get_error_count() : int|bool
Return values
int|bool —number of message, false otherwise.
get_error_list()
Returns the current error list.
public
get_error_list() : array<string|int, mixed>
Return values
array<string|int, mixed> —Error messages.
get_form_fields_name()
Generates a name for the group that will contain form fields.
public
get_form_fields_name([string $name = '' ]) : string
Parameters
- $name : string = ''
-
Optional. Suffix for the group name.
Return values
string —Group name.
get_index_relative_path()
Returns the relative path to the module's index page (public or admin).
public
get_index_relative_path() : string
Return values
string —Relative path to index.php.
get_message_list()
Returns the current message list.
public
get_message_list() : array<string|int, mixed>
Return values
array<string|int, mixed> —Informative messages.
get_multiple_tl()
returns an array with all identified texts, or the identifier in brackets if no text exists for this identifier $list is an array that contains another array like this: ['key'=>'string identifier' , 'replace'=>[...] ] replace can contain a word or an array of words each word will replace in order the numbered markers preceded by $ present in the text= if $join is specified, the result will be a string concatenated with this text instead of an array
public
get_multiple_tl(array<string|int, mixed> $list[, string|null $join = null ]) : array<string|int, mixed>|string
Parameters
- $list : array<string|int, mixed>
-
List of translation keys and replacements.
- $join : string|null = null
-
Optional. Join string for concatenation.
Return values
array<string|int, mixed>|string —Translated texts.
get_order_parenting()
Gets the next sort order value for a parent in the hierarchy table.
public
get_order_parenting(string $table[, int $id_parent = 0 ]) : int
Parameters
- $table : string
-
Table name.
- $id_parent : int = 0
-
Parent ID.
Return values
int —Next sort order value.
get_output()
Returns the HTML code to be displayed as output for this module.
public
get_output() : string
Return values
string —HTML output.
get_parent_data()
Gets parent data for a specified item in the hierarchy table.
public
get_parent_data(string $table, int $id) : array<string|int, mixed>|null
Parameters
- $table : string
-
Table name.
- $id : int
-
Item ID.
Return values
array<string|int, mixed>|null —Parent data or null if not found.
get_parent_id()
Gets the parent ID for a specified item in the hierarchy table.
public
get_parent_id(string $table, int $id) : int|null
Parameters
- $table : string
-
Table name.
- $id : int
-
Item ID.
Return values
int|null —Parent ID or null if not found.
get_raw_format()
Returns the raw format type for a given field type or name.
public
get_raw_format(string $nameOrType) : string
Parameters
- $nameOrType : string
-
Field type or name.
Return values
string —Raw format type ('int', 'float', 'string').
get_tl()
Returns the translated text for a given key, with optional replacements and pluralization.
public
get_tl([string $key = '' ][, mixed|null $replace = null ][, int|null $count_for_singular = null ][, bool $array = false ]) : string|array<string|int, mixed>
- return the identified text, or the identifier between braces if no text exists for this identifier $replace can contain a word or an array of words each word will replace in order the numbered markers preceded by $ present in the text $count_for_singular is used if the phrase needs to be converted to the plural or not based on a quantity. in this case : $key is plural (so $count_for_singular > 1) $key.'__none' matches none (so $count_for_singular == 0) $key.'__singular' matches the singular (i. e. $count_for_singular == 1)
variants with the suffixes ’__none' and ’_singular' must therefore exist in the tl file
Parameters
- $key : string = ''
-
Translation key.
- $replace : mixed|null = null
-
Optional. Replacement values.
- $count_for_singular : int|null = null
-
Optional. Quantity for pluralization.
- $array : bool = false
-
Optional. Return as array.
Return values
string|array<string|int, mixed> —Translated text.
get_translated_table_fields()
Returns translated field names for a table.
public
get_translated_table_fields(string $table, array<string|int, mixed> $fields) : array<string|int, mixed>
Parameters
- $table : string
-
Table name.
- $fields : array<string|int, mixed>
-
List of field names.
Return values
array<string|int, mixed> —Translated field names.
get_translated_text_from_other_module()
Gets a translated text from another module.
public
get_translated_text_from_other_module([string $module = '' ][, bool $admin = false ][, string $key = '' ][, mixed|null $replace = null ][, int|null $count_for_singular = null ]) : string
Parameters
- $module : string = ''
-
Module name.
- $admin : bool = false
-
Whether to use admin translations.
- $key : string = ''
-
Translation key.
- $replace : mixed|null = null
-
Optional. Replacement values.
- $count_for_singular : int|null = null
-
Optional. Quantity for pluralization.
Return values
string —Translated text.
group_has_access()
check if user has right to access depending group restriction
public
group_has_access(string $field_identifier, int $id_item) : bool
Item from a module can be access restricted depending group. If item is not restricted will return true. If item is restricted, will check if user belongs to group with access.
Parameters
- $field_identifier : string
-
Identify the field like "my_table-id"
- $id_item : int
-
ID of the field
Return values
bool —User right to access
has_any_message()
Checks if there are any error or message popups to display.
public
has_any_message() : bool
Return values
bool —True if there are messages or errors, false otherwise.
has_data_tree()
Checks if the specified table has a data tree structure.
public
has_data_tree(string $table) : bool
shortcut for module_has_data_tree with current module name
Parameters
- $table : string
-
Table name.
Return values
bool —True if data tree exists, false otherwise.
init_form_fields()
kept for compatibility.
public
init_form_fields([string $name = '' ]) : mixed
required fields are now directly into the form function from H class initialise required fields by default in all forms of the module
Parameters
- $name : string = ''
-
Optional. Suffix for the group name.
Return values
mixed —Form fields group object.
input_long_translation()
Creates translation textarea for a long text field.
public
input_long_translation(array<string|int, mixed> $attributes, int $id, array<string|int, mixed> &$post) : mixed
the first value of the array is the label of the field
Parameters
- $attributes : array<string|int, mixed>
-
Input attributes.
- $id : int
-
Item ID.
- $post : array<string|int, mixed>
-
Reference to the POST data array.
Return values
mixed —Textarea field object.
input_short_translation()
Creates translation inputs for a short text field.
public
input_short_translation(array<string|int, mixed> $attributes, int $id, array<string|int, mixed> &$post) : mixed
the first value of the array is the label of the field
Parameters
- $attributes : array<string|int, mixed>
-
Input attributes.
- $id : int
-
Item ID.
- $post : array<string|int, mixed>
-
Reference to the POST data array.
Return values
mixed —Input field object.
integrate_module()
Integrates another module's HTML output into the current module when no Hcode possible be careful, this function use the HTLM 4 Parser, but have been improved to support most of html5 https://www.php.net/manual/en/domdocument.loadhtml.php
public
integrate_module(string $data) : string
Parameters
- $data : string
-
HTML data containing module references.
Return values
string —Modified HTML with integrated modules.
load_options()
Loads options for this module from the main config file.
public
load_options() : void
Executed at starting of the module
load_settings_data()
Loads settings data for the current module from settings module DB if it's installed.
public
load_settings_data() : void
load_translation_files()
Loads translation files for the module.
public
load_translation_files(string|false $module_path) : void
Parameters
- $module_path : string|false
-
Optional. Path to the module.
module_data_tree()
public
static module_data_tree(mixed $module[, mixed $table = 'data' ][, mixed $display_field = 'name' ][, mixed $id_parent = 0 ][, mixed $linear = false ][, mixed $ignore = false ]) : mixed
Parameters
- $module : mixed
- $table : mixed = 'data'
- $display_field : mixed = 'name'
- $id_parent : mixed = 0
- $linear : mixed = false
- $ignore : mixed = false
module_data_tree_for_select()
Generates a data tree for a module's table for use in a select input.
public
static module_data_tree_for_select(string $module[, string $table = 'data' ][, string $display_field = 'name' ][, int $id_parent = 0 ][, array<string|int, mixed>|null $options = null ]) : array<string|int, mixed>
Parameters
- $module : string
-
Module name.
- $table : string = 'data'
-
Table name.
- $display_field : string = 'name'
-
Field name to display.
- $id_parent : int = 0
-
Root parent ID.
- $options : array<string|int, mixed>|null = null
-
Optional. Additional options.
Return values
array<string|int, mixed> —Data tree for select.
module_has_data_tree()
Checks if a module's table has a data tree structure.
public
static module_has_data_tree(string $module, string $table) : bool
Parameters
- $module : string
-
Module name.
- $table : string
-
Table name.
Return values
bool —True if data tree exists, false otherwise.
module_load_options()
Loads options for a given module from the configuration.
public
static module_load_options(string $module) : array<string|int, mixed>|false
used to check options from another module than current one.
Parameters
- $module : string
-
Module name.
Return values
array<string|int, mixed>|false —Options array or false if not found.
parse_hcode()
Parses Hcode tags in HTML and replaces them with module outputs.
public
parse_hcode([string $str_html = '' ][, bool $admin = false ]) : string
The Hcode is simple, it's a string indicating the module and params to execute, then the result is inclued inside the current one. exemple : [module|action=display&id=1] will call the module and request post with action = display & id=1. the html module code with be parsed / returned to the current one and display at the place was the hcode.
Parameters
- $str_html : string = ''
-
HTML string containing Hcode tags.
- $admin : bool = false
-
indicates if the loaded module need to be from admin side
Return values
string —HTML with parsed Hcode.
prepare_fields()
Prepares fields for editing forms by checking posted data and applying database values if there is an posted ID.
public
prepare_fields(array<string|int, mixed> &$post, string $table) : void
shorcut for check_posted_data + apply_bdd_data
Parameters
- $post : array<string|int, mixed>
-
Reference to the POST data array.
- $table : string
-
Table name.
Return values
void —$post will be filled.
prepare_group_query_part()
Prepares the SQL query part for group-based access restrictions.
public
prepare_group_query_part(string $field_identifier, int $id) : string
Parameters
- $field_identifier : string
-
Field identifier.
- $id : int
-
Item ID.
Return values
string —SQL query part to add in the query to limit depending group
prepare_module()
Prepares the module with its name and admin status.
public
prepare_module(string $newName, bool $isadmin) : void
Parameters
- $newName : string
-
New module name.
- $isadmin : bool
-
Whether the module is in admin mode.
process_data()
Main method for processing input data and handling module actions.
public
process_data(array<string|int, mixed> &$post) : bool
Handles form submissions, translation, autocomplete, TinyMCE uploads, quick edit, prepare javascript init, etc....
IMPORTANT: the & before $post makes it a pointer to the original variable which is then updated directly
Parameters
- $post : array<string|int, mixed>
-
Reference to the POST data array.
Return values
bool —True if processing succeeded, false otherwise.
publish_output()
Publishes the output, either integrating into core content or echoing directly.
public
publish_output() : void
quick_edit_update()
Validates and saves a quick edit update for a field.
public
quick_edit_update(int $id, mixed $value, string $type_index, string $field_data[, int $id_lang_data = 0 ]) : mixed
Parameters
- $id : int
-
Item ID.
- $value : mixed
-
New value.
- $type_index : string
-
Type index string.
- $field_data : string
-
Encrypted field data.
- $id_lang_data : int = 0
-
Optional. Language data ID.
Return values
mixed —Result of the update operation.
receive_tinymce_file()
Handles TinyMCE file uploads for the module.
public
receive_tinymce_file() : void
Tags
recurse_tree()
Recursively builds a tree structure for a module's table.
public
static recurse_tree(string $module, string $table, string $display_field[, int $id_parent = 0 ][, bool $linear = false ][, array<string|int, mixed>|false $ignore = false ][, int $level = 0 ]) : array<string|int, mixed>
Parameters
- $module : string
-
Module name.
- $table : string
-
Table name.
- $display_field : string
-
Field name to display.
- $id_parent : int = 0
-
Parent ID.
- $linear : bool = false
-
If true, returns a linear list; else recursive tree.
- $ignore : array<string|int, mixed>|false = false
-
List of IDs to ignore.
- $level : int = 0
-
Recursion level.
Return values
array<string|int, mixed> —Tree structure.
reset_fields()
Resets all fields in $post according to their type in the database.
public
reset_fields(array<string|int, mixed> &$post, string $table[, array<string|int, mixed>|false $fields = false ]) : void
Parameters
- $post : array<string|int, mixed>
-
Reference to the POST data array.
- $table : string
-
Table name.
- $fields : array<string|int, mixed>|false = false
-
Optional. List of fields to reset.
sync_messages_with()
Synchronizes error and message lists with another module instance.
public
sync_messages_with(HelPHP_module $moduleInstance) : void
Parameters
- $moduleInstance : HelPHP_module
-
The module instance to sync with.
sync_with_user()
Synchronizes error and message lists with the global user object to check connection etc.
public
sync_with_user() : void
translate_block()
Generates a translation block with inputs for multiple languages.
public
translate_block(array<string|int, mixed> &$post, array<string|int, mixed> $fields, string $types[, array<string|int, mixed>|false $attributes = false ]) : mixed
Parameters
- $post : array<string|int, mixed>
-
Reference to the POST data array.
- $fields : array<string|int, mixed>
-
List of field names.
- $types : string
-
String of types ('s' for short, 'l' for long).
- $attributes : array<string|int, mixed>|false = false
-
Optional. Additional attributes.
Return values
mixed —Translation block object.
user_query_part()
Returns the SQL query part to limit results to the current user.
public
user_query_part([string|false $field = false ]) : string
Parameters
- $field : string|false = false
-
Optional. Field name to check.
Return values
string —SQL query part.