API - XOOPS 2.5.11 Beta 2
By monxoops.fr
Highlighter Class Reference

Static Public Member Functions

static apply ($words, $body, $pre='< mark >', $post='</mark >')
 

Data Fields

const ENCODING = 'UTF-8'
 

Static Protected Member Functions

static splitOnTag ($needle, $haystack, $pre, $post)
 

Member Function Documentation

◆ apply()

static apply (   $words,
  $body,
  $pre = '<mark>',
  $post = '</mark>' 
)
static

Apply highlight to words in body text

Surround occurrences of words in body with pre in front and post behind. Considers only occurrences of words outside of HTML tags.

Parameters
string | string[]$wordswords to highlight
string$bodybody of html text to highlight
string$prestring to begin a highlight
string$poststring to end a highlight
Returns
string highlighted body

◆ splitOnTag()

static splitOnTag (   $needle,
  $haystack,
  $pre,
  $post 
)
staticprotected

find needle in between html tags and add highlighting

Parameters
string$needlestring to find
string$haystackhtml text to find needle in
string$preinsert before needle
string$postinsert after needle
Returns
mixed return from preg_replace_callback()

Field Documentation

◆ ENCODING

const ENCODING = 'UTF-8'

mbstring encoding


The documentation for this class was generated from the following file: