Feature #19347 » 0009373.patch
typo3/sysext/cms/tslib/class.tslib_content.php (Arbeitskopie) | ||
---|---|---|
$content = '';
|
||
} else {
|
||
// Perform data processing:
|
||
if (isset($conf['replacement.'])) {
|
||
$content = $this->processReplacement($content, $conf['replacement.']);
|
||
}
|
||
if ($conf['csConv']) { $content=$GLOBALS['TSFE']->csConv($content,$conf['csConv']); }
|
||
if ($conf['parseFunc.'] || $conf['parseFunc']) {$content=$this->parseFunc($content,$conf['parseFunc.'],$conf['parseFunc']);}
|
||
if ($conf['HTMLparser'] && is_array($conf['HTMLparser.'])) {$content=$this->HTMLparser_TSbridge($content,$conf['HTMLparser.']);}
|
||
... | ... | |
}
|
||
/**
|
||
* Processes ordered replacements on content data.
|
||
*
|
||
* @param string $content: The content to be processed
|
||
* @param array $configuration: The TypoScript configuration for stdWrap.replacement
|
||
* @return string The processed content data
|
||
*/
|
||
public function processReplacement($content, array $configuration) {
|
||
// Sorts actions in configuration:
|
||
ksort($configuration);
|
||
foreach ($configuration as $index => $action) {
|
||
// Checks whether we have an valid action and a numeric key ending with a dot ("10."):
|
||
if (is_array($action) && substr($index, -1) === '.' && t3lib_div::testInt(substr($index, 0, -1))) {
|
||
$content = $this->processReplacementAction($content, $action);
|
||
}
|
||
}
|
||
return $content;
|
||
}
|
||
/**
|
||
* Processes a single search/replace on content data.
|
||
*
|
||
* @param string $content: The content to be processed
|
||
* @param array $configuration: The TypoScript of the search/replace action to be processed
|
||
* @return string The processed content data
|
||
*/
|
||
protected function processReplacementAction($content, array $configuration) {
|
||
if ((isset($configuration['search']) || isset($configuration['search.']))
|
||
&& (isset($configuration['replace']) || isset($configuration['replace.']))) {
|
||
// Gets the search needle:
|
||
$search = $this->stdWrap($configuration['search'], $configuration['search.']);
|
||
// Determines whether regular expression shall be used:
|
||
if (isset($configuration['useRegExp']) || $configuration['useRegExp.']) {
|
||
$useRegularExpression = $this->stdWrap($configuration['useRegExp'], $configuration['useRegExp.']);
|
||
}
|
||
// Performs a replacement by preg_replace():
|
||
if ($useRegularExpression) {
|
||
$replace = $this->stdWrap($configuration['replace'], $configuration['replace.']);
|
||
$content = preg_replace($search, $replace, $content);
|
||
// Checks whether the search needle is part of the content:
|
||
} elseif (strpos($content, $search) !== false) {
|
||
$replace = $this->stdWrap($configuration['replace'], $configuration['replace.']);
|
||
$content = str_replace($search, $replace, $content);
|
||
}
|
||
}
|
||
return $content;
|
||
}
|
||
/**
|
||
* Implements the stdWrap property, "parseFunc".
|
||
* This is a function with a lot of interesting uses. In classic TypoScript this is used to process text from the bodytext field; This included highlighting of search words, changing http:// and mailto: prefixed strings into links, parsing <typolist>, <typohead> and <typocode> tags etc.
|
||
* It is still a very important function for processing of bodytext which is normally stored in the database in a format which is not fully ready to be outputted. This situation has not become better by having a RTE around...
|