Project

General

Profile

Bug #14988 » bug_1477_stucki.diff

Administrator Admin, 2007-04-20 17:20

View differences:

t3lib/class.t3lib_parsehtml.php (Arbeitskopie)
* @param array $tags; is an array where each key is a tagname in lowercase. Only tags present as keys in this array are preserved. The value of the key can be an array with a vast number of options to configure.
* @param string $keepAll; boolean/'protect', if set, then all tags are kept regardless of tags present as keys in $tags-array. If 'protect' then the preserved tags have their <> converted to &lt; and &gt;
* @param integer $hSC; Values -1,0,1,2: Set to zero= disabled, set to 1 then the content BETWEEN tags is htmlspecialchar()'ed, set to -1 its the opposite and set to 2 the content will be HSC'ed BUT with preservation for real entities (eg. "&amp;" or "&#234;")
* @param array Configuration array send along as $conf to the internal functions ->processContent() and ->processTag()
* @param array $addConfig; Configuration array send along as $conf to the internal functions ->processContent() and ->processTag()
* @param string $preserveContent; Comma-separated list of tags whose content must not be modified. Useful for JavaScript code, etc. TODO: Maybe it would be good to check if the preserved content is really wrapped inside HTML comment tags.
* @return string Processed HTML content
*/
function HTMLcleaner($content, $tags=array(),$keepAll=0,$hSC=0,$addConfig=array()) {
function HTMLcleaner($content,$tags=array(),$keepAll=0,$hSC=0,$addConfig=array(),$preserveContent='style,script') {
if ($preserveContent) {
$preserveContentArr = array();
$preserveContentTags = t3lib_div::trimExplode(',',$preserveContent);
foreach($preserveContentTags as $preserveContentTag) {
unset($res);
if (preg_match_all('/<'.preg_quote($preserveContentTag,'/').'.*?>(.*?)<\/'.preg_quote($preserveContentTag,'/').'>/s',$content,$res)) {
array_shift($res);
while(list($key,$preservePart)=each($res[0])) {
$key = '###PRESERVE_PART_'.strtoupper($preserveContentTag).'_'.$key.'###';
$preserveContentArr[$key] = $preservePart;
$content = str_replace($preservePart,$key,$content);
}
}
}
}
$newContent = array();
$tokArr = explode('<',$content);
$newContent[] = $this->processContent(current($tokArr),$hSC,$addConfig);
......
}
}
return implode('',$newContent);
$content = implode('',$newContent);
// Restoring preserved content
reset($preserveContentArr);
while(list($key,$preservePart)=each($preserveContentArr)) {
$content = str_replace($key,$preservePart,$content);
}
unset($preserveContentArr);
return $content;
}
/**
(3-3/3)