Conn2Flow
Docs navigation

Reference / Libraries

sitemap.php library

Generation and incremental updates of sitemap.xml and robots.txt: which pages go in, where the files live and when they are updated.

Path in the Gestor bibliotecas/sitemap.php

Maintains the site's sitemap.xml and robots.txt. Both live in gestor/assets/ and are served by the arquivo-estatico controller at https://<domain>/sitemap.xml and /robots.txt, with no dependency on server rewrite rules. An old sitemap.xml at the Gestor root, if the core generated it, is deleted on the next write; a hand-made one is preserved.

Which pages go in

sitemap_pagina_elegivel($page) requires:

  • status='A' and sem_permissao (public page; the whole admin panel stays out);

  • a path that is not a Gestor system route nor a flow route (sitemap_caminho_nao_indexavel()): OAuth callbacks, signin-2fa, validate-user, form processors, pagina-de-impressao, any path starting with admin-, and outcome pages whose last segment is or ends in confirmation, success, error, failure, cancel, cancelled or canceled (contact-success, checkout/error), plus …/payment, …/checkout, …/processing and …/download in compound paths, and the purchase flow: last segment cart or checkout, or ending in -cart/-checkout (cart/, en/checkout/, subscription-checkout/, req-191);

  • being inside the data_publicacao_inicio/fim window.

/signin/, /signup/ and /forgot-password/ are included. The URL carries the language prefix when it is not the default (/en/docs/), and lastmod is the page's data_modificacao.

When it is updated

  • Incrementally, on every save, clone, delete or status change in admin-paginas, publisher-pages and Live Editor edits (sitemap_sincronizar_por_id(), which calls sitemap_sincronizar_pagina()): only that page's URL is added, changed or removed. If the path changed, the old URL goes out before the new one comes in.

  • Fully (sitemap_gerar_completo()), only when the file does not exist, is corrupted or the edited page vanished from the database. A full generation also rewrites robots.txt.

robots.txt

sitemap_robots_montar() blocks the utility routes (/_gestor-cookie-verify, /oauth-callback, /signin-2fa, /forms-submissions-process…) and declares Sitemap: <url>/sitemap.xml. It accepts extra disallow entries.

XML functions

sitemap_xml_montar($urls), sitemap_xml_upsert($xml, $loc, $lastmod) and sitemap_xml_remover($xml, $loc) are pure (text → text); sitemap_data_w3c() formats lastmod. sitemap_url_da_pagina(), sitemap_caminho_arquivo(), sitemap_robots_caminho_arquivo(), sitemap_gravar(), sitemap_robots_gravar(), sitemap_conteudo_proprio() and sitemap_legado_remover() handle the URL and the disk.

Functions

Generated from gestor/bibliotecas/sitemap.php · 17 functions

17 of 17

sitemap_pagina_elegivel

view source · line 41 ↗
sitemap_pagina_elegivel(array $pagina, int|null $agora = null): bool

Decide se uma página entra no sitemap.

Parameters

$paginaarray
Linha da tabela paginas.
$agoraint|null
Timestamp de referência (padrão: time()), usado nos testes.

Returns

bool

sitemap_xml_montar

view source · line 265 ↗
sitemap_xml_montar(array $urls = Array()): string

Monta o documento completo do sitemap a partir de uma lista de URLs.

Parameters

$urlsarray
Lista de ['loc' => string, 'lastmod' => string|null].

Returns

string
XML pronto para gravação.

sitemap_data_w3c

view source · line 294 ↗
sitemap_data_w3c(string|null $data = null): string|null

Converte uma data do banco para o formato W3C exigido pelo protocolo de sitemap.

Parameters

$datastring|null

Returns

string|null
null quando a data é inválida ou ausente (a tag é então omitida).

sitemap_xml_upsert

view source · line 314 ↗
sitemap_xml_upsert(string $xml, string $loc, string|null $lastmod = null): string

Insere ou atualiza a entrada de uma URL num sitemap existente (upsert incremental).

Parameters

$xmlstring
XML atual.
$locstring
URL absoluta da página.
$lastmodstring|null
Data de modificação.

Returns

string
XML atualizado.

sitemap_xml_remover

view source · line 345 ↗
sitemap_xml_remover(string $xml, string $loc): string

Remove a entrada de uma URL do sitemap (página excluída, despublicada ou que virou privada).

Parameters

$xmlstring
XML atual.
$locstring
URL absoluta a remover.

Returns

string
XML sem a entrada.

sitemap_url_da_pagina

view source · line 406 ↗
sitemap_url_da_pagina(array $pagina): string

URL pública absoluta de uma página, respeitando o prefixo de idioma quando não for o padrão.

Parameters

$paginaarray
Linha da tabela paginas.

Returns

string

sitemap_sincronizar_pagina

view source · line 566 ↗
sitemap_sincronizar_pagina(array $pagina, bool $remover = false, $caminhoAntigo = null): bool

Sincroniza UMA página no sitemap, criando o arquivo do zero quando ele ainda não existe.

Parameters

$paginaarray
Linha (ou dados equivalentes) da página alterada.
$removerbool
Força a remoção da entrada (página excluída).
$caminhoAntigo

Returns

bool

sitemap_sincronizar_por_id

view source · line 606 ↗
sitemap_sincronizar_por_id(string $id, bool $remover = false, string|null $caminhoAntigo = null): bool

Recarrega os dados de uma página pelo identificador e sincroniza o sitemap.

Parameters

$idstring
Identificador textual da página.
$removerbool
$caminhoAntigostring|null
Caminho anterior, quando o slug mudou (req-112).

Returns

bool

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