-tags:
if (!$css) {
if (!isset($this->procOptions['typolist']) || $this->procOptions['typolist']) {
$parts = $this->getAllParts($this->splitIntoBlock('LI',$this->removeFirstAndLastTag($blockSplit[$k])),1,0);
while(list($k2)=each($parts)) {
$parts[$k2]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/','',$parts[$k2]); // remove all linesbreaks!
$parts[$k2]=$this->defaultTStagMapping($parts[$k2],'db');
$parts[$k2]=$this->cleanFontTags($parts[$k2],0,0,0);
$parts[$k2] = $this->HTMLcleaner_db($parts[$k2],strtolower($this->procOptions['allowTagsInTypolists']?$this->procOptions['allowTagsInTypolists']:'br,font,b,i,u,a,img,span,strong,em'));
}
if ($tagName=='ol') { $params=' type="1"'; } else { $params=''; }
$blockSplit[$k]=''.chr(10).implode(chr(10),$parts).chr(10).''.$lastBR;
}
} else {
$blockSplit[$k]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
}
break;
case 'table': // Tables are NOT allowed in any form (unless preserveTables is set or CSS is the mode)
if (!$this->procOptions['preserveTables'] && !$css) {
$blockSplit[$k]=$this->TS_transform_db($this->removeTables($blockSplit[$k]));
} else {
$blockSplit[$k]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
}
break;
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
if (!$css) {
$attribArray=$this->get_tag_attributes_classic($tag);
// Processing inner content here:
$innerContent = $this->HTMLcleaner_db($this->removeFirstAndLastTag($blockSplit[$k]));
if (!isset($this->procOptions['typohead']) || $this->procOptions['typohead']) {
$type = intval(substr($tagName,1));
$blockSplit[$k]=''.
$innerContent.
''.
$lastBR;
} else {
$blockSplit[$k]='<'.$tagName.
($attribArray['align']?' align="'.htmlspecialchars($attribArray['align']).'"':'').
($attribArray['class']?' class="'.htmlspecialchars($attribArray['class']).'"':'').
'>'.
$innerContent.
''.$tagName.'>'.
$lastBR;
}
} else {
// Eliminate true linebreaks inside Hx tags
$blockSplit[$k]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
}
break;
default:
// Eliminate true linebreaks inside other headlist tags and after hr tag
$blockSplit[$k]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
break;
}
} else { // NON-block:
if (strcmp(trim($blockSplit[$k]),'')) {
$blockSplit[$k]=$this->divideIntoLines(preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$blockSplit[$k])).$lastBR;
$blockSplit[$k]=$this->transformStyledATags($blockSplit[$k]);
} else unset($blockSplit[$k]);
}
}
$this->TS_transform_db_safecounter++;
return implode('',$blockSplit);
}
/**
* Wraps a-tags that contain a style attribute with a span-tag
*
* @param string Content input
* @return string Content output
*/
function transformStyledATags($value) {
$blockSplit = $this->splitIntoBlock('A',$value);
foreach($blockSplit as $k => $v) {
if ($k%2) { // If an A-tag was found:
$attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
if ($attribArray['style']) { // If "style" attribute is set!
$attribArray_copy['style'] = $attribArray['style'];
unset($attribArray['style']);
$bTag='';
$eTag='';
$blockSplit[$k] = $bTag.$this->removeFirstAndLastTag($blockSplit[$k]).$eTag;
}
}
}
return implode('',$blockSplit);
}
/**
* Transformation handler: 'ts_transform' + 'css_transform' / direction: "rte"
* Set (->rte) for standard content elements (ts)
*
* @param string Content input
* @param boolean If true, the transformation was "css_transform", otherwise "ts_transform"
* @return string Content output
* @see TS_transform_db()
*/
function TS_transform_rte($value,$css=0) {
// Split the content from Database by the occurence of these blocks:
$blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->headListTags,$value);
// Traverse the blocks
foreach($blockSplit as $k => $v) {
if ($k%2) { // Inside one of the blocks:
// Init:
$tag = $this->getFirstTag($v);
$tagName = strtolower($this->getFirstTagName($v));
$attribArray = $this->get_tag_attributes_classic($tag);
// Based on tagname, we do transformations:
switch($tagName) {
case 'blockquote': // Keep blockquotes:
case 'div': // Keep div sections, if they were splitted
$blockSplit[$k] = $tag.
$this->TS_transform_rte($this->removeFirstAndLastTag($blockSplit[$k]),$css).
''.$tagName.'>';
break;
case 'typolist': // Transform typolist blocks into OL/UL lists. Type 1 is expected to be numerical block
if (!isset($this->procOptions['typolist']) || $this->procOptions['typolist']) {
$tListContent = $this->removeFirstAndLastTag($blockSplit[$k]);
$tListContent = ereg_replace('^[ ]*'.chr(10),'',$tListContent);
$tListContent = ereg_replace(chr(10).'[ ]*$','',$tListContent);
$lines = explode(chr(10),$tListContent);
$typ = $attribArray['type']==1 ? 'ol' : 'ul';
$blockSplit[$k] = '<'.$typ.'>'.chr(10).
''.implode(''.chr(10).'',$lines).''.
''.$typ.'>';
}
break;
case 'typohead': // Transform typohead into Hx tags.
if (!isset($this->procOptions['typohead']) || $this->procOptions['typohead']) {
$tC = $this->removeFirstAndLastTag($blockSplit[$k]);
$typ = t3lib_div::intInRange($attribArray['type'],0,6);
if (!$typ) $typ=6;
$align = $attribArray['align']?' align="'.$attribArray['align'].'"': '';
$class = $attribArray['class']?' class="'.$attribArray['class'].'"': '';
$blockSplit[$k] = ''.
$tC.
'';
}
break;
}
$blockSplit[$k+1] = ereg_replace('^[ ]*'.chr(10),'',$blockSplit[$k+1]); // Removing linebreak if typohead
} else { // NON-block:
$nextFTN = $this->getFirstTagName($blockSplit[$k+1]);
$singleLineBreak = $blockSplit[$k]==chr(10);
if (t3lib_div::inList('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->headListTags,$nextFTN)) { // Removing linebreak if typolist/typohead
$blockSplit[$k] = ereg_replace(chr(10).'[ ]*$','',$blockSplit[$k]);
}
// If $blockSplit[$k] is blank then unset the line. UNLESS the line happend to be a single line break.
if (!strcmp($blockSplit[$k],'') && !$singleLineBreak) {
unset($blockSplit[$k]);
} else {
$blockSplit[$k] = $this->setDivTags($blockSplit[$k],($this->procOptions['useDIVasParagraphTagForRTE']?'div':'p'));
}
}
}
return implode(chr(10),$blockSplit);
}
/**
* Transformation handler: 'ts_strip' / direction: "db"
* Removing all non-allowed tags
*
* @param string Content input
* @return string Content output
*/
function TS_strip_db($value) {
$value = strip_tags($value,'<'.implode('><',explode(',','b,i,u,a,img,br,div,center,pre,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote')).'>');
return $value;
}
/***************************************************************
*
* Generic RTE transformation, analysis and helper functions
*
**************************************************************/
/**
* Reads the file or url $url and returns the content
*
* @param string Filepath/URL to read
* @return string The content from the resource given as input.
* @see t3lib_div::getURL()
*/
function getURL($url) {
return t3lib_div::getURL($url);
}
/**
* 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
*
* @param string Content to clean up
* @param string Comma list of tags to specifically allow. Default comes from getKeepTags and is ""
* @return string Clean content
* @see getKeepTags()
*/
function HTMLcleaner_db($content,$tagList='') {
if (!$tagList) {
$keepTags = $this->getKeepTags('db');
} else {
$keepTags = $this->getKeepTags('db',$tagList);
}
$kUknown = $this->procOptions['dontRemoveUnknownTags_db'] ? 1 : 0; // Default: remove unknown tags.
$hSC = $this->procOptions['dontUndoHSC_db'] ? 0 : -1; // Default: re-convert literals to characters (that is < to <)
// Create additional configuration in order to honor the setting RTE.default.proc.HTMLparser_db.xhtml_cleaning=1
$addConfig=array();
if ((is_array($this->procOptions['HTMLparser_db.']) && $this->procOptions['HTMLparser_db.']['xhtml_cleaning']) || (is_array($this->procOptions['entryHTMLparser_db.']) && $this->procOptions['entryHTMLparser_db.']['xhtml_cleaning']) || (is_array($this->procOptions['exitHTMLparser_db.']) && $this->procOptions['exitHTMLparser_db.']['xhtml_cleaning'])) {
$addConfig['xhtml']=1;
}
return $this->HTMLcleaner($content,$keepTags,$kUknown,$hSC,$addConfig);
}
/**
* 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)
*
* @param string The 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)
* @param string Comma list of tags to keep (overriding default which is to keep all + take notice of internal configuration)
* @return array Configuration array
* @see HTMLcleaner_db()
*/
function getKeepTags($direction='rte',$tagList='') {
if (!is_array($this->getKeepTags_cache[$direction]) || $tagList) {
// Setting up allowed tags:
if (strcmp($tagList,'')) { // If the $tagList input var is set, this will take precedence
$keepTags = array_flip(t3lib_div::trimExplode(',',$tagList,1));
} else { // Default is to get allowed/denied tags from internal array of processing options:
// Construct default list of tags to keep:
$typoScript_list = 'b,i,u,a,img,br,div,center,pre,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote,strike,span';
$keepTags = array_flip(t3lib_div::trimExplode(',',$typoScript_list.','.strtolower($this->procOptions['allowTags']),1));
// For tags to deny, remove them from $keepTags array:
$denyTags = t3lib_div::trimExplode(',',$this->procOptions['denyTags'],1);
foreach($denyTags as $dKe) {
unset($keepTags[$dKe]);
}
}
// Based on the direction of content, set further options:
switch ($direction) {
// GOING from database to Rich Text Editor:
case 'rte':
if (!isset($this->procOptions['transformBoldAndItalicTags']) || $this->procOptions['transformBoldAndItalicTags']) {
// Transform bold/italics tags to strong/em
if (isset($keepTags['b'])) {$keepTags['b']=array('remap'=>'STRONG');}
if (isset($keepTags['i'])) {$keepTags['i']=array('remap'=>'EM');}
}
// Transforming keepTags array so it can be understood by the HTMLcleaner function. This basically converts the format of the array from TypoScript (having .'s) to plain multi-dimensional array.
list($keepTags) = $this->HTMLparserConfig($this->procOptions['HTMLparser_rte.'],$keepTags);
break;
// GOING from RTE to database:
case 'db':
if (!isset($this->procOptions['transformBoldAndItalicTags']) || $this->procOptions['transformBoldAndItalicTags']) {
// Transform strong/em back to bold/italics:
if (isset($keepTags['strong'])) { $keepTags['strong']=array('remap'=>'b'); }
if (isset($keepTags['em'])) { $keepTags['em']=array('remap'=>'i'); }
}
// Setting up span tags if they are allowed:
if (isset($keepTags['span'])) {
$classes=array_merge(array(''),$this->allowedClasses);
$keepTags['span']=array(
'allowedAttribs' => 'class,style,xml:lang',
'fixAttrib' => Array(
'class' => Array (
'list' => $classes,
'removeIfFalse' => 1
)
),
'rmTagIfNoAttrib' => 1
);
if (!$this->procOptions['allowedClasses']) unset($keepTags['span']['fixAttrib']['class']['list']);
}
// Setting up font tags if they are allowed:
if (isset($keepTags['font'])) {
$colors=array_merge(array(''),t3lib_div::trimExplode(',',$this->procOptions['allowedFontColors'],1));
$keepTags['font']=array(
'allowedAttribs'=>'face,color,size',
'fixAttrib' => Array(
'face' => Array (
'removeIfFalse' => 1
),
'color' => Array (
'removeIfFalse' => 1,
'list'=>$colors
),
'size' => Array (
'removeIfFalse' => 1,
)
),
'rmTagIfNoAttrib' => 1
);
if (!$this->procOptions['allowedFontColors']) unset($keepTags['font']['fixAttrib']['color']['list']);
}
// Setting further options, getting them from the processiong options:
$TSc = $this->procOptions['HTMLparser_db.'];
if (!$TSc['globalNesting']) $TSc['globalNesting']='b,i,u,a,center,font,sub,sup,strong,em,strike,span';
if (!$TSc['noAttrib']) $TSc['noAttrib']='b,i,u,br,center,hr,sub,sup,strong,em,li,ul,ol,blockquote,strike';
// Transforming the array from TypoScript to regular array:
list($keepTags) = $this->HTMLparserConfig($TSc,$keepTags);
break;
}
// Caching (internally, in object memory) the result unless tagList is set:
if (!$tagList) {
$this->getKeepTags_cache[$direction] = $keepTags;
} else {
return $keepTags;
}
}
// Return result:
return $this->getKeepTags_cache[$direction];
}
/**
* This resolves the $value into parts based on -sections and -sections and
-tags. These are returned as lines separated by chr(10).
* 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.
*
* @param string Value to process.
* @param integer Recursion brake. Decremented on each recursion down to zero. Default is 5 (which equals the allowed nesting levels of p/div tags).
* @param boolean If true, an array with the lines is returned, otherwise a string of the processed input value.
* @return string Processed input value.
* @see setDivTags()
*/
function divideIntoLines($value,$count=5,$returnArray=FALSE) {
// Internalize font tags (move them from OUTSIDE p/div to inside it that is the case):
if ($this->procOptions['internalizeFontTags']) {$value = $this->internalizeFontTags($value);}
// Setting configuration for processing:
$allowTagsOutside = t3lib_div::trimExplode(',',strtolower($this->procOptions['allowTagsOutside']?$this->procOptions['allowTagsOutside']:'img'),1);
$remapParagraphTag = strtoupper($this->procOptions['remapParagraphTag']);
$divSplit = $this->splitIntoBlock('div,p',$value,1); // Setting the third param to 1 will eliminate false end-tags. Maybe this is a good thing to do...?
if ($this->procOptions['keepPDIVattribs']) {
$keepAttribListArr = t3lib_div::trimExplode(',',strtolower($this->procOptions['keepPDIVattribs']),1);
} else {
$keepAttribListArr = array();
}
// Returns plainly the value if there was no div/p sections in it
if (count($divSplit)<=1 || $count<=0) {
return $value;
}
// Traverse the splitted sections:
foreach($divSplit as $k => $v) {
if ($k%2) { // Inside
$v=$this->removeFirstAndLastTag($v);
// Fetching 'sub-lines' - which will explode any further p/div nesting...
$subLines = $this->divideIntoLines($v,$count-1,1);
if (is_array($subLines)) { // So, if there happend to be sub-nesting of p/div, this is written directly as the new content of THIS section. (This would be considered 'an error')
// No noting.
} else { //... but if NO subsection was found, we process it as a TRUE line without erronous content:
$subLines = array($subLines);
if (!$this->procOptions['dontConvBRtoParagraph']) { // process break-tags, if configured for. Simply, the breaktags will here be treated like if each was a line of content...
$subLines = spliti('
',$v);
}
// Traverse sublines (there is typically one, except if
has been converted to lines as well!)
reset($subLines);
while(list($sk)=each($subLines)) {
// Clear up the subline for DB.
$subLines[$sk]=$this->HTMLcleaner_db($subLines[$sk]);
// Get first tag, attributes etc:
$fTag = $this->getFirstTag($divSplit[$k]);
$tagName=strtolower($this->getFirstTagName($divSplit[$k]));
$attribs=$this->get_tag_attributes($fTag);
// Keep attributes (lowercase)
$newAttribs=array();
if (count($keepAttribListArr)) {
foreach($keepAttribListArr as $keepA) {
if (isset($attribs[0][$keepA])) { $newAttribs[$keepA] = $attribs[0][$keepA]; }
}
}
// ALIGN attribute:
if (!$this->procOptions['skipAlign'] && strcmp(trim($attribs[0]['align']),'') && strtolower($attribs[0]['align'])!='left') { // Set to value, but not 'left'
$newAttribs['align']=strtolower($attribs[0]['align']);
}
// CLASS attribute:
if (!$this->procOptions['skipClass'] && strcmp(trim($attribs[0]['class']),'')) { // Set to whatever value
if (!count($this->allowedClasses) || in_array(strtoupper($attribs[0]['class']),$this->allowedClasses)) {
$newAttribs['class']=$attribs[0]['class'];
}
}
// Remove any line break char (10 or 13)
$subLines[$sk]=ereg_replace(chr(10).'|'.chr(13),'',$subLines[$sk]);
// If there are any attributes or if we are supposed to remap the tag, then do so:
if (count($newAttribs) && strcmp($remapParagraphTag,'1')) {
if ($remapParagraphTag=='P') $tagName='p';
if ($remapParagraphTag=='DIV') $tagName='div';
$subLines[$sk]='<'.trim($tagName.' '.$this->compileTagAttribs($newAttribs)).'>'.$subLines[$sk].''.$tagName.'>';
}
}
}
// Add the processed line(s)
$divSplit[$k] = implode(chr(10),$subLines);
// If it turns out the line is just blank (containing a possibly) then just make it pure blank.
// But, prevent filtering of lines that are blank in sense above, but whose tags contain attributes.
// Those attributes should have been filtered before; if they are still there they must be considered as possible content.
if (trim(strip_tags($divSplit[$k]))==' ' && !preg_match('/\<(img)(\s[^>]*)?\/?>/si', $divSplit[$k]) && !preg_match('/\<([^>]*)?( align| class| style| id| title| dir| lang| xml:lang)([^>]*)?>/si', trim($divSplit[$k]))) {
$divSplit[$k]='';
}
} else { // outside div:
// Remove positions which are outside div/p tags and without content
$divSplit[$k]=trim(strip_tags($divSplit[$k],'<'.implode('><',$allowTagsOutside).'>'));
if (!strcmp($divSplit[$k],'')) unset($divSplit[$k]); // Remove part if it's empty
}
}
// Return value:
return $returnArray ? $divSplit : implode(chr(10),$divSplit);
}
/**
* Converts all lines into
/-sections (unless the line is a div-section already)
* For processing of content going FROM database TO RTE.
*
* @param string Value to convert
* @param string Tag to wrap with. Either "p" or "div" should it be. Lowercase preferably.
* @return string Processed value.
* @see divideIntoLines()
*/
function setDivTags($value,$dT='p') {
// First, setting configuration for the HTMLcleaner function. This will process each line between the /
section on their way to the RTE
$keepTags = $this->getKeepTags('rte');
$kUknown = $this->procOptions['dontProtectUnknownTags_rte'] ? 0 : 'protect'; // Default: remove unknown tags.
$hSC = $this->procOptions['dontHSC_rte'] ? 0 : 1; // Default: re-convert literals to characters (that is < to <)
$convNBSP = !$this->procOptions['dontConvAmpInNBSP_rte']?1:0;
// Divide the content into lines, based on chr(10):
$parts = explode(chr(10),$value);
foreach($parts as $k => $v) {
// Processing of line content:
if (!strcmp(trim($parts[$k]),'')) { // If the line is blank, set it to
$parts[$k]=' ';
} else { // Clean the line content:
$parts[$k]=$this->HTMLcleaner($parts[$k],$keepTags,$kUknown,$hSC);
if ($convNBSP) $parts[$k]=str_replace(' ',' ',$parts[$k]);
}
// Wrapping the line in <$dT> is not already wrapped:
$testStr = strtolower(trim($parts[$k]));
if (substr($testStr,0,4)!='
') {
if (substr($testStr,0,2)!='
') {
// Only set p-tags if there is not already div or p tags:
$parts[$k]='<'.$dT.'>'.$parts[$k].''.$dT.'>';
}
}
}
// Implode result:
return implode(chr(10),$parts);
}
/**
* This splits the $value in font-tag chunks.
* If there are any
/
sections inside of them, the font-tag is wrapped AROUND the content INSIDE of the P/DIV sections and the outer font-tag is removed.
* This functions seems to be a good choice for pre-processing content if it has been pasted into the RTE from eg. star-office.
* In that case the font-tags are normally on the OUTSIDE of the sections.
* This function is used by eg. divideIntoLines() if the procesing option 'internalizeFontTags' is set.
*
* @param string Input content
* @return string Output content
* @see divideIntoLines()
*/
function internalizeFontTags($value) {
// Splitting into font tag blocks:
$fontSplit = $this->splitIntoBlock('font',$value);
foreach($fontSplit as $k => $v) {
if ($k%2) { // Inside
$fTag = $this->getFirstTag($v); // Fint font-tag
$divSplit_sub = $this->splitIntoBlock('div,p',$this->removeFirstAndLastTag($v),1);
if (count($divSplit_sub)>1) { // If there were div/p sections inside the font-tag, do something about it...
// traverse those sections:
foreach($divSplit_sub as $k2 => $v2) {
if ($k2%2) { // Inside
$div_p = $this->getFirstTag($v2); // Fint font-tag
$div_p_tagname = $this->getFirstTagName($v2); // Fint font-tag
$v2=$this->removeFirstAndLastTag($v2); // ... and remove it from original.
$divSplit_sub[$k2]=$div_p.$fTag.$v2.''.''.$div_p_tagname.'>';
} elseif (trim(strip_tags($v2))) {
$divSplit_sub[$k2]=$fTag.$v2.'';
}
}
$fontSplit[$k]=implode('',$divSplit_sub);
}
}
}
return implode('',$fontSplit);
}
/**
* Returns SiteURL based on thisScript.
*
* @return string Value of t3lib_div::getIndpEnv('TYPO3_SITE_URL');
* @see t3lib_div::getIndpEnv()
*/
function siteUrl() {
return t3lib_div::getIndpEnv('TYPO3_SITE_URL');
}
/**
* Return the storage folder of RTE image files.
* Default is $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'] unless something else is configured in the types configuration for the RTE.
*
* @return string
*/
function rteImageStorageDir() {
return $this->rte_p['imgpath'] ? $this->rte_p['imgpath'] : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];
}
/**
* 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.
*
* @param string Input value
* @param string Break character to use for linebreaks.
* @return string Output value
*/
function removeTables($value,$breakChar='
') {
// Splitting value into table blocks:
$tableSplit = $this->splitIntoBlock('table',$value);
// Traverse blocks of tables:
foreach($tableSplit as $k => $v) {
if ($k%2) {
$tableSplit[$k]='';
$rowSplit = $this->splitIntoBlock('tr',$v);
foreach($rowSplit as $k2 => $v2) {
if ($k2%2) {
$cellSplit = $this->getAllParts($this->splitIntoBlock('td',$v2),1,0);
foreach($cellSplit as $k3 => $v3) {
$tableSplit[$k].=$v3.$breakChar;
}
}
}
}
}
// Implode it all again:
return implode($breakChar,$tableSplit);
}
/**
* Default tag mapping for TS
*
* @param string Input code to process
* @param string Direction To databsae (db) or from database to RTE (rte)
* @return string Processed value
*/
function defaultTStagMapping($code,$direction='rte') {
if ($direction=='db') {
$code=$this->mapTags($code,array( // Map tags
'strong' => 'b',
'em' => 'i'
));
}
if ($direction=='rte') {
$code=$this->mapTags($code,array( // Map tags
'b' => 'strong',
'i' => 'em'
));
}
return $code;
}
/**
* Finds width and height from attrib-array
* If the width and height is found in the style-attribute, use that!
*
* @param array Array 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
* @return array Integer w/h in key 0/1. Zero is returned if not found.
*/
function getWHFromAttribs($attribArray) {
$style =trim($attribArray['style']);
if ($style) {
$regex='[[:space:]]*:[[:space:]]*([0-9]*)[[:space:]]*px';
// Width
$reg = array();
eregi('width'.$regex,$style,$reg);
$w = intval($reg[1]);
// Height
eregi('height'.$regex,$style,$reg);
$h = intval($reg[1]);
}
if (!$w) {
$w = $attribArray['width'];
}
if (!$h) {
$h = $attribArray['height'];
}
return array(intval($w),intval($h));
}
/**
* Parse
-tag href and return status of email,external,file or page
*
* @param string URL to analyse.
* @return array Information in an array about the URL
*/
function urlInfoForLinkTags($url) {
$info = array();
$url = trim($url);
if (substr(strtolower($url),0,7)=='mailto:') {
$info['url']=trim(substr($url,7));
$info['type']='email';
} else {
$curURL = $this->siteUrl(); // 100502, removed this: 'http://'.t3lib_div::getThisUrl(); Reason: The url returned had typo3/ in the end - should be only the site's url as far as I see...
for($a=0;$a-tags to absolute URLs (+ setting rtekeep attribute)
*
* @param string Content input
* @param boolean If true, then the "rtekeep" attribute will not be set.
* @return string Content output
*/
function TS_AtagToAbs($value,$dontSetRTEKEEP=FALSE) {
$blockSplit = $this->splitIntoBlock('A',$value);
reset($blockSplit);
while(list($k,$v)=each($blockSplit)) {
if ($k%2) { // block:
$attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
// Checking if there is a scheme, and if not, prepend the current url.
if (strlen($attribArray['href'])) { // ONLY do this if href has content - the tag COULD be an anchor and if so, it should be preserved...
$uP = parse_url(strtolower($attribArray['href']));
if (!$uP['scheme']) {
$attribArray['href'] = $this->siteUrl().substr($attribArray['href'],strlen($this->relBackPath));
}
} else {
$attribArray['rtekeep'] = 1;
}
if (!$dontSetRTEKEEP) $attribArray['rtekeep'] = 1;
$bTag='';
$eTag='';
$blockSplit[$k] = $bTag.$this->TS_AtagToAbs($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
}
}
return implode('',$blockSplit);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_parsehtml_proc.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_parsehtml_proc.php']);
}
?>