Index: typo3/sysext/cms/tslib/class.tslib_content.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_content.php (revision 2772) +++ typo3/sysext/cms/tslib/class.tslib_content.php (working copy) @@ -338,6 +338,7 @@ var $substMarkerCache=array(); // Caching substituteMarkerArrayCached function var $recordRegister=array(); // Array that registers rendered content elements (or any table) to make sure they are not rendered recursively! var $cObjHookObjectsArr = array(); // Containig hooks for userdefined cObjects + private $stdWrapHookObjects = array(); // Containig hook objects for stdWrap /** * Class constructor. @@ -358,6 +359,19 @@ $this->cObjHookObjectsArr[$classArr[0]] = &t3lib_div::getUserObj($classArr[1]); } } + + if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'])) { + foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] as $classData) { + $hookObject = &t3lib_div::getUserObj($classData); + + if(!($hookObject instanceof tslib_content_stdWrapHook)) { + throw new UnexpectedValueException('$hookObject must implement interface tslib_content_stdWrapHook', 1195043965); + } + + $this->stdWrapHookObjects[] = $hookObject; + } + } + } /** @@ -443,6 +457,8 @@ * @example http://typo3.org/doc.0.html?&encryptionKey=&tx_extrepmgm_pi1[extUid]=267&tx_extrepmgm_pi1[tocEl]=153&cHash=7e74f4d331 */ function cObjGetSingle($name,$conf,$TSkey='__') { + global $TYPO3_CONF_VARS; + $content=''; // Checking that the function is not called eternally. This is done by interrupting at a depth of 100 $GLOBALS['TSFE']->cObjectDepthCounter--; @@ -566,6 +582,20 @@ case 'MULTIMEDIA': $content.=$this->MULTIMEDIA($conf); break; + default: + // call hook functions for extra processing + if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) { + foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData) { + $hookObject = &t3lib_div::getUserObj($classData); + + if(!($hookObject instanceof tslib_content_cObjGetSingleHook)) { + throw new UnexpectedValueException('$hookObject must implement interface tslib_content_cObjGetSingleHook', 1195043731); + } + + $content .= $hookObject->getSingleContentObject($name, $conf, $TSkey, $this); + } + } + break; } } } @@ -3124,6 +3154,10 @@ function stdWrap($content,$conf) { if (is_array($conf)) { + foreach($this->stdWrapHookObjects as $hookObject) { + $content = $hookObject->stdWrapPreProcess($content, $conf, $this); + } + // Setting current value, if so if ($conf['setContentToCurrent']){$this->data[$this->currentValKey]=$content;} if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);} @@ -3141,6 +3175,10 @@ if ($conf['filelist'] || $conf['filelist.']) {$content=$this->filelist($this->stdWrap($conf['filelist'], $conf['filelist.']));} if ($conf['preUserFunc']) {$content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);} + foreach($this->stdWrapHookObjects as $hookObject) { + $content = $hookObject->stdWrapOverride($content, $conf, $this); + } + // Overriding values, evaluating conditions if ($conf['override'] || $conf['override.']){ $override = $this->stdWrap($conf['override'], $conf['override.']); @@ -3168,6 +3206,10 @@ // Call stdWrap recursively if ($conf['stdWrap.']) { $content=$this->stdWrap($content,$conf['stdWrap.']); } + foreach($this->stdWrapHookObjects as $hookObject) { + $content = $hookObject->stdWrapProcess($content, $conf, $this); + } + if ( ($conf['required'] && (string)$content=='') || ($conf['if.'] && !$this->checkIf($conf['if.'])) || ($conf['fieldRequired'] && !trim($this->data[$conf['fieldRequired']])) ){ $content = ''; } else { @@ -3269,6 +3311,10 @@ if ($conf['editPanel'] && $GLOBALS['TSFE']->beUserLogin){$content=$this->editPanel($content, $conf['editPanel.']);} } + foreach($this->stdWrapHookObjects as $hookObject) { + $content = $hookObject->stdWrapPostProcess($content, $conf, $this); + } + //Debug: if ($conf['debug']) {$content = '
'.htmlspecialchars($content).'';} if ($conf['debugFunc']) {debug($conf['debugFunc']==2?array($content):$content);} @@ -4760,6 +4806,8 @@ * @see getFieldVal() */ function getData($string,$fieldArray) { + global $TYPO3_CONF_VARS; + if (!is_array($fieldArray)) { $fieldArray=$GLOBALS['TSFE']->page; } @@ -4874,7 +4922,20 @@ break; } } + + if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'])) { + foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['getData'] as $classData) { + $hookObject = &t3lib_div::getUserObj($classData); + + if(!($hookObject instanceof tslib_content_getDataHook)) { + throw new UnexpectedValueException('$hookObject must implement interface tslib_content_getDataHook', 1195044480); + } + + $retVal = $hookObject->getDataExtension($string, $fieldArray, $secVal, $retVal, $this); + } + } } + return $retVal; } Index: typo3/sysext/cms/tslib/interfaces/interface.tslib_content_cobjgetsinglehook.php =================================================================== --- typo3/sysext/cms/tslib/interfaces/interface.tslib_content_cobjgetsinglehook.php (revision 0) +++ typo3/sysext/cms/tslib/interfaces/interface.tslib_content_cobjgetsinglehook.php (revision 0) @@ -0,0 +1,51 @@ + +* All rights reserved +* +* This script is part of the TYPO3 project. The TYPO3 project is +* free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* A copy is found in the textfile GPL.txt and important notices to the license +* from the author is found in LICENSE.txt distributed with these scripts. +* +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ + + +/** + * interface for classes which hook into tslib_content and do additional cObjGetSingle processing + * + * @author Ingo Renner