‪TYPO3CMS  10.4
UserFileInlineLabelService.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 
28 {
34  public function ‪getInlineLabel(array &$params)
35  {
36  $sysFileFields = isset($params['options']['sys_file']) && is_array($params['options']['sys_file'])
37  ? $params['options']['sys_file']
38  : [];
39 
40  if (empty($sysFileFields)) {
41  // Nothing to do
42  $params['title'] = $params['row']['uid'];
43  return;
44  }
45 
46  // In case of a group field uid_local is a resolved array
47  $fileRecord = $params['row']['uid_local'][0]['row'];
48 
49  // Configuration
50  $title = [];
51  foreach ($sysFileFields as $field) {
52  $value = '';
53  if ($field === 'title') {
54  if (isset($params['row']['title'])) {
55  $fullTitle = $params['row']['title'];
56  } else {
57  try {
58  $metaDataRepository = GeneralUtility::makeInstance(MetaDataRepository::class);
59  $metaData = $metaDataRepository->findByFileUid($fileRecord['uid']);
60  $fullTitle = $metaData['title'];
61  } catch (‪InvalidUidException $e) {
66  $fullTitle = '';
67  }
68  }
69 
70  $value = ‪BackendUtility::getRecordTitlePrep($fullTitle);
71  } else {
72  if (isset($params['row'][$field])) {
73  $value = htmlspecialchars($params['row'][$field]);
74  } elseif (isset($fileRecord[$field])) {
75  $value = ‪BackendUtility::getRecordTitlePrep($fileRecord[$field]);
76  }
77  }
78  if ((string)$value === '') {
79  continue;
80  }
81  $labelText = (string)‪LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file.' . $field, 'lang');
82  $title[] = '<dt>' . htmlspecialchars($labelText) . '</dt><dd>' . $value . '</dd>';
83  }
84  $params['title'] = '<dl>' . implode('', $title) . '</dl>';
85  }
86 }
‪TYPO3\CMS\Core\Resource\Index\MetaDataRepository
Definition: MetaDataRepository.php:40
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:33
‪TYPO3\CMS\Core\Resource\Exception\InvalidUidException
Definition: InvalidUidException.php:24
‪TYPO3\CMS\Core\Resource\Service
Definition: ExtractorService.php:18
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitlePrep
‪static string getRecordTitlePrep($title, $titleLength=0)
Definition: BackendUtility.php:1614
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate(string $key, ?string $extensionName=null, array $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:67
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Core\Resource\Service\UserFileInlineLabelService
Definition: UserFileInlineLabelService.php:28
‪TYPO3\CMS\Core\Resource\Service\UserFileInlineLabelService\getInlineLabel
‪getInlineLabel(array &$params)
Definition: UserFileInlineLabelService.php:34
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46