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