Stud.IP  5.4
Markup Class Reference

Static Public Member Functions

static apply ($markup, $text, $trim)
 
static editorEnabled ()
 
static isHtml ($text)
 
static isHtmlFallback ($text)
 
static hasHtmlMarker ($text)
 
static markAsHtml ($text)
 
static purifyHtml ($html)
 
static htmlReady ( $text, $trim=true, $br=false, $double_encode=true)
 
static wysiwygReady ( $text, $trim=true, $br=false, $double_encode=true)
 
static markupToHtml ($text, $trim=true, $mark=true)
 
static removeHtml ($html)
 

Data Fields

const HTML_MARKER = '<!--HTML-->'
 
const HTML_MARKER_FALLBACK = '<!-- HTML: Insert text after this line only. -->'
 
const HTML_MARKER_REGEXP = '/^\s*<!--\s*HTML.*?-->/i'
 

Member Function Documentation

◆ apply()

static apply (   $markup,
  $text,
  $trim 
)
static

Apply markup rules and clean the text up.

Parameters
TextFormat$markupMarkup rules applied on marked-up text.
string$textMarked-up text on which rules are applied.
boolean$trimTrim text before applying markup rules, if TRUE.
Returns
string HTML code computed from marked-up text.

◆ editorEnabled()

static editorEnabled ( )
static

Return true if the WYSIWYG editor is enabled for this user.

Returns
boolean always returns true.

◆ hasHtmlMarker()

static hasHtmlMarker (   $text)
static

Return true for HTML code and false for plain text.

HTML code must start with a match for HTML_MARKER_REGEXP.

Parameters
string$textHTML code or plain text.
Returns
boolean true for HTML code, false for plain text.

◆ htmlReady()

static htmlReady (   $text,
  $trim = true,
  $br = false,
  $double_encode = true 
)
static

Convert special characters to HTML entities, and clean up.

Parameters
string$textThis text's special chars will be converted.
boolean$trimTrim text before applying markup rules, if TRUE.
boolean$brReplace newlines by
, if TRUE.
boolean$double_encodeEncode existing HTML entities, if TRUE.
Returns
string The converted string.

◆ isHtml()

static isHtml (   $text)
static

Return true for HTML code and false for plain text.

HTML code must either match HTML_MARKER_REGEXP or begin with '<' and end with '>' (leading and trailing whitespace is ignored). Everything else is considered to be plain text.

Parameters
string$textHTML code or plain text.
Returns
boolean true for HTML code, false for plain text.

◆ isHtmlFallback()

static isHtmlFallback (   $text)
static

Return true for Stud.IP-HTML and false otherwise.

Stud.IP-HTML is HTML that can contain Stud.IP Markup.

Stud.IP-HTML must match Stud.IP 3.2's HTML marker. Leading and trailing whitespace is ignored.

Everything else is considered not Stud.IP-HTML. In other words, if it's not Stud.IP-HTML it might be everything from plain text to binary code. But usually it's either Stud.IP markup or plain HTML code, then.

Parameters
string$textText that is or isn't Stud.IP-HTML.
Returns
boolean true for Stud.IP-HTML

◆ markAsHtml()

static markAsHtml (   $text)
static

Mark a given text as HTML code.

No sanity-checking is done on the given text. It is simply marked up so to be identified by Markup::isHtml as HTML code.

Parameters
string$textThe text to be marked up as HTML code.
Returns
string The text marked up as HTML code.

◆ markupToHtml()

static markupToHtml (   $text,
  $trim = true,
  $mark = true 
)
static

Convert Stud.IP markup (possibly mixed with HTML if fallback mode is enabled) to editable HTML. Pure HTML will only run through the purifier.

Parameters
string$textThe text.
boolean$trimTrim text before applying markup rules, if TRUE.
boolean$markMark result text as HTML, if TRUE.
Returns
string The converted string.

◆ purifyHtml()

static purifyHtml (   $html)
static

Call HTMLPurifier to filter the HTML code (if the source is detected to contain HTML, returns the argument unchanged otherwise). The HTML marker is restored afterwards, if it was present.

Parameters
string$dirty_htmlUnsafe or 'uncleaned' HTML code.
Returns
string Clean and safe HTML code.

◆ removeHtml()

static removeHtml (   $html)
static

Call HTMLPurifier to remove all HTML tags from the string (if the source is detected to contain HTML, returns the argument unchanged otherwise).

Parameters
string$htmlHTML code to filter
Returns
string The converted string.

◆ wysiwygReady()

static wysiwygReady (   $text,
  $trim = true,
  $br = false,
  $double_encode = true 
)
static

Prepare text for wysiwyg (if enabled), otherwise convert special characters using htmlReady.

Parameters
string$textThe text.
boolean$trimTrim text before applying markup rules, if TRUE.
boolean$brReplace newlines by
, if TRUE and wysiwyg editor disabled.
boolean$double_encodeEncode existing HTML entities, if TRUE and wysiwyg editor disabled.
Returns
string The converted string.

Field Documentation

◆ HTML_MARKER

const HTML_MARKER = '<!--HTML-->'

◆ HTML_MARKER_FALLBACK

const HTML_MARKER_FALLBACK = '<!-- HTML: Insert text after this line only. -->'

◆ HTML_MARKER_REGEXP

const HTML_MARKER_REGEXP = '/^\s*<!--\s*HTML.*?-->/i'

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