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 withpagina_celula_incluir()), or nothing when$apagaristrue. With$comentario = true, the block format becomes<!-- name [[ … ]] name -->and the marker left behind is<!-- [[name]] -->. -
pagina_celula_incluir($celula, $valor)inserts$valorbefore 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$valoracross$_GESTOR['pagina']. With$variavelEspecifica = true, it looks for the literal string$variavelwithout adding the markers. -
pagina_celula_trocar_variavel_valor($celula, $variavel, $valor, $variavelEspecifica = false)does the same on a cell string and returns the result (anullvalue becomes empty). -
pagina_trocar_variavel(['codigo' => …, 'variavel' => …, 'valor' => …])does the same on any string. It returnsnullwhen 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
pagina_celula
view source · line 39 ↗pagina_celula(string $nome, bool $comentario = false, bool $apagar = false): stringExtrai 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
pagina_celula_trocar_variavel_valor
view source · line 75 ↗pagina_celula_trocar_variavel_valor(string $celula, string $variavel, string $valor, bool $variavelEspecifica = false): stringSubstitui 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
pagina_celula_incluir
view source · line 106 ↗pagina_celula_incluir(string $celula, string $valor): voidInclui célula de conteúdo na página.
Parameters
$celulastring- Nome da célula (obrigatório).
$valorstring- Valor a inserir (obrigatório).
Returns
pagina_trocar_variavel_valor
view source · line 128 ↗pagina_trocar_variavel_valor(string $variavel, string $valor, bool $variavelEspecifica = false): voidSubstitui 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
pagina_trocar_variavel
view source · line 160 ↗pagina_trocar_variavel(array|false $params = false): string|nullSubstitui variável por valor em código arbitrário.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
pagina_variaveis_globais_mascarar
view source · line 189 ↗pagina_variaveis_globais_mascarar(array|false $params = false): stringMascara variáveis globais para armazenamento em banco.
Parameters
$paramsarray|false- Parâmetros da função.
Returns
pagina_variaveis_globais_desmascarar
view source · line 223 ↗pagina_variaveis_globais_desmascarar(array|false $params = false): stringDesmascara variáveis globais vindas do banco.
Parameters
$paramsarray|false- Parâmetros da função.
Returns