Documentation du code de SPIP et de ses plugins

SPIP

HtmlTag extends AbstractCollecteur
in package

Collecter de balises html `<xx> ... </xx>` d'un texte

Tags
see
extraire_balises()

Table of Contents

Properties

$listeBalisesAProteger  : array<string|int, mixed>
$listeBalisesBloc  : array<string|int, mixed>
$lowercase_tag  : string
$markId  : string
$markPrefix  : string
$preg_closingtag  : string
$preg_openingtag  : string
La preg pour découper et collecter les modèles
$tag  : string

Methods

__construct()  : mixed
collecter()  : array<string|int, mixed>
detecter()  : bool
echappementHtmlBase64()  : string
Creer un bloc base64 correspondant a $texte ; au besoin en marquant une $source differente ; si $isBloc n'est pas fourni, le script detecte automagiquement si ce qu'on echappe est un div ou un span
echappementTexteContientBaliseBloc()  : bool
Detecter si un texte contient des balises bloc ou non
echapper()  : string
Echapper les occurences de la collecte par un texte neutre du point de vue HTML
echapper_enHtmlBase64()  : string
proteger_balisesHtml()  : string
pour $source voir commentaire infra (echappe_retour) pour $no_transform voir le filtre post_autobr dans inc/filtres
remplacer()  : string
Remplacer les occurrences de la collecte par un contenu donné en callback
retablir()  : string
Retablir les occurences échappées précédemment
retablir_depuisHtmlBase64()  : string
Rétablir les contenus échappés dans un texte en <(div|span) class="base64..."></(div|span)> Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes par propre() : exemple dans multi et dans typo()
collecteur()  : array<string|int, mixed>
Collecteur générique des occurences d'une preg dans un texte avec leurs positions et longueur
sanitizer_collection()  : array<string|int, mixed>
Sanitizer une collection d'occurences
remplacer_collection()  : string
Remplacer les occurrences de la collection d’un texte par un contenu donné en callback

Properties

$listeBalisesAProteger

public static array<string|int, mixed> $listeBalisesAProteger = ['html', 'pre', 'code', 'cadre', 'frame', 'script', 'style']

$listeBalisesBloc

public static array<string|int, mixed> $listeBalisesBloc = ['address', 'applet', 'article', 'aside', 'blockquote', 'button', 'center', 'dl', 'dt', 'dd', 'div', 'fieldset', 'figure', 'figcaption', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'hgroup', 'head', 'header', 'iframe', 'li', 'map', 'marquee', 'nav', 'noscript', 'object', 'ol', 'pre', 'section', 'table', 'tr', 'td', 'th', 'tbody', 'foot', 'textarea', 'ul', 'script', 'style']

$markPrefix

protected static string $markPrefix = 'HTMLTAG'

$preg_openingtag

La preg pour découper et collecter les modèles

protected string $preg_openingtag

Methods

__construct()

public __construct(string $tag[, string|null $preg_openingtag = null ][, string|null $preg_closingtag = null ]) : mixed
Parameters
$tag : string
$preg_openingtag : string|null = null
$preg_closingtag : string|null = null

collecter()

public collecter(string $texte[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
$texte : string
$options : array<string|int, mixed> = []

bool $detecter_presence bool $nb_max int $profondeur

Attributes
#[Override]
Return values
array<string|int, mixed>

echappementHtmlBase64()

Creer un bloc base64 correspondant a $texte ; au besoin en marquant une $source differente ; si $isBloc n'est pas fourni, le script detecte automagiquement si ce qu'on echappe est un div ou un span

public static echappementHtmlBase64(string $texte[, string $source = '' ][, bool|null $isBloc = null ][, array<string|int, mixed> $attributs = [] ]) : string
Parameters
$texte : string
$source : string = ''
$isBloc : bool|null = null
$attributs : array<string|int, mixed> = []
Return values
string

echappementTexteContientBaliseBloc()

Detecter si un texte contient des balises bloc ou non

public static echappementTexteContientBaliseBloc(string $texte) : bool
Parameters
$texte : string
Return values
bool

echapper()

Echapper les occurences de la collecte par un texte neutre du point de vue HTML

public echapper(string $texte[, array{sanitize_callback?: string} $options = [] ]) : string
Parameters
$texte : string
$options : array{sanitize_callback?: string} = []
Tags
see
retablir()
Return values
string

texte, marqueur utilise pour echapper les modeles

echapper_enHtmlBase64()

public echapper_enHtmlBase64(string $texte[, string $source = '' ][, callable|null $callback_function = null ][, array<string|int, mixed> $callback_options = [] ]) : string
Parameters
$texte : string
$source : string = ''
$callback_function : callable|null = null
$callback_options : array<string|int, mixed> = []
Attributes
#[Override]
Return values
string

proteger_balisesHtml()

pour $source voir commentaire infra (echappe_retour) pour $no_transform voir le filtre post_autobr dans inc/filtres

public static proteger_balisesHtml(string $texte[, string $source = '' ][, array<string|int, mixed>|null $html_tags = null ][, array<string|int, mixed> $callbacks_function = [] ][, array<string|int, mixed> $callback_options = [] ]) : string
Parameters
$texte : string
$source : string = ''
$html_tags : array<string|int, mixed>|null = null
$callbacks_function : array<string|int, mixed> = []
$callback_options : array<string|int, mixed> = []
Return values
string

remplacer()

Remplacer les occurrences de la collecte par un contenu donné en callback

public remplacer(string $texte, callable $callback[, array<string|int, mixed> $options = [] ]) : string

Chaque occurrence est passée en callback avec son contenu brut et les informations de la collecte la callback doit retourner le contenu à remplacer pour l'occurrence.

Parameters
$texte : string
$callback : callable
$options : array<string|int, mixed> = []
Return values
string

retablir()

Retablir les occurences échappées précédemment

public retablir(string $texte) : string
Parameters
$texte : string
Tags
see
echapper()
Return values
string

retablir_depuisHtmlBase64()

Rétablir les contenus échappés dans un texte en <(div|span) class="base64..."></(div|span)> Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes par propre() : exemple dans multi et dans typo()

public static retablir_depuisHtmlBase64(string $texte[, string $source = '' ][, callable|null $filtre = null ]) : string
Parameters
$texte : string
$source : string = ''
$filtre : callable|null = null
Tags
see
echappementHtmlBase64()
Return values
string

collecteur()

Collecteur générique des occurences d'une preg dans un texte avec leurs positions et longueur

protected static collecteur(string $texte, string $if_chars, string $start_with, string $preg[, int $max_items = 0 ]) : array<string|int, mixed>
Parameters
$texte : string

texte à analyser pour la collecte

$if_chars : string

caractere(s) à tester avant de tenter la preg

$start_with : string

caractere(s) par lesquels commencent l'expression recherchée (permet de démarrer la preg à la prochaine occurence de cette chaine)

$preg : string

preg utilisée pour la collecte

$max_items : int = 0

pour limiter le nombre de preg collectée (pour la detection simple de présence par exemple)

Return values
array<string|int, mixed>

sanitizer_collection()

Sanitizer une collection d'occurences

protected sanitizer_collection(array<string|int, mixed> $collection, string $sanitize_callback) : array<string|int, mixed>
Parameters
$collection : array<string|int, mixed>
$sanitize_callback : string
Tags
note

Cette méthode est souvent surchargée pour pouvoir sanitizer une partie texte sur un collecteur spécifique, par exemple le texte d’un lien, le texte des multis... Cela ne traite pas forcément donc l’ensemble de la chaine brute. Le collecteur de modèle ne sanitise rien par exemple (sous entendu que les modèles s’en occupent eux-mêmes)

Return values
array<string|int, mixed>

remplacer_collection()

Remplacer les occurrences de la collection d’un texte par un contenu donné en callback

private remplacer_collection(string $texte, array<string|int, mixed> $collection, callable $callback) : string
Parameters
$texte : string
$collection : array<string|int, mixed>
$callback : callable
Tags
note

On n’altère pas actuellement le texte (raw) et longeurs (length), du tableau de collecte ; ça pourrait être une option.

Return values
string

        
On this page

Search results