TYPO3  7.6
UserFileInlineLabelService.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Resource\Service;
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 
20 
25 {
32  public function getInlineLabel(array &$params)
33  {
34  $sysFileFields = isset($params['options']['sys_file']) && is_array($params['options']['sys_file'])
35  ? $params['options']['sys_file']
36  : array();
37 
38  if (empty($sysFileFields)) {
39  // Nothing to do
40  $params['title'] = $params['row']['uid'];
41  return;
42  }
43 
44  $fileInfo = BackendUtility::splitTable_Uid($params['row']['uid_local'], 2);
45  $fileRecord = BackendUtility::getRecord($fileInfo[0], $fileInfo[1]);
46 
47  // Configuration
48  $title = array();
49  foreach ($sysFileFields as $field) {
50  $value = '';
51  if ($field === 'title') {
52  if (isset($params['row']['title'])) {
53  $fullTitle = $params['row']['title'];
54  } else {
55  try {
56  $metaDataRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Index\MetaDataRepository::class);
57  $metaData = $metaDataRepository->findByFileUid($fileRecord['uid']);
58  $fullTitle = $metaData['title'];
59  } catch (\TYPO3\CMS\Core\Resource\Exception\InvalidUidException $e) {
64  }
65  }
66 
67  $value = BackendUtility::getRecordTitlePrep(htmlspecialchars($fullTitle));
68  } else {
69  if (isset($params['row'][$field])) {
70  $value = htmlspecialchars($params['row'][$field]);
71  } elseif (isset($fileRecord[$field])) {
72  $value = BackendUtility::getRecordTitlePrep($fileRecord[$field]);
73  }
74  }
75  if ((string)$value === '') {
76  continue;
77  }
78  $labelText = LocalizationUtility::translate('LLL:EXT:lang/locallang_tca.xlf:sys_file.' . $field, 'lang');
79  $title[] = '<dt>' . htmlspecialchars($labelText) . '</dt>' . '<dd>' . $value . '</dd>';
80  }
81  $params['title'] = '<dl>' . implode('', $title) . '</dl>';
82  }
83 }