‪TYPO3CMS  11.5
ContentContentObject.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
25 {
32  public function ‪render($conf = [])
33  {
34  if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
35  return '';
36  }
37 
38  $frontendController = $this->‪getTypoScriptFrontendController();
39  $theValue = '';
40  $originalRec = $frontendController->currentRecord;
41  // If the currentRecord is set, we register, that this record has invoked this function.
42  // It should not be allowed to do this again then!!
43  if ($originalRec) {
44  if (isset($frontendController->recordRegister[$originalRec])) {
45  ++$frontendController->recordRegister[$originalRec];
46  } else {
47  $frontendController->recordRegister[$originalRec] = 1;
48  }
49  }
50  $conf['table'] = trim((string)$this->cObj->stdWrapValue('table', $conf ?? []));
51  $conf['select.'] = !empty($conf['select.']) ? $conf['select.'] : [];
52  $renderObjName = ($conf['renderObj'] ?? false) ? $conf['renderObj'] : '<' . $conf['table'];
53  $renderObjKey = ($conf['renderObj'] ?? false) ? 'renderObj' : '';
54  $renderObjConf = $conf['renderObj.'] ?? [];
55  $slide = (int)$this->cObj->stdWrapValue('slide', $conf ?? []);
56  if (!$slide) {
57  $slide = 0;
58  }
59  $slideCollect = (int)$this->cObj->stdWrapValue('collect', $conf['slide.'] ?? []);
60  if (!$slideCollect) {
61  $slideCollect = 0;
62  }
63  $slideCollectReverse = (bool)$this->cObj->stdWrapValue('collectReverse', $conf['slide.'] ?? []);
64  $slideCollectFuzzy = (bool)$this->cObj->stdWrapValue('collectFuzzy', $conf['slide.'] ?? []);
65  if (!$slideCollect) {
66  $slideCollectFuzzy = true;
67  }
68  $again = false;
69  $tmpValue = '';
70 
71  do {
72  $records = $this->cObj->getRecords($conf['table'], $conf['select.']);
73  $cobjValue = '';
74  if (!empty($records)) {
75  // @deprecated since v11, will be removed in v12. Drop together with ContentObjectRenderer->currentRecordTotal
76  $this->cObj->currentRecordTotal = count($records);
77  $this->‪getTimeTracker()->‪setTSlogMessage('NUMROWS: ' . count($records));
78 
79  ‪$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class, $frontendController);
80  ‪$cObj->setParent($this->cObj->data, $this->cObj->currentRecord);
81  $this->cObj->currentRecordNumber = 0;
82 
83  foreach ($records as $row) {
84  // Call hook for possible manipulation of database row for cObj->data
85  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'] ?? [] as $className) {
86  $_procObj = GeneralUtility::makeInstance($className);
87  $_procObj->modifyDBRow($row, $conf['table']);
88  }
89  $registerField = $conf['table'] . ':' . ($row['uid'] ?? 0);
90  if (!($frontendController->recordRegister[$registerField] ?? false)) {
91  $this->cObj->currentRecordNumber++;
92  ‪$cObj->parentRecordNumber = $this->cObj->currentRecordNumber;
93  $frontendController->currentRecord = $registerField;
94  $this->cObj->lastChanged($row['tstamp'] ?? 0);
95  ‪$cObj->start($row, $conf['table'], $this->request);
96  $tmpValue = ‪$cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
97  $cobjValue .= $tmpValue;
98  }
99  }
100  }
101  if ($slideCollectReverse) {
102  $theValue = $cobjValue . $theValue;
103  } else {
104  $theValue .= $cobjValue;
105  }
106  if ($slideCollect > 0) {
107  $slideCollect--;
108  }
109  if ($slide) {
110  if ($slide > 0) {
111  $slide--;
112  }
113  $conf['select.']['pidInList'] = $this->cObj->getSlidePids(
114  $conf['select.']['pidInList'] ?? '',
115  $conf['select.']['pidInList.'] ?? [],
116  );
117  if (isset($conf['select.']['pidInList.'])) {
118  unset($conf['select.']['pidInList.']);
119  }
120  $again = (string)$conf['select.']['pidInList'] !== '';
121  }
122  } while ($again && $slide && ((string)$tmpValue === '' && $slideCollectFuzzy || $slideCollect));
123 
124  $wrap = $this->cObj->stdWrapValue('wrap', $conf ?? []);
125  if ($wrap) {
126  $theValue = $this->cObj->wrap($theValue, $wrap);
127  }
128  if (isset($conf['stdWrap.'])) {
129  $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
130  }
131  // Restore
132  $frontendController->currentRecord = $originalRec;
133  if ($originalRec) {
134  --$frontendController->recordRegister[$originalRec];
135  }
136  return $theValue;
137  }
138 
144  protected function ‪getTimeTracker(): ‪TimeTracker
145  {
146  return GeneralUtility::makeInstance(TimeTracker::class);
147  }
148 }
‪TYPO3\CMS\Core\TimeTracker\TimeTracker\setTSlogMessage
‪setTSlogMessage($content, $logLevel=LogLevel::INFO)
Definition: TimeTracker.php:226
‪TYPO3\CMS\Frontend\ContentObject
Definition: AbstractContentObject.php:16
‪TYPO3\CMS\Frontend\ContentObject\ContentContentObject\render
‪string render($conf=[])
Definition: ContentContentObject.php:32
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\getTypoScriptFrontendController
‪TypoScriptFrontendController getTypoScriptFrontendController()
Definition: AbstractContentObject.php:86
‪TYPO3\CMS\Frontend\ContentObject\ContentContentObject\getTimeTracker
‪TimeTracker getTimeTracker()
Definition: ContentContentObject.php:144
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
Definition: AbstractContentObject.php:29
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject\$cObj
‪ContentObjectRenderer $cObj
Definition: AbstractContentObject.php:32
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\TimeTracker\TimeTracker
Definition: TimeTracker.php:31
‪TYPO3\CMS\Frontend\ContentObject\ContentContentObject
Definition: ContentContentObject.php:25