48 public function render($conf = [])
51 $this->itemArray = [];
55 $originalRec =
$GLOBALS[
'TSFE']->currentRecord;
59 ++
$GLOBALS[
'TSFE']->recordRegister[$originalRec];
62 $tables = isset($conf[
'tables.']) ? $this->cObj->stdWrap($conf[
'tables'], $conf[
'tables.']) : $conf[
'tables'];
64 $tablesArray = array_unique(GeneralUtility::trimExplode(
',', $tables,
true));
66 if (is_array($conf[
'conf.'])) {
67 foreach ($conf[
'conf.'] as $key => $value) {
68 if (substr($key, -1) !==
'.' && !in_array($key, $tablesArray)) {
69 $tablesArray[] = $key;
76 $source = isset($conf[
'source.']) ? $this->cObj->stdWrap($conf[
'source'], $conf[
'source.']) : $conf[
'source'];
77 $categories = isset($conf[
'categories.']) ? $this->cObj->stdWrap($conf[
'categories'], $conf[
'categories.']) : $conf[
'categories'];
79 $this->collectRecordsFromSource($source, $tablesArray);
80 } elseif ($categories) {
81 $relationField = isset($conf[
'categories.'][
'relation.']) ? $this->cObj->stdWrap($conf[
'categories.'][
'relation'], $conf[
'categories.'][
'relation.']) : $conf[
'categories.'][
'relation'];
84 $itemArrayCount = count($this->itemArray);
85 if ($itemArrayCount > 0) {
87 $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
89 $this->cObj->currentRecordNumber = 0;
90 $this->cObj->currentRecordTotal = $itemArrayCount;
91 foreach ($this->itemArray as $val) {
92 $row = $this->data[$val[
'table']][$val[
'id']];
103 if (is_array($row)) {
104 $dontCheckPid = isset($conf[
'dontCheckPid.']) ? $this->cObj->stdWrap($conf[
'dontCheckPid'], $conf[
'dontCheckPid.']) : $conf[
'dontCheckPid'];
105 if (!$dontCheckPid) {
106 $row = $this->cObj->checkPid($row[
'pid']) ? $row :
'';
108 if ($row && !
$GLOBALS[
'TSFE']->recordRegister[$val[
'table'] .
':' . $val[
'id']]) {
109 $renderObjName = $conf[
'conf.'][$val[
'table']] ?:
'<' . $val[
'table'];
110 $renderObjKey = $conf[
'conf.'][$val[
'table']] ?
'conf.' . $val[
'table'] :
'';
111 $renderObjConf = $conf[
'conf.'][$val[
'table'] .
'.'];
112 $this->cObj->currentRecordNumber++;
113 $cObj->parentRecordNumber = $this->cObj->currentRecordNumber;
114 $GLOBALS[
'TSFE']->currentRecord = $val[
'table'] .
':' . $val[
'id'];
115 $this->cObj->lastChanged($row[
'tstamp']);
118 $theValue .= $tmpValue;
124 $wrap = isset($conf[
'wrap.']) ? $this->cObj->stdWrap($conf[
'wrap'], $conf[
'wrap.']) : $conf[
'wrap'];
126 $theValue = $this->cObj->wrap($theValue, $wrap);
128 if (isset($conf[
'stdWrap.'])) {
129 $theValue = $this->cObj->stdWrap($theValue, $conf[
'stdWrap.']);
132 $GLOBALS[
'TSFE']->currentRecord = $originalRec;
134 --
$GLOBALS[
'TSFE']->recordRegister[$originalRec];
145 protected function collectRecordsFromSource($source, array $tables)
148 $loadDB = GeneralUtility::makeInstance(RelationHandler::class);
149 $loadDB->setFetchAllFields(
true);
150 $loadDB->start($source, implode(
',', $tables));
151 foreach ($loadDB->tableArray as $table => $v) {
156 $this->data = $loadDB->getFromDB();
157 reset($loadDB->itemArray);
158 $this->itemArray = $loadDB->itemArray;
170 $selectedCategories = array_unique(GeneralUtility::intExplode(
',', $selectedCategories,
true));
173 foreach ($tables as $table) {
177 $categoriesPerRecord = [];
178 foreach ($selectedCategories as $aCategory) {
186 if ($collection->count() > 0) {
188 foreach ($collection as $item) {
189 $tableRecords[$item[
'uid']] = $item;
191 if (!isset($categoriesPerRecord[$item[
'uid']])) {
192 $categoriesPerRecord[$item[
'uid']] = [];
194 $categoriesPerRecord[$item[
'uid']][] = $aCategory;
199 'Could not get records for category id %d. Error: %s (%d)',
208 if (!empty($tableRecords)) {
209 $this->data[$table] = [];
210 foreach ($tableRecords as $record) {
211 $this->itemArray[] = [
212 'id' => $record[
'uid'],
216 $record[
'_categories'] = implode(
',', $categoriesPerRecord[$record[
'uid']]);
217 $this->data[$table][$record[
'uid']] = $record;
228 return GeneralUtility::makeInstance(TimeTracker::class);
236 return $GLOBALS[
'TSFE']->sys_page ?: GeneralUtility::makeInstance(PageRepository::class);