HtmlTag
extends AbstractCollecteur
in package
Collecter de balises html `<xx> ... </xx>` d'un texte
Tags
Table of Contents
Properties
- $listeBalisesAProteger : array<string|int, mixed>
- $listeBalisesBloc : array<string|int, mixed>
- $echappeBase64Id : string
- $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
- echappeBase64Class() : string
- Definir un nom de class base64- non predictible, en fonction de la source
- 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 il est implicite que les occurences sont triées dans l'ordre d'apparition (telles que fournies par le collecteur)
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']
$echappeBase64Id
protected
static string
$echappeBase64Id
$lowercase_tag
protected
string
$lowercase_tag
$markId
protected
string
$markId
$markPrefix
protected
static string
$markPrefix
= 'HTMLTAG'
$preg_closingtag
protected
string
$preg_closingtag
$preg_openingtag
La preg pour découper et collecter les modèles
protected
string
$preg_openingtag
$tag
protected
string
$tag
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{detecter_presence?: bool, nb_max?: int, profondeur?: int} $options = [] ]) : array<string|int, mixed>
Parameters
- $texte : string
- $options : array{detecter_presence?: bool, nb_max?: int, profondeur?: int} = []
Attributes
- #[Override]
Return values
array<string|int, mixed>detecter()
public
detecter(mixed $texte) : bool
Parameters
- $texte : mixed
Return values
boolechappementHtmlBase64()
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
stringechappementTexteContientBaliseBloc()
Detecter si un texte contient des balises bloc ou non
public
static echappementTexteContientBaliseBloc(string $texte) : bool
Parameters
- $texte : string
Return values
boolechapper()
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
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
stringproteger_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
stringremplacer()
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
stringretablir()
Retablir les occurences échappées précédemment
public
retablir(string $texte) : string
Parameters
- $texte : string
Tags
Return values
stringretablir_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
Return values
stringcollecteur()
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>echappeBase64Class()
Definir un nom de class base64- non predictible, en fonction de la source
protected
static echappeBase64Class(string $source) : string
Parameters
- $source : string
Tags
Return values
stringsanitizer_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
Return values
array<string|int, mixed>remplacer_collection()
Remplacer les occurrences de la collection d’un texte par un contenu donné en callback il est implicite que les occurences sont triées dans l'ordre d'apparition (telles que fournies par le collecteur)
private
static remplacer_collection(string $texte, array<string|int, mixed> $collection, callable $callback) : string
Parameters
- $texte : string
- $collection : array<string|int, mixed>
- $callback : callable