Project

General

Profile

Bug #19532 ยป substituteMarkerArrayNotCached.diff

Administrator Admin, 2008-10-30 13:54

View differences:

typo3/sysext/cms/tslib/class.tslib_content.php (working copy)
$GLOBALS['TT']->pull();
return $content;
}
/**
* Multi substitution function without caching.
*
* This function should be a one-stop substitution function for working
* with HTML-template. It does not substitute by str_replace but by
* splitting. This secures that the value inserted does not themselves
* contain markers or subparts.
*
* This function takes three kinds of substitutions in one:
* $markContentArray is a regular marker-array where the 'keys' are
* substituted in $content with their values
*
* $subpartContentArray works exactly like markContentArray only is whole
* subparts substituted and not only a single marker.
*
* $wrappedSubpartContentArray is an array of arrays with 0/1 keys where
* the subparts pointed to by the main key is wrapped with the 0/1 value
* alternating.
*
* @param string The content stream, typically HTML template content.
* @param array Regular marker-array where the 'keys' are substituted in $content with their values
* @param array Exactly like markContentArray only is whole subparts substituted and not only a single marker.
* @param array An array of arrays with 0/1 keys where the subparts pointed to by the main key is wrapped with the 0/1 value alternating.
* @return string The output content stream
* @see substituteSubpart(), substituteMarker(), substituteMarkerInObject(), substituteMarkerArrayCached(), TEMPLATE()
*/
function substituteMarkerArrayNotCached($content, array $markContentArray=array(), array $subpartContentArray=array(), array $wrappedSubpartContentArray=array()) {
// Finding keys
$subpartKeys = array_keys($subpartContentArray);
$wrappedSubpartKeys = array_keys($wrappedSubpartContentArray);
// Finding subparts and substituting them with the subpart as a marker
foreach($subpartKeys as $key) {
$content = $this->substituteSubpart($content, $key, $subpartContentArray[$key]);
}
// Finding subparts and wrapping them with markers
foreach($wrappedSubpartKeys as $key) {
if(is_array($wrappedSubpartContentArray[$key])) {
$parts = $wrappedSubpartContentArray[$key];
} else {
$parts = t3lib_div::trimExplode('|', $wrappedSubpartContentArray[$key], false);
}
$content = $this->substituteSubpart($content, $key, $parts);
}
return $this->substituteMarkerArray($content, $markContentArray);
}
/**
* Traverses the input $markContentArray array and for each key the marker
* by the same name (possibly wrapped and in upper case) will be
    (1-1/1)