TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Html\HtmlParser Class Reference
Inheritance diagram for TYPO3\CMS\Core\Html\HtmlParser:
TYPO3\CMS\Core\Html\RteHtmlParser

Public Member Functions

 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 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

const VOID_ELEMENTS = 'area|base|br|col|command|embed|hr|img|input|keygen|meta|param|source|track|wbr'
 

Protected Member Functions

 stripEmptyTagsIfConfigured ($value, $configuration)
 

Protected Attributes

 $caseShift_cache = []
 

Detailed Description

Functions for parsing HTML. You are encouraged to use this class in your own applications

Definition at line 24 of file HtmlParser.php.

Member Function Documentation

◆ bidir_htmlspecialchars()

TYPO3\CMS\Core\Html\HtmlParser::bidir_htmlspecialchars (   $value,
  $dir 
)

Converts htmlspecialchars forth ($dir=1) AND back ($dir=-1)

Parameters
string$valueInput value
int$dirDirection: forth ($dir=1, dir=2 for preserving entities) AND back ($dir=-1)
Returns
string Output value

Definition at line 882 of file HtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\HtmlParser\processContent(), and TYPO3\CMS\Core\Html\HtmlParser\processTag().

◆ caseShift()

TYPO3\CMS\Core\Html\HtmlParser::caseShift (   $str,
  $flag,
  $cacheKey = '' 
)

Internal function for case shifting of a string or whole array

Parameters
mixed$strInput string/array
bool$flagIf $str is a string AND this boolean(caseSensitive) is FALSE, the string is returned in uppercase
string$cacheKeyKey string used for internal caching of the results. Could be an MD5 hash of the serialized version of the input $str if that is an array.
Returns
string Output string, processed private

Definition at line 1116 of file HtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\HtmlParser\checkTagTypeCounts().

◆ checkTagTypeCounts()

TYPO3\CMS\Core\Html\HtmlParser::checkTagTypeCounts (   $content,
  $blockTags = 'a,
,
blockquote  ,
body  ,
div  ,
em  ,
font  ,
form  ,
h1  ,
h2  ,
h3  ,
h4  ,
h5  ,
h6  ,
,
li  ,
map  ,
ol  ,
option  ,
,
pre  ,
select  ,
span  ,
strong  ,
table  ,
td  ,
textarea  ,
tr  ,
,
ul'  ,
  $soloTags = 'br,
hr  ,
img  ,
input  ,
area'   
)

Checks whether block/solo tags are found in the correct amounts in HTML content Block tags are tags which are required to have an equal amount of start and end tags, eg. "<table>...</table>" Solo tags are tags which are required to have ONLY start tags (possibly with an XHTML ending like ".../>") NOTICE: Correct XHTML might actually fail since "<br></br>" is allowed as well as "<br/>". However only the LATTER is accepted by this function (with "br" in the "solo-tag" list), the first example will result in a warning. NOTICE: Correct XHTML might actually fail since "<p/>" is allowed as well as "<p></p>". However only the LATTER is accepted by this function (with "p" in the "block-tag" list), the first example will result in an ERROR! NOTICE: Correct HTML version "something" allows eg.

and to be NON-ended (implicitly ended by other tags). However this is NOT accepted by this function (with "p" and "li" in the block-tag list) and it will result in an ERROR!

Parameters
string$contentHTML content to analyze
string$blockTagsTag names for block tags (eg. table or div or p) in lowercase, commalist (eg. "table,div,p")
string$soloTagsTag names for solo tags (eg. img, br or input) in lowercase, commalist ("img,br,input")
Returns
array Analyse data.

Definition at line 490 of file HtmlParser.php.

References $params, TYPO3\CMS\Core\Utility\GeneralUtility\callUserFunction(), TYPO3\CMS\Core\Html\HtmlParser\caseShift(), TYPO3\CMS\Core\Html\HtmlParser\compileTagAttribs(), TYPO3\CMS\Core\Utility\MathUtility\forceIntegerInRange(), TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes(), TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), TYPO3\CMS\Core\Html\HtmlParser\processContent(), TYPO3\CMS\Core\Html\HtmlParser\processTag(), TYPO3\CMS\Core\Html\HtmlParser\stripEmptyTagsIfConfigured(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

◆ cleanFontTags()

TYPO3\CMS\Core\Html\HtmlParser::cleanFontTags (   $value,
  $keepFace = 0,
  $keepSize = 0,
  $keepColor = 0 
)

Cleans up the input $value for fonttags. If keepFace,-Size and -Color is set then font-tags with an allowed property is kept. Else deleted.

Parameters
stringHTML content with font-tags inside to clean up.
boolIf set, keep "face" attribute
boolIf set, keep "size" attribute
boolIf set, keep "color" attribute
Returns
string Processed HTML content

Definition at line 1023 of file HtmlParser.php.

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

◆ compileTagAttribs()

TYPO3\CMS\Core\Html\HtmlParser::compileTagAttribs (   $tagAttrib,
  $meta = [],
  $xhtmlClean = 0 
)

Compiling an array with tag attributes into a string

Parameters
array$tagAttribTag attributes
array$metaMeta information about these attributes (like if they were quoted)
bool$xhtmlCleanIf set, then the attribute names will be set in lower case, value quotes in double-quotes and the value will be htmlspecialchar()'ed
Returns
string Imploded attributes, eg: 'attribute="value" attrib2="value2"' private

Definition at line 1148 of file HtmlParser.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

Referenced by TYPO3\CMS\Core\Html\HtmlParser\checkTagTypeCounts(), TYPO3\CMS\Core\Html\RteHtmlParser\divideIntoLines(), and TYPO3\CMS\Core\Html\HtmlParser\prefixResourcePath().

◆ get_tag_attributes()

TYPO3\CMS\Core\Html\HtmlParser::get_tag_attributes (   $tag,
  $deHSC = 0 
)

Returns an array with all attributes as keys. Attributes are only lowercase a-z If an attribute is empty (shorthand), then the value for the key is empty. You can check if it existed with isset()

Parameters
string$tagTag: $tag is either a whole tag (eg '<TAG option="" attrib="VALUE">') or the parameterlist (ex ' OPTION ATTRIB=VALUE>')
bool$deHSCIf set, the attribute values are de-htmlspecialchar'ed. Should actually always be set!
Returns
array array(Tag attributes,Attribute meta-data)

Definition at line 408 of file HtmlParser.php.

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

Referenced by TYPO3\CMS\Core\Html\HtmlParser\checkTagTypeCounts(), TYPO3\CMS\Core\Html\RteHtmlParser\divideIntoLines(), TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes_classic(), TYPO3\CMS\Core\Html\HtmlParser\prefixResourcePath(), and TYPO3\CMS\Core\Html\HtmlParser\processTag().

◆ get_tag_attributes_classic()

◆ getAllParts()

TYPO3\CMS\Core\Html\HtmlParser::getAllParts (   $parts,
  $tag_parts = true,
  $include_tag = true 
)

Returns an array with either tag or non-tag content of the result from ->splitIntoBlock()/->splitTags()

Parameters
array$partsParts generated by ->splitIntoBlock() or >splitTags()
bool$tag_partsWhether to return the tag-parts (default,TRUE) or what was outside the tags.
bool$include_tagWhether to include the tags in the tag-parts (most useful for input made by ->splitIntoBlock())
Returns
array Tag-parts/Non-tag-parts depending on input argument settings
See also
splitIntoBlock(), splitTags()

Definition at line 335 of file HtmlParser.php.

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

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

◆ getFirstTag()

◆ getFirstTagName()

TYPO3\CMS\Core\Html\HtmlParser::getFirstTagName (   $str,
  $preserveCase = false 
)

Returns the NAME of the first tag in $str

Parameters
string$strHTML tag (The element name MUST be separated from the attributes by a space character! Just whitespace will not do)
bool$preserveCaseIf set, then the tag is NOT converted to uppercase by case is preserved.
Returns
string Tag name in upper case
See also
getFirstTag()

Definition at line 388 of file HtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\RteHtmlParser\divideIntoLines(), TYPO3\CMS\Core\Html\HtmlParser\prefixResourcePath(), TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlockRecursiveProc(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_preserve_db(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_db(), and TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_rte().

◆ getSubpart()

static TYPO3\CMS\Core\Html\HtmlParser::getSubpart (   $content,
  $marker 
)
static

Returns the first subpart encapsulated in the marker, $marker (possibly present in $content as a HTML comment)

Parameters
string$contentContent with subpart wrapped in fx. "###CONTENT_PART###" inside.
string$markerMarker string, eg. "###CONTENT_PART###
Returns
string
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly

Definition at line 44 of file HtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ HTMLparserConfig()

TYPO3\CMS\Core\Html\HtmlParser::HTMLparserConfig (   $TSconfig,
  $keepTags = [] 
)

Converts TSconfig into an array for the HTMLcleaner function.

Parameters
array$TSconfigTSconfig for HTMLcleaner
array$keepTagsArray of tags to keep (?)
Returns
array private

Definition at line 1210 of file HtmlParser.php.

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

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

◆ indentLines()

TYPO3\CMS\Core\Html\HtmlParser::indentLines (   $content,
  $number = 1,
  $indentChar = TAB 
)

Indents input content with $number instances of $indentChar

Parameters
string$contentContent string, multiple lines.
int$numberNumber of indents
string$indentCharIndent character/string
Returns
strin Indented code (typ. HTML)

Definition at line 1191 of file HtmlParser.php.

◆ mapTags()

TYPO3\CMS\Core\Html\HtmlParser::mapTags (   $value,
  $tags = [],
  $ltChar = '<',
  $ltChar2 = '<' 
)

This is used to map certain tag-names into other names.

Parameters
string$valueHTML content
array$tagsArray with tag key=>value pairs where key is from-tag and value is to-tag
string$ltCharAlternative less-than char to search for (search regex string)
string$ltChar2Alternative less-than char to replace with (replace regex string)
Returns
string Processed HTML content

Definition at line 1061 of file HtmlParser.php.

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

◆ prefixRelPath()

TYPO3\CMS\Core\Html\HtmlParser::prefixRelPath (   $prefix,
  $srcVal,
  $suffix = '' 
)

Internal sub-function for ->prefixResourcePath()

Parameters
string$prefixPrefix string
string$srcValRelative path/URL
string$suffixSuffix string
Returns
string Output path, prefixed if no scheme in input string private

Definition at line 999 of file HtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\HtmlParser\prefixResourcePath().

◆ prefixResourcePath()

TYPO3\CMS\Core\Html\HtmlParser::prefixResourcePath (   $main_prefix,
  $content,
  $alternatives = [],
  $suffix = '' 
)

Prefixes the relative paths of hrefs/src/action in the tags [td,table,body,img,input,form,link,script,a] in the $content with the $main_prefix or and alternative given by $alternatives

Parameters
string$main_prefixPrefix string
string$contentHTML content
array$alternativesArray with alternative prefixes for certain of the tags. key=>value pairs where the keys are the tag element names in uppercase
string$suffixSuffix string (put after the resource).
Returns
string Processed HTML content

Definition at line 904 of file HtmlParser.php.

References $params, TYPO3\CMS\Core\Html\HtmlParser\compileTagAttribs(), TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes(), TYPO3\CMS\Core\Html\HtmlParser\getFirstTagName(), TYPO3\CMS\Core\Html\HtmlParser\prefixRelPath(), TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlock(), and TYPO3\CMS\Core\Html\HtmlParser\splitTags().

◆ processContent()

TYPO3\CMS\Core\Html\HtmlParser::processContent (   $value,
  $dir,
  $conf 
)

Processing content between tags for HTML_cleaner

Parameters
string$valueThe value
int$dirDirection, either -1 or +1. 0 (zero) means no change to input value.
mixed$confNot used, ignore.
Returns
string The processed value. private

Definition at line 1437 of file HtmlParser.php.

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

Referenced by TYPO3\CMS\Core\Html\HtmlParser\checkTagTypeCounts().

◆ processTag()

TYPO3\CMS\Core\Html\HtmlParser::processTag (   $value,
  $conf,
  $endTag,
  $protected = 0 
)

Processing all tags themselves (Some additions by Sacha Vorbeck)

Parameters
stringTag to process
arrayConfiguration array passing instructions for processing. If count()==0, function will return value unprocessed. See source code for details
boolIs endtag, then set this.
boolIf set, just return value straight away
Returns
string Processed value. private

Definition at line 1377 of file HtmlParser.php.

References TYPO3\CMS\Core\Html\HtmlParser\bidir_htmlspecialchars(), TYPO3\CMS\Core\Utility\GeneralUtility\deprecationLog(), and TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes().

Referenced by TYPO3\CMS\Core\Html\HtmlParser\checkTagTypeCounts().

◆ removeFirstAndLastTag()

◆ split_tag_attributes()

TYPO3\CMS\Core\Html\HtmlParser::split_tag_attributes (   $tag)

Returns an array with the 'components' from an attribute list. The result is normally analyzed by get_tag_attributes Removes tag-name if found

Parameters
string$tagThe tag or attributes
Returns
array private
See also
::split_tag_attributes()

Definition at line 452 of file HtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\HtmlParser\get_tag_attributes().

◆ splitIntoBlock()

TYPO3\CMS\Core\Html\HtmlParser::splitIntoBlock (   $tag,
  $content,
  $eliminateExtraEndTags = false 
)

Returns an array with the $content divided by tag-blocks specified with the list of tags, $tag Even numbers in the array are outside the blocks, Odd numbers are block-content. Use ->getAllParts() and ->removeFirstAndLastTag() to process the content if needed.

Parameters
string$tagList of tags, comma separated.
string$contentHTML-content
bool$eliminateExtraEndTagsIf set, excessive end tags are ignored - you should probably set this in most cases.
Returns
array Even numbers in the array are outside the blocks, Odd numbers are block-content.
See also
splitTags(), getAllParts(), removeFirstAndLastTag()

Definition at line 191 of file HtmlParser.php.

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

Referenced by TYPO3\CMS\Core\Html\HtmlParser\cleanFontTags(), TYPO3\CMS\Core\Html\RteHtmlParser\divideIntoLines(), TYPO3\CMS\Core\Html\HtmlParser\prefixResourcePath(), TYPO3\CMS\Core\Html\RteHtmlParser\removeTables(), TYPO3\CMS\Core\Html\HtmlParser\splitIntoBlockRecursiveProc(), TYPO3\CMS\Core\Html\RteHtmlParser\transformStyledATags(), TYPO3\CMS\Core\Html\RteHtmlParser\TS_AtagToAbs(), 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_transform_db(), and TYPO3\CMS\Core\Html\RteHtmlParser\TS_transform_rte().

◆ splitIntoBlockRecursiveProc()

TYPO3\CMS\Core\Html\HtmlParser::splitIntoBlockRecursiveProc (   $tag,
  $content,
$procObj,
  $callBackContent,
  $callBackTags,
  $level = 0 
)

Splitting content into blocks recursively and processing tags/content with call back functions.

Parameters
string$tagTag list, see splitIntoBlock()
string$contentContent, see splitIntoBlock()
object$procObjObject where call back methods are.
string$callBackContentName of call back method for content; "function callBackContent($str,$level) @param string $callBackTags Name of call back method for tags; "function callBackTags($tags,$level)
int$levelIndent level
Returns
string Processed content
See also
splitIntoBlock()

Definition at line 263 of file HtmlParser.php.

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

◆ splitTags()

TYPO3\CMS\Core\Html\HtmlParser::splitTags (   $tag,
  $content 
)

Returns an array with the $content divided by tag-blocks specified with the list of tags, $tag Even numbers in the array are outside the blocks, Odd numbers are block-content. Use ->getAllParts() and ->removeFirstAndLastTag() to process the content if needed.

Parameters
string$tagList of tags
string$contentHTML-content
Returns
array Even numbers in the array are outside the blocks, Odd numbers are block-content.
See also
splitIntoBlock(), getAllParts(), removeFirstAndLastTag()

Definition at line 298 of file HtmlParser.php.

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

Referenced by TYPO3\CMS\Core\Html\HtmlParser\prefixResourcePath(), TYPO3\CMS\Core\Html\RteHtmlParser\RTE_transform(), and TYPO3\CMS\Core\Html\RteHtmlParser\TS_images_rte().

◆ stripEmptyTags()

TYPO3\CMS\Core\Html\HtmlParser::stripEmptyTags (   $content,
  $tagList = null,
  $treatNonBreakingSpaceAsEmpty = false 
)

Strips empty tags from HTML.

Parameters
string$contentThe content to be stripped of empty tags
string$tagListThe comma separated list of tags to be stripped. If empty, all empty tags will be stripped
bool$treatNonBreakingSpaceAsEmptyIf TRUE tags containing only   entities will be treated as empty.
Returns
string the stripped content

Definition at line 1454 of file HtmlParser.php.

Referenced by TYPO3\CMS\Core\Html\HtmlParser\stripEmptyTagsIfConfigured().

◆ stripEmptyTagsIfConfigured()

TYPO3\CMS\Core\Html\HtmlParser::stripEmptyTagsIfConfigured (   $value,
  $configuration 
)
protected

Strips the configured empty tags from the HMTL code.

Parameters
string$value
array$configuration
Returns
string

Definition at line 1476 of file HtmlParser.php.

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

Referenced by TYPO3\CMS\Core\Html\HtmlParser\checkTagTypeCounts().

◆ substituteMarker()

static TYPO3\CMS\Core\Html\HtmlParser::substituteMarker (   $content,
  $marker,
  $markContent 
)
static

Substitutes a marker string in the input content (by a simple str_replace())

Parameters
string$contentThe content stream, typically HTML template content.
string$markerThe marker string, typically on the form "###[the marker string]###
mixed$markContentThe content to insert instead of the marker string found.
Returns
string The processed HTML content string.
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly

Definition at line 97 of file HtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ substituteMarkerAndSubpartArrayRecursive()

static TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerAndSubpartArrayRecursive (   $content,
array  $markersAndSubparts,
  $wrap = '',
  $uppercase = false,
  $deleteUnused = false 
)
static

Replaces all markers and subparts in a template with the content provided in the structured array.

The array is built like the template with its markers and subparts. Keys represent the marker name and the values the content. If the value is not an array the key will be treated as a single marker. If the value is an array the key will be treated as a subpart marker. Repeated subpart contents are of course elements in the array, so every subpart value must contain an array with its markers.

$markersAndSubparts = array ( '###SINGLEMARKER1###' => 'value 1', '###SUBPARTMARKER1###' => array( 0 => array( '###SINGLEMARKER2###' => 'value 2', ), 1 => array( '###SINGLEMARKER2###' => 'value 3', ) ), '###SUBPARTMARKER2###' => array( ), ) Subparts can be nested, so below the 'SINGLEMARKER2' it is possible to have another subpart marker with an array as the value, which in its turn contains the elements of the sub-subparts. Empty arrays for Subparts will cause the subtemplate to be cleared.

Parameters
string$contentThe content stream, typically HTML template content.
array$markersAndSubpartsThe array of single markers and subpart contents.
string$wrapA wrap value - [part1] | [part2] - for the markers before substitution.
bool$uppercaseIf set, all marker string substitution is done with upper-case markers.
bool$deleteUnusedIf set, all unused single markers are deleted.
Returns
string The processed output stream
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly

Definition at line 168 of file HtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ substituteMarkerArray()

static TYPO3\CMS\Core\Html\HtmlParser::substituteMarkerArray (   $content,
  $markContentArray,
  $wrap = '',
  $uppercase = false,
  $deleteUnused = false 
)
static

Traverses the input $markContentArray array and for each key the marker by the same name (possibly wrapped and in upper case) will be substituted with the keys value in the array. This is very useful if you have a data-record to substitute in some content. In particular when you use the $wrap and $uppercase values to pre-process the markers. Eg. a key name like "myfield" could effectively be represented by the marker "###MYFIELD###" if the wrap value was "###|###" and the $uppercase boolean TRUE.

Parameters
string$contentThe content stream, typically HTML template content.
array$markContentArrayThe array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
string$wrapA wrap value - [part 1] | [part 2] - for the markers before substitution
bool$uppercaseIf set, all marker string substitution is done with upper-case markers.
bool$deleteUnusedIf set, all unused marker are deleted.
Returns
string The processed output stream
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly

Definition at line 123 of file HtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ substituteSubpart()

static TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart (   $content,
  $marker,
  $subpartContent,
  $recursive = true,
  $keepMarker = false 
)
static

Substitutes a subpart in $content with the content of $subpartContent.

Parameters
string$contentContent with subpart wrapped in fx. "###CONTENT_PART###" inside.
string$markerMarker string, eg. "###CONTENT_PART###
array$subpartContentIf $subpartContent happens to be an array, it's [0] and [1] elements are wrapped around the content of the subpart (fetched by getSubpart())
bool$recursiveIf $recursive is set, the function calls itself with the content set to the remaining part of the content after the second marker. This means that proceding subparts are ALSO substituted!
bool$keepMarkerIf set, the marker around the subpart is not removed, but kept in the output
Returns
string Processed input content
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly

Definition at line 63 of file HtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ substituteSubpartArray()

static TYPO3\CMS\Core\Html\HtmlParser::substituteSubpartArray (   $content,
array  $subpartsContent 
)
static

Substitues multiple subparts at once

Parameters
string$contentThe content stream, typically HTML template content.
array$subpartsContentThe array of key/value pairs being subpart/content values used in the substitution. For each element in this array the function will substitute a subpart in the content stream with the content.
Returns
string The processed HTML content string.
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use the corresponding method in MarkerBasedTemplateService accordingly

Definition at line 79 of file HtmlParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\logDeprecatedFunction(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ unprotectTags()

TYPO3\CMS\Core\Html\HtmlParser::unprotectTags (   $content,
  $tagList = '' 
)

This converts htmlspecialchar()'ed tags (from $tagList) back to real tags. Eg. '<strong&gt' would be converted back to '' if found in $tagList

Parameters
string$contentHTML content
string$tagListTag list, separated by comma. Lowercase!
Returns
string Processed HTML content

Definition at line 1076 of file HtmlParser.php.

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

◆ XHTML_clean()

TYPO3\CMS\Core\Html\HtmlParser::XHTML_clean (   $content)

Tries to convert the content to be XHTML compliant and other stuff like that. STILL EXPERIMENTAL. See comments below.

What it does NOT do (yet) according to XHTML specs.:

  • Wellformedness: Nesting is NOT checked
  • name/id attribute issue is not observed at this point.
  • Certain nesting of elements not allowed. Most interesting,
     cannot contain img, big,small,sub,sup ...
  • Wrapping scripts and style element contents in CDATA - or alternatively they should have entitites converted.
  • Setting charsets may put some special requirements on both XML declaration/ meta-http-equiv. (C.9)
  • UTF-8 encoding is in fact expected by XML!!
  • stylesheet element and attribute names are NOT converted to lowercase
  • ampersands (and entities in general I think) MUST be converted to an entity reference! (). This may mean further conversion of non-tag content before output to page. May be related to the charset issue as a whole.
  • Minimized values not allowed: Must do this: selected="selected"
What it does at this point:
  • All tags (frame,base,meta,link + img,br,hr,area,input) is ended with "/>" - others?
  • Lowercase for elements and attributes
  • All attributes in quotes
  • Add "alt" attribute to img-tags if it's not there already.
Parameters
string$contentContent to clean up
Returns
string Cleaned up content returned. private
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8

Definition at line 1360 of file HtmlParser.php.

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

Member Data Documentation

◆ $caseShift_cache

TYPO3\CMS\Core\Html\HtmlParser::$caseShift_cache = []
protected

Definition at line 29 of file HtmlParser.php.

◆ VOID_ELEMENTS

const TYPO3\CMS\Core\Html\HtmlParser::VOID_ELEMENTS = 'area|base|br|col|command|embed|hr|img|input|keygen|meta|param|source|track|wbr'

Definition at line 32 of file HtmlParser.php.