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>
- $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() : array<string|int, mixed>
- 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
- 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
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']
$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<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $texte : string
- $options : array<string|int, mixed> = []
-
bool $detecter_presence bool $nb_max int $profondeur
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<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $texte : string
- $options : array<string|int, mixed> = []
-
string $sanitize_callback
Tags
Return values
array<string|int, mixed> —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> = []
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
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 = '' ][, string $filtre = '' ]) : string
Parameters
- $texte : string
- $source : string = ''
- $filtre : string = ''
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>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