Overview

Namespaces

  • None
  • Xmf
    • Database
    • Module
      • Helper
    • Template
  • Xoops
    • Auth
    • Core
      • Cache
      • Database
        • Logging
        • Schema
      • Exception
      • Handler
        • Scheme
      • Kernel
        • Dtype
        • Handlers
        • Model
      • Lists
      • Locale
        • Punic
      • Service
        • Contract
      • Session
      • Text
        • Sanitizer
          • Extensions
      • Theme
        • Plugins
    • Form
    • Html
    • Locale
    • Module
      • Helper
      • Plugin

Classes

  • Sanitizer
  • ShortCodes
  • Overview
  • Namespace
  • Class
  • Tree

Class Sanitizer

Class to "clean up" text for various uses

Xoops\Core\Text\Sanitizer\SanitizerConfigurable
Extended by Xoops\Core\Text\Sanitizer

Direct known subclasses

MyTextSanitizer

Indirect known subclasses

MyTextSanitizerExtended
Namespace: Xoops\Core\Text
Package: Xoops\Core\Text
Category: Sanitizer
Copyright: 2000-2015 XOOPS Project (http://xoops.org)
License: GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
Author: Kazumi Ono onokazu@xoops.org
Author: Goghs Cheng (http://www.eqiao.com, http://www.devbeez.com/)
Author: Taiwen Jiang phppp@users.sourceforge.net
Author: Richard Griffith richard@geekwright.com
Link: http://xoops.org
Located at oops_lib/Xoops/Core/Text/Sanitizer.php
Methods summary
public static Xoops\Core\Text\Sanitizer
# getInstance( )

Returns the Singleton instance of this class.

Returns the Singleton instance of this class.

Returns

Xoops\Core\Text\Sanitizer
The Singleton instance.
protected
# __construct( )

Construct - protected to enforce singleton. The singleton pattern minimizes the impact of the expense of the setup logic.

Construct - protected to enforce singleton. The singleton pattern minimizes the impact of the expense of the setup logic.

public Xoops\Core\Text\ShortCodes
# getShortCodesInstance( )

get our ShortCodes instance. This is intended for internal use, as it is just the bare instance.

get our ShortCodes instance. This is intended for internal use, as it is just the bare instance.

Returns

Xoops\Core\Text\ShortCodes

Throws

ErrorException

See

Xoops\Core\Text\Sanitizer::getShortCodes()
public Xoops\Core\Text\ShortCodes
# getShortCodes( )

get our ShortCodes instance, but make sure extensions are loaded so caller can extend and override

get our ShortCodes instance, but make sure extensions are loaded so caller can extend and override

Returns

Xoops\Core\Text\ShortCodes

Throws

ErrorException
public
# addPatternCallback( string $pattern, callable $callback )

Add a preg_replace_callback pattern and callback

Add a preg_replace_callback pattern and callback

Parameters

$pattern
a pattern as used in preg_replace_callback
$callback
callback to do processing as used in preg_replace_callback
public string
# smiley( string $text )

Replace emoticons in a string with smiley images

Replace emoticons in a string with smiley images

Parameters

$text
text to filter

Returns

string
public string
# makeClickable( string $text )

Turn bare URLs and email addresses into links

Turn bare URLs and email addresses into links

Parameters

$text
text to filter

Returns

string
public string
# nl2Br( string $text )

Convert linebreaks to
tags

Convert linebreaks to
tags

This is used instead of PHP's built-in nl2br() because it removes the line endings, replacing them with br tags, while the built in just adds br tags and leaves the line endings. We don't want to leave those, as something may try to process them again.

Parameters

$text
text

Returns

string
public string
# htmlSpecialChars( string $text, integer $quote_style = ENT_QUOTES )

Convert special characters to HTML entities

Convert special characters to HTML entities

Character set is locked to 'UTF-8', double_encode to true

Parameters

$text
string being converted
$quote_style
ENT_QUOTES | ENT_SUBSTITUTE will forced

Returns

string
public string
# escapeForJavascript( string $text )

Convert special characters to HTML entities with special attention to quotes for strings which may be used in a javascript context.

Convert special characters to HTML entities with special attention to quotes for strings which may be used in a javascript context.

Escape double quote as \x22 , single as \x27, and then send to htmlSpecialChars().

Parameters

$text
string being converted

Returns

string
public string
# escapeShortCodes( string $text )

Escape any brackets ([]) to make them invisible to ShortCodes

Escape any brackets ([]) to make them invisible to ShortCodes

Parameters

$text
string to escape

Returns

string
public string
# undoHtmlSpecialChars( string $text )

Reverses htmlSpecialChars()

Reverses htmlSpecialChars()

Parameters

$text
htmlSpecialChars encoded text

Returns

string
protected string
# xoopsCodeDecode( string $text, boolean $allowImage = false )

Apply extension specified transformation, such as ShortCodes, to the supplied text

Apply extension specified transformation, such as ShortCodes, to the supplied text

Parameters

$text
text to filter
$allowImage
Allow images in the text? On FALSE, uses links to images.

Returns

string
public string
# filterForDisplay( string $text, boolean $html = false, boolean $smiley = true, boolean $xcode = true, boolean $image = true, boolean $br = true )

Filters data for display

Filters data for display

Parameters

$text
text to filter for display
$html
allow html?
$smiley
allow smileys?
$xcode
allow xoopscode (and shortcodes)?
$image
allow inline images?
$br
convert linebreaks?

Returns

string
public string
# displayTarea( string $text, boolean $html = false, boolean $smiley = true, boolean $xcode = true, boolean $image = true, boolean $br = true )

Filters textarea form data submitted for preview

Filters textarea form data submitted for preview

Parameters

$text
text to filter for display
$html
allow html?
$smiley
allow smileys?
$xcode
allow xoopscode?
$image
allow inline images?
$br
convert linebreaks?

Returns

string
public string
# previewTarea( string $text, integer $html = 0, integer $smiley = 1, integer $xcode = 1, integer $image = 1, integer $br = 1 )

Filters textarea form data submitted for preview

Filters textarea form data submitted for preview

Parameters

$text
text to filter for preview
$html
allow html?
$smiley
allow smileys?
$xcode
allow xoopscode?
$image
allow inline images?
$br
convert linebreaks?

Returns

string
public string
# censorString( string $text )

Replaces banned words in a string with their replacements

Replaces banned words in a string with their replacements

Parameters

$text
text to censor

Returns

string
protected string
# prefilterCodeBlocks( string $text )

Encode [code] elements as base64 to prevent processing of contents by other filters

Encode [code] elements as base64 to prevent processing of contents by other filters

Parameters

$text
text to filter

Returns

string
protected string
# postfilterCodeBlocks( string $text )

convert code blocks, previously processed by prefilterCodeBlocks(), for display

convert code blocks, previously processed by prefilterCodeBlocks(), for display

Parameters

$text
text to filter

Returns

string
public string[]
# listExtensions( )

listExtensions() - get list of active extensions

listExtensions() - get list of active extensions

Returns

string[]
public string[]
# getDhtmlEditorSupport( string $extension, string $textAreaId )

Provide button and javascript code used by the DhtmlTextArea

Provide button and javascript code used by the DhtmlTextArea

Parameters

$extension
extension name
$textAreaId
dom element id

Returns

string[]
editor button as HTML, supporting javascript
public array
# getConfig( string $componentName = 'sanitizer' )

getConfig() - get the configuration for a component (extension, filter, sanitizer)

getConfig() - get the configuration for a component (extension, filter, sanitizer)

Parameters

$componentName
get the configuration for component of this name

Returns

array
protected
# registerExtensions( )

registerExtensions()

registerExtensions()

This sets up the shortcode processing that will be applied to text to be displayed

protected object|null
# loadComponent( string $name )

Load a named component from specification in configuration

Load a named component from specification in configuration

Parameters

$name
name of component to load

Returns

object|null
protected Xoops\Core\Text\Sanitizer\ExtensionAbstract
# loadExtension( string $name )

Load an extension by name

Load an extension by name

Parameters

$name
extension name

Returns

Xoops\Core\Text\Sanitizer\ExtensionAbstract
protected Xoops\Core\Text\Sanitizer\FilterAbstract
# loadFilter( string $name )

Load a filter by name

Load a filter by name

Parameters

$name
name of filter to load

Returns

Xoops\Core\Text\Sanitizer\FilterAbstract
protected mixed
# registerExtension( string $name )

execute an extension

execute an extension

Parameters

$name
extension name

Returns

mixed
public mixed
# executeFilter( string $name )

execute a filter

execute a filter

Parameters

$name
extension name

Returns

mixed
public string
# textFilter( string $text, boolean $force = false )

Filter out possible malicious text with the textfilter filter

Filter out possible malicious text with the textfilter filter

Parameters

$text
text to filter
$force
force filtering

Returns

string
filtered text
public string
# filterXss( string $text )

Filter out possible malicious text with the xss filter

Filter out possible malicious text with the xss filter

Parameters

$text
text to filter

Returns

string
filtered text
public mixed
# cleanEnum( string $text, string[] $enumSet, string $default = '', boolean $firstLetter = false )

Test a string against an enumeration list.

Test a string against an enumeration list.

Parameters

$text
string to check
$enumSet
strings to match (case insensitive)
$default
default value is no match
$firstLetter
match first letter only

Returns

mixed
matched string, or default if no match
public
# enableComponentForTesting( string $name )

Force a component to be enabled.

Force a component to be enabled.

Note: This is intended to support testing, and is not recommended for any regular use

Parameters

$name
component to enable
Methods inherited from Xoops\Core\Text\Sanitizer\SanitizerConfigurable
getDefaultConfig()
Properties summary
protected static array $defaultConfiguration

default configuration values

default configuration values

# [ 'enabled' => true, 'prefilters' => [], 'postfilters' => ['embed', 'clickable'], ]
protected boolean $extensionsLoaded

Have extensions been loaded?

Have extensions been loaded?

# false
protected Xoops\Core\Text\ShortCodes $shortcodes
#
protected array $patterns
# array()
protected Xoops\Core\Text\Sanitizer\Configuration $config
#
API documentation generated by ApiGen