2 namespace TYPO3\CMS\Frontend\ContentObject
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Core\Cache\CacheManager
;
18 use TYPO3\CMS\Core\FrontendEditing\FrontendEditingController
;
19 use TYPO3\CMS\Core\Html\HtmlParser
;
20 use TYPO3\CMS\Core\Imaging\GraphicalFunctions
;
21 use TYPO3\CMS\Core\Log\LogManager
;
22 use TYPO3\CMS\Core\Mail\MailMessage
;
23 use TYPO3\CMS\Core\
Resource\Exception
;
24 use TYPO3\CMS\Core\
Resource\Exception\ResourceDoesNotExistException
;
25 use TYPO3\CMS\Core\
Resource\File
;
26 use TYPO3\CMS\Core\
Resource\FileInterface
;
27 use TYPO3\CMS\Core\
Resource\FileReference
;
28 use TYPO3\CMS\Core\
Resource\Folder
;
29 use TYPO3\CMS\Core\
Resource\ProcessedFile
;
30 use TYPO3\CMS\Core\
Resource\ResourceFactory
;
31 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
;
32 use TYPO3\CMS\Core\TypoScript\TemplateService
;
33 use TYPO3\CMS\Core\Utility\ArrayUtility
;
34 use TYPO3\CMS\Core\Utility\DebugUtility
;
35 use TYPO3\CMS\Core\Utility\GeneralUtility
;
36 use TYPO3\CMS\Core\Utility\HttpUtility
;
37 use TYPO3\CMS\Core\Utility\MailUtility
;
38 use TYPO3\CMS\Core\Utility\MathUtility
;
39 use TYPO3\CMS\Core\Utility\StringUtility
;
40 use TYPO3\CMS\Core\Versioning\VersionState
;
41 use TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException
;
42 use TYPO3\CMS\Frontend\ContentObject\Exception\ProductionExceptionHandler
;
43 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
;
44 use TYPO3\CMS\Frontend\Imaging\GifBuilder
;
45 use TYPO3\CMS\Frontend\ContentObject\Exception\ExceptionHandlerInterface
;
46 use TYPO3\CMS\Frontend\Page\CacheHashCalculator
;
47 use TYPO3\CMS\Frontend\Page\PageRepository
;
48 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
49 use TYPO3\CMS\Frontend\Service\TypoLinkCodecService
;
52 * This class contains all main TypoScript features.
53 * This includes the rendering of TypoScript content objects (cObjects).
54 * Is the backbone of TypoScript Template rendering.
56 * There are lots of functions you can use from your include-scripts.
57 * The class is normally instantiated and referred to as "cObj".
58 * When you call your own PHP-code typically through a USER or USER_INT cObject then it is this class that instantiates the object and calls the main method. Before it does so it will set (if you are using classes) a reference to itself in the internal variable "cObj" of the object. Thus you can access all functions and data from this class by $this->cObj->... from within you classes written to be USER or USER_INT content objects.
60 class ContentObjectRenderer
{
65 public $align = array(
72 * stdWrap functions in their correct order
76 public $stdWrapOrder = array(
77 'stdWrapPreProcess' => 'hook',
78 // this is a placeholder for the first Hook
79 'cacheRead' => 'hook',
80 // this is a placeholder for checking if the content is available in cache
81 'setContentToCurrent' => 'boolean',
82 'setContentToCurrent.' => 'array',
83 'addPageCacheTags' => 'string',
84 'addPageCacheTags.' => 'array',
85 'setCurrent' => 'string',
86 'setCurrent.' => 'array',
90 'field' => 'fieldName',
92 'current' => 'boolean',
93 'current.' => 'array',
94 'cObject' => 'cObject',
95 'cObject.' => 'array',
96 'numRows.' => 'array',
98 'filelist.' => 'array',
99 'preUserFunc' => 'functionName',
100 'stdWrapOverride' => 'hook',
101 // this is a placeholder for the second Hook
102 'override' => 'string',
103 'override.' => 'array',
104 'preIfEmptyListNum' => 'listNum',
105 'preIfEmptyListNum.' => 'array',
106 'ifNull' => 'string',
107 'ifNull.' => 'array',
108 'ifEmpty' => 'string',
109 'ifEmpty.' => 'array',
110 'ifBlank' => 'string',
111 'ifBlank.' => 'array',
112 'listNum' => 'listNum',
113 'listNum.' => 'array',
116 'strPad.' => 'array',
117 'stdWrap' => 'stdWrap',
118 'stdWrap.' => 'array',
119 'stdWrapProcess' => 'hook',
120 // this is a placeholder for the third Hook
121 'required' => 'boolean',
122 'required.' => 'array',
124 'fieldRequired' => 'fieldName',
125 'fieldRequired.' => 'array',
126 'csConv' => 'string',
127 'csConv.' => 'array',
128 'parseFunc' => 'objectpath',
129 'parseFunc.' => 'array',
130 'HTMLparser' => 'boolean',
131 'HTMLparser.' => 'array',
133 'replacement.' => 'array',
134 'prioriCalc' => 'boolean',
135 'prioriCalc.' => 'array',
138 'intval' => 'boolean',
139 'intval.' => 'array',
142 'round' => 'boolean',
144 'numberFormat.' => 'array',
145 'expandList' => 'boolean',
146 'expandList.' => 'array',
147 'date' => 'dateconf',
149 'strtotime' => 'strtotimeconf',
150 'strtotime.' => 'array',
151 'strftime' => 'strftimeconf',
152 'strftime.' => 'array',
157 'bytes' => 'boolean',
159 'substring' => 'parameters',
160 'substring.' => 'array',
161 'removeBadHTML' => 'boolean',
162 'removeBadHTML.' => 'array',
163 'cropHTML' => 'crop',
164 'cropHTML.' => 'array',
165 'stripHtml' => 'boolean',
166 'stripHtml.' => 'array',
169 'rawUrlEncode' => 'boolean',
170 'rawUrlEncode.' => 'array',
171 'htmlSpecialChars' => 'boolean',
172 'htmlSpecialChars.' => 'array',
173 'encodeForJavaScriptValue' => 'boolean',
174 'encodeForJavaScriptValue.' => 'array',
175 'doubleBrTag' => 'string',
176 'doubleBrTag.' => 'array',
181 'encapsLines.' => 'array',
182 'keywords' => 'boolean',
183 'keywords.' => 'array',
184 'innerWrap' => 'wrap',
185 'innerWrap.' => 'array',
186 'innerWrap2' => 'wrap',
187 'innerWrap2.' => 'array',
189 'fontTag.' => 'array',
190 'addParams.' => 'array',
191 'textStyle.' => 'array',
192 'tableStyle.' => 'array',
193 'filelink.' => 'array',
194 'preCObject' => 'cObject',
195 'preCObject.' => 'array',
196 'postCObject' => 'cObject',
197 'postCObject.' => 'array',
198 'wrapAlign' => 'align',
199 'wrapAlign.' => 'array',
200 'typolink.' => 'array',
201 'TCAselectItem.' => 'array',
204 'spaceBefore' => 'int',
205 'spaceBefore.' => 'array',
206 'spaceAfter' => 'int',
207 'spaceAfter.' => 'array',
210 'noTrimWrap' => 'wrap',
211 'noTrimWrap.' => 'array',
214 'dataWrap' => 'dataWrap',
215 'dataWrap.' => 'array',
216 'prepend' => 'cObject',
217 'prepend.' => 'array',
218 'append' => 'cObject',
219 'append.' => 'array',
222 'orderedStdWrap' => 'stdWrap',
223 'orderedStdWrap.' => 'array',
224 'outerWrap' => 'wrap',
225 'outerWrap.' => 'array',
226 'insertData' => 'boolean',
227 'insertData.' => 'array',
228 'offsetWrap' => 'space',
229 'offsetWrap.' => 'array',
230 'postUserFunc' => 'functionName',
231 'postUserFuncInt' => 'functionName',
232 'prefixComment' => 'string',
233 'prefixComment.' => 'array',
234 'editIcons' => 'string',
235 'editIcons.' => 'array',
236 'editPanel' => 'boolean',
237 'editPanel.' => 'array',
238 'cacheStore' => 'hook',
239 // this is a placeholder for storing the content in cache
240 'stdWrapPostProcess' => 'hook',
241 // this is a placeholder for the last Hook
242 'debug' => 'boolean',
244 'debugFunc' => 'boolean',
245 'debugFunc.' => 'array',
246 'debugData' => 'boolean',
247 'debugData.' => 'array'
251 * Class names for accordant content object names
255 protected $contentObjectClassMap = array();
258 * Holds ImageMagick parameters and extensions used for compression
263 public $image_compression = array(
269 'params' => '-colors 128',
273 'params' => '-colors 64',
277 'params' => '-colors 32',
281 'params' => '-colors 16',
285 'params' => '-colors 8',
289 'params' => '-quality 100',
293 'params' => '-quality 90',
297 'params' => '-quality 80',
301 'params' => '-quality 70',
305 'params' => '-quality 60',
309 'params' => '-quality 50',
313 'params' => '-quality 40',
317 'params' => '-quality 30',
321 'params' => '-quality 20',
325 'params' => '-colors 256',
329 'params' => '-colors 128',
333 'params' => '-colors 64',
337 'params' => '-colors 32',
341 'params' => '-colors 16',
345 'params' => '-colors 8',
355 * ImageMagick parameters for image effects
360 public $image_effects = array(
364 10 => '-colorspace GRAY',
373 * Loaded with the current data-record.
375 * If the instance of this class is used to render records from the database those records are found in this array.
376 * The function stdWrap has TypoScript properties that fetch field-data from this array.
381 public $data = array();
386 protected $table = '';
393 public $oldData = array();
396 * If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
400 public $alternativeData = '';
403 * Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
407 public $parameters = array();
412 public $currentValKey = 'currentValue_kidjls9dksoje';
415 * This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation.
416 * Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
420 public $currentRecord = '';
423 * Set in RecordsContentObject and ContentContentObject to the current number of records selected in a query.
427 public $currentRecordTotal = 0;
430 * Incremented in RecordsContentObject and ContentContentObject before each record rendering.
434 public $currentRecordNumber = 0;
437 * Incremented in RecordsContentObject and ContentContentObject before each record rendering.
441 public $parentRecordNumber = 0;
444 * If the ContentObjectRender was started from ContentContentObject, RecordsContentObject or SearchResultContentObject this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
448 public $parentRecord = array();
451 * Is set to 1 if the instance of this cObj is executed from a *_INT plugin (see pagegen, bottom of document)
455 public $INT_include = 0;
458 * This is used by checkPid, that checks if pages are accessible. The $checkPid_cache['page_uid'] is set TRUE or FALSE upon this check featuring a caching function for the next request.
462 public $checkPid_cache = array();
467 public $checkPid_badDoktypeList = '255';
470 * This will be set by typoLink() to the url of the most recent link created.
474 public $lastTypoLinkUrl = '';
481 public $lastTypoLinkTarget = '';
486 public $lastTypoLinkLD = array();
489 * Caching substituteMarkerArrayCached function
493 public $substMarkerCache = array();
496 * array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
500 public $recordRegister = array();
503 * Additionally registered content object types and class names
507 protected $cObjHookObjectsRegistry = array();
512 public $cObjHookObjectsArr = array();
515 * Containing hook objects for stdWrap
519 protected $stdWrapHookObjects = array();
522 * Containing hook objects for getImgResource
526 protected $getImgResourceHookObjects;
529 * @var File Current file objects (during iterations over files)
531 protected $currentFile = NULL;
534 * Set to TRUE by doConvertToUserIntObject() if USER object wants to become USER_INT
536 public $doConvertToUserIntObject = FALSE;
539 * Indicates current object type. Can hold one of OBJECTTYPE_ constants or FALSE.
540 * The value is set and reset inside USER() function. Any time outside of
541 * USER() it is FALSE.
543 protected $userObjectType = FALSE;
548 protected $stopRendering = array();
553 protected $stdWrapRecursionLevel = 0;
556 * @var TypoScriptFrontendController
558 protected $typoScriptFrontendController;
561 * Indicates that object type is USER.
563 * @see ContentObjectRender::$userObjectType
565 const OBJECTTYPE_USER_INT
= 1;
567 * Indicates that object type is USER.
569 * @see ContentObjectRender::$userObjectType
571 const OBJECTTYPE_USER
= 2;
574 * @param TypoScriptFrontendController $typoScriptFrontendController
576 public function __construct(TypoScriptFrontendController
$typoScriptFrontendController = NULL) {
577 $this->typoScriptFrontendController
= $typoScriptFrontendController ?
: $GLOBALS['TSFE'];
578 $this->contentObjectClassMap
= $GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects'];
582 * Prevent several objects from being serialized.
583 * If currentFile is set, it is either a File or a FileReference object. As the object itself can't be serialized,
584 * we have store a hash and restore the object in __wakeup()
588 public function __sleep() {
589 $vars = get_object_vars($this);
590 unset($vars['typoScriptFrontendController']);
591 if ($this->currentFile
instanceof FileReference
) {
592 $this->currentFile
= 'FileReference:' . $this->currentFile
->getUid();
593 } elseif ($this->currentFile
instanceof File
) {
594 $this->currentFile
= 'File:' . $this->currentFile
->getIdentifier();
596 unset($vars['currentFile']);
598 return array_keys($vars);
602 * Restore currentFile from hash.
603 * If currentFile references a File, the identifier equals file identifier.
604 * If it references a FileReference the identifier equals the uid of the reference.
606 public function __wakeup() {
607 if (isset($GLOBALS['TSFE'])) {
608 $this->typoScriptFrontendController
= $GLOBALS['TSFE'];
610 if ($this->currentFile
!== NULL && is_string($this->currentFile
)) {
611 list($objectType, $identifier) = explode(':', $this->currentFile
, 2);
613 if ($objectType === 'File') {
614 $this->currentFile
= ResourceFactory
::getInstance()->retrieveFileOrFolderObject($identifier);
615 } elseif ($objectType === 'FileReference') {
616 $this->currentFile
= ResourceFactory
::getInstance()->getFileReferenceObject($identifier);
618 } catch (ResourceDoesNotExistException
$e) {
619 $this->currentFile
= NULL;
625 * Allow injecting content object class map.
627 * This method is private API, please use configuration
628 * $GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects'] to add new content objects
631 * @param array $contentObjectClassMap
633 public function setContentObjectClassMap(array $contentObjectClassMap) {
634 $this->contentObjectClassMap
= $contentObjectClassMap;
638 * Register a single content object name to class name
640 * This method is private API, please use configuration
641 * $GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects'] to add new content objects
644 * @param string $className
645 * @param string $contentObjectName
647 public function registerContentObjectClass($className, $contentObjectName) {
648 $this->contentObjectClassMap
[$contentObjectName] = $className;
653 * Well, it has to be called manually since it is not a real constructor function.
654 * So after making an instance of the class, call this function and pass to it a database record and the tablename from where the record is from. That will then become the "current" record loaded into memory and accessed by the .fields property found in eg. stdWrap.
656 * @param array $data The record data that is rendered.
657 * @param string $table The table that the data record is from.
660 public function start($data, $table = '') {
662 $this->table
= $table;
663 $this->currentRecord
= $table ?
$table . ':' . $this->data
['uid'] : '';
664 $this->parameters
= array();
665 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'])) {
666 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] as $classArr) {
667 $this->cObjHookObjectsRegistry
[$classArr[0]] = $classArr[1];
670 $this->stdWrapHookObjects
= array();
671 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'])) {
672 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] as $classData) {
673 $hookObject = GeneralUtility
::getUserObj($classData);
674 if (!$hookObject instanceof ContentObjectStdWrapHookInterface
) {
675 throw new \
UnexpectedValueException($classData . ' must implement interface ' . ContentObjectStdWrapHookInterface
::class, 1195043965);
677 $this->stdWrapHookObjects
[] = $hookObject;
680 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'])) {
681 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'] as $classData) {
682 $postInitializationProcessor = GeneralUtility
::getUserObj($classData);
683 if (!$postInitializationProcessor instanceof ContentObjectPostInitHookInterface
) {
684 throw new \
UnexpectedValueException($classData . ' must implement interface ' . ContentObjectPostInitHookInterface
::class, 1274563549);
686 $postInitializationProcessor->postProcessContentObjectInitialization($this);
692 * Returns the current table
696 public function getCurrentTable() {
701 * Gets the 'getImgResource' hook objects.
702 * The first call initializes the accordant objects.
704 * @return array The 'getImgResource' hook objects (if any)
706 protected function getGetImgResourceHookObjects() {
707 if (!isset($this->getImgResourceHookObjects
)) {
708 $this->getImgResourceHookObjects
= array();
709 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'])) {
710 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'] as $classData) {
711 $hookObject = GeneralUtility
::getUserObj($classData);
712 if (!$hookObject instanceof ContentObjectGetImageResourceHookInterface
) {
713 throw new \
UnexpectedValueException('$hookObject must implement interface ' . ContentObjectGetImageResourceHookInterface
::class, 1218636383);
715 $this->getImgResourceHookObjects
[] = $hookObject;
719 return $this->getImgResourceHookObjects
;
723 * Sets the internal variable parentRecord with information about current record.
724 * If the ContentObjectRender was started from CONTENT, RECORD or SEARCHRESULT cObject's this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
726 * @param array $data The record array
727 * @param string $currentRecord This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation. Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
731 public function setParent($data, $currentRecord) {
732 $this->parentRecord
= array(
734 'currentRecord' => $currentRecord
738 /***********************************************
742 ***********************************************/
744 * Returns the "current" value.
745 * The "current" value is just an internal variable that can be used by functions to pass a single value on to another function later in the TypoScript processing.
746 * It's like "load accumulator" in the good old C64 days... basically a "register" you can use as you like.
747 * The TSref will tell if functions are setting this value before calling some other object so that you know if it holds any special information.
749 * @return mixed The "current" value
751 public function getCurrentVal() {
752 return $this->data
[$this->currentValKey
];
756 * Sets the "current" value.
758 * @param mixed $value The variable that you want to set as "current
760 * @see getCurrentVal()
762 public function setCurrentVal($value) {
763 $this->data
[$this->currentValKey
] = $value;
767 * Rendering of a "numerical array" of cObjects from TypoScript
768 * Will call ->cObjGetSingle() for each cObject found and accumulate the output.
770 * @param array $setup array with cObjects as values.
771 * @param string $addKey A prefix for the debugging information
772 * @return string Rendered output from the cObjects in the array.
773 * @see cObjGetSingle()
775 public function cObjGet($setup, $addKey = '') {
776 if (is_array($setup)) {
777 $sKeyArray = TemplateService
::sortedKeyList($setup);
779 foreach ($sKeyArray as $theKey) {
780 $theValue = $setup[$theKey];
781 if ((int)$theKey && strpos($theKey, '.') === FALSE) {
782 $conf = $setup[$theKey . '.'];
783 $content .= $this->cObjGetSingle($theValue, $conf, $addKey . $theKey);
791 * Renders a content object
793 * @param string $name The content object name, eg. "TEXT" or "USER" or "IMAGE
794 * @param array $conf The array with TypoScript properties for the content object
795 * @param string $TSkey A string label used for the internal debugging tracking.
796 * @return string cObject output
797 * @throws \UnexpectedValueException
799 public function cObjGetSingle($name, $conf, $TSkey = '__') {
801 // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
802 $GLOBALS['TSFE']->cObjectDepthCounter
--;
803 if ($GLOBALS['TSFE']->cObjectDepthCounter
> 0) {
805 if ($GLOBALS['TT']->LR
) {
806 $GLOBALS['TT']->push($TSkey, $name);
808 // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
809 if ($name[0] === '<') {
810 $key = trim(substr($name, 1));
811 $cF = GeneralUtility
::makeInstance(TypoScriptParser
::class);
812 // $name and $conf is loaded with the referenced values.
813 $confOverride = is_array($conf) ?
$conf : array();
814 list($name, $conf) = $cF->getVal($key, $GLOBALS['TSFE']->tmpl
->setup
);
815 $conf = array_replace_recursive(is_array($conf) ?
$conf : array(), $confOverride);
816 // Getting the cObject
817 $GLOBALS['TT']->incStackPointer();
818 $content .= $this->cObjGetSingle($name, $conf, $key);
819 $GLOBALS['TT']->decStackPointer();
822 // Application defined cObjects
823 if (!empty($this->cObjHookObjectsRegistry
[$name])) {
824 if (empty($this->cObjHookObjectsArr
[$name])) {
825 $this->cObjHookObjectsArr
[$name] = GeneralUtility
::getUserObj($this->cObjHookObjectsRegistry
[$name]);
827 $hookObj = $this->cObjHookObjectsArr
[$name];
828 if (method_exists($hookObj, 'cObjGetSingleExt')) {
829 $content .= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
834 $contentObject = $this->getContentObject($name);
835 if ($contentObject) {
836 $content .= $this->render($contentObject, $conf);
838 // Call hook functions for extra processing
839 if ($name && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) {
840 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData) {
841 $hookObject = GeneralUtility
::getUserObj($classData);
842 if (!$hookObject instanceof ContentObjectGetSingleHookInterface
) {
843 throw new \
UnexpectedValueException('$hookObject must implement interface ' . ContentObjectGetSingleHookInterface
::class, 1195043731);
845 /** @var $hookObject ContentObjectGetSingleHookInterface */
846 $content .= $hookObject->getSingleContentObject($name, (array)$conf, $TSkey, $this);
849 // Log error in AdminPanel
850 $warning = sprintf('Content Object "%s" does not exist', $name);
851 $GLOBALS['TT']->setTSlogMessage($warning, 2);
856 if ($GLOBALS['TT']->LR
) {
857 $GLOBALS['TT']->pull($content);
860 // Increasing on exit...
861 $GLOBALS['TSFE']->cObjectDepthCounter++
;
866 * Returns a new content object of type $name.
867 * This content object needs to be registered as content object
868 * in $this->contentObjectClassMap
870 * @param string $name
871 * @return NULL|AbstractContentObject
872 * @throws ContentRenderingException
874 public function getContentObject($name) {
875 if (!isset($this->contentObjectClassMap
[$name])) {
878 $fullyQualifiedClassName = $this->contentObjectClassMap
[$name];
879 $contentObject = GeneralUtility
::makeInstance($fullyQualifiedClassName, $this);
880 if (!($contentObject instanceof AbstractContentObject
)) {
881 throw new ContentRenderingException(sprintf('Registered content object class name "%" must be an instance of AbstractContentObject, but is not!', $fullyQualifiedClassName), 1422564295);
883 return $contentObject;
886 /********************************************
888 * Functions rendering content objects (cObjects)
890 ********************************************/
893 * Renders a content object by taking exception and cache handling
896 * @param AbstractContentObject $contentObject Content object instance
897 * @param array $configuration Array of TypoScript properties
899 * @throws ContentRenderingException
903 public function render(AbstractContentObject
$contentObject, $configuration = array()) {
906 // Evaluate possible cache and return
907 $cacheConfiguration = isset($configuration['cache.']) ?
$configuration['cache.'] : NULL;
908 if ($cacheConfiguration !== NULL) {
909 unset($configuration['cache.']);
910 $cache = $this->getFromCache($cacheConfiguration);
911 if ($cache !== FALSE) {
918 $content .= $contentObject->render($configuration);
919 } catch (ContentRenderingException
$exception) {
920 // Content rendering Exceptions indicate a critical problem which should not be
921 // caught e.g. when something went wrong with Exception handling itself
923 } catch (\Exception
$exception) {
924 $exceptionHandler = $this->createExceptionHandler($configuration);
925 if ($exceptionHandler === NULL) {
928 $content = $exceptionHandler->handle($exception, $contentObject, $configuration);
933 if ($cacheConfiguration !== NULL) {
934 $key = $this->calculateCacheKey($cacheConfiguration);
936 /** @var $cacheFrontend \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend */
937 $cacheFrontend = GeneralUtility
::makeInstance(CacheManager
::class)->getCache('cache_hash');
938 $tags = $this->calculateCacheTags($cacheConfiguration);
939 $lifetime = $this->calculateCacheLifetime($cacheConfiguration);
940 $cacheFrontend->set($key, $content, $tags, $lifetime);
948 * Creates the content object exception handler from local content object configuration
949 * or, from global configuration if not explicitly disabled in local configuration
951 * @param array $configuration
952 * @return NULL|ExceptionHandlerInterface
953 * @throws ContentRenderingException
955 protected function createExceptionHandler($configuration = array()) {
956 $exceptionHandler = NULL;
957 $exceptionHandlerClassName = $this->determineExceptionHandlerClassName($configuration);
958 if (!empty($exceptionHandlerClassName)) {
959 $exceptionHandler = GeneralUtility
::makeInstance($exceptionHandlerClassName, $this->mergeExceptionHandlerConfiguration($configuration));
960 if (!$exceptionHandler instanceof ExceptionHandlerInterface
) {
961 throw new ContentRenderingException('An exception handler was configured but the class does not exist or does not implement the ExceptionHandlerInterface', 1403653369);
965 return $exceptionHandler;
969 * Determine exception handler class name from global and content object configuration
971 * @param array $configuration
972 * @return string|NULL
974 protected function determineExceptionHandlerClassName($configuration) {
975 $exceptionHandlerClassName = NULL;
976 if (!isset($this->typoScriptFrontendController
->config
['config']['contentObjectExceptionHandler'])) {
977 if (GeneralUtility
::getApplicationContext()->isProduction()) {
978 $exceptionHandlerClassName = '1';
981 $exceptionHandlerClassName = $this->typoScriptFrontendController
->config
['config']['contentObjectExceptionHandler'];
984 if (isset($configuration['exceptionHandler'])) {
985 $exceptionHandlerClassName = $configuration['exceptionHandler'];
988 if ($exceptionHandlerClassName === '1') {
989 $exceptionHandlerClassName = ProductionExceptionHandler
::class;
992 return $exceptionHandlerClassName;
996 * Merges global exception handler configuration with the one from the content object
997 * and returns the merged exception handler configuration
999 * @param array $configuration
1002 protected function mergeExceptionHandlerConfiguration($configuration) {
1003 $exceptionHandlerConfiguration = array();
1004 if (!empty($this->typoScriptFrontendController
->config
['config']['contentObjectExceptionHandler.'])) {
1005 $exceptionHandlerConfiguration = $this->typoScriptFrontendController
->config
['config']['contentObjectExceptionHandler.'];
1007 if (!empty($configuration['exceptionHandler.'])) {
1008 $exceptionHandlerConfiguration = array_replace_recursive($exceptionHandlerConfiguration, $configuration['exceptionHandler.']);
1011 return $exceptionHandlerConfiguration;
1014 * Rendering the cObject, FLOWPLAYER
1016 * @param array $conf Array of TypoScript properties
1017 * @return string Output
1018 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('FLOWPLAYER', $conf) instead
1020 public function FLOWPLAYER($conf) {
1021 GeneralUtility
::logDeprecatedFunction();
1022 return $this->render($this->getContentObject('FLOWPLAYER'), $conf);
1026 * Rendering the cObject, TEXT
1028 * @param array $conf Array of TypoScript properties
1029 * @return string Output
1030 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('TEXT', $conf) instead
1032 public function TEXT($conf) {
1033 GeneralUtility
::logDeprecatedFunction();
1034 return $this->render($this->getContentObject('TEXT'), $conf);
1038 * Rendering the cObject, CLEARGIF
1040 * @param array $conf Array of TypoScript properties
1041 * @return string Output
1042 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('CLEARGIF', $conf) instead
1044 public function CLEARGIF($conf) {
1045 GeneralUtility
::logDeprecatedFunction();
1046 return $this->render($this->getContentObject('CLEARGIF'), $conf);
1050 * Rendering the cObject, COBJ_ARRAY / COA and COBJ_ARRAY_INT
1052 * @param array $conf Array of TypoScript properties
1053 * @param string $ext If "INT" then the cObject is a "COBJ_ARRAY_INT" (non-cached), otherwise just "COBJ_ARRAY" (cached)
1054 * @return string Output
1055 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('COA', $conf) or $cObj->cObjGetSingle('COA_INT', $conf) instead
1057 public function COBJ_ARRAY($conf, $ext = '') {
1058 GeneralUtility
::logDeprecatedFunction();
1059 if ($ext === 'INT') {
1060 return $this->render($this->getContentObject('COA_INT'), $conf);
1062 return $this->render($this->getContentObject('COA'), $conf);
1067 * Rendering the cObject, USER and USER_INT
1069 * @param array $conf Array of TypoScript properties
1070 * @param string $ext If "INT" then the cObject is a "USER_INT" (non-cached), otherwise just "USER" (cached)
1071 * @return string Output
1072 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('USER', $conf) or $cObj->cObjGetSingle('USER_INT', $conf) instead
1074 public function USER($conf, $ext = '') {
1075 GeneralUtility
::logDeprecatedFunction();
1076 if ($ext === 'INT') {
1077 return $this->render($this->getContentObject('USER_INT'), $conf);
1079 return $this->render($this->getContentObject('USER'), $conf);
1084 * Retrieves a type of object called as USER or USER_INT. Object can detect their
1085 * type by using this call. It returns OBJECTTYPE_USER_INT or OBJECTTYPE_USER depending on the
1086 * current object execution. In all other cases it will return FALSE to indicate
1087 * a call out of context.
1089 * @return mixed One of OBJECTTYPE_ class constants or FALSE
1091 public function getUserObjectType() {
1092 return $this->userObjectType
;
1096 * Sets the user object type
1098 * @param mixed $userObjectType
1101 public function setUserObjectType($userObjectType) {
1102 $this->userObjectType
= $userObjectType;
1106 * Requests the current USER object to be converted to USER_INT.
1110 public function convertToUserIntObject() {
1111 if ($this->userObjectType
!== self
::OBJECTTYPE_USER
) {
1112 $GLOBALS['TT']->setTSlogMessage(ContentObjectRenderer
::class . '::convertToUserIntObject() is called in the wrong context or for the wrong object type', 2);
1114 $this->doConvertToUserIntObject
= TRUE;
1119 * Rendering the cObject, FILE
1121 * @param array $conf Array of TypoScript properties
1122 * @return string Output
1123 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('FILE', $conf) instead
1125 public function FILE($conf) {
1126 GeneralUtility
::logDeprecatedFunction();
1127 return $this->render($this->getContentObject('FILE'), $conf);
1131 * Rendering the cObject, FILES
1133 * @param array $conf Array of TypoScript properties
1134 * @return string Output
1135 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('FILES', $conf) instead
1137 public function FILES($conf) {
1138 GeneralUtility
::logDeprecatedFunction();
1139 return $this->render($this->getContentObject('FILES'), $conf);
1143 * Rendering the cObject, IMAGE
1145 * @param array $conf Array of TypoScript properties
1146 * @return string Output
1148 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('IMAGE', $conf) instead
1150 public function IMAGE($conf) {
1151 GeneralUtility
::logDeprecatedFunction();
1152 return $this->render($this->getContentObject('IMAGE'), $conf);
1156 * Rendering the cObject, IMG_RESOURCE
1158 * @param array $conf Array of TypoScript properties
1159 * @return string Output
1160 * @see getImgResource()
1161 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('IMG_RESOURCE', $conf) instead
1163 public function IMG_RESOURCE($conf) {
1164 GeneralUtility
::logDeprecatedFunction();
1165 return $this->render($this->getContentObject('IMG_RESOURCE'), $conf);
1169 * Rendering the cObject, IMGTEXT
1171 * @param array $conf Array of TypoScript properties
1172 * @return string Output
1173 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('IMGTEXT', $conf) instead
1175 public function IMGTEXT($conf) {
1176 GeneralUtility
::logDeprecatedFunction();
1177 return $this->render($this->getContentObject('IMGTEXT'), $conf);
1181 * Rendering the cObject, CONTENT
1183 * @param array $conf Array of TypoScript properties
1184 * @return string Output
1185 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('CONTENT', $conf) instead
1187 public function CONTENT($conf) {
1188 GeneralUtility
::logDeprecatedFunction();
1189 return $this->render($this->getContentObject('CONTENT'), $conf);
1193 * Rendering the cObject, RECORDS
1195 * @param array $conf Array of TypoScript properties
1196 * @return string Output
1197 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('RECORDS', $conf) instead
1199 public function RECORDS($conf) {
1200 GeneralUtility
::logDeprecatedFunction();
1201 return $this->render($this->getContentObject('RECORDS'), $conf);
1205 * Rendering the cObject, HMENU
1207 * @param array $conf Array of TypoScript properties
1208 * @return string Output
1209 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('HMENU', $conf) instead
1211 public function HMENU($conf) {
1212 GeneralUtility
::logDeprecatedFunction();
1213 return $this->render($this->getContentObject('HMENU'), $conf);
1217 * Rendering the cObject, CTABLE
1219 * @param array $conf Array of TypoScript properties
1220 * @return string Output
1221 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('CTABLE', $conf) instead
1223 public function CTABLE($conf) {
1224 GeneralUtility
::logDeprecatedFunction();
1225 return $this->render($this->getContentObject('CTABLE'), $conf);
1229 * Rendering the cObject, OTABLE
1231 * @param array $conf Array of TypoScript properties
1232 * @return string Output
1233 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('OTABLE', $conf) instead
1235 public function OTABLE($conf) {
1236 GeneralUtility
::logDeprecatedFunction();
1237 return $this->render($this->getContentObject('OTABLE'), $conf);
1241 * Rendering the cObject, COLUMNS
1243 * @param array $conf Array of TypoScript properties
1244 * @return string Output
1245 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('COLUMNS', $conf) instead
1247 public function COLUMNS($conf) {
1248 GeneralUtility
::logDeprecatedFunction();
1249 return $this->render($this->getContentObject('COLUMNS'), $conf);
1253 * Rendering the cObject, HRULER
1255 * @param array $conf Array of TypoScript properties
1256 * @return string Output
1257 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('HRULER', $conf) instead
1259 public function HRULER($conf) {
1260 GeneralUtility
::logDeprecatedFunction();
1261 return $this->render($this->getContentObject('HRULER'), $conf);
1265 * Rendering the cObject, CASE
1267 * @param array $conf Array of TypoScript properties
1268 * @return string Output
1269 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('CASE', $conf) instead
1271 public function CASEFUNC($conf) {
1272 GeneralUtility
::logDeprecatedFunction();
1273 return $this->render($this->getContentObject('CASE'), $conf);
1277 * Rendering the cObject, LOAD_REGISTER and RESTORE_REGISTER
1278 * NOTICE: This cObject does NOT return any content since it just sets internal data based on the TypoScript properties.
1280 * @param array $conf Array of TypoScript properties
1281 * @param string $name If "RESTORE_REGISTER" then the cObject rendered is "RESTORE_REGISTER", otherwise "LOAD_REGISTER"
1282 * @return string Empty string (the cObject only sets internal data!)
1283 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('LOAD_REGISTER', $conf) and $cObj->cObjGetSingle('RESTORE_REGISTER', $conf) instead
1285 public function LOAD_REGISTER($conf, $name) {
1286 GeneralUtility
::logDeprecatedFunction();
1287 if ($name === 'RESTORE_REGISTER') {
1288 return $this->render($this->getContentObject('RESTORE_REGISTER'), $conf);
1290 return $this->render($this->getContentObject('LOAD_REGISTER'), $conf);
1295 * Rendering the cObject, FORM
1297 * @param array $conf Array of TypoScript properties
1298 * @param array $formData Alternative formdata overriding whatever comes from TypoScript
1299 * @return string Output
1300 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('FORM', $conf) instead
1302 public function FORM($conf, $formData = '') {
1303 GeneralUtility
::logDeprecatedFunction();
1304 return $this->render($this->getContentObject('FORM'), $conf);
1308 * Rendering the cObject, SEARCHRESULT
1310 * @param array $conf Array of TypoScript properties
1311 * @return string Output
1312 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('SEARCHRESULT', $conf) instead
1314 public function SEARCHRESULT($conf) {
1315 GeneralUtility
::logDeprecatedFunction();
1316 return $this->render($this->getContentObject('SEARCHRESULT'), $conf);
1320 * Rendering the cObject, TEMPLATE
1322 * @param array $conf Array of TypoScript properties
1323 * @return string Output
1324 * @see substituteMarkerArrayCached()
1325 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('TEMPLATE', $conf) instead
1327 public function TEMPLATE($conf) {
1328 GeneralUtility
::logDeprecatedFunction();
1329 return $this->render($this->getContentObject('TEMPLATE'), $conf);
1333 * Rendering the cObject, FLUIDTEMPLATE
1335 * @param array $conf Array of TypoScript properties
1336 * @return string the HTML output
1337 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('FLUIDTEMPLATE', $conf) instead
1339 protected function FLUIDTEMPLATE(array $conf) {
1340 GeneralUtility
::logDeprecatedFunction();
1341 return $this->render($this->getContentObject('FLUIDTEMPLATE'), $conf);
1345 * Rendering the cObject, MULTIMEDIA
1347 * @param array $conf Array of TypoScript properties
1348 * @return string Output
1349 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('MULTIMEDIA', $conf) instead
1351 public function MULTIMEDIA($conf) {
1352 GeneralUtility
::logDeprecatedFunction();
1353 return $this->render($this->getContentObject('MULTIMEDIA'), $conf);
1357 * Rendering the cObject, MEDIA
1359 * @param array $conf Array of TypoScript properties
1360 * @return string Output
1361 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('MEDIA', $conf) instead
1363 public function MEDIA($conf) {
1364 GeneralUtility
::logDeprecatedFunction();
1365 return $this->render($this->getContentObject('MEDIA'), $conf);
1369 * Rendering the cObject, SWFOBJECT
1371 * @param array $conf Array of TypoScript properties
1372 * @return string Output
1373 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('SWFOBJECT', $conf) instead
1375 public function SWFOBJECT($conf) {
1376 GeneralUtility
::logDeprecatedFunction();
1377 return $this->render($this->getContentObject('SWFOBJECT'), $conf);
1381 * Rendering the cObject, QTOBJECT
1383 * @param array $conf Array of TypoScript properties
1384 * @return string Output
1385 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('QTOBJECT', $conf) instead
1387 public function QTOBJECT($conf) {
1388 GeneralUtility
::logDeprecatedFunction();
1389 return $this->render($this->getContentObject('QTOBJECT'), $conf);
1393 * Rendering the cObject, SVG
1395 * @param array $conf Array of TypoScript properties
1396 * @return string Output
1397 * @deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8, use $cObj->cObjGetSingle('SVG', $conf) instead
1399 public function SVG($conf) {
1400 GeneralUtility
::logDeprecatedFunction();
1401 return $this->render($this->getContentObject('SVG'), $conf);
1404 /************************************
1406 * Various helper functions for content objects:
1408 ************************************/
1410 * Converts a given config in Flexform to a conf-array
1412 * @param string|array $flexData Flexform data
1413 * @param array $conf Array to write the data into, by reference
1414 * @param bool $recursive Is set if called recursive. Don't call function with this parameter, it's used inside the function only
1417 public function readFlexformIntoConf($flexData, &$conf, $recursive = FALSE) {
1418 if ($recursive === FALSE && is_string($flexData)) {
1419 $flexData = GeneralUtility
::xml2array($flexData, 'T3');
1421 if (is_array($flexData) && isset($flexData['data']['sDEF']['lDEF'])) {
1422 $flexData = $flexData['data']['sDEF']['lDEF'];
1424 if (!is_array($flexData)) {
1427 foreach ($flexData as $key => $value) {
1428 if (!is_array($value)) {
1431 if (isset($value['el'])) {
1432 if (is_array($value['el']) && !empty($value['el'])) {
1433 foreach ($value['el'] as $ekey => $element) {
1434 if (isset($element['vDEF'])) {
1435 $conf[$ekey] = $element['vDEF'];
1437 if (is_array($element)) {
1438 $this->readFlexformIntoConf($element, $conf[$key][key($element)][$ekey], TRUE);
1440 $this->readFlexformIntoConf($element, $conf[$key][$ekey], TRUE);
1445 $this->readFlexformIntoConf($value['el'], $conf[$key], TRUE);
1448 if (isset($value['vDEF'])) {
1449 $conf[$key] = $value['vDEF'];
1455 * Returns all parents of the given PID (Page UID) list
1457 * @param string $pidList A list of page Content-Element PIDs (Page UIDs) / stdWrap
1458 * @param array $pidConf stdWrap array for the list
1459 * @return string A list of PIDs
1462 public function getSlidePids($pidList, $pidConf) {
1463 $pidList = isset($pidConf) ?
trim($this->stdWrap($pidList, $pidConf)) : trim($pidList);
1464 if ($pidList === '') {
1467 if (trim($pidList)) {
1468 $listArr = GeneralUtility
::intExplode(',', str_replace('this', $GLOBALS['TSFE']->contentPid
, $pidList));
1469 $listArr = $this->checkPidArray($listArr);
1472 if (is_array($listArr) && !empty($listArr)) {
1473 foreach ($listArr as $uid) {
1474 $page = $GLOBALS['TSFE']->sys_page
->getPage($uid);
1475 if (!$page['is_siteroot']) {
1476 $pidList[] = $page['pid'];
1480 return implode(',', $pidList);
1484 * Returns a <img> tag with the image file defined by $file and processed according to the properties in the TypoScript array.
1485 * Mostly this function is a sub-function to the IMAGE function which renders the IMAGE cObject in TypoScript.
1486 * This function is called by "$this->cImage($conf['file'], $conf);" from IMAGE().
1488 * @param string $file File TypoScript resource
1489 * @param array $conf TypoScript configuration properties
1490 * @return string <img> tag, (possibly wrapped in links and other HTML) if any image found.
1494 public function cImage($file, $conf) {
1495 $info = $this->getImgResource($file, $conf['file.']);
1496 $GLOBALS['TSFE']->lastImageInfo
= $info;
1497 if (!is_array($info)) {
1500 if (is_file(PATH_site
. $info['3'])) {
1501 $source = $GLOBALS['TSFE']->absRefPrefix
. GeneralUtility
::rawUrlEncodeFP($info['3']);
1506 $layoutKey = $this->stdWrap($conf['layoutKey'], $conf['layoutKey.']);
1507 $imageTagTemplate = $this->getImageTagTemplate($layoutKey, $conf);
1508 $sourceCollection = $this->getImageSourceCollection($layoutKey, $conf, $file);
1510 // This array is used to collect the image-refs on the page...
1511 $GLOBALS['TSFE']->imagesOnPage
[] = $source;
1512 $altParam = $this->getAltParam($conf);
1513 $params = $this->stdWrapValue('params', $conf);
1514 if ($params !== '' && $params{0} !== ' ') {
1515 $params = ' ' . $params;
1518 $imageTagValues = array(
1519 'width' => $info[0],
1520 'height' => $info[1],
1521 'src' => htmlspecialchars($source),
1522 'params' => $params,
1523 'altParams' => $altParam,
1524 'border' => $this->getBorderAttr(' border="' . (int)$conf['border'] . '"'),
1525 'sourceCollection' => $sourceCollection,
1526 'selfClosingTagSlash' => (!empty($GLOBALS['TSFE']->xhtmlDoctype
) ?
' /' : ''),
1529 $theValue = $this->substituteMarkerArray($imageTagTemplate, $imageTagValues, '###|###', TRUE, TRUE);
1531 $linkWrap = isset($conf['linkWrap.']) ?
$this->stdWrap($conf['linkWrap'], $conf['linkWrap.']) : $conf['linkWrap'];
1533 $theValue = $this->linkWrap($theValue, $linkWrap);
1534 } elseif ($conf['imageLinkWrap']) {
1535 $originalFile = !empty($info['originalFile']) ?
$info['originalFile'] : $info['origFile'];
1536 $theValue = $this->imageLinkWrap($theValue, $originalFile, $conf['imageLinkWrap.']);
1538 $wrap = isset($conf['wrap.']) ?
$this->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
1540 $theValue = $this->wrap($theValue, $conf['wrap']);
1546 * Returns the 'border' attribute for an <img> tag only if the doctype is not xhtml_strict, xhtml_11, xhtml_2 or html5
1547 * or if the config parameter 'disableImgBorderAttr' is not set.
1549 * @param string $borderAttr The border attribute
1550 * @return string The border attribute
1552 public function getBorderAttr($borderAttr) {
1553 if (!GeneralUtility
::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype
) && $GLOBALS['TSFE']->config
['config']['doctype'] != 'html5' && !$GLOBALS['TSFE']->config
['config']['disableImgBorderAttr']) {
1559 * Returns the html-template for rendering the image-Tag if no template is defined via typoscript the
1560 * default <img> tag template is returned
1562 * @param string $layoutKey rendering key
1563 * @param array $conf TypoScript configuration properties
1566 public function getImageTagTemplate($layoutKey, $conf) {
1567 if ($layoutKey && isset($conf['layout.']) && isset($conf['layout.'][$layoutKey . '.'])) {
1568 $imageTagLayout = $this->stdWrap($conf['layout.'][$layoutKey . '.']['element'], $conf['layout.'][$layoutKey . '.']['element.']);
1570 $imageTagLayout = '<img src="###SRC###" width="###WIDTH###" height="###HEIGHT###" ###PARAMS### ###ALTPARAMS### ###BORDER######SELFCLOSINGTAGSLASH###>';
1572 return $imageTagLayout;
1576 * Render alternate sources for the image tag. If no source collection is given an empty string is returned.
1578 * @param string $layoutKey rendering key
1579 * @param array $conf TypoScript configuration properties
1580 * @param string $file
1581 * @throws \UnexpectedValueException
1584 public function getImageSourceCollection($layoutKey, $conf, $file) {
1585 $sourceCollection = '';
1586 if ($layoutKey && $conf['sourceCollection.'] && ($conf['layout.'][$layoutKey . '.']['source'] ||
$conf['layout.'][$layoutKey . '.']['source.'])) {
1588 // find active sourceCollection
1589 $activeSourceCollections = array();
1590 foreach ($conf['sourceCollection.'] as $sourceCollectionKey => $sourceCollectionConfiguration) {
1591 if (substr($sourceCollectionKey, -1) == '.') {
1592 if (empty($sourceCollectionConfiguration['if.']) ||
$this->checkIf($sourceCollectionConfiguration['if.'])) {
1593 $activeSourceCollections[] = $sourceCollectionConfiguration;
1598 // apply option split to configurations
1599 $srcLayoutOptionSplitted = $GLOBALS['TSFE']->tmpl
->splitConfArray($conf['layout.'][$layoutKey . '.'], count($activeSourceCollections));
1602 foreach ($activeSourceCollections as $key => $sourceConfiguration) {
1603 $sourceLayout = $this->stdWrap($srcLayoutOptionSplitted[$key]['source'], $srcLayoutOptionSplitted[$key]['source.']);
1605 $sourceRenderConfiguration = array (
1607 'file.' => $conf['file.']
1610 if (isset($sourceConfiguration['pixelDensity'])) {
1611 $pixelDensity = (int)$this->stdWrap($sourceConfiguration['pixelDensity'], $sourceConfiguration['pixelDensity.']);
1615 $dimensionKeys = array('width', 'height', 'maxW', 'minW', 'maxH', 'minH');
1616 foreach ($dimensionKeys as $dimensionKey) {
1617 $dimension = $this->stdWrap($sourceConfiguration[$dimensionKey], $sourceConfiguration[$dimensionKey . '.']);
1619 $dimension = $this->stdWrap($conf['file.'][$dimensionKey], $conf['file.'][$dimensionKey . '.']);
1622 if (strstr($dimension, 'c') !== FALSE && ($dimensionKey === 'width' ||
$dimensionKey === 'height')) {
1623 $dimensionParts = explode('c', $dimension, 2);
1624 $dimension = (int)($dimensionParts[0] * $pixelDensity) . 'c';
1625 if ($dimensionParts[1]) {
1626 $dimension .= $dimensionParts[1];
1629 $dimension = (int)($dimension * $pixelDensity);
1631 $sourceRenderConfiguration['file.'][$dimensionKey] = $dimension;
1632 // Remove the stdWrap properties for dimension as they have been processed already above.
1633 unset($sourceRenderConfiguration['file.'][$dimensionKey . '.']);
1636 $sourceInfo = $this->getImgResource($sourceRenderConfiguration['file'], $sourceRenderConfiguration['file.']);
1638 $sourceConfiguration['width'] = $sourceInfo[0];
1639 $sourceConfiguration['height'] = $sourceInfo[1];
1640 $sourceConfiguration['src'] = htmlspecialchars($GLOBALS['TSFE']->absRefPrefix
. $sourceInfo[3]);
1641 $sourceConfiguration['selfClosingTagSlash'] = (!empty($GLOBALS['TSFE']->xhtmlDoctype
) ?
' /' : '');
1643 $oneSourceCollection = $this->substituteMarkerArray($sourceLayout, $sourceConfiguration, '###|###', TRUE, TRUE);
1645 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImageSourceCollection'])) {
1646 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImageSourceCollection'] as $classData) {
1647 $hookObject = GeneralUtility
::getUserObj($classData);
1648 if (!$hookObject instanceof ContentObjectOneSourceCollectionHookInterface
) {
1649 throw new \
UnexpectedValueException(
1650 '$hookObject must implement interface ' . ContentObjectOneSourceCollectionHookInterface
::class,
1654 $oneSourceCollection = $hookObject->getOneSourceCollection((array)$sourceRenderConfiguration, (array)$sourceConfiguration, $oneSourceCollection, $this);
1658 $sourceCollection .= $oneSourceCollection;
1662 return $sourceCollection;
1666 * Wraps the input string in link-tags that opens the image in a new window.
1668 * @param string $string String to wrap, probably an <img> tag
1669 * @param string|File|FileReference $imageFile The original image file
1670 * @param array $conf TypoScript properties for the "imageLinkWrap" function
1671 * @return string The input string, $string, wrapped as configured.
1674 public function imageLinkWrap($string, $imageFile, $conf) {
1678 $enable = isset($conf['enable.']) ?
$this->stdWrap($conf['enable'], $conf['enable.']) : $conf['enable'];
1680 $content = $this->typolink($string, $conf['typolink.']);
1681 if (isset($conf['file.'])) {
1682 $imageFile = $this->stdWrap($imageFile, $conf['file.']);
1685 if ($imageFile instanceof File
) {
1687 } elseif ($imageFile instanceof FileReference
) {
1688 $file = $imageFile->getOriginalFile();
1690 if (MathUtility
::canBeInterpretedAsInteger($imageFile)) {
1691 $file = ResourceFactory
::getInstance()->getFileObject((int)$imageFile);
1693 $file = ResourceFactory
::getInstance()->getFileObjectFromCombinedIdentifier($imageFile);
1697 // Create imageFileLink if not created with typolink
1698 if ($content == $string) {
1699 $parameterNames = array('width', 'height', 'effects', 'bodyTag', 'title', 'wrap');
1700 $parameters = array();
1701 $sample = isset($conf['sample.']) ?
$this->stdWrap($conf['sample'], $conf['sample.']) : $conf['sample'];
1703 $parameters['sample'] = 1;
1705 foreach ($parameterNames as $parameterName) {
1706 if (isset($conf[$parameterName . '.'])) {
1707 $conf[$parameterName] = $this->stdWrap($conf[$parameterName], $conf[$parameterName . '.']);
1709 if (isset($conf[$parameterName]) && $conf[$parameterName]) {
1710 $parameters[$parameterName] = $conf[$parameterName];
1713 $parametersEncoded = base64_encode(serialize($parameters));
1714 $hmac = GeneralUtility
::hmac(implode('|', array($file->getUid(), $parametersEncoded)));
1715 $params = '&md5=' . $hmac;
1716 foreach (str_split($parametersEncoded, 64) as $index => $chunk) {
1717 $params .= '¶meters' . rawurlencode('[') . $index . rawurlencode(']') . '=' . rawurlencode($chunk);
1719 $url = $GLOBALS['TSFE']->absRefPrefix
. 'index.php?eID=tx_cms_showpic&file=' . $file->getUid() . $params;
1720 $directImageLink = isset($conf['directImageLink.']) ?
$this->stdWrap($conf['directImageLink'], $conf['directImageLink.']) : $conf['directImageLink'];
1721 if ($directImageLink) {
1722 $imgResourceConf = array(
1723 'file' => $imageFile,
1726 $url = $this->cObjGetSingle('IMG_RESOURCE', $imgResourceConf);
1728 // If no imagemagick / gm is available
1732 // Create TARGET-attribute only if the right doctype is used
1733 if (!GeneralUtility
::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype
)) {
1734 $target = isset($conf['target.']) ?
$this->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
1736 $target = sprintf(' target="%s"', $target);
1738 $target = ' target="thePicture"';
1743 $conf['JSwindow'] = isset($conf['JSwindow.']) ?
$this->stdWrap($conf['JSwindow'], $conf['JSwindow.']) : $conf['JSwindow'];
1744 if ($conf['JSwindow']) {
1745 if ($conf['JSwindow.']['altUrl'] ||
$conf['JSwindow.']['altUrl.']) {
1746 $altUrl = isset($conf['JSwindow.']['altUrl.']) ?
$this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.']) : $conf['JSwindow.']['altUrl'];
1748 $url = $altUrl . ($conf['JSwindow.']['altUrl_noDefaultParams'] ?
'' : '?file=' . rawurlencode($imageFile) . $params);
1752 $processedFile = $file->process('Image.CropScaleMask', $conf);
1753 $JSwindowExpand = isset($conf['JSwindow.']['expand.']) ?
$this->stdWrap($conf['JSwindow.']['expand'], $conf['JSwindow.']['expand.']) : $conf['JSwindow.']['expand'];
1754 $offset = GeneralUtility
::intExplode(',', $JSwindowExpand . ',');
1755 $newWindow = isset($conf['JSwindow.']['newWindow.']) ?
$this->stdWrap($conf['JSwindow.']['newWindow'], $conf['JSwindow.']['newWindow.']) : $conf['JSwindow.']['newWindow'];
1756 $onClick = 'openPic('
1757 . GeneralUtility
::quoteJSvalue($GLOBALS['TSFE']->baseUrlWrap($url)) . ','
1758 . '\'' . ($newWindow ?
md5($url) : 'thePicture') . '\','
1759 . GeneralUtility
::quoteJSvalue('width=' . ($processedFile->getProperty('width') +
$offset[0])
1760 . ',height=' . ($processedFile->getProperty('height') +
$offset[1]) . ',status=0,menubar=0')
1761 . '); return false;';
1762 $a1 = '<a href="' . htmlspecialchars($url) . '" onclick="' . htmlspecialchars($onClick) . '"' . $target . $GLOBALS['TSFE']->ATagParams
. '>';
1764 $GLOBALS['TSFE']->setJS('openPic');
1766 $conf['linkParams.']['parameter'] = $url;
1767 $string = $this->typoLink($string, $conf['linkParams.']);
1769 if (isset($conf['stdWrap.'])) {
1770 $string = $this->stdWrap($string, $conf['stdWrap.']);
1772 $content = $a1 . $string . $a2;
1779 * Returns content of a file. If it's an image the content of the file is not returned but rather an image tag is.
1781 * @param string $fName The filename, being a TypoScript resource data type
1782 * @param string $addParams Additional parameters (attributes). Default is empty alt and title tags.
1783 * @return string If jpg,gif,jpeg,png: returns image_tag with picture in. If html,txt: returns content string
1786 public function fileResource($fName, $addParams = 'alt="" title=""') {
1787 $incFile = $GLOBALS['TSFE']->tmpl
->getFileName($fName);
1788 if ($incFile && file_exists($incFile)) {
1789 $fileinfo = GeneralUtility
::split_fileref($incFile);
1790 if (GeneralUtility
::inList('jpg,gif,jpeg,png', $fileinfo['fileext'])) {
1791 $imgFile = $incFile;
1792 $imgInfo = @getImageSize
($imgFile);
1793 return '<img src="' . $GLOBALS['TSFE']->absRefPrefix
. $imgFile . '" width="' . $imgInfo[0] . '" height="' . $imgInfo[1] . '"' . $this->getBorderAttr(' border="0"') . ' ' . $addParams . ' />';
1794 } elseif (filesize($incFile) < 1024 * 1024) {
1795 return $GLOBALS['TSFE']->tmpl
->fileContent($incFile);
1801 * Sets the SYS_LASTCHANGED timestamp if input timestamp is larger than current value.
1802 * The SYS_LASTCHANGED timestamp can be used by various caching/indexing applications to determine if the page has new content.
1803 * Therefore you should call this function with the last-changed timestamp of any element you display.
1805 * @param int $tstamp Unix timestamp (number of seconds since 1970)
1807 * @see TypoScriptFrontendController::setSysLastChanged()
1809 public function lastChanged($tstamp) {
1810 $tstamp = (int)$tstamp;
1811 if ($tstamp > (int)$GLOBALS['TSFE']->register
['SYS_LASTCHANGED']) {
1812 $GLOBALS['TSFE']->register
['SYS_LASTCHANGED'] = $tstamp;
1817 * Wraps the input string by the $wrap value and implements the "linkWrap" data type as well.
1818 * The "linkWrap" data type means that this function will find any integer encapsulated in {} (curly braces) in the first wrap part and substitute it with the corresponding page uid from the rootline where the found integer is pointing to the key in the rootline. See link below.
1820 * @param string $content Input string
1821 * @param string $wrap A string where the first two parts separated by "|" (vertical line) will be wrapped around the input string
1822 * @return string Wrapped output string
1823 * @see wrap(), cImage(), FILE()
1825 public function linkWrap($content, $wrap) {
1826 $wrapArr = explode('|', $wrap);
1827 if (preg_match('/\\{([0-9]*)\\}/', $wrapArr[0], $reg)) {
1828 if ($uid = $GLOBALS['TSFE']->tmpl
->rootLine
[$reg[1]]['uid']) {
1829 $wrapArr[0] = str_replace($reg[0], $uid, $wrapArr[0]);
1832 return trim($wrapArr[0]) . $content . trim($wrapArr[1]);
1836 * An abstraction method which creates an alt or title parameter for an HTML img, applet, area or input element and the FILE content element.
1837 * From the $conf array it implements the properties "altText", "titleText" and "longdescURL"
1839 * @param array $conf TypoScript configuration properties
1840 * @param bool $longDesc If set, the longdesc attribute will be generated - must only be used for img elements!
1841 * @return string Parameter string containing alt and title parameters (if any)
1842 * @see IMGTEXT(), FILE(), FORM(), cImage(), filelink()
1844 public function getAltParam($conf, $longDesc = TRUE) {
1845 $altText = isset($conf['altText.']) ?
trim($this->stdWrap($conf['altText'], $conf['altText.'])) : trim($conf['altText']);
1846 $titleText = isset($conf['titleText.']) ?
trim($this->stdWrap($conf['titleText'], $conf['titleText.'])) : trim($conf['titleText']);
1847 if (isset($conf['longdescURL.']) && $GLOBALS['TSFE']->config
['config']['doctype'] != 'html5') {
1848 $longDesc = $this->typoLink_URL($conf['longdescURL.']);
1850 $longDesc = trim($conf['longdescURL']);
1853 $altParam = ' alt="' . htmlspecialchars($altText) . '"';
1855 $emptyTitleHandling = 'useAlt';
1856 $emptyTitleHandling = isset($conf['emptyTitleHandling.']) ?
$this->stdWrap($conf['emptyTitleHandling'], $conf['emptyTitleHandling.']) : $conf['emptyTitleHandling'];
1857 // Choices: 'keepEmpty' | 'useAlt' | 'removeAttr'
1858 if ($titleText ||
$emptyTitleHandling == 'keepEmpty') {
1859 $altParam .= ' title="' . htmlspecialchars($titleText) . '"';
1860 } elseif (!$titleText && $emptyTitleHandling == 'useAlt') {
1861 $altParam .= ' title="' . htmlspecialchars($altText) . '"';
1865 $altParam .= ' longdesc="' . htmlspecialchars(strip_tags($longDesc)) . '"';
1871 * Removes forbidden characters and spaces from name/id attributes in the form tag and formfields
1873 * @param string $name Input string
1874 * @return string the cleaned string
1876 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, the method is moved to FormContentObject
1878 public function cleanFormName($name) {
1879 GeneralUtility
::logDeprecatedFunction();
1880 // Turn data[x][y] into data:x:y:
1881 $name = preg_replace('/\\[|\\]\\[?/', ':', trim($name));
1882 // Remove illegal chars like _
1883 return preg_replace('#[^:a-zA-Z0-9]#', '', $name);
1887 * An abstraction method to add parameters to an A tag.
1888 * Uses the ATagParams property.
1890 * @param array $conf TypoScript configuration properties
1891 * @param bool $addGlobal If set, will add the global config.ATagParams to the link
1892 * @return string String containing the parameters to the A tag (if non empty, with a leading space)
1893 * @see IMGTEXT(), filelink(), makelinks(), typolink()
1895 public function getATagParams($conf, $addGlobal = 1) {
1897 if ($conf['ATagParams.']) {
1898 $aTagParams = ' ' . $this->stdWrap($conf['ATagParams'], $conf['ATagParams.']);
1899 } elseif ($conf['ATagParams']) {
1900 $aTagParams = ' ' . $conf['ATagParams'];
1903 $aTagParams = ' ' . trim(($GLOBALS['TSFE']->ATagParams
. $aTagParams));
1906 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getATagParamsPostProc']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getATagParamsPostProc'])) {
1909 'aTagParams' => &$aTagParams
1911 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getATagParamsPostProc'] as $objRef) {
1912 $processor =& GeneralUtility
::getUserObj($objRef);
1913 $aTagParams = $processor->process($_params, $this);
1917 $aTagParams = trim($aTagParams);
1918 if (!empty($aTagParams)) {
1919 $aTagParams = ' ' . $aTagParams;
1926 * All extension links should ask this function for additional properties to their tags.
1927 * Designed to add for instance an "onclick" property for site tracking systems.
1929 * @param string $URL URL of the website
1930 * @param string $TYPE
1931 * @return string The additional tag properties
1933 public function extLinkATagParams($URL, $TYPE) {
1935 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']) {
1936 $extLinkATagParamsHandler = GeneralUtility
::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']);
1937 if (method_exists($extLinkATagParamsHandler, 'main')) {
1938 $out .= trim($extLinkATagParamsHandler->main($URL, $TYPE, $this));
1941 return trim($out) ?
' ' . trim($out) : '';
1944 /***********************************************
1946 * HTML template processing functions
1948 ***********************************************/
1950 * Returns a subpart from the input content stream.
1951 * A subpart is a part of the input stream which is encapsulated in a
1952 * string matching the input string, $marker. If this string is found
1953 * inside of HTML comment tags the start/end points of the content block
1954 * returned will be that right outside that comment block.
1955 * Example: The contennt string is
1956 * "Hello <!--###sub1### begin--> World. How are <!--###sub1### end--> you?"
1957 * If $marker is "###sub1###" then the content returned is
1958 * " World. How are ". The input content string could just as well have
1959 * been "Hello ###sub1### World. How are ###sub1### you?" and the result
1961 * Wrapper for \TYPO3\CMS\Core\Html\HtmlParser::getSubpart which behaves identical
1963 * @param string $content The content stream, typically HTML template content.
1964 * @param string $marker The marker string, typically on the form "###[the marker string]###
1965 * @return string The subpart found, if found.
1967 public function getSubpart($content, $marker) {
1968 return HtmlParser
::getSubpart($content, $marker);
1972 * Substitute subpart in input template stream.
1973 * This function substitutes a subpart in $content with the content of
1975 * Wrapper for \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart which behaves identical
1977 * @param string $content The content stream, typically HTML template content.
1978 * @param string $marker The marker string, typically on the form "###[the marker string]###
1979 * @param mixed $subpartContent The content to insert instead of the subpart found. If a string, then just plain substitution happens (includes removing the HTML comments of the subpart if found). If $subpartContent happens to be an array, it's [0] and [1] elements are wrapped around the EXISTING content of the subpart (fetched by getSubpart()) thereby not removing the original content.
1980 * @param bool $recursive If $recursive is set, the function calls itself with the content set to the remaining part of the content after the second marker. This means that proceding subparts are ALSO substituted!
1981 * @return string The processed HTML content string.
1983 public function substituteSubpart($content, $marker, $subpartContent, $recursive = 1) {
1984 return HtmlParser
::substituteSubpart($content, $marker, $subpartContent, $recursive);
1988 * Substitues multiple subparts at once
1990 * @param string $content The content stream, typically HTML template content.
1991 * @param array $subpartsContent The array of key/value pairs being subpart/content values used in the substitution. For each element in this array the function will substitute a subpart in the content stream with the content.
1992 * @return string The processed HTML content string.
1994 public function substituteSubpartArray($content, array $subpartsContent) {
1995 return HtmlParser
::substituteSubpartArray($content, $subpartsContent);
1999 * Substitutes a marker string in the input content
2000 * (by a simple str_replace())
2002 * @param string $content The content stream, typically HTML template content.
2003 * @param string $marker The marker string, typically on the form "###[the marker string]###
2004 * @param mixed $markContent The content to insert instead of the marker string found.
2005 * @return string The processed HTML content string.
2006 * @see substituteSubpart()
2008 public function substituteMarker($content, $marker, $markContent) {
2009 return HtmlParser
::substituteMarker($content, $marker, $markContent);
2013 * Multi substitution function with caching.
2015 * This function should be a one-stop substitution function for working
2016 * with HTML-template. It does not substitute by str_replace but by
2017 * splitting. This secures that the value inserted does not themselves
2018 * contain markers or subparts.
2020 * Note that the "caching" won't cache the content of the substition,
2021 * but only the splitting of the template in various parts. So if you
2022 * want only one cache-entry per template, make sure you always pass the
2023 * exact same set of marker/subpart keys. Else you will be flooding the
2024 * users cache table.
2026 * This function takes three kinds of substitutions in one:
2027 * $markContentArray is a regular marker-array where the 'keys' are
2028 * substituted in $content with their values
2030 * $subpartContentArray works exactly like markContentArray only is whole
2031 * subparts substituted and not only a single marker.
2033 * $wrappedSubpartContentArray is an array of arrays with 0/1 keys where
2034 * the subparts pointed to by the main key is wrapped with the 0/1 value
2037 * @param string $content The content stream, typically HTML template content.
2038 * @param array $markContentArray Regular marker-array where the 'keys' are substituted in $content with their values
2039 * @param array $subpartContentArray Exactly like markContentArray only is whole subparts substituted and not only a single marker.
2040 * @param array $wrappedSubpartContentArray 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.
2041 * @return string The output content stream
2042 * @see substituteSubpart(), substituteMarker(), substituteMarkerInObject(), TEMPLATE()
2044 public function substituteMarkerArrayCached($content, array $markContentArray = NULL, array $subpartContentArray = NULL, array $wrappedSubpartContentArray = NULL) {
2045 $GLOBALS['TT']->push('substituteMarkerArrayCached');
2046 // If not arrays then set them
2047 if (is_null($markContentArray)) {
2049 $markContentArray = array();
2051 if (is_null($subpartContentArray)) {
2052 // Subparts being directly substituted
2053 $subpartContentArray = array();
2055 if (is_null($wrappedSubpartContentArray)) {
2056 // Subparts being wrapped
2057 $wrappedSubpartContentArray = array();
2059 // Finding keys and check hash:
2060 $sPkeys = array_keys($subpartContentArray);
2061 $wPkeys = array_keys($wrappedSubpartContentArray);
2062 $aKeys = array_merge(array_keys($markContentArray), $sPkeys, $wPkeys);
2063 if (empty($aKeys)) {
2064 $GLOBALS['TT']->pull();
2068 $storeKey = md5('substituteMarkerArrayCached_storeKey:' . serialize(array(
2072 if ($this->substMarkerCache
[$storeKey]) {
2073 $storeArr = $this->substMarkerCache
[$storeKey];
2074 $GLOBALS['TT']->setTSlogMessage('Cached', 0);
2076 $storeArrDat = $GLOBALS['TSFE']->sys_page
->getHash($storeKey);
2077 if (is_array($storeArrDat)) {
2078 $storeArr = $storeArrDat;
2080 $this->substMarkerCache
[$storeKey] = $storeArr;
2081 $GLOBALS['TT']->setTSlogMessage('Cached from DB', 0);
2083 // Initialize storeArr
2084 $storeArr = array();
2085 // Finding subparts and substituting them with the subpart as a marker
2086 foreach ($sPkeys as $sPK) {
2087 $content = $this->substituteSubpart($content, $sPK, $sPK);
2089 // Finding subparts and wrapping them with markers
2090 foreach ($wPkeys as $wPK) {
2091 $content = $this->substituteSubpart($content, $wPK, array(
2096 // Traverse keys and quote them for reg ex.
2097 foreach ($aKeys as $tK => $tV) {
2098 $aKeys[$tK] = preg_quote($tV, '/');
2100 $regex = '/' . implode('|', $aKeys) . '/';
2102 $storeArr['c'] = preg_split($regex, $content);
2103 preg_match_all($regex, $content, $keyList);
2104 $storeArr['k'] = $keyList[0];
2106 $this->substMarkerCache
[$storeKey] = $storeArr;
2107 // Storing the cached data:
2108 $GLOBALS['TSFE']->sys_page
->storeHash($storeKey, $storeArr, 'substMarkArrayCached');
2109 $GLOBALS['TT']->setTSlogMessage('Parsing', 0);
2112 // Substitution/Merging:
2113 // Merging content types together, resetting
2114 $valueArr = array_merge($markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
2115 $wSCA_reg = array();
2117 // Traversing the keyList array and merging the static and dynamic content
2118 foreach ($storeArr['k'] as $n => $keyN) {
2119 $content .= $storeArr['c'][$n];
2120 if (!is_array($valueArr[$keyN])) {
2121 $content .= $valueArr[$keyN];
2123 $content .= $valueArr[$keyN][(int)$wSCA_reg[$keyN] %
2];
2127 $content .= $storeArr['c'][count($storeArr['k'])];
2128 $GLOBALS['TT']->pull();
2133 * Traverses the input $markContentArray array and for each key the marker
2134 * by the same name (possibly wrapped and in upper case) will be
2135 * substituted with the keys value in the array.
2137 * This is very useful if you have a data-record to substitute in some
2138 * content. In particular when you use the $wrap and $uppercase values to
2139 * pre-process the markers. Eg. a key name like "myfield" could effectively
2140 * be represented by the marker "###MYFIELD###" if the wrap value
2141 * was "###|###" and the $uppercase boolean TRUE.
2143 * @param string $content The content stream, typically HTML template content.
2144 * @param array $markContentArray The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
2145 * @param string $wrap A wrap value - [part 1] | [part 2] - for the markers before substitution
2146 * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
2147 * @param bool $deleteUnused If set, all unused marker are deleted.
2148 * @return string The processed output stream
2149 * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE()
2151 public function substituteMarkerArray($content, array $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
2152 return HtmlParser
::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
2156 * Substitute marker array in an array of values
2158 * @param mixed $tree If string, then it just calls substituteMarkerArray. If array(and even multi-dim) then for each key/value pair the marker array will be substituted (by calling this function recursively)
2159 * @param array $markContentArray The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content string/array values.
2160 * @return mixed The processed input variable.
2161 * @see substituteMarker()
2163 public function substituteMarkerInObject(&$tree, array $markContentArray) {
2164 if (is_array($tree)) {
2165 foreach ($tree as $key => $value) {
2166 $this->substituteMarkerInObject($tree[$key], $markContentArray);
2169 $tree = $this->substituteMarkerArray($tree, $markContentArray);
2175 * Replaces all markers and subparts in a template with the content provided in the structured array.
2177 * @param string $content
2178 * @param array $markersAndSubparts
2179 * @param string $wrap
2180 * @param bool $uppercase
2181 * @param bool $deleteUnused
2184 public function substituteMarkerAndSubpartArrayRecursive($content, array $markersAndSubparts, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
2185 return HtmlParser
::substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
2189 * Adds elements to the input $markContentArray based on the values from
2190 * the fields from $fieldList found in $row
2192 * @param array $markContentArray Array with key/values being marker-strings/substitution values.
2193 * @param array $row An array with keys found in the $fieldList (typically a record) which values should be moved to the $markContentArray
2194 * @param string $fieldList A list of fields from the $row array to add to the $markContentArray array. If empty all fields from $row will be added (unless they are integers)
2195 * @param bool $nl2br If set, all values added to $markContentArray will be nl2br()'ed
2196 * @param string $prefix Prefix string to the fieldname before it is added as a key in the $markContentArray. Notice that the keys added to the $markContentArray always start and end with "###
2197 * @param bool $HSC If set, all values are passed through htmlspecialchars() - RECOMMENDED to avoid most obvious XSS and maintain XHTML compliance.
2198 * @return array The modified $markContentArray
2200 public function fillInMarkerArray(array $markContentArray, array $row, $fieldList = '', $nl2br = TRUE, $prefix = 'FIELD_', $HSC = FALSE) {
2202 $fArr = GeneralUtility
::trimExplode(',', $fieldList, TRUE);
2203 foreach ($fArr as $field) {
2204 $markContentArray['###' . $prefix . $field . '###'] = $nl2br ?
nl2br($row[$field], !empty($GLOBALS['TSFE']->xhtmlDoctype
)) : $row[$field];
2207 if (is_array($row)) {
2208 foreach ($row as $field => $value) {
2209 if (!MathUtility
::canBeInterpretedAsInteger($field)) {
2211 $value = htmlspecialchars($value);
2213 $markContentArray['###' . $prefix . $field . '###'] = $nl2br ?
nl2br($value, !empty($GLOBALS['TSFE']->xhtmlDoctype
)) : $value;
2218 return $markContentArray;
2222 * Sets the current file object during iterations over files.
2224 * @param File $fileObject The file object.
2226 public function setCurrentFile($fileObject) {
2227 $this->currentFile
= $fileObject;
2231 * Gets the current file object during iterations over files.
2233 * @return File The current file object.
2235 public function getCurrentFile() {
2236 return $this->currentFile
;
2239 /***********************************************
2241 * "stdWrap" + sub functions
2243 ***********************************************/
2245 * The "stdWrap" function. This is the implementation of what is known as "stdWrap properties" in TypoScript.
2246 * Basically "stdWrap" performs some processing of a value based on properties in the input $conf array(holding the TypoScript "stdWrap properties")
2247 * See the link below for a complete list of properties and what they do. The order of the table with properties found in TSref (the link) follows the actual order of implementation in this function.
2249 * If $this->alternativeData is an array it's used instead of the $this->data array in ->getData
2251 * @param string $content Input value undergoing processing in this function. Possibly substituted by other values fetched from another source.
2252 * @param array $conf TypoScript "stdWrap properties".
2253 * @return string The processed input value
2255 public function stdWrap($content = '', $conf = array()) {
2256 // If there is any hook object, activate all of the process and override functions.
2257 // The hook interface ContentObjectStdWrapHookInterface takes care that all 4 methods exist.
2258 if ($this->stdWrapHookObjects
) {
2259 $conf['stdWrapPreProcess'] = 1;
2260 $conf['stdWrapOverride'] = 1;
2261 $conf['stdWrapProcess'] = 1;
2262 $conf['stdWrapPostProcess'] = 1;
2265 if (!is_array($conf) ||
!$conf) {
2270 if (is_array($conf['cache.'])) {
2271 $conf['cache.']['key'] = $this->stdWrap($conf['cache.']['key'], $conf['cache.']['key.']);
2272 $conf['cache.']['tags'] = $this->stdWrap($conf['cache.']['tags'], $conf['cache.']['tags.']);
2273 $conf['cache.']['lifetime'] = $this->stdWrap($conf['cache.']['lifetime'], $conf['cache.']['lifetime.']);
2274 $conf['cacheRead'] = 1;
2275 $conf['cacheStore'] = 1;
2277 // Check, which of the available stdWrap functions is needed for the current conf Array
2278 // and keep only those but still in the same order
2279 $sortedConf = array_intersect_key($this->stdWrapOrder
, $conf);
2280 // Functions types that should not make use of nested stdWrap function calls to avoid conflicts with internal TypoScript used by these functions
2281 $stdWrapDisabledFunctionTypes = 'cObject,functionName,stdWrap';
2282 // Additional Array to check whether a function has already been executed
2283 $isExecuted = array();
2284 // Additional switch to make sure 'required', 'if' and 'fieldRequired'
2285 // will still stop rendering immediately in case they return FALSE
2286 $this->stdWrapRecursionLevel++
;
2287 $this->stopRendering
[$this->stdWrapRecursionLevel
] = FALSE;
2288 // execute each function in the predefined order
2289 foreach ($sortedConf as $stdWrapName => $functionType) {
2290 // eliminate the second key of a pair 'key'|'key.' to make sure functions get called only once and check if rendering has been stopped
2291 if (!$isExecuted[$stdWrapName] && !$this->stopRendering
[$this->stdWrapRecursionLevel
]) {
2292 $functionName = rtrim($stdWrapName, '.');
2293 $functionProperties = $functionName . '.';
2294 // If there is any code on the next level, check if it contains "official" stdWrap functions
2295 // if yes, execute them first - will make each function stdWrap aware
2296 // so additional stdWrap calls within the functions can be removed, since the result will be the same
2297 // exception: the recursive stdWrap function and cObject will still be using their own stdWrap call, since it modifies the content and not a property
2298 if ($functionName !== 'stdWrap' && !empty($conf[$functionProperties]) && !GeneralUtility
::inList($stdWrapDisabledFunctionTypes, $functionType)) {
2299 if (array_intersect_key($this->stdWrapOrder
, $conf[$functionProperties])) {
2300 $conf[$functionName] = $this->stdWrap($conf[$functionName], $conf[$functionProperties]);
2303 // Check if key is still containing something, since it might have been changed by next level stdWrap before
2304 if ((isset($conf[$functionName]) ||
$conf[$functionProperties]) && ($functionType !== 'boolean' ||
$conf[$functionName])) {
2305 // Get just that part of $conf that is needed for the particular function
2306 $singleConf = array(
2307 $functionName => $conf[$functionName],
2308 $functionProperties => $conf[$functionProperties]
2310 // In this special case 'spaceBefore' and 'spaceAfter' need additional stuff from 'space.''
2311 if ($functionName === 'spaceBefore' ||
$functionName === 'spaceAfter') {
2312 $singleConf['space.'] = $conf['space.'];
2314 // Hand over the whole $conf array to the stdWrapHookObjects
2315 if ($functionType === 'hook') {
2316 $singleConf = $conf;
2318 // Add both keys - with and without the dot - to the set of executed functions
2319 $isExecuted[$functionName] = TRUE;
2320 $isExecuted[$functionProperties] = TRUE;
2321 // Call the function with the prefix stdWrap_ to make sure nobody can execute functions just by adding their name to the TS Array
2322 $functionName = 'stdWrap_' . $functionName;
2323 $content = $this->{$functionName}($content, $singleConf);
2324 } elseif ($functionType == 'boolean' && !$conf[$functionName]) {
2325 $isExecuted[$functionName] = TRUE;
2326 $isExecuted[$functionProperties] = TRUE;
2330 unset($this->stopRendering
[$this->stdWrapRecursionLevel
]);
2331 $this->stdWrapRecursionLevel
--;
2337 * Gets a configuration value by passing them through stdWrap first and taking a default value if stdWrap doesn't yield a result.
2339 * @param string $key The config variable key (from TS array).
2340 * @param array $config The TypoScript array.
2341 * @param string $defaultValue Optional default value.
2342 * @return string Value of the config variable
2344 public function stdWrapValue($key, array $config, $defaultValue = '') {
2345 if (isset($config[$key])) {
2346 if (!isset($config[$key . '.'])) {
2347 return $config[$key];
2349 } elseif (isset($config[$key . '.'])) {
2352 return $defaultValue;
2354 $stdWrapped = $this->stdWrap($config[$key], $config[$key . '.']);
2355 return $stdWrapped ?
: $defaultValue;
2359 * stdWrap pre process hook
2360 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2361 * this hook will execute functions before any other stdWrap function can modify anything
2363 * @param string $content Input value undergoing processing in these functions.
2364 * @param array $conf All stdWrap properties, not just the ones for a particular function.
2365 * @return string The processed input value
2367 public function stdWrap_stdWrapPreProcess($content = '', $conf = array()) {
2368 foreach ($this->stdWrapHookObjects
as $hookObject) {
2369 $content = $hookObject->stdWrapPreProcess($content, $conf, $this);
2375 * Check if content was cached before (depending on the given cache key)
2377 * @param string $content Input value undergoing processing in these functions.
2378 * @param array $conf All stdWrap properties, not just the ones for a particular function.
2379 * @return string The processed input value
2381 public function stdWrap_cacheRead($content = '', $conf = array()) {
2382 if (!isset($conf['cache.'])) {
2385 $result = $this->getFromCache($conf['cache.']);
2386 return $result === FALSE ?
$content : $result;
2390 * Add tags to page cache (comma-separated list)
2392 * @param string $content Input value undergoing processing in these functions.
2393 * @param array $conf All stdWrap properties, not just the ones for a particular function.
2394 * @return string The processed input value
2396 public function stdWrap_addPageCacheTags($content = '', $conf = array()) {
2397 $tags = isset($conf['addPageCacheTags.'])
2398 ?
$this->stdWrap($conf['addPageCacheTags'], $conf['addPageCacheTags.'])
2399 : $conf['addPageCacheTags'];
2400 if (!empty($tags)) {
2401 $cacheTags = GeneralUtility
::trimExplode(',', $tags, TRUE);
2402 $GLOBALS['TSFE']->addCacheTags($cacheTags);
2408 * setContentToCurrent
2409 * actually it just does the contrary: Sets the value of 'current' based on current content
2411 * @param string $content Input value undergoing processing in this function.
2412 * @param array $conf stdWrap properties for setContentToCurrent.
2413 * @return string The processed input value
2415 public function stdWrap_setContentToCurrent($content = '', $conf = array()) {
2416 $this->data
[$this->currentValKey
] = $content;
2422 * Sets the value of 'current' based on the outcome of stdWrap operations
2424 * @param string $content Input value undergoing processing in this function.
2425 * @param array $conf stdWrap properties for setCurrent.
2426 * @return string The processed input value
2428 public function stdWrap_setCurrent($content = '', $conf = array()) {
2429 $this->data
[$this->currentValKey
] = $conf['setCurrent'];
2435 * Translates content based on the language currently used by the FE
2437 * @param string $content Input value undergoing processing in this function.
2438 * @param array $conf stdWrap properties for lang.
2439 * @return string The processed input value
2441 public function stdWrap_lang($content = '', $conf = array()) {
2442 if (isset($conf['lang.']) && $GLOBALS['TSFE']->config
['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config
['config']['language']])) {
2443 $content = $conf['lang.'][$GLOBALS['TSFE']->config
['config']['language']];
2450 * Gets content from different sources based on getText functions, makes use of alternativeData, when set
2452 * @param string $content Input value undergoing processing in this function.
2453 * @param array $conf stdWrap properties for data.
2454 * @return string The processed input value
2456 public function stdWrap_data($content = '', $conf = array()) {
2457 $content = $this->getData($conf['data'], is_array($this->alternativeData
) ?
$this->alternativeData
: $this->data
);
2458 // This must be unset directly after
2459 $this->alternativeData
= '';
2465 * Gets content from a DB field
2467 * @param string $content Input value undergoing processing in this function.
2468 * @param array $conf stdWrap properties for field.
2469 * @return string The processed input value
2471 public function stdWrap_field($content = '', $conf = array()) {
2472 return $this->getFieldVal($conf['field']);
2477 * Gets content that has been perviously set as 'current'
2478 * Can be set via setContentToCurrent or setCurrent or will be set automatically i.e. inside the split function
2480 * @param string $content Input value undergoing processing in this function.
2481 * @param array $conf stdWrap properties for current.
2482 * @return string The processed input value
2484 public function stdWrap_current($content = '', $conf = array()) {
2485 return $this->data
[$this->currentValKey
];
2490 * Will replace the content with the value of a any official TypoScript cObject
2491 * like TEXT, COA, HMENU
2493 * @param string $content Input value undergoing processing in this function.
2494 * @param array $conf stdWrap properties for cObject.
2495 * @return string The processed input value
2497 public function stdWrap_cObject($content = '', $conf = array()) {
2498 return $this->cObjGetSingle($conf['cObject'], $conf['cObject.'], '/stdWrap/.cObject');
2503 * Counts the number of returned records of a DB operation
2504 * makes use of select internally
2506 * @param string $content Input value undergoing processing in this function.
2507 * @param array $conf stdWrap properties for numRows.
2508 * @return string The processed input value
2510 public function stdWrap_numRows($content = '', $conf = array()) {
2511 return $this->numRows($conf['numRows.']);
2516 * Will create a list of files based on some additional parameters
2518 * @param string $content Input value undergoing processing in this function.
2519 * @param array $conf stdWrap properties for filelist.
2520 * @return string The processed input value
2522 public function stdWrap_filelist($content = '', $conf = array()) {
2523 return $this->filelist($conf['filelist']);
2528 * Will execute a user public function before the content will be modified by any other stdWrap function
2530 * @param string $content Input value undergoing processing in this function.
2531 * @param array $conf stdWrap properties for preUserFunc.
2532 * @return string The processed input value
2534 public function stdWrap_preUserFunc($content = '', $conf = array()) {
2535 return $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);
2539 * stdWrap override hook
2540 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2541 * this hook will execute functions on existing content but still before the content gets modified or replaced
2543 * @param string $content Input value undergoing processing in these functions.
2544 * @param array $conf All stdWrap properties, not just the ones for a particular function.
2545 * @return string The processed input value
2547 public function stdWrap_stdWrapOverride($content = '', $conf = array()) {
2548 foreach ($this->stdWrapHookObjects
as $hookObject) {
2549 $content = $hookObject->stdWrapOverride($content, $conf, $this);
2556 * Will override the current value of content with its own value'
2558 * @param string $content Input value undergoing processing in this function.
2559 * @param array $conf stdWrap properties for override.
2560 * @return string The processed input value
2562 public function stdWrap_override($content = '', $conf = array()) {
2563 if (trim($conf['override'])) {
2564 $content = $conf['override'];
2571 * Gets a value off a CSV list before the following ifEmpty check
2572 * Makes sure that the result of ifEmpty will be TRUE in case the CSV does not contain a value at the position given by preIfEmptyListNum
2574 * @param string $content Input value undergoing processing in this function.
2575 * @param array $conf stdWrap properties for preIfEmptyListNum.
2576 * @return string The processed input value
2578 public function stdWrap_preIfEmptyListNum($content = '', $conf = array()) {
2579 return $this->listNum($content, $conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['splitChar']);
2584 * Will set content to a replacement value in case the value of content is NULL
2586 * @param string|NULL $content Input value undergoing processing in this function.
2587 * @param array $conf stdWrap properties for ifNull.
2588 * @return string The processed input value
2590 public function stdWrap_ifNull($content = '', $conf = array()) {
2591 return $content !== NULL ?
$content : $conf['ifNull'];
2596 * Will set content to a replacement value in case the trimmed value of content returns FALSE
2597 * 0 (zero) will be replaced as well
2599 * @param string $content Input value undergoing processing in this function.
2600 * @param array $conf stdWrap properties for ifEmpty.
2601 * @return string The processed input value
2603 public function stdWrap_ifEmpty($content = '', $conf = array()) {
2604 if (!trim($content)) {
2605 $content = $conf['ifEmpty'];
2612 * Will set content to a replacement value in case the trimmed value of content has no length
2613 * 0 (zero) will not be replaced
2615 * @param string $content Input value undergoing processing in this function.
2616 * @param array $conf stdWrap properties for ifBlank.
2617 * @return string The processed input value
2619 public function stdWrap_ifBlank($content = '', $conf = array()) {
2620 if (trim($content) === '') {
2621 $content = $conf['ifBlank'];
2628 * Gets a value off a CSV list after ifEmpty check
2629 * Might return an empty value in case the CSV does not contain a value at the position given by listNum
2630 * Use preIfEmptyListNum to avoid that behaviour
2632 * @param string $content Input value undergoing processing in this function.
2633 * @param array $conf stdWrap properties for listNum.
2634 * @return string The processed input value
2636 public function stdWrap_listNum($content = '', $conf = array()) {
2637 return $this->listNum($content, $conf['listNum'], $conf['listNum.']['splitChar']);
2642 * Cuts off any whitespace at the beginning and the end of the content
2644 * @param string $content Input value undergoing processing in this function.
2645 * @param array $conf stdWrap properties for trim.
2646 * @return string The processed input value
2648 public function stdWrap_trim($content = '', $conf = array()) {
2649 return trim($content);
2654 * Will return a string padded left/right/on both sides, based on configuration given as stdWrap properties
2656 * @param string $content Input value undergoing processing in this function.
2657 * @param array $conf stdWrap properties for strPad.
2658 * @return string The processed input value
2660 public function stdWrap_strPad($content = '', $conf = array()) {
2661 // Must specify a length in conf for this to make sense
2663 // Padding with space is PHP-default
2665 // Padding on the right side is PHP-default
2666 $padType = STR_PAD_RIGHT
;
2667 if (!empty($conf['strPad.']['length'])) {
2668 $length = isset($conf['strPad.']['length.']) ?
$this->stdWrap($conf['strPad.']['length'], $conf['strPad.']['length.']) : $conf['strPad.']['length'];
2669 $length = (int)$length;
2671 if (isset($conf['strPad.']['padWith']) && (string)$conf['strPad.']['padWith'] !== '') {
2672 $padWith = isset($conf['strPad.']['padWith.']) ?
$this->stdWrap($conf['strPad.']['padWith'], $conf['strPad.']['padWith.']) : $conf['strPad.']['padWith'];
2674 if (!empty($conf['strPad.']['type'])) {
2675 $type = isset($conf['strPad.']['type.']) ?
$this->stdWrap($conf['strPad.']['type'], $conf['strPad.']['type.']) : $conf['strPad.']['type'];
2676 if (strtolower($type) === 'left') {
2677 $padType = STR_PAD_LEFT
;
2678 } elseif (strtolower($type) === 'both') {
2679 $padType = STR_PAD_BOTH
;
2682 $content = str_pad($content, $length, $padWith, $padType);
2688 * A recursive call of the stdWrap function set
2689 * This enables the user to execute stdWrap functions in another than the predefined order
2690 * It modifies the content, not the property
2691 * while the new feature of chained stdWrap functions modifies the property and not the content
2693 * @param string $content Input value undergoing processing in this function.
2694 * @param array $conf stdWrap properties for stdWrap.
2695 * @return string The processed input value
2697 public function stdWrap_stdWrap($content = '', $conf = array()) {
2698 return $this->stdWrap($content, $conf['stdWrap.']);
2702 * stdWrap process hook
2703 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2704 * this hook executes functions directly after the recursive stdWrap function call but still before the content gets modified
2706 * @param string $content Input value undergoing processing in these functions.
2707 * @param array $conf All stdWrap properties, not just the ones for a particular function.
2708 * @return string The processed input value
2710 public function stdWrap_stdWrapProcess($content = '', $conf = array()) {
2711 foreach ($this->stdWrapHookObjects
as $hookObject) {
2712 $content = $hookObject->stdWrapProcess($content, $conf, $this);
2719 * Will immediately stop rendering and return an empty value
2720 * when there is no content at this point
2722 * @param string $content Input value undergoing processing in this function.
2723 * @param array $conf stdWrap properties for required.
2724 * @return string The processed input value
2726 public function stdWrap_required($content = '', $conf = array()) {
2727 if ((string)$content === '') {
2729 $this->stopRendering
[$this->stdWrapRecursionLevel
] = TRUE;
2736 * Will immediately stop rendering and return an empty value
2737 * when the result of the checks returns FALSE
2739 * @param string $content Input value undergoing processing in this function.
2740 * @param array $conf stdWrap properties for if.
2741 * @return string The processed input value
2743 public function stdWrap_if($content = '', $conf = array()) {
2744 if (empty($conf['if.']) ||
$this->checkIf($conf['if.'])) {
2747 $this->stopRendering
[$this->stdWrapRecursionLevel
] = TRUE;
2753 * Will immediately stop rendering and return an empty value
2754 * when there is no content in the field given by fieldRequired
2756 * @param string $content Input value undergoing processing in this function.
2757 * @param array $conf stdWrap properties for fieldRequired.
2758 * @return string The processed input value
2760 public function stdWrap_fieldRequired($content = '', $conf = array()) {
2761 if (!trim($this->data
[$conf['fieldRequired']])) {
2763 $this->stopRendering
[$this->stdWrapRecursionLevel
] = TRUE;
2770 * Will convert the current chracter set of the content to the one given in csConv
2772 * @param string $content Input value undergoing processing in this function.
2773 * @param array $conf stdWrap properties for csConv.
2774 * @return string The processed input value
2776 public function stdWrap_csConv($content = '', $conf = array()) {
2777 return $GLOBALS['TSFE']->csConv($content, $conf['csConv']);
2782 * Will parse the content based on functions given as stdWrap properties
2783 * Heavily used together with RTE based content
2785 * @param string $content Input value undergoing processing in this function.
2786 * @param array $conf stdWrap properties for parseFunc.
2787 * @return string The processed input value
2789 public function stdWrap_parseFunc($content = '', $conf = array()) {
2790 return $this->parseFunc($content, $conf['parseFunc.'], $conf['parseFunc']);
2795 * Will parse HTML content based on functions given as stdWrap properties
2796 * Heavily used together with RTE based content
2798 * @param string $content Input value undergoing processing in this function.
2799 * @param array $conf stdWrap properties for HTMLparser.
2800 * @return string The processed input value
2802 public function stdWrap_HTMLparser($content = '', $conf = array()) {
2803 if (is_array($conf['HTMLparser.'])) {
2804 $content = $this->HTMLparser_TSbridge($content, $conf['HTMLparser.']);
2811 * Will split the content by a given token and treat the results separately
2812 * Automatically fills 'current' with a single result
2814 * @param string $content Input value undergoing processing in this function.
2815 * @param array $conf stdWrap properties for split.
2816 * @return string The processed input value
2818 public function stdWrap_split($content = '', $conf = array()) {
2819 return $this->splitObj($content, $conf['split.']);
2824 * Will execute replacements on the content (optionally with preg-regex)
2826 * @param string $content Input value undergoing processing in this function.
2827 * @param array $conf stdWrap properties for replacement.
2828 * @return string The processed input value
2830 public function stdWrap_replacement($content = '', $conf = array()) {
2831 return $this->replacement($content, $conf['replacement.']);
2836 * Will use the content as a mathematical term and calculate the result
2837 * Can be set to 1 to just get a calculated value or 'intval' to get the integer of the result