KWeb  6.4
TextFormat Class Reference

Various text formatting functions and helpers. More...

Public Member Functions

 safeFilename ($file)
 Makes filenames safe to use.

Static Public Member Functions

static prepareTextTypes (&$html, &$plain, $forceHtml=false)
 Uzupełnia formaty wiadomości.
static plainToHtml ($text)
static htmlToPlain ($text, $leaveHeaders=true, $leaveLinks=true, $htmlSafe=false)
static compressWhitespace ($text, $removeNewLines=false)
static htmlStrip ($html, $allowedTags= 'b|strong|i|u|br|span|img|div|hr|h\d|a|code|blockquote|ul|li|ol|p', $allowedParams= 'align|class|src|border|size|width|height|href|target')
static htmlCleanup ($html, $tags= 'font|script', $params= '(on[\w]+)|bgcolor|border', $styles= 'font-family|font-size|color|background', $shortTags= 'br|img')
static htmlFirstParagraph ($html)
static handleTextParser_htmlCleanup ($parser)
static replaceLinks ($txt)
static safeEmail ($email, $link=true)
static safeString ($str, $replacement= '_', $allowChars= '', $removeAccents=true, $cleanup=false)
 Makes string safe to use in URLs, filenames, identifiers, and so on.
static slugify ($str, $replacement= '-')
 Makes string suitable for url slugs.
static removeAccents ($str)
static flashHtml ($html, $nl2br=true)
static shorten ($text, $maxLength, $suffix= '', $removeFormatting=false)
static pushEncoding ($encoding)
 Pushes new current encoding.
static popEncoding ()
 Restores previous encoding.
static getEncoding ()
 Returns current encoding.
static pushFormat ($format)
 Pushes new current format.
static popFormat ()
 Restores previous format.
static getFormat ()
 Returns current format.
static isCurrentFormat ($what)
 Returns true if this format is currently set.
static registerFormatInfo ($format, $info)
static getFormatInfo ($format=false)
static getFormatTrait ($trait, $format=false, $default=null)
 Returns specific information about the format, like: escape - escaping function unescape - unescaping function nl - new line quote - quote character.
static convertEncoding ($string, $to, $from)
 Convert a string from one encoding to another.
static escape ($value, $format=false)
static escapeHtml ($value)
 This function is based on the source from Symfony2 Copyright (c) 2004-2011 Fabien Potencier.
static escapeJS ($value)
static escapeHtmlJS ($value)
static escapeJSData ($value)
 A function that escapes all non-alphanumeric characters into their or representations.

Static Protected Member Functions

static escapeJSDataCallback ($matches)

Static Protected Attributes

static $encodingStack = array()
static $formatStack = array()
static $formats

Detailed Description

Various text formatting functions and helpers.


Member Function Documentation

static TextFormat::compressWhitespace ( text,
removeNewLines = false 
) [static]
static TextFormat::convertEncoding ( string,
to,
from 
) [static]

Convert a string from one encoding to another.

Parameters:
string$stringThe string to convert
string$fromThe output encoding, or false to use current
string$toThe input encoding, or false to use current
Returns:
string The string with the new encoding
Exceptions:
\RuntimeExceptionif no suitable encoding function is found (iconv or mbstring)

This function is based on the source from Symfony2 Copyright (c) 2004-2011 Fabien Potencier

static TextFormat::escape ( value,
format = false 
) [static]
static TextFormat::escapeHtml ( value) [static]

This function is based on the source from Symfony2 Copyright (c) 2004-2011 Fabien Potencier.

static TextFormat::escapeHtmlJS ( value) [static]
static TextFormat::escapeJS ( value) [static]
static TextFormat::escapeJSData ( value) [static]

A function that escapes all non-alphanumeric characters into their or representations.

Parameters:
string$valuethe value to escape
Returns:
string the escaped value

This function is based on the source from Symfony2 Copyright (c) 2004-2011 Fabien Potencier

static TextFormat::escapeJSDataCallback ( matches) [static, protected]
static TextFormat::flashHtml ( html,
nl2br = true 
) [static]
static TextFormat::getEncoding ( ) [static]

Returns current encoding.

static TextFormat::getFormat ( ) [static]

Returns current format.

static TextFormat::getFormatInfo ( format = false) [static]
static TextFormat::getFormatTrait ( trait,
format = false,
default = null 
) [static]

Returns specific information about the format, like: escape - escaping function unescape - unescaping function nl - new line quote - quote character.

static TextFormat::handleTextParser_htmlCleanup ( parser) [static]
Parameters:
$parserTextParser
static TextFormat::htmlCleanup ( html,
tags = 'font|script',
params = '(on[\w]+)|bgcolor|border',
styles = 'font-family|font-size|color|background',
shortTags = 'br|img' 
) [static]
static TextFormat::htmlFirstParagraph ( html) [static]
static TextFormat::htmlStrip ( html,
allowedTags = 'b|strong|i|u|br|span|img|div|hr|h\d|a|code|blockquote|ul|li|ol|p',
allowedParams = 'align|class|src|border|size|width|height|href|target' 
) [static]
static TextFormat::htmlToPlain ( text,
leaveHeaders = true,
leaveLinks = true,
htmlSafe = false 
) [static]
static TextFormat::isCurrentFormat ( what) [static]

Returns true if this format is currently set.

static TextFormat::plainToHtml ( text) [static]
static TextFormat::popEncoding ( ) [static]

Restores previous encoding.

static TextFormat::popFormat ( ) [static]

Restores previous format.

static TextFormat::prepareTextTypes ( &$  html,
&$  plain,
forceHtml = false 
) [static]

Uzupełnia formaty wiadomości.

static TextFormat::pushEncoding ( encoding) [static]

Pushes new current encoding.

static TextFormat::pushFormat ( format) [static]

Pushes new current format.

static TextFormat::registerFormatInfo ( format,
info 
) [static]
static TextFormat::removeAccents ( str) [static]
static TextFormat::replaceLinks ( txt) [static]
static TextFormat::safeEmail ( email,
link = true 
) [static]
TextFormat::safeFilename ( file)

Makes filenames safe to use.

static TextFormat::safeString ( str,
replacement = '_',
allowChars = '',
removeAccents = true,
cleanup = false 
) [static]

Makes string safe to use in URLs, filenames, identifiers, and so on.

Parameters:
$str
$replacement
$allowChars
$removeAccents- remove all national accents
$cleanup- removes all excess replacements
Returns:
mixed
static TextFormat::shorten ( text,
maxLength,
suffix = '',
removeFormatting = false 
) [static]
static TextFormat::slugify ( str,
replacement = '-' 
) [static]

Makes string suitable for url slugs.

Lower case text with '-' as replacement for all non alphanumeric characters


Field Documentation

TextFormat::$encodingStack = array() [static, protected]
TextFormat::$formats [static, protected]
TextFormat::$formatStack = array() [static, protected]

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