‪TYPO3CMS  9.5
UserFileInlineLabelService.php
Go to the documentation of this file.
1 <?php
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 
22 
27 {
33  public function ‪getInlineLabel(array &$params)
34  {
35  $sysFileFields = isset($params['options']['sys_file']) && is_array($params['options']['sys_file'])
36  ? $params['options']['sys_file']
37  : [];
38 
39  if (empty($sysFileFields)) {
40  // Nothing to do
41  $params['title'] = $params['row']['uid'];
42  return;
43  }
44 
45  // In case of a group field uid_local is a resolved array
46  $fileRecord = $params['row']['uid_local'][0]['row'];
47 
48  // Configuration
49  $title = [];
50  foreach ($sysFileFields as $field) {
51  $value = '';
52  if ($field === 'title') {
53  if (isset($params['row']['title'])) {
54  $fullTitle = $params['row']['title'];
55  } else {
56  try {
57  $metaDataRepository = GeneralUtility::makeInstance(MetaDataRepository::class);
58  $metaData = $metaDataRepository->findByFileUid($fileRecord['uid']);
59  $fullTitle = $metaData['title'];
60  } catch (‪InvalidUidException $e) {
65  $fullTitle = '';
66  }
67  }
68 
69  $value = ‪BackendUtility::getRecordTitlePrep($fullTitle);
70  } else {
71  if (isset($params['row'][$field])) {
72  $value = htmlspecialchars($params['row'][$field]);
73  } elseif (isset($fileRecord[$field])) {
74  $value = ‪BackendUtility::getRecordTitlePrep($fileRecord[$field]);
75  }
76  }
77  if ((string)$value === '') {
78  continue;
79  }
80  $labelText = ‪LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file.' . $field, 'lang');
81  $title[] = '<dt>' . htmlspecialchars($labelText) . '</dt>' . '<dd>' . $value . '</dd>';
82  }
83  $params['title'] = '<dl>' . implode('', $title) . '</dl>';
84  }
85 }
‪TYPO3\CMS\Core\Resource\Index\MetaDataRepository
Definition: MetaDataRepository.php:37
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:29
‪TYPO3\CMS\Core\Resource\Exception\InvalidUidException
Definition: InvalidUidException.php:21
‪TYPO3\CMS\Core\Resource\Service
Definition: FileProcessingService.php:2
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitlePrep
‪static string getRecordTitlePrep($title, $titleLength=0)
Definition: BackendUtility.php:1883
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate($key, $extensionName=null, $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:63
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Core\Resource\Service\UserFileInlineLabelService
Definition: UserFileInlineLabelService.php:27
‪TYPO3\CMS\Core\Resource\Service\UserFileInlineLabelService\getInlineLabel
‪getInlineLabel(array &$params)
Definition: UserFileInlineLabelService.php:33
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45