TYPO3 CMS  TYPO3_7-6
ContentContentObject.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
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.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 
26 {
33  public function render($conf = [])
34  {
35  if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
36  return '';
37  }
38 
39  $frontendController = $this->getFrontendController();
40  $theValue = '';
41  $originalRec = $frontendController->currentRecord;
42  // If the currentRecord is set, we register, that this record has invoked this function.
43  // It's should not be allowed to do this again then!!
44  if ($originalRec) {
45  ++$frontendController->recordRegister[$originalRec];
46  }
47  $conf['table'] = isset($conf['table.']) ? trim($this->cObj->stdWrap($conf['table'], $conf['table.'])) : trim($conf['table']);
48  $conf['select.'] = !empty($conf['select.']) ? $conf['select.'] : [];
49  $renderObjName = $conf['renderObj'] ?: '<' . $conf['table'];
50  $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
51  $renderObjConf = $conf['renderObj.'];
52  $slide = isset($conf['slide.']) ? (int)$this->cObj->stdWrap($conf['slide'], $conf['slide.']) : (int)$conf['slide'];
53  if (!$slide) {
54  $slide = 0;
55  }
56  $slideCollect = isset($conf['slide.']['collect.']) ? (int)$this->cObj->stdWrap($conf['slide.']['collect'], $conf['slide.']['collect.']) : (int)$conf['slide.']['collect'];
57  if (!$slideCollect) {
58  $slideCollect = 0;
59  }
60  $slideCollectReverse = isset($conf['slide.']['collectReverse.']) ? (int)$this->cObj->stdWrap($conf['slide.']['collectReverse'], $conf['slide.']['collectReverse.']) : (int)$conf['slide.']['collectReverse'];
61  $slideCollectReverse = (bool)$slideCollectReverse;
62  $slideCollectFuzzy = isset($conf['slide.']['collectFuzzy.'])
63  ? (bool)$this->cObj->stdWrap($conf['slide.']['collectFuzzy'], $conf['slide.']['collectFuzzy.'])
64  : (bool)$conf['slide.']['collectFuzzy'];
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  $this->cObj->currentRecordTotal = count($records);
76  $this->getTimeTracker()->setTSlogMessage('NUMROWS: ' . count($records));
77 
79  $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
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  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'])) {
86  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'] as $_classRef) {
87  $_procObj = GeneralUtility::getUserObj($_classRef);
88  $_procObj->modifyDBRow($row, $conf['table']);
89  }
90  }
91  if (!$frontendController->recordRegister[$conf['table'] . ':' . $row['uid']]) {
92  $this->cObj->currentRecordNumber++;
93  $cObj->parentRecordNumber = $this->cObj->currentRecordNumber;
94  $frontendController->currentRecord = $conf['table'] . ':' . $row['uid'];
95  $this->cObj->lastChanged($row['tstamp']);
96  $cObj->start($row, $conf['table']);
97  $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
98  $cobjValue .= $tmpValue;
99  }
100  }
101  }
102  if ($slideCollectReverse) {
103  $theValue = $cobjValue . $theValue;
104  } else {
105  $theValue .= $cobjValue;
106  }
107  if ($slideCollect > 0) {
108  $slideCollect--;
109  }
110  if ($slide) {
111  if ($slide > 0) {
112  $slide--;
113  }
114  $conf['select.']['pidInList'] = $this->cObj->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']);
115  if (isset($conf['select.']['pidInList.'])) {
116  unset($conf['select.']['pidInList.']);
117  }
118  $again = (string)$conf['select.']['pidInList'] !== '';
119  }
120  } while ($again && $slide && ((string)$tmpValue === '' && $slideCollectFuzzy || $slideCollect));
121 
122  $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
123  if ($wrap) {
124  $theValue = $this->cObj->wrap($theValue, $wrap);
125  }
126  if (isset($conf['stdWrap.'])) {
127  $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
128  }
129  // Restore
130  $frontendController->currentRecord = $originalRec;
131  if ($originalRec) {
132  --$frontendController->recordRegister[$originalRec];
133  }
134  return $theValue;
135  }
136 
142  protected function getDatabaseConnection()
143  {
144  return $GLOBALS['TYPO3_DB'];
145  }
146 
152  protected function getFrontendController()
153  {
154  return $GLOBALS['TSFE'];
155  }
156 
162  protected function getTimeTracker()
163  {
164  return $GLOBALS['TT'];
165  }
166 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']