5983a06dbd962e1b96b073b16be43050a27cb7ed
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Controller / ContentElement / ElementInformationController.php
1 <?php
2 namespace TYPO3\CMS\Backend\Controller\ContentElement;
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
17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Backend\Backend\Avatar\Avatar;
20 use TYPO3\CMS\Backend\Template\ModuleTemplate;
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
22 use TYPO3\CMS\Core\Database\ConnectionPool;
23 use TYPO3\CMS\Core\Imaging\Icon;
24 use TYPO3\CMS\Core\Imaging\IconFactory;
25 use TYPO3\CMS\Core\Resource\AbstractFile;
26 use TYPO3\CMS\Core\Resource\Folder;
27 use TYPO3\CMS\Core\Resource\ResourceFactory;
28 use TYPO3\CMS\Core\Utility\GeneralUtility;
29 use TYPO3\CMS\Fluid\View\StandaloneView;
30
31 /**
32 * Script Class for showing information about an item.
33 */
34 class ElementInformationController
35 {
36 /**
37 * Record table name
38 *
39 * @var string
40 */
41 public $table;
42
43 /**
44 * Record uid
45 *
46 * @var int
47 */
48 public $uid;
49
50 /**
51 * @var string
52 */
53 protected $permsClause;
54
55 /**
56 * @var bool
57 */
58 public $access = false;
59
60 /**
61 * Which type of element:
62 * - "file"
63 * - "db"
64 *
65 * @var string
66 */
67 public $type = '';
68
69 /**
70 * @var ModuleTemplate
71 */
72 protected $moduleTemplate;
73
74 /**
75 * For type "db": Set to page record of the parent page of the item set
76 * (if type="db")
77 *
78 * @var array
79 */
80 public $pageInfo;
81
82 /**
83 * Database records identified by table/uid
84 *
85 * @var array
86 */
87 protected $row;
88
89 /**
90 * @var \TYPO3\CMS\Core\Resource\File
91 */
92 protected $fileObject;
93
94 /**
95 * @var Folder
96 */
97 protected $folderObject;
98
99 /**
100 * @var IconFactory
101 */
102 protected $iconFactory;
103
104 /**
105 * Constructor
106 */
107 public function __construct()
108 {
109 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
110 $GLOBALS['SOBE'] = $this;
111
112 $this->init();
113 }
114
115 /**
116 * Determines if table/uid point to database record or file and
117 * if user has access to view information
118 */
119 public function init()
120 {
121 $this->table = GeneralUtility::_GET('table');
122 $this->uid = GeneralUtility::_GET('uid');
123
124 $this->permsClause = $this->getBackendUser()->getPagePermsClause(1);
125 $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
126 $this->moduleTemplate->getDocHeaderComponent()->disable();
127
128 if (isset($GLOBALS['TCA'][$this->table])) {
129 $this->initDatabaseRecord();
130 } elseif ($this->table === '_FILE' || $this->table === '_FOLDER' || $this->table === 'sys_file') {
131 $this->initFileOrFolderRecord();
132 }
133 }
134
135 /**
136 * Init database records (table)
137 */
138 protected function initDatabaseRecord()
139 {
140 $this->type = 'db';
141 $this->uid = (int)$this->uid;
142
143 // Check permissions and uid value:
144 if ($this->uid && $this->getBackendUser()->check('tables_select', $this->table)) {
145 if ((string)$this->table === 'pages') {
146 $this->pageInfo = BackendUtility::readPageAccess($this->uid, $this->permsClause);
147 $this->access = is_array($this->pageInfo);
148 $this->row = $this->pageInfo;
149 } else {
150 $this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
151 if ($this->row) {
152 $this->pageInfo = BackendUtility::readPageAccess($this->row['pid'], $this->permsClause);
153 $this->access = is_array($this->pageInfo);
154 }
155 }
156 }
157 }
158
159 /**
160 * Init file/folder parameters
161 */
162 protected function initFileOrFolderRecord()
163 {
164 $fileOrFolderObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($this->uid);
165
166 if ($fileOrFolderObject instanceof Folder) {
167 $this->folderObject = $fileOrFolderObject;
168 $this->access = $this->folderObject->checkActionPermission('read');
169 $this->type = 'folder';
170 } else {
171 $this->fileObject = $fileOrFolderObject;
172 $this->access = $this->fileObject->checkActionPermission('read');
173 $this->type = 'file';
174 $this->table = 'sys_file';
175
176 try {
177 $this->row = BackendUtility::getRecordWSOL($this->table, $fileOrFolderObject->getUid());
178 } catch (\Exception $e) {
179 $this->row = [];
180 }
181 }
182 }
183
184 /**
185 * Injects the request object for the current request or subrequest
186 * As this controller goes only through the main() method, it is rather simple for now
187 *
188 * @param ServerRequestInterface $request the current request
189 * @param ResponseInterface $response
190 * @return ResponseInterface the response with the content
191 */
192 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
193 {
194 $this->main();
195
196 $response->getBody()->write($this->moduleTemplate->renderContent());
197 return $response;
198 }
199
200 /**
201 * Compiles the whole content to be outputted, which is then set as content to the moduleTemplate
202 * There is a hook to do a custom rendering of a record.
203 */
204 public function main()
205 {
206 if (!$this->access) {
207 return;
208 }
209
210 $content = '';
211
212 // render type by user func
213 $typeRendered = false;
214 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/show_item.php']['typeRendering'] ?? [] as $className) {
215 $typeRenderObj = GeneralUtility::makeInstance($className);
216 if (is_object($typeRenderObj) && method_exists($typeRenderObj, 'isValid') && method_exists($typeRenderObj, 'render')) {
217 if ($typeRenderObj->isValid($this->type, $this)) {
218 $content .= $typeRenderObj->render($this->type, $this);
219 $typeRendered = true;
220 break;
221 }
222 }
223 }
224
225 if (!$typeRendered) {
226 // Rendering of the output via fluid
227 $view = GeneralUtility::makeInstance(StandaloneView::class);
228 $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates')]);
229 $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials')]);
230 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName(
231 'EXT:backend/Resources/Private/Templates/ContentElement/ElementInformation.html'
232 ));
233 $view->assignMultiple($this->getPageTitle());
234 $view->assignMultiple($this->getPreview());
235 $view->assignMultiple($this->getPropertiesForTable());
236 $view->assignMultiple($this->getReferences());
237 $view->assignMultiple($this->getBackButton());
238 $view->assign('maxTitleLength', $this->getBackendUser()->uc['titleLen'] ?? 20);
239 $content .= $view->render();
240 }
241 $this->moduleTemplate->setContent($content);
242 }
243
244 /**
245 * Get page title with icon, table title and record title
246 *
247 * @return array
248 */
249 protected function getPageTitle() : array
250 {
251 $pageTitle = [
252 'title' => BackendUtility::getRecordTitle($this->table, $this->row, false)
253 ];
254 if ($this->type === 'folder') {
255 $pageTitle['table'] = $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:folder');
256 $pageTitle['icon'] = $this->iconFactory->getIconForResource($this->folderObject, Icon::SIZE_SMALL)->render();
257 } elseif ($this->type === 'file') {
258 $pageTitle['table'] = $this->getLanguageService()->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
259 $pageTitle['icon'] = $this->iconFactory->getIconForResource($this->fileObject, Icon::SIZE_SMALL)->render();
260 } else {
261 $pageTitle['table'] = $this->getLanguageService()->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']);
262 $pageTitle['icon'] = $this->iconFactory->getIconForRecord($this->table, $this->row, Icon::SIZE_SMALL);
263 }
264 $this->moduleTemplate->setTitle($pageTitle['table'] . ': ' . $pageTitle['title']);
265 return $pageTitle;
266 }
267
268 /**
269 * Get preview for current record
270 *
271 * @return array
272 */
273 protected function getPreview() : array
274 {
275 $preview = [];
276 // Perhaps @todo in future: Also display preview for records - without fileObject
277 if (!$this->fileObject) {
278 return $preview;
279 }
280
281 // check if file is marked as missing
282 if ($this->fileObject->isMissing()) {
283 $preview['missingFile'] =$this->fileObject->getName();
284 } else {
285 /** @var \TYPO3\CMS\Core\Resource\Rendering\RendererRegistry $rendererRegistry */
286 $rendererRegistry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::class);
287 $fileRenderer = $rendererRegistry->getRenderer($this->fileObject);
288 $fileExtension = $this->fileObject->getExtension();
289 $preview['url'] = $this->fileObject->getPublicUrl(true);
290
291 $width = '590m';
292 $heigth = '400m';
293
294 // Check if there is a FileRenderer
295 if ($fileRenderer !== null) {
296 $preview['fileRenderer'] = $fileRenderer->render(
297 $this->fileObject,
298 $width,
299 $heigth,
300 [],
301 true
302 );
303
304 // else check if we can create an Image preview
305 } elseif (GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $fileExtension)) {
306 $preview['fileObject'] = $this->fileObject;
307 $preview['width'] = $width;
308 $preview['heigth'] = $heigth;
309 }
310 }
311 return $preview;
312 }
313
314 /**
315 * Get property array for html table
316 *
317 * @return array
318 */
319 protected function getPropertiesForTable() : array
320 {
321 $propertiesForTable = [];
322 $lang = $this->getLanguageService();
323
324 $extraFields = [
325 'uid' => htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:show_item.php.uid'))
326 ];
327
328 if (in_array($this->type, ['folder', 'file'], true)) {
329 if ($this->type === 'file') {
330 $extraFields['creation_date'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.creationDate'));
331 $extraFields['modification_date'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.timestamp'));
332 if ($this->fileObject->getType() === AbstractFile::FILETYPE_IMAGE) {
333 $extraFields['width'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.width'));
334 $extraFields['height'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.height'));
335 }
336 }
337 $extraFields['storage'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file.storage'));
338 $extraFields['folder'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:folder'));
339 } else {
340 $extraFields['crdate'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.creationDate'));
341 $extraFields['cruser_id'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.creationUserId'));
342 $extraFields['tstamp'] = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.timestamp'));
343
344 // check if the special fields are defined in the TCA ctrl section of the table
345 foreach ($extraFields as $fieldName => $fieldLabel) {
346 if (isset($GLOBALS['TCA'][$this->table]['ctrl'][$fieldName])) {
347 $extraFields[$GLOBALS['TCA'][$this->table]['ctrl'][$fieldName]] = $fieldLabel;
348 } elseif ($fieldName !== 'uid') {
349 unset($extraFields[$fieldName]);
350 }
351 }
352 }
353
354 foreach ($extraFields as $name => $fieldLabel) {
355 $rowValue = '';
356 $thisRow = [];
357 if (!isset($this->row[$name])) {
358 $resourceObject = $this->fileObject ?: $this->folderObject;
359 if ($name === 'storage') {
360 $rowValue = $resourceObject->getStorage()->getName();
361 } elseif ($name === 'folder') {
362 $rowValue = $resourceObject->getParentFolder()->getReadablePath();
363 } elseif ($name === 'width') {
364 $rowValue = $this->fileObject->getProperty('width') . 'px';
365 } elseif ($name === 'height') {
366 $rowValue = $this->fileObject->getProperty('height') . 'px';
367 }
368 } elseif ($name === 'creation_date' || $name === 'modification_date') {
369 $rowValue = BackendUtility::datetime($this->row[$name]);
370 } else {
371 $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
372 }
373 $thisRow['value'] = $rowValue;
374 $thisRow['fieldLabel'] = rtrim($fieldLabel, ':');
375 // show the backend username who created the issue
376 if ($name === 'cruser_id' && $rowValue) {
377 $creatorRecord = BackendUtility::getRecord('be_users', $rowValue);
378 if ($creatorRecord) {
379 /** @var Avatar $avatar */
380 $avatar = GeneralUtility::makeInstance(Avatar::class);
381 $creatorRecord['icon'] = $avatar->render($creatorRecord);
382 $thisRow['creatorRecord'] = $creatorRecord;
383 $thisRow['value'] = '';
384 }
385 }
386 $propertiesForTable['extraFields'][] = $thisRow;
387 }
388
389 // Traverse the list of fields to display for the record:
390 $fieldList = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$this->table]['interface']['showRecordFieldList'], true);
391 foreach ($fieldList as $name) {
392 $thisRow = [];
393 $name = trim($name);
394 $uid = $this->row['uid'];
395
396 if (!isset($GLOBALS['TCA'][$this->table]['columns'][$name])) {
397 continue;
398 }
399
400 // Storage is already handled above
401 if ($this->type === 'file' && $name === 'storage') {
402 continue;
403 }
404
405 // format file size as bytes/kilobytes/megabytes
406 if ($this->type === 'file' && $name === 'size') {
407 $this->row[$name] = GeneralUtility::formatSize($this->row[$name], htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:byteSizeUnits')));
408 }
409
410 $isExcluded = !(!$GLOBALS['TCA'][$this->table]['columns'][$name]['exclude'] || $this->getBackendUser()->check('non_exclude_fields', $this->table . ':' . $name));
411 if ($isExcluded) {
412 continue;
413 }
414
415 $thisRow['fieldValue'] = BackendUtility::getProcessedValue($this->table, $name, $this->row[$name], 0, 0, false, $uid);
416 $thisRow['fieldLabel'] = htmlspecialchars($lang->sL(BackendUtility::getItemLabel($this->table, $name)));
417 $propertiesForTable['fields'][] = $thisRow;
418 }
419 return $propertiesForTable;
420 }
421
422 /**
423 * Get references section (references from and references to current record)
424 *
425 * @return array
426 */
427 protected function getReferences() : array
428 {
429 $references = [];
430 switch ($this->type) {
431 case 'db': {
432 $references['refLines'] = $this->makeRef($this->table, $this->row['uid']);
433 $references['refFromLines'] = $this->makeRefFrom($this->table, $this->row['uid']);
434 break;
435 }
436
437 case 'file': {
438 if ($this->fileObject && $this->fileObject->isIndexed()) {
439 $references['refLines'] = $this->makeRef('_FILE', $this->fileObject);
440 }
441 break;
442 }
443 }
444 return $references;
445 }
446
447 /**
448 * Get a back button, if a returnUrl was provided
449 *
450 * @return array
451 */
452 protected function getBackButton() : array
453 {
454 return ['returnUrl' => GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GET('returnUrl'))];
455 }
456
457 /**
458 * Get field name for specified table/column name
459 *
460 * @param string $tableName Table name
461 * @param string $fieldName Column name
462 * @return string label
463 */
464 public function getLabelForTableColumn($tableName, $fieldName)
465 {
466 if ($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label'] !== null) {
467 $field = $this->getLanguageService()->sL($GLOBALS['TCA'][$tableName]['columns'][$fieldName]['label']);
468 if (trim($field) === '') {
469 $field = $fieldName;
470 }
471 } else {
472 $field = $fieldName;
473 }
474 return $field;
475 }
476
477 /**
478 * Returns the record actions
479 *
480 * @param string $table
481 * @param int $uid
482 * @return array
483 */
484 protected function getRecordActions($table, $uid)
485 {
486 if ($table === '' || $uid < 0) {
487 return [];
488 }
489
490 $actions = [];
491 // Edit button
492 $urlParameters = [
493 'edit' => [
494 $table => [
495 $uid => 'edit'
496 ]
497 ],
498 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
499 ];
500 $actions['recordEditUrl'] = BackendUtility::getModuleUrl('record_edit', $urlParameters);
501
502 // History button
503 $urlParameters = [
504 'element' => $table . ':' . $uid,
505 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
506 ];
507 $actions['recordHistoryUrl'] = BackendUtility::getModuleUrl('record_history', $urlParameters);
508
509 if ($table === 'pages') {
510 // Recordlist button
511 $actions['webListUrl'] = BackendUtility::getModuleUrl('web_list', ['id' => $uid, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]);
512
513 // View page button
514 $actions['viewOnClick'] = BackendUtility::viewOnClick($uid, '', BackendUtility::BEgetRootLine($uid));
515 }
516
517 return $actions;
518 }
519
520 /**
521 * Make reference display
522 *
523 * @param string $table Table name
524 * @param string|\TYPO3\CMS\Core\Resource\File $ref Filename or uid
525 * @return array
526 */
527 protected function makeRef($table, $ref)
528 {
529 $refLines = [];
530 $lang = $this->getLanguageService();
531 // Files reside in sys_file table
532 if ($table === '_FILE') {
533 $selectTable = 'sys_file';
534 $selectUid = $ref->getUid();
535 } else {
536 $selectTable = $table;
537 $selectUid = $ref;
538 }
539 /** @var $queryBuilder \TYPO3\CMS\Core\Database\Query\QueryBuilder */
540 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
541 ->getQueryBuilderForTable('sys_refindex');
542 $rows = $queryBuilder
543 ->select('*')
544 ->from('sys_refindex')
545 ->where(
546 $queryBuilder->expr()->eq(
547 'ref_table',
548 $queryBuilder->createNamedParameter($selectTable, \PDO::PARAM_STR)
549 ),
550 $queryBuilder->expr()->eq(
551 'ref_uid',
552 $queryBuilder->createNamedParameter($selectUid, \PDO::PARAM_INT)
553 ),
554 $queryBuilder->expr()->eq(
555 'deleted',
556 $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
557 )
558 )
559 ->execute()
560 ->fetchAll();
561
562 // Compile information for title tag:
563 foreach ($rows as $row) {
564 if ($row['tablename'] === 'sys_file_reference') {
565 $row = $this->transformFileReferenceToRecordReference($row);
566 if ($row['tablename'] === null || $row['recuid'] === null) {
567 return;
568 }
569 }
570 $line = [];
571 $record = BackendUtility::getRecord($row['tablename'], $row['recuid']);
572 if ($record) {
573 $parentRecord = BackendUtility::getRecord('pages', $record['pid']);
574 $parentRecordTitle = is_array($parentRecord)
575 ? BackendUtility::getRecordTitle('pages', $parentRecord)
576 : '';
577 $urlParameters = [
578 'edit' => [
579 $row['tablename'] => [
580 $row['recuid'] => 'edit'
581 ]
582 ],
583 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
584 ];
585 $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
586 $line['url'] = $url;
587 $line['icon'] = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
588 $line['row'] = $row;
589 $line['record'] = $record;
590 $line['recordTitle'] = BackendUtility::getRecordTitle($row['tablename'], $record, false, true);
591 $line['parentRecordTitle'] = $parentRecordTitle;
592 $line['title'] = $lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']);
593 $line['labelForTableColumn'] = $this->getLabelForTableColumn($row['tablename'], $row['field']);
594 $line['actions'] = $this->getRecordActions($row['tablename'], $row['recuid']);
595 } else {
596 $line['row'] = $row;
597 $line['title'] = $lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']) ?: $row['tablename'];
598 $line['labelForTableColumn'] = $this->getLabelForTableColumn($row['tablename'], $row['field']);
599 }
600 $refLines[] = $line;
601 }
602 return $refLines;
603 }
604
605 /**
606 * Make reference display (what this elements points to)
607 *
608 * @param string $table Table name
609 * @param string $ref Filename or uid
610 * @return array
611 */
612 protected function makeRefFrom($table, $ref) : array
613 {
614 $refFromLines = [];
615 $lang = $this->getLanguageService();
616
617 /** @var $queryBuilder \TYPO3\CMS\Core\Database\Query\QueryBuilder */
618 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
619 ->getQueryBuilderForTable('sys_refindex');
620 $rows = $queryBuilder
621 ->select('*')
622 ->from('sys_refindex')
623 ->where(
624 $queryBuilder->expr()->eq(
625 'tablename',
626 $queryBuilder->createNamedParameter($table, \PDO::PARAM_STR)
627 ),
628 $queryBuilder->expr()->eq(
629 'recuid',
630 $queryBuilder->createNamedParameter($ref, \PDO::PARAM_INT)
631 )
632 )
633 ->execute()
634 ->fetchAll();
635
636 // Compile information for title tag:
637 foreach ($rows as $row) {
638 $line = [];
639 $record = BackendUtility::getRecord($row['ref_table'], $row['ref_uid']);
640 if ($record) {
641 $urlParameters = [
642 'edit' => [
643 $row['ref_table'] => [
644 $row['ref_uid'] => 'edit'
645 ]
646 ],
647 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
648 ];
649 $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
650 $line['url'] = $url;
651 $line['icon'] = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
652 $line['row'] = $row;
653 $line['record'] = $record;
654 $line['recordTitle'] = BackendUtility::getRecordTitle($row['ref_table'], $record, false, true);
655 $line['title'] = $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title']);
656 $line['labelForTableColumn'] = $this->getLabelForTableColumn($table, $row['field']);
657 $line['actions'] = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
658 } else {
659 $line['row'] = $row;
660 $line['title'] = $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title']);
661 $line['labelForTableColumn'] = $this->getLabelForTableColumn($table, $row['field']);
662 }
663 $refFromLines[] = $line;
664 }
665 return $refFromLines;
666 }
667
668 /**
669 * Convert FAL file reference (sys_file_reference) to reference index (sys_refindex) table format
670 *
671 * @param array $referenceRecord
672 * @return array
673 */
674 protected function transformFileReferenceToRecordReference(array $referenceRecord)
675 {
676 /** @var $queryBuilder \TYPO3\CMS\Core\Database\Query\QueryBuilder */
677 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
678 ->getQueryBuilderForTable('sys_file_reference');
679 $queryBuilder->getRestrictions()->removeAll();
680 $fileReference = $queryBuilder
681 ->select('*')
682 ->from('sys_file_reference')
683 ->where(
684 $queryBuilder->expr()->eq(
685 'uid',
686 $queryBuilder->createNamedParameter($referenceRecord['recuid'], \PDO::PARAM_INT)
687 )
688 )
689 ->execute()
690 ->fetch();
691
692 return [
693 'recuid' => $fileReference['uid_foreign'],
694 'tablename' => $fileReference['tablenames'],
695 'field' => $fileReference['fieldname'],
696 'flexpointer' => '',
697 'softref_key' => '',
698 'sorting' => $fileReference['sorting_foreign']
699 ];
700 }
701
702 /**
703 * Returns LanguageService
704 *
705 * @return \TYPO3\CMS\Core\Localization\LanguageService
706 */
707 protected function getLanguageService()
708 {
709 return $GLOBALS['LANG'];
710 }
711
712 /**
713 * Returns the current BE user.
714 *
715 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
716 */
717 protected function getBackendUser()
718 {
719 return $GLOBALS['BE_USER'];
720 }
721 }