Bug #23823 ยป tslib_content_v2.diff
typo3/sysext/cms/tslib/class.tslib_content.php (revision ) | ||
---|---|---|
* @see stdWrap()
|
||
*/
|
||
var $stdWrapOrder = array(
|
||
'stdWrapPreProcess' => 1, // this is a placeholder for the first Hook
|
||
'setContentToCurrent' => 1,
|
||
'setContentToCurrent.' => 1,
|
||
'setCurrent' => 1,
|
||
'setCurrent.' => 1,
|
||
'lang' => 1,
|
||
'lang.' => 1,
|
||
'data' => 1,
|
||
'data.' => 1,
|
||
'field' => 1,
|
||
'field.' => 1,
|
||
'current' => 1,
|
||
'current.' => 1,
|
||
'cObject' => 1,
|
||
'cObject.' => 1,
|
||
'numRows' => 1,
|
||
'numRows.' => 1,
|
||
'filelist' => 1,
|
||
'filelist.' => 1,
|
||
'preUserFunc' => 1,
|
||
'preUserFunc.' => 1,
|
||
'stdWrapOverride' => 1, // this is a placeholder for the second Hook
|
||
'override' => 1,
|
||
'override.' => 1,
|
||
'preIfEmptyListNum' => 1,
|
||
'preIfEmptyListNum.' => 1,
|
||
'ifEmpty' => 1,
|
||
'ifEmpty.' => 1,
|
||
'ifBlank' => 1,
|
||
'ifBlank.' => 1,
|
||
'listNum' => 1,
|
||
'listNum.' => 1,
|
||
'trim' => 1,
|
||
'trim.' => 1,
|
||
'stdWrap' => 1,
|
||
'stdWrap.' => 1,
|
||
'stdWrapProcess' => 1, // this is a placeholder for the third Hook
|
||
'required' => 1,
|
||
'required.' => 1,
|
||
'if' => 1,
|
||
'if.' => 1,
|
||
'fieldRequired' => 1,
|
||
'fieldRequired.' => 1,
|
||
'csConv' => 1,
|
||
'csConv.' => 1,
|
||
'parseFunc' => 1,
|
||
'parseFunc.' => 1,
|
||
'HTMLparser' => 1,
|
||
'HTMLparser.' => 1,
|
||
'split' => 1,
|
||
'split.' => 1,
|
||
'prioriCalc' => 1,
|
||
'prioriCalc.' => 1,
|
||
'char' => 1,
|
||
'char.' => 1,
|
||
'intval' => 1,
|
||
'intval.' => 1,
|
||
'numberFormat' => 1,
|
||
'numberFormat.' => 1,
|
||
'date' => 1,
|
||
'date.' => 1,
|
||
'strftime' => 1,
|
||
'strftime.' => 1,
|
||
'age' => 1,
|
||
'age.' => 1,
|
||
'case' => 1,
|
||
'case.' => 1,
|
||
'bytes' => 1,
|
||
'bytes.' => 1,
|
||
'substring' => 1,
|
||
'substring.' => 1,
|
||
'removeBadHTML' => 1,
|
||
'removeBadHTML.' => 1,
|
||
'cropHTML' => 1,
|
||
'cropHTML.' => 1,
|
||
'stripHtml' => 1,
|
||
'stripHtml.' => 1,
|
||
'crop' => 1,
|
||
'crop.' => 1,
|
||
'rawUrlEncode' => 1,
|
||
'rawUrlEncode.' => 1,
|
||
'htmlSpecialChars' => 1,
|
||
'htmlSpecialChars.' => 1,
|
||
'doubleBrTag' => 1,
|
||
'doubleBrTag.' => 1,
|
||
'br' => 1,
|
||
'br.' => 1,
|
||
'brTag' => 1,
|
||
'brTag.' => 1,
|
||
'encapsLines' => 1,
|
||
'encapsLines.' => 1,
|
||
'keywords' => 1,
|
||
'keywords.' => 1,
|
||
'innerWrap' => 1,
|
||
'innerWrap.' => 1,
|
||
'innerWrap2' => 1,
|
||
'innerWrap2.' => 1,
|
||
'fontTag' => 1,
|
||
'fontTag.' => 1,
|
||
'addParams' => 1,
|
||
'addParams.' => 1,
|
||
'textStyle' => 1,
|
||
'textStyle.' => 1,
|
||
'tableStyle' => 1,
|
||
'tableStyle.' => 1,
|
||
'filelink' => 1,
|
||
'filelink.' => 1,
|
||
'preCObject' => 1,
|
||
'preCObject.' => 1,
|
||
'postCObject' => 1,
|
||
'postCObject.' => 1,
|
||
'wrapAlign' => 1,
|
||
'wrapAlign.' => 1,
|
||
'typolink' => 1,
|
||
'typolink.' => 1,
|
||
'TCAselectItem' => 1,
|
||
'TCAselectItem.' => 1,
|
||
'space' => 1,
|
||
'space.' => 1,
|
||
'spaceBefore' => 1,
|
||
'spaceBefore.' => 1,
|
||
'spaceAfter' => 1,
|
||
'spaceAfter.' => 1,
|
||
'wrap' => 1,
|
||
'wrap.' => 1,
|
||
'noTrimWrap' => 1,
|
||
'noTrimWrap.' => 1,
|
||
'wrap2' => 1,
|
||
'wrap2.' => 1,
|
||
'dataWrap' => 1,
|
||
'dataWrap.' => 1,
|
||
'prepend' => 1,
|
||
'prepend.' => 1,
|
||
'append' => 1,
|
||
'append.' => 1,
|
||
'wrap3' => 1,
|
||
'wrap3.' => 1,
|
||
'outerWrap' => 1,
|
||
'outerWrap.' => 1,
|
||
'insertData' => 1,
|
||
'insertData.' => 1,
|
||
'offsetWrap' => 1,
|
||
'offsetWrap.' => 1,
|
||
'postUserFunc' => 1,
|
||
'postUserFunc.' => 1,
|
||
'postUserFuncInt' => 1,
|
||
'postUserFuncInt.' => 1,
|
||
'prefixComment' => 1,
|
||
'prefixComment.' => 1,
|
||
'editIcons' => 1,
|
||
'editIcons.' => 1,
|
||
'editPanel' => 1,
|
||
'editPanel.' => 1,
|
||
'stdWrapPostProcess' => 1, // this is a placeholder for the last Hook
|
||
'debug' => 1,
|
||
'debug.' => 1,
|
||
'debugFunc' => 1,
|
||
'debugFunc.' => 1,
|
||
'debugData' => 1,
|
||
'debugData.' => 1
|
||
'stdWrapPreProcess' => 'hook', // this is a placeholder for the first Hook
|
||
'setContentToCurrent' => 'boolean',
|
||
'setContentToCurrent.' => 'array',
|
||
'setCurrent' => 'string',
|
||
'setCurrent.' => 'array',
|
||
'lang.' => 'array',
|
||
'data' => 'getText',
|
||
'data.' => 'array',
|
||
'field' => 'fieldname',
|
||
'field.' => 'array',
|
||
'current' => 'boolean',
|
||
'current.' => 'array',
|
||
'cObject' => 'cObject',
|
||
'cObject.' => 'array',
|
||
'numRows.' => 'array',
|
||
'filelist' => 'dir',
|
||
'filelist.' => 'array',
|
||
'preUserFunc' => 'functionname',
|
||
'stdWrapOverride' => 'hook', // this is a placeholder for the second Hook
|
||
'override' => 'string',
|
||
'override.' => 'array',
|
||
'preIfEmptyListNum' => 'listNum',
|
||
'preIfEmptyListNum.' => 'array',
|
||
'ifEmpty' => 'string',
|
||
'ifEmpty.' => 'array',
|
||
'ifBlank' => 'string',
|
||
'ifBlank.' => 'array',
|
||
'listNum' => 'listNum',
|
||
'listNum.' => 'array',
|
||
'trim' => 'boolean',
|
||
'trim.' => 'array',
|
||
'stdWrap' => 'stdWrap',
|
||
'stdWrap.' => 'array',
|
||
'stdWrapProcess' => 'hook', // this is a placeholder for the third Hook
|
||
'required' => 'boolean',
|
||
'required.' => 'array',
|
||
'if.' => 'array',
|
||
'fieldRequired' => 'fieldname',
|
||
'fieldRequired.' => 'array',
|
||
'csConv' => 'string',
|
||
'csConv.' => 'array',
|
||
'parseFunc' => 'objectpath',
|
||
'parseFunc.' => 'array',
|
||
'HTMLparser' => 'boolean',
|
||
'HTMLparser.' => 'array',
|
||
'split.' => 'array',
|
||
'prioriCalc' => 'boolean',
|
||
'prioriCalc.' => 'array',
|
||
'char' => 'integer',
|
||
'char.' => 'array',
|
||
'intval' => 'boolean',
|
||
'intval.' => 'array',
|
||
'numberFormat.' => 'array',
|
||
'date' => 'dateconf',
|
||
'date.' => 'array',
|
||
'strftime' => 'strftimeconf',
|
||
'strftime.' => 'array',
|
||
'age' => 'boolean',
|
||
'age.' => 'array',
|
||
'case' => 'case',
|
||
'case.' => 'array',
|
||
'bytes' => 'boolean',
|
||
'bytes.' => 'array',
|
||
'substring' => 'parameters',
|
||
'substring.' => 'array',
|
||
'removeBadHTML' => 'boolean',
|
||
'removeBadHTML.' => 'array',
|
||
'cropHTML' => 'crop',
|
||
'cropHTML.' => 'array',
|
||
'stripHtml' => 'boolean',
|
||
'stripHtml.' => 'array',
|
||
'crop' => 'crop',
|
||
'crop.' => 'array',
|
||
'rawUrlEncode' => 'boolean',
|
||
'rawUrlEncode.' => 'array',
|
||
'htmlSpecialChars' => 'boolean',
|
||
'htmlSpecialChars.' => 'array',
|
||
'doubleBrTag' => 'string',
|
||
'doubleBrTag.' => 'array',
|
||
'br' => 'boolean',
|
||
'br.' => 'array',
|
||
'brTag' => 'string',
|
||
'brTag.' => 'array',
|
||
'encapsLines.' => 'array',
|
||
'keywords' => 'boolean',
|
||
'keywords.' => 'array',
|
||
'innerWrap' => 'wrap',
|
||
'innerWrap.' => 'array',
|
||
'innerWrap2' => 'wrap',
|
||
'innerWrap2.' => 'array',
|
||
'fontTag' => 'wrap',
|
||
'fontTag.' => 'array',
|
||
'addParams.' => 'array',
|
||
'textStyle.' => 'array',
|
||
'tableStyle.' => 'array',
|
||
'filelink.' => 'array',
|
||
'preCObject' => 'cObject',
|
||
'preCObject.' => 'array',
|
||
'postCObject' => 'cObject',
|
||
'postCObject.' => 'array',
|
||
'wrapAlign' => 'align',
|
||
'wrapAlign.' => 'array',
|
||
'typolink.' => 'array',
|
||
'TCAselectItem.' => 'array',
|
||
'space' => 'space',
|
||
'space.' => 'array',
|
||
'spaceBefore' => 'int',
|
||
'spaceBefore.' => 'array',
|
||
'spaceAfter' => 'int',
|
||
'spaceAfter.' => 'array',
|
||
'wrap' => 'wrap',
|
||
'wrap.' => 'array',
|
||
'noTrimWrap' => 'wrap',
|
||
'noTrimWrap.' => 'array',
|
||
'wrap2' => 'wrap',
|
||
'wrap2.' => 'array',
|
||
'dataWrap' => 'dataWrap',
|
||
'dataWrap.' => 'array',
|
||
'prepend' => 'cObject',
|
||
'prepend.' => 'array',
|
||
'append' => 'cObject',
|
||
'append.' => 'array',
|
||
'wrap3' => 'wrap',
|
||
'wrap3.' => 'array',
|
||
'outerWrap' => 'wrap',
|
||
'outerWrap.' => 'array',
|
||
'insertData' => 'boolean',
|
||
'insertData.' => 'array',
|
||
'offsetWrap' => 'space',
|
||
'offsetWrap.' => 'array',
|
||
'postUserFunc' => 'functionname',
|
||
'postUserFuncInt' => 'functionname',
|
||
'prefixComment' => 'string',
|
||
'prefixComment.' => 'array',
|
||
'editIcons' => 'string',
|
||
'editIcons.' => 'array',
|
||
'editPanel' => 'boolean',
|
||
'editPanel.' => 'array',
|
||
'stdWrapPostProcess' => 'hook', // this is a placeholder for the last Hook
|
||
'debug' => 'boolean',
|
||
'debug.' => 'array',
|
||
'debugFunc' => 'boolean',
|
||
'debugFunc.' => 'array',
|
||
'debugData' => 'boolean',
|
||
'debugData.' => 'array'
|
||
);
|
||
|
||
/**
|
||
... | ... | |
// and keep only those but still in the same order
|
||
$sortedConf = array_intersect_key($this->stdWrapOrder, $conf);
|
||
// functions that should not make use of nested stdWrap function calls to avoid conflicts with internal TypoScript used by these functions
|
||
$stdWrapDisabledFunctions = 'cObject,preUserFunc,stdWrap,preCObject,postCObject,prepend,append,postUserFunc,postUserFuncInt';
|
||
$stdWrapDisabledFunctions = 'cObject,functionname';
|
||
// additional Array to check whether a function has already been executed
|
||
$isExecuted = array();
|
||
// additional switch to make sure 'required', 'if' and 'fieldRequired'
|
||
// will still stop rendering immediately in case they return false
|
||
$this->stopRendering = false;
|
||
|
||
$this->stdWrapRecursionLevel++;
|
||
$this->stopRendering[$this->stdWrapRecursionLevel] = false;
|
||
|
||
// execute each funtion in the predefined order
|
||
foreach ($sortedConf as $stdWrapName => $enabled) {
|
||
foreach ($sortedConf as $stdWrapName => $functionType) {
|
||
|
||
// eliminate the second key of a pair 'key'|'key.' to make sure functions get called only once and check if rendering has been stopped
|
||
if (!$isExecuted[$stdWrapName] && !$this->stopRendering) {
|
||
if (!$isExecuted[$stdWrapName] &&
|
||
!$this->stopRendering[$this->stdWrapRecursionLevel]) {
|
||
$functionName = rtrim($stdWrapName, '.');
|
||
$functionProperties = $functionName . '.';
|
||
// if there is any code one the next level, check if it contains "official" stdWrap functions
|
||
... | ... | |
// so additional stdWrap calls within the functions can be removed, since the result will be the same
|
||
// exception: the recursive stdWrap function and cObject will still be using their own stdWrap call, since it modifies the content and not a property
|
||
if (count($conf[$functionProperties]) &&
|
||
!t3lib_div::inList($stdWrapDisabledFunctions, $functionName)) {
|
||
!t3lib_div::inList($stdWrapDisabledFunctions, $functionType)) {
|
||
if (array_intersect_key($this->stdWrapOrder, $conf[$functionProperties])) {
|
||
$conf[$functionName] = $this->stdWrap($conf[$functionName], $conf[$functionProperties]);
|
||
}
|
||
... | ... | |
if ($conf[$functionName] == 'stdWrapHookObject') {
|
||
$singleConf = $conf;
|
||
}
|
||
|
||
// check if key is still containing something, since it might have been changed by next level stdWrap before
|
||
if ($conf[$functionName] || $conf[$functionProperties]) {
|
||
if ((isset($conf[$functionName]) || $conf[$functionProperties]) &&
|
||
!($functionType == 'boolean' && $conf[$functionName] === '0')) {
|
||
//add both keys - with and without the dot - to the set of executed functions
|
||
$isExecuted[$functionName] = true;
|
||
$isExecuted[$functionProperties] = true;
|
||
... | ... | |
);
|
||
}
|
||
}
|
||
unset($this->stopRendering[$this->stdWrapRecursionLevel]);
|
||
$this->stdWrapRecursionLevel--;
|
||
}
|
||
}
|
||
return $content;
|
||
... | ... | |
public function stdWrap_required($content = '', $conf = array()) {
|
||
if ((string) $content == '') {
|
||
$content = '';
|
||
$this->stopRendering = TRUE;
|
||
$this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
|
||
}
|
||
return $content;
|
||
}
|
||
... | ... | |
public function stdWrap_if($content = '', $conf = array()) {
|
||
if (!$this->checkIf($conf['if.'])) {
|
||
$content = '';
|
||
$this->stopRendering = TRUE;
|
||
$this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
|
||
}
|
||
return $content;
|
||
}
|
||
... | ... | |
public function stdWrap_fieldRequired($content = '', $conf = array()) {
|
||
if (!trim($this->data[$conf['fieldRequired']])) {
|
||
$content = '';
|
||
$this->stopRendering = TRUE;
|
||
$this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
|
||
}
|
||
return $content;
|
||
}
|