TYPO3  7.6
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
RteHtmlParser Class Reference
Inheritance diagram for RteHtmlParser:
HtmlParser

Public Member Functions

 init ($elRef= '', $recPid=0)
 
 setRelPath ($path)
 
 RTE_transform ($value, $specConf, $direction= 'rte', $thisConfig=array())
 
 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 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=array(), $suffix= '')
 
 prefixRelPath ($prefix, $srcVal, $suffix= '')
 
 cleanFontTags ($value, $keepFace=0, $keepSize=0, $keepColor=0)
 
 mapTags ($value, $tags=array(), $ltChar= '<', $ltChar2= '<')
 
 unprotectTags ($content, $tagList= '')
 
 caseShift ($str, $flag, $cacheKey= '')
 
 compileTagAttribs ($tagAttrib, $meta=array(), $xhtmlClean=0)
 
 get_tag_attributes_classic ($tag, $deHSC=0)
 
 indentLines ($content, $number=1, $indentChar=TAB)
 
 HTMLparserConfig ($TSconfig, $keepTags=array())
 
 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 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

 $blockElementList = 'PRE,UL,OL,H1,H2,H3,H4,H5,H6,ADDRESS,DL,DD,HEADER,SECTION,FOOTER,NAV,ARTICLE,ASIDE'
 
 $recPid = 0
 
 $elRef = ''
 
 $relPath = ''
 
 $relBackPath = ''
 
 $tsConfig = array()
 
 $procOptions = array()
 
 $TS_transform_db_safecounter = 100
 
 $rte_p = ''
 
 $getKeepTags_cache = array()
 
 $allowedClasses = array()
 
 $preserveTags = ''
 
- Public Attributes inherited from 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 HtmlParser
 stripEmptyTagsIfConfigured ($value, $configuration)
 

Additional Inherited Members

- Protected Attributes inherited from HtmlParser
 $caseShift_cache = array()
 

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 (   $imageInfo,
  $attribArray 
)
protected

Apply plain image settings to the dimensions of the image

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

Definition at line 1613 of file RteHtmlParser.php.

defaultTStagMapping (   $code,
  $direction = 'rte' 
)

Default tag mapping for TS

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

Definition at line 1457 of file RteHtmlParser.php.

References HtmlParser\mapTags().

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.

Parameters
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.
Returns
string Processed input value.
See Also
setDivTags()

Definition at line 1245 of file RteHtmlParser.php.

References HtmlParser\compileTagAttribs(), HtmlParser\get_tag_attributes(), HtmlParser\getFirstTag(), HtmlParser\getFirstTagName(), RteHtmlParser\HTMLcleaner_db(), HtmlParser\removeFirstAndLastTag(), HtmlParser\splitIntoBlock(), and GeneralUtility\trimExplode().

Referenced by RteHtmlParser\TS_transform_db().

static evalWriteFile (   $pArr,
  $currentRecord 
)
static

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

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

Definition at line 157 of file RteHtmlParser.php.

References GeneralUtility\logDeprecatedFunction().

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)

Parameters
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)
Returns
array Configuration array
See Also
HTMLcleaner_db()

Definition at line 1127 of file RteHtmlParser.php.

References HtmlParser\HTMLparserConfig(), and GeneralUtility\trimExplode().

Referenced by RteHtmlParser\HTMLcleaner_db(), and RteHtmlParser\setDivTags().

getUrl (   $url)

Reads the file or url $url and returns the content

Parameters
string$urlFilepath/URL to read
Returns
string The content from the resource given as input.
See Also
::getUrl()

Definition at line 1084 of file RteHtmlParser.php.

References $url, and GeneralUtility\getUrl().

getWHFromAttribs (   $attribArray)

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

Parameters
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
Returns
array Integer w/h in key 0/1. Zero is returned if not found.

Definition at line 1483 of file RteHtmlParser.php.

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

Parameters
string$contentContent to clean up
string$tagListComma list of tags to specifically allow. Default comes from getKeepTags and is
Returns
string Clean content
See Also
getKeepTags()

Definition at line 1099 of file RteHtmlParser.php.

References RteHtmlParser\getKeepTags().

Referenced by RteHtmlParser\divideIntoLines(), and RteHtmlParser\TS_transform_db().

init (   $elRef = '',
  $recPid = 0 
)

Initialize, setting element reference and record PID

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

Definition at line 117 of file RteHtmlParser.php.

References RteHtmlParser\$elRef, and RteHtmlParser\$recPid.

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.

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

Definition at line 1427 of file RteHtmlParser.php.

References HtmlParser\getAllParts(), and HtmlParser\splitIntoBlock().

Referenced by RteHtmlParser\TS_transform_db().

RTE_transform (   $value,
  $specConf,
  $direction = 'rte',
  $thisConfig = array() 
)

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

Parameters
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.
Returns
string Output value

Definition at line 177 of file RteHtmlParser.php.

References $GLOBALS, BackendUtility\getSpecConfParametersFromArray(), GeneralUtility\getUserObj(), HtmlParser\HTMLparserConfig(), GeneralUtility\trimExplode(), RteHtmlParser\TS_images_rte(), RteHtmlParser\TS_links_db(), RteHtmlParser\TS_links_rte(), RteHtmlParser\TS_preserve_db(), RteHtmlParser\TS_preserve_rte(), RteHtmlParser\TS_reglinks(), RteHtmlParser\TS_strip_db(), RteHtmlParser\TS_transform_db(), and RteHtmlParser\TS_transform_rte().

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.

Parameters
string$valueValue to convert
string$dTTag to wrap with. Either "p" or "div" should it be. Lowercase preferably.
Returns
string Processed value.
See Also
divideIntoLines()

Definition at line 1369 of file RteHtmlParser.php.

References RteHtmlParser\getKeepTags().

Referenced by RteHtmlParser\TS_transform_rte().

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

Parameters
string$pathThe relative path from PATH_site to the place where the file being edited is. Eg. "fileadmin/static".
Returns
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.

siteUrl ( )

Returns SiteURL based on thisScript.

Returns
string Value of GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
See Also
::getIndpEnv()

Definition at line 1414 of file RteHtmlParser.php.

References GeneralUtility\getIndpEnv().

Referenced by RteHtmlParser\TS_AtagToAbs(), RteHtmlParser\TS_images_rte(), RteHtmlParser\TS_links_db(), RteHtmlParser\TS_links_rte(), RteHtmlParser\TS_reglinks(), and RteHtmlParser\urlInfoForLinkTags().

transformStyledATags (   $value)

Wraps a-tags that contain a style attribute with a span-tag

Parameters
string$valueContent input
Returns
string Content output

Definition at line 969 of file RteHtmlParser.php.

References HtmlParser\get_tag_attributes_classic(), HtmlParser\getFirstTag(), GeneralUtility\implodeAttributes(), HtmlParser\removeFirstAndLastTag(), and HtmlParser\splitIntoBlock().

Referenced by RteHtmlParser\TS_transform_db().

TS_AtagToAbs (   $value,
  $dontSetRTEKEEP = false 
)

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

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

Definition at line 1575 of file RteHtmlParser.php.

References elseif, HtmlParser\get_tag_attributes_classic(), HtmlParser\getFirstTag(), GeneralUtility\implodeAttributes(), HtmlParser\removeFirstAndLastTag(), RteHtmlParser\siteUrl(), and HtmlParser\splitIntoBlock().

Referenced by RteHtmlParser\TS_links_rte(), and RteHtmlParser\TS_reglinks().

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.

Parameters
string$valueContent input
Returns
string Content output

Definition at line 485 of file RteHtmlParser.php.

References HtmlParser\get_tag_attributes_classic(), GeneralUtility\getIndpEnv(), GeneralUtility\implodeAttributes(), RteHtmlParser\siteUrl(), and HtmlParser\splitTags().

Referenced by RteHtmlParser\RTE_transform().

TS_links_db (   $value)

Transformation handler: 'ts_links' / direction: "db" Converting -tags to <link tags>="">

Parameters
string$valueContent input
Returns
string Content output
See Also
TS_links_rte()

Definition at line 562 of file RteHtmlParser.php.

References $GLOBALS, HtmlParser\get_tag_attributes_classic(), HtmlParser\getFirstTag(), GeneralUtility\getUserObj(), GeneralUtility\implodeAttributes(), HtmlParser\removeFirstAndLastTag(), RteHtmlParser\siteUrl(), HtmlParser\splitIntoBlock(), and RteHtmlParser\urlInfoForLinkTags().

Referenced by RteHtmlParser\RTE_transform().

TS_links_rte (   $value)
TS_preserve_db (   $value)

Preserve special tags

Parameters
string$valueContent input
Returns
string Content output

Definition at line 805 of file RteHtmlParser.php.

References HtmlParser\get_tag_attributes_classic(), HtmlParser\getFirstTag(), HtmlParser\getFirstTagName(), HtmlParser\removeFirstAndLastTag(), and HtmlParser\splitIntoBlock().

Referenced by RteHtmlParser\RTE_transform().

TS_preserve_rte (   $value)

Preserve special tags

Parameters
string$valueContent input
Returns
string Content output

Definition at line 832 of file RteHtmlParser.php.

References HtmlParser\getFirstTag(), HtmlParser\removeFirstAndLastTag(), and HtmlParser\splitIntoBlock().

Referenced by RteHtmlParser\RTE_transform().

TS_reglinks (   $value,
  $direction 
)

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

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

Definition at line 525 of file RteHtmlParser.php.

References HtmlParser\get_tag_attributes_classic(), HtmlParser\getFirstTag(), GeneralUtility\implodeAttributes(), HtmlParser\removeFirstAndLastTag(), RteHtmlParser\siteUrl(), HtmlParser\splitIntoBlock(), and RteHtmlParser\TS_AtagToAbs().

Referenced by RteHtmlParser\RTE_transform().

TS_strip_db (   $value)

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

Parameters
string$valueContent input
Returns
string Content output

Definition at line 1066 of file RteHtmlParser.php.

Referenced by RteHtmlParser\RTE_transform().

TS_transform_db (   $value,
  $css = false 
)

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

Parameters
string$valueContent input
bool$cssIf TRUE, the transformation was "css_transform", otherwise "ts_transform
Returns
string Content output
See Also
TS_transform_rte()

Definition at line 856 of file RteHtmlParser.php.

References RteHtmlParser\divideIntoLines(), HtmlParser\get_tag_attributes_classic(), HtmlParser\getFirstTag(), HtmlParser\getFirstTagName(), RteHtmlParser\HTMLcleaner_db(), HtmlParser\removeFirstAndLastTag(), RteHtmlParser\removeTables(), HtmlParser\splitIntoBlock(), and RteHtmlParser\transformStyledATags().

Referenced by RteHtmlParser\RTE_transform().

TS_transform_rte (   $value,
  $css = 0 
)

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

Parameters
stringContent input
boolIf TRUE, the transformation was "css_transform", otherwise "ts_transform
Returns
string Content output
See Also
TS_transform_db()

Definition at line 998 of file RteHtmlParser.php.

References RteHtmlParser\$blockElementList, HtmlParser\get_tag_attributes_classic(), HtmlParser\getFirstTag(), HtmlParser\getFirstTagName(), GeneralUtility\inList(), HtmlParser\removeFirstAndLastTag(), RteHtmlParser\setDivTags(), and HtmlParser\splitIntoBlock().

Referenced by RteHtmlParser\RTE_transform().

urlInfoForLinkTags (   $url)

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

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

Definition at line 1511 of file RteHtmlParser.php.

References $url, elseif, and RteHtmlParser\siteUrl().

Referenced by RteHtmlParser\TS_links_db().

Member Data Documentation

$allowedClasses = array()

Definition at line 101 of file RteHtmlParser.php.

$blockElementList = 'PRE,UL,OL,H1,H2,H3,H4,H5,H6,ADDRESS,DL,DD,HEADER,SECTION,FOOTER,NAV,ARTICLE,ASIDE'

Definition at line 31 of file RteHtmlParser.php.

Referenced by RteHtmlParser\TS_transform_rte().

$elRef = ''

Definition at line 45 of file RteHtmlParser.php.

Referenced by RteHtmlParser\init().

$getKeepTags_cache = array()

Definition at line 94 of file RteHtmlParser.php.

$preserveTags = ''

Definition at line 108 of file RteHtmlParser.php.

$procOptions = array()

Definition at line 73 of file RteHtmlParser.php.

$recPid = 0

Definition at line 38 of file RteHtmlParser.php.

Referenced by RteHtmlParser\init(), and RteHtmlParser\TS_links_rte().

$relBackPath = ''

Definition at line 59 of file RteHtmlParser.php.

$relPath = ''

Definition at line 52 of file RteHtmlParser.php.

$rte_p = ''

Definition at line 87 of file RteHtmlParser.php.

$TS_transform_db_safecounter = 100

Definition at line 80 of file RteHtmlParser.php.

$tsConfig = array()

Definition at line 66 of file RteHtmlParser.php.