Path in the Gestor bibliotecas/html.php
A DOM editing session over HTML, kept in the $_HTML['dom'] global: it opens a snippet, changes elements selected by CSS class and returns the HTML. Today only configuracao.php uses it, to hide elements (the escondido class) on configuration screens; the rest of the Gestor works with strings through modelo.php.
gestor_incluir_biblioteca('html');
html_iniciar(['valor' => $snippet]); // or ['gestor' => true] to use $_GESTOR['pagina']
html_adicionar_classe(['consulta' => 'field', 'classe' => 'required']);
html_atributo(['opcao' => 'mudar', 'consulta' => 'field', 'atributo' => 'data-id', 'valor' => '7']);
$snippet = html_finalizar(); // or ['gestor' => true] to write into $_GESTOR['pagina']| Function | |
|---|---|
html_iniciar(['valor' => … \| 'gestor' => true]) |
Loads the HTML into a DOMDocument |
html_atributo(['opcao' => 'valor'\|'mudar', 'consulta', 'atributo', 'valor']) |
Reads the attribute of the first element with the class, or writes it on all of them |
html_valor(['opcao' => 'mudar', 'consulta', 'valor']) |
Replaces the text (nodeValue) of every element with the class |
html_adicionar_classe(['consulta', 'classe']) |
Adds a class |
html_elemento(['opcao' => 'excluir', 'consulta']) |
Removes every element with the class |
html_consulta(['valor' => '//xpath']) |
Free XPath query; returns a DOMNodeList |
html_finalizar(['gestor' => true]) |
Serializes, strips the <html><body> the DOM adds and releases the session |
html_beautify($html) |
Indents with the tidy extension; returns a tidy object |
consulta is always a class name (not a CSS selector) and goes into the XPath unescaped.
Other side effects:
-
html_adicionar_classe()reads theclassof the first element and writes it, with the new class, to every matching element: the other elements' own classes are replaced. -
html_iniciar()usesmb_convert_encoding(…, 'HTML-ENTITIES'), deprecated in PHP 8.2 (it raises a deprecation notice). -
DOMDocumentrepairs the HTML: it closes tags, moves elements and wraps loose text. The output may not match the input byte for byte. -
html_beautify()appliesstripslashes()first, which deletes backslashes from the content. It has no callers.
Functions
Generated from gestor/bibliotecas/html.php · 8 functions
html_iniciar
view source · line 35 ↗html_iniciar(array|false $params = false): voidInicializa objeto DOMDocument para manipulação HTML.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
html_finalizar
view source · line 70 ↗html_finalizar(array|false $params = false): string|voidFinaliza e retorna HTML do objeto DOM.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
html_consulta
view source · line 113 ↗html_consulta(array|false $params = false): DOMNodeListExecuta consulta XPath no objeto DOM.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
html_atributo
view source · line 145 ↗html_atributo(array|false $params = false): string|voidManipula atributos de elementos HTML.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
html_valor
view source · line 202 ↗html_valor(array|false $params = false): voidManipula valor (nodeValue) de elementos HTML.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
html_adicionar_classe
view source · line 246 ↗html_adicionar_classe(array|false $params = false): voidAdiciona classe CSS a elemento.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
html_elemento
view source · line 287 ↗html_elemento(array|false $params = false): voidManipula estrutura de elementos HTML.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
html_beautify
view source · line 325 ↗html_beautify(string $html): tidyFormata e embeleza HTML usando Tidy.
Parameters
$htmlstring- HTML a formatar.
Returns