TYPO3\CMS\Core\Html\RteHtmlParser Class Reference
Inheritance diagram for TYPO3\CMS\Core\Html\RteHtmlParser:

Public Member Functions

 init ($elRef='', $recPid=0)
 setRelPath ($path)
 RTE_transform ($value, $specConf, $direction='rte', $thisConfig=[])
 TS_images_rte ($value)
 TS_reglinks ($value, $direction)
 TS_links_db ($value)
 TS_links_rte ($value)
 TS_preserve_db ($value)
 TS_preserve_rte ($value)
 TS_transform_db ($value, $css=false)
 transformStyledATags ($value)
 TS_transform_rte ($value, $css=0)
 TS_strip_db ($value)
 getUrl ($url)
 HTMLcleaner_db ($content, $tagList='')
 getKeepTags ($direction='rte', $tagList='')
 divideIntoLines ($value, $count=5, $returnArray=false)
 setDivTags ($value, $dT='p')
 siteUrl ()
 removeTables ($value, $breakChar='< br/>')
 defaultTStagMapping ($code, $direction='rte')
 getWHFromAttribs ($attribArray)
 urlInfoForLinkTags ($url)
 TS_AtagToAbs ($value, $dontSetRTEKEEP=false)
- Public Member Functions inherited from TYPO3\CMS\Core\Html\HtmlParser
 splitIntoBlock ($tag, $content, $eliminateExtraEndTags=false)
 splitIntoBlockRecursiveProc ($tag, $content, &$procObj, $callBackContent, $callBackTags, $level=0)
 splitTags ($tag, $content)
 getAllParts ($parts, $tag_parts=true, $include_tag=true)
 removeFirstAndLastTag ($str)
 getFirstTag ($str)
 getFirstTagName ($str, $preserveCase=false)
 get_tag_attributes ($tag, $deHSC=0)
 split_tag_attributes ($tag)
 checkTagTypeCounts ($content, $blockTags='a, b, blockquote, body, div, em, font, form, h1, h2, h3, h4, h5, h6, i, li, map, ol, option, p, pre, select, span, strong, table, td, textarea, tr, u, ul', $soloTags='br, hr, img, input, area')
 bidir_htmlspecialchars ($value, $dir)
 prefixResourcePath ($main_prefix, $content, $alternatives=[], $suffix='')
 prefixRelPath ($prefix, $srcVal, $suffix='')
 cleanFontTags ($value, $keepFace=0, $keepSize=0, $keepColor=0)
 mapTags ($value, $tags=[], $ltChar='<', $ltChar2='<')
 unprotectTags ($content, $tagList='')
 caseShift ($str, $flag, $cacheKey='')
 compileTagAttribs ($tagAttrib, $meta=[], $xhtmlClean=0)
 get_tag_attributes_classic ($tag, $deHSC=0)
 indentLines ($content, $number=1, $indentChar=TAB)
 HTMLparserConfig ($TSconfig, $keepTags=[])
 XHTML_clean ($content)
 processTag ($value, $conf, $endTag, $protected=0)
 processContent ($value, $dir, $conf)
 stripEmptyTags ($content, $tagList=null, $treatNonBreakingSpaceAsEmpty=false)

Static Public Member Functions

static evalWriteFile ($pArr, $currentRecord)
- Static Public Member Functions inherited from TYPO3\CMS\Core\Html\HtmlParser
static getSubpart ($content, $marker)
static substituteSubpart ($content, $marker, $subpartContent, $recursive=true, $keepMarker=false)
static substituteSubpartArray ($content, array $subpartsContent)
static substituteMarker ($content, $marker, $markContent)
static substituteMarkerArray ($content, $markContentArray, $wrap='', $uppercase=false, $deleteUnused=false)
static substituteMarkerAndSubpartArrayRecursive ($content, array $markersAndSubparts, $wrap='', $uppercase=false, $deleteUnused=false)

Public Attributes

 $recPid = 0
 $elRef = ''
 $relPath = ''
 $relBackPath = ''
 $tsConfig = []
 $procOptions = []
 $TS_transform_db_safecounter = 100
 $rte_p = ''
 $getKeepTags_cache = []
 $allowedClasses = []
 $preserveTags = ''
- Public Attributes inherited from TYPO3\CMS\Core\Html\HtmlParser
const VOID_ELEMENTS = 'area|base|br|col|command|embed|hr|img|input|keygen|meta|param|source|track|wbr'

Protected Member Functions

 applyPlainImageModeSettings ($imageInfo, $attribArray)
- Protected Member Functions inherited from TYPO3\CMS\Core\Html\HtmlParser
 stripEmptyTagsIfConfigured ($value, $configuration)

Additional Inherited Members

- Protected Attributes inherited from TYPO3\CMS\Core\Html\HtmlParser
 $caseShift_cache = []

Detailed Description

Class for parsing HTML for the Rich Text Editor. (also called transformations)

Definition at line 26 of file RteHtmlParser.php.

Member Function Documentation

◆ applyPlainImageModeSettings()

TYPO3\CMS\Core\Html\RteHtmlParser::applyPlainImageModeSettings (   $imageInfo,

Apply plain image settings to the dimensions of the image

array$imageInfo,info array of the image
array$attribArray,array of attributes of an image tag
array a modified attributes array

Definition at line 1617 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform().

◆ defaultTStagMapping()

TYPO3\CMS\Core\Html\RteHtmlParser::defaultTStagMapping (   $code,
  $direction = 'rte' 

Default tag mapping for TS

string$codeInput code to process
string$directionDirection To databsae (db) or from database to RTE (rte)
string Processed value

Definition at line 1461 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\mapTags().

◆ divideIntoLines()

TYPO3\CMS\Core\Html\RteHtmlParser::divideIntoLines (   $value,
  $count = 5,
  $returnArray = false 

This resolves the $value into parts based on

-sections and

-sections and
-tags. These are returned as lines separated by LF. This point is to resolve the HTML-code returned from RTE into ordinary lines so it's 'human-readable' The function ->setDivTags does the opposite. This function processes content to go into the database.

string$valueValue to process.
int$countRecursion brake. Decremented on each recursion down to zero. Default is 5 (which equals the allowed nesting levels of p/div tags).
bool$returnArrayIf TRUE, an array with the lines is returned, otherwise a string of the processed input value.
string Processed input value.
See also

Definition at line 1250 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\compileTagAttribs(), TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes(), TYPO3\CMS\Core\Html\HtmlParser\getFirstTag(), TYPO3\CMS\Core\Html\HtmlParser\getFirstTagName(), TYPO3\CMS\Core\Html\RteHtmlParser\HTMLcleaner_db(), TYPO3\CMS\Core\Html\HtmlParser\removeFirstAndLastTag(), TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlock(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_db().

◆ evalWriteFile()

static TYPO3\CMS\Core\Html\RteHtmlParser::evalWriteFile (   $pArr,

Evaluate the environment for editing a staticFileEdit file. Called for almost all fields being saved in the database. Is called without an instance of ::evalWriteFile()

array$pArrParameters for the current field as found in types-config
array$currentRecordCurrent record we are editing.
mixed On success an array with various information is returned, otherwise a string with an error message
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8

Definition at line 157 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction().

◆ getKeepTags()

TYPO3\CMS\Core\Html\RteHtmlParser::getKeepTags (   $direction = 'rte',
  $tagList = '' 

Creates an array of configuration for the HTMLcleaner function based on whether content go TO or FROM the Rich Text Editor ($direction) Unless "tagList" is given, the function will cache the configuration for next time processing goes on. (In this class that is the case only if we are processing a bulletlist)

string$directionThe direction of the content being processed by the output configuration; "db" (content going into the database FROM the rte) or "rte" (content going into the form)
string$tagListComma list of tags to keep (overriding default which is to keep all + take notice of internal configuration)
array Configuration array
See also

Definition at line 1132 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\HTMLparserConfig(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\HTMLcleaner_db(), and TYPO3\CMS\Core\Html\RteHtmlParser\setDivTags().

◆ getUrl()

TYPO3\CMS\Core\Html\RteHtmlParser::getUrl (   $url)

Reads the file or url $url and returns the content

string$urlFilepath/URL to read
string The content from the resource given as input.
See also

Definition at line 1089 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\getUrl().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform().

◆ getWHFromAttribs()

TYPO3\CMS\Core\Html\RteHtmlParser::getWHFromAttribs (   $attribArray)

Finds width and height from attrib-array If the width and height is found in the style-attribute, use that!

array$attribArrayArray of attributes from tag in which to search. More specifically the content of the key "style" is used to extract "width:xxx / height:xxx" information
array Integer w/h in key 0/1. Zero is returned if not found.

Definition at line 1487 of file RteHtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform().

◆ HTMLcleaner_db()

TYPO3\CMS\Core\Html\RteHtmlParser::HTMLcleaner_db (   $content,
  $tagList = '' 

Function for cleaning content going into the database. Content is cleaned eg. by removing unallowed HTML and ds-HSC content It is basically calling HTMLcleaner from the parent class with some preset configuration specifically set up for cleaning content going from the RTE into the db

string$contentContent to clean up
string$tagListComma list of tags to specifically allow. Default comes from getKeepTags and is
string Clean content
See also

Definition at line 1104 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\RteHtmlParser\getKeepTags().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\divideIntoLines(), and TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_db().

◆ init()

TYPO3\CMS\Core\Html\RteHtmlParser::init (   $elRef = '',
  $recPid = 0 

Initialize, setting element reference and record PID

string$elRefElement reference, eg "tt_content:bodytext
int$recPidPID of the record (page id)

Definition at line 117 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\RteHtmlParser\$elRef, and TYPO3\CMS\Core\Html\RteHtmlParser\$recPid.

◆ removeTables()

TYPO3\CMS\Core\Html\RteHtmlParser::removeTables (   $value,
  $breakChar = '<br />' 

Remove all tables from incoming code The function is trying to to this is some more or less respectfull way. The approach is to resolve each table cells content and implode it all by
chars. Thus at least the content is preserved in some way.

string$valueInput value
string$breakCharBreak character to use for linebreaks.
string Output value

Definition at line 1431 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\getAllParts(), and TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlock().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_db().

◆ RTE_transform()

TYPO3\CMS\Core\Html\RteHtmlParser::RTE_transform (   $value,
  $direction = 'rte',
  $thisConfig = [] 

Transform value for RTE based on specConf in the direction specified by $direction (rte/db) This is the main function called from tcemain and transfer data classes

stringInput value
arraySpecial configuration for a field; This is coming from the types-configuration of the field in the TCA. In the types-configuration you can setup features for the field rendering and in particular the RTE takes al its major configuration options from there!
stringDirection of the transformation. Two keywords are allowed; "db" or "rte". If "db" it means the transformation will clean up content coming from the Rich Text Editor and goes into the database. The other direction, "rte", is of course when content is coming from database and must be transformed to fit the RTE.
arrayParsed TypoScript content configuring the RTE, probably coming from Page TSconfig.
string Output value

Definition at line 177 of file RteHtmlParser.php.

References $GLOBALS, TYPO3\CMS\Core\Html\RteHtmlParser\applyPlainImageModeSettings(), TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes_classic(), TYPO3\CMS\Core\Utility\GeneralUtility\getFileAbsFileName(), TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), TYPO3\CMS\Core\Resource\ResourceFactory\getInstance(), TYPO3\CMS\Backend\Utility\BackendUtility\getSpecConfParametersFromArray(), TYPO3\CMS\Core\Html\RteHtmlParser\getUrl(), TYPO3\CMS\Core\Utility\GeneralUtility\getUserObj(), TYPO3\CMS\Core\Html\RteHtmlParser\getWHFromAttribs(), TYPO3\CMS\Core\Html\HtmlParser\HTMLparserConfig(), TYPO3\CMS\Core\Utility\GeneralUtility\implodeAttributes(), TYPO3\CMS\Core\Utility\GeneralUtility\isFirstPartOfStr(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), TYPO3\CMS\Core\Utility\GeneralUtility\shortMD5(), TYPO3\CMS\Core\Html\RteHtmlParser\siteUrl(), TYPO3\CMS\Core\Html\HtmlParser\splitTags(), TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_images_rte(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_links_db(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_links_rte(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_preserve_db(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_preserve_rte(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_reglinks(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_strip_db(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_db(), and TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_rte().

◆ setDivTags()

TYPO3\CMS\Core\Html\RteHtmlParser::setDivTags (   $value,
  $dT = 'p' 

Converts all lines into


-sections (unless the line is a div-section already) For processing of content going FROM database TO RTE.

string$valueValue to convert
string$dTTag to wrap with. Either "p" or "div" should it be. Lowercase preferably.
string Processed value.
See also

Definition at line 1374 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\RteHtmlParser\getKeepTags().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_rte().

◆ setRelPath()

TYPO3\CMS\Core\Html\RteHtmlParser::setRelPath (   $path)

Setting the ->relPath and ->relBackPath to proper values so absolute references to links and images can be converted to relative dittos. This is used when editing files with the RTE

string$pathThe relative path from PATH_site to the place where the file being edited is. Eg. "fileadmin/static".
void There is no output, it is set in internal variables. With the above example of "fileadmin/static" as input this will yield ->relPath to be "fileadmin/static/" and ->relBackPath to be "../../ @TODO: Check if relPath and relBackPath are used for anything useful after removal of "static file edit" with #63818

Definition at line 131 of file RteHtmlParser.php.

References $a.

◆ siteUrl()

◆ transformStyledATags()

TYPO3\CMS\Core\Html\RteHtmlParser::transformStyledATags (   $value)

◆ TS_AtagToAbs()

TYPO3\CMS\Core\Html\RteHtmlParser::TS_AtagToAbs (   $value,
  $dontSetRTEKEEP = false 

Converting -tags to absolute URLs (+ setting rtekeep attribute)

string$valueContent input
bool$dontSetRTEKEEPIf TRUE, then the "rtekeep" attribute will not be set.
string Content output

Definition at line 1579 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes_classic(), TYPO3\CMS\Core\Html\HtmlParser\getFirstTag(), TYPO3\CMS\Core\Utility\GeneralUtility\implodeAttributes(), TYPO3\CMS\Core\Html\HtmlParser\removeFirstAndLastTag(), TYPO3\CMS\Core\Html\RteHtmlParser\siteUrl(), and TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlock().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\TS_links_rte(), and TYPO3\CMS\Core\Html\RteHtmlParser\TS_reglinks().

◆ TS_images_rte()

TYPO3\CMS\Core\Html\RteHtmlParser::TS_images_rte (   $value)

Transformation handler: 'ts_images' / direction: "rte" Processing images from database content going into the RTE. Processing includes converting the src attribute to an absolute URL.

string$valueContent input
string Content output

Definition at line 486 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes_classic(), TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), TYPO3\CMS\Core\Utility\GeneralUtility\implodeAttributes(), TYPO3\CMS\Core\Html\RteHtmlParser\siteUrl(), and TYPO3\CMS\Core\Html\HtmlParser\splitTags().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform().

◆ TS_links_db()

◆ TS_links_rte()

◆ TS_preserve_db()

TYPO3\CMS\Core\Html\RteHtmlParser::TS_preserve_db (   $value)

◆ TS_preserve_rte()

TYPO3\CMS\Core\Html\RteHtmlParser::TS_preserve_rte (   $value)

Preserve special tags

string$valueContent input
string Content output

Definition at line 835 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\getFirstTag(), TYPO3\CMS\Core\Html\HtmlParser\removeFirstAndLastTag(), and TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlock().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform().

◆ TS_reglinks()

TYPO3\CMS\Core\Html\RteHtmlParser::TS_reglinks (   $value,

Transformation handler: 'ts_reglinks' / direction: "db"+"rte" depending on $direction variable. Converting -tags to/from abs/rel

string$valueContent input
string$directionDirection of conversion; "rte" (from database to RTE) or "db" (from RTE to database)
string Content output

Definition at line 526 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes_classic(), TYPO3\CMS\Core\Html\HtmlParser\getFirstTag(), TYPO3\CMS\Core\Utility\GeneralUtility\implodeAttributes(), TYPO3\CMS\Core\Html\HtmlParser\removeFirstAndLastTag(), TYPO3\CMS\Core\Html\RteHtmlParser\siteUrl(), TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlock(), and TYPO3\CMS\Core\Html\RteHtmlParser\TS_AtagToAbs().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform().

◆ TS_strip_db()

TYPO3\CMS\Core\Html\RteHtmlParser::TS_strip_db (   $value)

Transformation handler: 'ts_strip' / direction: "db" Removing all non-allowed tags

string$valueContent input
string Content output

Definition at line 1071 of file RteHtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform().

◆ TS_transform_db()

TYPO3\CMS\Core\Html\RteHtmlParser::TS_transform_db (   $value,
  $css = false 

◆ TS_transform_rte()

TYPO3\CMS\Core\Html\RteHtmlParser::TS_transform_rte (   $value,
  $css = 0 

Transformation handler: 'ts_transform' + 'css_transform' / direction: "rte" Set (->rte) for standard content elements (ts)

stringContent input
boolIf TRUE, the transformation was "css_transform", otherwise "ts_transform
string Content output
See also

Definition at line 1003 of file RteHtmlParser.php.

References TYPO3\CMS\Core\Html\RteHtmlParser\$blockElementList, TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes_classic(), TYPO3\CMS\Core\Html\HtmlParser\getFirstTag(), TYPO3\CMS\Core\Html\HtmlParser\getFirstTagName(), TYPO3\CMS\Core\Utility\GeneralUtility\inList(), TYPO3\CMS\Core\Html\HtmlParser\removeFirstAndLastTag(), TYPO3\CMS\Core\Html\RteHtmlParser\setDivTags(), and TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlock().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform().

◆ urlInfoForLinkTags()

TYPO3\CMS\Core\Html\RteHtmlParser::urlInfoForLinkTags (   $url)

Parse -tag href and return status of email,external,file or page

string$urlURL to analyse.
array Information in an array about the URL

Definition at line 1515 of file RteHtmlParser.php.

References $a, and TYPO3\CMS\Core\Html\RteHtmlParser\siteUrl().

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\TS_links_db().

Member Data Documentation

◆ $allowedClasses

TYPO3\CMS\Core\Html\RteHtmlParser::$allowedClasses = []

Definition at line 101 of file RteHtmlParser.php.

◆ $blockElementList


◆ $elRef

TYPO3\CMS\Core\Html\RteHtmlParser::$elRef = ''

Definition at line 45 of file RteHtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\init().

◆ $getKeepTags_cache

TYPO3\CMS\Core\Html\RteHtmlParser::$getKeepTags_cache = []

Definition at line 94 of file RteHtmlParser.php.

◆ $preserveTags

TYPO3\CMS\Core\Html\RteHtmlParser::$preserveTags = ''

Definition at line 108 of file RteHtmlParser.php.

◆ $procOptions

TYPO3\CMS\Core\Html\RteHtmlParser::$procOptions = []

Definition at line 73 of file RteHtmlParser.php.

◆ $recPid

TYPO3\CMS\Core\Html\RteHtmlParser::$recPid = 0

◆ $relBackPath

TYPO3\CMS\Core\Html\RteHtmlParser::$relBackPath = ''

Definition at line 59 of file RteHtmlParser.php.

◆ $relPath

TYPO3\CMS\Core\Html\RteHtmlParser::$relPath = ''

Definition at line 52 of file RteHtmlParser.php.

◆ $rte_p

TYPO3\CMS\Core\Html\RteHtmlParser::$rte_p = ''

Definition at line 87 of file RteHtmlParser.php.

◆ $TS_transform_db_safecounter

TYPO3\CMS\Core\Html\RteHtmlParser::$TS_transform_db_safecounter = 100

Definition at line 80 of file RteHtmlParser.php.

◆ $tsConfig

TYPO3\CMS\Core\Html\RteHtmlParser::$tsConfig = []

Definition at line 66 of file RteHtmlParser.php.