Conn2Flow
Docs navigation

Reference / Libraries

pagina.php library

Shortcuts over $_GESTOR['pagina']: cutting cells, replacing global variables and masking markers for the database.

Path in the Gestor bibliotecas/pagina.php

pagina.php gathers shortcuts over $_GESTOR['pagina'], the HTML of the page the module is building, and over the global variable markers. Every function is a thin layer over the modelo.php library.

It is not loaded by default. Request pagina in the module JSON (admin-paginas, pages-index and publisher-pages do this) or use gestor_incluir_biblioteca('pagina').

Global variable markers

The markers are defined in gestor/config.php:

$_GESTOR['variavel-global'] key Value Use
open / close @[[ / ]]@ Form stored in the database and resolved at runtime
openText / closeText [[ / ]] Form typed by users in the editors

Page cells

  • pagina_celula($nome, $comentario = false, $apagar = false) cuts the <!-- name < -->…<!-- name > --> block out of $_GESTOR['pagina'] and returns its content. In its place it leaves the <!-- name --> marker (to re-insert with pagina_celula_incluir()), or nothing when $apagar is true. With $comentario = true, the block format becomes <!-- name [[ … ]] name --> and the marker left behind is <!-- [[name]] -->.

  • pagina_celula_incluir($celula, $valor) inserts $valor before the <!-- cell --> marker and keeps the marker, so it can be called in a loop to repeat rows.

Replacing global variables

  • pagina_trocar_variavel_valor($variavel, $valor, $variavelEspecifica = false) replaces @[[variable]]@ with $valor across $_GESTOR['pagina']. With $variavelEspecifica = true, it looks for the literal string $variavel without adding the markers.

  • pagina_celula_trocar_variavel_valor($celula, $variavel, $valor, $variavelEspecifica = false) does the same on a cell string and returns the result (a null value becomes empty).

  • pagina_trocar_variavel(['codigo' => …, 'variavel' => …, 'valor' => …]) does the same on any string. It returns null when any of the three parameters is missing.

All three use modelo_var_troca_tudo(): they replace every occurrence, case-insensitively. pagina_trocar_variavel_valor() does nothing when $valor is null.

Masking for the database

  • pagina_variaveis_globais_mascarar(['valor' => …]) turns [[x]] into @[[x]]@: this is what happens when an editor saves content typed by the user.

  • pagina_variaveis_globais_desmascarar(['valor' => …]) does the reverse, @[[x]]@ → [[x]], for display in the editor.

None of the variable functions has callers in the core today. Modules do the same work directly with modelo_var_troca_tudo() and preg_replace().

See also

Functions (generated reference)

Generated from gestor/bibliotecas/pagina.php · 7 functions

7 of 7

pagina_celula

view source · line 39 ↗
pagina_celula(string $nome, bool $comentario = false, bool $apagar = false): string

Extrai e processa célula de conteúdo da página.

Parameters

$nomestring
Nome da célula a extrair (obrigatório).
$comentariobool
Se true, usa formato [[ ]], senão usa < > (padrão: false).
$apagarbool
Se true, remove célula completamente, senão deixa marcador (padrão: false).

Returns

string
Conteúdo da célula ou string vazia.

pagina_celula_trocar_variavel_valor

view source · line 75 ↗
pagina_celula_trocar_variavel_valor(string $celula, string $variavel, string $valor, bool $variavelEspecifica = false): string

Substitui variável por valor em célula específica.

Parameters

$celulastring
Conteúdo da célula (obrigatório).
$variavelstring
Nome da variável (obrigatório).
$valorstring
Valor para substituir (opcional).
$variavelEspecificabool
Se true, usa variável literal sem marcadores (padrão: false).

Returns

string
Célula com variável substituída.

pagina_celula_incluir

view source · line 106 ↗
pagina_celula_incluir(string $celula, string $valor): void

Inclui célula de conteúdo na página.

Parameters

$celulastring
Nome da célula (obrigatório).
$valorstring
Valor a inserir (obrigatório).

Returns

void

pagina_trocar_variavel_valor

view source · line 128 ↗
pagina_trocar_variavel_valor(string $variavel, string $valor, bool $variavelEspecifica = false): void

Substitui variável por valor na página.

Parameters

$variavelstring
Nome da variável (obrigatório).
$valorstring
Valor para substituir (obrigatório).
$variavelEspecificabool
Se true, usa variável literal sem marcadores (padrão: false).

Returns

void

pagina_trocar_variavel

view source · line 160 ↗
pagina_trocar_variavel(array|false $params = false): string|null

Substitui variável por valor em código arbitrário.

Parameters

$paramsarray|false
Parâmetros da função.

Returns

string|null
Código com variável substituída ou null.

The Future is Hybrid: Human + AI.

Conn2Flow is the tool. If you need the Architect to design your company's strategy using this technology...

Hire Specialized Consulting